Search in sources :

Example 1 with SetReactionCenter

use of org.openscience.cdk.reaction.type.parameters.SetReactionCenter 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 2 with SetReactionCenter

use of org.openscience.cdk.reaction.type.parameters.SetReactionCenter 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)

Example 3 with SetReactionCenter

use of org.openscience.cdk.reaction.type.parameters.SetReactionCenter in project cdk by cdk.

the class RadicalSiteRrDeltaReactionTest 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 RadicalSiteRrDeltaReaction();
    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(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);
    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 4 with SetReactionCenter

use of org.openscience.cdk.reaction.type.parameters.SetReactionCenter in project cdk by cdk.

the class RadicalSiteRrGammaReactionTest method testMapping.

/**
 * A unit test suite for JUnit.
 */
@Test
public void testMapping() throws Exception {
    IReactionProcess type = new RadicalSiteRrGammaReaction();
    IAtomContainerSet setOfReactants = getExampleReactants();
    IAtomContainer molecule = setOfReactants.getAtomContainer(0);
    /* automatic search of the center active */
    molecule.getAtom(0).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getAtom(5).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);
    IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
    Assert.assertEquals(22, setOfReactions.getReaction(0).getMappingCount());
    IAtom mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(0));
    Assert.assertEquals(mappedProductA1, product.getAtom(0));
    IAtom mappedProductA2 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(1));
    Assert.assertEquals(mappedProductA2, product.getAtom(1));
    IAtom mappedProductA3 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(5));
    Assert.assertEquals(mappedProductA3, product.getAtom(5));
}
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) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test) ReactionProcessTest(org.openscience.cdk.reaction.ReactionProcessTest)

Example 5 with SetReactionCenter

use of org.openscience.cdk.reaction.type.parameters.SetReactionCenter in project cdk by cdk.

the class RadicalSiteRrGammaReactionTest 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 RadicalSiteRrGammaReaction();
    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(5).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)

Aggregations

IParameterReact (org.openscience.cdk.reaction.type.parameters.IParameterReact)164 SetReactionCenter (org.openscience.cdk.reaction.type.parameters.SetReactionCenter)164 ArrayList (java.util.ArrayList)163 IReactionProcess (org.openscience.cdk.reaction.IReactionProcess)163 Test (org.junit.Test)160 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)160 IAtomContainerSet (org.openscience.cdk.interfaces.IAtomContainerSet)160 IReactionSet (org.openscience.cdk.interfaces.IReactionSet)159 ReactionProcessTest (org.openscience.cdk.reaction.ReactionProcessTest)157 IAtom (org.openscience.cdk.interfaces.IAtom)86 IQueryAtomContainer (org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer)45 UniversalIsomorphismTester (org.openscience.cdk.isomorphism.UniversalIsomorphismTester)30 QueryAtomContainer (org.openscience.cdk.isomorphism.matchers.QueryAtomContainer)29 ISingleElectron (org.openscience.cdk.interfaces.ISingleElectron)17 LonePair (org.openscience.cdk.LonePair)3 CDKException (org.openscience.cdk.exception.CDKException)2 IBond (org.openscience.cdk.interfaces.IBond)2 PiBondingMovementReaction (org.openscience.cdk.reaction.type.PiBondingMovementReaction)2 RearrangementAnionReaction (org.openscience.cdk.reaction.type.RearrangementAnionReaction)2 RearrangementCationReaction (org.openscience.cdk.reaction.type.RearrangementCationReaction)2