From 5dbec2fe85830fec0f2907e601f65dcee359f502 Mon Sep 17 00:00:00 2001 From: kelley Date: Sun, 29 Nov 2015 17:52:27 -0500 Subject: [PATCH] Adds rdcasts where appropriate --- Code/GraphMol/AddHs.cpp | 4 ++-- Code/GraphMol/Aromaticity.cpp | 12 +++++----- Code/GraphMol/Canon.cpp | 12 +++++----- Code/GraphMol/Chirality.cpp | 4 ++-- Code/GraphMol/FindRings.cpp | 36 ++++++++++++++--------------- Code/GraphMol/Kekulize.cpp | 6 ++--- Code/GraphMol/Matrices.cpp | 12 +++++----- Code/GraphMol/MolDiscriminators.cpp | 4 ++-- Code/GraphMol/MolOps.cpp | 2 +- Code/GraphMol/MolPickler.cpp | 12 +++++----- Code/GraphMol/ROMol.cpp | 10 ++++---- Code/GraphMol/RWMol.cpp | 10 ++++---- Code/GraphMol/Resonance.cpp | 15 ++++++------ Code/GraphMol/RingInfo.cpp | 10 ++++---- Code/Query/SetQuery.h | 2 +- Code/RDGeneral/Ranking.h | 2 +- Code/RDGeneral/hanoiSort.h | 8 +++++++ 17 files changed, 85 insertions(+), 76 deletions(-) diff --git a/Code/GraphMol/AddHs.cpp b/Code/GraphMol/AddHs.cpp index dbaae4a92..984659966 100644 --- a/Code/GraphMol/AddHs.cpp +++ b/Code/GraphMol/AddHs.cpp @@ -210,7 +210,7 @@ void setHydrogenCoords(ROMol *mol, unsigned int hydIdx, unsigned int heavyIdx) { const Atom *tAtom = mol->getAtomWithIdx(*nbrIdx); int cip = 0; tAtom->getPropIfPresent(common_properties::_CIPRank, cip); - nbrs.push_back(std::make_pair(cip, *nbrIdx)); + nbrs.push_back(std::make_pair(cip, rdcast(*nbrIdx))); } ++nbrIdx; } @@ -611,7 +611,7 @@ void mergeQueryHs(RWMol &mol, bool mergeUnmappedOnly) { Atom &bgn = *mol.getAtomWithIdx(*begin); if (!mergeUnmappedOnly || !bgn.hasProp(common_properties::molAtomMapNumber)) { - atomsToRemove.push_back(*begin); + atomsToRemove.push_back(rdcast(*begin)); ++numHsToRemove; } } diff --git a/Code/GraphMol/Aromaticity.cpp b/Code/GraphMol/Aromaticity.cpp index bdcfb33e7..241f5c8fa 100644 --- a/Code/GraphMol/Aromaticity.cpp +++ b/Code/GraphMol/Aromaticity.cpp @@ -62,7 +62,7 @@ void pickFusedRings(int curr, const INT_INT_VECT_MAP &neighMap, INT_VECT &res, bool checkFused(const INT_VECT &rids, INT_INT_VECT_MAP &ringNeighs) { INT_INT_VECT_MAP_CI nci; - int nrings = ringNeighs.size(); + int nrings = rdcast(ringNeighs.size()); boost::dynamic_bitset<> done(nrings); int rid; INT_VECT fused; @@ -87,7 +87,7 @@ bool checkFused(const INT_VECT &rids, INT_INT_VECT_MAP &ringNeighs) { void makeRingNeighborMap(const VECT_INT_VECT &brings, INT_INT_VECT_MAP &neighMap, unsigned int maxSize) { - int nrings = brings.size(); + int nrings = rdcast(brings.size()); int i, j; INT_VECT ring1; for (i = 0; i < nrings; i++) { @@ -340,7 +340,7 @@ void applyHuckelToFused( INT_VECT aromRings; aromRings.resize(0); - unsigned int nrings = fused.size(); + unsigned int nrings = rdcast(fused.size()); INT_VECT curRs; INT_VECT_CI mri; curRs.push_back(fused.front()); @@ -350,7 +350,7 @@ void applyHuckelToFused( pos = -1; INT_VECT unionAtms; Union(srings, unionAtms); - unsigned int nAtms = unionAtms.size(); + unsigned int nAtms = rdcast(unionAtms.size()); std::set doneAtoms; while (1) { if (pos == -1) { @@ -414,7 +414,7 @@ void applyHuckelToFused( } } // end check huckel rule } // end while(1) - narom += aromRings.size(); + narom += rdcast(aromRings.size()); } bool isAtomCandForArom(const Atom *at, const ElectronDonorType edon) { @@ -691,7 +691,7 @@ int setAromaticity(RWMol &mol) { // huckel rule - of course paying attention to fused systems. INT_VECT doneRs; int curr = 0; - int cnrs = cRings.size(); + int cnrs = rdcast(cRings.size()); boost::dynamic_bitset<> fusDone(cnrs); INT_VECT fused; while (curr < cnrs) { diff --git a/Code/GraphMol/Canon.cpp b/Code/GraphMol/Canon.cpp index 9caa9a7ae..041df5f5b 100644 --- a/Code/GraphMol/Canon.cpp +++ b/Code/GraphMol/Canon.cpp @@ -578,7 +578,7 @@ void dfsBuildStack(ROMol &mol, int atomIdx, int inBondIdx, seenFromHere.set(atomIdx); molStack.push_back(MolStackElem(atom)); - atomOrders[atom->getIdx()] = molStack.size(); + atomOrders[atom->getIdx()] = rdcast(molStack.size()); colors[atomIdx] = GREY_NODE; INT_LIST travList; @@ -601,7 +601,7 @@ void dfsBuildStack(ROMol &mol, int atomIdx, int inBondIdx, // this is end of the ring closure // we can just pull the ring index from the bond itself: molStack.push_back(MolStackElem(bond, atomIdx)); - bondVisitOrders[bIdx] = molStack.size(); + bondVisitOrders[bIdx] = rdcast(molStack.size()); molStack.push_back(MolStackElem(ringIdx)); // don't make the ring digit immediately available again: we don't want // to have the same @@ -616,7 +616,7 @@ void dfsBuildStack(ROMol &mol, int atomIdx, int inBondIdx, throw ValueErrorException( "Too many rings open at once. SMILES cannot be generated."); } - unsigned int lowestRingIdx = cAIt - cyclesAvailable.begin(); + unsigned int lowestRingIdx = rdcast(cAIt - cyclesAvailable.begin()); cyclesAvailable[lowestRingIdx] = 0; ++lowestRingIdx; bond->setProp(common_properties::_TraversalRingClosureBond, @@ -710,16 +710,16 @@ void dfsBuildStack(ROMol &mol, int atomIdx, int inBondIdx, travList.push_back(bond->getIdx()); if (possiblesIt + 1 != possibles.end()) { // we're branching - molStack.push_back(MolStackElem("(", possiblesIt - possibles.begin())); + molStack.push_back(MolStackElem("(", rdcast(possiblesIt - possibles.begin()))); } molStack.push_back(MolStackElem(bond, atomIdx)); - bondVisitOrders[bond->getIdx()] = molStack.size(); + bondVisitOrders[bond->getIdx()] = rdcast(molStack.size()); dfsBuildStack(mol, possibleIdx, bond->getIdx(), colors, cycles, ranks, cyclesAvailable, molStack, atomOrders, bondVisitOrders, atomRingClosures, atomTraversalBondOrder, bondsInPlay, bondSymbols); if (possiblesIt + 1 != possibles.end()) { - molStack.push_back(MolStackElem(")", possiblesIt - possibles.begin())); + molStack.push_back(MolStackElem(")", rdcast(possiblesIt - possibles.begin()))); } } diff --git a/Code/GraphMol/Chirality.cpp b/Code/GraphMol/Chirality.cpp index 4d1eb1c9d..13830fc2f 100644 --- a/Code/GraphMol/Chirality.cpp +++ b/Code/GraphMol/Chirality.cpp @@ -238,7 +238,7 @@ void iterateCIPRanks(const ROMol &mol, DOUBLE_VECT &invars, UINT_VECT &ranks, cipEntries[*it].insert(cipEntries[*it].end(), localEntry.rbegin(), localEntry.rend()); if (cipEntries[*it].size() > longestEntry) { - longestEntry = cipEntries[*it].size(); + longestEntry = rdcast(cipEntries[*it].size()); } } // ---------------------------------------------------- @@ -246,7 +246,7 @@ void iterateCIPRanks(const ROMol &mol, DOUBLE_VECT &invars, UINT_VECT &ranks, // pad the entries so that we compare rounds to themselves: // for (INT_LIST_I it = allIndices.begin(); it != allIndices.end(); ++it) { - unsigned int sz = cipEntries[*it].size(); + unsigned int sz = rdcast(cipEntries[*it].size()); if (sz < longestEntry) { cipEntries[*it].insert(cipEntries[*it].end(), longestEntry - sz, -1); } diff --git a/Code/GraphMol/FindRings.cpp b/Code/GraphMol/FindRings.cpp index 74753b984..b025d1e3d 100644 --- a/Code/GraphMol/FindRings.cpp +++ b/Code/GraphMol/FindRings.cpp @@ -38,7 +38,7 @@ boost::uint32_t computeRingInvariant(INT_VECT ring, unsigned int nAtoms) { void convertToBonds(const VECT_INT_VECT &res, VECT_INT_VECT &brings, const ROMol &mol) { for (VECT_INT_VECT_CI ri = res.begin(); ri != res.end(); ++ri) { - unsigned int rsiz = ri->size(); + unsigned int rsiz = rdcast(ri->size()); INT_VECT bring(rsiz); for (unsigned int i = 0; i < (rsiz - 1); i++) { const Bond *bnd = mol.getBondBetweenAtoms((*ri)[i], (*ri)[i + 1]); @@ -171,7 +171,7 @@ void findSSSRforDupCands(const ROMol &mol, VECT_INT_VECT &res, for (VECT_INT_VECT_CI sri = srings.begin(); sri != srings.end(); ++sri) { if (sri->size() < minSiz) { - minSiz = sri->size(); + minSiz = rdcast(sri->size()); } nrings.push_back((*sri)); } @@ -261,7 +261,7 @@ void removeExtraRings(VECT_INT_VECT &res, unsigned int nexpt, j < res.size() && bitBrings[j].count() == bitBrings[i].count(); ++j) { if (!consider[j] || !availRings[j]) continue; - int overlap = (bitBrings[j] & munion).count(); + int overlap = rdcast((bitBrings[j] & munion).count()); if (overlap > bestOverlap) { bestOverlap = overlap; bestJ = j; @@ -710,18 +710,18 @@ int smallestRingsBfs(const ROMol &mol, int root, VECT_INT_VECT &rings, ring.insert(ring.end(), npath.begin(), npath.end()); #endif if (ring.size() <= curSize) { - curSize = ring.size(); + curSize = rdcast(ring.size()); rings.push_back(ring); } else { // we are done with the smallest rings - return rings.size(); + return rdcast(rings.size()); } } // end of found a ring } // end of we have seen this neighbor before } // end of nbrIdx not part of current path and not a done atom } // end of loop over neighbors of current atom } // moving to the next node - return rings.size(); // if we are here we should have found everything around + return rdcast(rings.size()); // if we are here we should have found everything around // the node } @@ -745,7 +745,7 @@ bool _atomSearchBFS(const ROMol &tMol, unsigned int startAtomIdx, while (nbrIdx != endNbrs) { if (*nbrIdx == endAtomIdx) { if (currAtomIdx != startAtomIdx) { - tv.push_back(*nbrIdx); + tv.push_back(rdcast(*nbrIdx)); // make sure the ring we just found isn't already in our set // of rings (this was an extension of sf.net issue 249) boost::uint32_t invr = @@ -763,7 +763,7 @@ bool _atomSearchBFS(const ROMol &tMol, unsigned int startAtomIdx, std::find(tv.begin(), tv.end(), *nbrIdx) == tv.end()) { //} else if(ringAtoms[*nbrIdx]){ INT_VECT nv(tv); - nv.push_back(*nbrIdx); + nv.push_back(rdcast(*nbrIdx)); bfsq.push_back(nv); } ++nbrIdx; @@ -828,7 +828,7 @@ int findSSSR(const ROMol &mol, VECT_INT_VECT &res) { // check if SSSR's are already on the molecule if (mol.getRingInfo()->isInitialized()) { res = mol.getRingInfo()->atomRings(); - return res.size(); + return rdcast(res.size()); } else { mol.getRingInfo()->initialize(); } @@ -985,8 +985,8 @@ int findSSSR(const ROMol &mol, VECT_INT_VECT &res) { std::cerr<((nbnds - curFrag.size() + 1)); + int ssiz = rdcast(fragRes.size()); // first check that we got at least the number of expected rings // std::cerr<<"EXPT: "<(fragRes.size()); if (ssiz < nexpt) { throw ValueErrorException("could not find number of expected rings."); } @@ -1058,7 +1058,7 @@ int findSSSR(const ROMol &mol, VECT_INT_VECT &res) { // update the ring memberships of atoms and bonds in the molecule: // store the SSSR rings on the the molecule as a property // we will ignore any existing SSSRs ont eh molecule - simply overwrite - return res.size(); + return rdcast(res.size()); } int symmetrizeSSSR(ROMol &mol) { @@ -1079,7 +1079,7 @@ int symmetrizeSSSR(ROMol &mol, VECT_INT_VECT &res) { nsssr = findSSSR(mol, sssrs); } else { sssrs = mol.getRingInfo()->atomRings(); - nsssr = sssrs.size(); + nsssr = rdcast(sssrs.size()); } VECT_INT_VECT_CI srci; @@ -1092,7 +1092,7 @@ int symmetrizeSSSR(ROMol &mol, VECT_INT_VECT &res) { // now check if there are any extra rings on the molecule if (!mol.hasProp(common_properties::extraRings)) { // no extra rings nothign to be done - return res.size(); + return rdcast(res.size()); } const VECT_INT_VECT &extras = mol.getProp(common_properties::extraRings); @@ -1107,7 +1107,7 @@ int symmetrizeSSSR(ROMol &mol, VECT_INT_VECT &res) { INT_VECT sr, exr; INT_VECT_CI eri; unsigned int eid, srid, ssiz; - unsigned int next = bextra.size(); + unsigned int next = rdcast(bextra.size()); // now the trick is the following // we will replace each ring of size ssiz from the SSSR with // one of the same size rings in the extras. Compute the union of of the new @@ -1124,7 +1124,7 @@ int symmetrizeSSSR(ROMol &mol, VECT_INT_VECT &res) { std::cerr<(sr.size()); INT_VECT exrid; exrid.push_back(srid); Union(bsrs, nunion, &exrid); @@ -1175,7 +1175,7 @@ int symmetrizeSSSR(ROMol &mol, VECT_INT_VECT &res) { if (mol.hasProp(common_properties::extraRings)) { mol.clearProp(common_properties::extraRings); } - return res.size(); + return rdcast(res.size()); } namespace { diff --git a/Code/GraphMol/Kekulize.cpp b/Code/GraphMol/Kekulize.cpp index 8cbe8982e..4323d9af0 100644 --- a/Code/GraphMol/Kekulize.cpp +++ b/Code/GraphMol/Kekulize.cpp @@ -271,7 +271,7 @@ bool kekulizeWorker(RWMol &mol, const INT_VECT &allAtms, // if the neighbor is not on the stack add it if (std::find(astack.begin(), astack.end(), static_cast(*nbrIdx)) == astack.end()) { - astack.push_back(*nbrIdx); + astack.push_back(rdcast(*nbrIdx)); } // check if the neighbor is also a candidate for a double bond @@ -287,7 +287,7 @@ bool kekulizeWorker(RWMol &mol, const INT_VECT &allAtms, (mol.getBondBetweenAtoms(curr, *nbrIdx)->getIsAromatic() || mol.getAtomWithIdx(curr)->getAtomicNum() == 0 || mol.getAtomWithIdx(*nbrIdx)->getAtomicNum() == 0)) { - opts.push_back(*nbrIdx); + opts.push_back(rdcast(*nbrIdx)); } // end of curr atoms can have a double bond ++nbrIdx; } // end of looping over neighbors @@ -519,7 +519,7 @@ void Kekulize(RWMol &mol, bool markAtomsBonds, unsigned int maxBackTracks) { RingUtils::makeRingNeighborMap(brings, neighMap); int curr = 0; - int cnrs = arings.size(); + int cnrs = rdcast(arings.size()); boost::dynamic_bitset<> fusDone(cnrs); while (curr < cnrs) { INT_VECT fused; diff --git a/Code/GraphMol/Matrices.cpp b/Code/GraphMol/Matrices.cpp index 3545ba326..64f21448d 100644 --- a/Code/GraphMol/Matrices.cpp +++ b/Code/GraphMol/Matrices.cpp @@ -234,7 +234,7 @@ double *getDistanceMat(const ROMol &mol, bool useBO, bool useAtomWts, double *getDistanceMat(const ROMol &mol, const std::vector &activeAtoms, const std::vector &bonds, bool useBO, bool useAtomWts) { - const int nAts = activeAtoms.size(); + const int nAts = rdcast(activeAtoms.size()); double *dMat = new double[nAts * nAts]; int i, j; @@ -245,12 +245,12 @@ double *getDistanceMat(const ROMol &mol, const std::vector &activeAtoms, for (std::vector::const_iterator bi = bonds.begin(); bi != bonds.end(); bi++) { const Bond *bond = *bi; - i = std::find(activeAtoms.begin(), activeAtoms.end(), + i = rdcast(std::find(activeAtoms.begin(), activeAtoms.end(), static_cast(bond->getBeginAtomIdx())) - - activeAtoms.begin(); - j = std::find(activeAtoms.begin(), activeAtoms.end(), + activeAtoms.begin()); + j = rdcast(std::find(activeAtoms.begin(), activeAtoms.end(), static_cast(bond->getEndAtomIdx())) - - activeAtoms.begin(); + activeAtoms.begin()); double contrib; if (useBO) { if (!bond->getIsAromatic()) { @@ -358,7 +358,7 @@ INT_LIST getShortestPath(const ROMol &mol, int aid1, int aid2) { done = true; break; } - bfsQ.push_back(*nbrIdx); + bfsQ.push_back(rdcast(*nbrIdx)); } nbrIdx++; } diff --git a/Code/GraphMol/MolDiscriminators.cpp b/Code/GraphMol/MolDiscriminators.cpp index 344b45abb..bec1e1025 100644 --- a/Code/GraphMol/MolDiscriminators.cpp +++ b/Code/GraphMol/MolDiscriminators.cpp @@ -93,8 +93,8 @@ double computeBalabanJ(const ROMol &mol, bool useBO, bool force, } beg++; } - nb = bondPath->size(); - nAts = atomsInPath.size(); + nb = rdcast(bondPath->size()); + nAts = rdcast(atomsInPath.size()); dMat = MolOps::getDistanceMat(mol, atomsInPath, bonds, true, true); res = computeBalabanJ(dMat, nb, nAts); delete[] dMat; diff --git a/Code/GraphMol/MolOps.cpp b/Code/GraphMol/MolOps.cpp index c5b5f39ac..4eecdcbf1 100644 --- a/Code/GraphMol/MolOps.cpp +++ b/Code/GraphMol/MolOps.cpp @@ -524,7 +524,7 @@ unsigned int getMolFrags(const ROMol &mol, VECT_INT_VECT &frags) { for (INT_INT_VECT_MAP_CI mci = comMap.begin(); mci != comMap.end(); mci++) { frags.push_back((*mci).second); } - return frags.size(); + return rdcast(frags.size()); } template diff --git a/Code/GraphMol/MolPickler.cpp b/Code/GraphMol/MolPickler.cpp index f6309dc9a..4be9c3f7b 100644 --- a/Code/GraphMol/MolPickler.cpp +++ b/Code/GraphMol/MolPickler.cpp @@ -29,7 +29,7 @@ const int32_t MolPickler::versionPatch = 0; const int32_t MolPickler::endianId = 0xDEADBEEF; void streamWrite(std::ostream &ss, const std::string &what) { - unsigned int l = what.length(); + unsigned int l = rdcast(what.length()); ss.write((const char *)&l, sizeof(l)); ss.write(what.c_str(), sizeof(char) * l); }; @@ -145,7 +145,7 @@ void pickleQuery(std::ostream &ss, const Query *query) { boost::tie(lowerOpen, upperOpen) = static_cast *>(query) ->getEndsOpen(); - ends = 0 | (lowerOpen << 1) | upperOpen; + ends = 0 | (rdcast(lowerOpen) << 1) | rdcast(upperOpen); streamWrite(ss, ends); } else if (typeid(*query) == typeid(SetQuery)) { streamWrite(ss, MolPickler::QUERY_SET); @@ -934,12 +934,12 @@ bool getAtomMapNumber(const Atom *atom, int &mapNum) { int tmpInt; try { atom->getProp(common_properties::molAtomMapNumber, tmpInt); - } catch (boost::bad_any_cast &exc) { + } catch (boost::bad_any_cast &) { const std::string &tmpSVal = atom->getProp(common_properties::molAtomMapNumber); try { tmpInt = boost::lexical_cast(tmpSVal); - } catch (boost::bad_lexical_cast &lexc) { + } catch (boost::bad_lexical_cast &) { res = false; } } @@ -1264,7 +1264,7 @@ Atom *MolPickler::_addAtomFromPickle(std::istream &ss, ROMol *mol, if (version > 5000) { if (version < 6020) { - unsigned int sPos = ss.tellg(); + unsigned int sPos = rdcast(ss.tellg()); Tags tag; streamRead(ss, tag, version); if (tag == ATOM_MAPNUMBER) { @@ -1356,7 +1356,7 @@ void MolPickler::_pickleBond(std::ostream &ss, const Bond *bond, tmpChar = static_cast(bond->getStereo()); streamWrite(ss, tmpChar); const INT_VECT &stereoAts = bond->getStereoAtoms(); - tmpChar = stereoAts.size(); + tmpChar = rdcast(stereoAts.size()); streamWrite(ss, tmpChar); for (INT_VECT_CI idxIt = stereoAts.begin(); idxIt != stereoAts.end(); ++idxIt) { diff --git a/Code/GraphMol/ROMol.cpp b/Code/GraphMol/ROMol.cpp index 172493afc..3fee9cc99 100644 --- a/Code/GraphMol/ROMol.cpp +++ b/Code/GraphMol/ROMol.cpp @@ -126,13 +126,13 @@ void ROMol::initMol() { } unsigned int ROMol::getAtomDegree(const Atom *at) const { - return (boost::out_degree(at->getIdx(), d_graph)); + 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 = boost::num_vertices(d_graph); + int res = rdcast(boost::num_vertices(d_graph)); if (!onlyExplicit) { // if we are interested in hydrogens as well add them up from // each @@ -238,7 +238,7 @@ void ROMol::clearBondBookmark(const int mark, const Bond *bond) { unsigned int ROMol::getNumBonds(bool onlyHeavy) const { // By default resturn the bonds that connect only the heavy atoms // hydrogen connecting bonds are ignores - int res = boost::num_edges(d_graph); + int res = rdcast(boost::num_edges(d_graph)); if (!onlyHeavy) { // If we need hydrogen connecting bonds add them up for (ConstAtomIterator ai = beginAtoms(); ai != endAtoms(); ++ai) { @@ -340,7 +340,7 @@ unsigned int ROMol::addAtom(Atom *atom_pin, bool updateLabel, cfi != this->endConformers(); ++cfi) { (*cfi)->setAtomPos(which, RDGeom::Point3D(0.0, 0.0, 0.0)); } - return which; + return rdcast(which); }; unsigned int ROMol::addAtom(Atom::ATOM_SPTR atom_sp, bool updateLabel) { return addAtom(atom_sp.get(), updateLabel, false); @@ -368,7 +368,7 @@ unsigned int ROMol::addBond(Bond *bond_pin, bool takeOwnership) { bond_p->getEndAtomIdx(), d_graph); CHECK_INVARIANT(ok, "bond could not be added"); d_graph[which].reset(bond_p); - int res = boost::num_edges(d_graph); + int res = rdcast(boost::num_edges(d_graph)); bond_p->setIdx(res - 1); return res; } diff --git a/Code/GraphMol/RWMol.cpp b/Code/GraphMol/RWMol.cpp index 17cf554dc..b640eb443 100644 --- a/Code/GraphMol/RWMol.cpp +++ b/Code/GraphMol/RWMol.cpp @@ -124,7 +124,7 @@ unsigned int RWMol::addAtom(bool updateLabel) { cfi != this->endConformers(); ++cfi) { (*cfi)->setAtomPos(which, RDGeom::Point3D(0.0, 0.0, 0.0)); } - return which; + return rdcast(which); } void RWMol::replaceAtom(unsigned int idx, Atom *atom_pin, bool updateLabel) { @@ -182,7 +182,7 @@ void RWMol::removeAtom(Atom *atom) { ADJ_ITER b1, b2; boost::tie(b1, b2) = getAtomNeighbors(atom); while (b1 != b2) { - nbrs.push_back(std::make_pair(atom->getIdx(), *b1)); + nbrs.push_back(std::make_pair(atom->getIdx(), rdcast(*b1))); ++b1; } for (unsigned int i = 0; i < nbrs.size(); ++i) { @@ -269,7 +269,7 @@ unsigned int RWMol::addBond(unsigned int atomIdx1, unsigned int atomIdx2, MolGraph::edge_descriptor which; boost::tie(which, ok) = boost::add_edge(atomIdx1, atomIdx2, d_graph); d_graph[which].reset(b); - unsigned int res = boost::num_edges(d_graph); + unsigned int res = rdcast(boost::num_edges(d_graph)); b->setIdx(res - 1); b->setBeginAtomIdx(atomIdx1); b->setEndAtomIdx(atomIdx2); @@ -322,7 +322,7 @@ void RWMol::removeBond(unsigned int aid1, unsigned int aid2) { ADJ_ITER a1, a2; boost::tie(a1, a2) = boost::adjacent_vertices(aid1, d_graph); while (a1 != a2) { - unsigned int oIdx = *a1; + unsigned int oIdx = rdcast(*a1); ++a1; if (oIdx == aid2) continue; Bond *obnd = getBondBetweenAtoms(aid1, oIdx); @@ -331,7 +331,7 @@ void RWMol::removeBond(unsigned int aid1, unsigned int aid2) { } boost::tie(a1, a2) = boost::adjacent_vertices(aid1, d_graph); while (a1 != a2) { - unsigned int oIdx = *a1; + unsigned int oIdx = rdcast(*a1); ++a1; if (oIdx == aid1) continue; Bond *obnd = getBondBetweenAtoms(aid2, oIdx); diff --git a/Code/GraphMol/Resonance.cpp b/Code/GraphMol/Resonance.cpp index 02e835d89..c69d2ae8f 100644 --- a/Code/GraphMol/Resonance.cpp +++ b/Code/GraphMol/Resonance.cpp @@ -19,8 +19,8 @@ class CEVect2 { public: CEVect2(CEMap &ceMap); ConjElectrons *getCE(unsigned int depth, unsigned int width); - unsigned int ceCount() { return d_ceVect.size(); } - unsigned int depth() { return d_degVect.size(); } + unsigned int ceCount() { return rdcast(d_ceVect.size()); } + unsigned int depth() { return rdcast(d_degVect.size()); } void resize(unsigned int size); void idxToDepthWidth(unsigned int idx, unsigned int &d, unsigned int &w); unsigned int ceCountAtDepth(unsigned int depth); @@ -527,8 +527,8 @@ bool ConjElectrons::storeFP(CEMap &ceMap, unsigned int flags) { boost::uint8_t byte; ConjFP fp; unsigned int fpSize = 0; - if (flags & FP_ATOMS) fpSize += d_conjAtomMap.size(); - if (flags & FP_BONDS) fpSize += ((d_conjBondMap.size() - 1) / 4 + 1); + if (flags & FP_ATOMS) fpSize += rdcast(d_conjAtomMap.size()); + if (flags & FP_BONDS) fpSize += rdcast((d_conjBondMap.size() - 1) / 4 + 1); fp.reserve(fpSize); if (flags & FP_ATOMS) { // for each atom, we push a byte to the FP vector whose @@ -737,7 +737,7 @@ void ConjElectrons::enumerateNonBonded(CEMap &ceMap) { // we compute the number of permutations (numComb) and a // binary code (v) which indicates which of the atom indices in // aiVec will be octet-unsatisfied for each permutation - ResonanceUtils::getNumCombStartV(numCand, aiVec.size(), numComb, v); + ResonanceUtils::getNumCombStartV(numCand, rdcast(aiVec.size()), numComb, v); // if there are multiple permutations, make a copy of the original // ConjElectrons object, since the latter will be modified ConjElectrons *ceCopy = ((numComb > 1) ? new ConjElectrons(*ce) : NULL); @@ -809,8 +809,9 @@ void ConjElectrons::computeDistFormalCharges() { for (ConjAtomMap::const_iterator it2 = it1; it2 != d_conjAtomMap.end(); ++it2) { if ((it1 == it2) || !it2->second->fc()) continue; - unsigned int dist = MolOps::getShortestPath(d_parent->mol(), it1->first, - it2->first).size(); + unsigned int dist = rdcast( + MolOps::getShortestPath(d_parent->mol(), it1->first, + it2->first).size()); if ((it1->second->fc() * it2->second->fc()) > 0) d_ceMetrics.d_fcSameSignDist += dist; else diff --git a/Code/GraphMol/RingInfo.cpp b/Code/GraphMol/RingInfo.cpp index 90897fcd3..6cfea5fe5 100644 --- a/Code/GraphMol/RingInfo.cpp +++ b/Code/GraphMol/RingInfo.cpp @@ -37,7 +37,7 @@ unsigned int RingInfo::numAtomRings(unsigned int idx) const { PRECONDITION(df_init, "RingInfo not initialized"); if (idx < d_atomMembers.size()) { - return d_atomMembers[idx].size(); + return rdcast(d_atomMembers[idx].size()); } else { return 0; } @@ -66,7 +66,7 @@ unsigned int RingInfo::numBondRings(unsigned int idx) const { PRECONDITION(df_init, "RingInfo not initialized"); if (idx < d_bondMembers.size()) { - return d_bondMembers[idx].size(); + return rdcast(d_bondMembers[idx].size()); } else { return 0; } @@ -75,14 +75,14 @@ unsigned int RingInfo::numBondRings(unsigned int idx) const { unsigned int RingInfo::numRings() const { PRECONDITION(df_init, "RingInfo not initialized"); PRECONDITION(d_atomRings.size() == d_bondRings.size(), "length mismatch"); - return d_atomRings.size(); + return rdcast(d_atomRings.size()); } unsigned int RingInfo::addRing(const INT_VECT &atomIndices, const INT_VECT &bondIndices) { PRECONDITION(df_init, "RingInfo not initialized"); PRECONDITION(atomIndices.size() == bondIndices.size(), "length mismatch"); - int sz = atomIndices.size(); + int sz = rdcast(atomIndices.size()); for (INT_VECT::const_iterator i = atomIndices.begin(); i < atomIndices.end(); i++) { if (*i >= static_cast(d_atomMembers.size())) @@ -98,7 +98,7 @@ unsigned int RingInfo::addRing(const INT_VECT &atomIndices, d_atomRings.push_back(atomIndices); d_bondRings.push_back(bondIndices); POSTCONDITION(d_atomRings.size() == d_bondRings.size(), "length mismatch"); - return d_atomRings.size(); + return rdcast(d_atomRings.size()); } void RingInfo::initialize() { diff --git a/Code/Query/SetQuery.h b/Code/Query/SetQuery.h index 0adef8f8f..98e741de8 100644 --- a/Code/Query/SetQuery.h +++ b/Code/Query/SetQuery.h @@ -61,7 +61,7 @@ class SetQuery typename CONTAINER_TYPE::const_iterator endSet() const { return d_set.end(); }; - unsigned int size() const { return d_set.size(); }; + unsigned int size() const { return rdcast(d_set.size()); }; std::string getFullDescription() const { std::ostringstream res; diff --git a/Code/RDGeneral/Ranking.h b/Code/RDGeneral/Ranking.h index dcff3d4cf..b338adc51 100644 --- a/Code/RDGeneral/Ranking.h +++ b/Code/RDGeneral/Ranking.h @@ -63,7 +63,7 @@ class argless : public std::binary_function { template void rankVect(const std::vector &vect, T2 &res) { PRECONDITION(res.size() >= vect.size(), "vector size mismatch"); - unsigned int nEntries = vect.size(); + unsigned int nEntries = rdcast(vect.size()); std::vector indices(nEntries); for (unsigned int i = 0; i < nEntries; ++i) indices[i] = i; diff --git a/Code/RDGeneral/hanoiSort.h b/Code/RDGeneral/hanoiSort.h index 930da0759..65c201314 100644 --- a/Code/RDGeneral/hanoiSort.h +++ b/Code/RDGeneral/hanoiSort.h @@ -17,6 +17,10 @@ #include #include +#if defined(_MSC_VER) +#pragma warning(push, 1) +#pragma warning(disable: 4800) +#endif namespace RDKit { template bool hanoi(int *base, int nel, int *temp, int *count, int *changed, @@ -144,4 +148,8 @@ void hanoisort(int *base, int nel, int *count, int *changed, } } +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + #endif /* HANOISORT_H_ */