use of org.openscience.cdk.ChemObject in project cdk by cdk.
the class ConjugatedPiSystemsDetectorTest method testPiSystemWithCumulativeDB.
/**
* A unit test for JUnit
*
*@return Description of the Return Value
*/
@Test
public void testPiSystemWithCumulativeDB() throws Exception {
logger.info("Entering testPiSystemWithCumulativeDB.");
IAtomContainer mol;
String filename = "piSystemCumulative.mol";
InputStream ins = this.getClass().getResourceAsStream(filename);
MDLReader reader = new MDLReader(ins);
IChemFile chemFile = (IChemFile) reader.read((ChemObject) new ChemFile());
mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
Aromaticity.cdkLegacy().apply(mol);
IAtomContainerSet acSet = ConjugatedPiSystemsDetector.detect(mol);
Assert.assertEquals(2, acSet.getAtomContainerCount());
IAtomContainer ac1 = acSet.getAtomContainer(0);
Assert.assertEquals(4, ac1.getAtomCount());
Assert.assertEquals(3, ac1.getBondCount());
for (int i = 0; i < ac1.getAtomCount(); i++) {
Assert.assertTrue(mol.contains(ac1.getAtom(i)));
}
for (int i = 0; i < ac1.getBondCount(); i++) {
Assert.assertTrue(mol.contains(ac1.getBond(i)));
}
IAtomContainer ac2 = acSet.getAtomContainer(0);
Assert.assertEquals(4, ac2.getAtomCount());
Assert.assertEquals(3, ac2.getBondCount());
for (int i = 0; i < ac2.getAtomCount(); i++) {
Assert.assertTrue(mol.contains(ac1.getAtom(i)));
}
for (int i = 0; i < ac2.getBondCount(); i++) {
Assert.assertTrue(mol.contains(ac1.getBond(i)));
}
}
use of org.openscience.cdk.ChemObject in project cdk by cdk.
the class ChemFileManipulatorTest method testGetAllAtomContainers_IChemFile.
@Test
public void testGetAllAtomContainers_IChemFile() throws Exception {
String filename = "prev2000.sd";
logger.info("Testing: " + filename);
InputStream ins = this.getClass().getResourceAsStream(filename);
MDLReader reader = new MDLReader(ins, Mode.STRICT);
ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
Assert.assertNotNull(chemFile);
List<IAtomContainer> containersList = ChemFileManipulator.getAllAtomContainers(chemFile);
Assert.assertEquals(2, containersList.size());
}
use of org.openscience.cdk.ChemObject in project cdk by cdk.
the class ChemModelManipulatorTest method testGetAllAtomContainers_IChemModel.
@Test
public void testGetAllAtomContainers_IChemModel() throws Exception {
String filename = "a-pinene.mol";
logger.info("Testing: " + filename);
InputStream ins = this.getClass().getResourceAsStream(filename);
MDLV2000Reader reader = new MDLV2000Reader(ins);
ChemModel chemFile = (ChemModel) reader.read((ChemObject) new ChemModel());
Assert.assertNotNull(chemFile);
List<IAtomContainer> containersList = ChemModelManipulator.getAllAtomContainers(chemFile);
Assert.assertEquals(1, containersList.size());
}
use of org.openscience.cdk.ChemObject in project cdk by cdk.
the class ZagrebIndexDescriptorTest method test2Dvs3D.
@Test
public void test2Dvs3D() throws Exception {
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer mol = sp.parseSmiles("O1C2C34C(C(C1O)CCCc1cc(cc(c1)C(F)(F)F)C(F)(F)F)CCC(C3CCC(O2)(OO4)C)C");
addExplicitHydrogens(mol);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
Aromaticity.cdkLegacy().apply(mol);
double value2D = ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue();
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);
mol = (IAtomContainer) cList.get(0);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
Aromaticity.cdkLegacy().apply(mol);
double value3D = ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue();
Assert.assertEquals(value2D, value3D, 0.001);
}
use of org.openscience.cdk.ChemObject in project cdk by cdk.
the class AtomPlacer3DTest method testFindHeavyAtomsInChain_IAtomContainer_IAtomContainer.
@Test
public void testFindHeavyAtomsInChain_IAtomContainer_IAtomContainer() throws Exception {
String filename = "allmol232.mol";
InputStream ins = this.getClass().getResourceAsStream(filename);
// TODO: shk3-cleanuptests: best to use the STRICT IO mode here
MDLV2000Reader reader = new MDLV2000Reader(ins);
ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
reader.close();
List<IAtomContainer> containersList = ChemFileManipulator.getAllAtomContainers(chemFile);
IAtomContainer ac = new AtomContainer(containersList.get(0));
addExplicitHydrogens(ac);
IAtomContainer chain = ac.getBuilder().newInstance(IAtomContainer.class);
for (int i = 16; i < 25; i++) {
chain.addAtom(ac.getAtom(i));
}
chain.addAtom(ac.getAtom(29));
chain.addAtom(ac.getAtom(30));
int[] result = new AtomPlacer3D().findHeavyAtomsInChain(ac, chain);
Assert.assertEquals(16, result[0]);
Assert.assertEquals(11, result[1]);
}
Aggregations