use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class SharingChargeDBReactionTest method testInitiate_IAtomContainerSet_IAtomContainerSet.
/**
* A unit test suite for JUnit. Reaction: C-C=[O+] => C-[C+]O|
* Automatic search of the center active.
*/
@Test
@Override
public void testInitiate_IAtomContainerSet_IAtomContainerSet() throws Exception {
IReactionProcess type = new SharingChargeDBReaction();
IAtomContainerSet setOfReactants = getExampleReactants();
IAtomContainer molecule = setOfReactants.getAtomContainer(0);
/* 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(1, setOfReactions.getReactionCount());
Assert.assertEquals(1, setOfReactions.getReaction(0).getProductCount());
IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
Assert.assertEquals(1, product.getAtom(1).getFormalCharge().intValue());
Assert.assertEquals(0, product.getConnectedLonePairsCount(product.getAtom(1)));
/* C[C+]O| */
IAtomContainer molecule2 = getExpectedProducts().getAtomContainer(0);
IQueryAtomContainer queryAtom = QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(product);
Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(molecule2, queryAtom));
}
use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class SharingChargeSBReactionTest method testNsp3ChargeSingleB.
/**
* A unit test suite for JUnit. Reaction:.
* C[N+]!-!C => CN + [C+]
*/
@Test
public void testNsp3ChargeSingleB() throws Exception {
// Smiles("C[N+]C")
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
molecule.addAtom(builder.newInstance(IAtom.class, "C"));
molecule.addAtom(builder.newInstance(IAtom.class, "N"));
molecule.getAtom(1).setFormalCharge(+1);
molecule.addAtom(builder.newInstance(IAtom.class, "C"));
molecule.addBond(0, 1, IBond.Order.SINGLE);
molecule.addBond(1, 2, IBond.Order.SINGLE);
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addBond(0, 3, IBond.Order.SINGLE);
molecule.addBond(0, 4, IBond.Order.SINGLE);
molecule.addBond(0, 5, IBond.Order.SINGLE);
molecule.addBond(1, 6, IBond.Order.SINGLE);
molecule.addBond(1, 7, IBond.Order.SINGLE);
molecule.addBond(2, 8, IBond.Order.SINGLE);
molecule.addBond(2, 9, IBond.Order.SINGLE);
molecule.addBond(2, 10, IBond.Order.SINGLE);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
lpcheck.saturate(molecule);
molecule.getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getAtom(2).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getBond(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
IAtomContainerSet setOfReactants = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
setOfReactants.addAtomContainer(molecule);
IReactionProcess type = new SharingChargeSBReaction();
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());
// expected products
// Smiles("CN")
IAtomContainer expected1 = builder.newInstance(IAtomContainer.class);
expected1.addAtom(builder.newInstance(IAtom.class, "C"));
expected1.addAtom(builder.newInstance(IAtom.class, "N"));
expected1.addBond(0, 1, IBond.Order.SINGLE);
expected1.addAtom(builder.newInstance(IAtom.class, "H"));
expected1.addAtom(builder.newInstance(IAtom.class, "H"));
expected1.addAtom(builder.newInstance(IAtom.class, "H"));
expected1.addAtom(builder.newInstance(IAtom.class, "H"));
expected1.addAtom(builder.newInstance(IAtom.class, "H"));
expected1.addBond(0, 2, IBond.Order.SINGLE);
expected1.addBond(0, 3, IBond.Order.SINGLE);
expected1.addBond(0, 4, IBond.Order.SINGLE);
expected1.addBond(1, 5, IBond.Order.SINGLE);
expected1.addBond(1, 6, IBond.Order.SINGLE);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(expected1);
lpcheck.saturate(expected1);
IAtomContainer product1 = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
QueryAtomContainer queryAtom = QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(expected1);
Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(product1, queryAtom));
// Smiles("[C+]")
IAtomContainer expected2 = builder.newInstance(IAtomContainer.class);
expected2.addAtom(builder.newInstance(IAtom.class, "C"));
expected2.getAtom(0).setFormalCharge(+1);
expected2.addAtom(builder.newInstance(IAtom.class, "H"));
expected2.addAtom(builder.newInstance(IAtom.class, "H"));
expected2.addAtom(builder.newInstance(IAtom.class, "H"));
expected2.addBond(0, 1, IBond.Order.SINGLE);
expected2.addBond(0, 2, IBond.Order.SINGLE);
expected2.addBond(0, 3, IBond.Order.SINGLE);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(expected2);
IAtomContainer product2 = setOfReactions.getReaction(0).getProducts().getAtomContainer(1);
queryAtom = QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(expected2);
Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(product2, queryAtom));
}
use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class SharingChargeSBReactionTest method testInitiate_IAtomContainerSet_IAtomContainerSet.
/**
* A unit test suite for JUnit. Reaction: methoxymethane.
* C[O+]!-!C => CO + [C+]
*/
@Test
@Override
public void testInitiate_IAtomContainerSet_IAtomContainerSet() throws Exception {
IReactionProcess type = new SharingChargeSBReaction();
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(2, setOfReactions.getReaction(0).getProductCount());
IAtomContainer product1 = setOfReactions.getReaction(1).getProducts().getAtomContainer(0);
IAtomContainer molecule1 = getExpectedProducts().getAtomContainer(0);
IQueryAtomContainer queryAtom = QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(product1);
Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(molecule1, queryAtom));
IAtomContainer product2 = setOfReactions.getReaction(0).getProducts().getAtomContainer(1);
IAtomContainer expected2 = getExpectedProducts().getAtomContainer(0);
queryAtom = QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(expected2);
Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(product2, queryAtom));
}
use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class SharingChargeSBReactionTest method testCDKConstants_REACTIVE_CENTER.
/**
* A unit test suite for JUnit.
*/
@Test
public void testCDKConstants_REACTIVE_CENTER() throws Exception {
IReactionProcess type = new SharingChargeSBReaction();
IAtomContainerSet setOfReactants = getExampleReactants();
IAtomContainer molecule = setOfReactants.getAtomContainer(0);
/* manually put the reactive center */
molecule.getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getAtom(2).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getBond(1).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(1).getFlag(CDKConstants.REACTIVE_CENTER));
Assert.assertTrue(reactant.getAtom(1).getFlag(CDKConstants.REACTIVE_CENTER));
Assert.assertTrue(molecule.getAtom(2).getFlag(CDKConstants.REACTIVE_CENTER));
Assert.assertTrue(reactant.getAtom(2).getFlag(CDKConstants.REACTIVE_CENTER));
Assert.assertTrue(molecule.getBond(1).getFlag(CDKConstants.REACTIVE_CENTER));
Assert.assertTrue(reactant.getBond(1).getFlag(CDKConstants.REACTIVE_CENTER));
}
use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class SharingChargeSBReactionTest method testNsp2ChargeSingleB.
/**
* A unit test suite for JUnit. Reaction:.
* C=[N+]!-!C => C=N + [C+]
*/
@Test
public void testNsp2ChargeSingleB() throws Exception {
// Smiles("C=[N+]C")
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
molecule.addAtom(builder.newInstance(IAtom.class, "C"));
molecule.addAtom(builder.newInstance(IAtom.class, "N"));
molecule.getAtom(1).setFormalCharge(1);
molecule.addAtom(builder.newInstance(IAtom.class, "C"));
molecule.addBond(0, 1, IBond.Order.DOUBLE);
molecule.addBond(1, 2, IBond.Order.SINGLE);
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addBond(0, 3, IBond.Order.SINGLE);
molecule.addBond(0, 4, IBond.Order.SINGLE);
molecule.addBond(1, 5, IBond.Order.SINGLE);
molecule.addBond(2, 6, IBond.Order.SINGLE);
molecule.addBond(2, 7, IBond.Order.SINGLE);
molecule.addBond(2, 8, IBond.Order.SINGLE);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
lpcheck.saturate(molecule);
molecule.getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getAtom(2).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getBond(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
IAtomContainerSet setOfReactants = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
setOfReactants.addAtomContainer(molecule);
IReactionProcess type = new SharingChargeSBReaction();
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());
// expected products
// Smiles("C=N")
IAtomContainer expected1 = builder.newInstance(IAtomContainer.class);
expected1.addAtom(builder.newInstance(IAtom.class, "C"));
expected1.addAtom(builder.newInstance(IAtom.class, "N"));
expected1.addBond(0, 1, IBond.Order.DOUBLE);
expected1.addAtom(builder.newInstance(IAtom.class, "H"));
expected1.addAtom(builder.newInstance(IAtom.class, "H"));
expected1.addAtom(builder.newInstance(IAtom.class, "H"));
expected1.addBond(0, 2, IBond.Order.SINGLE);
expected1.addBond(0, 3, IBond.Order.SINGLE);
expected1.addBond(1, 4, IBond.Order.SINGLE);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(expected1);
lpcheck.saturate(expected1);
IAtomContainer product1 = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
QueryAtomContainer queryAtom = QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(expected1);
Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(product1, queryAtom));
// Smiles("[C+]")
IAtomContainer expected2 = builder.newInstance(IAtomContainer.class);
expected2.addAtom(builder.newInstance(IAtom.class, "C"));
expected2.getAtom(0).setFormalCharge(+1);
expected2.addAtom(builder.newInstance(IAtom.class, "H"));
expected2.addAtom(builder.newInstance(IAtom.class, "H"));
expected2.addAtom(builder.newInstance(IAtom.class, "H"));
expected2.addBond(0, 1, IBond.Order.SINGLE);
expected2.addBond(0, 2, IBond.Order.SINGLE);
expected2.addBond(0, 3, IBond.Order.SINGLE);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(expected2);
IAtomContainer product2 = setOfReactions.getReaction(0).getProducts().getAtomContainer(1);
queryAtom = QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(expected2);
Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(product2, queryAtom));
}
Aggregations