use of ambit2.core.processors.structure.HydrogenAdderProcessor in project ambit-mirror by ideaconsult.
the class HydrogenAdderProcessorTest method testImplicitH_processorFormula.
/**
* CDK bug and a fix https://sourceforge.net/tracker/index.php?func=detail&aid=2983334&group_id=20024&atid=120024#
* @throws Exception
*/
@Test
public void testImplicitH_processorFormula() throws Exception {
HydrogenAdderProcessor p = new HydrogenAdderProcessor();
p.setAddEexplicitHydrogens(false);
IAtomContainer mol = MoleculeFactory.makeBenzene();
IMolecularFormula f = MolecularFormulaManipulator.getMolecularFormula(mol);
Assert.assertEquals("C6", MolecularFormulaManipulator.getString(f));
Assert.assertEquals(6, mol.getAtomCount());
mol = p.process(mol);
Assert.assertEquals(6, mol.getAtomCount());
f = MolecularFormulaManipulator.getMolecularFormula(mol);
Assert.assertEquals("C6H6", MolecularFormulaManipulator.getString(f));
}
use of ambit2.core.processors.structure.HydrogenAdderProcessor in project ambit-mirror by ideaconsult.
the class InchiProcessorTest method generate.
public void generate(IAtomContainer mol, String expected, boolean aromatic) throws Exception {
InchiProcessor p = new InchiProcessor();
HydrogenAdderProcessor ha = new HydrogenAdderProcessor();
mol = ha.process(mol);
if (aromatic) {
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
CDKHueckelAromaticityDetector.detectAromaticity(mol);
}
InChIGenerator gen = p.process(mol);
String inchi = gen.getInchi();
String auxinfo = gen.getAuxInfo();
Assert.assertEquals(expected, inchi);
}
use of ambit2.core.processors.structure.HydrogenAdderProcessor 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.core.processors.structure.HydrogenAdderProcessor in project ambit-mirror by ideaconsult.
the class FunctionalGroupDescriptorTest method setUp.
@Before
public void setUp() throws Exception {
d = new FunctionalGroupDescriptor();
groups = new ArrayList<FunctionalGroup>();
groups.add(new FunctionalGroup("alkane", "CCCC", "test"));
hadder = new HydrogenAdderProcessor();
}
use of ambit2.core.processors.structure.HydrogenAdderProcessor in project ambit-mirror by ideaconsult.
the class MolecularWeightDescriptorTest method testBCUT.
// this will hang!
public void testBCUT() throws Exception {
BCUTDescriptor mw = new BCUTDescriptor();
SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance());
// IAtomContainer mol = sp.parseSmiles("O[As](O)O");
IAtomContainer mol = sp.parseSmiles("O1[As]2O[As]1O2");
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
HydrogenAdderProcessor p = new HydrogenAdderProcessor();
DescriptorValue value = mw.calculate(p.process(mol));
System.out.println(value.getValue());
}
Aggregations