Search in sources :

Example 16 with ChemObject

use of org.openscience.cdk.ChemObject 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 17 with ChemObject

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

the class PMPReaderTest method testTwoAceticAcid.

@Test
public void testTwoAceticAcid() throws Exception {
    String filename = "two_aceticacid.pmp";
    InputStream ins = this.getClass().getResourceAsStream(filename);
    PMPReader reader = new PMPReader(ins);
    ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
    reader.close();
    Assert.assertNotNull(chemFile);
    Assert.assertEquals(1, chemFile.getChemSequenceCount());
    IChemSequence seq = chemFile.getChemSequence(0);
    Assert.assertNotNull(seq);
    Assert.assertEquals(2, seq.getChemModelCount());
    IChemModel model = seq.getChemModel(0);
    Assert.assertNotNull(model);
    ICrystal crystal = model.getCrystal();
    Assert.assertNotNull(crystal);
    Assert.assertEquals(32, crystal.getAtomCount());
    Assert.assertEquals(28, crystal.getBondCount());
    model = seq.getChemModel(1);
    Assert.assertNotNull(model);
    crystal = model.getCrystal();
    Assert.assertNotNull(crystal);
    Assert.assertEquals(32, crystal.getAtomCount());
    Assert.assertEquals(28, crystal.getBondCount());
}
Also used : ICrystal(org.openscience.cdk.interfaces.ICrystal) ChemObject(org.openscience.cdk.ChemObject) InputStream(java.io.InputStream) ChemFile(org.openscience.cdk.ChemFile) IChemModel(org.openscience.cdk.interfaces.IChemModel) IChemSequence(org.openscience.cdk.interfaces.IChemSequence) SimpleChemObjectReaderTest(org.openscience.cdk.test.io.SimpleChemObjectReaderTest) Test(org.junit.Test)

Example 18 with ChemObject

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

the class XYZReaderTest method testViagra.

@Test
public void testViagra() throws Exception {
    String filename = "viagra.xyz";
    logger.info("Testing: ", filename);
    InputStream ins = this.getClass().getResourceAsStream(filename);
    XYZReader reader = new XYZReader(ins);
    ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
    reader.close();
    Assert.assertNotNull(chemFile);
    Assert.assertEquals(1, chemFile.getChemSequenceCount());
    org.openscience.cdk.interfaces.IChemSequence seq = chemFile.getChemSequence(0);
    Assert.assertNotNull(seq);
    Assert.assertEquals(1, seq.getChemModelCount());
    org.openscience.cdk.interfaces.IChemModel model = seq.getChemModel(0);
    Assert.assertNotNull(model);
    IAtomContainerSet som = model.getMoleculeSet();
    Assert.assertNotNull(som);
    Assert.assertEquals(1, som.getAtomContainerCount());
    IAtomContainer m = som.getAtomContainer(0);
    Assert.assertNotNull(m);
    Assert.assertEquals(63, m.getAtomCount());
    Assert.assertEquals(0, m.getBondCount());
    Assert.assertEquals("N", m.getAtom(0).getSymbol());
    Assert.assertNotNull(m.getAtom(0).getPoint3d());
    Assert.assertEquals(-3.4932, m.getAtom(0).getPoint3d().x, 0.0001);
    Assert.assertEquals(-1.8950, m.getAtom(0).getPoint3d().y, 0.0001);
    Assert.assertEquals(0.1795, m.getAtom(0).getPoint3d().z, 0.0001);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemObject(org.openscience.cdk.ChemObject) InputStream(java.io.InputStream) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) ChemFile(org.openscience.cdk.ChemFile) SimpleChemObjectReaderTest(org.openscience.cdk.test.io.SimpleChemObjectReaderTest) Test(org.junit.Test)

Example 19 with ChemObject

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

the class XYZReaderTest method testComment.

@Test
public void testComment() throws Exception {
    String filename = "viagra_withComment.xyz";
    logger.info("Testing: ", filename);
    InputStream ins = this.getClass().getResourceAsStream(filename);
    XYZReader reader = new XYZReader(ins);
    ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
    reader.close();
    Assert.assertNotNull(chemFile);
    Assert.assertEquals(1, chemFile.getChemSequenceCount());
    org.openscience.cdk.interfaces.IChemSequence seq = chemFile.getChemSequence(0);
    Assert.assertNotNull(seq);
    Assert.assertEquals(1, seq.getChemModelCount());
    org.openscience.cdk.interfaces.IChemModel model = seq.getChemModel(0);
    Assert.assertNotNull(model);
    IAtomContainerSet som = model.getMoleculeSet();
    Assert.assertNotNull(som);
    Assert.assertEquals(1, som.getAtomContainerCount());
    IAtomContainer m = som.getAtomContainer(0);
    Assert.assertNotNull(m);
    Assert.assertEquals(63, m.getAtomCount());
    Assert.assertEquals(0, m.getBondCount());
    // atom 63: H    3.1625    3.1270   -0.9362
    Assert.assertEquals("H", m.getAtom(62).getSymbol());
    Assert.assertNotNull(m.getAtom(62).getPoint3d());
    Assert.assertEquals(3.1625, m.getAtom(62).getPoint3d().x, 0.0001);
    Assert.assertEquals(3.1270, m.getAtom(62).getPoint3d().y, 0.0001);
    Assert.assertEquals(-0.9362, m.getAtom(62).getPoint3d().z, 0.0001);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemObject(org.openscience.cdk.ChemObject) InputStream(java.io.InputStream) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) ChemFile(org.openscience.cdk.ChemFile) SimpleChemObjectReaderTest(org.openscience.cdk.test.io.SimpleChemObjectReaderTest) Test(org.junit.Test)

Example 20 with ChemObject

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

the class GhemicalReaderTest method testEthene.

@Test
public void testEthene() throws Exception {
    String filename = "ethene.mm1gp";
    InputStream ins = this.getClass().getResourceAsStream(filename);
    GhemicalMMReader reader = new GhemicalMMReader(ins);
    ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
    reader.close();
    Assert.assertNotNull(chemFile);
    Assert.assertEquals(1, chemFile.getChemSequenceCount());
    org.openscience.cdk.interfaces.IChemSequence seq = chemFile.getChemSequence(0);
    Assert.assertNotNull(seq);
    Assert.assertEquals(1, seq.getChemModelCount());
    org.openscience.cdk.interfaces.IChemModel model = seq.getChemModel(0);
    Assert.assertNotNull(model);
    IAtomContainerSet som = model.getMoleculeSet();
    Assert.assertNotNull(som);
    Assert.assertEquals(1, som.getAtomContainerCount());
    IAtomContainer m = som.getAtomContainer(0);
    Assert.assertNotNull(m);
    Assert.assertEquals(6, m.getAtomCount());
    Assert.assertEquals(5, m.getBondCount());
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemObject(org.openscience.cdk.ChemObject) InputStream(java.io.InputStream) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) ChemFile(org.openscience.cdk.ChemFile) SimpleChemObjectReaderTest(org.openscience.cdk.test.io.SimpleChemObjectReaderTest) 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