Skip to content

Commit 46560c7

Browse files
committed
new utility classes to detect if a Group is polymeric, an amino acid, or a nucleotide group.
1 parent feb8fe2 commit 46560c7

4 files changed

Lines changed: 111 additions & 2 deletions

File tree

biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/StructureUtil.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,18 @@ public static List<String> getAtomNames(Group group) {
341341
* @return
342342
*/
343343
public static List<Group> getAminoAcids(Chain chain) {
344-
return chain.getAtomGroups(GroupType.AMINOACID);
344+
345+
List<Group> gs = new ArrayList<>();
346+
347+
for ( Group g : chain.getAtomGroups()){
348+
349+
if ( g.isAminoAcid())
350+
gs.add(g);
351+
352+
}
353+
354+
return gs;
355+
345356
}
346357

347358
}

biojava-modfinder/src/test/java/org/biojava/nbio/protmod/structure/ProteinModificationParserTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ public static String[][] setUpShortTest() {
115115
{"2HGD",null}, // X9Q
116116
{"3LF4",null}, // 0YG
117117

118+
// {"2BF9","AA0099"}, // TYC this one needs a fix in the CCD before it can work
119+
118120
};
119121
return strucs;
120122
}
@@ -334,7 +336,9 @@ public void testParser() throws IOException, StructureException {
334336
public void multiTest() throws IOException, StructureException {
335337
for ( String[] name : strucs){
336338
parserTest(name[0], (String)null);
337-
parserTest(name[0], name[1]);
339+
340+
if ( name[1] != null)
341+
parserTest(name[0], name[1]);
338342

339343
}
340344
}
@@ -408,6 +412,7 @@ private void printResult(String pdbId, ProteinModificationIdentifier parser, boo
408412
for (ModifiedCompound mc : mcs) {
409413
sb.append("Modification #");
410414
sb.append(++i);
415+
sb.append(" ").append(mc.getDescription()).append(" ").append(mc.getModification().getId());
411416
sb.append(":\n");
412417
sb.append(mc.getAtomLinkages());
413418
sb.append('\n');

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,29 @@ public interface Group {
178178
*/
179179
public boolean hasAminoAtoms() ;
180180

181+
182+
/** tests in the Chemical Component Dictionary, if this group is a polymeric group
183+
*
184+
* @return true if a polymeric group
185+
*/
186+
public boolean isPolymeric();
187+
188+
189+
/** Tests in the Chemical Component Dictionary, if this group is an amino acid
190+
*
191+
* @return true if an amino acid
192+
*/
193+
public boolean isAminoAcid();
194+
195+
196+
/** Tests in the Chemical Component Dictionary, if this group is a nucleotide
197+
*
198+
* @return true if a nucleotide
199+
*/
200+
public boolean isNucleotide();
201+
202+
203+
181204
/**
182205
* Properties of this amino acid. Currently available properties are:
183206
* phi

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

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
import org.biojava.nbio.structure.io.GroupToSDF;
2727
import org.biojava.nbio.structure.io.mmcif.ChemCompGroupFactory;
28+
import org.biojava.nbio.structure.io.mmcif.chem.PolymerType;
29+
import org.biojava.nbio.structure.io.mmcif.chem.ResidueType;
2830
import org.biojava.nbio.structure.io.mmcif.model.ChemComp;
2931
import org.slf4j.Logger;
3032
import org.slf4j.LoggerFactory;
@@ -327,6 +329,71 @@ public boolean hasAminoAtoms(){
327329

328330
}
329331

332+
@Override
333+
public boolean isPolymeric() {
334+
335+
ChemComp cc = getChemComp();
336+
337+
if ( cc == null)
338+
return getType().equals(GroupType.AMINOACID) || getType().equals(GroupType.NUCLEOTIDE);
339+
340+
ResidueType rt = cc.getResidueType();
341+
342+
if ( rt.equals(ResidueType.nonPolymer))
343+
return false;
344+
345+
PolymerType pt = rt.getPolymerType();
346+
347+
return pt.equals(PolymerType.peptide) ||
348+
pt.equals(PolymerType.dna) ||
349+
pt.equals(PolymerType.rna) ||
350+
pt.equals(PolymerType.dnarna);
351+
352+
353+
}
354+
355+
@Override
356+
public boolean isAminoAcid() {
357+
358+
ChemComp cc = getChemComp();
359+
360+
if ( cc == null)
361+
return getType().equals(GroupType.AMINOACID);
362+
363+
364+
ResidueType rt = cc.getResidueType();
365+
366+
if ( rt.equals(ResidueType.nonPolymer))
367+
return false;
368+
369+
PolymerType pt = rt.getPolymerType();
370+
371+
return pt.equals(PolymerType.peptide);
372+
373+
}
374+
375+
@Override
376+
public boolean isNucleotide() {
377+
378+
ChemComp cc = getChemComp();
379+
380+
if ( cc == null)
381+
return getType().equals(GroupType.NUCLEOTIDE);
382+
383+
ResidueType rt = cc.getResidueType();
384+
385+
if ( rt.equals(ResidueType.nonPolymer))
386+
return false;
387+
388+
PolymerType pt = rt.getPolymerType();
389+
390+
return pt.equals(PolymerType.dna) ||
391+
pt.equals(PolymerType.rna) ||
392+
pt.equals(PolymerType.dnarna) ;
393+
394+
395+
}
396+
330397

331398
/**
332399
* {@inheritDoc}
@@ -604,4 +671,7 @@ public void setHetAtomInFile(boolean isHetAtomInFile) {
604671
this.isHetAtomInFile = isHetAtomInFile;
605672
}
606673

674+
675+
676+
607677
}

0 commit comments

Comments
 (0)