use of ambit2.descriptors.FunctionalGroup in project ambit-mirror by ideaconsult.
the class DbReaderTest method testProcess.
@Test
public void testProcess() 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());
ProcessorsChain<IStructureRecord, IBatchStatistics, IProcessor> p = new ProcessorsChain<IStructureRecord, IBatchStatistics, IProcessor>();
p.add(new ProcessorStructureRetrieval());
p.add(new IProcessor<IStructureRecord, IStructureRecord>() {
public boolean isEnabled() {
return true;
}
public IStructureRecord process(IStructureRecord target) throws AmbitException {
// System.out.println(target.getContent());
return target;
}
public void setEnabled(boolean value) {
}
public long getID() {
return 0;
}
@Override
public void open() throws Exception {
}
@Override
public void close() throws Exception {
}
});
p.add(new MoleculeReader());
p.add(new AtomConfigurator());
p.add(new FunctionalGroup("Test", "P", "Test"));
p.add(new IProcessor<VerboseDescriptorResult, String>() {
/**
*/
private static final long serialVersionUID = -3923864774580483348L;
public String process(VerboseDescriptorResult target) throws AmbitException {
Assert.assertEquals("1", target.getResult().toString());
return target.toString();
}
public boolean isEnabled() {
return true;
}
public void setEnabled(boolean value) {
}
public long getID() {
return 0;
}
@Override
public void open() throws Exception {
}
@Override
public void close() throws Exception {
}
});
batch.setProcessorChain(p);
QueryStructureByID query = new QueryStructureByID(100215);
batch.setConnection(c.getConnection());
batch.open();
IBatchStatistics stats = batch.process(query);
Assert.assertEquals(1, stats.getRecords(IBatchStatistics.RECORDS_STATS.RECORDS_READ));
Assert.assertEquals(1, stats.getRecords(IBatchStatistics.RECORDS_STATS.RECORDS_PROCESSED));
// C20H20BrP
}
use of ambit2.descriptors.FunctionalGroup in project ambit-mirror by ideaconsult.
the class QuerySmartsTest method testMatchNoAccelerator.
@Test
public void testMatchNoAccelerator() throws Exception {
Preferences.setProperty(Preferences.FASTSMARTS, "false");
QuerySMARTS q = new QuerySMARTS();
q.setValue(new FunctionalGroup("aromatic aldehyde example", "c1ccccc1[$(C(C)C(=O)),$(CC(C)C(=O))]", ""));
// "c1ccccc1C(C)C(=O)",""));
RawIteratingSDFReader reader = new RawIteratingSDFReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("ambit2/db/processors/test/smartssearch.sdf")));
int count = 0;
while (reader.hasNext()) {
IStructureRecord record = reader.nextRecord();
Assert.assertEquals(1.0, q.calculateMetric(record));
count++;
}
Assert.assertEquals(2, count);
}
use of ambit2.descriptors.FunctionalGroup in project ambit-mirror by ideaconsult.
the class FuncGroupsDescriptorFactoryTest method testSaveFragments.
@Test
public void testSaveFragments() throws Exception {
FuncGroupsDescriptorFactory factory = new FuncGroupsDescriptorFactory();
Collection<FunctionalGroup> list = factory.process(null);
File temp = File.createTempFile("test_save_funcgroups", ".xml");
OutputStream writer = new FileOutputStream(temp);
FuncGroupsDescriptorFactory.saveFragments(writer, list);
writer.flush();
writer.close();
Collection<FunctionalGroup> newlist = factory.process(temp.getAbsolutePath());
Assert.assertEquals(list.size(), newlist.size());
for (FunctionalGroup group : newlist) {
Assert.assertNotSame("", group.getSmarts());
Assert.assertNotSame("", group.getName());
Assert.assertNotSame("", group.getFamily());
}
temp.delete();
}
use of ambit2.descriptors.FunctionalGroup in project ambit-mirror by ideaconsult.
the class FunctionalGroupDescriptorTest method testMultiple.
@Test
public void testMultiple() throws Exception {
groups = new ArrayList<FunctionalGroup>();
groups.add(new FunctionalGroup("C4", "CCCC", "test4"));
groups.add(new FunctionalGroup("C5", "CCCCC", "test5"));
calculate(groups, false, MoleculeFactory.makeAlkane(4), 2);
}
use of ambit2.descriptors.FunctionalGroup in project ambit-mirror by ideaconsult.
the class FunctionalGroupDescriptorTest method testSingle.
@Test
public void testSingle() throws Exception {
groups = new ArrayList<FunctionalGroup>();
groups.add(new FunctionalGroup("C4", "CCCC", "test4"));
calculate(groups, false, MoleculeFactory.makeAlkane(4), 1);
}
Aggregations