コード例 #1
0
ファイル: Misc.java プロジェクト: egonw/cdkr
  public static IAtomContainer getMcsAsNewContainer(IAtomContainer mol1, IAtomContainer mol2)
      throws CDKException, CloneNotSupportedException {
    Isomorphism mcs = new Isomorphism(org.openscience.cdk.smsd.interfaces.Algorithm.DEFAULT, true);
    mcs.init(mol1, mol2, true, true);
    mcs.setChemFilters(true, true, true);

    mol1 = mcs.getReactantMolecule();
    mol2 = mcs.getProductMolecule();

    IAtomContainer mcsmolecule =
        DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class, mol1);

    List<IAtom> atomsToBeRemoved = new ArrayList<IAtom>();
    for (IAtom atom : mcsmolecule.atoms()) {
      int index = mcsmolecule.getAtomNumber(atom);
      if (!mcs.getFirstMapping().containsKey(index)) {
        atomsToBeRemoved.add(atom);
      }
    }

    for (IAtom atom : atomsToBeRemoved) {
      mcsmolecule.removeAtomAndConnectedElectronContainers(atom);
    }

    return mcsmolecule;
  }
コード例 #2
0
ファイル: AtomAtomMapping.java プロジェクト: asad/VFLib
 /**
  * Returns common mapped fragment in the target molecule.
  *
  * @return common mapped fragment in the target molecule
  * @throws CloneNotSupportedException
  */
 public synchronized IAtomContainer getCommonFragmentInTarget() throws CloneNotSupportedException {
   IAtomContainer ac = (IAtomContainer) target.clone();
   List<IAtom> uniqueAtoms = Collections.synchronizedList(new ArrayList<IAtom>());
   for (IAtom atom : target.atoms()) {
     if (!mapping.containsValue(atom)) {
       uniqueAtoms.add(ac.getAtom(getTargetIndex(atom)));
     }
   }
   for (IAtom atom : uniqueAtoms) {
     ac.removeAtomAndConnectedElectronContainers(atom);
   }
   return ac;
 }
コード例 #3
0
ファイル: AtomAtomMapping.java プロジェクト: asad/VFLib
 /**
  * Returns unique unmapped fragments in the target molecule.
  *
  * @return unique fragments in the target molecule
  * @throws CloneNotSupportedException
  */
 public synchronized IAtomContainerSet getUniqueFragmentsInTarget()
     throws CloneNotSupportedException {
   IAtomContainer ac = (IAtomContainer) target.clone();
   List<IAtom> commonAtoms = Collections.synchronizedList(new ArrayList<IAtom>());
   for (IAtom atom : mapping.values()) {
     commonAtoms.add(ac.getAtom(getTargetIndex(atom)));
   }
   for (IAtom atom : commonAtoms) {
     ac.removeAtomAndConnectedElectronContainers(atom);
   }
   // now we probably have a set of disconnected components
   // so lets get a set of individual atom containers for
   // corresponding to each component
   return ConnectivityChecker.partitionIntoMolecules(ac);
 }
コード例 #4
0
  @TestMethod("testDetectAromaticity_IAtomContainer")
  public static boolean detectAromaticity(IAtomContainer atomContainer) throws CDKException {
    SpanningTree spanningTree = new SpanningTree(atomContainer);
    IAtomContainer ringSystems = spanningTree.getCyclicFragmentsContainer();
    if (ringSystems.getAtomCount() == 0) {
      // If there are no rings, then there cannot be any aromaticity
      return false;
    }
    // disregard all atoms we know that cannot be aromatic anyway
    for (IAtom atom : ringSystems.atoms())
      if (!atomIsPotentiallyAromatic(atom))
        ringSystems.removeAtomAndConnectedElectronContainers(atom);

    // FIXME: should not really mark them here
    Iterator<IAtom> atoms = ringSystems.atoms().iterator();
    while (atoms.hasNext()) atoms.next().setFlag(CDKConstants.ISINRING, true);
    Iterator<IBond> bonds = ringSystems.bonds().iterator();
    while (bonds.hasNext()) bonds.next().setFlag(CDKConstants.ISINRING, true);

    boolean foundSomeAromaticity = false;
    Iterator<IAtomContainer> isolatedRingSystems =
        ConnectivityChecker.partitionIntoMolecules(ringSystems).atomContainers().iterator();
    while (isolatedRingSystems.hasNext()) {
      IAtomContainer isolatedSystem = isolatedRingSystems.next();
      IRingSet singleRings = new SSSRFinder(isolatedSystem).findSSSR();
      Iterator<IAtomContainer> singleRingsIterator = singleRings.atomContainers().iterator();
      int maxRingSize = 20;
      boolean atLeastOneRingIsSprouted = false;
      boolean allRingsAreAromatic = true;
      // test single rings in SSSR
      while (singleRingsIterator.hasNext()) {
        IAtomContainer singleRing = singleRingsIterator.next();
        if (singleRing.getAtomCount() > maxRingSize) maxRingSize = singleRing.getAtomCount();
        if (isRingSystemSproutedWithNonRingDoubleBonds(atomContainer, singleRing)) {
          //					OK, this ring is not aromatic
          atLeastOneRingIsSprouted = true;
          allRingsAreAromatic = false;
        } else {
          // possibly aromatic
          boolean ringIsAromatic = isHueckelValid(singleRing);
          foundSomeAromaticity |= ringIsAromatic;
          allRingsAreAromatic &= ringIsAromatic;
          if (ringIsAromatic) markRingAtomsAndBondsAromatic(singleRing);
        }
      }
      // OK, what about the one larger ring (if no aromaticity found in SSSR)?
      if (!allRingsAreAromatic
          && !atLeastOneRingIsSprouted
          && singleRings.getAtomContainerCount() <= 3) {
        // every ring system consisting of more than two rings is too difficult
        Iterator<IAtomContainer> allRingsIterator =
            new AllRingsFinder()
                .findAllRingsInIsolatedRingSystem(isolatedSystem)
                .atomContainers()
                .iterator();
        while (allRingsIterator.hasNext()) {
          // there should be exactly three rings, of which only one has a size larger
          // than the two previous ones
          IAtomContainer ring = allRingsIterator.next();
          if (ring.getAtomCount() <= maxRingSize) {
            // possibly aromatic
            boolean ringIsAromatic = isHueckelValid(ring);
            foundSomeAromaticity |= ringIsAromatic;
            if (ringIsAromatic) markRingAtomsAndBondsAromatic(ring);
          }
        }
      }
    }

    return foundSomeAromaticity;
  }