MDLV3000Reader extends DefaultChemObjectReader { @Override public <T extends IChemObject> T read(T object) throws CDKException { if (object instanceof IAtomContainer) { return (T) readMolecule(object.getBuilder()); } throw new CDKException("Only supports AtomContainer objects."); } MDLV3000Reader(Reader in);  MDLV3000Reader(Reader in, Mode mode);  MDLV3000Reader(InputStream input);  MDLV3000Reader(InputStream input, Mode mode);  MDLV3000Reader(); @Override IResourceFormat getFormat(); @Override void setReader(Reader input); @Override void setReader(InputStream input); @Override boolean accepts(Class<? extends IChemObject> classObject); @Override T read(T object); IAtomContainer readMolecule(IChemObjectBuilder builder); IAtomContainer readConnectionTable(IChemObjectBuilder builder); String readHeader(IAtomContainer readData); void readAtomBlock(IAtomContainer readData); void readBondBlock(IAtomContainer readData); void readSGroup(IAtomContainer readData); String exhaustStringTokenizer(StringTokenizer tokenizer); String readLine(); boolean isReady(); @Override void close();  }
@Test public void pseudoAtomReplacement() throws Exception { try (MDLV3000Reader reader = new MDLV3000Reader(getClass().getResourceAsStream("pseudoAtomReplacement.mol"))) { IAtomContainer container = reader.read(new org.openscience.cdk.AtomContainer(0, 0, 0, 0)); for (IAtom atom : container.getBond(9).atoms()) { Assert.assertTrue(container.contains(atom)); } } }
@Test public void positionalVariation() throws Exception { try (MDLV3000Reader reader = new MDLV3000Reader(getClass().getResourceAsStream("multicenterBond.mol"))) { IAtomContainer container = reader.read(new org.openscience.cdk.AtomContainer(0, 0, 0, 0)); assertThat(container.getBondCount(), is(8)); List<Sgroup> sgroups = container.getProperty(CDKConstants.CTAB_SGROUPS); assertNotNull(sgroups); assertThat(sgroups.size(), is(1)); assertThat(sgroups.get(0).getType(), is(SgroupType.ExtMulticenter)); } }
@Test public void radicalsInCH3() throws Exception { try (MDLV3000Reader reader = new MDLV3000Reader(getClass().getResourceAsStream("CH3.mol"))) { IAtomContainer container = reader.read(new org.openscience.cdk.AtomContainer(0, 0, 0, 0)); assertThat(container.getSingleElectronCount(), is(1)); assertThat(container.getAtom(0).getImplicitHydrogenCount(), is(3)); } }
@Test public void issue602() throws Exception { try (MDLV3000Reader reader = new MDLV3000Reader(getClass().getResourceAsStream("issue602.mol"))) { IAtomContainer mol = reader.read(SilentChemObjectBuilder.getInstance().newAtomContainer()); assertThat(mol.getAtomCount(), CoreMatchers.is(31)); } }
@Test public void reading_query_bond_should_not_npe() throws Exception { try (MDLV3000Reader reader = new MDLV3000Reader(getClass().getResourceAsStream("v3000Query.mol"))) { IAtomContainer container = reader.read(SilentChemObjectBuilder.getInstance().newAtomContainer()); for (IBond bond: container.bonds()) { assertNotNull(bond.getOrder()); } assertThat(container.getBond(4).getOrder(), is(IBond.Order.UNSET)); } }