Skip to content

Commit

Permalink
Fixed castings, to solve failing unit tests
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 9, 2011
1 parent 9e97f2d commit d273aa4
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 50 deletions.
Expand Up @@ -30,6 +30,7 @@
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.graph.ConnectivityChecker;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.interfaces.IBond;
Expand Down Expand Up @@ -127,7 +128,7 @@ public IReaction initiate(IMoleculeSet moleculeSet, ArrayList<IAtom> atomList,Ar
} else{
IAtomContainerSet moleculeSetP = ConnectivityChecker.partitionIntoMolecules(reactantCloned);
for(int z = 0; z < moleculeSetP.getAtomContainerCount() ; z++){
reaction.addProduct((IMolecule)moleculeSetP.getAtomContainer(z));
reaction.addProduct((IAtomContainer)moleculeSetP.getAtomContainer(z));
}
}

Expand Down
Expand Up @@ -30,6 +30,7 @@
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.graph.ConnectivityChecker;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.interfaces.IBond;
Expand Down Expand Up @@ -123,7 +124,7 @@ public IReaction initiate(IMoleculeSet moleculeSet, ArrayList<IAtom> atomList,Ar
} else{
IAtomContainerSet moleculeSetP = ConnectivityChecker.partitionIntoMolecules(reactantCloned);
for(int z = 0; z < moleculeSetP.getAtomContainerCount() ; z++){
reaction.addProduct((IMolecule)moleculeSetP.getAtomContainer(z));
reaction.addProduct((IAtomContainer)moleculeSetP.getAtomContainer(z));
}
}

Expand Down
Expand Up @@ -31,6 +31,7 @@
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.graph.ConnectivityChecker;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.interfaces.IBond;
Expand Down Expand Up @@ -132,7 +133,7 @@ public IReaction initiate(IMoleculeSet moleculeSet, ArrayList<IAtom> atomList,Ar

IAtomContainerSet moleculeSetP = ConnectivityChecker.partitionIntoMolecules(reactantCloned);
for(int z = 0; z < moleculeSetP.getAtomContainerCount() ; z++)
reaction.addProduct((IMolecule)moleculeSetP.getAtomContainer(z));
reaction.addProduct((IAtomContainer)moleculeSetP.getAtomContainer(z));

return reaction;
}
Expand Down
Expand Up @@ -33,6 +33,7 @@
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.graph.ConnectivityChecker;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.interfaces.IBond;
Expand Down Expand Up @@ -162,7 +163,7 @@ public IReaction initiate(IMoleculeSet moleculeSet, ArrayList<IAtom> atomList,Ar
} else{
IAtomContainerSet moleculeSetP = ConnectivityChecker.partitionIntoMolecules(reactantCloned);
for(int z = 0; z < moleculeSetP.getAtomContainerCount() ; z++){
reaction.addProduct((IMolecule)moleculeSetP.getAtomContainer(z));
reaction.addProduct((IAtomContainer)moleculeSetP.getAtomContainer(z));
}
}

Expand Down
Expand Up @@ -30,6 +30,7 @@
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.graph.ConnectivityChecker;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.interfaces.IBond;
Expand Down Expand Up @@ -125,7 +126,7 @@ public IReaction initiate(IMoleculeSet moleculeSet, ArrayList<IAtom> atomList,Ar
}else{
IAtomContainerSet moleculeSetP = ConnectivityChecker.partitionIntoMolecules(reactantCloned);
for(int z = 0; z < moleculeSetP.getAtomContainerCount() ; z++){
reaction.addProduct((IMolecule)moleculeSetP.getAtomContainer(z));
reaction.addProduct((IAtomContainer)moleculeSetP.getAtomContainer(z));
}
}

Expand Down
Expand Up @@ -25,14 +25,15 @@
package org.openscience.cdk.reaction.type;


import java.util.Iterator;

import org.openscience.cdk.CDKConstants;
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.IAtomContainerSet;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.interfaces.IReactionSet;
import org.openscience.cdk.interfaces.IRing;
Expand All @@ -48,8 +49,6 @@
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
import org.openscience.cdk.tools.manipulator.BondManipulator;

