Search in sources :

Example 1 with HydrogenAdderProcessor

use of ambit2.core.processors.structure.HydrogenAdderProcessor in project ambit-mirror by ideaconsult.

the class HydrogenAdderProcessorTest method testImplicitH_processorFormula.

/**
 * CDK bug and a fix https://sourceforge.net/tracker/index.php?func=detail&aid=2983334&group_id=20024&atid=120024#
 * @throws Exception
 */
@Test
public void testImplicitH_processorFormula() throws Exception {
    HydrogenAdderProcessor p = new HydrogenAdderProcessor();
    p.setAddEexplicitHydrogens(false);
    IAtomContainer mol = MoleculeFactory.makeBenzene();
    IMolecularFormula f = MolecularFormulaManipulator.getMolecularFormula(mol);
    Assert.assertEquals("C6", MolecularFormulaManipulator.getString(f));
    Assert.assertEquals(6, mol.getAtomCount());
    mol = p.process(mol);
    Assert.assertEquals(6, mol.getAtomCount());
    f = MolecularFormulaManipulator.getMolecularFormula(mol);
    Assert.assertEquals("C6H6", MolecularFormulaManipulator.getString(f));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) HydrogenAdderProcessor(ambit2.core.processors.structure.HydrogenAdderProcessor) IMolecularFormula(org.openscience.cdk.interfaces.IMolecularFormula) Test(org.junit.Test)

Example 2 with HydrogenAdderProcessor

use of ambit2.core.processors.structure.HydrogenAdderProcessor 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);
}
Also used : InchiProcessor(ambit2.core.processors.structure.InchiProcessor) InChIGenerator(org.openscience.cdk.inchi.InChIGenerator) HydrogenAdderProcessor(ambit2.core.processors.structure.HydrogenAdderProcessor)

Example 3 with HydrogenAdderProcessor

use of ambit2.core.processors.structure.HydrogenAdderProcessor in project ambit-mirror by ideaconsult.

the class DbDescriptorValuesWriterTest method testWriteDescriptorValueFromProfile.

/**
 * Test method for
 * {@link ambit2.db.processors.DbDescriptorWriter#write(org.openscience.cdk.qsar.DescriptorValue)}
 * .
 */
@Test
public void testWriteDescriptorValueFromProfile() throws Exception {
    setUpDatabaseFromResource("ambit2/db/processors/test/descriptors-datasets.xml");
    IDatabaseConnection c = getConnection();
    ITable names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
    Assert.assertEquals(5, names.getRowCount());
    ITable values = c.createQueryTable("EXPECTED_VALUES", "SELECT * FROM property_values");
    Assert.assertEquals(2, values.getRowCount());
    ITable templates = c.createQueryTable("EXPECTED_TEMPLATES", "SELECT * FROM template");
    Assert.assertEquals(5, templates.getRowCount());
    ITable template_def = c.createQueryTable("EXPECTED_TEMPLATES", "SELECT * FROM template_def");
    Assert.assertEquals(3, template_def.getRowCount());
    ITable dictionary = c.createQueryTable("EXPECTED_ONTOLOGY", "SELECT * FROM dictionary");
    Assert.assertEquals(3, dictionary.getRowCount());
    writer.setConnection(c.getConnection());
    writer.open();
    writer.setStructure(new StructureRecord(7, 100211, "", ""));
    // 3D molecule
    IAtomContainer mol = getTestMolecule();
    HydrogenAdderProcessor h = new HydrogenAdderProcessor();
    h.setAddEexplicitHydrogens(false);
    mol = h.process(mol);
    DescriptorsFactory factory = new DescriptorsFactory();
    PropertyCalculationProcessor calc = new PropertyCalculationProcessor();
    Profile profile = factory.process(null);
    Iterator<Property> i = profile.getProperties(true);
    int count = 0;
    int countValues = 0;
    while (i.hasNext()) {
        try {
            Property p = i.next();
            // if (p.getClazz().getName().indexOf("ambit")>=0) {
            if (p.isEnabled()) {
                count++;
                calc.setProperty(i.next());
                DescriptorValue value = calc.process(mol);
                countValues += value.getNames().length;
                writer.write(value);
            }
        } catch (Exception x) {
            throw new Exception(x);
        }
    }
    names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
    Assert.assertEquals(5 + countValues, names.getRowCount());
    values = c.createQueryTable("EXPECTED_VALUES", "SELECT * FROM property_values WHERE status ='OK' ");
    Assert.assertEquals(countValues, values.getRowCount());
    template_def = c.createQueryTable("EXPECTED_TEMPLATES", "SELECT type FROM catalog_references where type=\"Algorithm\"");
    Assert.assertEquals(4, template_def.getRowCount());
/*
		 * DescriptorValue v = new DescriptorValue( new
		 * DescriptorSpecification("XLogPReference"
		 * ,"XLogPTitle","XLogPIdentifier","XLogPVendor"), new String[] {}, new
		 * Object[] {}, new DoubleResult(5.01), new String[] {"XLogP"} );
		 * writer.setStructure(new StructureRecord(10,100214,"",""));
		 * writer.write(v); //one more time writer.write(v); c.close();
		 */
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) Profile(ambit2.base.data.Profile) PropertyCalculationProcessor(ambit2.descriptors.processors.PropertyCalculationProcessor) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) HydrogenAdderProcessor(ambit2.core.processors.structure.HydrogenAdderProcessor) StructureRecord(ambit2.base.data.StructureRecord) IStructureRecord(ambit2.base.interfaces.IStructureRecord) ITable(org.dbunit.dataset.ITable) DescriptorsFactory(ambit2.descriptors.processors.DescriptorsFactory) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) Property(ambit2.base.data.Property) Test(org.junit.Test)

