2828import org .biojava .nbio .structure .align .util .AtomCache ;
2929import org .biojava .nbio .structure .io .FileParsingParameters ;
3030import 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 ;
3134
3235import java .io .IOException ;
3336import java .io .InputStream ;
@@ -89,11 +92,16 @@ public void testGetCAAtoms(){
8992 }
9093
9194 public void testGetAtomsConsistency () throws IOException , StructureException {
95+
96+ //Save the existing ChemCompProvider
97+ ChemCompProvider provider = ChemCompGroupFactory .getChemCompProvider ();
98+ ChemCompGroupFactory .setChemCompProvider (new DownloadChemCompProvider ());
99+
92100 AtomCache cache = new AtomCache ();
93101 FileParsingParameters params = new FileParsingParameters ();
94102 params .setLoadChemCompInfo (true );
95103 cache .setFileParsingParams (params );
96-
104+
97105 Structure hivA = cache .getStructure ("1hiv.A" );
98106 Atom [] caSa = StructureTools .getRepresentativeAtomArray (hivA );
99107 Atom [] caCa = StructureTools .getRepresentativeAtomArray (hivA .getChain (0 ));
@@ -109,6 +117,8 @@ public void testGetAtomsConsistency() throws IOException, StructureException{
109117 assertEquals ("did not find the same number of Atoms in both chains..." ,
110118 caSa .length ,caCb .length );
111119 assertEquals (caSa .length , 99 );
120+
121+ ChemCompGroupFactory .setChemCompProvider (provider );
112122 }
113123
114124 public void testGetNrAtoms (){
@@ -426,19 +436,24 @@ public void testGroupsWithinShell() {
426436 }
427437
428438 public void testCAmmCIF () throws StructureException {
439+
440+ //Save the existing ChemCompProvider
441+ ChemCompProvider provider = ChemCompGroupFactory .getChemCompProvider ();
442+ ChemCompGroupFactory .setChemCompProvider (new DownloadChemCompProvider ());
443+
429444 //mmCIF files left justify their atom names (eg "CA "), so can have different behavior
430445 AtomCache pdbCache = new AtomCache ();
431446 pdbCache .setUseMmCif (false );
432447 FileParsingParameters params = new FileParsingParameters ();
433448 params .setLoadChemCompInfo (true );
434449 pdbCache .setFileParsingParams (params );
435-
450+
436451 AtomCache mmcifCache = new AtomCache ();
437452 mmcifCache .setUseMmCif (true );
438453 FileParsingParameters params2 = new FileParsingParameters ();
439454 params2 .setLoadChemCompInfo (true );
440455 mmcifCache .setFileParsingParams (params2 );
441-
456+
442457
443458 Structure pdb =null , mmcif =null ;
444459
@@ -455,6 +470,8 @@ public void testCAmmCIF() throws StructureException {
455470
456471 assertEquals ("PDB has wrong length" ,409 ,pdbCA .length );
457472 assertEquals ("PDB has wrong length" ,409 ,mmcifCA .length );
473+
474+ ChemCompGroupFactory .setChemCompProvider (provider );
458475 }
459476
460477}
0 commit comments