Example #1
0
void setReactantBondPropertiesToProduct(RWMOL_SPTR product,
                                        const ROMol &reactant,
                                        ReactantProductAtomMapping *mapping) {
  ROMol::BOND_ITER_PAIR bondItP = product->getEdges();
  while (bondItP.first != bondItP.second) {
    Bond *pBond = (*product)[*(bondItP.first)];
    ++bondItP.first;
    if (pBond->hasProp(common_properties::NullBond) ||
        pBond->hasProp(common_properties::_MolFileBondQuery)) {
      if (mapping->prodReactAtomMap.find(pBond->getBeginAtomIdx()) !=
              mapping->prodReactAtomMap.end() &&
          mapping->prodReactAtomMap.find(pBond->getEndAtomIdx()) !=
              mapping->prodReactAtomMap.end()) {
        // the bond is between two mapped atoms from this reactant:
        unsigned begIdx = mapping->prodReactAtomMap[pBond->getBeginAtomIdx()];
        unsigned endIdx = mapping->prodReactAtomMap[pBond->getEndAtomIdx()];
        const Bond *rBond = reactant.getBondBetweenAtoms(begIdx, endIdx);
        if (!rBond) continue;
        pBond->setBondType(rBond->getBondType());
        pBond->setBondDir(rBond->getBondDir());
        pBond->setIsAromatic(rBond->getIsAromatic());
        if (pBond->hasProp(common_properties::NullBond)) {
          pBond->clearProp(common_properties::NullBond);
        }
      }
    }
  }
}
Example #2
0
void addMissingProductBonds(const Bond &origB, RWMOL_SPTR product,
                            ReactantProductAtomMapping *mapping) {
  unsigned int begIdx = origB.getBeginAtomIdx();
  unsigned int endIdx = origB.getEndAtomIdx();

  std::vector<unsigned> prodBeginIdxs = mapping->reactProdAtomMap[begIdx];
  std::vector<unsigned> prodEndIdxs = mapping->reactProdAtomMap[endIdx];
  CHECK_INVARIANT(prodBeginIdxs.size() == prodEndIdxs.size(),
                  "Different number of start-end points for product bonds.");
  for (unsigned i = 0; i < prodBeginIdxs.size(); i++) {
    setNewProductBond(origB, product, prodBeginIdxs.at(i), prodEndIdxs.at(i));
  }
}