Search in sources :

Example 1 with DescriptorMopacShell

use of ambit2.mopac.DescriptorMopacShell in project ambit-mirror by ideaconsult.

the class DescriptorMopacShellTest method testCalculate2.

@Test
public void testCalculate2() throws Exception {
    DescriptorMopacShell d = new DescriptorMopacShell();
    String smiles = "[O-][N+](=O)C1=CC(Cl)=C(Cl)C=C1Cl";
    // "[H]C1=C([H])C([H])=C([H])C([H])=C1([H])";
    // todo add hydrogens
    IAtomContainer ac = parser.parseSmiles(smiles);
    DescriptorValue v = (DescriptorValue) d.calculate(ac);
    if (v.getException() != null)
        throw v.getException();
    Assert.assertEquals(Mopac7Reader.parameters.length, v.getNames().length);
    Assert.assertEquals(DescriptorMopacShell.EHOMO, v.getNames()[7]);
    Assert.assertEquals(DescriptorMopacShell.ELUMO, v.getNames()[8]);
    DoubleArrayResult r = (DoubleArrayResult) v.getValue();
    // System.out.println(r.get(7));
    // System.out.println(r.get(8));
    // ehomo
    Assert.assertEquals(-9.70887, r.get(7), 1E-2);
    // elumo
    Assert.assertEquals(-3.54057, r.get(8), 1E-2);
// Assert.assertEquals(78.113,r.get(6),1E-2); //Molecular weight
// Assert.assertEquals(97.85217,r.get(2),1E-2); //FINAL HEAT OF FORMATION
}
Also used : DescriptorMopacShell(ambit2.mopac.DescriptorMopacShell) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) Test(org.junit.Test)

Example 2 with DescriptorMopacShell

use of ambit2.mopac.DescriptorMopacShell in project ambit-mirror by ideaconsult.

the class DescriptorMopacShellTest method testCalculateUnsupportedAtom.

@Test
public void testCalculateUnsupportedAtom() throws Exception {
    DescriptorMopacShell d = new DescriptorMopacShell();
    // todo add hydrogens
    IAtomContainer ac = parser.parseSmiles("C[Si]");
    DescriptorValue value = d.calculate(ac);
    Assert.assertNotNull(value.getException());
    Assert.assertEquals(AbstractMopacShell.MESSAGE_UNSUPPORTED_TYPE + "Si", value.getException().getMessage());
}
Also used : DescriptorMopacShell(ambit2.mopac.DescriptorMopacShell) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) Test(org.junit.Test)

Example 3 with DescriptorMopacShell

use of ambit2.mopac.DescriptorMopacShell in project ambit-mirror by ideaconsult.

the class DescriptorMopacShellTest method testCalculate.

/*
	 * 
	 */
@Test
public void testCalculate() throws Exception {
    DescriptorMopacShell d = new DescriptorMopacShell();
    String smiles = "c1ccccc1";
    // "[H]C1=C([H])C([H])=C([H])C([H])=C1([H])";
    // todo add hydrogens
    IAtomContainer ac = parser.parseSmiles(smiles);
    DescriptorValue v = (DescriptorValue) d.calculate(ac);
    if (v.getException() != null)
        throw v.getException();
    Assert.assertEquals(Mopac7Reader.parameters.length, v.getNames().length);
    Assert.assertEquals(DescriptorMopacShell.EHOMO, v.getNames()[7]);
    Assert.assertEquals(DescriptorMopacShell.ELUMO, v.getNames()[8]);
    DoubleArrayResult r = (DoubleArrayResult) v.getValue();
    if (v.getException() != null)
        throw v.getException();
    // ehomo
    Assert.assertEquals(-9.75051, r.get(7), 1E-2);
    // elumo
    Assert.assertEquals(0.39523, r.get(8), 1E-2);
    // Molecular weight
    Assert.assertEquals(78.113, r.get(6), 1E-2);
    // FINAL HEAT OF FORMATION
    Assert.assertEquals(97.85217, r.get(2), 1E-2);
}
Also used : DescriptorMopacShell(ambit2.mopac.DescriptorMopacShell) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) Test(org.junit.Test)

