Search in sources :

Example 1 with HINReader

use of org.openscience.cdk.io.HINReader in project cdk by cdk.

the class MomentOfInertiaDescriptorTest method testMomentOfInertia2.

@Test
public void testMomentOfInertia2() throws java.lang.Exception {
    String filename = "momi2.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);
    DoubleArrayResult retval = (DoubleArrayResult) descriptor.calculate(ac).getValue();
    Assert.assertEquals(10068.419360, retval.get(0), 0.00001);
    Assert.assertEquals(9731.078356, retval.get(1), 0.00001);
    Assert.assertEquals(773.612799, retval.get(2), 0.00001);
    Assert.assertEquals(1.034666, retval.get(3), 0.00001);
    Assert.assertEquals(13.014804, retval.get(4), 0.00001);
    Assert.assertEquals(12.578745, retval.get(5), 0.00001);
    Assert.assertEquals(8.2966226, retval.get(6), 0.00001);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) HINReader(org.openscience.cdk.io.HINReader) 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) Test(org.junit.Test)

Example 2 with HINReader

use of org.openscience.cdk.io.HINReader 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 3 with HINReader

use of org.openscience.cdk.io.HINReader in project cdk by cdk.

the class ConnectivityCheckerTest method testIsConnectedFromHINFile.

/**
 * @cdk.bug 2126904
 */
@Test
public void testIsConnectedFromHINFile() throws Exception {
    String filename = "connectivity1.hin";
    InputStream ins = this.getClass().getResourceAsStream(filename);
    ISimpleChemObjectReader reader = new HINReader(ins);
    ChemFile content = (ChemFile) reader.read((ChemObject) new ChemFile());
    List<IAtomContainer> cList = ChemFileManipulator.getAllAtomContainers(content);
    IAtomContainer ac = cList.get(0);
    Assert.assertTrue("Molecule appears not to be connected", ConnectivityChecker.isConnected(ac));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) HINReader(org.openscience.cdk.io.HINReader) InputStream(java.io.InputStream) ISimpleChemObjectReader(org.openscience.cdk.io.ISimpleChemObjectReader) Test(org.junit.Test)

Example 4 with HINReader

use of org.openscience.cdk.io.HINReader in project cdk by cdk.

the class BCUTDescriptorTest method testExtraEigenvalues.

@Test
public void testExtraEigenvalues() 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] = 0;
    params[1] = 25;
    params[2] = true;
    descriptor.setParameters(params);
    DescriptorValue descriptorValue = descriptor.calculate(ac);
    DoubleArrayResult retval = (DoubleArrayResult) descriptorValue.getValue();
    int nheavy = 20;
    Assert.assertEquals(75, retval.length());
    for (int i = 0; i < nheavy; i++) Assert.assertTrue(retval.get(i) != Double.NaN);
    for (int i = nheavy; i < nheavy + 5; i++) {
        Assert.assertTrue("Extra eigenvalue should have been NaN", Double.isNaN(retval.get(i)));
    }
}
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 5 with HINReader

use of org.openscience.cdk.io.HINReader in project cdk by cdk.

the class CPSADescriptorTest method testCPSA.

@Test
public void testCPSA() throws Exception {
    String filename = "benzene.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);
    DoubleArrayResult retval = (DoubleArrayResult) descriptor.calculate(ac).getValue();
    /*
         * System.out.println("Num ret = "+retval.size()); for (int i = 0; i <
         * retval.size(); i++) { System.out.println( retval.get(i) ); }
         */
    // RPSA
    Assert.assertEquals(0, retval.get(28), 0.0001);
    // RHSA
    Assert.assertEquals(1, retval.get(27), 0.0001);
    // TPSA
    Assert.assertEquals(0, retval.get(26), 0.0001);
    // THSA
    Assert.assertEquals(231.66182, retval.get(25), 0.0001);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) HINReader(org.openscience.cdk.io.HINReader) 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) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)9 Test (org.junit.Test)9 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)9 HINReader (org.openscience.cdk.io.HINReader)9 ISimpleChemObjectReader (org.openscience.cdk.io.ISimpleChemObjectReader)9 ChemFile (org.openscience.cdk.ChemFile)8 ChemObject (org.openscience.cdk.ChemObject)8 List (java.util.List)7 DoubleArrayResult (org.openscience.cdk.qsar.result.DoubleArrayResult)6 DescriptorValue (org.openscience.cdk.qsar.DescriptorValue)2 Point3d (javax.vecmath.Point3d)1 Atom (org.openscience.cdk.Atom)1 IntegerResult (org.openscience.cdk.qsar.result.IntegerResult)1