Search in sources :

Example 1 with LonePair

use of org.openscience.cdk.LonePair in project cdk by cdk.

the class RearrangementAnionReactionTest method getExpectedProducts.

/**
 * Get the expected set of molecules.
 *
 * @return The IAtomContainerSet
 */
private IAtomContainerSet getExpectedProducts() {
    IAtomContainerSet setOfProducts = builder.newInstance(IAtomContainerSet.class);
    IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.addBond(0, 1, IBond.Order.DOUBLE);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.getAtom(2).setFormalCharge(-1);
    molecule.addLonePair(new LonePair(molecule.getAtom(2)));
    molecule.addBond(1, 2, IBond.Order.SINGLE);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.addBond(2, 3, IBond.Order.SINGLE);
    try {
        addExplicitHydrogens(molecule);
    } catch (Exception e) {
        LoggingToolFactory.createLoggingTool(getClass()).error("Unexpected Error:", e);
    }
    setOfProducts.addAtomContainer(molecule);
    return setOfProducts;
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) LonePair(org.openscience.cdk.LonePair) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IAtom(org.openscience.cdk.interfaces.IAtom) CDKException(org.openscience.cdk.exception.CDKException)

Example 2 with LonePair

use of org.openscience.cdk.LonePair in project cdk by cdk.

the class RearrangementLonePairReactionTest method testMapping.

/**
 * A unit test suite for JUnit.
 */
@Test
public void testMapping() throws Exception {
    IReactionProcess type = new RearrangementLonePairReaction();
    IAtomContainerSet setOfReactants = getExampleReactants();
    IAtomContainer molecule = setOfReactants.getAtomContainer(0);
    molecule.addLonePair(new LonePair(molecule.getAtom(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(10, setOfReactions.getReaction(0).getMappingCount());
    IAtom mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(0));
    Assert.assertEquals(mappedProductA1, product.getAtom(0));
    mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(1));
    Assert.assertEquals(mappedProductA1, product.getAtom(1));
    mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(2));
    Assert.assertEquals(mappedProductA1, product.getAtom(2));
}
Also used : IReactionProcess(org.openscience.cdk.reaction.IReactionProcess) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) LonePair(org.openscience.cdk.LonePair) 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 3 with LonePair

use of org.openscience.cdk.LonePair in project cdk by cdk.

the class RearrangementAnionReactionTest method testAutomaticSearchCentreActiveExample3.

/**
 * A unit test suite for JUnit. Reaction: [F+]=C1-[C-]-C=C-C=C1 => [F+]=C1-[C=]-C-[C-]-C=C1
 * Automatic search of the center active.
 */
@Test
public void testAutomaticSearchCentreActiveExample3() throws Exception {
    IReactionProcess type = new RearrangementAnionReaction();
    /* [F+]=C1-[C-]-C=C-C=C1 */
    IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
    molecule.addAtom(builder.newInstance(IAtom.class, "F"));
    molecule.getAtom(0).setFormalCharge(1);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.addBond(0, 1, IBond.Order.DOUBLE);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.getAtom(2).setFormalCharge(-1);
    molecule.addLonePair(new LonePair(molecule.getAtom(2)));
    molecule.addBond(1, 2, IBond.Order.SINGLE);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.addBond(2, 3, IBond.Order.SINGLE);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.addBond(3, 4, IBond.Order.DOUBLE);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.addBond(4, 5, IBond.Order.SINGLE);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.addBond(5, 6, IBond.Order.DOUBLE);
    molecule.addBond(6, 1, IBond.Order.SINGLE);
    addExplicitHydrogens(molecule);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
    lpcheck.saturate(molecule);
    IAtomContainerSet setOfReactants = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
    setOfReactants.addAtomContainer(molecule);
    /* initiate */
    makeSureAtomTypesAreRecognized(molecule);
    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(2, setOfReactions.getReactionCount());
    Assert.assertEquals(1, setOfReactions.getReaction(0).getProductCount());
    IAtomContainer product1 = setOfReactions.getReaction(1).getProducts().getAtomContainer(0);
    /* [F+]=C1-[C=]-C-[C-]-C=C1 */
    IAtomContainer molecule2 = builder.newInstance(IAtomContainer.class);
    molecule2.addAtom(builder.newInstance(IAtom.class, "F"));
    molecule2.getAtom(0).setFormalCharge(1);
    molecule2.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule2.addBond(0, 1, IBond.Order.DOUBLE);
    molecule2.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule2.addBond(1, 2, IBond.Order.SINGLE);
    molecule2.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule2.addBond(2, 3, IBond.Order.DOUBLE);
    molecule2.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule2.getAtom(4).setFormalCharge(-1);
    molecule2.addBond(3, 4, IBond.Order.SINGLE);
    molecule2.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule2.addBond(4, 5, IBond.Order.SINGLE);
    molecule2.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule2.addBond(5, 6, IBond.Order.DOUBLE);
    molecule2.addBond(6, 1, IBond.Order.SINGLE);
    addExplicitHydrogens(molecule2);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule2);
    lpcheck.saturate(molecule2);
    makeSureAtomTypesAreRecognized(molecule2);
    assertEquals(molecule2, product1);
    // ////////////////////////////////////////////////
    IAtomContainer product2 = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
    /* F=c1ccccc1 */
    IAtomContainer molecule3 = builder.newInstance(IAtomContainer.class);
    molecule3.addAtom(builder.newInstance(IAtom.class, "F"));
    molecule3.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule3.addBond(0, 1, IBond.Order.SINGLE);
    molecule3.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule3.addBond(1, 2, IBond.Order.DOUBLE);
    molecule3.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule3.addBond(2, 3, IBond.Order.SINGLE);
    molecule3.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule3.addBond(3, 4, IBond.Order.DOUBLE);
    molecule3.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule3.addBond(4, 5, IBond.Order.SINGLE);
    molecule3.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule3.addBond(5, 6, IBond.Order.DOUBLE);
    molecule3.addBond(6, 1, IBond.Order.SINGLE);
    addExplicitHydrogens(molecule3);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule3);
    lpcheck.saturate(molecule3);
    makeSureAtomTypesAreRecognized(molecule3);
    assertEquals(molecule3, product2);
    Assert.assertEquals(12, setOfReactions.getReaction(0).getMappingCount());
}
Also used : IReactionProcess(org.openscience.cdk.reaction.IReactionProcess) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) LonePair(org.openscience.cdk.LonePair) 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 4 with LonePair

