Search in sources :

Example 1 with IReactionSet

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

the class IDCreator method createIDsForChemModel.

private static void createIDsForChemModel(IChemModel model, List<String> tabuList) {
    if (tabuList == null)
        tabuList = ChemModelManipulator.getAllIDs(model);
    if (null == model.getID()) {
        chemModelCount = setID(CHEMMODEL_PREFIX, chemModelCount, model, tabuList);
    }
    ICrystal crystal = model.getCrystal();
    if (crystal != null) {
        if (policy == OBJECT_UNIQUE_POLICY) {
            atomCount = 0;
            bondCount = 0;
        }
        createIDsForAtomContainer(crystal, tabuList);
    }
    IAtomContainerSet moleculeSet = model.getMoleculeSet();
    if (moleculeSet != null) {
        if (policy == OBJECT_UNIQUE_POLICY) {
            atomContainerSetCount = 0;
            atomContainerCount = 0;
        }
        createIDsForAtomContainerSet(moleculeSet, tabuList);
    }
    IReactionSet reactionSet = model.getReactionSet();
    if (reactionSet != null) {
        if (policy == OBJECT_UNIQUE_POLICY) {
            reactionSetCount = 0;
            reactionCount = 0;
        }
        createIDsForReactionSet(reactionSet, tabuList);
    }
}
Also used : ICrystal(org.openscience.cdk.interfaces.ICrystal) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet)

Example 2 with IReactionSet

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

the class ReactionSetTest method testReactionSet.

@Test
public void testReactionSet() {
    IReactionSet reactionSet = new ReactionSet();
    Assert.assertNotNull(reactionSet);
}
Also used : IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) AbstractReactionSetTest(org.openscience.cdk.test.interfaces.AbstractReactionSetTest) Test(org.junit.Test)

Example 3 with IReactionSet

use of org.openscience.cdk.interfaces.IReactionSet 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 4 with IReactionSet

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

the class RadicalSiteRrBetaReactionTest method testInitiate_IAtomContainerSet_IAtomContainerSet.

/**
 * A unit test suite for JUnit. Reaction:
 * Manually put of the center active.
 */
@Test
@Override
public void testInitiate_IAtomContainerSet_IAtomContainerSet() throws Exception {
    IReactionProcess type = new RadicalSiteRrBetaReaction();
    IAtomContainerSet setOfReactants = getExampleReactants();
    IAtomContainer molecule = setOfReactants.getAtomContainer(0);
    /* initiate */
    molecule.getAtom(0).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getAtom(4).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getBond(0).setFlag(CDKConstants.REACTIVE_CENTER, true);
    List<IParameterReact> paramList = new ArrayList<>();
    IParameterReact param = new SetReactionCenter();
    param.setParameter(Boolean.TRUE);
    paramList.add(param);
    type.setParameterList(paramList);
    IReactionSet setOfReactions = type.initiate(setOfReactants, null);
    Assert.assertEquals(1, setOfReactions.getReactionCount());
    Assert.assertEquals(1, setOfReactions.getReaction(0).getProductCount());
    IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
    IAtomContainer molecule2 = getExpectedProducts().getAtomContainer(0);
    assertEquals(molecule2, product);
}
Also used : IReactionProcess(org.openscience.cdk.reaction.IReactionProcess) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IParameterReact(org.openscience.cdk.reaction.type.parameters.IParameterReact) ArrayList(java.util.ArrayList) SetReactionCenter(org.openscience.cdk.reaction.type.parameters.SetReactionCenter) Test(org.junit.Test) ReactionProcessTest(org.openscience.cdk.reaction.ReactionProcessTest)

Example 5 with IReactionSet

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

the class RadicalSiteRrDeltaReactionTest method testCDKConstants_REACTIVE_CENTER.

/**
 * A unit test suite for JUnit.
 */
@Test
public void testCDKConstants_REACTIVE_CENTER() throws Exception {
    IReactionProcess type = new RadicalSiteRrDeltaReaction();
    IAtomContainerSet setOfReactants = getExampleReactants();
    IAtomContainer molecule = setOfReactants.getAtomContainer(0);
    /* manually put the reactive center */
    molecule.getAtom(0).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getAtom(6).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getBond(0).setFlag(CDKConstants.REACTIVE_CENTER, true);
    List<IParameterReact> paramList = new ArrayList<>();
    IParameterReact param = new SetReactionCenter();
    param.setParameter(Boolean.TRUE);
    paramList.add(param);
    type.setParameterList(paramList);
    /* initiate */
    IReactionSet setOfReactions = type.initiate(setOfReactants, null);
    Assert.assertEquals(1, setOfReactions.getReactionCount());
    IAtomContainer reactant = setOfReactions.getReaction(0).getReactants().getAtomContainer(0);
    Assert.assertTrue(molecule.getAtom(0).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getAtom(0).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(molecule.getAtom(1).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getAtom(1).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(molecule.getAtom(6).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getAtom(6).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(molecule.getBond(0).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getBond(0).getFlag(CDKConstants.REACTIVE_CENTER));
}
Also used : IReactionProcess(org.openscience.cdk.reaction.IReactionProcess) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IParameterReact(org.openscience.cdk.reaction.type.parameters.IParameterReact) ArrayList(java.util.ArrayList) SetReactionCenter(org.openscience.cdk.reaction.type.parameters.SetReactionCenter) Test(org.junit.Test) ReactionProcessTest(org.openscience.cdk.reaction.ReactionProcessTest)

Aggregations

IReactionSet (org.openscience.cdk.interfaces.IReactionSet)270 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)222 IAtomContainerSet (org.openscience.cdk.interfaces.IAtomContainerSet)217 Test (org.junit.Test)208 ArrayList (java.util.ArrayList)195 IParameterReact (org.openscience.cdk.reaction.type.parameters.IParameterReact)192 IReactionProcess (org.openscience.cdk.reaction.IReactionProcess)162 ReactionProcessTest (org.openscience.cdk.reaction.ReactionProcessTest)159 SetReactionCenter (org.openscience.cdk.reaction.type.parameters.SetReactionCenter)159 IAtom (org.openscience.cdk.interfaces.IAtom)132 IReaction (org.openscience.cdk.interfaces.IReaction)84 IQueryAtomContainer (org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer)45 CDKException (org.openscience.cdk.exception.CDKException)37 IBond (org.openscience.cdk.interfaces.IBond)37 UniversalIsomorphismTester (org.openscience.cdk.isomorphism.UniversalIsomorphismTester)29 QueryAtomContainer (org.openscience.cdk.isomorphism.matchers.QueryAtomContainer)28 ISingleElectron (org.openscience.cdk.interfaces.ISingleElectron)17 IChemModel (org.openscience.cdk.interfaces.IChemModel)15 ICrystal (org.openscience.cdk.interfaces.ICrystal)11 IRingSet (org.openscience.cdk.interfaces.IRingSet)10