예제 #1
0
  /** @cdk.inchi InChI=1/C4H5N/c1-2-4-5-3-1/h1-5H */
  @Test
  public void xtestPyrrole() throws Exception {
    IAtomContainer enol = new AtomContainer();

    // atom block
    IAtom atom1 = new Atom(Elements.CARBON);
    atom1.setHybridization(Hybridization.SP2);
    IAtom atom2 = new Atom(Elements.CARBON);
    atom2.setHybridization(Hybridization.SP2);
    IAtom atom3 = new Atom(Elements.CARBON);
    atom3.setHybridization(Hybridization.SP2);
    IAtom atom4 = new Atom(Elements.CARBON);
    atom4.setHybridization(Hybridization.SP2);
    IAtom atom5 = new Atom(Elements.NITROGEN);
    atom5.setHybridization(Hybridization.SP2);
    atom5.setImplicitHydrogenCount(1);

    // bond block
    IBond bond1 = new Bond(atom1, atom2);
    IBond bond2 = new Bond(atom2, atom3);
    IBond bond3 = new Bond(atom3, atom4);
    IBond bond4 = new Bond(atom4, atom5);
    IBond bond5 = new Bond(atom5, atom1);

    enol.addAtom(atom1);
    enol.addAtom(atom2);
    enol.addAtom(atom3);
    enol.addAtom(atom4);
    enol.addAtom(atom5);
    enol.addBond(bond1);
    enol.addBond(bond2);
    enol.addBond(bond3);
    enol.addBond(bond4);
    enol.addBond(bond5);

    // perceive atom types
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(enol);

    // now have the algorithm have a go at it
    enol = fbot.kekuliseAromaticRings(enol);
    Assert.assertNotNull(enol);
    // Assert.assertTrue(fbot.isOK(enol));

    // now check whether it did the right thing
    Assert.assertEquals(CDKConstants.BONDORDER_DOUBLE, enol.getBond(0).getOrder());
    ;
    Assert.assertEquals(CDKConstants.BONDORDER_SINGLE, enol.getBond(1).getOrder());
    ;
    Assert.assertEquals(CDKConstants.BONDORDER_DOUBLE, enol.getBond(2).getOrder());
    ;
    Assert.assertEquals(CDKConstants.BONDORDER_SINGLE, enol.getBond(3).getOrder());
    ;
    Assert.assertEquals(CDKConstants.BONDORDER_SINGLE, enol.getBond(4).getOrder());
    ;
  }
