Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactored the last getter from IReaction to use IAtomContainer*
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
rajarshi authored and egonw committed Dec 8, 2011
1 parent 104ecd1 commit 91f8083
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/main/org/openscience/cdk/Reaction.java
Expand Up @@ -70,7 +70,7 @@ public class Reaction extends ChemObject implements Serializable, IReaction, Clo
protected IAtomContainerSet products;
/** These are the used solvent, catalysts etc that normally appear above
the reaction arrow */
protected IMoleculeSet agents;
protected IAtomContainerSet agents;

protected IMapping[] map;
protected int mappingCount;
Expand All @@ -81,9 +81,9 @@ public class Reaction extends ChemObject implements Serializable, IReaction, Clo
* Constructs an empty, forward reaction.
*/
public Reaction() {
this.reactants = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
this.products = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
this.agents = new MoleculeSet();
this.reactants = getBuilder().newInstance(IAtomContainerSet.class);
this.products = getBuilder().newInstance(IAtomContainerSet.class);
this.agents = getBuilder().newInstance(IAtomContainerSet.class);
this.map = new Mapping[growArraySize];
mappingCount = 0;
reactionDirection = IReaction.Direction.FORWARD;
Expand Down Expand Up @@ -155,7 +155,7 @@ public void setProducts(IMoleculeSet setOfMolecules) {
* @return A MoleculeSet containing the agents in this reaction
* @see #addAgent
*/
public IMoleculeSet getAgents() {
public IAtomContainerSet getAgents() {
return agents;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/org/openscience/cdk/debug/DebugReaction.java
Expand Up @@ -177,7 +177,7 @@ public void setProducts(IMoleculeSet products) {
super.setProducts(products);
}

public IMoleculeSet getAgents() {
public IAtomContainerSet getAgents() {
logger.debug("Getting agents: ", super.getAgents());
return super.getAgents();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/org/openscience/cdk/interfaces/IReaction.java
Expand Up @@ -110,7 +110,7 @@ public enum Direction {
* @return A IMoleculeSet containing the agents in this reaction
* @see #addAgent
*/
public IMoleculeSet getAgents();
public IAtomContainerSet getAgents();

/**
* Returns the mappings between the reactant and the product side.
Expand Down
2 changes: 1 addition & 1 deletion src/main/org/openscience/cdk/libio/cml/Convertor.java
Expand Up @@ -387,7 +387,7 @@ private CMLReaction cdkReactionToCMLReaction(IReaction reaction, boolean setIDs)

// substance
CMLSubstanceList cmlSubstances = new CMLSubstanceList();
Iterator<IAtomContainer> substance = reaction.getAgents().molecules().iterator();
Iterator<IAtomContainer> substance = reaction.getAgents().atomContainers().iterator();
while (substance.hasNext()) {
CMLSubstance cmlSubstance = new CMLSubstance();
cmlSubstance.addMolecule(cdkMoleculeToCMLMolecule((IMolecule)substance.next(), false));
Expand Down
10 changes: 5 additions & 5 deletions src/main/org/openscience/cdk/silent/Reaction.java
Expand Up @@ -68,7 +68,7 @@ public class Reaction extends ChemObject implements Serializable, IReaction, Clo
protected IAtomContainerSet products;
/** These are the used solvent, catalysts etc that normally appear above
the reaction arrow */
protected IMoleculeSet agents;
protected IAtomContainerSet agents;

protected IMapping[] map;
protected int mappingCount;
Expand All @@ -79,9 +79,9 @@ public class Reaction extends ChemObject implements Serializable, IReaction, Clo
* Constructs an empty, forward reaction.
*/
public Reaction() {
this.reactants = SilentChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
this.products = SilentChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
this.agents = new MoleculeSet();
this.reactants = getBuilder().newInstance(IAtomContainerSet.class);
this.products = getBuilder().newInstance(IAtomContainerSet.class);
this.agents = getBuilder().newInstance(IAtomContainerSet.class);
this.map = new Mapping[growArraySize];
mappingCount = 0;
reactionDirection = IReaction.Direction.FORWARD;
Expand Down Expand Up @@ -151,7 +151,7 @@ public void setProducts(IMoleculeSet setOfMolecules) {
* @return A MoleculeSet containing the agents in this reaction
* @see #addAgent
*/
public IMoleculeSet getAgents() {
public IAtomContainerSet getAgents() {
return agents;
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/org/openscience/cdk/smiles/SmilesGenerator.java
Expand Up @@ -41,7 +41,6 @@
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IIsotope;
import org.openscience.cdk.interfaces.IMoleculeSet;
import org.openscience.cdk.interfaces.IPseudoAtom;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.interfaces.IRingSet;
Expand Down Expand Up @@ -232,10 +231,10 @@ public synchronized String createSMILES(IReaction reaction) throws CDKException
}
}
reactionSMILES.append('>');
IMoleculeSet agents = reaction.getAgents();
IAtomContainerSet agents = reaction.getAgents();
for (int i = 0; i < agents.getAtomContainerCount(); i++)
{
reactionSMILES.append(createSMILES(agents.getMolecule(i)));
reactionSMILES.append(createSMILES(agents.getAtomContainer(i)));
if (i + 1 < agents.getAtomContainerCount())
{
reactionSMILES.append('.');
Expand Down
Expand Up @@ -537,7 +537,7 @@ private IAtomContainer checkForXMoleculeFile(IChemFile chemFile, int numberOfMol
Assert.assertEquals(1, reaction.getAgents().getAtomContainerCount());
Assert.assertEquals("react", reaction.getReactants().getAtomContainer(0).getID());
Assert.assertEquals("product", reaction.getProducts().getAtomContainer(0).getID());
Assert.assertEquals("water", reaction.getAgents().getMolecule(0).getID());
Assert.assertEquals("water", reaction.getAgents().getAtomContainer(0).getID());
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/test/org/openscience/cdk/io/cml/CMLRoundTripTest.java
Expand Up @@ -45,7 +45,6 @@
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.io.CMLReader;
import org.openscience.cdk.libio.cml.Convertor;
Expand Down Expand Up @@ -519,10 +518,10 @@ public void testAtomStereoParity() throws Exception {
Assert.assertEquals("product", roundTrippedProduct.getID());
Assert.assertEquals(1, roundTrippedProduct.getAtomCount());

IMoleculeSet agents = roundTrippedReaction.getAgents();
IAtomContainerSet agents = roundTrippedReaction.getAgents();
Assert.assertNotNull(agents);
Assert.assertEquals(1, agents.getAtomContainerCount());
IMolecule roundTrippedAgent = agents.getMolecule(0);
IAtomContainer roundTrippedAgent = agents.getAtomContainer(0);
Assert.assertEquals("water", roundTrippedAgent.getID());
Assert.assertEquals(1, roundTrippedAgent.getAtomCount());
}
Expand Down
Expand Up @@ -30,7 +30,6 @@
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IChemFile;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IMoleculeSet;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.interfaces.IReactionSet;
import org.openscience.cdk.io.CMLReader;
Expand Down Expand Up @@ -313,7 +312,7 @@ private Dictionary openingDictionary() {
IReaction reactionDict = chemFile.getChemSequence(0).getChemModel(0).getReactionSet().getReaction(0);

IAtomContainerSet reactants = reactionDict.getReactants();
IMoleculeSet agents = reactionDict.getAgents();
IAtomContainerSet agents = reactionDict.getAgents();
IAtomContainerSet products = reactionDict.getProducts();
if(agents.getAtomContainerCount() == 0)
agents = null;
Expand Down

0 comments on commit 91f8083

Please sign in to comment.