Example 4 with DescriptorMopacShell

use of ambit2.mopac.DescriptorMopacShell in project ambit-mirror by ideaconsult.

the class DescriptorMopacShellTest method testCalculate1.

@Test
public void testCalculate1() throws Exception {
    DescriptorMopacShell d = new DescriptorMopacShell();
    // todo add H
    IAtomContainer ac = parser.parseSmiles("CCCCCCCCCCC");
    DescriptorValue v = (DescriptorValue) d.calculate(ac);
    if (v.getException() != null)
        throw v.getException();
    Assert.assertEquals(Mopac7Reader.parameters.length, v.getNames().length);
    Assert.assertEquals(DescriptorMopacShell.EHOMO, v.getNames()[7]);
    Assert.assertEquals(DescriptorMopacShell.ELUMO, v.getNames()[8]);
}
Also used : DescriptorMopacShell(ambit2.mopac.DescriptorMopacShell) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) Test(org.junit.Test)

Example 5 with DescriptorMopacShell

use of ambit2.mopac.DescriptorMopacShell in project ambit-mirror by ideaconsult.

the class Mopac7WriterTest method testNCI.

public void testNCI() throws Exception {
    IteratingSDFReader reader = new IteratingSDFReader(new FileInputStream("D:\\nina\\Databases\\nciopen_3D_fixed.sdf"), SilentChemObjectBuilder.getInstance());
    SDFWriter wriOK = new SDFWriter(new FileOutputStream("D:\\nina\\nciopen_3D_electronic_ok.sdf"));
    SDFWriter wriErr = new SDFWriter(new FileOutputStream("D:\\nina\\nciopen_3D_electronic_err.sdf"));
    int n = 0;
    DescriptorMopacShell shell = new DescriptorMopacShell();
    while (reader.hasNext()) {
        Object o = reader.next();
        if (o instanceof IAtomContainer) {
            n++;
            if (n < 210)
                continue;
            if (n > 219)
                break;
            IAtomContainer m = (IAtomContainer) o;
            // writer.write((org.openscience.cdk.interfaces.ChemObject)o);
            DescriptorValue v = shell.calculate(m);
            DoubleArrayResult r = (DoubleArrayResult) v.getValue();
            String[] names = v.getNames();
            Assert.assertEquals(names.length, r.length());
            for (int g = 0; g < names.length; g++) {
                Assert.assertNotNull(r.get(g));
                Assert.assertNull(v.getException());
            // System.out.println(names[g] + "\t= "+r.get(g));
            }
        /*
                    if ((m.getProperty(MopacShell.EHOMO) == null) ||
                    	m.getProperty(MopacShell.ELUMO) == null) {
                        wriErr.setSdFields(m.getProperties());
                        wriErr.writeMolecule(m);
                        System.out.println("HOMO/LUMO not calculated");
                    } else {
                        wriOK.setSdFields(m.getProperties());
                        wriOK.writeMolecule(m);
                        System.out.println("HOMO/LUMO calculated");
                    }
                    */
        }
    // System.out.println(n);
    // if (n > 1)
    }
    Assert.assertEquals(220, n);
    reader.close();
    wriOK.close();
    wriErr.close();
}
Also used : DescriptorMopacShell(ambit2.mopac.DescriptorMopacShell) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) FileOutputStream(java.io.FileOutputStream) IteratingSDFReader(org.openscience.cdk.io.iterator.IteratingSDFReader) SDFWriter(org.openscience.cdk.io.SDFWriter) IChemObject(org.openscience.cdk.interfaces.IChemObject) DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) FileInputStream(java.io.FileInputStream) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue)

Aggregations

DescriptorMopacShell (ambit2.mopac.DescriptorMopacShell)5 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)5 DescriptorValue (org.openscience.cdk.qsar.DescriptorValue)5 Test (org.junit.Test)4 DoubleArrayResult (org.openscience.cdk.qsar.result.DoubleArrayResult)3 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IChemObject (org.openscience.cdk.interfaces.IChemObject)1 SDFWriter (org.openscience.cdk.io.SDFWriter)1 IteratingSDFReader (org.openscience.cdk.io.iterator.IteratingSDFReader)1