use of org.openscience.cdk.ChemFile 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.ChemFile 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]);
}
use of org.openscience.cdk.ChemFile in project cdk by cdk.
the class ModelBuilder3DTest method testModelBuilder3D_bug_1241421.
/*
* @cdk.bug 1241421
*/
@Test
@Category(SlowTest.class)
public void testModelBuilder3D_bug_1241421() throws Exception {
ModelBuilder3D mb3d = ModelBuilder3D.getInstance(DefaultChemObjectBuilder.getInstance());
String filename = "bug1241421.mol";
InputStream ins = this.getClass().getResourceAsStream(filename);
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));
ac = mb3d.generate3DCoordinates(ac, false);
checkAverageBondLength(ac);
}
use of org.openscience.cdk.ChemFile in project cdk by cdk.
the class MolecularFormulaManipulatorTest method testFromMol.
/**
* @cdk.bug 3071473
*/
@Test
public void testFromMol() throws Exception {
String filename = "formulatest.mol";
InputStream ins = this.getClass().getResourceAsStream(filename);
MDLV2000Reader reader = new MDLV2000Reader(ins);
ChemFile chemFile = reader.read(new ChemFile());
reader.close();
Assert.assertNotNull(chemFile);
List<IAtomContainer> mols = ChemFileManipulator.getAllAtomContainers(chemFile);
IAtomContainer mol = mols.get(0);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
CDKHydrogenAdder ha = CDKHydrogenAdder.getInstance(DefaultChemObjectBuilder.getInstance());
ha.addImplicitHydrogens(mol);
AtomContainerManipulator.convertImplicitToExplicitHydrogens(mol);
IMolecularFormula molecularFormula = MolecularFormulaManipulator.getMolecularFormula(mol);
String formula2 = MolecularFormulaManipulator.getString(molecularFormula);
Assert.assertTrue(formula2.equals("C35H64N3O21P3S"));
}
use of org.openscience.cdk.ChemFile 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);
}
Aggregations