use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class HyperconjugationReactionTest method testWithNegativeCharge.
/**
* A unit test suite for JUnit. Reaction: [C-][C+]-C => [C-]C=C + [H+]
* Automatic search for the active center.
*/
@Test
public void testWithNegativeCharge() throws Exception {
IReactionProcess type = new HyperconjugationReaction();
IAtomContainerSet setOfReactants = getExampleReactants();
/* 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);
Assert.assertEquals(3, 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(molecule2);
Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(product, queryAtom));
product = setOfReactions.getReaction(0).getProducts().getAtomContainer(1);
molecule2 = builder.newInstance(IAtomContainer.class);
molecule2.addAtom(builder.newInstance(IAtom.class, "H"));
molecule2.getAtom(0).setFormalCharge(1);
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 PiBondingMovementReactionTest method testDoubleRingConjugated2.
/**
* A unit test suite for JUnit with 2-methylnaphthalene.
* Reaction: C1=CC(=CC2=C1C=CC=C2)C
* -> C1=CC(=CC2=CC=CC=C12)C + {NO => C1=C2C(=CC(=C1)C)C=CC=C2}
*
* restricted the reaction center.
*
* InChI=1/C11H10/c1-9-6-7-10-4-2-3-5-11(10)8-9/h2-8H,1H3
*/
@Test
public void testDoubleRingConjugated2() throws Exception {
IReactionProcess type = new PiBondingMovementReaction();
// C1=CC(=CC2=C1C=CC=C2)C
IAtomContainerSet setOfReactants = getExampleReactants();
IAtomContainer molecule = setOfReactants.getAtomContainer(0);
/* manually putting the reaction center */
molecule.getBond(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getBond(2).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getBond(3).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getBond(9).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getBond(10).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getBond(11).setFlag(CDKConstants.REACTIVE_CENTER, true);
/* initiate */
List<IParameterReact> paramList = new ArrayList<>();
IParameterReact param = new SetReactionCenter();
param.setParameter(Boolean.TRUE);
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 product2 = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
IAtomContainer molecule2 = getExpectedProducts().getAtomContainer(0);
IQueryAtomContainer queryAtom = QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(product2);
Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(molecule2, queryAtom));
}
use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class RadicalSiteHrBetaReactionTest method testInitiate_IAtomContainerSet_IAtomContainerSet.
/**
* A unit test suite for JUnit. Reaction:
*/
@Test
@Override
public void testInitiate_IAtomContainerSet_IAtomContainerSet() throws Exception {
IReactionProcess type = new RadicalSiteHrBetaReaction();
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(1, setOfReactions.getReaction(0).getProductCount());
IAtomContainer product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
IAtomContainer molecule2 = getExpectedProducts().getAtomContainer(0);
assertEquals(molecule2, product);
}
use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class RadicalSiteHrBetaReactionTest method testCDKConstants_REACTIVE_CENTER.
/**
* A unit test suite for JUnit.
*/
@Test
public void testCDKConstants_REACTIVE_CENTER() throws Exception {
IReactionProcess type = new RadicalSiteHrBetaReaction();
IAtomContainerSet setOfReactants = getExampleReactants();
IAtomContainer molecule = setOfReactants.getAtomContainer(0);
/* manually put the reactive center */
molecule.getAtom(3).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getAtom(0).setFlag(CDKConstants.REACTIVE_CENTER, true);
molecule.getAtom(6).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);
IAtomContainer reactant = setOfReactions.getReaction(0).getReactants().getAtomContainer(0);
Assert.assertTrue(molecule.getAtom(6).getFlag(CDKConstants.REACTIVE_CENTER));
Assert.assertTrue(reactant.getAtom(6).getFlag(CDKConstants.REACTIVE_CENTER));
Assert.assertTrue(molecule.getAtom(0).getFlag(CDKConstants.REACTIVE_CENTER));
Assert.assertTrue(reactant.getAtom(0).getFlag(CDKConstants.REACTIVE_CENTER));
Assert.assertTrue(molecule.getAtom(3).getFlag(CDKConstants.REACTIVE_CENTER));
Assert.assertTrue(reactant.getAtom(3).getFlag(CDKConstants.REACTIVE_CENTER));
Assert.assertTrue(molecule.getBond(5).getFlag(CDKConstants.REACTIVE_CENTER));
Assert.assertTrue(reactant.getBond(5).getFlag(CDKConstants.REACTIVE_CENTER));
}
use of org.openscience.cdk.interfaces.IReactionSet in project cdk by cdk.
the class RadicalSiteHrBetaReactionTest method testMapping.
/**
* A unit test suite for JUnit.
*/
@Test
public void testMapping() throws Exception {
IReactionProcess type = new RadicalSiteHrBetaReaction();
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 product = setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
Assert.assertEquals(19, 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(6));
Assert.assertEquals(mappedProductA2, product.getAtom(6));
IAtom mappedProductA3 = (IAtom) ReactionManipulator.getMappedChemObject(setOfReactions.getReaction(0), molecule.getAtom(3));
Assert.assertEquals(mappedProductA3, product.getAtom(3));
}
Aggregations