use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class HomolyticCleavageReactionTest method testNspChargeTripleB.
/**
* A unit test suite for JUnit. Reaction:.
* [N+]!#!C => [N*+]=[C*]
*/
@Test
public void testNspChargeTripleB() throws Exception {
// Smiles("[N+]#C")
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
molecule.addAtom(builder.newInstance(IAtom.class, "N"));
molecule.addAtom(builder.newInstance(IAtom.class, "C"));
molecule.getAtom(0).setFormalCharge(+1);
molecule.addBond(0, 1, IBond.Order.TRIPLE);
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addAtom(builder.newInstance(IAtom.class, "H"));
molecule.addBond(0, 2, IBond.Order.SINGLE);
molecule.addBond(1, 3, IBond.Order.SINGLE);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
lpcheck.saturate(molecule);
molecule.getAtom(0).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getBond(0).setFlag(CDKConstants.REACTIVE_CENTER, true);
IAtomContainerSet setOfReactants = builder.newInstance(IAtomContainerSet.class);
setOfReactants.addAtomContainer(molecule);
IReactionProcess type = new HomolyticCleavageReaction();
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(0, setOfReactions.getReactionCount());
}
use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class HomolyticCleavageReactionTest method testMapping.
/**
* A unit test suite for JUnit.
*/
@Test
public void testMapping() throws Exception {
IReactionProcess type = new HomolyticCleavageReaction();
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 */
makeSureAtomTypesAreRecognized(molecule);
IReactionSet setOfReactions = type.initiate(setOfReactants, null);
IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
Assert.assertEquals(4, 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(1));
Assert.assertEquals(mappedProductA2, product.getAtom(1));
}
use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class HyperconjugationReactionTest method testMapping.
/**
* A unit test suite for JUnit.
*/
@Test
public void testMapping() throws Exception {
IReactionProcess type = new HyperconjugationReaction();
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 product1 = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
IAtomContainer product2 = setOfReactions.getReaction(0).getProducts().getAtomContainer(1);
Assert.assertEquals(3, setOfReactions.getReactionCount());
Assert.assertEquals(2, setOfReactions.getReaction(0).getProductCount());
// if these assertions fail the atom order may have changed
IAtom mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(1));
Assert.assertEquals(mappedProductA1, product1.getAtom(1));
mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(2));
Assert.assertEquals(mappedProductA1, product1.getAtom(2));
mappedProductA1 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(6));
Assert.assertEquals(mappedProductA1, product2.getAtom(0));
}
use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class HyperconjugationReactionTest method testInitiate_IAtomContainerSet_IAtomContainerSet.
/**
* A unit test suite for JUnit. Reaction: [C+]-CC => C=CC + [H+]
* Automatic search for the active center.
*/
@Test
@Override
public void testInitiate_IAtomContainerSet_IAtomContainerSet() throws Exception {
IReactionProcess type = new HyperconjugationReaction();
IAtomContainerSet setOfReactants = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
/* [C+]CC */
IAtomContainer molecule = builder.newInstance(IAtomContainer.class);
molecule.addAtom(builder.newInstance(IAtom.class, "C"));
molecule.getAtom(0).setFormalCharge(1);
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.SINGLE);
addExplicitHydrogens(molecule);
setOfReactants.addAtomContainer(molecule);
/* 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 */
makeSureAtomTypesAreRecognized(molecule);
IReactionSet setOfReactions = type.initiate(setOfReactants, null);
Assert.assertEquals(2, setOfReactions.getReactionCount());
Assert.assertEquals(2, setOfReactions.getReaction(0).getProductCount());
IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
/* C=CC */
IAtomContainer molecule2 = builder.newInstance(IAtomContainer.class);
molecule2.addAtom(builder.newInstance(IAtom.class, "C"));
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);
addExplicitHydrogens(molecule2);
Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(molecule2, product));
product = setOfReactions.getReaction(0).getProducts().getAtomContainer(1);
/* [H+] */
molecule2 = builder.newInstance(IAtomContainer.class);
molecule2.addAtom(builder.newInstance(IAtom.class, "H"));
molecule2.getAtom(0).setFormalCharge(1);
Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(molecule2, product));
}
use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class HyperconjugationReactionTest method testManuallyCentreActive.
/**
* A unit test suite for JUnit. Reaction: [C-][C+]-C => [C-]C=C + [H+]
* Manually put of the center active.
*/
@Test
public void testManuallyCentreActive() throws Exception {
IReactionProcess type = new HyperconjugationReaction();
IAtomContainerSet setOfReactants = getExampleReactants();
IAtomContainer molecule = setOfReactants.getAtomContainer(0);
/* manually put the center active */
molecule.getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getAtom(2).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getAtom(6).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getBond(1).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);
Assert.assertEquals(1, 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(product);
Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(molecule2, queryAtom));
}
Aggregations