/** * The reader is already set to read the record buffer. * @return the read IChemObject * @throws CDKException an error occurred whilst reading the file */ protected IChemObject processContent() throws CDKException { return chemObjectReader.read(builder.newInstance(IChemFile.class)); }
/** * The reader is already set to read the record buffer. * @return the read IChemObject * @throws CDKException an error occurred whilst reading the file */ protected IChemObject processContent() throws CDKException { return chemObjectReader.read(builder.newInstance(IChemFile.class)); }
/** * @cdk.bug 1750968 */ public IAtomContainer makeBug1750968() throws Exception { String filename = "data/mdl/bug_1750968.mol"; // set up molecule reader InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader molReader = new MDLReader(ins, Mode.STRICT); // read molecule return molReader.read(DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class)); }
/** * @cdk.bug 2984581 * @throws Exception */ @Test public void testAromaticRingsLine() throws Exception { String filename = "data/hin/bug2984581.hin"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new HINReader(ins); IChemFile content = reader.read(new ChemFile()); reader.close(); List<IAtomContainer> cList = ChemFileManipulator.getAllAtomContainers(content); Assert.assertEquals(1, cList.size()); }
/** * @cdk.bug 2126904 */ @Test public void testIsConnectedFromHINFile() throws Exception { String filename = "data/hin/connectivity1.hin"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new HINReader(ins); ChemFile content = (ChemFile) reader.read((ChemObject) new ChemFile()); List<IAtomContainer> cList = ChemFileManipulator.getAllAtomContainers(content); IAtomContainer ac = cList.get(0); Assert.assertTrue("Molecule appears not to be connected", ConnectivityChecker.isConnected(ac)); }
/** * @cdk.bug 2126904 */ @Test public void testIsConnectedFromSDFile() throws Exception { String filename = "data/mdl/mdeotest.sdf"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new MDLV2000Reader(ins); ChemFile content = (ChemFile) reader.read((ChemObject) new ChemFile()); List<IAtomContainer> cList = ChemFileManipulator.getAllAtomContainers(content); IAtomContainer ac = cList.get(0); Assert.assertTrue("Molecule appears not to be connected", ConnectivityChecker.isConnected(ac)); }
private static IAtomContainer createMolecule(String molecule) throws IOException, CDKException { IAtomContainer structure = null; if (molecule != null) { ISimpleChemObjectReader reader = new MDLV2000Reader(new StringReader(molecule)); Assert.assertNotNull("Could not create reader", reader); if (reader.accepts(AtomContainer.class)) { structure = reader.read(DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class)); } } return structure; }
@Test public void testIsConnectedFromHINFile() throws Exception { String filename = "data/hin/connectivity1.hin"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new HINReader(ins); IChemFile content = reader.read(new ChemFile()); reader.close(); List<IAtomContainer> cList = ChemFileManipulator.getAllAtomContainers(content); IAtomContainer ac = cList.get(0); Assert.assertEquals(57, ac.getAtomCount()); Assert.assertEquals(59, ac.getBondCount()); }
public IChemFile getChemFile(ISimpleChemObjectReader reader, boolean useRebond) throws Exception { Assert.assertNotNull(reader); reader.getSetting("UseRebondTool").setSetting(String.valueOf(useRebond)); IChemFile chemFile = (IChemFile) reader.read(new ChemFile()); Assert.assertNotNull(chemFile); return chemFile; }
/** * @cdk.bug 1965254 */ @Test public void testLOBDescriptor2() throws Exception { String filename = "data/mdl/lobtest2.sdf"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new MDLV2000Reader(ins); ChemFile content = (ChemFile) reader.read(new ChemFile()); List cList = ChemFileManipulator.getAllAtomContainers(content); IAtomContainer ac = (IAtomContainer) cList.get(0); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(ac); DoubleArrayResult result = (DoubleArrayResult) descriptor.calculate(ac).getValue(); Assert.assertNotNull(result); }
@Test public void testChargedMolecule() throws Exception { String filename = "data/mdl/cpsa-charged.sdf"; InputStream ins = this.getClass().getClassLoader().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); }
@Test public void testEccentricConnectivityIndex() throws ClassNotFoundException, CDKException, java.lang.Exception { String filename = "data/hin/gravindex.hin"; InputStream ins = this.getClass().getClassLoader().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); addImplicitHydrogens(ac); IntegerResult retval = (IntegerResult) descriptor.calculate(ac).getValue(); //logger.debug(retval.intValue()); Assert.assertEquals(254, retval.intValue(), 0); } }
@Test public void testUnChargedMolecule() throws Exception { String filename = "data/mdl/cpsa-uncharged.sdf"; InputStream ins = this.getClass().getClassLoader().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); } }
@Test public void testLOBDescriptorCyclohexane() throws Exception { String filename = "data/mdl/lobtest.sdf"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new MDLV2000Reader(ins); ChemFile content = (ChemFile) reader.read(new ChemFile()); List cList = ChemFileManipulator.getAllAtomContainers(content); IAtomContainer ac = (IAtomContainer) cList.get(1); Isotopes.getInstance().configureAtoms(ac); DoubleArrayResult result = (DoubleArrayResult) descriptor.calculate(ac).getValue(); Assert.assertEquals(1.1476784, result.get(0), 0.01); Assert.assertEquals(1.0936984, result.get(1), 0.01); }
@Test public void testLOBDescriptorNaphthalene() throws Exception { String filename = "data/mdl/lobtest.sdf"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new MDLV2000Reader(ins); ChemFile content = (ChemFile) reader.read(new ChemFile()); List cList = ChemFileManipulator.getAllAtomContainers(content); IAtomContainer ac = (IAtomContainer) cList.get(2); Isotopes.getInstance().configureAtoms(ac); DoubleArrayResult result = (DoubleArrayResult) descriptor.calculate(ac).getValue(); Assert.assertEquals(1.3083278, result.get(0), 0.01); Assert.assertEquals(1.3083278, result.get(1), 0.01); }
@Test public void testLOBDescriptorCholesterol() throws Exception { String filename = "data/mdl/lobtest.sdf"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new MDLV2000Reader(ins); ChemFile content = (ChemFile) reader.read(new ChemFile()); List cList = ChemFileManipulator.getAllAtomContainers(content); IAtomContainer ac = (IAtomContainer) cList.get(0); Isotopes.getInstance().configureAtoms(ac); DoubleArrayResult result = (DoubleArrayResult) descriptor.calculate(ac).getValue(); Assert.assertEquals(3.5029, result.get(0), 0.001); Assert.assertEquals(3.5029, result.get(1), 0.001); }
@Test public void testLOBDescriptorNButane() throws Exception { String filename = "data/mdl/lobtest.sdf"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new MDLV2000Reader(ins); ChemFile content = (ChemFile) reader.read(new ChemFile()); List cList = ChemFileManipulator.getAllAtomContainers(content); IAtomContainer ac = (IAtomContainer) cList.get(3); Isotopes.getInstance().configureAtoms(ac); DoubleArrayResult result = (DoubleArrayResult) descriptor.calculate(ac).getValue(); Assert.assertEquals(2.0880171, result.get(0), 0.000001); Assert.assertEquals(2.0880171, result.get(1), 0.000001); }
@Test public void testReadGzWithGzipDetection() throws Exception { String filename = "data/xyz/bf3.xyz.gz"; InputStream input = this.getClass().getClassLoader().getResourceAsStream(filename); // ok, if format ok, try instantiating a reader ISimpleChemObjectReader reader = factory.createReader(input); Assert.assertNotNull(reader); Assert.assertEquals(((IChemFormat) XYZFormat.getInstance()).getReaderClassName(), reader.getClass().getName()); // now try reading something from it IChemFile chemFile = (IChemFile) reader.read(new ChemFile()); IAtomContainer molecule = new AtomContainer(); for (IAtomContainer container : ChemFileManipulator.getAllAtomContainers(chemFile)) { molecule.add(container); } Assert.assertNotNull(molecule); Assert.assertEquals(4, molecule.getAtomCount()); }
@Test public void testMDE1() throws ClassNotFoundException, CDKException, Exception { String filename = "data/mdl/mdeotest.sdf"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new MDLV2000Reader(ins); ChemFile content = (ChemFile) reader.read(new ChemFile()); List cList = ChemFileManipulator.getAllAtomContainers(content); IAtomContainer ac = (IAtomContainer) cList.get(0); DoubleArrayResult result = (DoubleArrayResult) descriptor.calculate(ac).getValue(); Assert.assertEquals(0.0000, result.get(MDEDescriptor.MDEO11), 0.0001); Assert.assertEquals(1.1547, result.get(MDEDescriptor.MDEO12), 0.0001); Assert.assertEquals(2.9416, result.get(MDEDescriptor.MDEO22), 0.0001); } }
@Test public void testCPSA() throws Exception { String filename = "data/hin/benzene.hin"; InputStream ins = this.getClass().getClassLoader().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(); /* * System.out.println("Num ret = "+retval.size()); for (int i = 0; i < * retval.size(); i++) { System.out.println( retval.get(i) ); } */ Assert.assertEquals(0, retval.get(28), 0.0001); Assert.assertEquals(1, retval.get(27), 0.0001); Assert.assertEquals(0, retval.get(26), 0.0001); Assert.assertEquals(356.8849, retval.get(25), 0.0001); }