@Test public void testMultiMolButSingle() throws Exception { Assume.assumeTrue(runSlowTests()); String filename = "data/mol2/fromWebsite.mol2"; logger.info("Testing: ", filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); Mol2Reader reader = new Mol2Reader(ins); IChemFile chemFile = reader.read(new ChemFile()); reader.close(); List<IAtomContainer> mols = ChemFileManipulator.getAllAtomContainers(chemFile); Assert.assertEquals(1, mols.size()); Assert.assertEquals(12, mols.get(0).getAtomCount()); }
@Test public void testReadingIDs() throws Exception { String filename = "data/mol2/fromWebsite.mol2"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); Mol2Reader reader = new Mol2Reader(ins); IAtomContainer molecule = (IAtomContainer) reader.read(new AtomContainer()); reader.close(); Assert.assertNotNull(molecule); IAtomContainer reference = (IAtomContainer) molecule.clone(); Assert.assertEquals("C1", reference.getAtom(0).getID()); }
@Test public void unrecognisedAtomTypes() throws Exception { Mol2Reader mol2Reader = null; try { mol2Reader = new Mol2Reader(getClass().getResourceAsStream("CLMW1.mol2")); IAtomContainer container = mol2Reader.read(new AtomContainer()); for (IAtom atom : container.atoms()) Assert.assertNotNull(atom.getAtomicNumber()); } finally { if (mol2Reader != null) mol2Reader.close(); } } }
@Test public void testMultiMol() throws Exception { Assume.assumeTrue(runSlowTests()); String filename = "data/mol2/actives.mol2"; logger.info("Testing: ", filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); Mol2Reader reader = new Mol2Reader(ins); IChemFile chemFile = reader.read(new ChemFile()); reader.close(); List<IAtomContainer> mols = ChemFileManipulator.getAllAtomContainers(chemFile); Assert.assertEquals(30, mols.size()); Assert.assertEquals(25, mols.get(0).getAtomCount()); Assert.assertEquals(24, mols.get(29).getAtomCount()); }
@Test public void testIAtomContainer() throws Exception { String filename = "data/mol2/fromWebsite.mol2"; InputStream in = Mol2ReaderTest.class.getClassLoader().getResourceAsStream(filename); Mol2Reader reader = new Mol2Reader(in); IAtomContainer mol = (IAtomContainer) reader.read(new AtomContainer()); reader.close(); Assert.assertNotNull(mol); Assert.assertEquals(12, mol.getAtomCount()); Assert.assertEquals(12, mol.getBondCount()); }
private void checkMol(StringBuilder buf) throws Exception { StringReader sr = new StringReader(buf.toString()); Mol2Reader reader = new Mol2Reader(sr); IChemFile mol = (IChemFile) reader.read(SilentChemObjectBuilder.getInstance().newInstance(IChemFile.class)); reader.close(); Assert.assertTrue(mol.getChemSequenceCount() > 0); Assert.assertTrue(mol.getChemSequence(0).getChemModelCount() > 0); Assert.assertTrue(mol.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainerCount() > 0); Assert.assertTrue(mol.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0).getAtomCount() > 0); }
Mol2Reader r = new Mol2Reader(new StringReader(problematicMol2)); IChemModel model = (IChemModel) r.read(SilentChemObjectBuilder.getInstance().newInstance(IChemModel.class)); r.close(); Assert.assertNotNull(model); List<IAtomContainer> containers = ChemModelManipulator.getAllAtomContainers(model);
Mol2Reader reader = new Mol2Reader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); reader.close();