use of org.openscience.cdk.LonePair in project cdk by cdk.

the class RearrangementLonePairReactionTest method getExpectedProducts.

/**
 * Get the expected set of molecules.
 *
 * @return The IAtomContainerSet
 */
private IAtomContainerSet getExpectedProducts() {
    IAtomContainerSet setOfProducts = builder.newInstance(IAtomContainerSet.class);
    // [O+]=C-[C-]-C
    IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
    molecule.addAtom(builder.newInstance(IAtom.class, "O"));
    molecule.getAtom(0).setFormalCharge(+1);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.addBond(0, 1, IBond.Order.DOUBLE);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.getAtom(2).setFormalCharge(-1);
    molecule.addLonePair(new LonePair(molecule.getAtom(2)));
    molecule.addBond(1, 2, IBond.Order.SINGLE);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.addBond(2, 3, IBond.Order.SINGLE);
    try {
        addExplicitHydrogens(molecule);
        AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
        lpcheck.saturate(molecule);
    } catch (Exception e) {
        LoggingToolFactory.createLoggingTool(getClass()).error("Unexpected Error:", e);
    }
    setOfProducts.addAtomContainer(molecule);
    return setOfProducts;
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) LonePair(org.openscience.cdk.LonePair) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IAtom(org.openscience.cdk.interfaces.IAtom) CDKException(org.openscience.cdk.exception.CDKException)

Example 5 with LonePair

use of org.openscience.cdk.LonePair in project cdk by cdk.

the class RearrangementLonePairReactionTest method getExampleReactants.

/**
 * get the molecule 1: O-C=C-C
 *
 * @cdk.inchi  InChI=1/C3H6O/c1-2-3-4/h2-4H,1H3
 *
 * @return The IAtomContainerSet
 */
private IAtomContainerSet getExampleReactants() {
    IAtomContainerSet setOfReactants = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
    IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
    molecule.addAtom(builder.newInstance(IAtom.class, "O"));
    molecule.addLonePair(new LonePair(molecule.getAtom(0)));
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.addBond(0, 1, IBond.Order.SINGLE);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.addBond(1, 2, IBond.Order.DOUBLE);
    molecule.addAtom(builder.newInstance(IAtom.class, "C"));
    molecule.addBond(2, 3, IBond.Order.SINGLE);
    try {
        addExplicitHydrogens(molecule);
        AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
        lpcheck.saturate(molecule);
    } catch (Exception e) {
        LoggingToolFactory.createLoggingTool(getClass()).error("Unexpected Error:", e);
    }
    setOfReactants.addAtomContainer(molecule);
    return setOfReactants;
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) LonePair(org.openscience.cdk.LonePair) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IAtom(org.openscience.cdk.interfaces.IAtom) CDKException(org.openscience.cdk.exception.CDKException)

Aggregations

LonePair (org.openscience.cdk.LonePair)11 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)11 IAtom (org.openscience.cdk.interfaces.IAtom)9 IAtomContainerSet (org.openscience.cdk.interfaces.IAtomContainerSet)9 Test (org.junit.Test)6 CDKException (org.openscience.cdk.exception.CDKException)4 ArrayList (java.util.ArrayList)3 IReactionSet (org.openscience.cdk.interfaces.IReactionSet)3 IReactionProcess (org.openscience.cdk.reaction.IReactionProcess)3 ReactionProcessTest (org.openscience.cdk.reaction.ReactionProcessTest)3 IParameterReact (org.openscience.cdk.reaction.type.parameters.IParameterReact)3 SetReactionCenter (org.openscience.cdk.reaction.type.parameters.SetReactionCenter)3 Atom (org.openscience.cdk.Atom)2 AtomContainer (org.openscience.cdk.AtomContainer)2 Bond (org.openscience.cdk.Bond)2 IBond (org.openscience.cdk.interfaces.IBond)2 UniversalIsomorphismTester (org.openscience.cdk.isomorphism.UniversalIsomorphismTester)1 QueryAtomContainer (org.openscience.cdk.isomorphism.matchers.QueryAtomContainer)1 SlowTest (org.openscience.cdk.test.SlowTest)1