Search in sources :

Example 26 with AtomContainer

use of org.openscience.cdk.AtomContainer 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);
}
Also used : ChemSequence(org.openscience.cdk.ChemSequence) IChemSequence(org.openscience.cdk.interfaces.IChemSequence) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) ReactionSet(org.openscience.cdk.ReactionSet) ChemModel(org.openscience.cdk.ChemModel) IChemModel(org.openscience.cdk.interfaces.IChemModel) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) Bond(org.openscience.cdk.Bond) IBond(org.openscience.cdk.interfaces.IBond) Reaction(org.openscience.cdk.Reaction) IReaction(org.openscience.cdk.interfaces.IReaction) IAtom(org.openscience.cdk.interfaces.IAtom) Atom(org.openscience.cdk.Atom) Before(org.junit.Before)

Example 27 with AtomContainer

use of org.openscience.cdk.AtomContainer in project cdk by cdk.

the class MoleculeSetManipulatorTest method testRemoveElectronContainer_IAtomContainerSet_IElectronContainer.

@Test
public void testRemoveElectronContainer_IAtomContainerSet_IElectronContainer() {
    IAtomContainerSet ms = new AtomContainerSet();
    IAtomContainer mol = new AtomContainer();
    mol.addAtom(new Atom("O"));
    mol.addAtom(new Atom("O"));
    mol.addBond(0, 1, IBond.Order.DOUBLE);
    IBond bond = mol.getBond(0);
    ms.addAtomContainer(mol);
    IBond otherBond = new Bond(new Atom(), new Atom());
    MoleculeSetManipulator.removeElectronContainer(ms, otherBond);
    Assert.assertEquals(1, MoleculeSetManipulator.getBondCount(ms));
    MoleculeSetManipulator.removeElectronContainer(ms, bond);
    Assert.assertEquals(0, MoleculeSetManipulator.getBondCount(ms));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IBond(org.openscience.cdk.interfaces.IBond) Bond(org.openscience.cdk.Bond) IBond(org.openscience.cdk.interfaces.IBond) AtomContainerSet(org.openscience.cdk.AtomContainerSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) Atom(org.openscience.cdk.Atom) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 28 with AtomContainer

use of org.openscience.cdk.AtomContainer in project cdk by cdk.

the class MoleculeSetManipulatorTest method setUp.

@Before
public void setUp() {
    mol1 = new AtomContainer();
    atomInMol1 = new Atom("Cl");
    atomInMol1.setCharge(-1.0);
    atomInMol1.setFormalCharge(-1);
    atomInMol1.setImplicitHydrogenCount(1);
    mol1.addAtom(atomInMol1);
    mol1.addAtom(new Atom("Cl"));
    bondInMol1 = new Bond(atomInMol1, mol1.getAtom(1));
    mol1.addBond(bondInMol1);
    mol2 = new AtomContainer();
    atomInMol2 = new Atom("O");
    atomInMol2.setImplicitHydrogenCount(2);
    mol2.addAtom(atomInMol2);
    som.addAtomContainer(mol1);
    som.addAtomContainer(mol2);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) Bond(org.openscience.cdk.Bond) IBond(org.openscience.cdk.interfaces.IBond) Atom(org.openscience.cdk.Atom) IAtom(org.openscience.cdk.interfaces.IAtom) Before(org.junit.Before)

Example 29 with AtomContainer

use of org.openscience.cdk.AtomContainer 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());
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) Reaction(org.openscience.cdk.Reaction) IReaction(org.openscience.cdk.interfaces.IReaction) IAtom(org.openscience.cdk.interfaces.IAtom) Atom(org.openscience.cdk.Atom) Test(org.junit.Test)

Example 30 with AtomContainer

use of org.openscience.cdk.AtomContainer 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);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) Reaction(org.openscience.cdk.Reaction) IReaction(org.openscience.cdk.interfaces.IReaction) Test(org.junit.Test)

Aggregations

AtomContainer (org.openscience.cdk.AtomContainer)743 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)730 Test (org.junit.Test)641 IAtom (org.openscience.cdk.interfaces.IAtom)556 Atom (org.openscience.cdk.Atom)523 PseudoAtom (org.openscience.cdk.PseudoAtom)206 IBond (org.openscience.cdk.interfaces.IBond)136 Bond (org.openscience.cdk.Bond)90 Point2d (javax.vecmath.Point2d)86 InputStream (java.io.InputStream)80 IQueryAtomContainer (org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer)61 QueryAtomContainer (org.openscience.cdk.isomorphism.matchers.QueryAtomContainer)57 MDLV2000Reader (org.openscience.cdk.io.MDLV2000Reader)44 SimpleChemObjectReaderTest (org.openscience.cdk.test.io.SimpleChemObjectReaderTest)43 ByteArrayInputStream (java.io.ByteArrayInputStream)41 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)32 SlowTest (org.openscience.cdk.test.SlowTest)32 Point3d (javax.vecmath.Point3d)30 IPseudoAtom (org.openscience.cdk.interfaces.IPseudoAtom)29 DoubleArrayResult (org.openscience.cdk.qsar.result.DoubleArrayResult)23