Skip to content

Commit

Permalink
Another batch of s/IMolecule/IAtomContainer/
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 Dec 11, 2011
1 parent 6bf4aa2 commit 5da1d1b
Show file tree
Hide file tree
Showing 28 changed files with 144 additions and 221 deletions.
24 changes: 12 additions & 12 deletions src/main/org/openscience/cdk/debug/DebugReaction.java
Expand Up @@ -20,18 +20,18 @@
*/
package org.openscience.cdk.debug;

import java.util.Map;

import org.openscience.cdk.Reaction;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IChemObjectChangeEvent;
import org.openscience.cdk.interfaces.IChemObjectListener;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.tools.ILoggingTool;
import org.openscience.cdk.tools.LoggingToolFactory;

import java.util.Map;

/**
* Debugging data class.
*
Expand Down Expand Up @@ -181,47 +181,47 @@ public IAtomContainerSet getAgents() {
return super.getAgents();
}

public void addReactant(IMolecule reactant) {
public void addReactant(IAtomContainer reactant) {
logger.debug("Adding reactant: ", reactant);
super.addReactant(reactant);
}

public void addAgent(IMolecule agent) {
public void addAgent(IAtomContainer agent) {
logger.debug("Adding agent: ", agent);
super.addAgent(agent);
}

public void addReactant(IMolecule reactant, Double coefficient) {
public void addReactant(IAtomContainer reactant, Double coefficient) {
logger.debug("Adding reactant with coefficient: ", reactant, ""+coefficient);
super.addReactant(reactant, coefficient);
}

public void addProduct(IMolecule product) {
public void addProduct(IAtomContainer product) {
logger.debug("Adding product: ", product);
super.addProduct(product);
}

public void addProduct(IMolecule product, Double coefficient) {
public void addProduct(IAtomContainer product, Double coefficient) {
logger.debug("Adding product with coefficient: ", product, ""+coefficient);
super.addProduct(product, coefficient);
}

public Double getReactantCoefficient(IMolecule reactant) {
public Double getReactantCoefficient(IAtomContainer reactant) {
logger.debug("Setting reactant coefficient: ", reactant, ""+ super.getReactantCoefficient(reactant));
return super.getReactantCoefficient(reactant);
}

public Double getProductCoefficient(IMolecule product) {
public Double getProductCoefficient(IAtomContainer product) {
logger.debug("Setting product coefficient: ", product, ""+ super.getProductCoefficient(product));
return super.getProductCoefficient(product);
}

public boolean setReactantCoefficient(IMolecule reactant, Double coefficient) {
public boolean setReactantCoefficient(IAtomContainer reactant, Double coefficient) {
logger.debug("Setting reactant coefficient: ", reactant, ""+coefficient);
return super.setReactantCoefficient(reactant, coefficient);
}

public boolean setProductCoefficient(IMolecule product, Double coefficient) {
public boolean setProductCoefficient(IAtomContainer product, Double coefficient) {
logger.debug("Setting product coefficient: ", product, ""+coefficient);
return super.setProductCoefficient(product, coefficient);
}
Expand Down
Expand Up @@ -28,12 +28,12 @@
package org.openscience.cdk.dict;

import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IChemModel;
import org.openscience.cdk.interfaces.IChemObject;
import org.openscience.cdk.interfaces.IElement;
import org.openscience.cdk.interfaces.IIsotope;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IReaction;

/**
Expand Down Expand Up @@ -67,8 +67,8 @@ public static void makeReferencesExplicit(IChemObject object) {
makeReferencesExplicitForIsotope((IIsotope)object);
} else if (object instanceof IElement) {
makeReferencesExplicitForElement((IElement)object);
} else if (object instanceof IMolecule) {
makeReferencesExplicitForMolecule((IMolecule)object);
} else if (object instanceof IAtomContainer) {
makeReferencesExplicitForMolecule((IAtomContainer)object);
} else if (object instanceof IReaction) {
makeReferencesExplicitForReaction((IReaction)object);
}
Expand Down Expand Up @@ -116,7 +116,7 @@ private static void makeReferencesExplicitForIsotope(IIsotope isotope) {
isotope.setProperty(prefix + ":self:" + selfCounter++, "chemical:isotope");
}

private static void makeReferencesExplicitForMolecule(IMolecule molecule) {
private static void makeReferencesExplicitForMolecule(IAtomContainer molecule) {
int selfCounter = 0;
molecule.setProperty(prefix + ":self:" + selfCounter++, "chemical:molecularEntity");
/* remark: this is not strictly true... the Compendium includes the
Expand Down
3 changes: 2 additions & 1 deletion src/main/org/openscience/cdk/io/PCCompoundXMLReader.java
Expand Up @@ -33,6 +33,7 @@
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IChemObject;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
Expand Down Expand Up @@ -138,7 +139,7 @@ public void close() throws IOException {

// private procedures

private IMolecule readMolecule() throws Exception {
private IAtomContainer readMolecule() throws Exception {
boolean foundCompound = false;
while (parser.next() != XmlPullParser.END_DOCUMENT) {
if (parser.getEventType() == XmlPullParser.START_TAG) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/org/openscience/cdk/io/PCSubstanceXMLReader.java
Expand Up @@ -33,9 +33,10 @@
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IChemObject;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.io.formats.IResourceFormat;
import org.openscience.cdk.io.formats.PubChemSubstanceXMLFormat;
import org.openscience.cdk.io.pubchemxml.PubChemXMLHelper;
Expand Down Expand Up @@ -138,7 +139,7 @@ public void close() throws IOException {

// private procedures

private IMolecule readMolecule() throws Exception {
private IAtomContainer readMolecule() throws Exception {
boolean foundCompound = false;
while (parser.next() != XmlPullParser.END_DOCUMENT) {
if (parser.getEventType() == XmlPullParser.START_TAG) {
Expand Down
Expand Up @@ -9,7 +9,7 @@
import org.openscience.cdk.ConformerContainer;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IChemObjectBuilder;

/**
Expand Down Expand Up @@ -52,7 +52,7 @@
public class IteratingMDLConformerReader implements Iterator {
private IteratingMDLReader imdlr;
private ConformerContainer container;
private IMolecule lastMol = null;
private IAtomContainer lastMol = null;

private boolean hasNext = false;
private boolean nextIsKnown = false;
Expand Down Expand Up @@ -80,7 +80,7 @@ public boolean hasNext() {
if (!nextIsKnown) {
while (imdlr.hasNext()) {
slurpedConformers = true;
IMolecule mol = (IMolecule) imdlr.next();
IAtomContainer mol = (IAtomContainer) imdlr.next();
if (container.size() == 0) container.add(mol);
else {
if (container.getTitle().equals(mol.getProperty(CDKConstants.TITLE))) container.add(mol);
Expand Down
Expand Up @@ -34,8 +34,8 @@

import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IChemObject;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.io.ISimpleChemObjectReader;
import org.openscience.cdk.io.MDLV2000Reader;
Expand Down Expand Up @@ -94,7 +94,7 @@ public class IteratingMDLReader extends DefaultIteratingChemObjectReader impleme
private boolean nextAvailableIsKnown;
private boolean hasNext;
private IChemObjectBuilder builder;
private IMolecule nextMolecule;
private IAtomContainer nextMolecule;

private BooleanIOSetting forceReadAs3DCoords;

Expand Down Expand Up @@ -162,7 +162,7 @@ public boolean hasNext() {
reader.addChemObjectIOListener(this);
((MDLV2000Reader)reader).customizeJob();
}
nextMolecule = (IMolecule)reader.read(builder.newInstance(IMolecule.class));
nextMolecule = (IAtomContainer)reader.read(builder.newInstance(IAtomContainer.class));

// note that a molecule may have 0 atoms, but still
// be useful (by having SD tags for example), so just
Expand All @@ -187,7 +187,7 @@ public boolean hasNext() {
return hasNext;
}

private void readDataBlockInto(IMolecule m) throws IOException {
private void readDataBlockInto(IAtomContainer m) throws IOException {
String fieldName = null;
while (currentLine != null && !(currentLine.trim().equals("$$$$"))) {
logger.debug("looking for data header: ", currentLine);
Expand Down
Expand Up @@ -36,7 +36,6 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IChemFile;
import org.openscience.cdk.interfaces.IChemObject;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.io.PCCompoundASNReader;
import org.openscience.cdk.io.formats.IResourceFormat;
Expand Down Expand Up @@ -68,7 +67,7 @@ public class IteratingPCCompoundASNReader extends DefaultIteratingChemObjectRead

private boolean nextAvailableIsKnown;
private boolean hasNext;
private IMolecule nextMolecule;
private IAtomContainer nextMolecule;

private String currentLine;
private int depth;
Expand Down Expand Up @@ -140,12 +139,7 @@ public boolean hasNext() {
new StringReader(buffer.toString())
);
IChemFile cFile = (IChemFile)asnReader.read(builder.newInstance(IChemFile.class));
IAtomContainer container = ChemFileManipulator.getAllAtomContainers(cFile).get(0);
if (container instanceof IMolecule) {
nextMolecule = (IMolecule)container;
} else {
nextMolecule = builder.newInstance(IMolecule.class,container);
}
nextMolecule = ChemFileManipulator.getAllAtomContainers(cFile).get(0);
}
} catch (Exception exception) {
logger.error("Error while reading next molecule: ", exception.getMessage());
Expand Down
Expand Up @@ -32,8 +32,8 @@

import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IChemObject;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.io.formats.IResourceFormat;
import org.openscience.cdk.io.formats.PubChemCompoundsXMLFormat;
Expand Down Expand Up @@ -65,7 +65,7 @@ public class IteratingPCCompoundXMLReader extends DefaultIteratingChemObjectRead

private boolean nextAvailableIsKnown;
private boolean hasNext;
private IMolecule nextMolecule;
private IAtomContainer nextMolecule;

/**
* Constructs a new IteratingPCCompoundXMLReader that can read Molecule from a given Reader and IChemObjectBuilder.
Expand Down
10 changes: 5 additions & 5 deletions src/main/org/openscience/cdk/io/program/GaussianInputWriter.java
Expand Up @@ -36,8 +36,8 @@
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IChemObject;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.io.DefaultChemObjectWriter;
import org.openscience.cdk.io.formats.GaussianInputFormat;
import org.openscience.cdk.io.formats.IResourceFormat;
Expand Down Expand Up @@ -120,15 +120,15 @@ public void close() throws IOException {

@TestMethod("testAccepts")
public boolean accepts(Class classObject) {
if (IMolecule.class.isInstance(classObject)) return true;
if (IAtomContainer.class.isInstance(classObject)) return true;
return false;
}

@TestMethod("testWrite")
public void write(IChemObject object) throws CDKException {
if (object instanceof IMolecule) {
if (object instanceof IAtomContainer) {
try {
writeMolecule((IMolecule)object);
writeMolecule((IAtomContainer)object);
} catch(Exception ex) {
throw new CDKException("Error while writing Gaussian input file: " + ex.getMessage(), ex);
}
Expand All @@ -140,7 +140,7 @@ public void write(IChemObject object) throws CDKException {
/**
* Writes a molecule for input for Gaussian.
*/
public void writeMolecule(IMolecule mol) throws IOException {
public void writeMolecule(IAtomContainer mol) throws IOException {

customizeJob();

Expand Down

0 comments on commit 5da1d1b

Please sign in to comment.