import java.util.Iterator;

/**
* <p>IReactionProcess which tries to reproduce the delocalization of electrons
* which are unsaturated bonds from conjugated rings. Only is allowed those
Expand Down Expand Up @@ -145,7 +144,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
// }

AllRingsFinder arf = new AllRingsFinder();
IRingSet ringSet = arf.findAllRings((IMolecule) reactant);
IRingSet ringSet = arf.findAllRings((IAtomContainer) reactant);
for (int ir = 0; ir < ringSet.getAtomContainerCount(); ir++) {
IRing ring = (IRing) ringSet.getAtomContainer(ir);

Expand Down Expand Up @@ -177,9 +176,9 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
IReaction reaction = reactants.getBuilder().newInstance(IReaction.class);
reaction.addReactant(reactant);

IMolecule reactantCloned;
IAtomContainer reactantCloned;
try {
reactantCloned = (IMolecule) reactant.clone();
reactantCloned = (IAtomContainer) reactant.clone();
} catch (CloneNotSupportedException e) {
throw new CDKException("Could not clone IMolecule!", e);
}
Expand All @@ -195,7 +194,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen

}

reaction.addProduct((IMolecule) reactantCloned);
reaction.addProduct((IAtomContainer) reactantCloned);
setOfReactions.addReaction(reaction);
}

Expand All @@ -216,7 +215,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
*/
private void setActiveCenters(IAtomContainer reactant) throws CDKException {
AllRingsFinder arf = new AllRingsFinder();
IRingSet ringSet = arf.findAllRings((IMolecule) reactant);
IRingSet ringSet = arf.findAllRings((IAtomContainer) reactant);
for (int ir = 0; ir < ringSet.getAtomContainerCount(); ir++) {
IRing ring = (IRing) ringSet.getAtomContainer(ir);
//only rings with even number of atoms
Expand Down
Expand Up @@ -25,6 +25,9 @@
package org.openscience.cdk.reaction.type;


import java.util.ArrayList;
import java.util.Iterator;

import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
Expand All @@ -34,7 +37,6 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IMoleculeSet;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.interfaces.IReactionSet;
Expand All @@ -52,9 +54,6 @@
import org.openscience.cdk.tools.LoggingToolFactory;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;

import java.util.ArrayList;
import java.util.Iterator;

/**
* <p>
* This reaction could be represented as [A*]-(C)_2-C3[H] => A([H])-(C_2)-[C3*]. Due to
Expand Down Expand Up @@ -140,7 +139,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(reactant);
CDKHueckelAromaticityDetector.detectAromaticity(reactant);
AllRingsFinder arf = new AllRingsFinder();
IRingSet ringSet = arf.findAllRings((IMolecule) reactant);
IRingSet ringSet = arf.findAllRings((IAtomContainer) reactant);
for (int ir = 0; ir < ringSet.getAtomContainerCount(); ir++) {
IRing ring = (IRing)ringSet.getAtomContainer(ir);
for (int jr = 0; jr < ring.getAtomCount(); jr++) {
Expand All @@ -160,7 +159,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
if(atomi.getFlag(CDKConstants.REACTIVE_CENTER)
&& reactant.getConnectedSingleElectronsCount(atomi) == 1) {

hcg.getSpheres((IMolecule) reactant, atomi, 2, true);
hcg.getSpheres((IAtomContainer) reactant, atomi, 2, true);
Iterator<IAtom> atomls = hcg.getNodesInSphere(2).iterator();
while(atomls.hasNext()){
IAtom atoml = atomls.next();
Expand Down Expand Up @@ -217,7 +216,7 @@ private void setActiveCenters(IAtomContainer reactant) throws CDKException {
IAtom atomi = atomis.next();
if(reactant.getConnectedSingleElectronsCount(atomi) == 1) {

hcg.getSpheres((IMolecule) reactant, atomi, 2, true);
hcg.getSpheres((IAtomContainer) reactant, atomi, 2, true);
Iterator<IAtom> atomls = hcg.getNodesInSphere(2).iterator();
while(atomls.hasNext()){
IAtom atoml = atomls.next();
Expand Down
Expand Up @@ -25,6 +25,9 @@
package org.openscience.cdk.reaction.type;


import java.util.ArrayList;
import java.util.Iterator;

import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
Expand All @@ -34,7 +37,6 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IMoleculeSet;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.interfaces.IReactionSet;
Expand All @@ -52,9 +54,6 @@
import org.openscience.cdk.tools.LoggingToolFactory;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;

import java.util.ArrayList;
import java.util.Iterator;

/**
* <p>
* This reaction could be represented as [A*]-(C)_3-C4[H] => A([H])-(C_3)-[C4*]. Due to
Expand Down Expand Up @@ -141,7 +140,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(reactant);
CDKHueckelAromaticityDetector.detectAromaticity(reactant);
AllRingsFinder arf = new AllRingsFinder();
IRingSet ringSet = arf.findAllRings((IMolecule) reactant);
IRingSet ringSet = arf.findAllRings((IAtomContainer) reactant);
for (int ir = 0; ir < ringSet.getAtomContainerCount(); ir++) {
IRing ring = (IRing)ringSet.getAtomContainer(ir);
for (int jr = 0; jr < ring.getAtomCount(); jr++) {
Expand All @@ -161,7 +160,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
if(atomi.getFlag(CDKConstants.REACTIVE_CENTER)
&& reactant.getConnectedSingleElectronsCount(atomi) == 1) {

hcg.getSpheres((IMolecule) reactant, atomi, 3, true);
hcg.getSpheres((IAtomContainer) reactant, atomi, 3, true);
Iterator<IAtom> atomls = hcg.getNodesInSphere(3).iterator();
while(atomls.hasNext()){
IAtom atoml = atomls.next();
Expand Down Expand Up @@ -218,7 +217,7 @@ private void setActiveCenters(IAtomContainer reactant) throws CDKException {
IAtom atomi = atomis.next();
if(reactant.getConnectedSingleElectronsCount(atomi) == 1) {

hcg.getSpheres((IMolecule) reactant, atomi, 3, true);
hcg.getSpheres((IAtomContainer) reactant, atomi, 3, true);
Iterator<IAtom> atomls = hcg.getNodesInSphere(3).iterator();
while(atomls.hasNext()){
IAtom atoml = atomls.next();
Expand Down
Expand Up @@ -25,6 +25,9 @@
package org.openscience.cdk.reaction.type;


import java.util.ArrayList;
import java.util.Iterator;

import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
Expand All @@ -34,7 +37,6 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IMoleculeSet;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.interfaces.IReactionSet;
Expand All @@ -52,9 +54,6 @@
import org.openscience.cdk.tools.LoggingToolFactory;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;

import java.util.ArrayList;
import java.util.Iterator;

/**
* <p>
* This reaction could be represented as [A*]-(C)_4-C5[H] => A([H])-(C_4)-[C5*]. Due to
Expand Down Expand Up @@ -142,7 +141,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(reactant);
CDKHueckelAromaticityDetector.detectAromaticity(reactant);
AllRingsFinder arf = new AllRingsFinder();
IRingSet ringSet = arf.findAllRings((IMolecule) reactant);
IRingSet ringSet = arf.findAllRings((IAtomContainer) reactant);
for (int ir = 0; ir < ringSet.getAtomContainerCount(); ir++) {
IRing ring = (IRing)ringSet.getAtomContainer(ir);
for (int jr = 0; jr < ring.getAtomCount(); jr++) {
Expand All @@ -162,7 +161,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
if(atomi.getFlag(CDKConstants.REACTIVE_CENTER)
&& reactant.getConnectedSingleElectronsCount(atomi) == 1) {

hcg.getSpheres((IMolecule) reactant, atomi, 5, true);
hcg.getSpheres((IAtomContainer) reactant, atomi, 5, true);
Iterator<IAtom> atomls = hcg.getNodesInSphere(5).iterator();
while(atomls.hasNext()){
IAtom atoml = atomls.next();
Expand Down Expand Up @@ -219,7 +218,7 @@ private void setActiveCenters(IAtomContainer reactant) throws CDKException {
IAtom atomi = atomis.next();
if(reactant.getConnectedSingleElectronsCount(atomi) == 1) {

hcg.getSpheres((IMolecule) reactant, atomi, 5, true);
hcg.getSpheres((IAtomContainer) reactant, atomi, 5, true);
Iterator<IAtom> atomls = hcg.getNodesInSphere(5).iterator();
while(atomls.hasNext()){
IAtom atoml = atomls.next();
Expand Down
Expand Up @@ -25,6 +25,9 @@
package org.openscience.cdk.reaction.type;


import java.util.ArrayList;
import java.util.Iterator;

import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
Expand All @@ -34,7 +37,6 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomContainerSet;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IMoleculeSet;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.interfaces.IReactionSet;
Expand All @@ -52,9 +54,6 @@
import org.openscience.cdk.tools.LoggingToolFactory;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;

import java.util.ArrayList;
import java.util.Iterator;

/**
* <p>
* This reaction could be represented as [A*]-C1-C2-C3[H] => A([H])-C1-C2-[C3*]. Due to
Expand Down Expand Up @@ -141,7 +140,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(reactant);
CDKHueckelAromaticityDetector.detectAromaticity(reactant);
AllRingsFinder arf = new AllRingsFinder();
IRingSet ringSet = arf.findAllRings((IMolecule) reactant);
IRingSet ringSet = arf.findAllRings((IAtomContainer) reactant);
for (int ir = 0; ir < ringSet.getAtomContainerCount(); ir++) {
IRing ring = (IRing)ringSet.getAtomContainer(ir);
for (int jr = 0; jr < ring.getAtomCount(); jr++) {
Expand All @@ -161,7 +160,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
if(atomi.getFlag(CDKConstants.REACTIVE_CENTER) && atomi.getSymbol().equals("C")
&& reactant.getConnectedSingleElectronsCount(atomi) == 1) {

hcg.getSpheres((IMolecule) reactant, atomi, 4, true);
hcg.getSpheres((IAtomContainer) reactant, atomi, 4, true);
Iterator<IAtom> atomls = hcg.getNodesInSphere(4).iterator();
while(atomls.hasNext()){
IAtom atoml = atomls.next();
Expand Down Expand Up @@ -219,7 +218,7 @@ private void setActiveCenters(IAtomContainer reactant) throws CDKException {
if(atomi.getSymbol().equals("C")
&& reactant.getConnectedSingleElectronsCount(atomi) == 1) {

hcg.getSpheres((IMolecule) reactant, atomi, 4, true);
hcg.getSpheres((IAtomContainer) reactant, atomi, 4, true);
Iterator<IAtom> atomls = hcg.getNodesInSphere(4).iterator();
while(atomls.hasNext()){
IAtom atoml = atomls.next();
Expand Down
Expand Up @@ -142,7 +142,7 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(reactant);
CDKHueckelAromaticityDetector.detectAromaticity(reactant);
AllRingsFinder arf = new AllRingsFinder();
IRingSet ringSet = arf.findAllRings((IMolecule) reactant);
IRingSet ringSet = arf.findAllRings((IAtomContainer) reactant);
for (int ir = 0; ir < ringSet.getAtomContainerCount(); ir++) {
IRing ring = (IRing)ringSet.getAtomContainer(ir);
for (int jr = 0; jr < ring.getAtomCount(); jr++) {
Expand All @@ -162,10 +162,10 @@ public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agen
if(atomi.getFlag(CDKConstants.REACTIVE_CENTER)
&& reactant.getConnectedSingleElectronsCount(atomi) == 1) {

hcg.getSpheres((IMolecule) reactant, atomi, 1, true);
hcg.getSpheres((IAtomContainer) reactant, atomi, 1, true);
List<IAtom> atom1s = hcg.getNodesInSphere(1);

hcg.getSpheres((IMolecule) reactant, atomi, 2, true);
hcg.getSpheres((IAtomContainer) reactant, atomi, 2, true);
Iterator<IAtom> atomls = hcg.getNodesInSphere(2).iterator();
while(atomls.hasNext()){
IAtom atoml = atomls.next();
Expand Down

0 comments on commit d273aa4

Please sign in to comment.