use of org.openscience.cdk.qsar.descriptors.molecular.XLogPDescriptor in project ambit-mirror by ideaconsult.
the class DbDescriptorValuesWriterTest method testWriteDescriptorValue.
/**
* Test method for
* {@link ambit2.db.processors.DbDescriptorWriter#write(org.openscience.cdk.qsar.DescriptorValue)}
* .
*/
@Test
public void testWriteDescriptorValue() 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 dictionary = c.createQueryTable("EXPECTED_ONTOLOGY", "SELECT * FROM dictionary");
Assert.assertEquals(3, dictionary.getRowCount());
writer.setConnection(c.getConnection());
writer.open();
XLogPDescriptor xlogp = new XLogPDescriptor();
writer.setStructure(new StructureRecord(7, 100211, "", ""));
writer.write(xlogp.calculate(MoleculeFactory.makeAlkane(10)));
names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
Assert.assertEquals(6, names.getRowCount());
values = c.createQueryTable("EXPECTED_VALUES", "SELECT * FROM property_values");
Assert.assertEquals(3, values.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();
c = getConnection();
names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
Assert.assertEquals(7, names.getRowCount());
values = c.createQueryTable("EXPECTED_VALUES", "SELECT value_num FROM property_values WHERE idstructure=100214");
Assert.assertEquals(1, values.getRowCount());
Assert.assertEquals(5.01, (Double) DataType.DOUBLE.typeCast(values.getValue(0, "value_num")), 1E-4);
c.close();
}
use of org.openscience.cdk.qsar.descriptors.molecular.XLogPDescriptor in project ambit-mirror by ideaconsult.
the class DbDescriptorValuesWriterTest method testReadWriteProperty.
@Test
public void testReadWriteProperty() throws Exception {
setUpDatabaseFromResource("ambit2/db/processors/test/experiments-datasets.xml");
IDatabaseConnection c = getConnection();
ITable names = c.createQueryTable("EXPECTED_FIELDS", "SELECT * FROM property_values");
Assert.assertEquals(0, names.getRowCount());
XLogPDescriptor xlogp = new XLogPDescriptor();
RepositoryReader reader = new RepositoryReader();
reader.setConnection(c.getConnection());
writer.setConnection(c.getConnection());
writer.open();
reader.open();
int records = 0;
long now = System.currentTimeMillis();
IChemObjectBuilder b = SilentChemObjectBuilder.getInstance();
IStructureRecord o;
while (reader.hasNext()) {
o = reader.next();
String content = reader.getStructure(o.getIdstructure());
if (content == null)
continue;
IIteratingChemObjectReader mReader = new IteratingSDFReader(new StringReader(content), b);
if (mReader.hasNext()) {
Object mol = mReader.next();
if (mol instanceof IAtomContainer) {
writer.setStructure(o);
writer.write(xlogp.calculate((IAtomContainer) mol));
}
}
o.clear();
mReader.close();
mReader = null;
records++;
}
reader.close();
writer.close();
now = System.currentTimeMillis() - now;
c = getConnection();
names = c.createQueryTable("EXPECTED_FIELDS", "SELECT * FROM property_values where value_num is not null");
Assert.assertEquals(2, names.getRowCount());
names = c.createQueryTable("EXPECTED_FIELDS", "SELECT * FROM property_values where idstructure in (105095,109287)");
Assert.assertEquals(2, names.getRowCount());
c.close();
}
use of org.openscience.cdk.qsar.descriptors.molecular.XLogPDescriptor 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();
}
use of org.openscience.cdk.qsar.descriptors.molecular.XLogPDescriptor in project ambit-mirror by ideaconsult.
the class DbDescriptorValuesWriterTest method testWriteStringDescriptorValue.
@Test
public void testWriteStringDescriptorValue() 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());
writer.setConnection(c.getConnection());
writer.open();
XLogPDescriptor xlogp = new XLogPDescriptor();
writer.setStructure(new StructureRecord(7, 100211, "", ""));
writer.write(xlogp.calculate(MoleculeFactory.makeAlkane(10)));
names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
Assert.assertEquals(6, names.getRowCount());
values = c.createQueryTable("EXPECTED_VALUES", "SELECT * FROM property_values");
Assert.assertEquals(3, values.getRowCount());
DescriptorValue v = new DescriptorValue(new DescriptorSpecification("XLogPReference", "XLogPTitle", "XLogPIdentifier", "XLogPVendor"), new String[] {}, new Object[] {}, new StringDescriptorResultType("TESTVALUE"), new String[] { "XLogP" });
writer.setStructure(new StructureRecord(10, 100214, "", ""));
writer.write(v);
// one more time
writer.write(v);
c.close();
c = getConnection();
names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
Assert.assertEquals(7, names.getRowCount());
values = c.createQueryTable("EXPECTED_VALUES", "SELECT value FROM values_string WHERE idstructure=100214");
Assert.assertEquals(1, values.getRowCount());
Object o = values.getValue(0, "value");
if (o instanceof String)
Assert.assertEquals("TESTVALUE", (String) o);
else
Assert.assertEquals("TESTVALUE", new String((byte[]) o));
c.close();
}
use of org.openscience.cdk.qsar.descriptors.molecular.XLogPDescriptor 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();
}
Aggregations