use of org.openscience.cdk.inchi.InChIGenerator in project ambit-mirror by ideaconsult.
the class InchiProcessorTest method testEquals.
@Test
public void testEquals() throws Exception {
List<INCHI_OPTION> options = new ArrayList<INCHI_OPTION>();
options.add(INCHI_OPTION.FixedH);
options.add(INCHI_OPTION.SAbs);
options.add(INCHI_OPTION.SAsXYZ);
options.add(INCHI_OPTION.SPXYZ);
options.add(INCHI_OPTION.FixSp3Bug);
options.add(INCHI_OPTION.AuxNone);
SmilesParser p = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer mol = p.parseSmiles("CN1C=NC2=C1C(=O)N(C(=O)N2C)C");
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
CDKHydrogenAdder.getInstance(mol.getBuilder()).addImplicitHydrogens(mol);
IAtomContainer molH = mol.clone();
MoleculeTools.convertImplicitToExplicitHydrogens(molH);
InChIGeneratorFactory factory = InChIGeneratorFactory.getInstance();
InChIGenerator gen = factory.getInChIGenerator(mol, options);
Assert.assertEquals(INCHI_RET.OKAY, gen.getReturnStatus());
InChIGenerator genH = factory.getInChIGenerator(mol, options);
Assert.assertEquals(INCHI_RET.OKAY, genH.getReturnStatus());
Assert.assertEquals(gen.getInchi(), genH.getInchi());
}
use of org.openscience.cdk.inchi.InChIGenerator in project ambit-mirror by ideaconsult.
the class InchiProcessorTest method testTautomers.
@Test
public void testTautomers() throws Exception {
List<INCHI_OPTION> options = new ArrayList<INCHI_OPTION>();
options.add(INCHI_OPTION.FixedH);
options.add(INCHI_OPTION.SAbs);
options.add(INCHI_OPTION.SAsXYZ);
options.add(INCHI_OPTION.SPXYZ);
options.add(INCHI_OPTION.FixSp3Bug);
options.add(INCHI_OPTION.AuxNone);
SmilesParser p = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer mol1 = p.parseSmiles("S=NNCC");
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol1);
CDKHydrogenAdder.getInstance(mol1.getBuilder()).addImplicitHydrogens(mol1);
IAtomContainer mol2 = p.parseSmiles("SN=NCC");
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol2);
CDKHydrogenAdder.getInstance(mol2.getBuilder()).addImplicitHydrogens(mol2);
InChIGeneratorFactory factory = InChIGeneratorFactory.getInstance();
InChIGenerator gen1 = factory.getInChIGenerator(mol1, options);
System.out.println(gen1.getReturnStatus());
System.out.println(gen1.getMessage());
// Assert.assertEquals(INCHI_RET.OKAY, gen1.getReturnStatus());
InChIGenerator gen2 = factory.getInChIGenerator(mol2, options);
// Assert.assertEquals(INCHI_RET.OKAY, gen2.getReturnStatus());
System.out.println(gen2.getReturnStatus());
System.out.println(gen2.getMessage());
Assert.assertEquals("InChI=1/C2H6N2S/c1-2-3-4-5/h2H2,1H3,(H,3,5)/f/h3H", gen1.getInchi());
Assert.assertEquals("HLBPZSLHBUKVDX-TULZNQERNA-N", gen1.getInchiKey());
Assert.assertEquals("InChI=1/C2H6N2S/c1-2-3-4-5/h2H2,1H3,(H,3,5)/f/h5H", gen2.getInchi());
Assert.assertEquals("HLBPZSLHBUKVDX-JSWHHWTPNA-N", gen2.getInchiKey());
Assert.assertTrue(!gen1.getInchi().equals(gen2.getInchi()));
Assert.assertTrue(!gen1.getInchiKey().equals(gen2.getInchiKey()));
}
use of org.openscience.cdk.inchi.InChIGenerator in project ambit-mirror by ideaconsult.
the class InchiProcessorTest method testProcessAromaticity.
@Test
public void testProcessAromaticity() throws Exception {
SmilesParser p = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer mol = p.parseSmiles("CN1C=NC2=C1C(=O)N(C(=O)N2C)C");
// IAtomContainer mol = p.parseSmiles("c1ccccc1");
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
CDKHydrogenAdder ha = CDKHydrogenAdder.getInstance(SilentChemObjectBuilder.getInstance());
ha.addImplicitHydrogens(mol);
// AtomContainerManipulator.convertImplicitToExplicitHydrogens(mol); //
// this is the most important
InChIGeneratorFactory factory = InChIGeneratorFactory.getInstance();
InChIGenerator gen = factory.getInChIGenerator(mol);
INCHI_RET ret = gen.getReturnStatus();
if (ret != INCHI_RET.OKAY) {
throw new Exception(String.format("InChI failed: %s [%s]", ret.toString(), gen.getMessage()));
}
String inchi = gen.getInchi();
Assert.assertEquals("InChI=1S/C8H10N4O2/c1-10-4-9-6-5(10)7(13)12(3)8(14)11(6)2/h4H,1-3H3", inchi);
}
use of org.openscience.cdk.inchi.InChIGenerator in project ambit-mirror by ideaconsult.
the class InchiProcessor method process.
public InChIGenerator process(IAtomContainer target) throws AmbitException {
try {
List<net.sf.jniinchi.INCHI_OPTION> options = new ArrayList<net.sf.jniinchi.INCHI_OPTION>();
/*
options.add(INCHI_OPTION.ChiralFlagON);
options.add(INCHI_OPTION.SUCF);
options.add(INCHI_OPTION.SRel);
*/
options.add(INCHI_OPTION.SAbs);
options.add(INCHI_OPTION.SAsXYZ);
options.add(INCHI_OPTION.SPXYZ);
options.add(INCHI_OPTION.FixSp3Bug);
options.add(INCHI_OPTION.AuxNone);
InChIGenerator gen = factory.getInChIGenerator(target, options);
INCHI_RET ret = gen.getReturnStatus();
if (ret == INCHI_RET.WARNING) {
// InChI generated, but with warning message
logger.warning("InChI warning: " + gen.getMessage());
} else if (ret != INCHI_RET.OKAY) {
// InChI generation failed
throw new AmbitException("InChI failed: " + ret.toString() + " [" + gen.getMessage() + "]");
}
return gen;
} catch (CDKException x) {
throw new AmbitException(x);
}
}
use of org.openscience.cdk.inchi.InChIGenerator in project ambit-mirror by ideaconsult.
the class InchiProcessorTest method generate.
public void generate(IAtomContainer mol, String expected, boolean aromatic) throws Exception {
InchiProcessor p = new InchiProcessor();
HydrogenAdderProcessor ha = new HydrogenAdderProcessor();
mol = ha.process(mol);
if (aromatic) {
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
CDKHueckelAromaticityDetector.detectAromaticity(mol);
}
InChIGenerator gen = p.process(mol);
String inchi = gen.getInchi();
String auxinfo = gen.getAuxInfo();
Assert.assertEquals(expected, inchi);
}
Aggregations