Search in sources :

Example 21 with IReactionSet

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

the class HyperconjugationReactionTest method testWithNegativeCharge.

/**
 * A unit test suite for JUnit. Reaction: [C-][C+]-C => [C-]C=C + [H+]
 * Automatic search for the active center.
 */
@Test
public void testWithNegativeCharge() throws Exception {
    IReactionProcess type = new HyperconjugationReaction();
    IAtomContainerSet setOfReactants = getExampleReactants();
    /* automatic search of the center active */
    List<IParameterReact> paramList = new ArrayList<>();
    IParameterReact param = new SetReactionCenter();
    param.setParameter(Boolean.FALSE);
    paramList.add(param);
    type.setParameterList(paramList);
    /* initiate */
    IReactionSet setOfReactions = type.initiate(setOfReactants, null);
    Assert.assertEquals(3, setOfReactions.getReactionCount());
    Assert.assertEquals(2, setOfReactions.getReaction(0).getProductCount());
    IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
    IAtomContainer molecule2 = getExpectedProducts().getAtomContainer(0);
    IQueryAtomContainer queryAtom = QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(molecule2);
    Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(product, queryAtom));
    product = setOfReactions.getReaction(0).getProducts().getAtomContainer(1);
    molecule2 = builder.newInstance(IAtomContainer.class);
    molecule2.addAtom(builder.newInstance(IAtom.class, "H"));
    molecule2.getAtom(0).setFormalCharge(1);
    queryAtom = QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(product);
    Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(molecule2, queryAtom));
}
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) UniversalIsomorphismTester(org.openscience.cdk.isomorphism.UniversalIsomorphismTester) SetReactionCenter(org.openscience.cdk.reaction.type.parameters.SetReactionCenter) IQueryAtomContainer(org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test) ReactionProcessTest(org.openscience.cdk.reaction.ReactionProcessTest)

Example 22 with IReactionSet

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

the class PiBondingMovementReactionTest method testDoubleRingConjugated2.

/**
 * A unit test suite for JUnit with 2-methylnaphthalene.
 * Reaction: C1=CC(=CC2=C1C=CC=C2)C
 * -> C1=CC(=CC2=CC=CC=C12)C + {NO => C1=C2C(=CC(=C1)C)C=CC=C2}
 *
 * restricted the reaction center.
 *
 * InChI=1/C11H10/c1-9-6-7-10-4-2-3-5-11(10)8-9/h2-8H,1H3
 */
@Test
public void testDoubleRingConjugated2() throws Exception {
    IReactionProcess type = new PiBondingMovementReaction();
    // C1=CC(=CC2=C1C=CC=C2)C
    IAtomContainerSet setOfReactants = getExampleReactants();
    IAtomContainer molecule = setOfReactants.getAtomContainer(0);
    /* manually putting the reaction center */
    molecule.getBond(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getBond(2).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getBond(3).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getBond(9).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getBond(10).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getBond(11).setFlag(CDKConstants.REACTIVE_CENTER, true);
    /* initiate */
    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 product2 = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
    IAtomContainer molecule2 = getExpectedProducts().getAtomContainer(0);
    IQueryAtomContainer queryAtom = QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(product2);
    Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(molecule2, queryAtom));
}
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) UniversalIsomorphismTester(org.openscience.cdk.isomorphism.UniversalIsomorphismTester) SetReactionCenter(org.openscience.cdk.reaction.type.parameters.SetReactionCenter) IQueryAtomContainer(org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer) Test(org.junit.Test) ReactionProcessTest(org.openscience.cdk.reaction.ReactionProcessTest)

Example 23 with IReactionSet

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

the class RadicalSiteHrBetaReactionTest method testInitiate_IAtomContainerSet_IAtomContainerSet.

/**
 * A unit test suite for JUnit. Reaction:
 */
@Test
@Override
public void testInitiate_IAtomContainerSet_IAtomContainerSet() throws Exception {
    IReactionProcess type = new RadicalSiteHrBetaReaction();
    IAtomContainerSet setOfReactants = getExampleReactants();
    /* initiate */
    List<IParameterReact> paramList = new ArrayList<>();
    IParameterReact param = new SetReactionCenter();
    param.setParameter(Boolean.FALSE);
    paramList.add(param);
    type.setParameterList(paramList);
    IReactionSet setOfReactions = type.initiate(setOfReactants, null);
    Assert.assertEquals(3, 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 24 with IReactionSet

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

the class RadicalSiteHrBetaReactionTest method testCDKConstants_REACTIVE_CENTER.

/**
 * A unit test suite for JUnit.
 */
@Test
public void testCDKConstants_REACTIVE_CENTER() throws Exception {
    IReactionProcess type = new RadicalSiteHrBetaReaction();
    IAtomContainerSet setOfReactants = getExampleReactants();
    IAtomContainer molecule = setOfReactants.getAtomContainer(0);
    /* manually put the reactive center */
    molecule.getAtom(3).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getAtom(0).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getAtom(6).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getBond(5).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 reactant = setOfReactions.getReaction(0).getReactants().getAtomContainer(0);
    Assert.assertTrue(molecule.getAtom(6).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getAtom(6).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(molecule.getAtom(0).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getAtom(0).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(molecule.getAtom(3).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getAtom(3).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(molecule.getBond(5).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getBond(5).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 25 with IReactionSet

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

the class RadicalSiteHrBetaReactionTest method testMapping.

/**
 * A unit test suite for JUnit.
 */
@Test
public void testMapping() throws Exception {
    IReactionProcess type = new RadicalSiteHrBetaReaction();
    IAtomContainerSet setOfReactants = getExampleReactants();
    IAtomContainer molecule = setOfReactants.getAtomContainer(0);
    /* automatic search of the center active */
    List<IParameterReact> paramList = new ArrayList<>();
    IParameterReact param = new SetReactionCenter();
    param.setParameter(Boolean.FALSE);
    paramList.add(param);
    type.setParameterList(paramList);
    /* initiate */
    IReactionSet setOfReactions = type.initiate(setOfReactants, null);
    IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
    Assert.assertEquals(19, 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(6));
    Assert.assertEquals(mappedProductA2, product.getAtom(6));
    IAtom mappedProductA3 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(3));
    Assert.assertEquals(mappedProductA3, product.getAtom(3));
}
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)

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