Skip to content

Commit 8340928

Browse files
committed
Converting to unit test
1 parent 3c97b85 commit 8340928

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

biojava-structure/src/test/java/org/biojava/nbio/structure/asa/TestAsaCalc.java

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
*/
2121
package org.biojava.nbio.structure.asa;
2222

23+
import org.biojava.nbio.structure.AminoAcidImpl;
2324
import org.biojava.nbio.structure.Atom;
25+
import org.biojava.nbio.structure.AtomImpl;
26+
import org.biojava.nbio.structure.Element;
2427
import org.biojava.nbio.structure.Structure;
2528
import org.biojava.nbio.structure.StructureException;
2629
import org.biojava.nbio.structure.StructureIO;
@@ -186,15 +189,13 @@ public void testPerformance() throws StructureException, IOException {
186189
}
187190

188191
@Test
189-
public void testNoNeighborsIssue() throws StructureException, IOException {
190-
// important: without this the tests can fail when running in maven (but not in IDE)
191-
// that's because it depends on the order on how tests were run - JD 2018-03-10
192-
ChemCompGroupFactory.setChemCompProvider(new DownloadChemCompProvider());
193-
194-
Structure structure = StructureIO.getStructure("1EMI");
192+
public void testNoNeighborsIssue() {
195193

196-
// chain B, atom with index 35 does not have any neighbors. The calculation should not fail
197-
Atom[] atoms = StructureTools.getAllNonHAtomArray(structure.getPolyChainByPDB("B"), false);
194+
Atom[] atoms = {
195+
getAtom(1.0, 1.0, 1.0),
196+
getAtom(10.0, 1.0, 1.0),
197+
getAtom(13.0, 1.0, 1.0)
198+
};
198199

199200
AsaCalculator asaCalc = new AsaCalculator(atoms,
200201
AsaCalculator.DEFAULT_PROBE_SIZE,
@@ -204,8 +205,10 @@ public void testNoNeighborsIssue() throws StructureException, IOException {
204205

205206
int[][] allNbs = asaCalc.findNeighborIndices();
206207

208+
assertEquals(3, allNbs.length);
209+
assertEquals(3, allNbsSh.length);
210+
207211
for (int indexToTest =0; indexToTest < asaCalc.getAtomCoords().length; indexToTest++) {
208-
//int indexToTest = 198;
209212
int[] nbsSh = allNbsSh[indexToTest];
210213
int[] nbs = allNbs[indexToTest];
211214

@@ -224,6 +227,21 @@ public void testNoNeighborsIssue() throws StructureException, IOException {
224227
assertEquals(nbs.length, listOfMatchingIndices.size());
225228
}
226229

230+
// first atom should have no neighbors
231+
assertEquals(0, allNbsSh[0].length);
232+
}
233+
234+
private Atom getAtom(double x, double y, double z) {
235+
Atom atom = new AtomImpl();
236+
AminoAcidImpl g = new AminoAcidImpl();
237+
g.setAminoType('A');
238+
atom.setGroup(g);
239+
atom.setName("CA");
240+
atom.setElement(Element.C);
241+
atom.setX(x);
242+
atom.setY(y);
243+
atom.setZ(z);
244+
return atom;
227245
}
228246

229247
@Test

0 commit comments

Comments
 (0)