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();
*/
}
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());
}
Aggregations