Skip to content

Commit

Permalink
Work with AtomContainers (fixes #2788763)
Browse files Browse the repository at this point in the history
Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
  • Loading branch information
egonw authored and rajarshi committed Oct 2, 2011
1 parent 4cc5ff8 commit c72d442
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/org/openscience/cdk/io/MDLV2000Reader.java
Expand Up @@ -168,7 +168,7 @@ public boolean accepts(Class<? extends IChemObject> classObject) {
for (int i=0; i<interfaces.length; i++) {
if (IChemFile.class.equals(interfaces[i])) return true;
if (IChemModel.class.equals(interfaces[i])) return true;
if (IMolecule.class.equals(interfaces[i])) return true;
if (IAtomContainer.class.equals(interfaces[i])) return true;
}
Class superClass = classObject.getSuperclass();
if (superClass != null) return this.accepts(superClass);
Expand All @@ -190,8 +190,8 @@ public <T extends IChemObject> T read(T object) throws CDKException {
return (T)readChemFile((IChemFile)object);
} else if (object instanceof IChemModel) {
return (T)readChemModel((IChemModel)object);
} else if (object instanceof IMolecule) {
return (T)readAtomContainer((IMolecule)object);
} else if (object instanceof IAtomContainer) {
return (T)readAtomContainer((IAtomContainer)object);
} else {
throw new CDKException("Only supported are ChemFile and Molecule.");
}
Expand Down Expand Up @@ -351,7 +351,7 @@ private IChemFile readChemFile(IChemFile chemFile) throws CDKException {
*
*@return The Molecule that was read from the MDL file.
*/
private IAtomContainer readAtomContainer(IMolecule molecule) throws CDKException {
private IAtomContainer readAtomContainer(IAtomContainer molecule) throws CDKException {
logger.debug("Reading new molecule");
IAtomContainer outputContainer=null;
int linecount = 0;
Expand Down Expand Up @@ -908,7 +908,7 @@ private IAtomContainer readAtomContainer(IMolecule molecule) throws CDKException
return outputContainer;
}

private void fixHydrogenIsotopes(IMolecule molecule,IsotopeFactory isotopeFactory) {
private void fixHydrogenIsotopes(IAtomContainer molecule,IsotopeFactory isotopeFactory) {
Iterator<IAtom> atoms = molecule.atoms().iterator();
while (atoms.hasNext()) {
IAtom atom = atoms.next();
Expand Down
2 changes: 2 additions & 0 deletions src/test/org/openscience/cdk/io/MDLV2000ReaderTest.java
Expand Up @@ -35,6 +35,7 @@
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openscience.cdk.AtomContainer;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.ChemFile;
import org.openscience.cdk.ChemModel;
Expand Down Expand Up @@ -83,6 +84,7 @@ public class MDLV2000ReaderTest extends SimpleChemObjectReaderTest {
Assert.assertTrue(reader.accepts(ChemFile.class));
Assert.assertTrue(reader.accepts(ChemModel.class));
Assert.assertTrue(reader.accepts(Molecule.class));
Assert.assertTrue(reader.accepts(AtomContainer.class));
}

/**
Expand Down

0 comments on commit c72d442

Please sign in to comment.