use of org.openscience.cdk.ChemFile in project cdk by cdk.
the class PetitjeanShapeIndexDescriptorTest method testPetitjeanShapeIndexDescriptor.
@Test
public void testPetitjeanShapeIndexDescriptor() throws Exception {
// first molecule is nbutane, second is naphthalene
String filename = "petitejean.sdf";
InputStream ins = this.getClass().getResourceAsStream(filename);
ISimpleChemObjectReader reader = new MDLV2000Reader(ins);
ChemFile content = (ChemFile) reader.read((ChemObject) new ChemFile());
List cList = ChemFileManipulator.getAllAtomContainers(content);
IAtomContainer ac = (IAtomContainer) cList.get(0);
DescriptorValue result = descriptor.calculate(ac);
DoubleArrayResult dar = (DoubleArrayResult) result.getValue();
Assert.assertEquals(0.5, dar.get(0), 0.00001);
Assert.assertEquals(0.606477, dar.get(1), 0.000001);
ac = (IAtomContainer) cList.get(1);
result = descriptor.calculate(ac);
dar = (DoubleArrayResult) result.getValue();
Assert.assertEquals(0.666666, dar.get(0), 0.000001);
Assert.assertEquals(0.845452, dar.get(1), 0.000001);
}
use of org.openscience.cdk.ChemFile in project cdk by cdk.
the class BCUTDescriptorTest method testBCUT.
@Test
public void testBCUT() throws Exception {
String filename = "gravindex.hin";
InputStream ins = this.getClass().getResourceAsStream(filename);
ISimpleChemObjectReader reader = new HINReader(ins);
ChemFile content = (ChemFile) reader.read((ChemObject) new ChemFile());
List cList = ChemFileManipulator.getAllAtomContainers(content);
IAtomContainer ac = (IAtomContainer) cList.get(0);
Object[] params = new Object[3];
params[0] = 2;
params[1] = 2;
params[2] = true;
descriptor.setParameters(params);
DescriptorValue descriptorValue = descriptor.calculate(ac);
DoubleArrayResult retval = (DoubleArrayResult) descriptorValue.getValue();
Assert.assertNotNull(retval);
/* System.out.println("Num ret = "+retval.size()); */
for (int i = 0; i < retval.length(); i++) {
Assert.assertTrue("The returned value must be non-zero", Math.abs(0.0 - retval.get(i)) > 0.0000001);
}
String[] names = descriptorValue.getNames();
for (String name : names) Assert.assertNotNull(name);
/*
* Assert.assertEquals(1756.5060703860984,
* ((Double)retval.get(0)).doubleValue(), 0.00000001);
* Assert.assertEquals(41.91069159994975,
* ((Double)retval.get(1)).doubleValue(), 0.00000001);
* Assert.assertEquals(12.06562671430088,
* ((Double)retval.get(2)).doubleValue(), 0.00000001);
* Assert.assertEquals(1976.6432599699767,
* ((Double)retval.get(3)).doubleValue(), 0.00000001);
* Assert.assertEquals(44.45945636161082,
* ((Double)retval.get(4)).doubleValue(), 0.00000001);
* Assert.assertEquals(12.549972243701887,
* ((Double)retval.get(5)).doubleValue(), 0.00000001);
* Assert.assertEquals(4333.097373073368,
* ((Double)retval.get(6)).doubleValue(), 0.00000001);
* Assert.assertEquals(65.82626658920714,
* ((Double)retval.get(7)).doubleValue(), 0.00000001);
* Assert.assertEquals(16.302948232909483,
* ((Double)retval.get(8)).doubleValue(), 0.00000001);
*/
}
use of org.openscience.cdk.ChemFile in project cdk by cdk.
the class CPSADescriptorTest method testChargedMolecule.
@Test
public void testChargedMolecule() throws Exception {
String filename = "cpsa-charged.sdf";
InputStream ins = this.getClass().getResourceAsStream(filename);
ISimpleChemObjectReader reader = new MDLV2000Reader(ins);
ChemFile content = (ChemFile) reader.read((ChemObject) new ChemFile());
List cList = ChemFileManipulator.getAllAtomContainers(content);
IAtomContainer ac = (IAtomContainer) cList.get(0);
DoubleArrayResult retval = (DoubleArrayResult) descriptor.calculate(ac).getValue();
int ndesc = retval.length();
for (int i = 0; i < ndesc; i++) Assert.assertTrue(retval.get(i) != Double.NaN);
}
use of org.openscience.cdk.ChemFile in project cdk by cdk.
the class CPSADescriptorTest method testUnChargedMolecule.
@Test
public void testUnChargedMolecule() throws Exception {
String filename = "cpsa-uncharged.sdf";
InputStream ins = this.getClass().getResourceAsStream(filename);
ISimpleChemObjectReader reader = new MDLV2000Reader(ins);
ChemFile content = (ChemFile) reader.read((ChemObject) new ChemFile());
List cList = ChemFileManipulator.getAllAtomContainers(content);
IAtomContainer ac = (IAtomContainer) cList.get(0);
DoubleArrayResult retval = (DoubleArrayResult) descriptor.calculate(ac).getValue();
int ndesc = retval.length();
for (int i = 0; i < ndesc; i++) Assert.assertTrue(retval.get(i) != Double.NaN);
}
use of org.openscience.cdk.ChemFile in project cdk by cdk.
the class LengthOverBreadthDescriptorTest method testLOBDescriptorCholesterol.
@Test
public void testLOBDescriptorCholesterol() throws Exception {
String filename = "lobtest.sdf";
InputStream ins = this.getClass().getResourceAsStream(filename);
ISimpleChemObjectReader reader = new MDLV2000Reader(ins);
ChemFile content = reader.read(new ChemFile());
List cList = ChemFileManipulator.getAllAtomContainers(content);
IAtomContainer ac = (IAtomContainer) cList.get(0);
Isotopes.getInstance().configureAtoms(ac);
DoubleArrayResult result = (DoubleArrayResult) descriptor.calculate(ac).getValue();
Assert.assertEquals(3.5029, result.get(0), 0.001);
Assert.assertEquals(3.5029, result.get(1), 0.001);
}
Aggregations