use of org.openscience.cdk.Reaction in project cdk by cdk.
the class ChemModelManipulatorTest method setUp.
@Before
public void setUp() {
molecule1 = new AtomContainer();
atomInMol1 = new Atom("Cl");
atomInMol1.setCharge(-1.0);
atomInMol1.setFormalCharge(-1);
atomInMol1.setImplicitHydrogenCount(1);
molecule1.addAtom(atomInMol1);
molecule1.addAtom(new Atom("Cl"));
bondInMol1 = new Bond(atomInMol1, molecule1.getAtom(1));
molecule1.addBond(bondInMol1);
molecule2 = new AtomContainer();
atomInMol2 = new Atom("O");
atomInMol2.setImplicitHydrogenCount(2);
molecule2.addAtom(atomInMol2);
moleculeSet = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
moleculeSet.addAtomContainer(molecule1);
moleculeSet.addAtomContainer(molecule2);
reaction = new Reaction();
reaction.addReactant(molecule1);
reaction.addProduct(molecule2);
reactionSet = new ReactionSet();
reactionSet.addReaction(reaction);
chemModel = new ChemModel();
chemModel.setMoleculeSet(moleculeSet);
chemModel.setReactionSet(reactionSet);
}
use of org.openscience.cdk.Reaction in project cdk by cdk.
the class ChemModelManipulatorTest method testRemoveElectronContainer_IChemModel_IElectronContainer.
@Test
public void testRemoveElectronContainer_IChemModel_IElectronContainer() {
IAtomContainer mol1 = new AtomContainer();
mol1.addAtom(new Atom("Cl"));
mol1.addAtom(new Atom("Cl"));
IBond bond1 = new Bond(mol1.getAtom(0), mol1.getAtom(1));
mol1.addBond(bond1);
IAtomContainer mol2 = new AtomContainer();
mol2.addAtom(new Atom("I"));
mol2.addAtom(new Atom("I"));
IBond bond2 = new Bond(mol2.getAtom(0), mol2.getAtom(1));
mol2.addBond(bond2);
IAtomContainerSet molSet = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
molSet.addAtomContainer(mol1);
IReaction r = new Reaction();
r.addProduct(mol2);
IReactionSet rSet = new ReactionSet();
rSet.addReaction(r);
IChemModel model = new ChemModel();
model.setMoleculeSet(molSet);
model.setReactionSet(rSet);
IBond otherBond = new Bond();
Assert.assertEquals(2, ChemModelManipulator.getBondCount(model));
ChemModelManipulator.removeElectronContainer(model, otherBond);
Assert.assertEquals(2, ChemModelManipulator.getBondCount(model));
ChemModelManipulator.removeElectronContainer(model, bond1);
Assert.assertEquals(1, ChemModelManipulator.getBondCount(model));
ChemModelManipulator.removeElectronContainer(model, bond2);
Assert.assertEquals(0, ChemModelManipulator.getBondCount(model));
}
use of org.openscience.cdk.Reaction in project cdk by cdk.
the class ChemSequenceManipulatorTest method setUp.
@Before
public void setUp() {
molecule1 = new AtomContainer();
atomInMol1 = new Atom("Cl");
molecule1.addAtom(atomInMol1);
molecule1.addAtom(new Atom("Cl"));
bondInMol1 = new Bond(atomInMol1, molecule1.getAtom(1));
molecule1.addBond(bondInMol1);
molecule2 = new AtomContainer();
atomInMol2 = new Atom("O");
atomInMol2.setImplicitHydrogenCount(2);
molecule2.addAtom(atomInMol2);
moleculeSet = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
moleculeSet.addAtomContainer(molecule1);
moleculeSet.addAtomContainer(molecule2);
reaction = new Reaction();
reaction.addReactant(molecule1);
reaction.addProduct(molecule2);
reactionSet = new ReactionSet();
reactionSet.addReaction(reaction);
chemModel1 = new ChemModel();
chemModel1.setMoleculeSet(moleculeSet);
chemModel2 = new ChemModel();
chemModel2.setReactionSet(reactionSet);
chemSequence = new ChemSequence();
chemSequence.addChemModel(chemModel1);
chemSequence.addChemModel(chemModel2);
}
use of org.openscience.cdk.Reaction in project cdk by cdk.
the class ReactionManipulatorTest method testGetAllIDs_IReaction.
@Test
public void testGetAllIDs_IReaction() {
Reaction reaction = new Reaction();
reaction.setID("r1");
IAtomContainer water = new AtomContainer();
water.setID("m1");
Atom oxygen = new Atom("O");
oxygen.setID("a1");
water.addAtom(oxygen);
reaction.addReactant(water);
reaction.addProduct(water);
List<String> ids = ReactionManipulator.getAllIDs(reaction);
Assert.assertNotNull(ids);
Assert.assertEquals(5, ids.size());
}
use of org.openscience.cdk.Reaction in project cdk by cdk.
the class ReactionManipulatorTest method testReverse_IReaction.
@Test
public void testReverse_IReaction() {
Reaction reaction = new Reaction();
reaction.setDirection(IReaction.Direction.BACKWARD);
IAtomContainer water = new AtomContainer();
reaction.addReactant(water, 3.0);
reaction.addReactant(new AtomContainer());
reaction.addProduct(new AtomContainer());
Reaction reversedReaction = (Reaction) ReactionManipulator.reverse(reaction);
Assert.assertEquals(IReaction.Direction.FORWARD, reversedReaction.getDirection());
Assert.assertEquals(2, reversedReaction.getProductCount());
Assert.assertEquals(1, reversedReaction.getReactantCount());
Assert.assertEquals(3.0, reversedReaction.getProductCoefficient(water), 0.00001);
}
Aggregations