Search in sources :

Example 1 with DescriptorsFactory

use of ambit2.descriptors.processors.DescriptorsFactory 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 2 with DescriptorsFactory

use of ambit2.descriptors.processors.DescriptorsFactory in project ambit-mirror by ideaconsult.

the class DescriptorsFactoryTest method testProcess.

@Test
public void testProcess() throws Exception {
    DescriptorsFactory factory = new DescriptorsFactory();
    Profile profile = factory.process(null);
    Assert.assertNotNull(profile);
    Iterator<Property> p = profile.getProperties(false);
    while (p.hasNext()) {
        Assert.assertNotNull(p.next().getClazz());
    }
    Assert.assertEquals(44, profile.size());
}
Also used : DescriptorsFactory(ambit2.descriptors.processors.DescriptorsFactory) Property(ambit2.base.data.Property) Profile(ambit2.base.data.Profile) Test(org.junit.Test)

Aggregations

Profile (ambit2.base.data.Profile)2 Property (ambit2.base.data.Property)2 DescriptorsFactory (ambit2.descriptors.processors.DescriptorsFactory)2 Test (org.junit.Test)2 StructureRecord (ambit2.base.data.StructureRecord)1 IStructureRecord (ambit2.base.interfaces.IStructureRecord)1 HydrogenAdderProcessor (ambit2.core.processors.structure.HydrogenAdderProcessor)1 PropertyCalculationProcessor (ambit2.descriptors.processors.PropertyCalculationProcessor)1 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)1 ITable (org.dbunit.dataset.ITable)1 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)1 DescriptorValue (org.openscience.cdk.qsar.DescriptorValue)1