diff --git a/Code/GraphMol/AddHs.cpp b/Code/GraphMol/AddHs.cpp index 0832247ad..b762afcf8 100644 --- a/Code/GraphMol/AddHs.cpp +++ b/Code/GraphMol/AddHs.cpp @@ -471,7 +471,7 @@ void removeHs(RWMol &mol, bool implicitOnly, bool updateExplicitCount, // note the assumption that the H only has one neighbor... I // feel no need to handle the case of hypervalent hydrogen! // :-) - const BOND_SPTR bond = mol[*beg]; + const Bond* bond = mol[*beg]; Atom *heavyAtom = bond->getOtherAtom(atom); int heavyAtomNum = heavyAtom->getAtomicNum(); const INT_VECT &defaultVs = @@ -545,7 +545,7 @@ void removeHs(RWMol &mol, bool implicitOnly, bool updateExplicitCount, if (mol[*beg]->getIdx() != bond->getIdx() && mol[*beg]->getBondType() == Bond::SINGLE) { if (mol[*beg]->getBondDir() == Bond::NONE) { - oBond = mol[*beg].get(); + oBond = mol[*beg]; } else { foundADir = true; } diff --git a/Code/GraphMol/AdjustQuery.cpp b/Code/GraphMol/AdjustQuery.cpp index f89da80e0..ec002a581 100644 --- a/Code/GraphMol/AdjustQuery.cpp +++ b/Code/GraphMol/AdjustQuery.cpp @@ -171,7 +171,7 @@ void adjustQueryProperties(RWMol &mol, const AdjustQueryParameters *inParams) { ROMol::EDGE_ITER firstB, lastB; boost::tie(firstB, lastB) = mol.getEdges(); while (firstB != lastB) { - BOND_SPTR bond = mol[*firstB]; + //Bond *bond = mol[*firstB]; ++firstB; } } diff --git a/Code/GraphMol/Aromaticity.cpp b/Code/GraphMol/Aromaticity.cpp index 87d675d3a..80428721d 100644 --- a/Code/GraphMol/Aromaticity.cpp +++ b/Code/GraphMol/Aromaticity.cpp @@ -284,7 +284,7 @@ bool incidentMultipleBond(const Atom *at) { ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = at->getOwningMol().getAtomBonds(at); while (beg != end) { - BOND_SPTR bond = at->getOwningMol()[*beg]; + Bond* bond = at->getOwningMol()[*beg]; if (bond->getBondType() == Bond::ZERO) --deg; ++beg; } @@ -500,7 +500,7 @@ bool isAtomCandForArom(const Atom *at, const ElectronDonorType edon, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(at); while (beg != end) { - const Bond *bnd = mol[*beg].get(); + const Bond *bnd = mol[*beg]; if ((bnd->getBondType() == Bond::DOUBLE || bnd->getBondType() == Bond::TRIPLE) && !queryIsBondInRing(bnd)) @@ -606,7 +606,7 @@ int countAtomElec(const Atom *at) { ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = at->getOwningMol().getAtomBonds(at); while (beg != end) { - BOND_SPTR bond = at->getOwningMol()[*beg]; + Bond* bond = at->getOwningMol()[*beg]; if (bond->getBondType() == Bond::UNSPECIFIED // query bonds should not // contribute; this was github // issue #443 diff --git a/Code/GraphMol/Atom.h b/Code/GraphMol/Atom.h index d686c360b..63281abbf 100644 --- a/Code/GraphMol/Atom.h +++ b/Code/GraphMol/Atom.h @@ -71,8 +71,6 @@ class Atom : public RDProps { friend class RWMol; public: - typedef boost::shared_ptr ATOM_SPTR; - typedef boost::shared_ptr C_ATOM_SPTR; // FIX: grn... typedef Queries::Query QUERYATOM_QUERY; @@ -303,10 +301,6 @@ class Atom : public RDProps { | [CH2] | O[CH2]O | Yes | */ virtual bool Match(Atom const *what) const; - //! \overload - virtual inline bool Match(const ATOM_SPTR &what) const { - return Match(what.get()); - }; //! returns the perturbation order for a list of integers /*! diff --git a/Code/GraphMol/AtomIterators.cpp b/Code/GraphMol/AtomIterators.cpp index 78b1f6e90..611e85a81 100644 --- a/Code/GraphMol/AtomIterators.cpp +++ b/Code/GraphMol/AtomIterators.cpp @@ -82,14 +82,14 @@ template Atom_ *AtomIterator_::operator*() const { PRECONDITION(_mol != nullptr, "no molecule"); RANGE_CHECK(0, _pos, _max - 1); - return (*_mol)[_pos].get(); + return (*_mol)[_pos]; } // random access template Atom_ *AtomIterator_::operator[](const int which) const { PRECONDITION(_mol != nullptr, "no molecule"); RANGE_CHECK(0, which, _max - 1); - return (*_mol)[which].get(); + return (*_mol)[which]; } template @@ -208,7 +208,7 @@ bool HeteroatomIterator_::operator!=(const ThisType &other) const { template Atom_ *HeteroatomIterator_::operator*() const { PRECONDITION(_mol != nullptr, "no molecule"); - return (*_mol)[_pos].get(); + return (*_mol)[_pos]; } // pre-increment template @@ -313,7 +313,7 @@ bool AromaticAtomIterator_::operator!=( template Atom_ *AromaticAtomIterator_::operator*() const { PRECONDITION(_mol != nullptr, "no molecule"); - return (*_mol)[_pos].get(); + return (*_mol)[_pos]; } // pre-increment template @@ -433,7 +433,7 @@ bool QueryAtomIterator_::operator!=( template Atom_ *QueryAtomIterator_::operator*() const { PRECONDITION(_mol != nullptr, "no molecule"); - return (*_mol)[_pos].get(); + return (*_mol)[_pos]; } // pre-increment template @@ -547,7 +547,7 @@ bool MatchingAtomIterator_::operator!=( template Atom_ *MatchingAtomIterator_::operator*() const { PRECONDITION(_mol != nullptr, "no molecule"); - return (*_mol)[_pos].get(); + return (*_mol)[_pos]; } // pre-increment template @@ -582,7 +582,7 @@ int MatchingAtomIterator_::_findNext(int from) { PRECONDITION(_mol != nullptr, "no molecule"); PRECONDITION(_qF != nullptr, "no query set"); while (from < _end) { - if (_qF((*_mol)[from].get())) + if (_qF((*_mol)[from])) break; else ++from; @@ -595,7 +595,7 @@ int MatchingAtomIterator_::_findPrev(int from) { PRECONDITION(_mol != nullptr, "no molecule"); PRECONDITION(_qF != nullptr, "no query set"); while (from > 0) { - if (_qF((*_mol)[from].get())) + if (_qF((*_mol)[from])) break; else --from; diff --git a/Code/GraphMol/Bond.cpp b/Code/GraphMol/Bond.cpp index 6ee114459..7e3ffa98b 100644 --- a/Code/GraphMol/Bond.cpp +++ b/Code/GraphMol/Bond.cpp @@ -95,19 +95,10 @@ void Bond::setBeginAtom(Atom *at) { PRECONDITION(dp_mol != nullptr, "no owning molecule for bond"); setBeginAtomIdx(at->getIdx()); } -void Bond::setBeginAtom(Atom::ATOM_SPTR at) { - PRECONDITION(dp_mol != nullptr, "no owning molecule for bond"); - setBeginAtomIdx(at->getIdx()); -} - void Bond::setEndAtom(Atom *at) { PRECONDITION(dp_mol != nullptr, "no owning molecule for bond"); setEndAtomIdx(at->getIdx()); } -void Bond::setEndAtom(Atom::ATOM_SPTR at) { - PRECONDITION(dp_mol != nullptr, "no owning molecule for bond"); - setEndAtomIdx(at->getIdx()); -} Atom *Bond::getBeginAtom() const { PRECONDITION(dp_mol != nullptr, "no owning molecule for bond"); @@ -181,10 +172,6 @@ double Bond::getBondTypeAsDouble() const { } } -double Bond::getValenceContrib(Atom::ATOM_SPTR at) const { - return getValenceContrib(at.get()); -} - double Bond::getValenceContrib(const Atom *atom) const { switch (getBondType()) { case UNSPECIFIED: @@ -275,10 +262,6 @@ bool Bond::Match(Bond const *what) const { return res; }; -bool Bond::Match(const Bond::BOND_SPTR what) const { - return Match(what.get()); -}; - void Bond::expandQuery(Bond::QUERYBOND_QUERY *what, Queries::CompositeQueryType how, bool maintainOrder) { RDUNUSED_PARAM(what); diff --git a/Code/GraphMol/Bond.h b/Code/GraphMol/Bond.h index 6dd27894d..865ff23ad 100644 --- a/Code/GraphMol/Bond.h +++ b/Code/GraphMol/Bond.h @@ -25,7 +25,6 @@ namespace RDKit { class ROMol; class RWMol; class Atom; -typedef boost::shared_ptr ATOM_SPTR; //! class for representing a bond /*! @@ -49,7 +48,6 @@ class Bond : public RDProps { friend class ROMol; public: - typedef boost::shared_ptr BOND_SPTR; // FIX: grn... typedef Queries::Query QUERYBOND_QUERY; @@ -132,8 +130,6 @@ class Bond : public RDProps { - requires an owning molecule */ double getValenceContrib(const Atom *at) const; - // \overload - double getValenceContrib(ATOM_SPTR at) const; //! sets our \c isAromatic flag void setIsAromatic(bool what) { df_isAromatic = what; }; @@ -210,16 +206,12 @@ class Bond : public RDProps { - requires an owning molecule */ void setBeginAtom(Atom *at); - //! \overload - void setBeginAtom(ATOM_SPTR at); //! sets our end Atom /*! Notes: - requires an owning molecule */ void setEndAtom(Atom *at); - //! \overload - void setEndAtom(ATOM_SPTR at); //! returns a pointer to our begin Atom /*! @@ -268,8 +260,6 @@ class Bond : public RDProps { same \c bondType. */ virtual bool Match(Bond const *what) const; - //! \overload - virtual bool Match(const Bond::BOND_SPTR what) const; //! sets our direction void setBondDir(BondDir what) { d_dirTag = what; }; diff --git a/Code/GraphMol/BondIterators.cpp b/Code/GraphMol/BondIterators.cpp index 597f197d7..d43bf69bb 100644 --- a/Code/GraphMol/BondIterators.cpp +++ b/Code/GraphMol/BondIterators.cpp @@ -45,7 +45,7 @@ bool BondIterator_::operator!=(const BondIterator_ &other) const { return _mol != other._mol || _pos != other._pos; } -Bond *BondIterator_::operator*() const { return (*_mol)[*_pos].get(); } +Bond *BondIterator_::operator*() const { return (*_mol)[*_pos]; } // pre-increment BondIterator_ &BondIterator_::operator++() { PRECONDITION(_pos != _end, "bad initial position") @@ -109,7 +109,7 @@ bool ConstBondIterator_::operator!=(const ConstBondIterator_ &other) const { } Bond const *ConstBondIterator_::operator*() const { - return (*_mol)[*_pos].get(); + return (*_mol)[*_pos]; } // pre-increment ConstBondIterator_ &ConstBondIterator_::operator++() { diff --git a/Code/GraphMol/CMakeLists.txt b/Code/GraphMol/CMakeLists.txt index 7ba486faf..7e3e06add 100644 --- a/Code/GraphMol/CMakeLists.txt +++ b/Code/GraphMol/CMakeLists.txt @@ -122,3 +122,5 @@ rdkit_test(resMolSupplierTest resMolSupplierTest.cpp rdkit_test(molBundleTest testMolBundle.cpp LINK_LIBRARIES SmilesParse GraphMol RDGeometryLib RDGeneral SubstructMatch FileParsers) + +rdkit_test(test-valgrind test-valgrind.cpp LINK_LIBRARIES FileParsers SmilesParse GraphMol RDGeometryLib RDGeneral SubstructMatch ForceFieldHelpers ForceField) diff --git a/Code/GraphMol/Canon.cpp b/Code/GraphMol/Canon.cpp index ee4ebcff7..920012bba 100644 --- a/Code/GraphMol/Canon.cpp +++ b/Code/GraphMol/Canon.cpp @@ -87,17 +87,17 @@ void canonicalizeDoubleBond(Bond *dblBond, INT_VECT &bondVisitOrders, bool dir1Set = false, dir2Set = false; atomBonds = mol.getAtomBonds(atom1); while (atomBonds.first != atomBonds.second) { - if (mol[*atomBonds.first].get() != dblBond) { + if (mol[*atomBonds.first] != dblBond) { int bondIdx = mol[*atomBonds.first]->getIdx(); if (bondDirCounts[bondIdx] > 0) { dir1Set = true; } if (!firstFromAtom1 || bondVisitOrders[bondIdx] < firstVisitOrder) { if (firstFromAtom1) secondFromAtom1 = firstFromAtom1; - firstFromAtom1 = mol[*atomBonds.first].get(); + firstFromAtom1 = mol[*atomBonds.first]; firstVisitOrder = bondVisitOrders[bondIdx]; } else { - secondFromAtom1 = mol[*atomBonds.first].get(); + secondFromAtom1 = mol[*atomBonds.first]; } } atomBonds.first++; @@ -105,17 +105,17 @@ void canonicalizeDoubleBond(Bond *dblBond, INT_VECT &bondVisitOrders, atomBonds = mol.getAtomBonds(atom2); firstVisitOrder = 10000; while (atomBonds.first != atomBonds.second) { - if (mol[*atomBonds.first].get() != dblBond) { + if (mol[*atomBonds.first] != dblBond) { int bondIdx = mol[*atomBonds.first]->getIdx(); if (bondDirCounts[bondIdx] > 0) { dir2Set = true; } if (!firstFromAtom2 || bondVisitOrders[bondIdx] < firstVisitOrder) { if (firstFromAtom2) secondFromAtom2 = firstFromAtom2; - firstFromAtom2 = mol[*atomBonds.first].get(); + firstFromAtom2 = mol[*atomBonds.first]; firstVisitOrder = bondVisitOrders[bondIdx]; } else { - secondFromAtom2 = mol[*atomBonds.first].get(); + secondFromAtom2 = mol[*atomBonds.first]; } } atomBonds.first++; @@ -425,7 +425,7 @@ void canonicalizeDoubleBond(Bond *dblBond, INT_VECT &bondVisitOrders, bool dblBondPresent = false; atomBonds = mol.getAtomBonds(atom3); while (atomBonds.first != atomBonds.second) { - Bond *tbond = mol[*atomBonds.first].get(); + Bond *tbond = mol[*atomBonds.first]; if (tbond->getBondType() == Bond::DOUBLE && tbond->getStereo() > Bond::STEREOANY) { dblBondPresent = true; @@ -466,7 +466,7 @@ void dfsFindCycles(ROMol &mol, int atomIdx, int inBondIdx, possibles.reserve(bondsPair.second - bondsPair.first); while (bondsPair.first != bondsPair.second) { - BOND_SPTR theBond = mol[*(bondsPair.first)]; + Bond* theBond = mol[*(bondsPair.first)]; bondsPair.first++; if (bondsInPlay && !(*bondsInPlay)[theBond->getIdx()]) continue; if (inBondIdx < 0 || @@ -516,7 +516,7 @@ void dfsFindCycles(ROMol &mol, int atomIdx, int inBondIdx, // std::cerr<<"aIdx: "<< atomIdx <<" p: "<getBondType()<<" "<getIdx()]) continue; if (inBondIdx < 0 || @@ -674,7 +674,7 @@ void dfsBuildStack(ROMol &mol, int atomIdx, int inBondIdx, } // std::cerr<<" p: "<getBondType()<<" "<>"<getIdx()<<" "<getIdx()]<<"-"<getIdx()]<<" // "<getBeginAtomIdx()]<<"-"<getEndAtomIdx()]<getBondType() == Bond::DOUBLE && mol[*beg]->getStereo() > Bond::STEREOANY) { dblBondAtom = @@ -866,7 +866,7 @@ void removeRedundantBondDirSpecs(ROMol &mol, MolStack &molStack, dblBondAtom = nullptr; boost::tie(beg, end) = mol.getAtomBonds(canonEndAtom); while (beg != end) { - if (mol[*beg].get() != tBond && + if (mol[*beg] != tBond && mol[*beg]->getBondType() == Bond::DOUBLE && mol[*beg]->getStereo() > Bond::STEREOANY) { dblBondAtom = canonEndAtom; // tBond->getOtherAtom(canonEndAtom); diff --git a/Code/GraphMol/ChemReactions/MoleculeParser.cpp b/Code/GraphMol/ChemReactions/MoleculeParser.cpp index db59fe481..45050a7bf 100644 --- a/Code/GraphMol/ChemReactions/MoleculeParser.cpp +++ b/Code/GraphMol/ChemReactions/MoleculeParser.cpp @@ -41,7 +41,7 @@ namespace { bool testForSameRXNRoleOfAllMoleculeAtoms(const RDKit::ROMol &mol, int role) { RDKit::ROMol::ATOM_ITER_PAIR atItP = mol.getVertices(); while (atItP.first != atItP.second) { - const RDKit::Atom *oAtom = mol[*(atItP.first++)].get(); + const RDKit::Atom *oAtom = mol[*(atItP.first++)]; int current_role; if (oAtom->getPropIfPresent(RDKit::common_properties::molRxnRole, current_role) && @@ -55,7 +55,7 @@ bool testForSameRXNRoleOfAllMoleculeAtoms(const RDKit::ROMol &mol, int role) { int getRXNRoleOfMolecule(const RDKit::ROMol &mol) { RDKit::ROMol::ATOM_ITER_PAIR atItP = mol.getVertices(); while (atItP.first != atItP.second) { - const RDKit::Atom *oAtom = mol[*(atItP.first++)].get(); + const RDKit::Atom *oAtom = mol[*(atItP.first++)]; int molRxnRole; if (oAtom->getPropIfPresent(RDKit::common_properties::molRxnRole, molRxnRole)) { diff --git a/Code/GraphMol/ChemReactions/Reaction.cpp b/Code/GraphMol/ChemReactions/Reaction.cpp index c8be9a58a..0e4a164d3 100644 --- a/Code/GraphMol/ChemReactions/Reaction.cpp +++ b/Code/GraphMol/ChemReactions/Reaction.cpp @@ -479,7 +479,7 @@ bool isChangedAtom(const Atom &rAtom, const Atom &pAtom, int mapNum, ROMol::ADJ_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = rAtom.getOwningMol().getAtomNeighbors(&rAtom); while (nbrIdx != endNbrs) { - const ATOM_SPTR nbr = rAtom.getOwningMol()[*nbrIdx]; + const Atom *nbr = rAtom.getOwningMol()[*nbrIdx]; int mapNum; if (nbr->getPropIfPresent(common_properties::molAtomMapNumber, mapNum)) { reactantBonds[mapNum] = rAtom.getOwningMol().getBondBetweenAtoms( @@ -492,7 +492,7 @@ bool isChangedAtom(const Atom &rAtom, const Atom &pAtom, int mapNum, } boost::tie(nbrIdx, endNbrs) = pAtom.getOwningMol().getAtomNeighbors(&pAtom); while (nbrIdx != endNbrs) { - const ATOM_SPTR nbr = pAtom.getOwningMol()[*nbrIdx]; + const Atom * nbr = pAtom.getOwningMol()[*nbrIdx]; int mapNum; if (nbr->getPropIfPresent(common_properties::molAtomMapNumber, mapNum)) { // if we don't have a bond to a similarly mapped atom in the reactant, @@ -560,7 +560,7 @@ template bool getMappedAtoms(T &rIt, std::map &mappedAtoms) { ROMol::ATOM_ITER_PAIR atItP = rIt->getVertices(); while (atItP.first != atItP.second) { - const Atom *oAtom = (*rIt)[*(atItP.first++)].get(); + const Atom *oAtom = (*rIt)[*(atItP.first++)]; // we only worry about mapped atoms: int mapNum; if (oAtom->getPropIfPresent(common_properties::molAtomMapNumber, mapNum)) { @@ -597,7 +597,7 @@ VECT_INT_VECT getReactingAtoms(const ChemicalReaction &rxn, rIt != rxn.endReactantTemplates(); ++rIt, ++resIt) { ROMol::ATOM_ITER_PAIR atItP = (*rIt)->getVertices(); while (atItP.first != atItP.second) { - const Atom *oAtom = (**rIt)[*(atItP.first++)].get(); + const Atom *oAtom = (**rIt)[*(atItP.first++)]; // unmapped atoms are definitely changing: int mapNum; if (!oAtom->getPropIfPresent(common_properties::molAtomMapNumber, diff --git a/Code/GraphMol/ChemReactions/ReactionRunner.cpp b/Code/GraphMol/ChemReactions/ReactionRunner.cpp index 0376966ac..56d4e2d7a 100644 --- a/Code/GraphMol/ChemReactions/ReactionRunner.cpp +++ b/Code/GraphMol/ChemReactions/ReactionRunner.cpp @@ -191,7 +191,7 @@ RWMOL_SPTR convertTemplateToMol(const ROMOL_SPTR prodTemplateSptr) { // copy in the atoms: ROMol::ATOM_ITER_PAIR atItP = prodTemplate->getVertices(); while (atItP.first != atItP.second) { - Atom *oAtom = (*prodTemplate)[*(atItP.first++)].get(); + const Atom *oAtom = (*prodTemplate)[*(atItP.first++)]; auto *newAtom = new Atom(*oAtom); res->addAtom(newAtom, false, true); int mapNum; @@ -234,7 +234,7 @@ RWMOL_SPTR convertTemplateToMol(const ROMOL_SPTR prodTemplateSptr) { // and the bonds: ROMol::BOND_ITER_PAIR bondItP = prodTemplate->getEdges(); while (bondItP.first != bondItP.second) { - const BOND_SPTR oldB = (*prodTemplate)[*(bondItP.first++)]; + const Bond* oldB = (*prodTemplate)[*(bondItP.first++)]; unsigned int bondIdx; bondIdx = res->addBond(oldB->getBeginAtomIdx(), oldB->getEndAtomIdx(), oldB->getBondType()) - @@ -300,7 +300,7 @@ ReactantProductAtomMapping *getAtomMappingsReactantProduct( ROMol::EDGE_ITER firstB, lastB; boost::tie(firstB, lastB) = reactantTemplate.getEdges(); while (firstB != lastB) { - BOND_SPTR bond = reactantTemplate[*firstB]; + const Bond* bond = reactantTemplate[*firstB]; // this will put in pairs with 0s for things that aren't mapped, but we // don't care about that int a1mapidx = bond->getBeginAtom()->getAtomMapNum(); @@ -345,7 +345,7 @@ void setReactantBondPropertiesToProduct(RWMOL_SPTR product, ReactantProductAtomMapping *mapping) { ROMol::BOND_ITER_PAIR bondItP = product->getEdges(); while (bondItP.first != bondItP.second) { - BOND_SPTR pBond = (*product)[*(bondItP.first)]; + Bond* pBond = (*product)[*(bondItP.first)]; ++bondItP.first; if (pBond->hasProp(common_properties::NullBond)) { if (mapping->prodReactAtomMap.find(pBond->getBeginAtomIdx()) != @@ -734,7 +734,7 @@ void checkAndCorrectChiralityOfProduct( boost::tie(beg, end) = reactantAtom->getOwningMol().getAtomBonds(reactantAtom); while (beg != end) { - const BOND_SPTR reactantBond = reactantAtom->getOwningMol()[*beg]; + const Bond* reactantBond = reactantAtom->getOwningMol()[*beg]; unsigned int oAtomIdx = reactantBond->getOtherAtomIdx(reactantAtom->getIdx()); CHECK_INVARIANT(mapping->reactProdAtomMap.find(oAtomIdx) != diff --git a/Code/GraphMol/ChemReactions/ReactionWriter.cpp b/Code/GraphMol/ChemReactions/ReactionWriter.cpp index e4e62e2f3..ebbc481e5 100644 --- a/Code/GraphMol/ChemReactions/ReactionWriter.cpp +++ b/Code/GraphMol/ChemReactions/ReactionWriter.cpp @@ -44,7 +44,7 @@ namespace { void setRXNRoleOfAllMoleculeAtoms(RDKit::ROMol &mol, int role) { RDKit::ROMol::ATOM_ITER_PAIR atItP = mol.getVertices(); while (atItP.first != atItP.second) { - RDKit::Atom *oAtom = mol[*(atItP.first++)].get(); + RDKit::Atom *oAtom = mol[*(atItP.first++)]; oAtom->setProp(RDKit::common_properties::molRxnRole, role); } } diff --git a/Code/GraphMol/ChemTransforms/ChemTransforms.cpp b/Code/GraphMol/ChemTransforms/ChemTransforms.cpp index d2a7bc3d4..2254bc0c3 100644 --- a/Code/GraphMol/ChemTransforms/ChemTransforms.cpp +++ b/Code/GraphMol/ChemTransforms/ChemTransforms.cpp @@ -523,7 +523,7 @@ ROMol *replaceCore(const ROMol &mol, const ROMol &core, } ROMol *MurckoDecompose(const ROMol &mol) { - auto *res = new RWMol(mol); + RWMol *res = new RWMol(mol); unsigned int nAtoms = res->getNumAtoms(); if (!nAtoms) return res; @@ -568,7 +568,7 @@ ROMol *MurckoDecompose(const ROMol &mol) { ROMol::ADJ_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = res->getAtomNeighbors(atom); while (nbrIdx != endNbrs) { - const ATOM_SPTR nbr = (*res)[*nbrIdx]; + Atom *nbr = (*res)[*nbrIdx]; if (keepAtoms[nbr->getIdx()]) { if (res->getBondBetweenAtoms(atom->getIdx(), nbr->getIdx()) ->getBondType() == Bond::DOUBLE) { @@ -648,7 +648,7 @@ void addRecursiveQueries( ROMol::VERTEX_ITER atBegin, atEnd; boost::tie(atBegin, atEnd) = mol.getVertices(); while (atBegin != atEnd) { - Atom *at = mol[*atBegin].get(); + Atom *at = mol[*atBegin]; ++atBegin; if (!at->hasProp(propName)) continue; std::string pval; diff --git a/Code/GraphMol/ChemTransforms/MolFragmenter.cpp b/Code/GraphMol/ChemTransforms/MolFragmenter.cpp index 005da6ebe..4655be66d 100644 --- a/Code/GraphMol/ChemTransforms/MolFragmenter.cpp +++ b/Code/GraphMol/ChemTransforms/MolFragmenter.cpp @@ -360,9 +360,9 @@ void checkChiralityPostMove(const ROMol &mol, const Atom *oAt, Atom *nAt, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(oAt); while (beg != end) { - const BOND_SPTR obond = mol[*beg]; + const Bond* obond = mol[*beg]; ++beg; - if (obond.get() == bond) { + if (obond == bond) { continue; } newOrder.push_back(obond->getIdx()); diff --git a/Code/GraphMol/Chirality.cpp b/Code/GraphMol/Chirality.cpp index 3a2bdb07a..3d10dd989 100644 --- a/Code/GraphMol/Chirality.cpp +++ b/Code/GraphMol/Chirality.cpp @@ -191,12 +191,12 @@ void iterateCIPRanks(const ROMol &mol, DOUBLE_VECT &invars, UINT_VECT &ranks, // start by pushing on our neighbors' ranks: ROMol::OEDGE_ITER beg, end; - boost::tie(beg, end) = mol.getAtomBonds(mol[index].get()); + boost::tie(beg, end) = mol.getAtomBonds(mol[index]); while (beg != end) { - const Bond *bond = mol[*beg].get(); + const Bond *bond = mol[*beg]; ++beg; unsigned int nbrIdx = bond->getOtherAtomIdx(index); - const Atom *nbr = mol[nbrIdx].get(); + const Atom *nbr = mol[nbrIdx]; int rank = ranks[nbrIdx] + 1; // put the neighbor in 2N times where N is the bond order as a double. @@ -316,7 +316,7 @@ void findAtomNeighborDirHelper(const ROMol &mol, const Atom *atom, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(atom); while (beg != end) { - const BOND_SPTR bond = mol[*beg]; + const Bond* bond = mol[*beg]; // check whether this bond is explictly set to have unknown stereo if (!hasExplicitUnknownStereo) { int explicit_unknown_stereo; @@ -386,7 +386,7 @@ void findAtomNeighborsHelper(const ROMol &mol, const Atom *atom, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(atom); while (beg != end) { - const BOND_SPTR bond = mol[*beg]; + const Bond* bond = mol[*beg]; Bond::BondDir dir = bond->getBondDir(); if (bond->getBondType() == Bond::SINGLE && bond->getIdx() != refBond->getIdx()) { @@ -422,7 +422,7 @@ bool atomIsCandidateForRingStereochem(const ROMol &mol, const Atom *atom) { std::vector nonRingNbrs; std::vector ringNbrs; while (beg != end) { - const BOND_SPTR bond = mol[*beg]; + const Bond* bond = mol[*beg]; if (!ringInfo->numBondRings(bond->getIdx())) { nonRingNbrs.push_back(bond->getOtherAtom(atom)); } else { @@ -924,7 +924,7 @@ void rerankAtoms(const ROMol &mol, UINT_VECT &ranks) { ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(atom); while (beg != end) { - const BOND_SPTR oBond = mol[*beg]; + const Bond* oBond = mol[*beg]; if (oBond->getBondType() == Bond::DOUBLE) { if (oBond->getStereo() == Bond::STEREOE) { invars[i] += 1; @@ -1016,7 +1016,7 @@ void assignStereochemistry(ROMol &mol, bool cleanIt, bool force, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds((*bondIt)->getBeginAtom()); while (!hasStereoBonds && beg != end) { - const BOND_SPTR nbond = mol[*beg]; + const Bond* nbond = mol[*beg]; ++beg; if (nbond->getBondDir() == Bond::ENDDOWNRIGHT || nbond->getBondDir() == Bond::ENDUPRIGHT) { @@ -1025,7 +1025,7 @@ void assignStereochemistry(ROMol &mol, bool cleanIt, bool force, } boost::tie(beg, end) = mol.getAtomBonds((*bondIt)->getEndAtom()); while (!hasStereoBonds && beg != end) { - const BOND_SPTR nbond = mol[*beg]; + const Bond* nbond = mol[*beg]; ++beg; if (nbond->getBondDir() == Bond::ENDDOWNRIGHT || nbond->getBondDir() == Bond::ENDUPRIGHT) { @@ -1372,7 +1372,7 @@ void setBondDirRelativeToAtom(Bond *bond, Atom *atom, Bond::BondDir dir, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = oAtom->getOwningMol().getAtomBonds(oAtom); while (beg != end) { - Bond *nbrBond = oAtom->getOwningMol()[*beg].get(); + Bond *nbrBond = oAtom->getOwningMol()[*beg]; ++beg; if (nbrBond != bond && nbrBond->getBondType() != Bond::DOUBLE && needsDir[nbrBond->getIdx()]) { @@ -1425,7 +1425,7 @@ void updateDoubleBondNeighbors(ROMol &mol, Bond *dblBond, const Conformer &conf, bool squiggleBondSeen = false; boost::tie(beg, end) = mol.getAtomBonds(dblBond->getBeginAtom()); while (beg != end) { - Bond *tBond = mol[*beg].get(); + Bond *tBond = mol[*beg]; if (tBond->getBondType() == Bond::SINGLE || tBond->getBondType() == Bond::AROMATIC) { // prefer bonds that already have their directionality set @@ -1463,7 +1463,7 @@ void updateDoubleBondNeighbors(ROMol &mol, Bond *dblBond, const Conformer &conf, Bond *bond2 = nullptr, *obond2 = nullptr; boost::tie(beg, end) = mol.getAtomBonds(dblBond->getEndAtom()); while (beg != end) { - Bond *tBond = mol[*beg].get(); + Bond *tBond = mol[*beg]; if (tBond->getBondType() == Bond::SINGLE || tBond->getBondType() == Bond::AROMATIC) { if (!bond2) { @@ -1703,7 +1703,7 @@ void detectBondStereochemistry(ROMol &mol, int confId) { ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(a1); while (beg != end) { - const Bond *nbrBond = mol[*beg].get(); + const Bond *nbrBond = mol[*beg]; if (nbrBond->getBondType() == Bond::SINGLE || nbrBond->getBondType() == Bond::AROMATIC) { singleBondCounts[nbrBond->getIdx()] += 1; @@ -1724,7 +1724,7 @@ void detectBondStereochemistry(ROMol &mol, int confId) { } boost::tie(beg, end) = mol.getAtomBonds(a2); while (beg != end) { - const Bond *nbrBond = mol[*beg].get(); + const Bond *nbrBond = mol[*beg]; if (nbrBond->getBondType() == Bond::SINGLE || nbrBond->getBondType() == Bond::AROMATIC) { singleBondCounts[nbrBond->getIdx()] += 1; diff --git a/Code/GraphMol/ConjugHybrid.cpp b/Code/GraphMol/ConjugHybrid.cpp index be935c04d..5d5d438e0 100644 --- a/Code/GraphMol/ConjugHybrid.cpp +++ b/Code/GraphMol/ConjugHybrid.cpp @@ -83,7 +83,7 @@ int numBondsPlusLonePairs(Atom *at) { ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = at->getOwningMol().getAtomBonds(at); while (beg != end) { - BOND_SPTR bond = at->getOwningMol()[*beg]; + Bond* bond = at->getOwningMol()[*beg]; if (bond->getBondType() == Bond::ZERO) --deg; ++beg; } diff --git a/Code/GraphMol/Depictor/EmbeddedFrag.cpp b/Code/GraphMol/Depictor/EmbeddedFrag.cpp index 2ce0135ec..6823e53c2 100644 --- a/Code/GraphMol/Depictor/EmbeddedFrag.cpp +++ b/Code/GraphMol/Depictor/EmbeddedFrag.cpp @@ -1613,7 +1613,7 @@ void _recurseDegTwoRingAtoms(unsigned int aid, const RDKit::ROMol *mol, int bondId; RDKit::INT_VECT nbrs; while (atomBonds.first != atomBonds.second) { - const RDKit::BOND_SPTR bnd = (*mol)[*atomBonds.first]; + const RDKit::Bond* bnd = (*mol)[*atomBonds.first]; bondId = bnd->getIdx(); if (mol->getRingInfo()->numBondRings(bondId)) { nbrs.push_back(bnd->getOtherAtomIdx(aid)); diff --git a/Code/GraphMol/Descriptors/ConnectivityDescriptors.cpp b/Code/GraphMol/Descriptors/ConnectivityDescriptors.cpp index 543ffbe01..9c444e567 100644 --- a/Code/GraphMol/Descriptors/ConnectivityDescriptors.cpp +++ b/Code/GraphMol/Descriptors/ConnectivityDescriptors.cpp @@ -29,7 +29,7 @@ void hkDeltas(const ROMol &mol, std::vector &deltas, bool force) { ROMol::VERTEX_ITER atBegin, atEnd; boost::tie(atBegin, atEnd) = mol.getVertices(); while (atBegin != atEnd) { - ATOM_SPTR at = mol[*atBegin]; + const Atom* at = mol[*atBegin]; unsigned int n = at->getAtomicNum(); if (n <= 1) { deltas[at->getIdx()] = 0; @@ -57,7 +57,7 @@ void nVals(const ROMol &mol, std::vector &nVs, bool force) { ROMol::VERTEX_ITER atBegin, atEnd; boost::tie(atBegin, atEnd) = mol.getVertices(); while (atBegin != atEnd) { - ATOM_SPTR at = mol[*atBegin]; + const Atom* at = mol[*atBegin]; double v = tbl->getNouterElecs(at->getAtomicNum()) - at->getTotalNumHs(); if (v != 0.0) { v = 1. / sqrt(v); @@ -219,7 +219,7 @@ double calcChi1v(const ROMol &mol, bool force) { ROMol::EDGE_ITER firstB, lastB; boost::tie(firstB, lastB) = mol.getEdges(); while (firstB != lastB) { - BOND_SPTR bond = mol[*firstB]; + const Bond* bond = mol[*firstB]; res += hkDs[bond->getBeginAtomIdx()] * hkDs[bond->getEndAtomIdx()]; ++firstB; } @@ -248,7 +248,7 @@ double calcChi1n(const ROMol &mol, bool force) { ROMol::EDGE_ITER firstB, lastB; boost::tie(firstB, lastB) = mol.getEdges(); while (firstB != lastB) { - BOND_SPTR bond = mol[*firstB]; + const Bond* bond = mol[*firstB]; res += nVs[bond->getBeginAtomIdx()] * nVs[bond->getEndAtomIdx()]; ++firstB; } @@ -273,12 +273,12 @@ double calcHallKierAlpha(const ROMol &mol, std::vector *atomContribs) { ROMol::VERTEX_ITER atBegin, atEnd; boost::tie(atBegin, atEnd) = mol.getVertices(); while (atBegin != atEnd) { - ATOM_SPTR at = mol[*atBegin]; + const Atom* at = mol[*atBegin]; ++atBegin; unsigned int n = at->getAtomicNum(); if (!n) continue; bool found; - double alpha = detail::getAlpha(*(at.get()), found); + double alpha = detail::getAlpha(*(at), found); if (!found) { double rA = tbl->getRb0(n); alpha = rA / rC - 1.0; diff --git a/Code/GraphMol/Descriptors/Lipinski.cpp b/Code/GraphMol/Descriptors/Lipinski.cpp index 6b642658f..2f870189e 100644 --- a/Code/GraphMol/Descriptors/Lipinski.cpp +++ b/Code/GraphMol/Descriptors/Lipinski.cpp @@ -203,7 +203,7 @@ double calcFractionCSP3(const ROMol &mol) { ROMol::VERTEX_ITER atBegin, atEnd; boost::tie(atBegin, atEnd) = mol.getVertices(); while (atBegin != atEnd) { - ATOM_SPTR at = mol[*atBegin]; + const Atom* at = mol[*atBegin]; if (at->getAtomicNum() == 6) { ++nC; if (at->getTotalDegree() == 4) { diff --git a/Code/GraphMol/Descriptors/MQN.cpp b/Code/GraphMol/Descriptors/MQN.cpp index 5a7c48121..ce032e9a0 100644 --- a/Code/GraphMol/Descriptors/MQN.cpp +++ b/Code/GraphMol/Descriptors/MQN.cpp @@ -32,7 +32,7 @@ std::vector calcMQNs(const ROMol &mol, bool force) { ROMol::VERTEX_ITER atBegin, atEnd; boost::tie(atBegin, atEnd) = mol.getVertices(); while (atBegin != atEnd) { - const ATOM_SPTR at = mol[*atBegin]; + const Atom* at = mol[*atBegin]; ++atBegin; unsigned int nHs = at->getTotalNumHs(); unsigned int nRings = mol.getRingInfo()->numAtomRings(at->getIdx()); @@ -135,7 +135,7 @@ std::vector calcMQNs(const ROMol &mol, bool force) { ROMol::EDGE_ITER firstB, lastB; boost::tie(firstB, lastB) = mol.getEdges(); while (firstB != lastB) { - const BOND_SPTR bond = mol[*firstB]; + const Bond* bond = mol[*firstB]; if (bond->getIsAromatic()) ++nAromatic; unsigned int nRings = mol.getRingInfo()->numBondRings(bond->getIdx()); switch (bond->getBondType()) { diff --git a/Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp b/Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp index d3fcf7e07..bf8c3cc96 100644 --- a/Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp +++ b/Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp @@ -443,12 +443,12 @@ void set13Bounds(const ROMol &mol, DistGeom::BoundsMatPtr mmat, // system while (beg1 != end1) { - const BOND_SPTR bnd1 = mol[*beg1]; + const Bond* bnd1 = mol[*beg1]; bid1 = bnd1->getIdx(); aid1 = bnd1->getOtherAtomIdx(aid2); boost::tie(beg2, end2) = mol.getAtomBonds(atom); while (beg2 != beg1) { - const BOND_SPTR bnd2 = mol[*beg2]; + const Bond* bnd2 = mol[*beg2]; bid2 = bnd2->getIdx(); // invar = firstThousandPrimes[bid1]*firstThousandPrimes[bid2]; if (accumData.bondAngles->getVal(bid1, bid2) < 0.0) { @@ -499,12 +499,12 @@ void set13Bounds(const ROMol &mol, DistGeom::BoundsMatPtr mmat, } else if (visited[aid2] == 0) { // non-ring atoms - we will simply use angles based on hydridization while (beg1 != end1) { - const BOND_SPTR bnd1 = mol[*beg1]; + const Bond* bnd1 = mol[*beg1]; bid1 = bnd1->getIdx(); aid1 = bnd1->getOtherAtomIdx(aid2); boost::tie(beg2, end2) = mol.getAtomBonds(atom); while (beg2 != beg1) { - const BOND_SPTR bnd2 = mol[*beg2]; + const Bond* bnd2 = mol[*beg2]; bid2 = bnd2->getIdx(); if (ahyb == Atom::SP) { angle = M_PI; @@ -1171,12 +1171,12 @@ void set14Bounds(const ROMol &mol, DistGeom::BoundsMatPtr mmat, aid3 = (*bi)->getEndAtomIdx(); boost::tie(beg1, end1) = mol.getAtomBonds(mol.getAtomWithIdx(aid2)); while (beg1 != end1) { - const Bond *bnd1 = mol[*beg1].get(); + const Bond *bnd1 = mol[*beg1]; bid1 = bnd1->getIdx(); if (bid1 != bid2) { boost::tie(beg2, end2) = mol.getAtomBonds(mol.getAtomWithIdx(aid3)); while (beg2 != end2) { - const Bond *bnd3 = mol[*beg2].get(); + const Bond *bnd3 = mol[*beg2]; bid3 = bnd3->getIdx(); if (bid3 != bid2) { id1 = nb * nb * bid1 + nb * bid2 + bid3; diff --git a/Code/GraphMol/FileParsers/MolFileStereochem.cpp b/Code/GraphMol/FileParsers/MolFileStereochem.cpp index 6bab35aaf..c9e78398a 100644 --- a/Code/GraphMol/FileParsers/MolFileStereochem.cpp +++ b/Code/GraphMol/FileParsers/MolFileStereochem.cpp @@ -89,7 +89,7 @@ Atom::ChiralType FindAtomStereochemistry(const RWMol &mol, const Bond *bond, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(atom); while (beg != end) { - Bond *nbrBond = mol[*beg].get(); + const Bond *nbrBond = mol[*beg]; if (nbrBond->getBondType() != Bond::SINGLE) { allSingle = false; // break; @@ -404,7 +404,7 @@ INT_MAP_INT pickBondsToWedge(const ROMol &mol) { ROMol::ADJ_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(at); while (nbrIdx != endNbrs) { - const ATOM_SPTR nat = mol[*nbrIdx]; + const Atom* nat = mol[*nbrIdx]; ++nbrIdx; if (nat->getAtomicNum() == 1) { // special case: it's an H... we weight these especially high: @@ -457,7 +457,7 @@ INT_MAP_INT pickBondsToWedge(const ROMol &mol) { RDKit::ROMol::OBOND_ITER_PAIR atomBonds = mol.getAtomBonds(atom); std::vector> nbrScores; while (atomBonds.first != atomBonds.second) { - const Bond *bond = mol[*atomBonds.first].get(); + const Bond *bond = mol[*atomBonds.first]; ++atomBonds.first; // can only wedge single bonds: @@ -564,7 +564,7 @@ Bond::BondDir DetermineBondWedgeState(const Bond *bond, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol->getAtomBonds(atom); while (beg != end) { - Bond *nbrBond = (*mol)[*beg].get(); + const Bond *nbrBond = (*mol)[*beg]; Atom *otherAtom = nbrBond->getOtherAtom(atom); if (nbrBond != bond) { tmpPt = conf->getAtomPos(otherAtom->getIdx()); diff --git a/Code/GraphMol/FileParsers/MolFileStereochem.cpp.hold b/Code/GraphMol/FileParsers/MolFileStereochem.cpp.hold index 100a0edca..581888feb 100644 --- a/Code/GraphMol/FileParsers/MolFileStereochem.cpp.hold +++ b/Code/GraphMol/FileParsers/MolFileStereochem.cpp.hold @@ -401,7 +401,7 @@ INT_MAP_INT pickBondsToWedge(const ROMol &mol) { ROMol::ADJ_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(at); while (nbrIdx != endNbrs) { - const ATOM_SPTR nat = mol[*nbrIdx]; + const Atom* nat = mol[*nbrIdx]; ++nbrIdx; if (nat->getAtomicNum() == 1) { // special case: it's an H... we weight these especially high: diff --git a/Code/GraphMol/FileParsers/MolFileWriter.cpp b/Code/GraphMol/FileParsers/MolFileWriter.cpp index cbc01b6cd..3a7405edd 100644 --- a/Code/GraphMol/FileParsers/MolFileWriter.cpp +++ b/Code/GraphMol/FileParsers/MolFileWriter.cpp @@ -776,7 +776,7 @@ void GetMolFileBondStereoInfo(const Bond *bond, const INT_MAP_INT &wedgeBonds, boost::tie(beg, end) = bond->getOwningMol().getAtomBonds(bond->getBeginAtom()); while (beg != end && !nbrHasDir) { - const BOND_SPTR nbrBond = bond->getOwningMol()[*beg]; + const Bond* nbrBond = bond->getOwningMol()[*beg]; if (nbrBond->getBondType() == Bond::SINGLE && (nbrBond->getBondDir() == Bond::ENDUPRIGHT || nbrBond->getBondDir() == Bond::ENDDOWNRIGHT)) { @@ -787,7 +787,7 @@ void GetMolFileBondStereoInfo(const Bond *bond, const INT_MAP_INT &wedgeBonds, boost::tie(beg, end) = bond->getOwningMol().getAtomBonds(bond->getEndAtom()); while (beg != end && !nbrHasDir) { - const BOND_SPTR nbrBond = bond->getOwningMol()[*beg]; + const Bond* nbrBond = bond->getOwningMol()[*beg]; if (nbrBond->getBondType() == Bond::SINGLE && (nbrBond->getBondDir() == Bond::ENDUPRIGHT || nbrBond->getBondDir() == Bond::ENDDOWNRIGHT)) { diff --git a/Code/GraphMol/FileParsers/PDBParser.cpp b/Code/GraphMol/FileParsers/PDBParser.cpp index c424c89a8..39035b0c4 100644 --- a/Code/GraphMol/FileParsers/PDBParser.cpp +++ b/Code/GraphMol/FileParsers/PDBParser.cpp @@ -457,7 +457,7 @@ void BasicPDBCleanup(RWMol &mol) { ROMol::VERTEX_ITER atBegin, atEnd; boost::tie(atBegin, atEnd) = mol.getVertices(); while (atBegin != atEnd) { - ATOM_SPTR atom = mol[*atBegin]; + Atom* atom = mol[*atBegin]; atom->calcExplicitValence(false); // correct four-valent neutral N -> N+ diff --git a/Code/GraphMol/FileParsers/PDBWriter.cpp b/Code/GraphMol/FileParsers/PDBWriter.cpp index 7671e4193..038b0eebb 100644 --- a/Code/GraphMol/FileParsers/PDBWriter.cpp +++ b/Code/GraphMol/FileParsers/PDBWriter.cpp @@ -147,7 +147,7 @@ std::string GetPDBBondLines(const Atom *atom, bool all, bool both, bool mult, ROMol *mol = &atom->getOwningMol(); for (ROMol::OBOND_ITER_PAIR bondIt = mol->getAtomBonds(atom); bondIt.first != bondIt.second; ++bondIt.first) { - Bond *bptr = (*mol)[*bondIt.first].get(); + Bond *bptr = (*mol)[*bondIt.first]; Atom *nptr = bptr->getOtherAtom(atom); unsigned int dst = nptr->getIdx() + 1; if (dst < src && !both) continue; diff --git a/Code/GraphMol/FileParsers/ProximityBonds.cpp b/Code/GraphMol/FileParsers/ProximityBonds.cpp index 174d62858..60ccde62d 100644 --- a/Code/GraphMol/FileParsers/ProximityBonds.cpp +++ b/Code/GraphMol/FileParsers/ProximityBonds.cpp @@ -370,9 +370,9 @@ static bool StandardPDBDoubleBond(RWMol *mol, Atom *beg, Atom *end) { // Check that neither end already has a double bond ROMol::OBOND_ITER_PAIR bp; for (bp = mol->getAtomBonds(beg); bp.first != bp.second; ++bp.first) - if ((*mol)[*bp.first].get()->getBondType() == Bond::DOUBLE) return false; + if ((*mol)[*bp.first]->getBondType() == Bond::DOUBLE) return false; for (bp = mol->getAtomBonds(end); bp.first != bp.second; ++bp.first) - if ((*mol)[*bp.first].get()->getBondType() == Bond::DOUBLE) return false; + if ((*mol)[*bp.first]->getBondType() == Bond::DOUBLE) return false; return true; } diff --git a/Code/GraphMol/FindRings.cpp b/Code/GraphMol/FindRings.cpp index 08a18e905..ac2a69fce 100644 --- a/Code/GraphMol/FindRings.cpp +++ b/Code/GraphMol/FindRings.cpp @@ -96,7 +96,7 @@ void markUselessD2s(unsigned int root, const ROMol &tMol, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = tMol.getAtomBonds(tMol.getAtomWithIdx(root)); while (beg != end) { - BOND_SPTR bond = tMol[*beg]; + const Bond* bond = tMol[*beg]; ++beg; if (!activeBonds[bond->getIdx()]) continue; unsigned int oIdx = bond->getOtherAtomIdx(root); @@ -585,7 +585,7 @@ void trimBonds(unsigned int cand, const ROMol &tMol, INT_SET &changed, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = tMol.getAtomBonds(tMol.getAtomWithIdx(cand)); while (beg != end) { - BOND_SPTR bond = tMol[*beg]; + const Bond* bond = tMol[*beg]; ++beg; if (!activeBonds[bond->getIdx()]) continue; unsigned int oIdx = bond->getOtherAtomIdx(cand); @@ -662,7 +662,7 @@ int smallestRingsBfs(const ROMol &mol, int root, VECT_INT_VECT &rings, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(mol.getAtomWithIdx(curr)); while (beg != end) { - BOND_SPTR bond = mol[*beg]; + const Bond* bond = mol[*beg]; ++beg; if (!activeBonds[bond->getIdx()]) continue; int nbrIdx = bond->getOtherAtomIdx(curr); @@ -865,7 +865,7 @@ int findSSSR(const ROMol &mol, VECT_INT_VECT &res) { ROMol::EDGE_ITER firstB, lastB; boost::tie(firstB, lastB) = mol.getEdges(); while (firstB != lastB) { - BOND_SPTR bond = mol[*firstB]; + const Bond* bond = mol[*firstB]; if (bond->getBondType() == Bond::ZERO) activeBonds[bond->getIdx()] = 0; ++firstB; } @@ -883,7 +883,7 @@ int findSSSR(const ROMol &mol, VECT_INT_VECT &res) { ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(atom); while (beg != end) { - BOND_SPTR bond = mol[*beg]; + const Bond* bond = mol[*beg]; if (bond->getBondType() == Bond::ZERO) atomDegrees[i]--; ++beg; } @@ -1222,7 +1222,7 @@ void _DFS(const ROMol &mol, const Atom *atom, INT_VECT &atomColors, ROMol::ADJ_ITER nbrIter, endNbrs; boost::tie(nbrIter, endNbrs) = mol.getAtomNeighbors(atom); while (nbrIter != endNbrs) { - const Atom *nbr = mol[*nbrIter].get(); + const Atom *nbr = mol[*nbrIter]; unsigned int nbrIdx = nbr->getIdx(); // std::cerr<<" "<getIdx()<<" consider: "<getIdx()] = 0x0; bondCache[bond->getIdx()]=bond; if(isComplexQuery(bond)){ @@ -639,7 +639,7 @@ ExplicitBitVect *LayeredFingerprintMol( ROMol::EDGE_ITER firstB, lastB; boost::tie(firstB, lastB) = mol.getEdges(); while (firstB != lastB) { - const Bond *bond = mol[*firstB].get(); + const Bond *bond = mol[*firstB]; isQueryBond[bond->getIdx()] = 0x0; bondCache[bond->getIdx()] = bond; if (isComplexQuery(bond)) { @@ -659,7 +659,7 @@ ExplicitBitVect *LayeredFingerprintMol( ROMol::VERTEX_ITER firstA, lastA; boost::tie(firstA, lastA) = mol.getVertices(); while (firstA != lastA) { - const Atom *atom = mol[*firstA].get(); + const Atom *atom = mol[*firstA]; if (isAtomAromatic(atom)) aromaticAtoms[atom->getIdx()] = true; anums[atom->getIdx()] = atom->getAtomicNum(); ++firstA; diff --git a/Code/GraphMol/Fingerprints/MorganFingerprints.cpp b/Code/GraphMol/Fingerprints/MorganFingerprints.cpp index e43391d44..7b9848cb8 100644 --- a/Code/GraphMol/Fingerprints/MorganFingerprints.cpp +++ b/Code/GraphMol/Fingerprints/MorganFingerprints.cpp @@ -261,7 +261,7 @@ void calcFingerprint(const ROMol &mol, unsigned int radius, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(tAtom); while (beg != end) { - const BOND_SPTR bond = mol[*beg]; + const Bond* bond = mol[*beg]; roundAtomNeighborhoods[atomIdx][bond->getIdx()] = 1; unsigned int oIdx = bond->getOtherAtomIdx(atomIdx); diff --git a/Code/GraphMol/Fingerprints/PatternFingerprints.cpp b/Code/GraphMol/Fingerprints/PatternFingerprints.cpp index 6dd0563df..e174dfc1c 100644 --- a/Code/GraphMol/Fingerprints/PatternFingerprints.cpp +++ b/Code/GraphMol/Fingerprints/PatternFingerprints.cpp @@ -197,7 +197,7 @@ ExplicitBitVect *PatternFingerprintMol(const ROMol &mol, unsigned int fpSize, ROMol::VERTEX_ITER firstA, lastA; boost::tie(firstA, lastA) = mol.getVertices(); while (firstA != lastA) { - const Atom *at = mol[*firstA].get(); + const Atom *at = mol[*firstA]; if (isComplexQuery(at)) { isQueryAtom.set(at->getIdx()); // std::cerr<<" complex atom: "<getIdx()<getIdx()); @@ -262,7 +262,7 @@ ExplicitBitVect *PatternFingerprintMol(const ROMol &mol, unsigned int fpSize, std::cerr << " bs:|| "; #endif while (!isQuery && firstB != lastB) { - BOND_SPTR pbond = (*patt)[*firstB]; + const Bond* pbond = (*patt)[*firstB]; ++firstB; const Bond *mbond = mol.getBondBetweenAtoms( amap[pbond->getBeginAtomIdx()], amap[pbond->getEndAtomIdx()]); diff --git a/Code/GraphMol/ForceFieldHelpers/CrystalFF/TorsionPreferences.cpp b/Code/GraphMol/ForceFieldHelpers/CrystalFF/TorsionPreferences.cpp index d6e0b9183..bab5d4341 100644 --- a/Code/GraphMol/ForceFieldHelpers/CrystalFF/TorsionPreferences.cpp +++ b/Code/GraphMol/ForceFieldHelpers/CrystalFF/TorsionPreferences.cpp @@ -227,7 +227,7 @@ void getExperimentalTorsions( unsigned int i = 0; unsigned int isBoundToSP2O = 0; // false for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *atomX = mol[*nbrIdx].get(); + const Atom *atomX = mol[*nbrIdx]; atoms[i] = atomX->getIdx(); // if the central atom is sp2 carbon and is bound to sp2 oxygen, set // a flag diff --git a/Code/GraphMol/ForceFieldHelpers/MMFF/AtomTyper.cpp b/Code/GraphMol/ForceFieldHelpers/MMFF/AtomTyper.cpp index 23ca6ba01..5df088ad7 100644 --- a/Code/GraphMol/ForceFieldHelpers/MMFF/AtomTyper.cpp +++ b/Code/GraphMol/ForceFieldHelpers/MMFF/AtomTyper.cpp @@ -249,7 +249,7 @@ bool isAtomNOxide(const Atom *atom) { // loop over neighbors boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; (!isNOxide) && (nbrIdx != endNbrs); ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; isNOxide = ((nbrAtom->getAtomicNum() == 8) && (nbrAtom->getTotalDegree() == 1)); } @@ -280,7 +280,7 @@ unsigned int isAngleInRingOfSize3or4(const ROMol &mol, const unsigned int idx1, boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(mol.getAtomWithIdx(idx1)); for (; nbrIdx != endNbrs; ++nbrIdx) { - newIdx = mol[*nbrIdx].get()->getIdx(); + newIdx = mol[*nbrIdx]->getIdx(); if (newIdx != idx2) { s1.insert(newIdx); } @@ -288,7 +288,7 @@ unsigned int isAngleInRingOfSize3or4(const ROMol &mol, const unsigned int idx1, boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(mol.getAtomWithIdx(idx3)); for (; nbrIdx != endNbrs; ++nbrIdx) { - newIdx = mol[*nbrIdx].get()->getIdx(); + newIdx = mol[*nbrIdx]->getIdx(); if (newIdx != idx2) { s2.insert(newIdx); } @@ -329,7 +329,7 @@ unsigned int isTorsionInRingOfSize4or5(const ROMol &mol, boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(mol.getAtomWithIdx(idx1)); for (; nbrIdx != endNbrs; ++nbrIdx) { - newIdx = mol[*nbrIdx].get()->getIdx(); + newIdx = mol[*nbrIdx]->getIdx(); if (newIdx != idx2) { s1.insert(newIdx); } @@ -337,7 +337,7 @@ unsigned int isTorsionInRingOfSize4or5(const ROMol &mol, boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(mol.getAtomWithIdx(idx4)); for (; nbrIdx != endNbrs; ++nbrIdx) { - newIdx = mol[*nbrIdx].get()->getIdx(); + newIdx = mol[*nbrIdx]->getIdx(); if (newIdx != idx3) { s2.insert(newIdx); } @@ -463,7 +463,7 @@ void setMMFFAromaticity(RWMol &mol) { // loop over neighbors boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; // if the neighbor is one of the ring atoms, skip it // since we are looking for exocyclic neighbors if (std::find(atomRings[i].begin(), atomRings[i].end(), @@ -611,7 +611,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( // loop over alpha neighbors boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; // if the alpha neighbor is not in a 5-membered aromatic // ring, skip to the next neighbor if (!rmSize.isAtomInAromaticRingOfSize(nbrAtom, 5)) { @@ -631,7 +631,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( // loop over beta neighbors boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(nbrAtom); for (; nbr2Idx != end2Nbrs; ++nbr2Idx) { - const Atom *nbr2Atom = mol[*nbr2Idx].get(); + const Atom *nbr2Atom = mol[*nbr2Idx]; // if we have gone back to the ipso atom, move on if (nbr2Atom->getIdx() == atom->getIdx()) { continue; @@ -692,7 +692,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( unsigned int nInAromatic6Ring = 0; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; if ((nbrAtom->getAtomicNum() == 7) && (nbrAtom->getTotalDegree() == 3)) { ++nN; @@ -728,7 +728,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( // are all neighbors benzene carbons? boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; if ((nbrAtom->getAtomicNum() != 6) || (!(ringInfo->isAtomInRingOfSize(nbrAtom->getIdx(), 6)))) { @@ -928,7 +928,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( unsigned int doubleBondedElement = 0; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; // find if there is a double-bonded element if ((mol.getBondBetweenAtoms(nbrAtom->getIdx(), atom->getIdx())) ->getBondType() == Bond::DOUBLE) { @@ -1057,7 +1057,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( // to that phosphorus or sulfur atom boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; // count how many terminal oxygen atoms // are bonded to ipso if ((nbrAtom->getAtomicNum() == 8) && @@ -1070,7 +1070,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( unsigned int nObondedToSP = 0; boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(nbrAtom); for (; nbr2Idx != end2Nbrs; ++nbr2Idx) { - const Atom *nbr2Atom = mol[*nbr2Idx].get(); + const Atom *nbr2Atom = mol[*nbr2Idx]; if ((nbr2Atom->getAtomicNum() == 8) && (nbr2Atom->getTotalDegree() == 1)) { ++nObondedToSP; @@ -1102,7 +1102,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( bool doubleBondedCN = false; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; // find if there is a double-bonded nitrogen, // or a carbon which is not bonded to other // nitrogen atoms with 3 neighbors @@ -1113,7 +1113,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( if (nbrAtom->getAtomicNum() == 6) { boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(nbrAtom); for (; doubleBondedCN && (nbr2Idx != end2Nbrs); ++nbr2Idx) { - const Atom *nbr2Atom = mol[*nbr2Idx].get(); + const Atom *nbr2Atom = mol[*nbr2Idx]; if (nbr2Atom->getIdx() == atom->getIdx()) { continue; } @@ -1169,7 +1169,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( // loop over neighbors boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; // if the neighbor is carbon if (nbrAtom->getAtomicNum() == 6) { isNbrC = true; @@ -1187,7 +1187,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( // loop over carbon neighbors boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(nbrAtom); for (; nbr2Idx != end2Nbrs; ++nbr2Idx) { - const Atom *nbr2Atom = mol[*nbr2Idx].get(); + const Atom *nbr2Atom = mol[*nbr2Idx]; const Bond *bond = mol.getBondBetweenAtoms( nbrAtom->getIdx(), nbr2Atom->getIdx()); // check if we have oxygen or sulfur double-bonded to this @@ -1229,7 +1229,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( boost::tie(nbr3Idx, end3Nbrs) = mol.getAtomNeighbors(nbr2Atom); for (; nbr3Idx != end3Nbrs; ++nbr3Idx) { - const Atom *nbr3Atom = mol[*nbr3Idx].get(); + const Atom *nbr3Atom = mol[*nbr3Idx]; if (nbr3Atom->getAtomicNum() == 8) { ++nObondedToN3; } @@ -1294,7 +1294,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( // loop over nitrogen neighbors boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(nbrAtom); for (; nbr2Idx != end2Nbrs; ++nbr2Idx) { - const Atom *nbr2Atom = mol[*nbr2Idx].get(); + const Atom *nbr2Atom = mol[*nbr2Idx]; const Bond *bond = mol.getBondBetweenAtoms( nbrAtom->getIdx(), nbr2Atom->getIdx()); // if the bond to nitrogen is double @@ -1305,7 +1305,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( boost::tie(nbr3Idx, end3Nbrs) = mol.getAtomNeighbors(nbr2Atom); for (; nbr3Idx != end3Nbrs; ++nbr3Idx) { - const Atom *nbr3Atom = mol[*nbr3Idx].get(); + const Atom *nbr3Atom = mol[*nbr3Idx]; // if the nitrogen neighbor to ipso is met, move on if (nbr3Atom->getIdx() == nbrAtom->getIdx()) { continue; @@ -1412,7 +1412,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( bool isIsonitrile = false; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; (!isIsonitrile) && (nbrIdx != endNbrs); ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; // if neighbor is triple-bonded isIsonitrile = ((mol.getBondBetweenAtoms(atom->getIdx(), nbrAtom->getIdx())) @@ -1436,7 +1436,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( bool isImineOrAzo = false; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; // if the neighbor is double bonded (-N=) if ((mol.getBondBetweenAtoms(atom->getIdx(), nbrAtom->getIdx())) ->getBondType() == Bond::DOUBLE) { @@ -1470,7 +1470,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( bool isNSO = false; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; (!isNSO) && (nbrIdx != endNbrs); ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; // if the neighbor is sulfur bonded to a single terminal oxygen if (nbrAtom->getAtomicNum() == 16) { // loop over neighbors and count how many @@ -1478,7 +1478,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( unsigned int nTermObondedToS = 0; boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(nbrAtom); for (; nbr2Idx != end2Nbrs; ++nbr2Idx) { - const Atom *nbr2Atom = mol[*nbr2Idx].get(); + const Atom *nbr2Atom = mol[*nbr2Idx]; if ((nbr2Atom->getAtomicNum() == 8) && (nbr2Atom->getTotalDegree() == 1)) { ++nTermObondedToS; @@ -1520,7 +1520,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( bool isNAZT = false; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; (!isNSP) && (!isNAZT) && (nbrIdx != endNbrs); ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; // if ipso is triple-bonded to its only neighbor isNSP = ((mol.getBondBetweenAtoms(atom->getIdx(), nbrAtom->getIdx())) @@ -1531,7 +1531,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( // loop over nitrogen neighbors boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(nbrAtom); for (; (!isNAZT) && (nbr2Idx != end2Nbrs); ++nbr2Idx) { - const Atom *nbr2Atom = mol[*nbr2Idx].get(); + const Atom *nbr2Atom = mol[*nbr2Idx]; // if another nitrogen with 2 neighbors, or a carbon // with 3 neighbors is found, ipso is NAZT isNAZT = (((nbr2Atom->getAtomicNum() == 7) && @@ -1581,7 +1581,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( unsigned int nHbondedToO = 0; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; if (nbrAtom->getAtomicNum() == 1) { ++nHbondedToO; } @@ -1653,7 +1653,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( (!isPhosphateOrPerchlorateO) && (!isCarbonylO) && (!isNitrosoO) && (!isSulfoxideO); ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; const Bond *bond = mol.getBondBetweenAtoms(atom->getIdx(), nbrAtom->getIdx()); // if the neighbor is carbon, nitrogen or sulfur @@ -1665,7 +1665,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( // are bonded to the carbon or nitrogen neighbor of ipso boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(nbrAtom); for (; nbr2Idx != end2Nbrs; ++nbr2Idx) { - const Atom *nbr2Atom = mol[*nbr2Idx].get(); + const Atom *nbr2Atom = mol[*nbr2Idx]; if ((nbr2Atom->getAtomicNum() == 7) && (nbr2Atom->getTotalDegree() == 2)) { ++nNbondedToCorNorS; @@ -1896,7 +1896,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( // loop over neighbors boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; // check if ipso sulfur is double-bonded to carbon if ((nbrAtom->getAtomicNum() == 6) && ((mol.getBondBetweenAtoms(atom->getIdx(), nbrAtom->getIdx())) @@ -1949,7 +1949,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( bool isODoubleBondedToS = false; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; // check if ipso sulfur is double-bonded to oxygen if ((nbrAtom->getAtomicNum() == 8) && ((mol.getBondBetweenAtoms(atom->getIdx(), nbrAtom->getIdx())) @@ -1978,10 +1978,10 @@ void MMFFMolProperties::setMMFFHeavyAtomType( // atoms are there, including ipso boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(nbrAtom); for (; nbr2Idx != end2Nbrs; ++nbr2Idx) { - const Atom *nbr2Atom = mol[*nbr2Idx].get(); + const Atom *nbr2Atom = mol[*nbr2Idx]; if ((nbr2Atom->getAtomicNum() == 16) && (nbr2Atom->getTotalDegree() == 1)) { ++nTermSbondedToNbr; @@ -2024,7 +2024,7 @@ void MMFFMolProperties::setMMFFHeavyAtomType( unsigned int nObondedToCl = 0; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; if (nbrAtom->getAtomicNum() == 8) { ++nObondedToCl; } @@ -2170,7 +2170,7 @@ void MMFFMolProperties::setMMFFHydrogenType(const Atom *atom) { // loop over neighbors (actually there can be only one) boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; switch (nbrAtom->getAtomicNum()) { // carbon, silicon case 6: @@ -2288,13 +2288,13 @@ void MMFFMolProperties::setMMFFHydrogenType(const Atom *atom) { // loop over oxygen neighbors boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(nbrAtom); for (; nbr2Idx != end2Nbrs; ++nbr2Idx) { - const Atom *nbr2Atom = mol[*nbr2Idx].get(); + const Atom *nbr2Atom = mol[*nbr2Idx]; // if the neighbor of oxygen is carbon, loop over the carbon // neighbors if (nbr2Atom->getAtomicNum() == 6) { boost::tie(nbr3Idx, end3Nbrs) = mol.getAtomNeighbors(nbr2Atom); for (; nbr3Idx != end3Nbrs; ++nbr3Idx) { - const Atom *nbr3Atom = mol[*nbr3Idx].get(); + const Atom *nbr3Atom = mol[*nbr3Idx]; const Bond *bond = mol.getBondBetweenAtoms( nbr2Atom->getIdx(), nbr3Atom->getIdx()); // if the starting oxygen is met, move on @@ -3179,7 +3179,7 @@ void MMFFMolProperties::computeMMFFCharges(const ROMol &mol) { // loop over neighbors boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; nbrAtomType = this->getMMFFAtomType(nbrAtom->getIdx()); // loop over neighbors of the neighbor // count how many terminal oxygen/sulfur atoms @@ -3189,7 +3189,7 @@ void MMFFMolProperties::computeMMFFCharges(const ROMol &mol) { int nTermOSbondedToNbr = 0; boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(nbrAtom); for (; nbr2Idx != end2Nbrs; ++nbr2Idx) { - const Atom *nbr2Atom = mol[*nbr2Idx].get(); + const Atom *nbr2Atom = mol[*nbr2Idx]; // if it's nitrogen with 2 neighbors and it is not aromatic, // increment the counter of secondary nitrogens if ((nbr2Atom->getAtomicNum() == 7) && @@ -3356,7 +3356,7 @@ void MMFFMolProperties::computeMMFFCharges(const ROMol &mol) { boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(mol.getAtomWithIdx(i)); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; nbrAtomType = this->getMMFFAtomType(nbrAtom->getIdx()); // if atom type is not 80 or 57, move on if ((nbrAtomType != 57) && (nbrAtomType != 80)) { @@ -3368,7 +3368,7 @@ void MMFFMolProperties::computeMMFFCharges(const ROMol &mol) { // and increment the nConj counter by 1 boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(nbrAtom); for (; nbr2Idx != end2Nbrs; ++nbr2Idx) { - const Atom *nbr2Atom = mol[*nbr2Idx].get(); + const Atom *nbr2Atom = mol[*nbr2Idx]; // if atom type is not 81, 55 or 56, move on nbrAtomType = this->getMMFFAtomType(nbr2Atom->getIdx()); if ((nbrAtomType != 55) && (nbrAtomType != 56) && @@ -3397,7 +3397,7 @@ void MMFFMolProperties::computeMMFFCharges(const ROMol &mol) { // loop over neighbors boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; // if it is diazonium, set a +1 formal charge on // the secondary nitrogen if (this->getMMFFAtomType(nbrAtom->getIdx()) == 42) { @@ -3510,7 +3510,7 @@ void MMFFMolProperties::computeMMFFCharges(const ROMol &mol) { // loop over neighbors boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; nbrFormalCharge = this->getMMFFFormalCharge(nbrAtom->getIdx()); // if neighbors have a negative formal charge, the latter // influences the charge on ipso @@ -3524,7 +3524,7 @@ void MMFFMolProperties::computeMMFFCharges(const ROMol &mol) { if (atomType == 62) { boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; nbrFormalCharge = this->getMMFFFormalCharge(nbrAtom->getIdx()); if (nbrFormalCharge > 0.0) { q0 -= (nbrFormalCharge / 2.0); @@ -3534,7 +3534,7 @@ void MMFFMolProperties::computeMMFFCharges(const ROMol &mol) { // loop over neighbors boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom); for (; nbrIdx != endNbrs; ++nbrIdx) { - const Atom *nbrAtom = mol[*nbrIdx].get(); + const Atom *nbrAtom = mol[*nbrIdx]; const Bond *bond = mol.getBondBetweenAtoms(atom->getIdx(), nbrAtom->getIdx()); // we need to determine the sign of bond charge diff --git a/Code/GraphMol/ForceFieldHelpers/MMFF/Builder.cpp b/Code/GraphMol/ForceFieldHelpers/MMFF/Builder.cpp index 9c7f61b60..dea42115f 100644 --- a/Code/GraphMol/ForceFieldHelpers/MMFF/Builder.cpp +++ b/Code/GraphMol/ForceFieldHelpers/MMFF/Builder.cpp @@ -251,14 +251,14 @@ void addAngles(const ROMol &mol, MMFFMolProperties *mmffMolProperties, const MMFFProp *mmffPropParamsCentralAtom = (*mmffProp)(jAtomType); boost::tie(nbr1Idx, end1Nbrs) = mol.getAtomNeighbors(jAtom); for (; nbr1Idx != end1Nbrs; ++nbr1Idx) { - const Atom *iAtom = mol[*nbr1Idx].get(); + const Atom *iAtom = mol[*nbr1Idx]; idx[0] = iAtom->getIdx(); boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(jAtom); for (; nbr2Idx != end2Nbrs; ++nbr2Idx) { if (nbr2Idx < (nbr1Idx + 1)) { continue; } - const Atom *kAtom = mol[*nbr2Idx].get(); + const Atom *kAtom = mol[*nbr2Idx]; idx[2] = kAtom->getIdx(); unsigned int angleType; MMFFAngle mmffAngleParams; @@ -369,11 +369,11 @@ void addStretchBend(const ROMol &mol, MMFFMolProperties *mmffMolProperties, boost::tie(nbr1Idx, end1Nbrs) = mol.getAtomNeighbors(jAtom); unsigned int i = 0; for (; nbr1Idx != end1Nbrs; ++nbr1Idx) { - const Atom *iAtom = mol[*nbr1Idx].get(); + const Atom *iAtom = mol[*nbr1Idx]; boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(jAtom); unsigned int j = 0; for (; nbr2Idx != end2Nbrs; ++nbr2Idx) { - const Atom *kAtom = mol[*nbr2Idx].get(); + const Atom *kAtom = mol[*nbr2Idx]; if (j < (i + 1)) { ++j; continue; @@ -507,7 +507,7 @@ void addOop(const ROMol &mol, MMFFMolProperties *mmffMolProperties, boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(atom[1]); unsigned int i = 0; for (; nbrIdx != endNbrs; ++nbrIdx) { - atom[i] = mol[*nbrIdx].get(); + atom[i] = mol[*nbrIdx]; idx[i] = atom[i]->getIdx(); atomType[i] = mmffMolProperties->getMMFFAtomType(idx[i]); if (!i) { @@ -672,13 +672,13 @@ void addTorsions(const ROMol &mol, MMFFMolProperties *mmffMolProperties, ROMol::OEDGE_ITER beg1, end1; boost::tie(beg1, end1) = mol.getAtomBonds(jAtom); while (beg1 != end1) { - const Bond *tBond1 = mol[*beg1].get(); + const Bond *tBond1 = mol[*beg1]; if (tBond1 != bond) { int idx1 = tBond1->getOtherAtomIdx(idx2); ROMol::OEDGE_ITER beg2, end2; boost::tie(beg2, end2) = mol.getAtomBonds(kAtom); while (beg2 != end2) { - const Bond *tBond2 = mol[*beg2].get(); + const Bond *tBond2 = mol[*beg2]; if ((tBond2 != bond) && (tBond2 != tBond1)) { int idx4 = tBond2->getOtherAtomIdx(idx3); // make sure this isn't a three-membered ring: diff --git a/Code/GraphMol/ForceFieldHelpers/UFF/Builder.cpp b/Code/GraphMol/ForceFieldHelpers/UFF/Builder.cpp index 642a0c0fe..9eb8263c3 100644 --- a/Code/GraphMol/ForceFieldHelpers/UFF/Builder.cpp +++ b/Code/GraphMol/ForceFieldHelpers/UFF/Builder.cpp @@ -149,7 +149,7 @@ void addAngles(const ROMol &mol, const AtomicParamVect ¶ms, if (atomJ->getDegree() == 1) continue; boost::tie(nbr1Idx, end1Nbrs) = mol.getAtomNeighbors(atomJ); for (; nbr1Idx != end1Nbrs; nbr1Idx++) { - const Atom *atomI = mol[*nbr1Idx].get(); + const Atom *atomI = mol[*nbr1Idx]; unsigned int i = atomI->getIdx(); if (!params[i]) continue; boost::tie(nbr2Idx, end2Nbrs) = mol.getAtomNeighbors(atomJ); @@ -157,7 +157,7 @@ void addAngles(const ROMol &mol, const AtomicParamVect ¶ms, if (nbr2Idx < (nbr1Idx + 1)) { continue; } - const Atom *atomK = mol[*nbr2Idx].get(); + const Atom *atomK = mol[*nbr2Idx]; unsigned int k = atomK->getIdx(); if (!params[k]) continue; // skip special cases: @@ -258,7 +258,7 @@ void addTrigonalBipyramidAngles(const Atom *atom, const ROMol &mol, int confId, boost::tie(beg1, end1) = mol.getAtomBonds(atom); unsigned int aid = atom->getIdx(); while (beg1 != end1) { - const Bond *bond1 = mol[*beg1].get(); + const Bond *bond1 = mol[*beg1]; unsigned int oaid = bond1->getOtherAtomIdx(aid); RDGeom::Point3D v1 = conf.getAtomPos(aid).directionVector(conf.getAtomPos(oaid)); @@ -266,7 +266,7 @@ void addTrigonalBipyramidAngles(const Atom *atom, const ROMol &mol, int confId, ROMol::OEDGE_ITER beg2, end2; boost::tie(beg2, end2) = mol.getAtomBonds(atom); while (beg2 != end2) { - const Bond *bond2 = mol[*beg2].get(); + const Bond *bond2 = mol[*beg2]; if (bond2->getIdx() > bond1->getIdx()) { unsigned int oaid2 = bond2->getOtherAtomIdx(aid); RDGeom::Point3D v2 = @@ -287,7 +287,7 @@ void addTrigonalBipyramidAngles(const Atom *atom, const ROMol &mol, int confId, boost::tie(beg1, end1) = mol.getAtomBonds(atom); while (beg1 != end1) { - const Bond *bond = mol[*beg1].get(); + const Bond *bond = mol[*beg1]; ++beg1; if (bond == ax1 || bond == ax2) continue; if (!eq1) @@ -540,13 +540,13 @@ void addTorsions(const ROMol &mol, const AtomicParamVect ¶ms, ROMol::OEDGE_ITER beg1, end1; boost::tie(beg1, end1) = mol.getAtomBonds(atom1); while (beg1 != end1) { - const Bond *tBond1 = mol[*beg1].get(); + const Bond *tBond1 = mol[*beg1]; if (tBond1 != bond) { int bIdx = tBond1->getOtherAtomIdx(idx1); ROMol::OEDGE_ITER beg2, end2; boost::tie(beg2, end2) = mol.getAtomBonds(atom2); while (beg2 != end2) { - const Bond *tBond2 = mol[*beg2].get(); + const Bond *tBond2 = mol[*beg2]; if (tBond2 != bond && tBond2 != tBond1) { int eIdx = tBond2->getOtherAtomIdx(idx2); // make sure this isn't a three-membered ring: @@ -627,7 +627,7 @@ void addInversions(const ROMol &mol, const AtomicParamVect ¶ms, unsigned int i = 0; bool isBoundToSP2O = false; for (; nbrIdx != endNbrs; ++nbrIdx) { - atom[i] = mol[*nbrIdx].get(); + atom[i] = mol[*nbrIdx]; idx[i] = atom[i]->getIdx(); // if the central atom is sp2 carbon and is // bound to sp2 oxygen, set a flag diff --git a/Code/GraphMol/Kekulize.cpp b/Code/GraphMol/Kekulize.cpp index 7e45412d3..1e4dad8ea 100644 --- a/Code/GraphMol/Kekulize.cpp +++ b/Code/GraphMol/Kekulize.cpp @@ -123,7 +123,7 @@ void markDbondCands(RWMol &mol, const INT_VECT &allAtms, RWMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(at); while (beg != end) { - Bond *bond = mol[*beg].get(); + Bond *bond = mol[*beg]; if (bond->getIsAromatic() && (bond->getBondType() == Bond::SINGLE || bond->getBondType() == Bond::DOUBLE || bond->getBondType() == Bond::AROMATIC)) { diff --git a/Code/GraphMol/MMPA/MMPA.cpp b/Code/GraphMol/MMPA/MMPA.cpp index 3b2d43c3c..ac2583f1c 100644 --- a/Code/GraphMol/MMPA/MMPA.cpp +++ b/Code/GraphMol/MMPA/MMPA.cpp @@ -208,7 +208,7 @@ static void addResult(std::vector>& Atom* a = em.getAtomWithIdx(ai); ROMol::OEDGE_ITER beg, end; for (boost::tie(beg, end) = em.getAtomBonds(a); beg != end; ++beg) { - const BOND_SPTR bond = em[*beg]; + const Bond* bond = em[*beg]; if (newAtomMap.end() == newAtomMap.find(bond->getBeginAtomIdx()) || newAtomMap.end() == newAtomMap.find(bond->getEndAtomIdx()) || visitedBonds.end() != visitedBonds.find(bond->getIdx())) @@ -247,7 +247,7 @@ static void addResult(std::vector>& Atom* a = em.getAtomWithIdx(ai); ROMol::OEDGE_ITER beg, end; for (boost::tie(beg, end) = em.getAtomBonds(a); beg != end; ++beg) { - const BOND_SPTR bond = em[*beg]; + const Bond* bond = em[*beg]; if (newAtomMap.end() == newAtomMap.find(bond->getBeginAtomIdx()) || newAtomMap.end() == newAtomMap.find(bond->getEndAtomIdx()) || visitedBonds.end() != visitedBonds.find(bond->getIdx())) diff --git a/Code/GraphMol/Matrices.cpp b/Code/GraphMol/Matrices.cpp index 52808d628..3a67c04a7 100644 --- a/Code/GraphMol/Matrices.cpp +++ b/Code/GraphMol/Matrices.cpp @@ -190,7 +190,7 @@ double *getDistanceMat(const ROMol &mol, bool useBO, bool useAtomWts, ROMol::EDGE_ITER firstB, lastB; boost::tie(firstB, lastB) = mol.getEdges(); while (firstB != lastB) { - const BOND_SPTR bond = mol[*firstB]; + const Bond* bond = mol[*firstB]; i = bond->getBeginAtomIdx(); j = bond->getEndAtomIdx(); double contrib; diff --git a/Code/GraphMol/MolDiscriminators.cpp b/Code/GraphMol/MolDiscriminators.cpp index 402069879..795947396 100644 --- a/Code/GraphMol/MolDiscriminators.cpp +++ b/Code/GraphMol/MolDiscriminators.cpp @@ -76,7 +76,7 @@ double computeBalabanJ(const ROMol &mol, bool useBO, bool force, ROMol::EDGE_ITER beg, end; boost::tie(beg, end) = mol.getEdges(); while (beg != end) { - const Bond *bond = mol[*beg].get(); + const Bond *bond = mol[*beg]; if (bondsUsed[bond->getIdx()]) { int begIdx = bond->getBeginAtomIdx(); int endIdx = bond->getEndAtomIdx(); diff --git a/Code/GraphMol/MolDraw2D/MolDraw2D.cpp b/Code/GraphMol/MolDraw2D/MolDraw2D.cpp index b94f9b3a4..22512a478 100644 --- a/Code/GraphMol/MolDraw2D/MolDraw2D.cpp +++ b/Code/GraphMol/MolDraw2D/MolDraw2D.cpp @@ -109,9 +109,9 @@ void MolDraw2D::doContinuousHighlighting( while (this_at != end_at) { int this_idx = mol[*this_at]->getIdx(); ROMol::OEDGE_ITER nbr, end_nbr; - boost::tie(nbr, end_nbr) = mol.getAtomBonds(mol[*this_at].get()); + boost::tie(nbr, end_nbr) = mol.getAtomBonds(mol[*this_at]); while (nbr != end_nbr) { - const BOND_SPTR bond = mol[*nbr]; + const Bond* bond = mol[*nbr]; ++nbr; int nbr_idx = bond->getOtherAtomIdx(this_idx); if (nbr_idx < static_cast(at_cds_[activeMolIdx_].size()) && @@ -275,9 +275,9 @@ void MolDraw2D::drawMolecule(const ROMol &mol, while (this_at != end_at) { int this_idx = mol[*this_at]->getIdx(); ROMol::OEDGE_ITER nbr, end_nbr; - boost::tie(nbr, end_nbr) = mol.getAtomBonds(mol[*this_at].get()); + boost::tie(nbr, end_nbr) = mol.getAtomBonds(mol[*this_at]); while (nbr != end_nbr) { - const BOND_SPTR bond = mol[*nbr]; + const Bond* bond = mol[*nbr]; ++nbr; int nbr_idx = bond->getOtherAtomIdx(this_idx); if (nbr_idx < static_cast(at_cds_[activeMolIdx_].size()) && @@ -293,7 +293,7 @@ void MolDraw2D::drawMolecule(const ROMol &mol, ROMol::VERTEX_ITER atom, end_atom; boost::tie(atom, end_atom) = mol.getVertices(); while (atom != end_atom) { - const Atom *at1 = mol[*atom].get(); + const Atom *at1 = mol[*atom]; ++atom; if (at1->hasProp(common_properties::atomLabel) || drawOptions().atomLabels.find(at1->getIdx()) != @@ -305,7 +305,7 @@ void MolDraw2D::drawMolecule(const ROMol &mol, Point2D &at1_cds = at_cds_[activeMolIdx_][at1->getIdx()]; ROMol::ADJ_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(at1); - const ATOM_SPTR at2 = mol[*nbrIdx]; + const Atom* at2 = mol[*nbrIdx]; Point2D &at2_cds = at_cds_[activeMolIdx_][at2->getIdx()]; drawAttachmentLine(at2_cds, at1_cds, DrawColour(.5, .5, .5)); } @@ -564,7 +564,7 @@ void MolDraw2D::drawReaction( ROMol::ADJ_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = tmol->getAtomNeighbors(atom); while (nbrIdx != endNbrs) { - const ATOM_SPTR nbr = (*tmol)[*nbrIdx]; + const Atom* nbr = (*tmol)[*nbrIdx]; if (nbr->getIdx() < aidx && atomfragmap[nbr->getIdx()] == atomfragmap[aidx]) { int bondIdx = @@ -593,7 +593,7 @@ void MolDraw2D::drawReaction( ROMol::ADJ_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = tmol->getAtomNeighbors(atom); while (nbrIdx != endNbrs) { - const ATOM_SPTR nbr = (*tmol)[*nbrIdx]; + const Atom* nbr = (*tmol)[*nbrIdx]; if (nbr->getIdx() < aidx && (*atom_highlight_colors)[nbr->getIdx()] == (*atom_highlight_colors)[aidx]) { @@ -1137,12 +1137,12 @@ void MolDraw2D::extractAtomSymbols(const ROMol &mol) { boost::tie(atom, end_atom) = mol.getVertices(); while (atom != end_atom) { ROMol::OEDGE_ITER nbr, end_nbrs; - const Atom *at1 = mol[*atom].get(); + const Atom *at1 = mol[*atom]; boost::tie(nbr, end_nbrs) = mol.getAtomBonds(at1); Point2D &at1_cds = at_cds_[activeMolIdx_][at1->getIdx()]; Point2D nbr_sum(0.0, 0.0); while (nbr != end_nbrs) { - const BOND_SPTR bond = mol[*nbr]; + const Bond* bond = mol[*nbr]; ++nbr; Point2D &at2_cds = at_cds_[activeMolIdx_][bond->getOtherAtomIdx(at1->getIdx())]; @@ -1156,7 +1156,7 @@ void MolDraw2D::extractAtomSymbols(const ROMol &mol) { } // **************************************************************************** -void MolDraw2D::drawBond(const ROMol &mol, const BOND_SPTR &bond, int at1_idx, +void MolDraw2D::drawBond(const ROMol &mol, const Bond* bond, int at1_idx, int at2_idx, const vector *highlight_atoms, const map *highlight_atom_map, const vector *highlight_bonds, @@ -1386,13 +1386,13 @@ Point2D MolDraw2D::calcPerpendicular(const Point2D &cds1, const Point2D &cds2) { // **************************************************************************** // cds1 and cds2 are 2 atoms in a ring. Returns the perpendicular pointing into // the ring -Point2D MolDraw2D::bondInsideRing(const ROMol &mol, const BOND_SPTR &bond, +Point2D MolDraw2D::bondInsideRing(const ROMol &mol, const Bond* bond, const Point2D &cds1, const Point2D &cds2) { Atom *bgn_atom = bond->getBeginAtom(); ROMol::OEDGE_ITER nbr2, end_nbrs2; boost::tie(nbr2, end_nbrs2) = mol.getAtomBonds(bgn_atom); while (nbr2 != end_nbrs2) { - const BOND_SPTR bond2 = mol[*nbr2]; + const Bond* bond2 = mol[*nbr2]; ++nbr2; if (bond2->getIdx() == bond->getIdx() || !mol.getRingInfo()->numBondRings(bond2->getIdx())) { @@ -1421,7 +1421,7 @@ Point2D MolDraw2D::bondInsideRing(const ROMol &mol, const BOND_SPTR &bond, // cds1 and cds2 are 2 atoms in a chain double bond. Returns the perpendicular // pointing into the inside of the bond Point2D MolDraw2D::bondInsideDoubleBond(const ROMol &mol, - const BOND_SPTR &bond) { + const Bond* bond) { // a chain double bond, were it looks nicer IMO if the 2nd line is inside // the angle of outgoing bond. Unless it's an allene, where nothing // looks great. @@ -1439,7 +1439,7 @@ Point2D MolDraw2D::bondInsideDoubleBond(const ROMol &mol, ROMol::OEDGE_ITER nbr2, end_nbrs2; boost::tie(nbr2, end_nbrs2) = mol.getAtomBonds(bond_atom); while (nbr2 != end_nbrs2) { - const BOND_SPTR bond2 = mol[*nbr2]; + const Bond* bond2 = mol[*nbr2]; ++nbr2; if (bond != bond2) { at3 = bond2->getOtherAtomIdx(bond_atom->getIdx()); diff --git a/Code/GraphMol/MolDraw2D/MolDraw2D.h b/Code/GraphMol/MolDraw2D/MolDraw2D.h index 2a370be5e..2517d217f 100644 --- a/Code/GraphMol/MolDraw2D/MolDraw2D.h +++ b/Code/GraphMol/MolDraw2D/MolDraw2D.h @@ -430,7 +430,7 @@ class MolDraw2D { virtual void drawLine(const Point2D &cds1, const Point2D &cds2, const DrawColour &col1, const DrawColour &col2); - void drawBond(const ROMol &mol, const BOND_SPTR &bond, int at1_idx, + void drawBond(const ROMol &mol, const Bond* bond, int at1_idx, int at2_idx, const std::vector *highlight_atoms = NULL, const std::map *highlight_atom_map = NULL, const std::vector *highlight_bonds = NULL, @@ -444,12 +444,12 @@ class MolDraw2D { // cds1 and cds2 are 2 atoms in a ring. Returns the perpendicular pointing // into // the ring. - Point2D bondInsideRing(const ROMol &mol, const BOND_SPTR &bond, + Point2D bondInsideRing(const ROMol &mol, const Bond* bond, const Point2D &cds1, const Point2D &cds2); // cds1 and cds2 are 2 atoms in a chain double bond. Returns the // perpendicular // pointing into the inside of the bond - Point2D bondInsideDoubleBond(const ROMol &mol, const BOND_SPTR &bond); + Point2D bondInsideDoubleBond(const ROMol &mol, const Bond* bond); // calculate normalised perpendicular to vector between two coords, such // that // it's inside the angle made between (1 and 2) and (2 and 3). diff --git a/Code/GraphMol/MolDraw2D/MultiMolDraw2D.cpp b/Code/GraphMol/MolDraw2D/MultiMolDraw2D.cpp index d4766d5f4..d1cf6ce0a 100644 --- a/Code/GraphMol/MolDraw2D/MultiMolDraw2D.cpp +++ b/Code/GraphMol/MolDraw2D/MultiMolDraw2D.cpp @@ -86,7 +86,7 @@ void MolDraw2D::doContinuousHighlighting( ROMol::OEDGE_ITER nbr, end_nbr; boost::tie(nbr, end_nbr) = mol.getAtomBonds(mol[*this_at].get()); while (nbr != end_nbr) { - const BOND_SPTR bond = mol[*nbr]; + const Bond* bond = mol[*nbr]; ++nbr; int nbr_idx = bond->getOtherAtomIdx(this_idx); if (nbr_idx < static_cast(at_cds_.size()) && nbr_idx > this_idx) { @@ -246,7 +246,7 @@ void MolDraw2D::drawMolecule(const ROMol &mol, ROMol::OEDGE_ITER nbr, end_nbr; boost::tie(nbr, end_nbr) = mol.getAtomBonds(mol[*this_at].get()); while (nbr != end_nbr) { - const BOND_SPTR bond = mol[*nbr]; + const Bond* bond = mol[*nbr]; ++nbr; int nbr_idx = bond->getOtherAtomIdx(this_idx); if (nbr_idx < static_cast(at_cds_.size()) && nbr_idx > this_idx) { @@ -272,7 +272,7 @@ void MolDraw2D::drawMolecule(const ROMol &mol, Point2D &at1_cds = at_cds_[at1->getIdx()]; ROMol::ADJ_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(at1); - const ATOM_SPTR at2 = mol[*nbrIdx]; + const Atom* at2 = mol[*nbrIdx]; Point2D &at2_cds = at_cds_[at2->getIdx()]; drawAttachmentLine(at2_cds, at1_cds, DrawColour(.5, .5, .5)); } @@ -663,7 +663,7 @@ void MolDraw2D::extractAtomSymbols(const ROMol &mol) { Point2D &at1_cds = at_cds_[at1->getIdx()]; Point2D nbr_sum(0.0, 0.0); while (nbr != end_nbrs) { - const BOND_SPTR bond = mol[*nbr]; + const Bond* bond = mol[*nbr]; ++nbr; Point2D &at2_cds = at_cds_[bond->getOtherAtomIdx(at1->getIdx())]; nbr_sum += at2_cds - at1_cds; @@ -675,7 +675,7 @@ void MolDraw2D::extractAtomSymbols(const ROMol &mol) { } // **************************************************************************** -void MolDraw2D::drawBond(const ROMol &mol, const BOND_SPTR &bond, int at1_idx, +void MolDraw2D::drawBond(const ROMol &mol, const Bond* &bond, int at1_idx, int at2_idx, const vector *highlight_atoms, const map *highlight_atom_map, const vector *highlight_bonds, @@ -900,13 +900,13 @@ Point2D MolDraw2D::calcPerpendicular(const Point2D &cds1, const Point2D &cds2) { // **************************************************************************** // cds1 and cds2 are 2 atoms in a ring. Returns the perpendicular pointing into // the ring -Point2D MolDraw2D::bondInsideRing(const ROMol &mol, const BOND_SPTR &bond, +Point2D MolDraw2D::bondInsideRing(const ROMol &mol, const Bond* &bond, const Point2D &cds1, const Point2D &cds2) { Atom *bgn_atom = bond->getBeginAtom(); ROMol::OEDGE_ITER nbr2, end_nbrs2; boost::tie(nbr2, end_nbrs2) = mol.getAtomBonds(bgn_atom); while (nbr2 != end_nbrs2) { - const BOND_SPTR bond2 = mol[*nbr2]; + const Bond* bond2 = mol[*nbr2]; ++nbr2; if (bond2->getIdx() == bond->getIdx() || !mol.getRingInfo()->numBondRings(bond2->getIdx())) { @@ -935,7 +935,7 @@ Point2D MolDraw2D::bondInsideRing(const ROMol &mol, const BOND_SPTR &bond, // cds1 and cds2 are 2 atoms in a chain double bond. Returns the perpendicular // pointing into the inside of the bond Point2D MolDraw2D::bondInsideDoubleBond(const ROMol &mol, - const BOND_SPTR &bond) { + const Bond* &bond) { // a chain double bond, were it looks nicer IMO if the 2nd line is inside // the angle of outgoing bond. Unless it's an allene, where nothing // looks great. @@ -953,7 +953,7 @@ Point2D MolDraw2D::bondInsideDoubleBond(const ROMol &mol, ROMol::OEDGE_ITER nbr2, end_nbrs2; boost::tie(nbr2, end_nbrs2) = mol.getAtomBonds(bond_atom); while (nbr2 != end_nbrs2) { - const BOND_SPTR bond2 = mol[*nbr2]; + const Bond* bond2 = mol[*nbr2]; ++nbr2; if (bond != bond2) { at3 = bond2->getOtherAtomIdx(bond_atom->getIdx()); diff --git a/Code/GraphMol/MolOps.cpp b/Code/GraphMol/MolOps.cpp index 9438e2227..ab9222554 100644 --- a/Code/GraphMol/MolOps.cpp +++ b/Code/GraphMol/MolOps.cpp @@ -467,7 +467,7 @@ std::vector getMolFrags(const ROMol &mol, bool sanitizeFrags, ROMol::EDGE_ITER beg, end; boost::tie(beg, end) = mol.getEdges(); while (beg != end) { - BOND_SPTR bond = (mol)[*beg]; + const Bond* bond = (mol)[*beg]; ++beg; if (!copiedBonds[bond->getIdx()]) { continue; diff --git a/Code/GraphMol/MolTransforms/MolTransforms.cpp b/Code/GraphMol/MolTransforms/MolTransforms.cpp index 91af3f2bf..20a4c3415 100644 --- a/Code/GraphMol/MolTransforms/MolTransforms.cpp +++ b/Code/GraphMol/MolTransforms/MolTransforms.cpp @@ -377,7 +377,7 @@ void _toBeMovedIdxList(const ROMol &mol, unsigned int iAtomId, boost::tie(nbrIdx, endNbrs) = mol.getAtomNeighbors(tAtom); unsigned int eIdx; for (eIdx = 0; nbrIdx != endNbrs; ++nbrIdx, ++eIdx) { - wIdx = (mol[*nbrIdx].get())->getIdx(); + wIdx = (mol[*nbrIdx])->getIdx(); if (!visitedIdx[wIdx]) { visitedIdx[wIdx] = 1; stack.push(wIdx); diff --git a/Code/GraphMol/QueryAtom.cpp b/Code/GraphMol/QueryAtom.cpp index c1b32b79f..d328998e7 100644 --- a/Code/GraphMol/QueryAtom.cpp +++ b/Code/GraphMol/QueryAtom.cpp @@ -54,10 +54,6 @@ void QueryAtom::expandQuery(QUERYATOM_QUERY *what, } } -bool QueryAtom::Match(const Atom::ATOM_SPTR &what) const { - return Match(what.get()); -} - namespace { bool localMatch(ATOM_EQUALS_QUERY const *q1, ATOM_EQUALS_QUERY const *q2) { if (q1->getNegation() == q2->getNegation()) { diff --git a/Code/GraphMol/QueryAtom.h b/Code/GraphMol/QueryAtom.h index 0ef51e8a9..74b22b763 100644 --- a/Code/GraphMol/QueryAtom.h +++ b/Code/GraphMol/QueryAtom.h @@ -69,8 +69,6 @@ class QueryAtom : public Atom { bool maintainOrder = true); //! returns true if we match Atom \c what - bool Match(const Atom::ATOM_SPTR &what) const; - //! \overload bool Match(Atom const *what) const; //! returns true if our query details match those of QueryAtom \c what diff --git a/Code/GraphMol/QueryBond.cpp b/Code/GraphMol/QueryBond.cpp index e7ac14f85..0c534ba70 100644 --- a/Code/GraphMol/QueryBond.cpp +++ b/Code/GraphMol/QueryBond.cpp @@ -95,10 +95,6 @@ void QueryBond::expandQuery(QUERYBOND_QUERY *what, } } -bool QueryBond::Match(const Bond::BOND_SPTR what) const { - return Match(what.get()); -} - namespace { bool localMatch(BOND_EQUALS_QUERY const *q1, BOND_EQUALS_QUERY const *q2) { if (q1->getNegation() == q2->getNegation()) { diff --git a/Code/GraphMol/QueryBond.h b/Code/GraphMol/QueryBond.h index 97d3e4ff6..4f2f19597 100644 --- a/Code/GraphMol/QueryBond.h +++ b/Code/GraphMol/QueryBond.h @@ -50,8 +50,6 @@ class QueryBond : public Bond { void setBondDir(BondDir bD); //! returns true if we match Bond \c what - bool Match(const Bond::BOND_SPTR what) const; - //! \overload bool Match(Bond const *what) const; //! returns true if our query details match those of QueryBond \c what diff --git a/Code/GraphMol/QueryOps.h b/Code/GraphMol/QueryOps.h index 53a237107..e44794ca9 100644 --- a/Code/GraphMol/QueryOps.h +++ b/Code/GraphMol/QueryOps.h @@ -132,7 +132,7 @@ static inline int queryAtomHasHeteroatomNbrs(Atom const *at) { ROMol::ADJ_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = at->getOwningMol().getAtomNeighbors(at); while (nbrIdx != endNbrs) { - const ATOM_SPTR nbr = at->getOwningMol()[*nbrIdx]; + const Atom *nbr = at->getOwningMol()[*nbrIdx]; if (nbr->getAtomicNum() != 6 && nbr->getAtomicNum() != 1) { return 1; } @@ -146,7 +146,7 @@ static inline int queryAtomNumHeteroatomNbrs(Atom const *at) { ROMol::ADJ_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = at->getOwningMol().getAtomNeighbors(at); while (nbrIdx != endNbrs) { - const ATOM_SPTR nbr = at->getOwningMol()[*nbrIdx]; + const Atom *nbr = at->getOwningMol()[*nbrIdx]; if (nbr->getAtomicNum() != 6 && nbr->getAtomicNum() != 1) { ++res; } @@ -159,7 +159,7 @@ static inline int queryAtomHasAliphaticHeteroatomNbrs(Atom const *at) { ROMol::ADJ_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = at->getOwningMol().getAtomNeighbors(at); while (nbrIdx != endNbrs) { - const ATOM_SPTR nbr = at->getOwningMol()[*nbrIdx]; + const Atom *nbr = at->getOwningMol()[*nbrIdx]; if ((!nbr->getIsAromatic()) && nbr->getAtomicNum() != 6 && nbr->getAtomicNum() != 1) { return 1; @@ -174,7 +174,7 @@ static inline int queryAtomNumAliphaticHeteroatomNbrs(Atom const *at) { ROMol::ADJ_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = at->getOwningMol().getAtomNeighbors(at); while (nbrIdx != endNbrs) { - const ATOM_SPTR nbr = at->getOwningMol()[*nbrIdx]; + const Atom *nbr = at->getOwningMol()[*nbrIdx]; if ((!nbr->getIsAromatic()) && nbr->getAtomicNum() != 6 && nbr->getAtomicNum() != 1) { ++res; diff --git a/Code/GraphMol/ROMol.cpp b/Code/GraphMol/ROMol.cpp index c33aefe7e..67c494eba 100644 --- a/Code/GraphMol/ROMol.cpp +++ b/Code/GraphMol/ROMol.cpp @@ -33,6 +33,17 @@ const int ci_ATOM_HOLDER = -0xDEADD06; void ROMol::destroy() { d_atomBookmarks.clear(); d_bondBookmarks.clear(); + + ATOM_ITER_PAIR atItP = boost::vertices(d_graph); + while (atItP.first != atItP.second) { + delete (d_graph)[*(atItP.first++)]; + } + + BOND_ITER_PAIR bondItP = boost::edges(d_graph); + while (bondItP.first != bondItP.second) { + delete (d_graph)[*(bondItP.first++)]; + } + d_graph.clear(); if (dp_ringInfo) { @@ -122,9 +133,7 @@ void ROMol::initMol() { unsigned int ROMol::getAtomDegree(const Atom *at) const { return rdcast(boost::out_degree(at->getIdx(), d_graph)); }; -unsigned int ROMol::getAtomDegree(Atom::ATOM_SPTR at) const { - return getAtomDegree(at.get()); -}; + unsigned int ROMol::getNumAtoms(bool onlyExplicit) const { int res = rdcast(boost::num_vertices(d_graph)); if (!onlyExplicit) { @@ -149,7 +158,7 @@ Atom *ROMol::getAtomWithIdx(unsigned int idx) { URANGE_CHECK(idx, getNumAtoms()); MolGraph::vertex_descriptor vd = boost::vertex(idx, d_graph); - Atom *res = d_graph[vd].get(); + Atom *res = d_graph[vd]; POSTCONDITION(res, ""); return res; } @@ -159,7 +168,7 @@ const Atom *ROMol::getAtomWithIdx(unsigned int idx) const { URANGE_CHECK(idx, getNumAtoms()); MolGraph::vertex_descriptor vd = boost::vertex(idx, d_graph); - const Atom *res = d_graph[vd].get(); + const Atom *res = d_graph[vd]; POSTCONDITION(res, ""); return res; @@ -248,7 +257,7 @@ Bond *ROMol::getBondWithIdx(unsigned int idx) { BOND_ITER_PAIR bIter = getEdges(); for (unsigned int i = 0; i < idx; i++) ++bIter.first; - Bond *res = d_graph[*(bIter.first)].get(); + Bond *res = d_graph[*(bIter.first)]; POSTCONDITION(res != nullptr, "Invalid bond requested"); return res; @@ -260,7 +269,7 @@ const Bond *ROMol::getBondWithIdx(unsigned int idx) const { BOND_ITER_PAIR bIter = getEdges(); for (unsigned int i = 0; i < idx; i++) ++bIter.first; - const Bond *res = d_graph[*(bIter.first)].get(); + const Bond *res = d_graph[*(bIter.first)]; POSTCONDITION(res != nullptr, "Invalid bond requested"); return res; @@ -276,7 +285,7 @@ Bond *ROMol::getBondBetweenAtoms(unsigned int idx1, unsigned int idx2) { boost::tie(edge, found) = boost::edge(boost::vertex(idx1, d_graph), boost::vertex(idx2, d_graph), d_graph); if (found) { - res = d_graph[edge].get(); + res = d_graph[edge]; } return res; } @@ -292,7 +301,7 @@ const Bond *ROMol::getBondBetweenAtoms(unsigned int idx1, boost::tie(edge, found) = boost::edge(boost::vertex(idx1, d_graph), boost::vertex(idx2, d_graph), d_graph); if (found) { - res = d_graph[edge].get(); + res = d_graph[edge]; } return res; } @@ -300,9 +309,7 @@ const Bond *ROMol::getBondBetweenAtoms(unsigned int idx1, ROMol::ADJ_ITER_PAIR ROMol::getAtomNeighbors(Atom const *at) const { return boost::adjacent_vertices(at->getIdx(), d_graph); }; -ROMol::ADJ_ITER_PAIR ROMol::getAtomNeighbors(Atom::ATOM_SPTR at) const { - return boost::adjacent_vertices(at->getIdx(), d_graph); -}; + ROMol::OBOND_ITER_PAIR ROMol::getAtomBonds(Atom const *at) const { return boost::out_edges(at->getIdx(), d_graph); } @@ -325,7 +332,7 @@ unsigned int ROMol::addAtom(Atom *atom_pin, bool updateLabel, atom_p->setOwningMol(this); MolGraph::vertex_descriptor which = boost::add_vertex(d_graph); - d_graph[which].reset(atom_p); + d_graph[which] = atom_p; atom_p->setIdx(which); if (updateLabel) { replaceAtomBookmark(atom_p, ci_RIGHTMOST_ATOM); @@ -336,9 +343,7 @@ unsigned int ROMol::addAtom(Atom *atom_pin, bool updateLabel, } return rdcast(which); }; -unsigned int ROMol::addAtom(Atom::ATOM_SPTR atom_sp, bool updateLabel) { - return addAtom(atom_sp.get(), updateLabel, false); -} + unsigned int ROMol::addBond(Bond *bond_pin, bool takeOwnership) { PRECONDITION(bond_pin, "null bond passed in"); URANGE_CHECK(bond_pin->getBeginAtomIdx(), getNumAtoms()); @@ -362,13 +367,12 @@ unsigned int ROMol::addBond(Bond *bond_pin, bool takeOwnership) { boost::tie(which, ok) = boost::add_edge(bond_p->getBeginAtomIdx(), bond_p->getEndAtomIdx(), d_graph); CHECK_INVARIANT(ok, "bond could not be added"); - d_graph[which].reset(bond_p); + d_graph[which] = bond_p; numBonds++; // int res = rdcast(boost::num_edges(d_graph)); bond_p->setIdx(numBonds - 1); return numBonds; // res; } -unsigned int ROMol::addBond(Bond::BOND_SPTR bsp) { return addBond(bsp.get()); } void ROMol::debugMol(std::ostream &str) const { ATOM_ITER_PAIR atItP = getVertices(); @@ -376,12 +380,12 @@ void ROMol::debugMol(std::ostream &str) const { str << "Atoms:" << std::endl; while (atItP.first != atItP.second) { - str << "\t" << *d_graph[*(atItP.first++)].get() << std::endl; + str << "\t" << *d_graph[*(atItP.first++)] << std::endl; } str << "Bonds:" << std::endl; while (bondItP.first != bondItP.second) { - str << "\t" << *d_graph[*(bondItP.first++)].get() << std::endl; + str << "\t" << *d_graph[*(bondItP.first++)] << std::endl; } } diff --git a/Code/GraphMol/ROMol.h b/Code/GraphMol/ROMol.h index 405207670..a403afeca 100644 --- a/Code/GraphMol/ROMol.h +++ b/Code/GraphMol/ROMol.h @@ -38,12 +38,9 @@ namespace RDKit { class Atom; class Bond; -typedef boost::shared_ptr ATOM_SPTR; -typedef boost::shared_ptr BOND_SPTR; - //! This is the BGL type used to store the topology: typedef boost::adjacency_list + Atom *, Bond *> MolGraph; class MolPickler; class RWMol; @@ -102,62 +99,68 @@ extern const int ci_ATOM_HOLDER; //! \name C++11 Iterators -template +template struct CXXAtomIterator { Graph *graph; typename Graph::vertex_iterator vstart, vend; - + struct CXXAtomIter { Graph *graph; typename Graph::vertex_iterator pos; Atom *current; - - CXXAtomIter(Graph *graph, - typename Graph::vertex_iterator pos) : - graph(graph), pos(pos), - current(boost::num_vertices(*graph) ? (*graph)[*pos].get() : 0) {} - - Vertex& operator*() { return current; } - CXXAtomIter& operator++() { current = (*graph)[*(++pos)].get(); return *this; } - bool operator!=(const CXXAtomIter&it) const { return pos != it.pos; } + + CXXAtomIter(Graph *graph, typename Graph::vertex_iterator pos) + : graph(graph), + pos(pos), + current(boost::num_vertices(*graph) ? (*graph)[*pos] : 0) {} + + Vertex &operator*() { return current; } + CXXAtomIter &operator++() { + current = (*graph)[*(++pos)]; + return *this; + } + bool operator!=(const CXXAtomIter &it) const { return pos != it.pos; } }; - - CXXAtomIterator(Graph *graph) : graph(graph) { - auto vs = boost::vertices(*graph); - vstart = vs.first; - vend = vs.second; - } - CXXAtomIter begin() { return { graph, vstart }; } - CXXAtomIter end() { return { graph, vend }; } + + CXXAtomIterator(Graph *graph) : graph(graph) { + auto vs = boost::vertices(*graph); + vstart = vs.first; + vend = vs.second; + } + CXXAtomIter begin() { return {graph, vstart}; } + CXXAtomIter end() { return {graph, vend}; } }; -template +template struct CXXBondIterator { Graph *graph; typename Graph::edge_iterator vstart, vend; - + struct CXXBondIter { Graph *graph; typename Graph::edge_iterator pos; Bond *current; - - CXXBondIter(Graph *graph, - typename Graph::edge_iterator pos) : - graph(graph), pos(pos), - current(boost::num_vertices(*graph) ? (*graph)[*pos].get() : 0) {} - - Edge& operator*() { return current; } - CXXBondIter& operator++() { current = (*graph)[*(++pos)].get(); return *this; } - bool operator!=(const CXXBondIter&it) const { return pos != it.pos; } + + CXXBondIter(Graph *graph, typename Graph::edge_iterator pos) + : graph(graph), + pos(pos), + current(boost::num_vertices(*graph) ? (*graph)[*pos] : 0) {} + + Edge &operator*() { return current; } + CXXBondIter &operator++() { + current = (*graph)[*(++pos)]; + return *this; + } + bool operator!=(const CXXBondIter &it) const { return pos != it.pos; } }; - - CXXBondIterator(Graph *graph) : graph(graph) { - auto vs = boost::edges(*graph); - vstart = vs.first; - vend = vs.second; - } - CXXBondIter begin() { return { graph, vstart }; } - CXXBondIter end() { return { graph, vend }; } + + CXXBondIterator(Graph *graph) : graph(graph) { + auto vs = boost::edges(*graph); + vstart = vs.first; + vend = vs.second; + } + CXXBondIter begin() { return {graph, vstart}; } + CXXBondIter end() { return {graph, vend}; } }; class ROMol : public RDProps { @@ -181,13 +184,6 @@ class ROMol : public RDProps { typedef std::pair ATOM_ITER_PAIR; typedef std::pair ADJ_ITER_PAIR; - typedef std::vector ATOM_SPTR_VECT; - typedef ATOM_SPTR_VECT::iterator ATOM_SPTR_VECT_I; - typedef ATOM_SPTR_VECT::const_iterator ATOM_SPTR_VECT_CI; - typedef std::vector BOND_SPTR_VECT; - typedef BOND_SPTR_VECT::iterator BOND_SPTR_VECT_I; - typedef BOND_SPTR_VECT::const_iterator BOND_SPTR_VECT_CI; - typedef std::vector ATOM_PTR_VECT; typedef ATOM_PTR_VECT::iterator ATOM_PTR_VECT_I; typedef ATOM_PTR_VECT::const_iterator ATOM_PTR_VECT_CI; @@ -244,33 +240,28 @@ class ROMol : public RDProps { }; \endcode */ - - CXXAtomIterator atoms() { - return { &d_graph }; + + CXXAtomIterator atoms() { return {&d_graph}; } + + CXXAtomIterator atoms() const { + return {&d_graph}; } - CXXAtomIterator atoms() const { - return { &d_graph }; + /*! + Usage + \code + for(auto bond : mol.bonds()) { + bond->getIdx(); + }; + \endcode + */ + + CXXBondIterator bonds() { return {&d_graph}; } + + CXXBondIterator bonds() const { + return {&d_graph}; } - /*! - Usage - \code - for(auto bond : mol.bonds()) { - bond->getIdx(); - }; - \endcode - */ - - CXXBondIterator bonds() { - return { &d_graph }; - } - - CXXBondIterator bonds() const { - return { &d_graph }; - } - - ROMol() : RDProps(), numBonds(0) { initMol(); } //! copy constructor with a twist @@ -319,8 +310,6 @@ class ROMol : public RDProps { } //! returns the degree (number of neighbors) of an Atom in the graph unsigned int getAtomDegree(const Atom *at) const; - //! \overload - unsigned int getAtomDegree(ATOM_SPTR at) const; //@} //! \name Bonds @@ -365,19 +354,10 @@ class ROMol : public RDProps { //@{ //! associates an Atom pointer with a bookmark - void setAtomBookmark(ATOM_SPTR at, int mark) { - d_atomBookmarks[mark].push_back(at.get()); - }; - //! \overload void setAtomBookmark(Atom *at, int mark) { d_atomBookmarks[mark].push_back(at); }; //! associates an Atom pointer with a bookmark - void replaceAtomBookmark(ATOM_SPTR at, int mark) { - d_atomBookmarks[mark].clear(); - d_atomBookmarks[mark].push_back(at.get()); - }; - //! \overload void replaceAtomBookmark(Atom *at, int mark) { d_atomBookmarks[mark].clear(); d_atomBookmarks[mark].push_back(at); @@ -390,10 +370,7 @@ class ROMol : public RDProps { void clearAtomBookmark(const int mark); //! removes a particular Atom from the list associated with the \c bookmark void clearAtomBookmark(const int mark, const Atom *atom); - //! \overload - void clearAtomBookmark(const int mark, ATOM_SPTR atom) { - clearAtomBookmark(mark, atom.get()); - }; + //! blows out all atomic \c bookmarks void clearAllAtomBookmarks() { d_atomBookmarks.clear(); }; //! queries whether or not any atoms are associated with a \c bookmark @@ -402,10 +379,6 @@ class ROMol : public RDProps { ATOM_BOOKMARK_MAP *getAtomBookmarks() { return &d_atomBookmarks; }; //! associates a Bond pointer with a bookmark - void setBondBookmark(BOND_SPTR bond, int mark) { - d_bondBookmarks[mark].push_back(bond.get()); - }; - //! \overload void setBondBookmark(Bond *bond, int mark) { d_bondBookmarks[mark].push_back(bond); }; @@ -417,10 +390,7 @@ class ROMol : public RDProps { void clearBondBookmark(int mark); //! removes a particular Bond from the list associated with the \c bookmark void clearBondBookmark(int mark, const Bond *bond); - //! \overload - void clearBondBookmark(int mark, BOND_SPTR bond) { - clearBondBookmark(mark, bond.get()); - }; + //! blows out all bond \c bookmarks void clearAllBondBookmarks() { d_bondBookmarks.clear(); }; //! queries whether or not any bonds are associated with a \c bookmark @@ -491,8 +461,6 @@ class ROMol : public RDProps { */ ADJ_ITER_PAIR getAtomNeighbors(Atom const *at) const; - //! \overload - ADJ_ITER_PAIR getAtomNeighbors(ATOM_SPTR at) const; //! provides access to all Bond objects connected to an Atom /*! @@ -671,15 +639,13 @@ class ROMol : public RDProps { void debugMol(std::ostream &str) const; //@} - ATOM_SPTR operator[](const vertex_descriptor &v) { return d_graph[v]; }; - const ATOM_SPTR operator[](const vertex_descriptor &v) const { + Atom *operator[](const vertex_descriptor &v) { return d_graph[v]; }; + const Atom *operator[](const vertex_descriptor &v) const { return d_graph[v]; }; - BOND_SPTR operator[](const edge_descriptor &e) { return d_graph[e]; }; - const BOND_SPTR operator[](const edge_descriptor &e) const { - return d_graph[e]; - }; + Bond *operator[](const edge_descriptor &e) { return d_graph[e]; }; + const Bond *operator[](const edge_descriptor &e) const { return d_graph[e]; }; private: MolGraph d_graph; @@ -710,21 +676,6 @@ class ROMol : public RDProps { */ unsigned int addAtom(Atom *atom, bool updateLabel = true, bool takeOwnership = false); - //! adds an Atom to our collection - /*! - \param atom pointer to the Atom to add - \param updateLabel (optional) if this is true, the new Atom will be - our \c activeAtom - - - \return the new number of atoms - - Note: since this is using a smart pointer, we don't need to worry - about - issues of ownership. - - */ - unsigned int addAtom(ATOM_SPTR, bool updateLabel = true); //! adds a Bond to our collection /*! \param bond pointer to the Bond to add @@ -745,18 +696,6 @@ class ROMol : public RDProps { about issues of ownership. */ - unsigned int addBond(BOND_SPTR bsp); - - //! initializes from the contents of another molecule - /*! - \param other the molecule to be copied - \param quickCopy if this is true, we will not - copy any of the properties or bookmarks and conformers from \c other. - This can - make the copy substantially faster (thus the name). - \param confId if this is >=0, the resulting ROMol will contain only - the specified conformer from \c other. - */ void initFromOther(const ROMol &other, bool quickCopy, int confId); }; diff --git a/Code/GraphMol/RWMol.cpp b/Code/GraphMol/RWMol.cpp index 8b6adbf9f..843a732ab 100644 --- a/Code/GraphMol/RWMol.cpp +++ b/Code/GraphMol/RWMol.cpp @@ -113,7 +113,7 @@ unsigned int RWMol::addAtom(bool updateLabel) { auto *atom_p = new Atom(); atom_p->setOwningMol(this); MolGraph::vertex_descriptor which = boost::add_vertex(d_graph); - d_graph[which].reset(atom_p); + d_graph[which] = atom_p; atom_p->setIdx(which); if (updateLabel) { clearAtomBookmark(ci_RIGHTMOST_ATOM); @@ -138,9 +138,10 @@ void RWMol::replaceAtom(unsigned int idx, Atom *atom_pin, bool updateLabel, MolGraph::vertex_descriptor vd = boost::vertex(idx, d_graph); if (preserveProps) { const bool replaceExistingData = false; - atom_p->updateProps(*d_graph[vd].get(), replaceExistingData); + atom_p->updateProps(*d_graph[vd], replaceExistingData); } - d_graph[vd].reset(atom_p); + delete d_graph[vd]; + d_graph[vd] = atom_p; // FIX: do something about bookmarks }; @@ -149,7 +150,7 @@ void RWMol::replaceBond(unsigned int idx, Bond *bond_pin, bool preserveProps) { URANGE_CHECK(idx, getNumBonds()); BOND_ITER_PAIR bIter = getEdges(); for (unsigned int i = 0; i < idx; i++) ++bIter.first; - BOND_SPTR obond = d_graph[*(bIter.first)]; + Bond* obond = d_graph[*(bIter.first)]; Bond *bond_p = bond_pin->copy(); bond_p->setOwningMol(this); bond_p->setIdx(idx); @@ -157,10 +158,11 @@ void RWMol::replaceBond(unsigned int idx, Bond *bond_pin, bool preserveProps) { bond_p->setEndAtomIdx(obond->getEndAtomIdx()); if (preserveProps) { const bool replaceExistingData = false; - bond_p->updateProps(*d_graph[*(bIter.first)].get(), replaceExistingData); + bond_p->updateProps(*d_graph[*(bIter.first)], replaceExistingData); } - d_graph[*(bIter.first)].reset(bond_p); + delete d_graph[*(bIter.first)]; + d_graph[*(bIter.first)] = bond_p; // FIX: do something about bookmarks }; @@ -239,7 +241,7 @@ void RWMol::removeAtom(Atom *atom) { EDGE_ITER beg, end; boost::tie(beg, end) = getEdges(); while (beg != end) { - BOND_SPTR bond = d_graph[*beg++]; + Bond* bond = d_graph[*beg++]; unsigned int tmpIdx = bond->getBeginAtomIdx(); if (tmpIdx > idx) bond->setBeginAtomIdx(tmpIdx - 1); tmpIdx = bond->getEndAtomIdx(); @@ -267,6 +269,7 @@ void RWMol::removeAtom(Atom *atom) { boost::clear_vertex(vd, d_graph); // finally remove the vertex itself boost::remove_vertex(vd, d_graph); + delete atom; } unsigned int RWMol::addBond(unsigned int atomIdx1, unsigned int atomIdx2, @@ -293,7 +296,7 @@ unsigned int RWMol::addBond(unsigned int atomIdx1, unsigned int atomIdx2, bool ok; MolGraph::edge_descriptor which; boost::tie(which, ok) = boost::add_edge(atomIdx1, atomIdx2, d_graph); - d_graph[which].reset(b); + d_graph[which] = b; // unsigned int res = rdcast(boost::num_edges(d_graph)); ++numBonds; b->setIdx(numBonds - 1); @@ -316,11 +319,6 @@ unsigned int RWMol::addBond(Atom *atom1, Atom *atom2, Bond::BondType bondType) { return addBond(atom1->getIdx(), atom2->getIdx(), bondType); } -unsigned int RWMol::addBond(Atom::ATOM_SPTR atom1, Atom::ATOM_SPTR atom2, - Bond::BondType bondType) { - return addBond(atom1->getIdx(), atom2->getIdx(), bondType); -} - void RWMol::removeBond(unsigned int aid1, unsigned int aid2) { URANGE_CHECK(aid1, getNumAtoms()); URANGE_CHECK(aid2, getNumAtoms()); @@ -373,7 +371,7 @@ void RWMol::removeBond(unsigned int aid1, unsigned int aid2) { ROMol::EDGE_ITER firstB, lastB; boost::tie(firstB, lastB) = this->getEdges(); while (firstB != lastB) { - BOND_SPTR bond = (*this)[*firstB]; + Bond* bond = (*this)[*firstB]; if (bond->getIdx() > idx) { bond->setIdx(bond->getIdx() - 1); } @@ -384,6 +382,7 @@ void RWMol::removeBond(unsigned int aid1, unsigned int aid2) { MolGraph::vertex_descriptor vd1 = boost::vertex(aid1, d_graph); MolGraph::vertex_descriptor vd2 = boost::vertex(aid2, d_graph); boost::remove_edge(vd1, vd2, d_graph); + delete bnd; --numBonds; } diff --git a/Code/GraphMol/RWMol.h b/Code/GraphMol/RWMol.h index 8b98b0030..006818101 100644 --- a/Code/GraphMol/RWMol.h +++ b/Code/GraphMol/RWMol.h @@ -80,22 +80,6 @@ class RWMol : public ROMol { }; //! adds an Atom to our collection - /*! - \param atom pointer to the Atom to add - \param updateLabel (optional) if this is true, the new Atom will be - our \c activeAtom - - - \return the new number of atoms - - Note: since this is using a smart pointer, we don't need to worry - about - issues of ownership. - - */ - unsigned int addAtom(ATOM_SPTR atom, bool updateLabel = true) { - return ROMol::addAtom(atom, updateLabel); - }; //! replaces a particular Atom /*! @@ -137,9 +121,6 @@ class RWMol : public ROMol { unsigned int addBond(unsigned int beginAtomIdx, unsigned int endAtomIdx, Bond::BondType order = Bond::UNSPECIFIED); //! \overload - unsigned int addBond(ATOM_SPTR beginAtom, ATOM_SPTR endAtom, - Bond::BondType order = Bond::UNSPECIFIED); - //! \overload unsigned int addBond(Atom *beginAtom, Atom *endAtom, Bond::BondType order = Bond::UNSPECIFIED); @@ -155,17 +136,6 @@ class RWMol : public ROMol { unsigned int addBond(Bond *bond, bool takeOwnership = false) { return ROMol::addBond(bond, takeOwnership); }; - //! adds a Bond to our collection - /*! - \param bsp smart pointer to the Bond to add - - \return the new number of bonds - - Note: since this is using a smart pointer, we don't need to worry - about - issues of ownership. - */ - unsigned int addBond(BOND_SPTR bsp) { return ROMol::addBond(bsp); }; //! starts a Bond and sets its beginAtomIdx /*! @@ -222,19 +192,16 @@ class RWMol : public ROMol { //! removes all atoms, bonds, properties, bookmarks, etc. void clear() { - d_atomBookmarks.clear(); - d_bondBookmarks.clear(); - d_graph.clear(); + destroy(); d_confs.clear(); dp_props.reset(); STR_VECT computed; dp_props.setVal(RDKit::detail::computedPropName, computed); numBonds = 0; - if (dp_ringInfo) dp_ringInfo->reset(); }; - + private: - std::vector d_partialBonds; + std::vector d_partialBonds; void destroy(); }; diff --git a/Code/GraphMol/Resonance.cpp b/Code/GraphMol/Resonance.cpp index dd0df2f00..441110da2 100644 --- a/Code/GraphMol/Resonance.cpp +++ b/Code/GraphMol/Resonance.cpp @@ -311,7 +311,7 @@ bool AtomElectrons::isNbrCharged(unsigned int bo, unsigned int oeConstraint) { ROMol::OEDGE_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = mol.getAtomBonds(d_atom); for (; !res && (nbrIdx != endNbrs); ++nbrIdx) { - const Bond *bondNbr = mol[*nbrIdx].get(); + const Bond *bondNbr = mol[*nbrIdx]; unsigned int biNbr = bondNbr->getIdx(); if (d_parent->parent()->getBondConjGrpIdx(biNbr) != conjGrpIdx()) continue; BondElectrons *beNbr = d_parent->getBondElectronsWithIdx(biNbr); @@ -373,7 +373,7 @@ void AtomElectrons::allConjBondsDefinitiveBut(unsigned int bi) { ROMol::OEDGE_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = mol.getAtomBonds(d_atom); for (; allDefinitive && (nbrIdx != endNbrs); ++nbrIdx) { - unsigned int nbi = mol[*nbrIdx].get()->getIdx(); + unsigned int nbi = mol[*nbrIdx]->getIdx(); if ((nbi != bi) && (d_parent->parent()->getBondConjGrpIdx(nbi) == conjGrpIdx())) allDefinitive = d_parent->getBondElectronsWithIdx(nbi)->isDefinitive(); @@ -1333,7 +1333,7 @@ void ResonanceMolSupplier::buildCEMap(CEMap &ceMap, unsigned int conjGrpIdx) { boost::tie(nbrIdx, endNbrs) = d_mol->getAtomNeighbors(ae[BEGIN_POS]->atom()); for (; nbrIdx != endNbrs; ++nbrIdx) { - unsigned int aiNbr = (*d_mol)[*nbrIdx].get()->getIdx(); + unsigned int aiNbr = (*d_mol)[*nbrIdx]->getIdx(); // if this neighbor is not part of the conjugated group, // ignore it if (ce->parent()->getAtomConjGrpIdx(aiNbr) != diff --git a/Code/GraphMol/SmilesParse/SmilesParseOps.cpp b/Code/GraphMol/SmilesParse/SmilesParseOps.cpp index 21ad0b9a0..a6fa9c4ef 100644 --- a/Code/GraphMol/SmilesParse/SmilesParseOps.cpp +++ b/Code/GraphMol/SmilesParse/SmilesParseOps.cpp @@ -238,7 +238,7 @@ bool isUnsaturated(const Atom *atom, const RWMol *mol) { ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol->getAtomBonds(atom); while (beg != end) { - const BOND_SPTR bond = (*mol)[*beg]; + const Bond* bond = (*mol)[*beg]; ++beg; if (bond->getBondType() != Bond::SINGLE) return true; } diff --git a/Code/GraphMol/SmilesParse/SmilesWrite.cpp b/Code/GraphMol/SmilesParse/SmilesWrite.cpp index ba52fb574..601c7a8dd 100644 --- a/Code/GraphMol/SmilesParse/SmilesWrite.cpp +++ b/Code/GraphMol/SmilesParse/SmilesWrite.cpp @@ -559,7 +559,7 @@ std::string MolFragmentToSmiles(const ROMol &mol, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(mol.getAtomWithIdx(aidx)); while (beg != end) { - const BOND_SPTR bond = mol[*beg]; + const Bond* bond = mol[*beg]; if (atomsInPlay[bond->getOtherAtomIdx(aidx)]) bondsInPlay.set(bond->getIdx()); ++beg; diff --git a/Code/GraphMol/Subgraphs/Subgraphs.cpp b/Code/GraphMol/Subgraphs/Subgraphs.cpp index 232328332..ca26117e6 100644 --- a/Code/GraphMol/Subgraphs/Subgraphs.cpp +++ b/Code/GraphMol/Subgraphs/Subgraphs.cpp @@ -43,7 +43,7 @@ void getNbrsList(const ROMol &mol, bool useHs, INT_INT_VECT_MAP &nbrs) { ROMol::OEDGE_ITER bIt1, end; boost::tie(bIt1, end) = mol.getAtomBonds(atom); while (bIt1 != end) { - const BOND_SPTR bond1 = mol[*bIt1]; + const Bond* bond1 = mol[*bIt1]; // if this bond connect to a hydrogen and we are not interested // in it ignore if (useHs || bond1->getOtherAtom(atom)->getAtomicNum() != 1) { @@ -54,7 +54,7 @@ void getNbrsList(const ROMol &mol, bool useHs, INT_INT_VECT_MAP &nbrs) { } ROMol::OEDGE_ITER bIt2 = mol.getAtomBonds(atom).first; while (bIt2 != end) { - const BOND_SPTR bond2 = mol[*bIt2]; + const Bond* bond2 = mol[*bIt2]; int bid2 = bond2->getIdx(); if (bid1 != bid2 && (useHs || bond2->getOtherAtom(atom)->getAtomicNum() != 1)) { @@ -548,7 +548,7 @@ PATH_TYPE findAtomEnvironmentOfRadiusN(const ROMol &mol, unsigned int radius, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(mol.getAtomWithIdx(rootedAtAtom)); while (beg != end) { - BOND_SPTR bond = mol[*beg]; + const Bond* bond = mol[*beg]; if (useHs || mol.getAtomWithIdx(bond->getOtherAtomIdx(rootedAtAtom)) ->getAtomicNum() != 1) { @@ -576,7 +576,7 @@ PATH_TYPE findAtomEnvironmentOfRadiusN(const ROMol &mol, unsigned int radius, int oAtom = mol.getBondWithIdx(bondIdx)->getOtherAtomIdx(startAtom); boost::tie(beg, end) = mol.getAtomBonds(mol.getAtomWithIdx(oAtom)); while (beg != end) { - BOND_SPTR bond = mol[*beg]; + const Bond* bond = mol[*beg]; if (!bondsIn.test(bond->getIdx())) { if (useHs || mol.getAtomWithIdx(bond->getOtherAtomIdx(oAtom)) diff --git a/Code/GraphMol/Substruct/SubstructMatch.cpp b/Code/GraphMol/Substruct/SubstructMatch.cpp index 51774b904..b16d0a414 100644 --- a/Code/GraphMol/Substruct/SubstructMatch.cpp +++ b/Code/GraphMol/Substruct/SubstructMatch.cpp @@ -242,10 +242,10 @@ class BondLabelFunctor { bool operator()(MolGraph::edge_descriptor i, MolGraph::edge_descriptor j) const { if (df_useChirality) { - const BOND_SPTR qBnd = d_query[i]; + const Bond* qBnd = d_query[i]; if (qBnd->getBondType() == Bond::DOUBLE && qBnd->getStereo() > Bond::STEREOANY) { - const BOND_SPTR mBnd = d_mol[j]; + const Bond* mBnd = d_mol[j]; if (mBnd->getBondType() == Bond::DOUBLE && mBnd->getStereo() <= Bond::STEREOANY) return false; diff --git a/Code/GraphMol/Substruct/SubstructUtils.cpp b/Code/GraphMol/Substruct/SubstructUtils.cpp index fb1629f8e..81fa068a3 100644 --- a/Code/GraphMol/Substruct/SubstructUtils.cpp +++ b/Code/GraphMol/Substruct/SubstructUtils.cpp @@ -16,7 +16,7 @@ namespace RDKit { -bool atomCompat(const ATOM_SPTR &a1, const ATOM_SPTR &a2, +bool atomCompat(const Atom* a1, const Atom* a2, bool useQueryQueryMatches) { PRECONDITION(a1, "bad atom"); PRECONDITION(a2, "bad atom"); @@ -24,8 +24,8 @@ bool atomCompat(const ATOM_SPTR &a1, const ATOM_SPTR &a2, // " " << a2->getIdx() << std::endl; bool res; if (useQueryQueryMatches && a1->hasQuery() && a2->hasQuery()) { - res = static_cast(a1.get())->QueryMatch( - static_cast(a2.get())); + res = static_cast(a1)->QueryMatch( + static_cast(a2)); } else { res = a1->Match(a2); } @@ -36,7 +36,7 @@ bool atomCompat(const ATOM_SPTR &a1, const ATOM_SPTR &a2, return res; } -bool chiralAtomCompat(const ATOM_SPTR &a1, const ATOM_SPTR &a2) { +bool chiralAtomCompat(const Atom* &a1, const Atom* &a2) { PRECONDITION(a1, "bad atom"); PRECONDITION(a2, "bad atom"); bool res = a1->Match(a2); @@ -54,14 +54,14 @@ bool chiralAtomCompat(const ATOM_SPTR &a1, const ATOM_SPTR &a2) { return res; } -bool bondCompat(const BOND_SPTR &b1, const BOND_SPTR &b2, +bool bondCompat(const Bond* b1, const Bond* b2, bool useQueryQueryMatches) { PRECONDITION(b1, "bad bond"); PRECONDITION(b2, "bad bond"); bool res; if (useQueryQueryMatches && b1->hasQuery() && b2->hasQuery()) { - res = static_cast(b1.get())->QueryMatch( - static_cast(b2.get())); + res = static_cast(b1)->QueryMatch( + static_cast(b2)); } else { res = b1->Match(b2); } diff --git a/Code/GraphMol/Substruct/SubstructUtils.h b/Code/GraphMol/Substruct/SubstructUtils.h index a34d58188..41382144c 100644 --- a/Code/GraphMol/Substruct/SubstructUtils.h +++ b/Code/GraphMol/Substruct/SubstructUtils.h @@ -17,15 +17,13 @@ namespace RDKit { class ROMol; class Atom; class Bond; -typedef boost::shared_ptr ATOM_SPTR; -typedef boost::shared_ptr BOND_SPTR; double toPrime(const MatchVectType &v); void removeDuplicates(std::vector &v, unsigned int nAtoms); -bool atomCompat(const ATOM_SPTR &a1, const ATOM_SPTR &a2, +bool atomCompat(const Atom* a1, const Atom* a2, bool useQueryQueryMatches = false); -bool chiralAtomCompat(const ATOM_SPTR &a1, const ATOM_SPTR &a2); -bool bondCompat(const BOND_SPTR &b1, const BOND_SPTR &b2, +bool chiralAtomCompat(const Atom* a1, const Atom* a2); +bool bondCompat(const Bond* b1, const Bond* b2, bool useQueryQueryMatches = false); } diff --git a/Code/GraphMol/Wrap/Atom.cpp b/Code/GraphMol/Wrap/Atom.cpp index 1bb814871..a51b2bb42 100644 --- a/Code/GraphMol/Wrap/Atom.cpp +++ b/Code/GraphMol/Wrap/Atom.cpp @@ -72,7 +72,7 @@ python::tuple AtomGetBonds(Atom *atom) { ROMol::OEDGE_ITER begin, end; boost::tie(begin, end) = parent->getAtomBonds(atom); while (begin != end) { - Bond *tmpB = (*parent)[*begin].get(); + const Bond *tmpB = (*parent)[*begin]; res.append(python::ptr(tmpB)); begin++; } diff --git a/Code/GraphMol/blah b/Code/GraphMol/blah index cdd979f5d..2fb65edee 100644 --- a/Code/GraphMol/blah +++ b/Code/GraphMol/blah @@ -409,7 +409,7 @@ std::vector getMolFrags(const ROMol &mol, bool sanitizeFrags, ROMol::EDGE_ITER beg, end; boost::tie(beg, end) = mol.getEdges(); while (beg != end) { - BOND_SPTR bond = (mol)[*beg]; + Bond* bond = (mol)[*beg]; ++beg; if (!copiedBonds[bond->getIdx()]) { continue; diff --git a/Code/GraphMol/hanoitest.cpp b/Code/GraphMol/hanoitest.cpp index 8efc8a68b..9cf33afe4 100644 --- a/Code/GraphMol/hanoitest.cpp +++ b/Code/GraphMol/hanoitest.cpp @@ -343,7 +343,7 @@ class atomcomparefunctor3 { ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = dp_mol->getAtomBonds(at); while (beg != end) { - const BOND_SPTR bond = (*dp_mol)[*beg]; + const Bond* bond = (*dp_mol)[*beg]; nbrs[nbridx] = static_cast(100 * bond->getBondTypeAsDouble()) + dp_atoms[bond->getOtherAtomIdx(i)].index; diff --git a/Code/GraphMol/new_canon.cpp b/Code/GraphMol/new_canon.cpp index ca75aa326..2f9b2f1c6 100644 --- a/Code/GraphMol/new_canon.cpp +++ b/Code/GraphMol/new_canon.cpp @@ -292,7 +292,7 @@ bool hasRingNbr(const ROMol &mol, const Atom *at) { ROMol::ADJ_ITER beg, end; boost::tie(beg, end) = mol.getAtomNeighbors(at); while (beg != end) { - const ATOM_SPTR nbr = mol[*beg]; + const Atom* nbr = mol[*beg]; ++beg; if ((nbr->getChiralTag() == Atom::CHI_TETRAHEDRAL_CW || nbr->getChiralTag() == Atom::CHI_TETRAHEDRAL_CCW) && @@ -309,7 +309,7 @@ void getNbrs(const ROMol &mol, const Atom *at, int *ids) { unsigned int idx = 0; while (beg != end) { - const BOND_SPTR bond = (mol)[*beg]; + const Bond* bond = (mol)[*beg]; ++beg; unsigned int nbrIdx = bond->getOtherAtomIdx(at->getIdx()); ids[idx] = nbrIdx; @@ -335,10 +335,10 @@ void getBonds(const ROMol &mol, const Atom *at, std::vector &nbrs, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(at); while (beg != end) { - const BOND_SPTR bond = (mol)[*beg]; + const Bond* bond = (mol)[*beg]; ++beg; nbrs.push_back(makeBondHolder( - bond.get(), bond->getOtherAtomIdx(at->getIdx()), includeChirality)); + bond, bond->getOtherAtomIdx(at->getIdx()), includeChirality)); } std::sort(nbrs.begin(), nbrs.end(), bondholder::greater); } @@ -348,7 +348,7 @@ void getChiralBonds(const ROMol &mol, const Atom *at, ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(at); while (beg != end) { - const BOND_SPTR bond = (mol)[*beg]; + const Bond* bond = (mol)[*beg]; ++beg; unsigned int nbrIdx = bond->getOtherAtomIdx(at->getIdx()); const Atom *nbr = mol.getAtomWithIdx(nbrIdx); diff --git a/Code/GraphMol/querytest.cpp b/Code/GraphMol/querytest.cpp index 5bbd77510..4c4f79d71 100644 --- a/Code/GraphMol/querytest.cpp +++ b/Code/GraphMol/querytest.cpp @@ -52,8 +52,7 @@ void test1() { qM.addAtom(qA); delete qA; qM.addAtom(new QueryAtom(8), true, true); - // Atom::ATOM_SPTR qA(new QueryAtom(6)); - + QueryBond *qB; qB = new QueryBond(Bond::UNSPECIFIED); qB->setOwningMol(qM); diff --git a/Code/GraphMol/test-valgrind.cpp b/Code/GraphMol/test-valgrind.cpp new file mode 100644 index 000000000..e14294185 --- /dev/null +++ b/Code/GraphMol/test-valgrind.cpp @@ -0,0 +1,59 @@ +// +// Copyright (C) 2018 Novartis Institutes Of BioMedical Research +// +// @@ All Rights Reserved @@ +// This file is part of the RDKit. +// The contents are covered by the terms of the BSD license +// which is included in the file license.txt, found at the root +// of the RDKit source tree. +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace RDKit; + +// memory tests for valgrind +void testRemoveAtomBond(RWMol &m, int atomidx, int bondidx) +{ + const Bond *b = m.getBondWithIdx(bondidx); + if (bondidx>=0) m.removeBond(b->getBeginAtomIdx(), b->getEndAtomIdx()); + if (atomidx>=0) m.removeAtom(atomidx); +} + +void testRemovals(RWMol m) { + for(unsigned int i=0;igetIdx() == *atBegin); atBegin++; } @@ -1207,8 +1207,8 @@ void testAtomListLineRoundTrip() { MolDataStreamToMol(inStream2, line, sanitize, removeHs, strictParsing); TEST_ASSERT(m2); TEST_ASSERT(desc == qhelper(m2->getAtomWithIdx(3)->getQuery())); - Atom::ATOM_SPTR cl(new Atom(17)); - Atom::ATOM_SPTR o(new Atom(17)); + Atom* cl(new Atom(17)); + Atom* o(new Atom(17)); TEST_ASSERT(dynamic_cast(m->getAtomWithIdx(3))->Match(cl)); TEST_ASSERT(dynamic_cast(m->getAtomWithIdx(3))->Match(o)); TEST_ASSERT(dynamic_cast(m2->getAtomWithIdx(3))->Match(cl)); diff --git a/Code/JavaWrappers/Atom.i b/Code/JavaWrappers/Atom.i index 5a08cb3fe..4a45b2999 100644 --- a/Code/JavaWrappers/Atom.i +++ b/Code/JavaWrappers/Atom.i @@ -1,21 +1,21 @@ -/* +/* * $Id: Atom.i 2519 2013-05-17 03:01:18Z glandrum $ * * Copyright (c) 2010, Novartis Institutes for BioMedical Research Inc. * All rights reserved. -* +* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are -* met: +* met: * -* * Redistributions of source code must retain the above copyright +* * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided * with the distribution. -* * Neither the name of Novartis Institutes for BioMedical Research Inc. -* nor the names of its contributors may be used to endorse or promote +* * Neither the name of Novartis Institutes for BioMedical Research Inc. +* nor the names of its contributors may be used to endorse or promote * products derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS @@ -100,11 +100,11 @@ std::vector *getBonds() { std::vector *bonds = new std::vector; - const RDKit::ROMol *parent = &($self)->getOwningMol(); + RDKit::ROMol *parent = &($self)->getOwningMol(); RDKit::ROMol::OEDGE_ITER begin,end; boost::tie(begin,end) = parent->getAtomBonds(($self)); while(begin!=end){ - RDKit::Bond *tmpB = (*parent)[*begin].get(); + RDKit::Bond *tmpB = (*parent)[*begin]; bonds->push_back(tmpB); begin++; } @@ -112,4 +112,3 @@ } } - diff --git a/Code/JavaWrappers/ROMol.i b/Code/JavaWrappers/ROMol.i index 536038cd0..664c1e248 100644 --- a/Code/JavaWrappers/ROMol.i +++ b/Code/JavaWrappers/ROMol.i @@ -68,19 +68,12 @@ %template(Atom_Vect) std::vector; // These prevent duplicate definitions in Java code -%ignore RDKit::ROMol::getAtomDegree(const Atom *) const; -%ignore RDKit::ROMol::setAtomBookmark(Atom *,int); -%ignore RDKit::ROMol::clearAtomBookmark(const int, const Atom *); -%ignore RDKit::ROMol::setBondBookmark(Bond *,int); -%ignore RDKit::ROMol::clearBondBookmark(int, const Bond *); -%ignore RDKit::ROMol::replaceAtomBookmark(Atom *,int); %ignore RDKit::ROMol::hasProp(std::string const) const ; %ignore RDKit::ROMol::clearProp(std::string const) const ; %ignore RDKit::ROMol::getAtomWithIdx(unsigned int) const ; %ignore RDKit::ROMol::getBondWithIdx(unsigned int) const ; %ignore RDKit::ROMol::getBondBetweenAtoms(unsigned int,unsigned int) const ; %ignore RDKit::ROMol::getAtomNeighbors(Atom const *at) const; -%ignore RDKit::ROMol::getAtomNeighbors(ATOM_SPTR at) const; %ignore RDKit::ROMol::getAtomBonds(Atom const *at) const; %ignore RDKit::ROMol::getVertices() ; %ignore RDKit::ROMol::getVertices() const ;