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;
}
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));
}
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());
}
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;
}
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;
}
Aggregations