예제 #2
0
  /**
   * This method calculates the ionization potential of an atom.
   *
   * @param atom The IAtom to ionize.
   * @param container Parameter is the IAtomContainer.
   * @return The ionization potential. Not possible the ionization.
   */
  @Override
  public DescriptorValue calculate(IAtom atom, IAtomContainer container) {
    double value = 0;
    // FIXME: for now I'll cache a few modified atomic properties, and restore them at the end of
    // this method
    String originalAtomtypeName = atom.getAtomTypeName();
    Integer originalNeighborCount = atom.getFormalNeighbourCount();
    Integer originalValency = atom.getValency();
    IAtomType.Hybridization originalHybrid = atom.getHybridization();
    Double originalBondOrderSum = atom.getBondOrderSum();
    Order originalMaxBondOrder = atom.getMaxBondOrder();

    if (!isCachedAtomContainer(container)) {
      try {
        AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(container);

        LonePairElectronChecker lpcheck = new LonePairElectronChecker();
        lpcheck.saturate(container);
      } catch (CDKException e) {
        return new DescriptorValue(
            getSpecification(),
            getParameterNames(),
            getParameters(),
            new DoubleResult(Double.NaN),
            getDescriptorNames(),
            e);
      }
    }

    try {
      value = IonizationPotentialTool.predictIP(container, atom);
    } catch (CDKException e) {
      return new DescriptorValue(
          getSpecification(),
          getParameterNames(),
          getParameters(),
          new DoubleResult(Double.NaN),
          getDescriptorNames(),
          e);
    }
    // restore original props
    atom.setAtomTypeName(originalAtomtypeName);
    atom.setFormalNeighbourCount(originalNeighborCount);
    atom.setValency(originalValency);
    atom.setHybridization(originalHybrid);
    atom.setMaxBondOrder(originalMaxBondOrder);
    atom.setBondOrderSum(originalBondOrderSum);

    return new DescriptorValue(
        getSpecification(),
        getParameterNames(),
        getParameters(),
        new DoubleResult(value),
        getDescriptorNames());
  }
  /**
   * Initiates the process for the given mechanism. The atoms to apply are mapped between reactants
   * and products.
   *
   * @param atomContainerSet
   * @param atomList The list of atoms taking part in the mechanism. Only allowed two atoms. The
   *     first atom is the atom which contains the ISingleElectron and the second third is the atom
   *     which will be removed the first atom
   * @param bondList The list of bonds taking part in the mechanism. Only allowed one bond. It is
   *     the bond which is moved
   * @return The Reaction mechanism
   */
  @TestMethod(value = "testInitiate_IAtomContainerSet_ArrayList_ArrayList")
  public IReaction initiate(
      IAtomContainerSet atomContainerSet, ArrayList<IAtom> atomList, ArrayList<IBond> bondList)
      throws CDKException {
    CDKAtomTypeMatcher atMatcher = CDKAtomTypeMatcher.getInstance(atomContainerSet.getBuilder());
    if (atomContainerSet.getAtomContainerCount() != 1) {
      throw new CDKException("RadicalSiteIonizationMechanism only expects one IMolecule");
    }
    if (atomList.size() != 3) {
      throw new CDKException("RadicalSiteIonizationMechanism expects three atoms in the ArrayList");
    }
    if (bondList.size() != 2) {
      throw new CDKException(
          "RadicalSiteIonizationMechanism only expect one bond in the ArrayList");
    }
    IAtomContainer molecule = atomContainerSet.getAtomContainer(0);
    IAtomContainer reactantCloned;
    try {
      reactantCloned = (IAtomContainer) molecule.clone();
    } catch (CloneNotSupportedException e) {
      throw new CDKException("Could not clone IMolecule!", e);
    }
    IAtom atom1 = atomList.get(0); // Atom containing the ISingleElectron
    IAtom atom1C = reactantCloned.getAtom(molecule.getAtomNumber(atom1));
    IAtom atom2 = atomList.get(1); // Atom
    IAtom atom2C = reactantCloned.getAtom(molecule.getAtomNumber(atom2));
    IAtom atom3 = atomList.get(2); // Atom to be saved
    IAtom atom3C = reactantCloned.getAtom(molecule.getAtomNumber(atom3));
    IBond bond1 = bondList.get(0); // Bond to increase the order
    int posBond1 = molecule.getBondNumber(bond1);
    IBond bond2 = bondList.get(1); // Bond to remove
    int posBond2 = molecule.getBondNumber(bond2);

    BondManipulator.increaseBondOrder(reactantCloned.getBond(posBond1));
    reactantCloned.removeBond(reactantCloned.getBond(posBond2));

    List<ISingleElectron> selectron = reactantCloned.getConnectedSingleElectronsList(atom1C);
    reactantCloned.removeSingleElectron(selectron.get(selectron.size() - 1));
    atom1C.setHybridization(null);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(reactantCloned);
    IAtomType type = atMatcher.findMatchingAtomType(reactantCloned, atom1C);
    if (type == null) return null;

    atom2C.setHybridization(null);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(reactantCloned);
    type = atMatcher.findMatchingAtomType(reactantCloned, atom2C);
    if (type == null) return null;

    reactantCloned.addSingleElectron(new SingleElectron(atom3C));
    atom3C.setHybridization(null);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(reactantCloned);
    type = atMatcher.findMatchingAtomType(reactantCloned, atom3C);
    if (type == null) return null;

    IReaction reaction = DefaultChemObjectBuilder.getInstance().newInstance(IReaction.class);
    reaction.addReactant(molecule);

    /* mapping */
    for (IAtom atom : molecule.atoms()) {
      IMapping mapping =
          DefaultChemObjectBuilder.getInstance()
              .newInstance(
                  IMapping.class, atom, reactantCloned.getAtom(molecule.getAtomNumber(atom)));
      reaction.addMapping(mapping);
    }

    IAtomContainerSet moleculeSetP = ConnectivityChecker.partitionIntoMolecules(reactantCloned);
    for (int z = 0; z < moleculeSetP.getAtomContainerCount(); z++)
      reaction.addProduct((IAtomContainer) moleculeSetP.getAtomContainer(z));

    return reaction;
  }