Search in sources :

Example 1 with RearrangementCationReaction

use of org.openscience.cdk.reaction.type.RearrangementCationReaction in project cdk by cdk.

the class StructureResonanceGeneratorTest method testSetDefaultReactions.

/**
 * A unit test suite for JUnit.
 */
@Test
public void testSetDefaultReactions() {
    StructureResonanceGenerator sRG = new StructureResonanceGenerator();
    List<IReactionProcess> reactionList = sRG.getReactions();
    Assert.assertNotNull(reactionList);
    Assert.assertEquals(6, reactionList.size());
    SharingLonePairReaction slReaction = (SharingLonePairReaction) reactionList.get(0);
    Assert.assertEquals(1, slReaction.getParameterList().size());
    List<IParameterReact> objects = slReaction.getParameterList();
    for (IParameterReact object : objects) {
        if (object instanceof SetReactionCenter)
            Assert.assertFalse(object.isSetParameter());
    }
    PiBondingMovementReaction pBReaction = (PiBondingMovementReaction) reactionList.get(1);
    Assert.assertEquals(1, pBReaction.getParameterList().size());
    objects = pBReaction.getParameterList();
    for (IParameterReact object : objects) {
        if (object instanceof SetReactionCenter)
            Assert.assertFalse(object.isSetParameter());
    }
    RearrangementAnionReaction raReaction = (RearrangementAnionReaction) reactionList.get(2);
    Assert.assertEquals(1, raReaction.getParameterList().size());
    objects = raReaction.getParameterList();
    for (IParameterReact object : objects) {
        if (object instanceof SetReactionCenter)
            Assert.assertFalse(object.isSetParameter());
    }
    RearrangementCationReaction rcReaction = (RearrangementCationReaction) reactionList.get(3);
    Assert.assertEquals(1, rcReaction.getParameterList().size());
    objects = rcReaction.getParameterList();
    for (IParameterReact object : objects) {
        if (object instanceof SetReactionCenter)
            Assert.assertFalse(object.isSetParameter());
    }
    RearrangementLonePairReaction lnReaction = (RearrangementLonePairReaction) reactionList.get(4);
    Assert.assertEquals(1, lnReaction.getParameterList().size());
    objects = lnReaction.getParameterList();
    for (IParameterReact object : objects) {
        if (object instanceof SetReactionCenter)
            Assert.assertFalse(object.isSetParameter());
    }
    RearrangementRadicalReaction rrReaction = (RearrangementRadicalReaction) reactionList.get(5);
    Assert.assertEquals(1, rrReaction.getParameterList().size());
    objects = rrReaction.getParameterList();
    for (IParameterReact object : objects) {
        if (object instanceof SetReactionCenter)
            Assert.assertFalse(object.isSetParameter());
    }
}
Also used : IReactionProcess(org.openscience.cdk.reaction.IReactionProcess) PiBondingMovementReaction(org.openscience.cdk.reaction.type.PiBondingMovementReaction) RearrangementCationReaction(org.openscience.cdk.reaction.type.RearrangementCationReaction) SharingLonePairReaction(org.openscience.cdk.reaction.type.SharingLonePairReaction) IParameterReact(org.openscience.cdk.reaction.type.parameters.IParameterReact) SetReactionCenter(org.openscience.cdk.reaction.type.parameters.SetReactionCenter) RearrangementLonePairReaction(org.openscience.cdk.reaction.type.RearrangementLonePairReaction) RearrangementRadicalReaction(org.openscience.cdk.reaction.type.RearrangementRadicalReaction) RearrangementAnionReaction(org.openscience.cdk.reaction.type.RearrangementAnionReaction) SlowTest(org.openscience.cdk.test.SlowTest) Test(org.junit.Test)

Example 2 with RearrangementCationReaction

use of org.openscience.cdk.reaction.type.RearrangementCationReaction in project cdk by cdk.

