Skip to content

Commit 084cd4a

Browse files
committed
Merge pull request biojava#434 from abradle/master
Fixed a bug where nucleotide bonds were not being generated. Added a …
2 parents 070356c + 44b3e4c commit 084cd4a

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ private void formNucleotideBonds() {
165165
continue;
166166
}
167167

168-
Atom phosphorous = tail.getP();
169-
Atom oThreePrime = head.getO3Prime();
168+
Atom phosphorous = head.getP();
169+
Atom oThreePrime = tail.getO3Prime();
170170

171171
if (phosphorous == null || oThreePrime == null) {
172172
continue;

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
package org.biojava.nbio.structure;
2222

2323
import java.io.IOException;
24+
import java.util.ArrayList;
25+
import java.util.List;
2426

2527
import org.biojava.nbio.structure.align.util.AtomCache;
2628
import org.biojava.nbio.structure.io.FileParsingParameters;
@@ -138,6 +140,38 @@ public void testLigandBonds() throws StructureException, IOException {
138140
assertTrue(areBonded(phosphateP, phosphateO));
139141
}
140142

143+
/**
144+
* Test whether nucleotide bonds are being generated
145+
* @throws IOException
146+
* @throws StructureException
147+
*/
148+
@Test
149+
public void testNucleotideBonds() throws IOException, StructureException {
150+
Structure bio = StructureIO.getStructure("4y60");
151+
for( Chain c : bio.getChains()) {
152+
int groupCounter = 0;
153+
List<Group> currentGroups = c.getAtomGroups();
154+
for ( Group g : currentGroups) {
155+
if(groupCounter!=0 && groupCounter<currentGroups.size()) {
156+
List<Atom> atoms = g.getAtoms();
157+
for ( Atom a : atoms) {
158+
if ( a.getName().equals("P")){
159+
// Check to see if one of the phosphate atoms has bonding to something
160+
// outside of the group.
161+
List<Integer> indexList = new ArrayList<>();
162+
for (Bond b : a.getBonds()){
163+
indexList.add(atoms.indexOf(b.getOther(a)));
164+
}
165+
assertTrue(indexList.contains(-1));
166+
}
167+
}
168+
}
169+
groupCounter++;
170+
}
171+
172+
}
173+
}
174+
141175
private boolean areBonded(Atom a, Atom b) {
142176
for (Bond bond : a.getBonds()) {
143177
if (bond.getOther(a) == b) {

0 commit comments

Comments
 (0)