Skip to content

Commit 636929b

Browse files
committed
Fixed a bug in generation of disulphide bonds - including a test case.
1 parent ffaa1c7 commit 636929b

2 files changed

Lines changed: 49 additions & 5 deletions

File tree

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

Lines changed: 11 additions & 5 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")) {

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

Lines changed: 38 additions & 0 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

@@ -286,4 +316,12 @@ public void testWeirdCase() throws IOException, StructureException {
286316
assertEquals(testMissingBonds("1IU6"),6);
287317
}
288318

319+
320+
@Test
321+
public void testSSBonds() throws IOException, StructureException {
322+
for(String pdbCode : new String[]{"3ZXW", "1NTY", "4H2I", "2K6D", "2MLM"}){
323+
assertEquals(testBondedToSelf(pdbCode),0);
324+
}
325+
}
326+
289327
}

0 commit comments

Comments
 (0)