Skip to content

Commit 6f70909

Browse files
committed
More parsing fixes, biojava#305
1 parent 55af360 commit 6f70909

4 files changed

Lines changed: 24 additions & 3 deletions

File tree

biojava-structure/src/main/java/org/biojava/nbio/structure/Compound.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@ private void initResSerialsMap(Chain c) {
510510
logger.warn("No SEQRES groups found in chain {}, will use residue numbers as given (no insertion codes, not necessarily aligned). "
511511
+ "Make sure your structure has SEQRES records and that you use FileParsingParameters.setAlignSeqRes(true)",
512512
c.getChainID());
513+
// we add a explicit null to the map so that we flag it as unavailable for this chain
514+
chains2pdbResNums2ResSerials.put(c.getChainID(), null);
513515
return;
514516
}
515517

biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,4 +1718,17 @@ public static boolean isChainWaterOnly(Chain c) {
17181718
return waterOnly;
17191719
}
17201720

1721+
/**
1722+
* Returns true if the given chain is composed of non-polymeric groups only
1723+
* @param c
1724+
* @return
1725+
*/
1726+
public static boolean isChainPureNonPolymer(Chain c) {
1727+
1728+
for (Group g: c.getAtomGroups()) {
1729+
if (g.getType() == GroupType.AMINOACID || g.getType() == GroupType.NUCLEOTIDE) return false;
1730+
1731+
}
1732+
return true;
1733+
}
17211734
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,6 +2139,10 @@ private void pdb_MODEL_Handler(String line) {
21392139
logger.warn("Chain {} ({} atom groups) is composed of water molecules only. Removing it.",
21402140
c.getChainID(), c.getAtomGroups().size());
21412141
it.remove();
2142+
} else if (StructureTools.isChainPureNonPolymer(c)) {
2143+
logger.warn("Chain {} ({} atom groups) is composed of non-polymer molecules only. Removing it.",
2144+
c.getChainID(), c.getAtomGroups().size());
2145+
it.remove();
21422146
}
21432147
}
21442148
structure.addModel(current_model);
@@ -2922,6 +2926,10 @@ private void triggerEndFileChecks(){
29222926
logger.warn("Chain {} ({} atom groups) is composed of water molecules only. Removing it.",
29232927
c.getChainID(), c.getAtomGroups().size());
29242928
it.remove();
2929+
} else if (StructureTools.isChainPureNonPolymer(c)) {
2930+
logger.warn("Chain {} ({} atom groups) is composed of non-polymer molecules only. Removing it.",
2931+
c.getChainID(), c.getAtomGroups().size());
2932+
it.remove();
29252933
}
29262934
}
29272935
structure.addModel(current_model);

biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifConsumer.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,14 +748,12 @@ public void documentEnd() {
748748
it = pdbChains.iterator();
749749
while (it.hasNext()) {
750750
Chain chain = it.next();
751-
GroupType predominantGroupType = StructureTools.getPredominantGroupType(chain);
752751
if (StructureTools.isChainWaterOnly(chain)) {
753752
it.remove();
754753
logger.warn("Chain with chain id {} (asym id {}) and {} residues, contains only waters. Will ignore the chain because it doesn't fit into the BioJava structure data model.",
755754
chain.getChainID(),chain.getInternalChainID(),chain.getAtomGroups().size());
756755
}
757-
else if (predominantGroupType != GroupType.AMINOACID &&
758-
predominantGroupType!=GroupType.NUCLEOTIDE ) {
756+
else if (StructureTools.isChainPureNonPolymer(chain) ) {
759757
logger.warn("Chain with chain id {} (asym id {}) and {} residues, does not seem to be polymeric. Will ignore the chain because it doesn't fit into the BioJava structure data model.",
760758
chain.getChainID(),chain.getInternalChainID(),chain.getAtomGroups().size());
761759
it.remove();

0 commit comments

Comments
 (0)