the class StructureResonanceGenerator method callDefaultReactions.

private void callDefaultReactions() {
    List<IParameterReact> paramList = new ArrayList<>();
    IParameterReact param = new SetReactionCenter();
    param.setParameter(Boolean.FALSE);
    paramList.add(param);
    IReactionProcess type = new SharingLonePairReaction();
    try {
        type.setParameterList(paramList);
    } catch (CDKException e) {
        LoggingToolFactory.createLoggingTool(StructureResonanceGenerator.class).warn("Unexpected Error:", e);
    }
    reactionsList.add(type);
    type = new PiBondingMovementReaction();
    List<IParameterReact> paramList2 = new ArrayList<>();
    IParameterReact param2 = new SetReactionCenter();
    param2.setParameter(Boolean.FALSE);
    paramList2.add(param2);
    try {
        type.setParameterList(paramList2);
    } catch (CDKException e) {
        LoggingToolFactory.createLoggingTool(StructureResonanceGenerator.class).warn("Unexpected Error:", e);
    }
    reactionsList.add(type);
    type = new RearrangementAnionReaction();
    try {
        type.setParameterList(paramList);
    } catch (CDKException e) {
        LoggingToolFactory.createLoggingTool(StructureResonanceGenerator.class).warn("Unexpected Error:", e);
    }
    reactionsList.add(type);
    type = new RearrangementCationReaction();
    try {
        type.setParameterList(paramList);
    } catch (CDKException e) {
        LoggingToolFactory.createLoggingTool(StructureResonanceGenerator.class).warn("Unexpected Error:", e);
    }
    reactionsList.add(type);
    type = new RearrangementLonePairReaction();
    try {
        type.setParameterList(paramList);
    } catch (CDKException e) {
        LoggingToolFactory.createLoggingTool(StructureResonanceGenerator.class).warn("Unexpected Error:", e);
    }
    reactionsList.add(type);
    type = new RearrangementRadicalReaction();
    try {
        type.setParameterList(paramList);
    } catch (CDKException e) {
        LoggingToolFactory.createLoggingTool(StructureResonanceGenerator.class).warn("Unexpected Error:", e);
    }
    reactionsList.add(type);
}
Also used : IReactionProcess(org.openscience.cdk.reaction.IReactionProcess) PiBondingMovementReaction(org.openscience.cdk.reaction.type.PiBondingMovementReaction) RearrangementCationReaction(org.openscience.cdk.reaction.type.RearrangementCationReaction) CDKException(org.openscience.cdk.exception.CDKException) IParameterReact(org.openscience.cdk.reaction.type.parameters.IParameterReact) ArrayList(java.util.ArrayList) SharingLonePairReaction(org.openscience.cdk.reaction.type.SharingLonePairReaction) SetReactionCenter(org.openscience.cdk.reaction.type.parameters.SetReactionCenter) RearrangementLonePairReaction(org.openscience.cdk.reaction.type.RearrangementLonePairReaction) RearrangementRadicalReaction(org.openscience.cdk.reaction.type.RearrangementRadicalReaction) RearrangementAnionReaction(org.openscience.cdk.reaction.type.RearrangementAnionReaction)

Aggregations

IReactionProcess (org.openscience.cdk.reaction.IReactionProcess)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 RearrangementLonePairReaction (org.openscience.cdk.reaction.type.RearrangementLonePairReaction)2 RearrangementRadicalReaction (org.openscience.cdk.reaction.type.RearrangementRadicalReaction)2 SharingLonePairReaction (org.openscience.cdk.reaction.type.SharingLonePairReaction)2 IParameterReact (org.openscience.cdk.reaction.type.parameters.IParameterReact)2 SetReactionCenter (org.openscience.cdk.reaction.type.parameters.SetReactionCenter)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 CDKException (org.openscience.cdk.exception.CDKException)1 SlowTest (org.openscience.cdk.test.SlowTest)1