Skip to content

Commit 50ed273

Browse files
committed
Merge branch 'master' of github.com:biojava/biojava
* 'master' of github.com:biojava/biojava: [maven-release-plugin]prepare for next development iteration [maven-release-plugin]prepare release biojava-5.0.0-alpha6 Fixed the logic of working out which type of group a group is. Fixed a typo Immutability test fails with Cobertura instrumented classes Fixed the formatting and added some javadocs Upgrade to v1.0.0 Fixed handling of entities with no chains Fixed a null pointer exception from getAtomFromRecord Added handling of different residue types. Fixed a bug in generation of disulphide bonds - including a test case. Added support for D-GAMMA-PEPTIDE being a heatatm (as with mmCIF) not an amino. # Conflicts: # biojava-sequencing/src/test/java/org/biojava/nbio/sequencing/io/fastq/FastqTest.java
2 parents 25a220a + 2a14437 commit 50ed273

5 files changed

Lines changed: 85 additions & 39 deletions

File tree

biojava-structure/src/main/java/org/biojava/nbio/structure/io/BondMaker.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,10 @@ private void formDisulfideBond(SSBondImpl disulfideBond) {
281281
if(a.containsKey(i) && b.containsKey(i)){
282282
// TODO determine what the actual bond order of this bond is; for
283283
// now, we're assuming they're single bonds
284-
Bond ssbond = new BondImpl(a.get(i), b.get(i), 1);
285-
structure.addSSBond(ssbond);
284+
if(!a.get(i).equals(b.get(i))){
285+
Bond ssbond = new BondImpl(a.get(i), b.get(i), 1);
286+
structure.addSSBond(ssbond);
287+
}
286288
}
287289
}
288290

@@ -322,7 +324,9 @@ public void formLinkRecordBond(LinkRecord linkRecord) {
322324
if(a.containsKey(i) && b.containsKey(i)){
323325
// TODO determine what the actual bond order of this bond is; for
324326
// now, we're assuming they're single bonds
325-
new BondImpl(a.get(i), b.get(i), 1);
327+
if(!a.get(i).equals(b.get(i))){
328+
new BondImpl(a.get(i), b.get(i), 1);
329+
}
326330
}
327331
}
328332
}catch (StructureException e) {
@@ -336,7 +340,7 @@ public void formLinkRecordBond(LinkRecord linkRecord) {
336340
}
337341
}
338342

