private void callDefaultReactions() {
    List<IParameterReact> paramList = new ArrayList<IParameterReact>();
    IParameterReact param = new SetReactionCenter();
    param.setParameter(Boolean.FALSE);
    paramList.add(param);

    IReactionProcess type = new SharingLonePairReaction();
    try {
      type.setParameterList(paramList);
    } catch (CDKException e) {
      e.printStackTrace();
    }
    reactionsList.add(type);

    type = new PiBondingMovementReaction();
    List<IParameterReact> paramList2 = new ArrayList<IParameterReact>();
    IParameterReact param2 = new SetReactionCenter();
    param2.setParameter(Boolean.FALSE);
    paramList2.add(param2);
    try {
      type.setParameterList(paramList2);
    } catch (CDKException e) {
      e.printStackTrace();
    }
    reactionsList.add(type);

    type = new RearrangementAnionReaction();
    try {
      type.setParameterList(paramList);
    } catch (CDKException e) {
      e.printStackTrace();
    }
    reactionsList.add(type);

    type = new RearrangementCationReaction();
    try {
      type.setParameterList(paramList);
    } catch (CDKException e) {
      e.printStackTrace();
    }
    reactionsList.add(type);

    type = new RearrangementLonePairReaction();
    try {
      type.setParameterList(paramList);
    } catch (CDKException e) {
      e.printStackTrace();
    }
    reactionsList.add(type);

    type = new RearrangementRadicalReaction();
    try {
      type.setParameterList(paramList);
    } catch (CDKException e) {
      e.printStackTrace();
    }
    reactionsList.add(type);
  }
コード例 #2
0
  /**
   * A unit test suite for JUnit for Ethene. Reaction: O=C-C-H => O(H)-C=C. Automatic looking for
   * active center.
   *
   * @cdk.inchi InChI=1/C2H4/c1-2/h1-2H2
   * @return The test suite
   */
  @Test
  public void testInitiate_IMoleculeSet_IMoleculeSet() throws Exception {

    IReactionProcess type = new AdductionProtonPBReaction();

    IMolecule molecule = getEthene();

    IMoleculeSet setOfReactants = DefaultChemObjectBuilder.getInstance().newMoleculeSet();
    setOfReactants.addMolecule(molecule);

    /* initiate */
    List<IParameterReact> paramList = new ArrayList<IParameterReact>();
    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());

    IMolecule product = setOfReactions.getReaction(0).getProducts().getMolecule(0);

    IMolecule molecule2 = getExpected();

    IQueryAtomContainer queryAtom =
        QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(product);
    Assert.assertTrue(UniversalIsomorphismTester.isIsomorph(molecule2, queryAtom));
  }
コード例 #3
0
  /**
   * A unit test suite for JUnit.
   *
   * @cdk.inchi InChI=1/C2H4/c1-2/h1-2H2
   * @return The test suite
   */
  @Test
  public void testCDKConstants_REACTIVE_CENTER() throws Exception {
    IReactionProcess type = new AdductionProtonPBReaction();
    IMoleculeSet setOfReactants = builder.newMoleculeSet();
    IMolecule molecule = getEthene();

    /*manually putting the active center*/
    molecule.getAtom(0).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getBond(0).setFlag(CDKConstants.REACTIVE_CENTER, true);

    setOfReactants.addMolecule(molecule);
    List<IParameterReact> paramList = new ArrayList<IParameterReact>();
    IParameterReact param = new SetReactionCenter();
    param.setParameter(Boolean.TRUE);
    paramList.add(param);
    type.setParameterList(paramList);

    /* initiate */
    IReactionSet setOfReactions = type.initiate(setOfReactants, null);

    IMolecule reactant = setOfReactions.getReaction(0).getReactants().getMolecule(0);
    Assert.assertTrue(molecule.getAtom(0).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getAtom(0).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(molecule.getAtom(1).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getAtom(1).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(molecule.getBond(0).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getBond(0).getFlag(CDKConstants.REACTIVE_CENTER));
  }
コード例 #4
0
  /**
   * A unit test suite for JUnit. Reaction:
   *
   * @return The test suite
   */
  @Test
  @Override
  public void testInitiate_IAtomContainerSet_IAtomContainerSet() throws Exception {
    IReactionProcess type = new RadicalSiteHrBetaReaction();

    IAtomContainerSet setOfReactants = getExampleReactants();

    /* initiate */

    List<IParameterReact> paramList = new ArrayList<IParameterReact>();
    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);

    IQueryAtomContainer queryAtom =
        QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(product);
    Assert.assertTrue(new UniversalIsomorphismTester().isIsomorph(molecule2, queryAtom));
  }
コード例 #5
0
  /**
   * A unit test suite for JUnit.
   *
   * @return The test suite
   */
  @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>();
    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));
  }
コード例 #6
0
  /**
   * A unit test suite for JUnit.
   *
   * @cdk.inchi InChI=1/C2H4/c1-2/h1-2H2
   * @return The test suite
   */
  @Test
  public void testMapping() throws Exception {
    IReactionProcess type = new AdductionProtonPBReaction();

    IMoleculeSet setOfReactants = DefaultChemObjectBuilder.getInstance().newMoleculeSet();
    IMolecule molecule = getEthene();

    setOfReactants.addMolecule(molecule);

    /*automatic looking for active center*/
    List<IParameterReact> paramList = new ArrayList<IParameterReact>();
    IParameterReact param = new SetReactionCenter();
    param.setParameter(Boolean.FALSE);
    paramList.add(param);
    type.setParameterList(paramList);

    /* initiate */

    IReactionSet setOfReactions = type.initiate(setOfReactants, null);

    IMolecule product = setOfReactions.getReaction(0).getProducts().getMolecule(0);

    Assert.assertEquals(3, 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));
    IBond mappedProductB1 =
        (IBond)
            ReactionManipulator.getMappedChemObject(
                setOfReactions.getReaction(0), molecule.getBond(0));
    Assert.assertEquals(mappedProductB1, product.getBond(0));
  }
コード例 #7
0
  /**
   * A unit test suite for JUnit.
   *
   * @return The test suite
   */
  @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>();
    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));
  }