Skip to content

Commit

Permalink
Random test order causes failure now default option is to ignore arom…
Browse files Browse the repository at this point in the history
…aticity.

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Apr 6, 2014
1 parent 1d51037 commit 2f7e936
Showing 1 changed file with 36 additions and 31 deletions.
Expand Up @@ -173,36 +173,41 @@ public void testGetInChIToStructure_String_IChemObjectBuilder_NullList() throws
*/
@Test public void testInChIGenerator_AromaticBonds() throws CDKException {

// create a fairly complex aromatic molecule
IAtomContainer tetrazole = TestMoleculeFactory.makeTetrazole();
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(tetrazole);
CDKHueckelAromaticityDetector.detectAromaticity(tetrazole);

InChIGeneratorFactory inchiFactory = InChIGeneratorFactory.getInstance();

// include aromatic bonds by default
InChIGenerator genAromaticity1 = inchiFactory.getInChIGenerator(tetrazole);

// exclude aromatic bonds
assertFalse(inchiFactory.getIgnoreAromaticBonds());
inchiFactory.setIgnoreAromaticBonds(true);
assertTrue(inchiFactory.getIgnoreAromaticBonds());
InChIGenerator genNoAromaticity = inchiFactory.getInChIGenerator(tetrazole);

// include aromatic bonds again
inchiFactory.setIgnoreAromaticBonds(false);
assertFalse(inchiFactory.getIgnoreAromaticBonds());
InChIGenerator genAromaticity2 = inchiFactory.getInChIGenerator(tetrazole);

// with the aromatic bonds included, no InChI can be generated
Assert.assertEquals("return status was not in error",
INCHI_RET.ERROR, genAromaticity1.getReturnStatus());
Assert.assertEquals("return status was not in error",
INCHI_RET.ERROR, genAromaticity2.getReturnStatus());
// excluding the aromatic bonds gives the normal InChI
Assert.assertEquals("return status was not okay",
INCHI_RET.OKAY, genNoAromaticity.getReturnStatus());
Assert.assertEquals("InChIs did not match",
"InChI=1S/CH2N4/c1-2-4-5-3-1/h1H,(H,2,3,4,5)", genNoAromaticity.getInchi());
try {
// create a fairly complex aromatic molecule
IAtomContainer tetrazole = TestMoleculeFactory.makeTetrazole();
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(tetrazole);
CDKHueckelAromaticityDetector.detectAromaticity(tetrazole);

InChIGeneratorFactory inchiFactory = InChIGeneratorFactory.getInstance();
inchiFactory.setIgnoreAromaticBonds(false);

// include aromatic bonds by default
InChIGenerator genAromaticity1 = inchiFactory.getInChIGenerator(tetrazole);

// exclude aromatic bonds
assertFalse(inchiFactory.getIgnoreAromaticBonds());
inchiFactory.setIgnoreAromaticBonds(true);
assertTrue(inchiFactory.getIgnoreAromaticBonds());
InChIGenerator genNoAromaticity = inchiFactory.getInChIGenerator(tetrazole);

// include aromatic bonds again
inchiFactory.setIgnoreAromaticBonds(false);
assertFalse(inchiFactory.getIgnoreAromaticBonds());
InChIGenerator genAromaticity2 = inchiFactory.getInChIGenerator(tetrazole);

// with the aromatic bonds included, no InChI can be generated
Assert.assertEquals("return status was not in error",
INCHI_RET.ERROR, genAromaticity1.getReturnStatus());
Assert.assertEquals("return status was not in error",
INCHI_RET.ERROR, genAromaticity2.getReturnStatus());
// excluding the aromatic bonds gives the normal InChI
Assert.assertEquals("return status was not okay",
INCHI_RET.OKAY, genNoAromaticity.getReturnStatus());
Assert.assertEquals("InChIs did not match",
"InChI=1S/CH2N4/c1-2-4-5-3-1/h1H,(H,2,3,4,5)", genNoAromaticity.getInchi());
} finally {
InChIGeneratorFactory.getInstance().setIgnoreAromaticBonds(true);
}
}
}

0 comments on commit 2f7e936

Please sign in to comment.