Search in sources :

Example 11 with ChemFile

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);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemObject(org.openscience.cdk.ChemObject) InputStream(java.io.InputStream) ChemFile(org.openscience.cdk.ChemFile) ISimpleChemObjectReader(org.openscience.cdk.io.ISimpleChemObjectReader) List(java.util.List) DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) MDLV2000Reader(org.openscience.cdk.io.MDLV2000Reader) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) Test(org.junit.Test)

Example 12 with ChemFile

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);
         */
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemObject(org.openscience.cdk.ChemObject) InputStream(java.io.InputStream) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) HINReader(org.openscience.cdk.io.HINReader) ChemFile(org.openscience.cdk.ChemFile) ISimpleChemObjectReader(org.openscience.cdk.io.ISimpleChemObjectReader) List(java.util.List) ChemObject(org.openscience.cdk.ChemObject) DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) Test(org.junit.Test)

Example 13 with ChemFile

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);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemObject(org.openscience.cdk.ChemObject) InputStream(java.io.InputStream) ChemFile(org.openscience.cdk.ChemFile) ISimpleChemObjectReader(org.openscience.cdk.io.ISimpleChemObjectReader) List(java.util.List) DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) MDLV2000Reader(org.openscience.cdk.io.MDLV2000Reader) Test(org.junit.Test)

Example 14 with ChemFile

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);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemObject(org.openscience.cdk.ChemObject) InputStream(java.io.InputStream) ChemFile(org.openscience.cdk.ChemFile) ISimpleChemObjectReader(org.openscience.cdk.io.ISimpleChemObjectReader) List(java.util.List) DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) MDLV2000Reader(org.openscience.cdk.io.MDLV2000Reader) Test(org.junit.Test)

Example 15 with ChemFile

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);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) InputStream(java.io.InputStream) ChemFile(org.openscience.cdk.ChemFile) ISimpleChemObjectReader(org.openscience.cdk.io.ISimpleChemObjectReader) List(java.util.List) DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) MDLV2000Reader(org.openscience.cdk.io.MDLV2000Reader) Test(org.junit.Test)

Aggregations

ChemFile (org.openscience.cdk.ChemFile)188 InputStream (java.io.InputStream)171 Test (org.junit.Test)171 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)154 IChemFile (org.openscience.cdk.interfaces.IChemFile)112 ChemObject (org.openscience.cdk.ChemObject)68 SimpleChemObjectReaderTest (org.openscience.cdk.test.io.SimpleChemObjectReaderTest)66 IChemSequence (org.openscience.cdk.interfaces.IChemSequence)57 IChemModel (org.openscience.cdk.interfaces.IChemModel)55 MDLV2000Reader (org.openscience.cdk.io.MDLV2000Reader)52 CMLReader (org.openscience.cdk.io.CMLReader)41 IAtomContainerSet (org.openscience.cdk.interfaces.IAtomContainerSet)33 ByteArrayInputStream (java.io.ByteArrayInputStream)30 ISimpleChemObjectReader (org.openscience.cdk.io.ISimpleChemObjectReader)25 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)23 List (java.util.List)21 IAtom (org.openscience.cdk.interfaces.IAtom)19 SlowTest (org.openscience.cdk.test.SlowTest)18 DoubleArrayResult (org.openscience.cdk.qsar.result.DoubleArrayResult)15 IReaction (org.openscience.cdk.interfaces.IReaction)11