Search in sources :

Example 96 with ChemObject

use of org.openscience.cdk.ChemObject in project cdk by cdk.

the class BondToolsTest method testGiveAngleFromMiddle_IAtom_IAtom_IAtom.

@Test
public void testGiveAngleFromMiddle_IAtom_IAtom_IAtom() throws Exception {
    String filename = "testdoublebondconfig.mol";
    InputStream ins = this.getClass().getResourceAsStream(filename);
    MDLV2000Reader reader = new MDLV2000Reader(ins);
    ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
    IAtomContainer mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0);
    Assert.assertEquals(2.0943946986086157, BondTools.giveAngleFromMiddle(mol.getAtom(0), mol.getAtom(2), mol.getAtom(3)), 0.2);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemObject(org.openscience.cdk.ChemObject) InputStream(java.io.InputStream) ChemFile(org.openscience.cdk.ChemFile) MDLV2000Reader(org.openscience.cdk.io.MDLV2000Reader) Test(org.junit.Test)

Example 97 with ChemObject

use of org.openscience.cdk.ChemObject in project cdk by cdk.

the class BondToolsTest method testCloseEnoughToBond_IAtom_IAtom_double.

/**
 * Make sure the the rebonding is working.
 */
@Test
public void testCloseEnoughToBond_IAtom_IAtom_double() throws Exception {
    String filename = "viagra.xyz";
    InputStream ins = this.getClass().getResourceAsStream(filename);
    XYZReader reader = new XYZReader(ins);
    AtomTypeFactory atf = AtomTypeFactory.getInstance("org/openscience/cdk/config/data/jmol_atomtypes.txt", SilentChemObjectBuilder.getInstance());
    ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
    IAtomContainer mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0);
    for (IAtom iAtom : mol.atoms()) {
        atf.configure(iAtom);
    }
    Assert.assertTrue(BondTools.closeEnoughToBond(mol.getAtom(0), mol.getAtom(1), 1));
    Assert.assertFalse(BondTools.closeEnoughToBond(mol.getAtom(0), mol.getAtom(8), 1));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) XYZReader(org.openscience.cdk.io.XYZReader) ChemObject(org.openscience.cdk.ChemObject) InputStream(java.io.InputStream) ChemFile(org.openscience.cdk.ChemFile) AtomTypeFactory(org.openscience.cdk.config.AtomTypeFactory) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 98 with ChemObject

use of org.openscience.cdk.ChemObject in project cdk by cdk.

the class BondToolsTest method testIsStereo_IAtomContainer_IAtom.

@Test
public void testIsStereo_IAtomContainer_IAtom() throws Exception {
    String filename = "trigonal_bipyramidal.mol";
    InputStream ins = this.getClass().getResourceAsStream(filename);
    MDLV2000Reader reader = new MDLV2000Reader(ins);
    ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
    IAtomContainer mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0);
    Assert.assertTrue(BondTools.isStereo(mol, mol.getAtom(0)));
    Assert.assertFalse(BondTools.isStereo(mol, mol.getAtom(1)));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemObject(org.openscience.cdk.ChemObject) InputStream(java.io.InputStream) ChemFile(org.openscience.cdk.ChemFile) MDLV2000Reader(org.openscience.cdk.io.MDLV2000Reader) Test(org.junit.Test)

Example 99 with ChemObject

use of org.openscience.cdk.ChemObject in project cdk by cdk.

the class BondToolsTest method testIsTrigonalBipyramidalOrOctahedral_IAtomContainer_IAtom.

@Test
public void testIsTrigonalBipyramidalOrOctahedral_IAtomContainer_IAtom() throws Exception {
    String filename = "trigonal_bipyramidal.mol";
    InputStream ins = this.getClass().getResourceAsStream(filename);
    MDLV2000Reader reader = new MDLV2000Reader(ins);
    ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
    IAtomContainer mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0);
    Assert.assertEquals(BondTools.isTrigonalBipyramidalOrOctahedral(mol, mol.getAtom(0)), 1);
    Assert.assertEquals(BondTools.isTrigonalBipyramidalOrOctahedral(mol, mol.getAtom(1)), 0);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemObject(org.openscience.cdk.ChemObject) InputStream(java.io.InputStream) ChemFile(org.openscience.cdk.ChemFile) MDLV2000Reader(org.openscience.cdk.io.MDLV2000Reader) Test(org.junit.Test)

Example 100 with ChemObject

use of org.openscience.cdk.ChemObject in project cdk by cdk.

the class RDFProtonDescriptor_GDRTest method testExample1.

@Test
public void testExample1() throws Exception {
    // firstly read file to molecule
    String filename = "hydroxyamino.mol";
    InputStream ins = this.getClass().getResourceAsStream(filename);
    MDLV2000Reader reader = new MDLV2000Reader(ins, Mode.STRICT);
    ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
    IChemSequence seq = chemFile.getChemSequence(0);
    IChemModel model = seq.getChemModel(0);
    IAtomContainerSet som = model.getMoleculeSet();
    IAtomContainer mol = som.getAtomContainer(0);
    for (int i = 0; i < mol.getAtomCount(); i++) {
        // System.out.println("Atom: " + mol.getAtom(i).getSymbol());
        if (mol.getAtom(i).getAtomicNumber() == IElement.H) {
            // secondly perform calculation on it.
            RDFProtonDescriptor_GDR descriptor = new RDFProtonDescriptor_GDR();
            DescriptorValue dv = descriptor.calculate(mol.getAtom(i), mol);
            IDescriptorResult result = dv.getValue();
            // System.out.println("array: " + result.toString());
            Assert.assertNotNull(result);
            Assert.assertEquals(dv.getNames().length, result.length());
        }
    }
}
Also used : IDescriptorResult(org.openscience.cdk.qsar.result.IDescriptorResult) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemObject(org.openscience.cdk.ChemObject) InputStream(java.io.InputStream) IChemModel(org.openscience.cdk.interfaces.IChemModel) MDLV2000Reader(org.openscience.cdk.io.MDLV2000Reader) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) ChemFile(org.openscience.cdk.ChemFile) IChemSequence(org.openscience.cdk.interfaces.IChemSequence) Test(org.junit.Test)

Aggregations

ChemObject (org.openscience.cdk.ChemObject)108 Test (org.junit.Test)104 InputStream (java.io.InputStream)69 ChemFile (org.openscience.cdk.ChemFile)68 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)64 MDLV2000Reader (org.openscience.cdk.io.MDLV2000Reader)34 IAtomContainerSet (org.openscience.cdk.interfaces.IAtomContainerSet)22 SimpleChemObjectReaderTest (org.openscience.cdk.test.io.SimpleChemObjectReaderTest)21 IChemFile (org.openscience.cdk.interfaces.IChemFile)14 IAtomType (org.openscience.cdk.interfaces.IAtomType)12 IChemModel (org.openscience.cdk.interfaces.IChemModel)12 ISimpleChemObjectReader (org.openscience.cdk.io.ISimpleChemObjectReader)12 List (java.util.List)11 StringReader (java.io.StringReader)10 IChemSequence (org.openscience.cdk.interfaces.IChemSequence)9 IIsotope (org.openscience.cdk.interfaces.IIsotope)9 DoubleArrayResult (org.openscience.cdk.qsar.result.DoubleArrayResult)9 IChemObject (org.openscience.cdk.interfaces.IChemObject)8 HINReader (org.openscience.cdk.io.HINReader)8 DescriptorValue (org.openscience.cdk.qsar.DescriptorValue)8