// handles stereochem markers set by the Mol file parser and // converts them to the RD standard: void DetectAtomStereoChemistry(RWMol &mol, const Conformer *conf) { PRECONDITION(conf, "no conformer"); // make sure we've calculated the implicit valence on each atom: for (RWMol::AtomIterator atomIt = mol.beginAtoms(); atomIt != mol.endAtoms(); ++atomIt) { (*atomIt)->calcImplicitValence(false); } for (RWMol::BondIterator bondIt = mol.beginBonds(); bondIt != mol.endBonds(); ++bondIt) { Bond *bond = *bondIt; if (bond->getBondDir() != Bond::UNKNOWN) { Bond::BondDir dir = bond->getBondDir(); // the bond is marked as chiral: if (dir == Bond::BEGINWEDGE || dir == Bond::BEGINDASH) { Atom *atom = bond->getBeginAtom(); if (atom->getImplicitValence() == -1) { atom->calcExplicitValence(); atom->calcImplicitValence(); } Atom::ChiralType code = FindAtomStereochemistry(mol, bond, conf); atom->setChiralTag(code); // within the RD representation, if a three-coordinate atom // is chiral and has an implicit H, that H needs to be made explicit: if (atom->getDegree() == 3 && !atom->getNumExplicitHs() && atom->getNumImplicitHs() == 1) { atom->setNumExplicitHs(1); // recalculated number of implicit Hs: atom->updatePropertyCache(); } } } } }
void setNewProductBond(const Bond &origB, RWMOL_SPTR product, unsigned bondBeginIdx, unsigned bondEndIdx) { unsigned bondIdx = product->addBond(bondBeginIdx, bondEndIdx, origB.getBondType()) - 1; Bond *newB = product->getBondWithIdx(bondIdx); newB->setBondDir(origB.getBondDir()); }