Skip to content

Commit c561c3a

Browse files
committed
Allowing detection of PTMs that interact with Terbium, as reported by @epeisach . Also less verbose PTM junit test.
1 parent 57f456b commit c561c3a

File tree

7 files changed

+99
-22
lines changed

7 files changed

+99
-22
lines changed

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

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void setbondLengthTolerance(final double bondLengthTolerance) {
9595

9696
/**
9797
*
98-
* @param recordUnidentifiableAtomLinkages true if choosing to record unidentifiable
98+
* @param recordUnidentifiableModifiedCompounds true if choosing to record unidentifiable
9999
* atoms; false, otherwise.
100100
* @see #getRecordUnidentifiableCompounds
101101
* @see #getUnidentifiableModifiedResidues
@@ -266,17 +266,15 @@ public void identify(final List<Chain> chains,
266266
return;
267267
}
268268

269-
Map<String, Chain> mapChainIdChain = new HashMap<String, Chain>(chains.size());
269+
270270
residues = new ArrayList<Group>();
271271
List<Group> ligands = new ArrayList<Group>();
272272
Map<Component, Set<Group>> mapCompGroups = new HashMap<Component, Set<Group>>();
273273

274274
for (Chain chain : chains) {
275-
mapChainIdChain.put(chain.getName(), chain);
276275

277276
List<Group> ress = StructureUtil.getAminoAcids(chain);
278277

279-
280278
//List<Group> ligs = chain.getAtomLigands();
281279
List<Group> ligs = StructureTools.filterLigands(chain.getAtomGroups());
282280
residues.addAll(ress);
@@ -318,7 +316,7 @@ public void identify(final List<Chain> chains,
318316
if (recordAdditionalAttachments) {
319317
// identify additional groups that are not directly attached to amino acids.
320318
for (ModifiedCompound mc : modComps) {
321-
identifyAdditionalAttachments(mc, ligands, mapChainIdChain);
319+
identifyAdditionalAttachments(mc, ligands, chains);
322320
}
323321
}
324322

@@ -378,12 +376,13 @@ private void processCrosslink1(Map<Component, Set<Group>> mapCompGroups,
378376

379377
/**
380378
* identify additional groups that are not directly attached to amino acids.
381-
* @param mc {@link ModifiedCompound}.
382-
* @param chain a {@link Chain}.
383-
* @return a list of added groups.
379+
* @param mc {@link ModifiedCompound}
380+
* @param ligands {@link Group}
381+
* @param chains List of {@link Chain}s
382+
* @return a list of added groups
384383
*/
385384
private void identifyAdditionalAttachments(ModifiedCompound mc,
386-
List<Group> ligands, Map<String, Chain> mapChainIdChain) {
385+
List<Group> ligands, List<Chain> chains) {
387386
if (ligands.isEmpty()) {
388387
return;
389388
}
@@ -406,7 +405,9 @@ private void identifyAdditionalAttachments(ModifiedCompound mc,
406405
resNum.setSeqNum(num.getResidueNumber());
407406
resNum.setInsCode(num.getInsCode());
408407
//group = chain.getGroupByPDB(numIns);
409-
group = mapChainIdChain.get(num.getChainId()).getGroupByPDB(resNum);
408+
409+
group = getGroup(num,chains);
410+
//group = mapChainIdChain.get(num.getChainId()).getGroupByPDB(resNum);
410411
} catch (StructureException e) {
411412
logger.error("Exception: ", e);
412413
// should not happen
@@ -442,6 +443,23 @@ private void identifyAdditionalAttachments(ModifiedCompound mc,
442443
}
443444
}
444445

446+
private Group getGroup(StructureGroup num, List<Chain> chains) throws StructureException {
447+
for (Chain c : chains){
448+
if ( c.getId().equals(num.getChainId())){
449+
450+
ResidueNumber resNum = new ResidueNumber();
451+
452+
resNum.setSeqNum(num.getResidueNumber());
453+
resNum.setInsCode(num.getInsCode());
454+
455+
456+
return c.getGroupByPDB(resNum);
457+
}
458+
}
459+
460+
throw new StructureException("Could not find residue " + num);
461+
}
462+
445463
/**
446464
* Merge identified modified compounds if linked.
447465
*/
@@ -547,6 +565,8 @@ private void recordUnidentifiableModifiedResidues(List<ModifiedCompound> modComp
547565
if (group.getType().equals(GroupType.HETATM)) {
548566
StructureGroup strucGroup = StructureUtil.getStructureGroup(
549567
group, true);
568+
strucGroup.setChainId(group.getChainId());
569+
550570
if (!identifiedComps.contains(strucGroup)) {
551571
unidentifiableModifiedResidues.add(strucGroup);
552572
}
@@ -777,13 +797,12 @@ private List<List<Atom[]>> getMatchedAtomsOfLinkages(
777797
return matchedAtomsOfLinkages;
778798
}
779799

780-
/**
781-
* Assembly the matched linkages.
800+
/** Assembly the matched linkages
801+
*
782802
* @param matchedAtomsOfLinkages
783803
* @param mod
784-
* @param condition
785-
* @param ret ModifiedCompound will be stored here.
786-
*/
804+
* @param ret ModifiedCompound will be stored here
805+
*/
787806
private void assembleLinkages(List<List<Atom[]>> matchedAtomsOfLinkages,
788807
ProteinModification mod, List<ModifiedCompound> ret) {
789808
ModificationCondition condition = mod.getCondition();

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ public static StructureGroup getStructureGroup(Group group, boolean isAminoAcid)
5353
* @return the {@link StructureAtom} of the atom.
5454
*/
5555
public static StructureAtom getStructureAtom(Atom atom, boolean isParentAminoAcid) {
56-
StructureGroup strucGroup = getStructureGroup(atom.getGroup(), isParentAminoAcid);
56+
57+
Group g = atom.getGroup();
58+
String chainId = g.getChainId();
59+
StructureGroup strucGroup = getStructureGroup(g, isParentAminoAcid);
60+
strucGroup.setChainId(chainId);
5761
return new StructureAtom(strucGroup, atom.getName());
5862
}
5963

@@ -104,6 +108,8 @@ public static double getAtomDistance(Atom atom1, Atom atom2) {
104108
public static Atom[] findNearestAtomLinkage(final Group group1, final Group group2,
105109
List<String> potentialNamesOfAtomOnGroup1, List<String> potentialNamesOfAtomOnGroup2,
106110
final boolean ignoreNCLinkage, double bondLengthTolerance) {
111+
112+
107113
List<Atom[]> linkages = findAtomLinkages(group1, group2,
108114
potentialNamesOfAtomOnGroup1, potentialNamesOfAtomOnGroup2,
109115
ignoreNCLinkage, bondLengthTolerance);
@@ -216,19 +222,28 @@ public static List<Atom[]> findAtomLinkages(final Group group1,
216222
public static Atom[] findLinkage(final Group group1, final Group group2,
217223
String nameOfAtomOnGroup1, String nameOfAtomOnGroup2,
218224
double bondLengthTolerance) {
219-
Atom[] ret = new Atom[2];
220-
double distance;
221225

226+
Atom[] ret = new Atom[2];
222227

223228
ret[0] = group1.getAtom(nameOfAtomOnGroup1);
224229
ret[1] = group2.getAtom(nameOfAtomOnGroup2);
230+
225231
if (ret[0]==null || ret[1]==null) {
226232
return null;
227233
}
228234

229-
distance = Calc.getDistance(ret[0], ret[1]);
230235

236+
Atom a1 = ret[0];
237+
Atom a2 = ret[1];
238+
239+
boolean hasBond = a1.hasBond(a2);
231240

241+
if ( hasBond ) {
242+
243+
return ret;
244+
}
245+
246+
double distance = Calc.getDistance(a1,a2);
232247

233248
float radiusOfAtom1 = ret[0].getElement().getCovalentRadius();
234249
float radiusOfAtom2 = ret[1].getElement().getCovalentRadius();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public List<ModifiedCompound> testXMLSerialization(String pdbId){
164164
}
165165
}
166166
} catch (Exception e){
167+
logger.error(e.getMessage(),e);
167168
logger.error("Error when serializing {}", pdbId);
168169
logger.error(currentMC.getDescription());
169170
logger.error(xml, e);

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ public static String[][] setUpShortTest() {
9090
{"3H8L", "AA0513"}, // CYS-S3H-CYS
9191
{"1CAD", null}, // FE and 4 Cys, cross-link4
9292

93+
// Terbium
94+
{"1NCZ", null},
95+
//{"3LTQ",null}, has metalc, we ignore those for now
96+
// {"4ESQ",null},
97+
// {"1TJB",null},
98+
// {"2V15",null},
99+
// {"2K61",null},
100+
93101
};
94102
return strucs;
95103
}
@@ -285,6 +293,14 @@ public static String[][] setUpLongTest() {
285293
{"3EE4", "AA0490"}, // VAL-TYR
286294
{"3H8L", "AA0513"}, // CYS-S3H-CYS
287295
{"1CAD", null}, // FE and 4 Cys, cross-link4
296+
297+
// Terbium
298+
{"1NCZ", null},
299+
{"3LTQ",null},
300+
{"4ESQ",null},
301+
{"1TJB",null},
302+
{"2V15",null},
303+
{"2K61",null},
288304
};
289305
return strucs;
290306
}
@@ -324,8 +340,10 @@ private void parserTest(String pdbId, Set<ProteinModification> mods) throws IOEx
324340

325341
parser.identify(struc, mods);
326342

327-
if (! parser.getIdentifiedModifiedCompound().isEmpty() ){
328-
logger.warn("Did not identify any modified compounds for {}", pdbId);
343+
if ( parser.getIdentifiedModifiedCompound().isEmpty() ){
344+
String msg = "Did not identify any modified compounds for " + pdbId;
345+
logger.warn(msg);
346+
fail(msg);
329347
}
330348

331349
assertFalse("Did not identify any modified compounds for " + pdbId ,
@@ -350,7 +368,7 @@ private void printResult(String pdbId, ProteinModificationIdentifier parser, boo
350368
sb.append("Modification #");
351369
sb.append(++i);
352370
sb.append(":\n");
353-
sb.append(mc);
371+
sb.append(mc.getAtomLinkages());
354372
sb.append('\n');
355373
}
356374

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class TmpAtomCache
3636
FileParsingParameters params = new FileParsingParameters();
3737
params.setAlignSeqRes(true);
3838
params.setParseSecStruc(false);
39+
params.setCreateAtomBonds(true);
3940
cache.setFetchBehavior(FetchBehavior.FETCH_REMEDIATED);
4041
cache.setFileParsingParams(params);
4142
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ public interface Atom extends Cloneable, PDBRecord {
225225
*/
226226
public void setBonds(List<Bond> bonds);
227227

228+
229+
/** Test if another atom has a bond to this atom
230+
*
231+
* @param other
232+
* @return
233+
*/
234+
public boolean hasBond(Atom other);
235+
228236
/**
229237
* Get the charge of this atom
230238
*

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,21 @@ public List<Bond> getBonds() {
266266
return bonds;
267267
}
268268

269+
/**
270+
* {@inheritDoc}
271+
*/
272+
@Override
273+
public boolean hasBond(Atom other){
274+
if ( bonds == null)
275+
return false;
276+
277+
for (Bond b : bonds){
278+
if ( b.getAtomA().equals(other) || b.getAtomB().equals(other))
279+
return true;
280+
}
281+
return false;
282+
}
283+
269284
/**
270285
* {@inheritDoc}
271286
*/

0 commit comments

Comments
 (0)