Permalink
Browse files

Work with AtomContainers (fixes #2788763)

Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
  • Loading branch information...
1 parent 4cc5ff8 commit c72d442576ad39416a41d6a8be94a0ccc2d20a5c @egonw egonw committed with rajarshi Sep 25, 2011
@@ -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);
@@ -190,8 +190,8 @@ public boolean accepts(Class<? extends IChemObject> classObject) {
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.");
}
@@ -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;
@@ -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();
@@ -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;
@@ -83,6 +84,7 @@
Assert.assertTrue(reader.accepts(ChemFile.class));
Assert.assertTrue(reader.accepts(ChemModel.class));
Assert.assertTrue(reader.accepts(Molecule.class));
+ Assert.assertTrue(reader.accepts(AtomContainer.class));
}
/**

0 comments on commit c72d442

Please sign in to comment.