Search in sources :

Example 1 with IReaction

use of org.openscience.cdk.interfaces.IReaction in project cdk by cdk.

the class ReactionTest method testReaction.

@Test
public void testReaction() {
    IReaction reaction = new Reaction();
    Assert.assertNotNull(reaction);
    Assert.assertEquals(0, reaction.getReactantCount());
    Assert.assertEquals(0, reaction.getProductCount());
    Assert.assertEquals(IReaction.Direction.FORWARD, reaction.getDirection());
}
Also used : IReaction(org.openscience.cdk.interfaces.IReaction) IReaction(org.openscience.cdk.interfaces.IReaction) AbstractReactionTest(org.openscience.cdk.test.interfaces.AbstractReactionTest) Test(org.junit.Test)

Example 2 with IReaction

use of org.openscience.cdk.interfaces.IReaction in project cdk by cdk.

the class ChemModelTest method testChemModel.

@Test
public void testChemModel() {
    IChemModel chemModel = new ChemModel();
    Assert.assertNotNull(chemModel);
    Assert.assertTrue(chemModel.isEmpty());
    IAtom atom = new Atom("N");
    IAtomContainer mol = new AtomContainer();
    IAtomContainerSet mset = new AtomContainerSet();
    mol.addAtom(atom);
    mset.addAtomContainer(mol);
    chemModel.setMoleculeSet(mset);
    Assert.assertFalse(chemModel.isEmpty());
    mol.removeAtomOnly(atom);
    Assert.assertFalse(chemModel.isEmpty());
    chemModel.setMoleculeSet(null);
    Assert.assertTrue(chemModel.isEmpty());
    IChemModel model1 = new ChemModel();
    mol.addAtom(atom);
    IReaction react = new Reaction();
    react.addReactant(mol);
    IReactionSet rset = new ReactionSet();
    rset.addReaction(react);
    model1.setReactionSet(rset);
    Assert.assertFalse(model1.isEmpty());
    mol.removeAtomOnly(atom);
    Assert.assertFalse(model1.isEmpty());
    model1.setReactionSet(null);
    Assert.assertTrue(model1.isEmpty());
    IChemModel model2 = new ChemModel();
    mol.addAtom(atom);
    IRingSet ringset = new RingSet();
    ringset.add(mset);
    model2.setRingSet(ringset);
    Assert.assertFalse(model2.isEmpty());
    mol.removeAtomOnly(atom);
    Assert.assertFalse(model2.isEmpty());
    model2.setRingSet(null);
    Assert.assertTrue(model2.isEmpty());
    IChemModel model3 = new ChemModel();
    mol.addAtom(atom);
    ICrystal cry = new Crystal(mol);
    model3.setCrystal(cry);
    Assert.assertFalse(model3.isEmpty());
    mol.removeAtomOnly(atom);
    Assert.assertFalse(model3.isEmpty());
    model3.setCrystal(null);
    Assert.assertTrue(model3.isEmpty());
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IChemModel(org.openscience.cdk.interfaces.IChemModel) IReaction(org.openscience.cdk.interfaces.IReaction) IAtom(org.openscience.cdk.interfaces.IAtom) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) ICrystal(org.openscience.cdk.interfaces.ICrystal) IChemModel(org.openscience.cdk.interfaces.IChemModel) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IRingSet(org.openscience.cdk.interfaces.IRingSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IRingSet(org.openscience.cdk.interfaces.IRingSet) IReaction(org.openscience.cdk.interfaces.IReaction) IAtom(org.openscience.cdk.interfaces.IAtom) ICrystal(org.openscience.cdk.interfaces.ICrystal) AbstractChemModelTest(org.openscience.cdk.test.interfaces.AbstractChemModelTest) Test(org.junit.Test)

Example 3 with IReaction

use of org.openscience.cdk.interfaces.IReaction in project cdk by cdk.

the class DebugReactionTest method testDebugReaction.

@Test
public void testDebugReaction() {
    IReaction polymer = new DebugReaction();
    Assert.assertTrue(polymer instanceof DebugReaction);
}
Also used : IReaction(org.openscience.cdk.interfaces.IReaction) AbstractReactionTest(org.openscience.cdk.test.interfaces.AbstractReactionTest) Test(org.junit.Test)

Example 4 with IReaction

use of org.openscience.cdk.interfaces.IReaction in project cdk by cdk.

the class ReactionScheme method clone.

/**
 * Clones this ReactionScheme object and its content.
 *
 * @return    The cloned object
 */
@Override
public Object clone() throws CloneNotSupportedException {
    IReactionScheme clone = new ReactionScheme();
    for (IReactionScheme scheme : this.reactionSchemes()) {
        clone.add((IReactionScheme) scheme.clone());
    }
    for (IReaction reaction : reactions()) {
        clone.addReaction((IReaction) reaction.clone());
    }
    // clone the properties
    if (getProperties() != null) {
        Map<Object, Object> properties = getProperties();
        Map<Object, Object> clonedHashtable = new HashMap<>();
        for (Object key : properties.keySet()) {
            Object value = properties.get(key);
            clonedHashtable.put(key, value);
        }
        clone.addProperties(clonedHashtable);
    }
    return clone;
}
Also used : IReactionScheme(org.openscience.cdk.interfaces.IReactionScheme) HashMap(java.util.HashMap) IReactionScheme(org.openscience.cdk.interfaces.IReactionScheme) IReaction(org.openscience.cdk.interfaces.IReaction)

Example 5 with IReaction

use of org.openscience.cdk.interfaces.IReaction in project cdk by cdk.

the class ReactionSet method toString.

@Override
public String toString() {
    StringBuilder buffer = new StringBuilder(32);
    buffer.append("ReactionSet(");
    buffer.append(this.hashCode());
    buffer.append(", R=").append(getReactionCount()).append(", ");
    for (IReaction reaction : reactions()) {
        buffer.append(reaction.toString());
    }
    buffer.append(')');
    return buffer.toString();
}
Also used : IReaction(org.openscience.cdk.interfaces.IReaction)

Aggregations

IReaction (org.openscience.cdk.interfaces.IReaction)228 Test (org.junit.Test)152 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)138 IAtom (org.openscience.cdk.interfaces.IAtom)83 IReactionSet (org.openscience.cdk.interfaces.IReactionSet)72 IAtomContainerSet (org.openscience.cdk.interfaces.IAtomContainerSet)58 CDKException (org.openscience.cdk.exception.CDKException)51 IBond (org.openscience.cdk.interfaces.IBond)48 ArrayList (java.util.ArrayList)39 IParameterReact (org.openscience.cdk.reaction.type.parameters.IParameterReact)33 IMapping (org.openscience.cdk.interfaces.IMapping)23 Reaction (org.openscience.cdk.Reaction)21 IChemModel (org.openscience.cdk.interfaces.IChemModel)19 IReactionScheme (org.openscience.cdk.interfaces.IReactionScheme)19 InputStream (java.io.InputStream)18 IChemFile (org.openscience.cdk.interfaces.IChemFile)15 IChemSequence (org.openscience.cdk.interfaces.IChemSequence)13 Atom (org.openscience.cdk.Atom)11 AtomContainer (org.openscience.cdk.AtomContainer)11 CDKAtomTypeMatcher (org.openscience.cdk.atomtype.CDKAtomTypeMatcher)11