Skip to content

Commit 235f342

Browse files
author
Dmytro Guzenko
committed
modify atom cache locally in tests
1 parent de28e0d commit 235f342

File tree

3 files changed

+40
-18
lines changed

3 files changed

+40
-18
lines changed

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/io/TestBioassemblies.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class TestBioassemblies {
2424
@Test
2525
public void test1E17() throws IOException, StructureException {
2626

27+
AtomCache prevAtomCache = StructureIO.getAtomCache();
28+
2729
AtomCache cache = new AtomCache();
2830
cache.setUseMmCif(true);
2931
StructureIO.setAtomCache(cache);
@@ -43,7 +45,8 @@ public void test1E17() throws IOException, StructureException {
4345
// the bioassembly is a monomer
4446
assertEquals(1, multiModelBioAssemblies.get(0).getPolyChains().size());
4547
assertEquals(1, flattenedBioAssemblies.get(0).getPolyChains().size());
46-
48+
49+
StructureIO.setAtomCache(prevAtomCache);
4750
}
4851

4952
/**
@@ -54,6 +57,7 @@ public void test1E17() throws IOException, StructureException {
5457
@Test
5558
public void test4TTX() throws IOException, StructureException {
5659

60+
AtomCache prevAtomCache = StructureIO.getAtomCache();
5761
AtomCache cache = new AtomCache();
5862
cache.setUseMmCif(true);
5963
StructureIO.setAtomCache(cache);
@@ -79,8 +83,8 @@ public void test4TTX() throws IOException, StructureException {
7983

8084
assertEquals(2, multiModelBioAssemblies.get(2).getPolyChains().size());
8185
assertEquals(2, flattenedBioAssemblies.get(2).getPolyChains().size());
82-
83-
86+
87+
StructureIO.setAtomCache(prevAtomCache);
8488

8589
}
8690

@@ -91,6 +95,8 @@ public void test4TTX() throws IOException, StructureException {
9195
*/
9296
@Test
9397
public void test4OPJ() throws IOException, StructureException {
98+
99+
AtomCache prevAtomCache = StructureIO.getAtomCache();
94100
AtomCache cache = new AtomCache();
95101
cache.setUseMmCif(true);
96102
StructureIO.setAtomCache(cache);
@@ -144,6 +150,7 @@ public void test4OPJ() throws IOException, StructureException {
144150
assertTrue(c.getName().contains("_"));
145151
}
146152

153+
StructureIO.setAtomCache(prevAtomCache);
147154

148155
}
149156

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/symmetry/TestQuatSymmetryDetectorExamples.java

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.biojava.nbio.structure.Structure;
2929
import org.biojava.nbio.structure.StructureException;
3030
import org.biojava.nbio.structure.StructureIO;
31+
import org.biojava.nbio.structure.align.util.AtomCache;
32+
import org.biojava.nbio.structure.cluster.SubunitCluster;
3133
import org.biojava.nbio.structure.cluster.SubunitClusterer;
3234
import org.biojava.nbio.structure.cluster.SubunitClustererMethod;
3335
import org.biojava.nbio.structure.cluster.SubunitClustererParameters;
@@ -139,6 +141,9 @@ public void testPseudosymmetry() throws IOException, StructureException {
139141
@Test
140142
public void testLocal() throws IOException, StructureException {
141143

144+
AtomCache atomCache = new AtomCache();
145+
atomCache.setUseMmtf(true);
146+
142147
List<String> testIds = new ArrayList<>();
143148
List<String> testStoichiometries = new ArrayList<>();
144149
List<Map<String,String>> testLocalSymmetries = new ArrayList<>();
@@ -227,37 +232,42 @@ public void testLocal() throws IOException, StructureException {
227232
localSymmetries.put("A6","D3");
228233
testLocalSymmetries.add(localSymmetries);
229234

230-
// temporarily commented out because it fails when running with maven, TODO debug and bring back - JD 2018-03-10
231-
// testIds.add("BIO:3JC9:1");
232-
// testStoichiometries.add("A12B12C12D12E12F12G5H2");
233-
// localSymmetries = new HashMap<>();
234-
// localSymmetries.put("A12C12D12E12F12H2","C2");
235-
// localSymmetries.put("A12B12C12D12E12F12","C12");
236-
// localSymmetries.put("G5","H");
237-
// testLocalSymmetries.add(localSymmetries);
235+
testIds.add("BIO:3JC9:1");
236+
testStoichiometries.add("A12B12C12D12E12F12G5H2");
237+
localSymmetries = new HashMap<>();
238+
localSymmetries.put("A12C12D12E12F12H2","C2");
239+
localSymmetries.put("A12B12C12D12E12F12","C12");
240+
localSymmetries.put("G5","H");
241+
testLocalSymmetries.add(localSymmetries);
238242

239243
QuatSymmetryParameters symmParams = new QuatSymmetryParameters();
240244
SubunitClustererParameters clusterParams = new SubunitClustererParameters(true);
241245
clusterParams.setClustererMethod(SubunitClustererMethod.SEQUENCE);
242246
clusterParams.setSequenceIdentityThreshold(0.75);
243247

244248
for(int iTest = 0; iTest<testIds.size();iTest++) {
245-
logger.info(testIds.get(iTest));
246-
Structure pdb = StructureIO.getStructure(testIds.get(iTest));
249+
logger.info("Processing "+testIds.get(iTest));
250+
Structure pdb = atomCache.getStructure(testIds.get(iTest));
247251
Stoichiometry composition = SubunitClusterer.cluster(pdb,clusterParams);
248252

249253
// no global symmetry
250254
QuatSymmetryResults globalSymmetry = QuatSymmetryDetector.calcGlobalSymmetry(composition,symmParams);
251-
assertEquals("C1", globalSymmetry.getSymmetry());
252-
assertEquals(testStoichiometries.get(iTest), globalSymmetry.getStoichiometry().toString());
255+
assertEquals("Unexpected global symmetry in "+testIds.get(iTest),
256+
"C1", globalSymmetry.getSymmetry());
257+
assertEquals("Unexpected global stoichiometry in "+testIds.get(iTest),
258+
testStoichiometries.get(iTest), globalSymmetry.getStoichiometry().toString());
253259

254260
List<QuatSymmetryResults> foundLocal = QuatSymmetryDetector.calcLocalSymmetries(composition, symmParams);
255261
Map<String,String> refLocal = testLocalSymmetries.get(iTest);
256262

257263
for (QuatSymmetryResults local:foundLocal) {
258-
logger.info(local.getStoichiometry().toString());
259-
assertTrue(refLocal.keySet().contains(local.getStoichiometry().toString()));
260-
assertEquals(refLocal.get(local.getStoichiometry().toString()),local.getSymmetry());
264+
logger.info("Found stoichiometry "+local.getStoichiometry().toString()+" with symmetry "+local.getSymmetry());
265+
assertTrue("Stoichiometry "+local.getStoichiometry().toString()+" not expected for "+testIds.get(iTest),
266+
refLocal.keySet().contains(local.getStoichiometry().toString()));
267+
268+
assertEquals("Symmetry "+local.getSymmetry()+" with stoichiometry "+local.getStoichiometry().toString()+
269+
" not expected for "+testIds.get(iTest),
270+
refLocal.get(local.getStoichiometry().toString()),local.getSymmetry());
261271
}
262272
}
263273
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ public static void setAtomCache(AtomCache c){
115115
cache = c;
116116
}
117117

118+
public static AtomCache getAtomCache() {
119+
return cache;
120+
}
121+
122+
118123
/**
119124
* Returns the first biological assembly that is available for the given PDB id.
120125
* <p>

0 commit comments

Comments
 (0)