Skip to content

Commit

Permalink
cleaned up a bunch of MoleculeSet usages
Browse files Browse the repository at this point in the history
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
rajarshi authored and egonw committed Dec 10, 2011
1 parent 0a98a7f commit 150fee9
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 31 deletions.
3 changes: 1 addition & 2 deletions src/main/org/openscience/cdk/silent/Reaction.java
Expand Up @@ -27,7 +27,6 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IMapping;
import org.openscience.cdk.interfaces.IMoleculeSet;
import org.openscience.cdk.interfaces.IReaction;

import java.io.Serializable;
Expand Down Expand Up @@ -449,7 +448,7 @@ public Object clone() throws CloneNotSupportedException {
Reaction clone = (Reaction)super.clone();
// clone the reactants, products and agents
clone.reactants = (IAtomContainerSet) reactants.clone();
clone.agents = (IMoleculeSet) agents.clone();
clone.agents = (IAtomContainerSet) agents.clone();
clone.products = (IAtomContainerSet) products.clone();
// create a Map of corresponding atoms for molecules (key: original Atom,
// value: clone Atom)
Expand Down
Expand Up @@ -20,12 +20,6 @@
*/
package org.openscience.cdk.tools.manipulator;

import java.io.InputStream;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -41,20 +35,26 @@
import org.openscience.cdk.Reaction;
import org.openscience.cdk.ReactionSet;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IChemFile;
import org.openscience.cdk.interfaces.IChemModel;
import org.openscience.cdk.interfaces.IChemSequence;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IMoleculeSet;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.interfaces.IReactionSet;
import org.openscience.cdk.io.MDLReader;
import org.openscience.cdk.io.IChemObjectReader.Mode;
import org.openscience.cdk.io.MDLReader;
import org.openscience.cdk.tools.IDCreator;
import org.openscience.cdk.tools.ILoggingTool;
import org.openscience.cdk.tools.LoggingToolFactory;

import java.io.InputStream;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

/**
* @cdk.module test-standard
*/
Expand All @@ -68,7 +68,7 @@ public class ChemFileManipulatorTest extends CDKTestCase {
IAtom atomInMol1 = null;
IBond bondInMol1 = null;
IAtom atomInMol2 = null;
IMoleculeSet moleculeSet = null;
IAtomContainerSet moleculeSet = null;
IReaction reaction = null;
IReactionSet reactionSet = null;
IChemModel chemModel = null;
Expand Down Expand Up @@ -166,7 +166,7 @@ public void testGetAllChemObjects_IChemFile()
if (o instanceof IAtom) ++atomCount;
if (o instanceof IBond) ++bondCount;
if (o instanceof IMolecule) ++molCount;
else if (o instanceof IMoleculeSet) ++molSetCount;
else if (o instanceof IAtomContainerSet) ++molSetCount;
else if (o instanceof IReaction) ++reactionCount;
else if (o instanceof IReactionSet) ++reactionSetCount;
else if (o instanceof IChemModel) ++chemModelCount;
Expand Down
Expand Up @@ -20,11 +20,6 @@
*/
package org.openscience.cdk.tools.manipulator;

import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -34,25 +29,30 @@
import org.openscience.cdk.CDKTestCase;
import org.openscience.cdk.ChemModel;
import org.openscience.cdk.ChemObject;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.Molecule;
import org.openscience.cdk.MoleculeSet;
import org.openscience.cdk.Reaction;
import org.openscience.cdk.ReactionSet;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IChemModel;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IMoleculeSet;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.interfaces.IReactionSet;
import org.openscience.cdk.io.IChemObjectReader.Mode;
import org.openscience.cdk.io.MDLRXNV2000Reader;
import org.openscience.cdk.io.MDLV2000Reader;
import org.openscience.cdk.io.IChemObjectReader.Mode;
import org.openscience.cdk.tools.IDCreator;
import org.openscience.cdk.tools.ILoggingTool;
import org.openscience.cdk.tools.LoggingToolFactory;

import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* @cdk.module test-standard
*/
Expand All @@ -66,7 +66,7 @@ public class ChemModelManipulatorTest extends CDKTestCase {
IAtom atomInMol1 = null;
IBond bondInMol1 = null;
IAtom atomInMol2 = null;
IMoleculeSet moleculeSet = null;
IAtomContainerSet moleculeSet = null;
IReaction reaction = null;
IReactionSet reactionSet = null;
IChemModel chemModel = null;
Expand All @@ -90,7 +90,7 @@ public void setUp() {
atomInMol2 = new Atom("O");
atomInMol2.setImplicitHydrogenCount(2);
molecule2.addAtom(atomInMol2);
moleculeSet = new MoleculeSet();
moleculeSet = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
moleculeSet.addAtomContainer(molecule1);
moleculeSet.addAtomContainer(molecule2);
reaction = new Reaction();
Expand Down Expand Up @@ -171,7 +171,7 @@ public void testGetAllAtomContainers_IChemModel_WithReactions() throws Exception
mol2.addAtom(new Atom("I"));
IBond bond2 = new Bond(mol2.getAtom(0), mol2.getAtom(1));
mol2.addBond(bond2);
IMoleculeSet molSet = new MoleculeSet();
IAtomContainerSet molSet = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
molSet.addAtomContainer(mol1);
IReaction r = new Reaction();
r.addProduct(mol2);
Expand Down Expand Up @@ -204,7 +204,7 @@ public void testGetAllAtomContainers_IChemModel_WithReactions() throws Exception
mol2.addAtom(new Atom("I"));
IBond bond2 = new Bond(mol2.getAtom(0), mol2.getAtom(1));
mol2.addBond(bond2);
IMoleculeSet molSet = new MoleculeSet();
IAtomContainerSet molSet = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
molSet.addAtomContainer(mol1);
IReaction r = new Reaction();
r.addProduct(mol2);
Expand Down Expand Up @@ -264,7 +264,7 @@ public void testGetAllAtomContainers_IChemModel_WithReactions() throws Exception
//if (o instanceof IAtom) ++atomCount;
//if (o instanceof IBond) ++bondCount;
if (o instanceof IMolecule) ++molCount;
else if (o instanceof IMoleculeSet) ++molSetCount;
else if (o instanceof IAtomContainerSet) ++molSetCount;
else if (o instanceof IReaction) ++reactionCount;
else if (o instanceof IReactionSet) ++reactionSetCount;
else Assert.fail("Unexpected Object of type " + o.getClass());
Expand Down
Expand Up @@ -23,11 +23,24 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openscience.cdk.*;
import org.openscience.cdk.interfaces.*;
import org.openscience.cdk.Atom;
import org.openscience.cdk.Bond;
import org.openscience.cdk.CDKTestCase;
import org.openscience.cdk.ChemModel;
import org.openscience.cdk.ChemSequence;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.Molecule;
import org.openscience.cdk.Reaction;
import org.openscience.cdk.ReactionSet;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IChemModel;
import org.openscience.cdk.interfaces.IChemSequence;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.interfaces.IReactionSet;
import org.openscience.cdk.tools.IDCreator;
import org.openscience.cdk.tools.manipulator.ChemSequenceManipulator;

import java.util.HashSet;
import java.util.List;
Expand All @@ -43,7 +56,7 @@ public class ChemSequenceManipulatorTest extends CDKTestCase {
IAtom atomInMol1 = null;
IBond bondInMol1 = null;
IAtom atomInMol2 = null;
IMoleculeSet moleculeSet = null;
IAtomContainerSet moleculeSet = null;
IReaction reaction = null;
IReactionSet reactionSet = null;
IChemModel chemModel1 = null;
Expand All @@ -67,7 +80,7 @@ public void setUp() {
atomInMol2 = new Atom("O");
atomInMol2.setImplicitHydrogenCount(2);
molecule2.addAtom(atomInMol2);
moleculeSet = new MoleculeSet();
moleculeSet = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
moleculeSet.addAtomContainer(molecule1);
moleculeSet.addAtomContainer(molecule2);
reaction = new Reaction();
Expand Down Expand Up @@ -114,7 +127,7 @@ public void testGetAtomCount_IChemSequence() {
//if (o instanceof IAtom) ++atomCount;
//if (o instanceof IBond) ++bondCount;
if (o instanceof IMolecule) ++molCount;
else if (o instanceof IMoleculeSet) ++molSetCount;
else if (o instanceof IAtomContainerSet) ++molSetCount;
else if (o instanceof IReaction) ++reactionCount;
else if (o instanceof IReactionSet) ++reactionSetCount;
else if (o instanceof IChemModel) ++chemModelCount;
Expand Down

0 comments on commit 150fee9

Please sign in to comment.