339-
343+
340344
public void formBondsFromStructConn(List<StructConn> structConn) {
341345

342346
final String symop = "1_555"; // For now - accept bonds within origin asymmetric unit.
@@ -413,7 +417,9 @@ public void formBondsFromStructConn(List<StructConn> structConn) {
413417
for(int i=0; i<structure.nrModels(); i++){
414418
Bond bond = null;
415419
if(a1.containsKey(i) && a2.containsKey(i)){
416-
bond = new BondImpl(a1.get(i), a2.get(i), 1);
420+
if(!a1.get(i).equals(a2.get(i))){
421+
bond = new BondImpl(a1.get(i), a2.get(i), 1);
422+
}
417423
}
418424
if(bond!=null){
419425
if (conn.getConn_type_id().equals("disulf")) {
@@ -448,7 +454,10 @@ private Map<Integer,Atom> getAtomFromRecord(String name, String altLoc, String r
448454
if (g==null)
449455
throw new StructureException("Could not find altLoc code "+altLoc+" in group "+resSeq+iCode+" of chain "+ chainID);
450456
}
451-
outMap.put(i,g.getAtom(name));
457+
Atom a = g.getAtom(name);
458+
if (a!=null){
459+
outMap.put(i,a);
460+
}
452461
}
453462
return outMap;
454463
}

biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfStructureReader.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.biojava.nbio.structure.Structure;
3030
import org.biojava.nbio.structure.StructureImpl;
3131
import org.biojava.nbio.structure.StructureTools;
32+
import org.biojava.nbio.structure.io.mmcif.chem.PolymerType;
3233
import org.biojava.nbio.structure.io.mmcif.chem.ResidueType;
3334
import org.biojava.nbio.structure.io.mmcif.model.ChemComp;
3435
import org.biojava.nbio.structure.quaternary.BioAssemblyInfo;
@@ -185,7 +186,8 @@ public void setGroupInfo(String groupName, int groupNumber,
185186
char insertionCode, String chemCompType, int atomCount, int bondCount,
186187
char singleLetterCode, int sequenceIndexId, int secStructType) {
187188
// Get the polymer type
188-
int polymerType = getGroupTypIndicator(chemCompType);
189+
ResidueType residueType = ResidueType.getResidueTypeFromString(chemCompType);
190+
int polymerType = getGroupTypIndicator(residueType.polymerType);
189191
switch (polymerType) {
190192
case 1:
191193
AminoAcid aa = new AminoAcidImpl();
@@ -204,7 +206,6 @@ public void setGroupInfo(String groupName, int groupNumber,
204206
ChemComp chemComp = new ChemComp();
205207
chemComp.setOne_letter_code(String.valueOf(singleLetterCode));
206208
chemComp.setType(chemCompType.toUpperCase());
207-
ResidueType residueType = ResidueType.getResidueTypeFromString(chemCompType);
208209
chemComp.setResidueType(residueType);
209210
chemComp.setPolymerType(residueType.polymerType);
210211
group.setChemComp(chemComp);
@@ -400,24 +401,14 @@ public void setXtalInfo(String spaceGroupString, float[] unitCell, double[][] nc
400401
* @param currentGroup
401402
* @return The type of group. (0,1 or 2) depending on whether it is an amino aicd (1), nucleic acid (2) or ligand (0)
402403
*/
403-
private int getGroupTypIndicator(String currentGroupType) {
404-
// At the moment - peptide like is a HETATM group (consistent with biojava)
405-
if("PEPTIDE-LIKE".equalsIgnoreCase(currentGroupType)){
406-
return 0;
407-
}
408-
// Again to correspond with Biojava - but I suspect we really want this to be 1
409-
if("D-PEPTIDE LINKING".equalsIgnoreCase(currentGroupType)){
410-
return 0;
411-
}
412-
if(currentGroupType.toUpperCase().contains("PEPTIDE")){
404+
private int getGroupTypIndicator(PolymerType polymerType) {
405+
if(PolymerType.PROTEIN_ONLY.contains(polymerType)){
413406
return 1;
414407
}
415-
if(currentGroupType.toUpperCase().contains("DNA") || currentGroupType.toUpperCase().contains("RNA")){
408+
if(PolymerType.POLYNUCLEOTIDE_ONLY.contains(polymerType)){
416409
return 2;
417410
}
418-
else{
419-
return 0;
420-
}
411+
return 0;
421412
}
422413

423414

biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfStructureWriter.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,22 +159,25 @@ private void storeEntityInformation(List<Chain> allChains, List<EntityInfo> enti
159159
if (entityChains.isEmpty()){
160160
// Error mapping chain to entity
161161
System.err.println("ERROR MAPPING CHAIN TO ENTITY: "+description);
162+
mmtfDecoderInterface.setEntityInfo(new int[0], "", description, type);
162163
continue;
163164
}
164-
int[] chainIndices = new int[entityChains.size()];
165-
for (int i=0; i<entityChains.size(); i++) {
166-
chainIndices[i] = allChains.indexOf(entityChains.get(i));
167-
}
168-
Chain chain = entityChains.get(0);
169-
ChainImpl chainImpl;
170-
if (chain instanceof ChainImpl){
171-
chainImpl = (ChainImpl) entityChains.get(0);
172-
}
173165
else{
174-
throw new RuntimeException();
166+
int[] chainIndices = new int[entityChains.size()];
167+
for (int i=0; i<entityChains.size(); i++) {
168+
chainIndices[i] = allChains.indexOf(entityChains.get(i));
169+
}
170+
Chain chain = entityChains.get(0);
171+
ChainImpl chainImpl;
172+
if (chain instanceof ChainImpl){
173+
chainImpl = (ChainImpl) entityChains.get(0);
174+
}
175+
else{
176+
throw new RuntimeException();
177+
}
178+
String sequence = chainImpl.getSeqResOneLetterSeq();
179+
mmtfDecoderInterface.setEntityInfo(chainIndices, sequence, description, type);
175180
}
176-
String sequence = chainImpl.getSeqResOneLetterSeq();
177-
mmtfDecoderInterface.setEntityInfo(chainIndices, sequence, description, type);
178181
}
179182
}
180183

biojava-structure/src/test/java/org/biojava/nbio/structure/TestBond.java

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,37 @@ private int testMissingBonds(String pdbId) throws IOException, StructureExceptio
228228
}
229229
}
230230
return nonBondedCounter;
231+
}
231232

233+
private int testBondedToSelf(String pdbId) throws IOException, StructureException {
234+
Structure inputStructure = StructureIO.getStructure(pdbId);
235+
int bondedToSelf =0;
236+
for(int i=0;i<inputStructure.nrModels();i++){
237+
for(Chain c: inputStructure.getChains(i)){
238+
for(Group g: c.getAtomGroups()){
239+
// Skip single atom groups
240+
if(g.size()<=1){
241+
continue;
242+
}
243+
// Get all the atoms
244+
List<Atom> atomsList = new ArrayList<>(g.getAtoms());
245+
for(Group altLocOne: g.getAltLocs()){
246+
atomsList.addAll(altLocOne.getAtoms());
247+
}
248+
// Check they all have bonds
249+
for(Atom a: atomsList){
250+
if(a.getBonds()!=null){
251+
for(Bond b: a.getBonds()){
252+
if(b.getAtomA().equals(b.getAtomB())){
253+
bondedToSelf+=1;
254+
}
255+
}
256+
}
257+
}
258+
}
259+
}
260+
}
261+
return bondedToSelf;
232262
}
233263

234264

@@ -263,8 +293,8 @@ public void test1BDX() throws IOException, StructureException {
263293

264294
/**
265295
* Test that all the atoms in deuterated structures are bonded.
266-
* @throws IOException
267-
* @throws StructureException
296+
* @throws IOException an error getting the required file
297+
* @throws StructureException an error parsing the required file
268298
*/
269299
@Test
270300
public void testDeuterated() throws IOException, StructureException {
@@ -278,12 +308,25 @@ public void testDeuterated() throws IOException, StructureException {
278308
/**
279309
* Test this weird case - with missing Oxygen atoms, alternate locations on Deuterium
280310
* and terminal hydrogens.
281-
* @throws IOException
282-
* @throws StructureException
311+
* @throws IOException an error getting the required file
312+
* @throws StructureException an error parsing the required file
283313
*/
284314
@Test
285315
public void testWeirdCase() throws IOException, StructureException {
286316
assertEquals(testMissingBonds("1IU6"),6);
287317
}
288318

319+
320+
/**
321+
* Test that Sulphur atoms are not found to be bonded to themselves
322+
* @throws IOException an error getting the required file
323+
* @throws StructureException an error parsing the required file
324+
*/
325+
@Test
326+
public void testSSBonds() throws IOException, StructureException {
327+
for(String pdbCode : new String[]{"3ZXW","1NTY", "4H2I", "2K6D", "2MLM"}){
328+
assertEquals(testBondedToSelf(pdbCode),0);
329+
}
330+
}
331+
289332
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3838
<project.build.targetEncoding>UTF-8</project.build.targetEncoding>
3939
<maxmem>512M</maxmem>
40-
<mmtf.version>0.2.2</mmtf.version>
40+
<mmtf.version>1.0.0</mmtf.version>
4141
<slf4j.version>1.7.21</slf4j.version>
4242
<log4j.version>2.6.1</log4j.version>
4343
</properties>

0 commit comments

Comments
 (0)