Skip to content

Commit f8ac919

Browse files
committed
Adds a new definitions file so the code can correctly detect Metal bonds. Slightly more efficient representation of standard amino acids.
1 parent 849001f commit f8ac919

File tree

10 files changed

+457
-181
lines changed

10 files changed

+457
-181
lines changed

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

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@
2525
package org.biojava.nbio.protmod.structure;
2626

2727
import org.biojava.nbio.structure.*;
28+
import org.biojava.nbio.structure.io.mmcif.MetalBondParser;
29+
import org.biojava.nbio.structure.io.mmcif.chem.MetalBondDistance;
2830

2931
import java.util.ArrayList;
3032
import java.util.Collections;
3133
import java.util.List;
34+
import java.util.Map;
3235

3336
public final class StructureUtil {
3437
private StructureUtil() {
@@ -242,18 +245,74 @@ public static Atom[] findLinkage(final Group group1, final Group group2,
242245

243246
return ret;
244247
}
245-
248+
249+
// is it a metal ?
250+
251+
if ( a1.getElement().isMetal() || a2.getElement().isMetal()){
252+
253+
MetalBondDistance defined = getMetalDistanceCutoff(a1.getName(),a2.getName());
254+
255+
if ( defined != null) {
256+
257+
if (hasMetalBond(a1, a2, defined))
258+
return ret;
259+
else
260+
return null;
261+
}
262+
263+
}
264+
265+
// not a metal
266+
267+
double distance = Calc.getDistance(a1, a2);
268+
269+
float radiusOfAtom1 = ret[0].getElement().getCovalentRadius();
270+
float radiusOfAtom2 = ret[1].getElement().getCovalentRadius();
271+
272+
if (Math.abs(distance - radiusOfAtom1 - radiusOfAtom2)
273+
> bondLengthTolerance) {
274+
return null;
275+
}
276+
277+
278+
return ret;
279+
}
280+
281+
private static boolean hasMetalBond(Atom a1, Atom a2, MetalBondDistance definition) {
282+
246283
double distance = Calc.getDistance(a1,a2);
247284

248-
float radiusOfAtom1 = ret[0].getElement().getCovalentRadius();
249-
float radiusOfAtom2 = ret[1].getElement().getCovalentRadius();
285+
Float min = definition.getLowerLimit();
286+
Float max = definition.getUpperLimit();
287+
288+
return ( min < distance && max > distance);
289+
290+
}
291+
292+
private static MetalBondDistance getMetalDistanceCutoff(String name1, String name2) {
293+
Map<String,List<MetalBondDistance>> defs= MetalBondParser.getMetalBondDefinitions();
250294

251-
if (Math.abs(distance-radiusOfAtom1 -radiusOfAtom2)
252-
> bondLengthTolerance) {
295+
List<MetalBondDistance> distances = defs.get(name1);
296+
297+
if ( distances == null){
298+
299+
distances = defs.get(name2);
300+
String tmp = name1;
301+
name2 = name1;
302+
name1 = tmp;
303+
}
304+
if ( distances == null){
253305
return null;
254306
}
255307

256-
return ret;
308+
for ( MetalBondDistance d : distances){
309+
if ( name1.equalsIgnoreCase(d.getAtomType1()) && name2.equalsIgnoreCase(d.getAtomType2()) )
310+
return d;
311+
}
312+
313+
// no matching atom definitions found
314+
return null;
315+
257316
}
258317

259318
/**

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ public static String[][] setUpShortTest() {
9090

9191
// Terbium
9292
{"1NCZ", null},
93-
//{"3LTQ",null}, has metalc, we ignore those for now
94-
// {"4ESQ",null},
95-
// {"1TJB",null},
96-
// {"2V15",null},
97-
// {"2K61",null},
93+
{"3LTQ",null}, // has metalc,
94+
95+
{"4ESQ",null},
96+
{"1TJB",null},
97+
{"2V15",null},
98+
{"2K61",null},
9899

99100
};
100101
return strucs;

biojava-structure/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
<filtering>false</filtering>
124124
<includes>
125125
<include>**/*.cif.gz</include>
126-
<include>**/*.pdb</include>
126+
<include>**/*.pdb.gz</include>
127127
<include>**/*.mat</include>
128128
<include>**/*.xml</include>
129129
</includes>

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.io.InputStream;
2828
import java.util.HashMap;
2929
import java.util.Map;
30+
import java.util.zip.GZIPInputStream;
3031

3132

3233
/** A class that provides a set of standard amino acids.
@@ -40,7 +41,7 @@
4041
*/
4142
public final class StandardAminoAcid {
4243

43-
private static final String STANDARD_AMINOS_FILE = "org/biojava/nbio/structure/standardaminos.pdb";
44+
private static final String STANDARD_AMINOS_FILE = "org/biojava/nbio/structure/standardaminos.pdb.gz";
4445

4546
static private Map<String,AminoAcid> aminoAcids;
4647

@@ -72,9 +73,12 @@ private StandardAminoAcid() {
7273
throw new RuntimeException("Could not find resource "+STANDARD_AMINOS_FILE+". This probably means that your biojava.jar file is corrupt or incorrectly built.");
7374
}
7475

76+
77+
7578
try {
79+
GZIPInputStream gzipIS = new GZIPInputStream(fileStream);
7680
PDBFileParser parser = new PDBFileParser();
77-
Structure s = parser.parsePDBFile(fileStream);
81+
Structure s = parser.parsePDBFile(gzipIS);
7882

7983

8084
GroupIterator iter = new GroupIterator(s);

0 commit comments

Comments
 (0)