28
28
import org .biojava .nbio .structure .align .util .AtomCache ;
29
29
import org .biojava .nbio .structure .io .FileParsingParameters ;
30
30
import org .biojava .nbio .structure .io .PDBFileParser ;
31
+ import org .biojava .nbio .structure .io .mmcif .ChemCompGroupFactory ;
32
+ import org .biojava .nbio .structure .io .mmcif .ChemCompProvider ;
33
+ import org .biojava .nbio .structure .io .mmcif .DownloadChemCompProvider ;
31
34
32
35
import java .io .IOException ;
33
36
import java .io .InputStream ;
@@ -89,11 +92,16 @@ public void testGetCAAtoms(){
89
92
}
90
93
91
94
public void testGetAtomsConsistency () throws IOException , StructureException {
95
+
96
+ //Save the existing ChemCompProvider
97
+ ChemCompProvider provider = ChemCompGroupFactory .getChemCompProvider ();
98
+ ChemCompGroupFactory .setChemCompProvider (new DownloadChemCompProvider ());
99
+
92
100
AtomCache cache = new AtomCache ();
93
101
FileParsingParameters params = new FileParsingParameters ();
94
102
params .setLoadChemCompInfo (true );
95
103
cache .setFileParsingParams (params );
96
-
104
+
97
105
Structure hivA = cache .getStructure ("1hiv.A" );
98
106
Atom [] caSa = StructureTools .getRepresentativeAtomArray (hivA );
99
107
Atom [] caCa = StructureTools .getRepresentativeAtomArray (hivA .getChain (0 ));
@@ -109,6 +117,8 @@ public void testGetAtomsConsistency() throws IOException, StructureException{
109
117
assertEquals ("did not find the same number of Atoms in both chains..." ,
110
118
caSa .length ,caCb .length );
111
119
assertEquals (caSa .length , 99 );
120
+
121
+ ChemCompGroupFactory .setChemCompProvider (provider );
112
122
}
113
123
114
124
public void testGetNrAtoms (){
@@ -426,19 +436,24 @@ public void testGroupsWithinShell() {
426
436
}
427
437
428
438
public void testCAmmCIF () throws StructureException {
439
+
440
+ //Save the existing ChemCompProvider
441
+ ChemCompProvider provider = ChemCompGroupFactory .getChemCompProvider ();
442
+ ChemCompGroupFactory .setChemCompProvider (new DownloadChemCompProvider ());
443
+
429
444
//mmCIF files left justify their atom names (eg "CA "), so can have different behavior
430
445
AtomCache pdbCache = new AtomCache ();
431
446
pdbCache .setUseMmCif (false );
432
447
FileParsingParameters params = new FileParsingParameters ();
433
448
params .setLoadChemCompInfo (true );
434
449
pdbCache .setFileParsingParams (params );
435
-
450
+
436
451
AtomCache mmcifCache = new AtomCache ();
437
452
mmcifCache .setUseMmCif (true );
438
453
FileParsingParameters params2 = new FileParsingParameters ();
439
454
params2 .setLoadChemCompInfo (true );
440
455
mmcifCache .setFileParsingParams (params2 );
441
-
456
+
442
457
443
458
Structure pdb =null , mmcif =null ;
444
459
@@ -455,6 +470,8 @@ public void testCAmmCIF() throws StructureException {
455
470
456
471
assertEquals ("PDB has wrong length" ,409 ,pdbCA .length );
457
472
assertEquals ("PDB has wrong length" ,409 ,mmcifCA .length );
473
+
474
+ ChemCompGroupFactory .setChemCompProvider (provider );
458
475
}
459
476
460
477
}
0 commit comments