Skip to content

Commit 4e53ffe

Browse files
committed
Merge pull request biojava#421 from josemduarte/bondsRewrite
Improving bonds support
2 parents 065624c + 2b1c35f commit 4e53ffe

File tree

24 files changed

+483
-720
lines changed

24 files changed

+483
-720
lines changed

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/StructureTest.java

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.biojava.nbio.structure.*;
2424
import org.biojava.nbio.structure.io.FileParsingParameters;
2525
import org.biojava.nbio.structure.io.PDBFileParser;
26+
import org.biojava.nbio.structure.io.SSBondImpl;
2627
import org.biojava.nbio.structure.jama.Matrix;
2728

2829
import java.io.IOException;
@@ -54,6 +55,7 @@ public static void setUp() throws IOException {
5455
PDBFileParser pdbpars = new PDBFileParser();
5556
FileParsingParameters params = new FileParsingParameters();
5657
params.setAlignSeqRes(true);
58+
params.setCreateAtomBonds(true);
5759
pdbpars.setFileParsingParameters(params);
5860

5961
structure = pdbpars.parsePDBFile(inStream) ;
@@ -125,27 +127,38 @@ public void testReadPDBFile() throws Exception {
125127
public void testSSBondParsing() throws Exception {
126128
assertNotNull(structure);
127129

128-
List<SSBond> ssbonds = structure.getSSBonds();
130+
List<Bond> ssbonds = structure.getSSBonds();
129131
assertEquals("did not find the correct nr of SSBonds ",3,ssbonds.size());
130132

131133
String pdb1 = "SSBOND 1 CYS A 5 CYS A 55";
132134
String pdb2 = "SSBOND 2 CYS A 14 CYS A 38";
133135

134-
SSBond bond1 = ssbonds.get(0);
136+
Bond bond1 = ssbonds.get(0);
137+
assertDisulfideBond("A", "A", 5, 55, bond1);
135138

136-
String b1 = bond1.toPDB();
139+
Bond bond2 = ssbonds.get(1);
140+
assertDisulfideBond("A", "A", 14, 38, bond2);
137141

138-
assertTrue("PDB representation incorrect",pdb1.equals(b1.trim()));
139-
assertTrue("not right resnum1 " , bond1.getResnum1().equals("5"));
140-
assertTrue("not right resnum2 " , bond1.getResnum2().equals("55"));
142+
List<SSBondImpl> list = SSBondImpl.getSsBondListFromBondList(ssbonds);
141143

142-
SSBond bond2 = ssbonds.get(1);
143-
String b2 = bond2.toPDB();
144-
assertTrue("not right resnum1 " , bond2.getResnum1().equals("14"));
145-
assertTrue("not right resnum2 " , bond2.getResnum2().equals("38"));
146-
assertTrue("PDB representation incorrect",pdb2.equals(b2.trim()));
144+
//System.out.println(list.get(0).toPDB());
145+
assertEquals("PDB representation incorrect", pdb1, list.get(0).toPDB().trim());
146+
147+
//System.out.println(list.get(1).toPDB());
148+
assertEquals("PDB representation incorrect", pdb2, list.get(1).toPDB().trim());
147149

148150
}
151+
152+
private void assertDisulfideBond(String expectedChainId1, String expectedChainId2, int expectedResSerial1, int expectedResSerial2, Bond bond) {
153+
String chainId1 = bond.getAtomA().getGroup().getChainId();
154+
String chainId2 = bond.getAtomB().getGroup().getChainId();
155+
ResidueNumber resNum1 = bond.getAtomA().getGroup().getResidueNumber();
156+
ResidueNumber resNum2 = bond.getAtomB().getGroup().getResidueNumber();
157+
assertEquals("disulfide bond first chain id failed ", expectedChainId1, chainId1);
158+
assertEquals("disulfide bond second chain id failed ", expectedChainId2, chainId2);
159+
assertEquals("disulfide bond failed first residue number failed ", new ResidueNumber(expectedChainId1, expectedResSerial1, null), resNum1);
160+
assertEquals("disulfide bond failed second residue number failed ", new ResidueNumber(expectedChainId2, expectedResSerial2, null), resNum2);
161+
}
149162

150163
/**
151164
* Tests that standard amino acids are working properly

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/Test1o2f.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.biojava.nbio.structure.test;
22

33
import org.biojava.nbio.structure.Chain;
4-
import org.biojava.nbio.structure.Group;
54
import org.biojava.nbio.structure.Structure;
65
import org.biojava.nbio.structure.StructureIO;
76
import org.biojava.nbio.structure.align.util.AtomCache;

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/ecod/EcodParseTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
package org.biojava.nbio.structure.test.ecod;
2222

2323
import java.io.IOException;
24-
import java.util.Arrays;
2524
import java.util.List;
2625

2726
import org.biojava.nbio.structure.Atom;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ public String toString() {
194194
return "Bond [atomA=" + atomA + ", atomB=" + atomB + ", bondOrder="
195195
+ bondOrder + "]";
196196
}
197-
197+
198+
198199

199200
}

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

Lines changed: 0 additions & 102 deletions
This file was deleted.

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,18 @@ <li> atomserial (mandatory) : Atom serial number</li>
260260
*
261261
* @param connections a List object specifying the connections
262262
* @see #getConnections
263+
* @deprecated use {@link Atom#addBond(Bond)} instead
263264
*/
265+
@Deprecated
264266
public void setConnections(List<Map<String,Integer>> connections);
265267

266268
/**
267269
* Return the connections value.
268270
* @return a List object representing the connections value
269271
* @see #setConnections
272+
* @deprecated use {@link Atom#getBonds()} instead
270273
*/
274+
@Deprecated
271275
public List<Map<String,Integer>> getConnections();
272276

273277
/**
@@ -582,25 +586,25 @@ public Chain getChainByPDB(String chainId, int modelnr)
582586
public void setJournalArticle(JournalArticle journalArticle);
583587

584588
/**
585-
* Get the list of SSBonds as they have been defined in the PDB files
589+
* Get the list of disulfide Bonds as they have been defined in the PDB files
586590
*
587-
* @return a list of SSBonds
591+
* @return a list of Bonds
588592
*/
589-
public List<SSBond> getSSBonds();
593+
public List<Bond> getSSBonds();
590594

591595
/**
592596
* Set the list of SSBonds for this structure
593597
*
594598
* @param ssbonds
595599
*/
596-
public void setSSBonds(List<SSBond> ssbonds);
600+
public void setSSBonds(List<Bond> ssbonds);
597601

598602
/**
599-
* Add a single SSBond to this structure
603+
* Add a single disulfide Bond to this structure
600604
*
601605
* @param ssbond
602606
*/
603-
public void addSSBond(SSBond ssbond);
607+
public void addSSBond(Bond ssbond);
604608

605609
/**
606610
* Set the the header information for this PDB file

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

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class StructureImpl implements Structure, Serializable {
5959
private List<Map <String,Integer>> connections ;
6060
private List<Compound> compounds;
6161
private List<DBRef> dbrefs;
62-
private List<SSBond> ssbonds;
62+
private List<Bond> ssbonds;
6363
private List<Site> sites;
6464
private List<Group> hetAtoms;
6565
private String name ;
@@ -82,7 +82,7 @@ public StructureImpl() {
8282
compounds = new ArrayList<Compound>();
8383
dbrefs = new ArrayList<DBRef>();
8484
pdbHeader = new PDBHeader();
85-
ssbonds = new ArrayList<SSBond>();
85+
ssbonds = new ArrayList<Bond>();
8686
sites = new ArrayList<Site>();
8787
hetAtoms = new ArrayList<Group>();
8888
}
@@ -146,8 +146,7 @@ public Structure clone() {
146146
//TODO the header data is not being deep-copied, that's a minor issue since it is just some static metadata, but we should recheck this if needed - JD 2014-12-11
147147
n.setPDBHeader(pdbHeader);
148148
n.setDBRefs(this.getDBRefs());
149-
n.setConnections(getConnections());
150-
n.setSites(getSites());
149+
n.setSites(getSites());
151150

152151

153152
// go through each chain and clone chain
@@ -190,10 +189,7 @@ public Structure clone() {
190189
}
191190
n.setCompounds(newCompoundList);
192191

193-
194-
for (SSBond ssbond: ssbonds){
195-
n.addSSBond(ssbond.clone());
196-
}
192+
// TODO ssbonds are complicated to clone: there are deep references inside Atom objects, how would we do it? - JD 2016-03-03
197193

198194
return n ;
199195
}
@@ -743,32 +739,27 @@ public void setPDBHeader(PDBHeader pdbHeader){
743739
this.pdbHeader = pdbHeader;
744740
}
745741

746-
/** get the list of SSBonds as they have been defined in the PDB files
747-
*
748-
* @return a list of SSBonds
749-
*/
742+
/** {@inheritDoc} */
750743
@Override
751-
public List<SSBond> getSSBonds(){
744+
public List<Bond> getSSBonds(){
752745
return ssbonds;
753746

754747
}
755-
/** set the list of SSBonds for this structure
756-
*
757-
* @param ssbonds
758-
*/
748+
749+
/** {@inheritDoc} */
759750
@Override
760-
public void setSSBonds(List<SSBond> ssbonds){
751+
public void setSSBonds(List<Bond> ssbonds){
761752
this.ssbonds = ssbonds;
762753
}
763754

764-
/** add a single SSBond to this structure
755+
/**
756+
* Adds a single disulfide Bond to this structure
765757
*
766758
* @param ssbond the SSBond.
767759
*/
768760
@Override
769-
public void addSSBond(SSBond ssbond){
761+
public void addSSBond(Bond ssbond){
770762
ssbonds.add(ssbond);
771-
ssbond.setSerNum(ssbonds.size());
772763
}
773764

774765
/**

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,9 +1576,8 @@ public static Structure removeModels(Structure s) {
15761576
// TODO: do deep copying of data!
15771577
n.setPDBHeader(s.getPDBHeader());
15781578
n.setDBRefs(s.getDBRefs());
1579-
n.setConnections(s.getConnections());
1579+
15801580
n.setSites(s.getSites());
1581-
n.setCrystallographicInfo(s.getCrystallographicInfo());
15821581

15831582
n.setChains(s.getModel(0));
15841583

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,10 @@ public Structure reduce(Structure s) throws StructureException {
178178
newS.setBiologicalAssembly(s.isBiologicalAssembly());
179179
newS.getPDBHeader().setDescription(
180180
"sub-range " + ranges + " of " + newS.getPDBCode() + " "
181-
+ s.getPDBHeader().getDescription());
182-
newS.setCrystallographicInfo(s.getCrystallographicInfo());
181+
+ s.getPDBHeader().getDescription());
183182
// TODO The following should be only copied for atoms which are present in the range.
184183
newS.setCompounds(s.getCompounds());
185-
newS.setConnections(s.getConnections());
184+
186185
newS.setSSBonds(s.getSSBonds());
187186
newS.setSites(s.getSites());
188187

@@ -198,7 +197,6 @@ public Structure reduce(Structure s) throws StructureException {
198197
if(getResidueRanges().isEmpty()) {
199198
// Include all residues
200199
newS.setCompounds(s.getCompounds());
201-
newS.setConnections(s.getConnections());
202200
newS.setSSBonds(s.getSSBonds());
203201
newS.setSites(s.getSites());
204202

0 commit comments

Comments
 (0)