Search in sources :

Example 1 with INCHI_OPTION

use of net.sf.jniinchi.INCHI_OPTION in project ambit-mirror by ideaconsult.

the class InchiProcessorTest method testProcessExplicitH.

@Test
public void testProcessExplicitH() 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());
}
Also used : SmilesParser(org.openscience.cdk.smiles.SmilesParser) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) INCHI_OPTION(net.sf.jniinchi.INCHI_OPTION) InChIGenerator(org.openscience.cdk.inchi.InChIGenerator) ArrayList(java.util.ArrayList) InChIGeneratorFactory(org.openscience.cdk.inchi.InChIGeneratorFactory) Test(org.junit.Test)

Example 2 with INCHI_OPTION

use of net.sf.jniinchi.INCHI_OPTION 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());
}
Also used : SmilesParser(org.openscience.cdk.smiles.SmilesParser) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) INCHI_OPTION(net.sf.jniinchi.INCHI_OPTION) InChIGenerator(org.openscience.cdk.inchi.InChIGenerator) ArrayList(java.util.ArrayList) InChIGeneratorFactory(org.openscience.cdk.inchi.InChIGeneratorFactory) Test(org.junit.Test)

Example 3 with INCHI_OPTION

use of net.sf.jniinchi.INCHI_OPTION 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()));
}
Also used : SmilesParser(org.openscience.cdk.smiles.SmilesParser) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) INCHI_OPTION(net.sf.jniinchi.INCHI_OPTION) InChIGenerator(org.openscience.cdk.inchi.InChIGenerator) ArrayList(java.util.ArrayList) InChIGeneratorFactory(org.openscience.cdk.inchi.InChIGeneratorFactory) Test(org.junit.Test)

Example 4 with INCHI_OPTION

use of net.sf.jniinchi.INCHI_OPTION in project ambit-mirror by ideaconsult.

the class ReactorStrategy method readReactorStrategyFromJsonNode.

public static ReactorStrategy readReactorStrategyFromJsonNode(JsonNode node, ReactorStrategy reactorStrategy) throws Exception {
    ReactorStrategy strategy = reactorStrategy;
    if (strategy == null)
        strategy = new ReactorStrategy();
    strategy.maxNumOfReactions = JSONParsingUtils.extractIntKeyword(node, "MAX_NUM_OF_REACTIONS", true);
    strategy.maxLevel = JSONParsingUtils.extractIntKeyword(node, "MAX_LEVEL", true);
    strategy.allowedProducts = JSONParsingUtils.getStructureRecords(node, "ALLOWED_PRODUCTS_SMILES", STRUCTURE_RECORD_INPUT_INFO.smiles, false);
    strategy.forbiddenProducts = JSONParsingUtils.getStructureRecords(node, "FORBIDDEN_PRODUCTS_SMILES", STRUCTURE_RECORD_INPUT_INFO.smiles, false);
    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);
    InChIGeneratorFactory igf = InChIGeneratorFactory.getInstance();
    // Configure products
    if (strategy.allowedProducts != null)
        for (StructureRecord sr : strategy.allowedProducts) configureStructureRecord(sr, igf, options);
    if (strategy.forbiddenProducts != null)
        for (StructureRecord sr : strategy.forbiddenProducts) configureStructureRecord(sr, igf, options);
    return strategy;
}
Also used : INCHI_OPTION(net.sf.jniinchi.INCHI_OPTION) StructureRecord(ambit2.base.data.StructureRecord) ArrayList(java.util.ArrayList) InChIGeneratorFactory(org.openscience.cdk.inchi.InChIGeneratorFactory)

Example 5 with INCHI_OPTION

use of net.sf.jniinchi.INCHI_OPTION in project cdk by cdk.

the class InChIGeneratorFactoryTest method testGetInChIGenerator_IAtomContainer_List.

/**
 * Because we are setting an options, we get a non-standard InChI.
 */
@Test
public void testGetInChIGenerator_IAtomContainer_List() throws Exception {
    IAtomContainer ac = new AtomContainer();
    IAtom a = new Atom("Cl");
    a.setImplicitHydrogenCount(1);
    ac.addAtom(a);
    List<INCHI_OPTION> options = new ArrayList<>();
    options.add(INCHI_OPTION.FixedH);
    InChIGenerator gen = InChIGeneratorFactory.getInstance().getInChIGenerator(ac, options);
    Assert.assertEquals(gen.getReturnStatus(), INCHI_RET.OKAY);
    Assert.assertEquals("InChI=1/ClH/h1H", gen.getInchi());
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) INCHI_OPTION(net.sf.jniinchi.INCHI_OPTION) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) ArrayList(java.util.ArrayList) IAtom(org.openscience.cdk.interfaces.IAtom) Atom(org.openscience.cdk.Atom) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Aggregations

INCHI_OPTION (net.sf.jniinchi.INCHI_OPTION)9 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)8 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 InChIGeneratorFactory (org.openscience.cdk.inchi.InChIGeneratorFactory)6 InChIGenerator (org.openscience.cdk.inchi.InChIGenerator)5 Atom (org.openscience.cdk.Atom)3 AtomContainer (org.openscience.cdk.AtomContainer)3 IAtom (org.openscience.cdk.interfaces.IAtom)3 SmilesParser (org.openscience.cdk.smiles.SmilesParser)3 INCHI_RET (net.sf.jniinchi.INCHI_RET)2 StructureRecord (ambit2.base.data.StructureRecord)1 FileWriter (java.io.FileWriter)1 RandomAccessFile (java.io.RandomAccessFile)1 Bond (org.openscience.cdk.Bond)1 IBond (org.openscience.cdk.interfaces.IBond)1