Search in sources :

Example 1 with DbDescriptorWriter

use of ambit2.db.processors.DbDescriptorWriter in project ambit-mirror by ideaconsult.

the class DbDescriptorWriterTest method testWriteAllDescriptors.

@Test
public void testWriteAllDescriptors() throws Exception {
    setUpDatabaseFromResource("ambit2/db/processors/test/descriptors-datasets.xml");
    DbDescriptorWriter writer = new DbDescriptorWriter();
    IDatabaseConnection c = getConnection();
    ITable names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
    Assert.assertEquals(5, names.getRowCount());
    writer.setConnection(c.getConnection());
    writer.open();
    XLogPDescriptor xlogp = new XLogPDescriptor();
    writer.write(xlogp.calculate(MoleculeFactory.makeAlkane(10)));
    DescriptorValue v = new DescriptorValue(new DescriptorSpecification("XLogPReference", "XLogPTitle", "XLogPIdentifier", "XLogPVendor"), new String[] {}, new Object[] {}, new DoubleResult(5), new String[] { "XLogP" });
    writer.write(xlogp.calculate(MoleculeFactory.makeAlkane(10)));
    writer.write(v);
    c.close();
    c = getConnection();
    names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
    Assert.assertEquals(7, names.getRowCount());
    ITable values = c.createQueryTable("EXPECTED_VALUES", "SELECT * FROM property_values");
    Assert.assertEquals(2, values.getRowCount());
    c.close();
}
Also used : DbDescriptorWriter(ambit2.db.processors.DbDescriptorWriter) ITable(org.dbunit.dataset.ITable) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) DoubleResult(org.openscience.cdk.qsar.result.DoubleResult) DescriptorSpecification(org.openscience.cdk.qsar.DescriptorSpecification) XLogPDescriptor(org.openscience.cdk.qsar.descriptors.molecular.XLogPDescriptor) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) Test(org.junit.Test)

Example 2 with DbDescriptorWriter

use of ambit2.db.processors.DbDescriptorWriter in project ambit-mirror by ideaconsult.

the class DbDescriptorWriterTest method testWriteFunctionalGroups.

@Test
public void testWriteFunctionalGroups() throws Exception {
    setUpDatabaseFromResource("ambit2/db/processors/test/descriptors-datasets.xml");
    DbDescriptorWriter writer = new DbDescriptorWriter();
    IDatabaseConnection c = getConnection();
    ITable names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
    Assert.assertEquals(5, names.getRowCount());
    writer.setConnection(c.getConnection());
    writer.open();
    FunctionalGroupDescriptor d = new FunctionalGroupDescriptor();
    Assert.assertEquals(84, ((List) d.getParameters()[0]).size());
    DescriptorValue v = d.calculate(MoleculeFactory.makePhenylAmine());
    Assert.assertEquals(84, v.getNames().length);
    writer.write(v);
    c.close();
    c = getConnection();
    names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
    Assert.assertEquals(89, 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 properties join catalog_references using(idreference) where title=\"" + d.getClass().getName() + "\"");
    Assert.assertEquals(84, templates.getRowCount());
    c.close();
}
Also used : DbDescriptorWriter(ambit2.db.processors.DbDescriptorWriter) FunctionalGroupDescriptor(ambit2.descriptors.FunctionalGroupDescriptor) ITable(org.dbunit.dataset.ITable) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) Test(org.junit.Test)

Example 3 with DbDescriptorWriter

use of ambit2.db.processors.DbDescriptorWriter in project ambit-mirror by ideaconsult.

the class DbDescriptorWriterTest method test.

@Test
public void test() throws Exception {
    setUpDatabaseFromResource("ambit2/db/processors/test/descriptors-datasets.xml");
    DbDescriptorWriter writer = new DbDescriptorWriter();
    IDatabaseConnection c = getConnection();
    ITable names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
    Assert.assertEquals(5, names.getRowCount());
    writer.setConnection(c.getConnection());
    writer.open();
    XLogPDescriptor xlogp = new XLogPDescriptor();
    writer.write(xlogp.calculate(MoleculeFactory.makeAlkane(10)));
    DescriptorValue v = new DescriptorValue(new DescriptorSpecification("XLogPReference", "XLogPTitle", "XLogPIdentifier", "XLogPVendor"), new String[] {}, new Object[] {}, new DoubleResult(5), new String[] { "XLogP" });
    writer.write(xlogp.calculate(MoleculeFactory.makeAlkane(10)));
    writer.write(v);
    c.close();
    c = getConnection();
    names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
    Assert.assertEquals(7, names.getRowCount());
    ITable values = c.createQueryTable("EXPECTED_VALUES", "SELECT * FROM property_values");
    Assert.assertEquals(2, values.getRowCount());
    c.close();
}
Also used : DbDescriptorWriter(ambit2.db.processors.DbDescriptorWriter) ITable(org.dbunit.dataset.ITable) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) DoubleResult(org.openscience.cdk.qsar.result.DoubleResult) DescriptorSpecification(org.openscience.cdk.qsar.DescriptorSpecification) XLogPDescriptor(org.openscience.cdk.qsar.descriptors.molecular.XLogPDescriptor) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) Test(org.junit.Test)

Aggregations

DbDescriptorWriter (ambit2.db.processors.DbDescriptorWriter)3 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)3 ITable (org.dbunit.dataset.ITable)3 Test (org.junit.Test)3 DescriptorValue (org.openscience.cdk.qsar.DescriptorValue)3 DescriptorSpecification (org.openscience.cdk.qsar.DescriptorSpecification)2 XLogPDescriptor (org.openscience.cdk.qsar.descriptors.molecular.XLogPDescriptor)2 DoubleResult (org.openscience.cdk.qsar.result.DoubleResult)2 FunctionalGroupDescriptor (ambit2.descriptors.FunctionalGroupDescriptor)1