Skip to content

Commit

Permalink
More modifications to use AtomContainer rather than Molecule
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 9, 2011
1 parent 46e3ddc commit f4647d8
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 163 deletions.
3 changes: 1 addition & 2 deletions src/main/org/openscience/cdk/Reaction.java
Expand Up @@ -29,7 +29,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 @@ -462,7 +461,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
16 changes: 8 additions & 8 deletions src/main/org/openscience/cdk/interfaces/IReaction.java
Expand Up @@ -73,15 +73,15 @@ public enum Direction {
public int getProductCount();

/**
* Returns a IMoleculeSet containing the reactants in this reaction.
* Returns a IAtomContaineSet containing the reactants in this reaction.
*
* @return A IMoleculeSet containing the reactants in this reaction
* @return A IAtomContaineSet containing the reactants in this reaction
* @see #setReactants
*/
public IAtomContainerSet getReactants();

/**
* Assigns a IMoleculeSet to the reactants in this reaction.
* Assigns a IAtomContaineSet to the reactants in this reaction.
*
*
* @param reactants The new set of reactants
Expand All @@ -90,15 +90,15 @@ public enum Direction {
public void setReactants(IAtomContainerSet reactants);

/**
* Returns a IMoleculeSet containing the products of this reaction.
* Returns a IAtomContaineSet containing the products of this reaction.
*
* @return A IMoleculeSet containing the products in this reaction
* @return A IAtomContaineSet containing the products in this reaction
* @see #setProducts
*/
public IAtomContainerSet getProducts();

/**
* Assigns a IMoleculeSet to the products of this reaction.
* Assigns a IAtomContaineSet to the products of this reaction.
*
*
* @param products The new set of products
Expand All @@ -107,9 +107,9 @@ public enum Direction {
public void setProducts(IAtomContainerSet products);

/**
* Returns a IMoleculeSet containing the agents in this reaction.
* Returns a IAtomContaineSet containing the agents in this reaction.
*
* @return A IMoleculeSet containing the agents in this reaction
* @return A IAtomContaineSet containing the agents in this reaction
* @see #addAgent
*/
public IAtomContainerSet getAgents();
Expand Down
25 changes: 12 additions & 13 deletions src/main/org/openscience/cdk/io/CMLWriter.java
Expand Up @@ -26,20 +26,10 @@
*/
package org.openscience.cdk.io;

import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;

import nu.xom.Attribute;
import nu.xom.Document;
import nu.xom.Element;
import nu.xom.Serializer;

import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.exception.CDKException;
Expand Down Expand Up @@ -67,8 +57,17 @@
import org.openscience.cdk.tools.ILoggingTool;
import org.openscience.cdk.tools.LoggingToolFactory;

import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;

/**
* Serializes a {@link IMoleculeSet} or a {@link IMolecule} object to CML 2 code.
* Serializes a {@link IAtomContainerSet} or a {@link IAtomContainer} object to CML 2 code.
* Chemical Markup Language is an XML-based file format {@cdk.cite PMR99}.
* Output can be redirected to other Writer objects like {@link StringWriter}
* and {@link FileWriter}. An example:
Expand Down Expand Up @@ -204,7 +203,7 @@ public boolean accepts(Class classObject) {
/**
* Serializes the IChemObject to CML and redirects it to the output Writer.
*
* @param object A Molecule of MoleculeSet object
* @param object A Molecule of AtomContaineSet object
*/
public void write(IChemObject object) throws CDKException {

Expand Down Expand Up @@ -253,7 +252,7 @@ public void write(IChemObject object) throws CDKException {
} else if (object instanceof IReactionSet) {
root = convertor.cdkReactionSetToCMLReactionList((IReactionSet)object);
} else if (object instanceof IAtomContainerSet) {
root = convertor.cdkMoleculeSetToCMLList((IAtomContainerSet)object);
root = convertor.cdkAtomContainerSetToCMLList((IAtomContainerSet)object);
} else if (object instanceof IChemSequence) {
root = convertor.cdkChemSequenceToCMLList((IChemSequence)object);
} else if (object instanceof IChemModel) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/org/openscience/cdk/io/RssWriter.java
Expand Up @@ -211,7 +211,7 @@ public void write(IChemObject object) throws CDKException {
} else if (object instanceof IReactionSet) {
root = convertor.cdkReactionSetToCMLReactionList((IReactionSet)object);
} else if (object instanceof IAtomContainerSet) {
root = convertor.cdkMoleculeSetToCMLList((IAtomContainerSet)object);
root = convertor.cdkAtomContainerSetToCMLList((IAtomContainerSet)object);
} else if (object instanceof IChemSequence) {
root = convertor.cdkChemSequenceToCMLList((IChemSequence)object);
} else if (object instanceof IChemModel) {
Expand Down
24 changes: 12 additions & 12 deletions src/main/org/openscience/cdk/libio/cml/Convertor.java
Expand Up @@ -25,13 +25,6 @@
*/
package org.openscience.cdk.libio.cml;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.dict.DictRef;
import org.openscience.cdk.dict.DictionaryDatabase;
Expand Down Expand Up @@ -85,6 +78,13 @@
import org.xmlcml.cml.element.CMLSubstance;
import org.xmlcml.cml.element.CMLSubstanceList;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
* @cdk.module libiocml
* @cdk.githash
Expand Down Expand Up @@ -235,15 +235,15 @@ private CMLList cdkChemModelToCMLList(IChemModel model, boolean setIDs) {
cmlList.appendChild(cdkReactionSetToCMLReactionList(model.getReactionSet(), false));
}
if (model.getMoleculeSet() != null) {
cmlList.appendChild(cdkMoleculeSetToCMLList(model.getMoleculeSet(), false));
cmlList.appendChild(cdkAtomContainerSetToCMLList(model.getMoleculeSet(), false));
}

return cmlList;
}

public CMLCml cdkReactionSchemeToCMLReactionSchemeAndMoleculeList(IReactionScheme cdkScheme){
CMLCml cml = new CMLCml();
cml.appendChild(cdkMoleculeSetToCMLList(ReactionSchemeManipulator.getAllMolecules(cdkScheme)));
cml.appendChild(cdkAtomContainerSetToCMLList(ReactionSchemeManipulator.getAllAtomContainers(cdkScheme)));
cml.appendChild(cdkReactionSchemeToCMLReactionScheme(cdkScheme, true, true));
return cml;
}
Expand Down Expand Up @@ -305,11 +305,11 @@ private CMLReactionList cdkReactionSetToCMLReactionList(IReactionSet reactionSet
return reactionList;
}

public CMLMoleculeList cdkMoleculeSetToCMLList(IAtomContainerSet moleculeSet) {
return cdkMoleculeSetToCMLList(moleculeSet, true);
public CMLMoleculeList cdkAtomContainerSetToCMLList(IAtomContainerSet moleculeSet) {
return cdkAtomContainerSetToCMLList(moleculeSet, true);
}

private CMLMoleculeList cdkMoleculeSetToCMLList(IAtomContainerSet moleculeSet, boolean setIDs) {
private CMLMoleculeList cdkAtomContainerSetToCMLList(IAtomContainerSet moleculeSet, boolean setIDs) {
CMLMoleculeList cmlList = new CMLMoleculeList();
cmlList.setConvention("cdk:moleculeSet");

Expand Down

0 comments on commit f4647d8

Please sign in to comment.