Example 4 with HydrogenAdderProcessor

use of ambit2.core.processors.structure.HydrogenAdderProcessor in project ambit-mirror by ideaconsult.

the class FunctionalGroupDescriptorTest method setUp.

@Before
public void setUp() throws Exception {
    d = new FunctionalGroupDescriptor();
    groups = new ArrayList<FunctionalGroup>();
    groups.add(new FunctionalGroup("alkane", "CCCC", "test"));
    hadder = new HydrogenAdderProcessor();
}
Also used : FunctionalGroup(ambit2.descriptors.FunctionalGroup) HydrogenAdderProcessor(ambit2.core.processors.structure.HydrogenAdderProcessor) FunctionalGroupDescriptor(ambit2.descriptors.FunctionalGroupDescriptor) Before(org.junit.Before)

Example 5 with HydrogenAdderProcessor

use of ambit2.core.processors.structure.HydrogenAdderProcessor in project ambit-mirror by ideaconsult.

the class MolecularWeightDescriptorTest method testBCUT.

// this will hang!
public void testBCUT() throws Exception {
    BCUTDescriptor mw = new BCUTDescriptor();
    SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance());
    // IAtomContainer mol = sp.parseSmiles("O[As](O)O");
    IAtomContainer mol = sp.parseSmiles("O1[As]2O[As]1O2");
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
    HydrogenAdderProcessor p = new HydrogenAdderProcessor();
    DescriptorValue value = mw.calculate(p.process(mol));
    System.out.println(value.getValue());
}
Also used : SmilesParser(org.openscience.cdk.smiles.SmilesParser) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) HydrogenAdderProcessor(ambit2.core.processors.structure.HydrogenAdderProcessor) BCUTDescriptor(org.openscience.cdk.qsar.descriptors.molecular.BCUTDescriptor) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue)

Aggregations

HydrogenAdderProcessor (ambit2.core.processors.structure.HydrogenAdderProcessor)22 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)20 Test (org.junit.Test)13 AtomConfigurator (ambit2.core.processors.structure.AtomConfigurator)11 DescriptorValue (org.openscience.cdk.qsar.DescriptorValue)6 SmilesParser (org.openscience.cdk.smiles.SmilesParser)6 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)3 UniversalIsomorphismTester (org.openscience.cdk.isomorphism.UniversalIsomorphismTester)3 FunctionalGroup (ambit2.descriptors.FunctionalGroup)2 PKANode (ambit2.descriptors.PKANode)2 VerboseDescriptorResult (ambit2.descriptors.VerboseDescriptorResult)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 InputStream (java.io.InputStream)2 CDKException (org.openscience.cdk.exception.CDKException)2 Profile (ambit2.base.data.Profile)1 Property (ambit2.base.data.Property)1 StructureRecord (ambit2.base.data.StructureRecord)1 IStructureRecord (ambit2.base.interfaces.IStructureRecord)1 DelimitedFileWriter (ambit2.core.io.DelimitedFileWriter)1