mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
Run clang-tidy (readability-braces-around-statements) (#4977)
https://github.com/rdkit/rdkit/pull/3024#discussion_r526549843
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---
|
||||
Checks: '-*,boost-use-to-string,modernize-use-auto,modernize-use-nullptr,modernize-loop-convert,modernize-use-override,modernize-pass-by-value,modernize-shrink-to-fit'
|
||||
Checks: '-*,boost-use-to-string,modernize-use-auto,modernize-use-nullptr,modernize-loop-convert,modernize-use-override,modernize-pass-by-value,modernize-shrink-to-fit,readability-braces-around-statements'
|
||||
HeaderFilterRegex: 'Code/'
|
||||
AnalyzeTemporaryDtors: false
|
||||
User: glandrum
|
||||
|
||||
@@ -43,7 +43,9 @@ double SimilarityWrapper(const T& bv1, const T& bv2,
|
||||
} else {
|
||||
res = metric(bv1, bv2);
|
||||
}
|
||||
if (returnDistance) res = 1.0 - res;
|
||||
if (returnDistance) {
|
||||
res = 1.0 - res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
//! \overload
|
||||
@@ -63,7 +65,9 @@ double SimilarityWrapper(const T& bv1, const T& bv2, double a, double b,
|
||||
} else {
|
||||
res = metric(bv1, bv2, a, b);
|
||||
}
|
||||
if (returnDistance) res = 1.0 - res;
|
||||
if (returnDistance) {
|
||||
res = 1.0 - res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,9 @@ class RDKIT_DATASTRUCTS_EXPORT FPBReader {
|
||||
df_lazyRead(lazyRead) {}
|
||||
~FPBReader() {
|
||||
destroy();
|
||||
if (df_owner) delete dp_istrm;
|
||||
if (df_owner) {
|
||||
delete dp_istrm;
|
||||
}
|
||||
dp_istrm = nullptr;
|
||||
df_init = false;
|
||||
}
|
||||
@@ -115,7 +117,9 @@ class RDKIT_DATASTRUCTS_EXPORT FPBReader {
|
||||
Cleans up whatever memory was allocated during init()
|
||||
*/
|
||||
void cleanup() {
|
||||
if (!df_init) return;
|
||||
if (!df_init) {
|
||||
return;
|
||||
}
|
||||
destroy();
|
||||
df_init = false;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,9 @@ class RDKIT_DATASTRUCTS_EXPORT MultiFPBReader {
|
||||
unsigned int addReader(FPBReader *rdr) {
|
||||
PRECONDITION(rdr, "no reader provided");
|
||||
d_readers.push_back(rdr);
|
||||
if (df_init) rdr->init();
|
||||
if (df_init) {
|
||||
rdr->init();
|
||||
}
|
||||
return d_readers.size();
|
||||
}
|
||||
|
||||
|
||||
@@ -115,10 +115,11 @@ class SparseIntVect {
|
||||
int res = 0;
|
||||
typename StorageType::const_iterator iter;
|
||||
for (iter = d_data.begin(); iter != d_data.end(); ++iter) {
|
||||
if (!doAbs)
|
||||
if (!doAbs) {
|
||||
res += iter->second;
|
||||
else
|
||||
} else {
|
||||
res += abs(iter->second);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -523,7 +524,9 @@ double DiceSimilarity(const SparseIntVect<IndexType> &v1,
|
||||
} else {
|
||||
sim = 2. * numer / denom;
|
||||
}
|
||||
if (returnDistance) sim = 1. - sim;
|
||||
if (returnDistance) {
|
||||
sim = 1. - sim;
|
||||
}
|
||||
// std::cerr<<" "<<v1Sum<<" "<<v2Sum<<" " << numer << " " << sim <<std::endl;
|
||||
return sim;
|
||||
}
|
||||
@@ -550,7 +553,9 @@ double TverskySimilarity(const SparseIntVect<IndexType> &v1,
|
||||
} else {
|
||||
sim = andSum / denom;
|
||||
}
|
||||
if (returnDistance) sim = 1. - sim;
|
||||
if (returnDistance) {
|
||||
sim = 1. - sim;
|
||||
}
|
||||
// std::cerr<<" "<<v1Sum<<" "<<v2Sum<<" " << numer << " " << sim <<std::endl;
|
||||
return sim;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,9 @@ class RDKIT_RDGEOMETRYLIB_EXPORT Point3D : public Point {
|
||||
double signedAngleTo(const Point3D &other) const {
|
||||
double res = this->angleTo(other);
|
||||
// check the sign of the z component of the cross product:
|
||||
if ((this->x * other.y - this->y * other.x) < -1e-6) res = 2.0 * M_PI - res;
|
||||
if ((this->x * other.y - this->y * other.x) < -1e-6) {
|
||||
res = 2.0 * M_PI - res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -377,16 +379,19 @@ class RDKIT_RDGEOMETRYLIB_EXPORT Point2D : public Point {
|
||||
t2.normalize();
|
||||
double dotProd = t1.dotProduct(t2);
|
||||
// watch for roundoff error:
|
||||
if (dotProd < -1.0)
|
||||
if (dotProd < -1.0) {
|
||||
dotProd = -1.0;
|
||||
else if (dotProd > 1.0)
|
||||
} else if (dotProd > 1.0) {
|
||||
dotProd = 1.0;
|
||||
}
|
||||
return acos(dotProd);
|
||||
}
|
||||
|
||||
double signedAngleTo(const Point2D &other) const {
|
||||
double res = this->angleTo(other);
|
||||
if ((this->x * other.y - this->y * other.x) < -1e-6) res = 2.0 * M_PI - res;
|
||||
if ((this->x * other.y - this->y * other.x) < -1e-6) {
|
||||
res = 2.0 * M_PI - res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -453,7 +458,9 @@ class RDKIT_RDGEOMETRYLIB_EXPORT PointND : public Point {
|
||||
unsigned int dimension() const override { return dp_storage.get()->size(); }
|
||||
|
||||
PointND &operator=(const PointND &other) {
|
||||
if (this == &other) return *this;
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
RDNumeric::Vector<double> *nvec =
|
||||
new RDNumeric::Vector<double>(*other.getStorage());
|
||||
@@ -501,10 +508,11 @@ class RDKIT_RDGEOMETRYLIB_EXPORT PointND : public Point {
|
||||
if ((n1 > 1.e-8) && (n2 > 1.e-8)) {
|
||||
dp /= (n1 * n2);
|
||||
}
|
||||
if (dp < -1.0)
|
||||
if (dp < -1.0) {
|
||||
dp = -1.0;
|
||||
else if (dp > 1.0)
|
||||
} else if (dp > 1.0) {
|
||||
dp = 1.0;
|
||||
}
|
||||
return acos(dp);
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,9 @@ class RDKIT_GRAPHMOL_EXPORT Bond : public RDProps {
|
||||
dp_stereoAtoms = std::exchange(o.dp_stereoAtoms, nullptr);
|
||||
}
|
||||
Bond &operator=(Bond &&o) noexcept {
|
||||
if (this == &o) return *this;
|
||||
if (this == &o) {
|
||||
return *this;
|
||||
}
|
||||
RDProps::operator=(std::move(o));
|
||||
df_isAromatic = o.df_isAromatic;
|
||||
df_isConjugated = o.df_isConjugated;
|
||||
@@ -346,7 +348,9 @@ class RDKIT_GRAPHMOL_EXPORT Bond : public RDProps {
|
||||
}
|
||||
//! \overload
|
||||
INT_VECT &getStereoAtoms() {
|
||||
if (!dp_stereoAtoms) dp_stereoAtoms = new INT_VECT();
|
||||
if (!dp_stereoAtoms) {
|
||||
dp_stereoAtoms = new INT_VECT();
|
||||
}
|
||||
return *dp_stereoAtoms;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,9 @@ CIPMol::CIPMol(ROMol &mol) : d_mol{mol} {}
|
||||
|
||||
boost::rational<int> CIPMol::getFractionalAtomicNum(Atom *atom) const {
|
||||
PRECONDITION(atom, "bad atom")
|
||||
if (d_atomnums.empty())
|
||||
if (d_atomnums.empty()) {
|
||||
const_cast<CIPMol *>(this)->d_atomnums = calcFracAtomNums(*this);
|
||||
}
|
||||
return d_atomnums[atom->getIdx()];
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ Priority Sort::prioritize(const Node *node, std::vector<Edge *> &edges,
|
||||
bool unique = true;
|
||||
int numPseudoAsym = 0;
|
||||
|
||||
for (auto i = 0u; i < edges.size(); ++i)
|
||||
for (auto i = 0u; i < edges.size(); ++i) {
|
||||
for (auto j = i; j > 0; --j) {
|
||||
int cmp = compareSubstituents(node, edges[j - 1], edges[j], deep);
|
||||
|
||||
@@ -46,6 +46,7 @@ Priority Sort::prioritize(const Node *node, std::vector<Edge *> &edges,
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {unique, numPseudoAsym == 1};
|
||||
}
|
||||
|
||||
@@ -87,8 +87,9 @@ class RDKIT_CHEMREACTIONS_EXPORT CartesianProductStrategy
|
||||
const EnumerationTypes::RGROUPS &next() override {
|
||||
if (m_numPermutationsProcessed) {
|
||||
increment();
|
||||
} else
|
||||
} else {
|
||||
++m_numPermutationsProcessed;
|
||||
}
|
||||
|
||||
return m_permutation;
|
||||
}
|
||||
@@ -120,7 +121,9 @@ class RDKIT_CHEMREACTIONS_EXPORT CartesianProductStrategy
|
||||
}
|
||||
|
||||
void next(size_t rowToIncrement) {
|
||||
if (!hasNext()) return;
|
||||
if (!hasNext()) {
|
||||
return;
|
||||
}
|
||||
m_permutation[rowToIncrement] += 1;
|
||||
size_t max_index_of_row = m_permutationSizes[rowToIncrement] - 1;
|
||||
if (m_permutation[rowToIncrement] > max_index_of_row) {
|
||||
|
||||
@@ -75,7 +75,9 @@ template <class T>
|
||||
EnumerationTypes::RGROUPS getSizesFromBBs(
|
||||
const std::vector<std::vector<T>> &bbs) {
|
||||
EnumerationTypes::RGROUPS sizes;
|
||||
for (size_t i = 0; i < bbs.size(); ++i) sizes.push_back(bbs[i].size());
|
||||
for (size_t i = 0; i < bbs.size(); ++i) {
|
||||
sizes.push_back(bbs[i].size());
|
||||
}
|
||||
return sizes;
|
||||
}
|
||||
|
||||
@@ -188,7 +190,9 @@ class RDKIT_CHEMREACTIONS_EXPORT EnumerationStrategyBase {
|
||||
//! Skip the specified number of permutations (useful for
|
||||
//! resetting state to a known position)
|
||||
bool skip(boost::uint64_t skipCount) {
|
||||
for (boost::uint64_t i = 0; i < skipCount; ++i) next();
|
||||
for (boost::uint64_t i = 0; i < skipCount; ++i) {
|
||||
next();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -322,8 +322,9 @@ TEST_CASE("molzip", "[]") {
|
||||
RDKit::MolFragmenter::fragmentOnBonds(*m, bonds)};
|
||||
auto smiles = MolToSmiles(*resa);
|
||||
|
||||
if (std::count(smiles.begin(), smiles.end(), '/') != 2)
|
||||
if (std::count(smiles.begin(), smiles.end(), '/') != 2) {
|
||||
continue; // we removed bond stereo in fragment to bonds!
|
||||
}
|
||||
MolzipParams p;
|
||||
p.label = MolzipLabel::FragmentOnBonds;
|
||||
CHECK(MolToSmiles(*molzip(*resa, p)) == MolToSmiles(*m));
|
||||
@@ -334,8 +335,9 @@ TEST_CASE("molzip", "[]") {
|
||||
*m, bonds, true, &dummyLabels)};
|
||||
auto smiles = MolToSmiles(*res);
|
||||
|
||||
if (std::count(smiles.begin(), smiles.end(), '/') != 2)
|
||||
if (std::count(smiles.begin(), smiles.end(), '/') != 2) {
|
||||
continue; // we removed bond stereo in fragment to bonds!
|
||||
}
|
||||
for (auto *atom : res->atoms()) {
|
||||
if (atom->getIsotope()) {
|
||||
atom->setAtomMapNum(atom->getIsotope());
|
||||
|
||||
@@ -408,7 +408,9 @@ bool isLinearArrangement(const RDGeom::Point3D &v1, const RDGeom::Point3D &v2) {
|
||||
double lsq = v1.lengthSq() * v2.lengthSq();
|
||||
|
||||
// treat zero length vectors as linear
|
||||
if (lsq < 1.0e-6) return true;
|
||||
if (lsq < 1.0e-6) {
|
||||
return true;
|
||||
}
|
||||
|
||||
double dotProd = v1.dotProduct(v2);
|
||||
|
||||
|
||||
@@ -171,7 +171,9 @@ typedef boost::shared_ptr<Conformer> CONFORMER_SPTR;
|
||||
*/
|
||||
inline bool hasNonZeroZCoords(const Conformer &conf) {
|
||||
for (auto p : conf.getPositions()) {
|
||||
if (p.z != 0.0) return true;
|
||||
if (p.z != 0.0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -135,8 +135,9 @@ std::unique_ptr<ROMol> deprotect(
|
||||
if (deprotections_used.size() >= MAX_DEPROTECTIONS) {
|
||||
BOOST_LOG(rdErrorLog)
|
||||
<< "Too many deprotections, halting..." << std::endl;
|
||||
} else
|
||||
} else {
|
||||
something_happened = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -866,7 +866,9 @@ bool _checkMacrocycleAllInSameRingAmideEster14(const ROMol &mol, const Bond *,
|
||||
unsigned int a2Num = atm2->getAtomicNum();
|
||||
unsigned int a3Num = atm3->getAtomicNum();
|
||||
|
||||
if (a3Num != 6) return false;
|
||||
if (a3Num != 6) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a2Num == 7 || a2Num == 8) {
|
||||
if (mol.getAtomDegree(atm2) == 3 && mol.getAtomDegree(atm3) == 3) {
|
||||
|
||||
@@ -32,16 +32,20 @@ class Composition2N { // generator of 2^N-1 possible bit combinations
|
||||
if ((++Bits) <= MaxValue) {
|
||||
InverseBits = (~Bits + 1) & ValueMask;
|
||||
return true;
|
||||
} else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool is2Power() const { // one bit is set only
|
||||
BitSet bits = getBitSet();
|
||||
unsigned n = 0;
|
||||
while (0 == (bits & 1uLL) &&
|
||||
++n < sizeof(bits) * 8) // find lowest bitwise 1
|
||||
++n < sizeof(bits) * 8) { // find lowest bitwise 1
|
||||
bits >>= 1u; // shift all zero lower bits
|
||||
if (0 != (bits & 1uLL)) bits >>= 1u; // shift first set bit too
|
||||
}
|
||||
if (0 != (bits & 1uLL)) {
|
||||
bits >>= 1u; // shift first set bit too
|
||||
}
|
||||
return 0 == bits; // remained bits except lowest 1
|
||||
}
|
||||
// unused: bool nonZero() {return 0!=getBitSet();}
|
||||
|
||||
@@ -47,18 +47,30 @@ class DuplicatedSeedCache {
|
||||
}
|
||||
|
||||
bool operator<(const TKey& right) const {
|
||||
if (AtomIdx.size() < right.AtomIdx.size()) return true;
|
||||
if (AtomIdx.size() > right.AtomIdx.size()) return false;
|
||||
if (AtomIdx.size() < right.AtomIdx.size()) {
|
||||
return true;
|
||||
}
|
||||
if (AtomIdx.size() > right.AtomIdx.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (BondIdx.size() < right.BondIdx.size()) return true;
|
||||
if (BondIdx.size() > right.BondIdx.size()) return false;
|
||||
if (BondIdx.size() < right.BondIdx.size()) {
|
||||
return true;
|
||||
}
|
||||
if (BondIdx.size() > right.BondIdx.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// everything is equal -> perform straight comparison
|
||||
int diff;
|
||||
diff = memcmp(&AtomIdx[0], &right.AtomIdx[0],
|
||||
AtomIdx.size() * sizeof(unsigned));
|
||||
if (diff < 0) return true;
|
||||
if (diff > 0) return false;
|
||||
if (diff < 0) {
|
||||
return true;
|
||||
}
|
||||
if (diff > 0) {
|
||||
return false;
|
||||
}
|
||||
return memcmp(&BondIdx[0], &right.BondIdx[0],
|
||||
BondIdx.size() * sizeof(unsigned)) < 0;
|
||||
}
|
||||
@@ -76,16 +88,21 @@ class DuplicatedSeedCache {
|
||||
|
||||
bool find(const TKey& key, TValue& value) const {
|
||||
value = false;
|
||||
if (key.getNumAtoms() > MaxAtoms)
|
||||
if (key.getNumAtoms() > MaxAtoms) {
|
||||
return false; // fast check if key greater then max key in the cache
|
||||
}
|
||||
|
||||
std::map<TKey, TValue>::const_iterator entryit = Index.find(key);
|
||||
if (Index.end() != entryit) value = entryit->second;
|
||||
if (Index.end() != entryit) {
|
||||
value = entryit->second;
|
||||
}
|
||||
return Index.end() != entryit;
|
||||
}
|
||||
|
||||
void add(const TKey& key, TValue found = true) {
|
||||
if (key.getNumAtoms() > MaxAtoms) MaxAtoms = key.getNumAtoms();
|
||||
if (key.getNumAtoms() > MaxAtoms) {
|
||||
MaxAtoms = key.getNumAtoms();
|
||||
}
|
||||
|
||||
Index.insert(std::pair<TKey, bool>(key, found));
|
||||
}
|
||||
|
||||
@@ -27,16 +27,20 @@ class RDKIT_FMCS_EXPORT RingMatchTableSet {
|
||||
}
|
||||
inline void resize(unsigned s1, unsigned s2) {
|
||||
MatchMatrix.resize(s1, s2);
|
||||
for (size_t i = 0; i < s1; i++)
|
||||
for (size_t j = 0; j < s2; j++) MatchMatrix.set(i, j, false);
|
||||
for (size_t i = 0; i < s1; i++) {
|
||||
for (size_t j = 0; j < s2; j++) {
|
||||
MatchMatrix.set(i, j, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
inline void makeRingIndex(const ROMol* mol2) {
|
||||
unsigned i = 0;
|
||||
// for each TARGET ring
|
||||
const RingInfo::VECT_INT_VECT& rings2 = mol2->getRingInfo()->bondRings();
|
||||
for (RingInfo::VECT_INT_VECT::const_iterator r2 = rings2.begin();
|
||||
r2 != rings2.end(); r2++)
|
||||
r2 != rings2.end(); r2++) {
|
||||
RingIndex[&*r2] = i++;
|
||||
}
|
||||
}
|
||||
inline bool isEqual(unsigned i, const INT_VECT* r2) const {
|
||||
return MatchMatrix.at(i, getRingIndex(r2));
|
||||
@@ -49,7 +53,9 @@ class RDKIT_FMCS_EXPORT RingMatchTableSet {
|
||||
inline unsigned getRingIndex(const INT_VECT* r2) const {
|
||||
std::map<const INT_VECT*, unsigned>::const_iterator j =
|
||||
RingIndex.find(r2);
|
||||
if (RingIndex.end() == j) throw -1;
|
||||
if (RingIndex.end() == j) {
|
||||
throw -1;
|
||||
}
|
||||
return j->second;
|
||||
}
|
||||
};
|
||||
@@ -66,7 +72,9 @@ class RDKIT_FMCS_EXPORT RingMatchTableSet {
|
||||
RingMatchTableSet() {}
|
||||
|
||||
inline void clear() {
|
||||
if (QueryBondRingsIndeces) QueryBondRingsIndeces->clear();
|
||||
if (QueryBondRingsIndeces) {
|
||||
QueryBondRingsIndeces->clear();
|
||||
}
|
||||
TargetBondRingsIndecesSet.clear();
|
||||
MatchMatrixSet.clear();
|
||||
QueryRingIndex.clear();
|
||||
@@ -82,14 +90,18 @@ class RDKIT_FMCS_EXPORT RingMatchTableSet {
|
||||
inline bool isTargetBondInRing(const ROMol* target, unsigned bi) const {
|
||||
std::map<const ROMol*, std::vector<std::vector<size_t>>>::const_iterator i =
|
||||
TargetBondRingsIndecesSet.find(target);
|
||||
if (TargetBondRingsIndecesSet.end() == i) throw -1; // never
|
||||
if (TargetBondRingsIndecesSet.end() == i) {
|
||||
throw -1; // never
|
||||
}
|
||||
return i->second[bi].empty();
|
||||
}
|
||||
inline const std::vector<size_t>& getTargetBondRings(const ROMol* target,
|
||||
unsigned bi) const {
|
||||
std::map<const ROMol*, std::vector<std::vector<size_t>>>::const_iterator i =
|
||||
TargetBondRingsIndecesSet.find(target);
|
||||
if (TargetBondRingsIndecesSet.end() == i) throw -1; // never
|
||||
if (TargetBondRingsIndecesSet.end() == i) {
|
||||
throw -1; // never
|
||||
}
|
||||
return i->second[bi];
|
||||
}
|
||||
|
||||
@@ -106,17 +118,20 @@ class RDKIT_FMCS_EXPORT RingMatchTableSet {
|
||||
unsigned i = 0;
|
||||
const RingInfo::VECT_INT_VECT& rings = query->getRingInfo()->bondRings();
|
||||
for (RingInfo::VECT_INT_VECT::const_iterator r = rings.begin();
|
||||
r != rings.end(); r++)
|
||||
r != rings.end(); r++) {
|
||||
QueryRingIndex[&*r] = i++;
|
||||
}
|
||||
TargetBondRingsIndecesSet.clear();
|
||||
QueryBondRingsIndeces = &TargetBondRingsIndecesSet[query];
|
||||
QueryBondRingsIndeces->resize(query->getNumBonds());
|
||||
size_t ri = 0;
|
||||
for (RingInfo::VECT_INT_VECT::const_iterator r = rings.begin();
|
||||
r != rings.end(); r++, ri++)
|
||||
r != rings.end(); r++, ri++) {
|
||||
for (INT_VECT::const_iterator bi = r->begin(); bi != r->end();
|
||||
bi++) // all bonds in the ring
|
||||
bi++) { // all bonds in the ring
|
||||
(*QueryBondRingsIndeces)[*bi].push_back(ri);
|
||||
}
|
||||
}
|
||||
}
|
||||
inline void addTargetBondRingsIndeces(const ROMol* mol2) {
|
||||
std::vector<std::vector<size_t>>& m = TargetBondRingsIndecesSet[mol2];
|
||||
@@ -125,10 +140,12 @@ class RDKIT_FMCS_EXPORT RingMatchTableSet {
|
||||
size_t ri = 0;
|
||||
const RingInfo::VECT_INT_VECT& rings = mol2->getRingInfo()->bondRings();
|
||||
for (RingInfo::VECT_INT_VECT::const_iterator r = rings.begin();
|
||||
r != rings.end(); r++, ri++)
|
||||
r != rings.end(); r++, ri++) {
|
||||
for (INT_VECT::const_iterator bi = r->begin(); bi != r->end();
|
||||
bi++) // all bonds in the ring
|
||||
bi++) { // all bonds in the ring
|
||||
m[*bi].push_back(ri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void computeRingMatchTable(
|
||||
@@ -150,8 +167,9 @@ class RDKIT_FMCS_EXPORT RingMatchTableSet {
|
||||
// for each TARGET ring
|
||||
for (RingInfo::VECT_INT_VECT::const_iterator r2 = rings2.begin();
|
||||
r2 != rings2.end(); r2++) {
|
||||
if (r1->size() != r2->size()) // rings are different
|
||||
if (r1->size() != r2->size()) { // rings are different
|
||||
continue;
|
||||
}
|
||||
FMCS::Graph graph2;
|
||||
makeRingGraph(
|
||||
graph2, *r2,
|
||||
@@ -173,7 +191,9 @@ class RDKIT_FMCS_EXPORT RingMatchTableSet {
|
||||
parameters.BondTyper, nullptr, parameters.AtomCompareParameters,
|
||||
bp, parameters.CompareFunctionsUserData);
|
||||
#endif
|
||||
if (match) m.setMatch(i, &*r2);
|
||||
if (match) {
|
||||
m.setMatch(i, &*r2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,9 +211,13 @@ class RDKIT_FMCS_EXPORT RingMatchTableSet {
|
||||
unsigned j2 = NotSet;
|
||||
std::map<const Atom*, unsigned>::const_iterator ai;
|
||||
ai = atomMap.find(atom1);
|
||||
if (atomMap.end() != ai) j1 = ai->second;
|
||||
if (atomMap.end() != ai) {
|
||||
j1 = ai->second;
|
||||
}
|
||||
ai = atomMap.find(atom2);
|
||||
if (atomMap.end() != ai) j2 = ai->second;
|
||||
if (atomMap.end() != ai) {
|
||||
j2 = ai->second;
|
||||
}
|
||||
if (NotSet == j1) {
|
||||
j1 = g.m_vertices.size();
|
||||
atomMap[atom1] = j1;
|
||||
@@ -211,13 +235,17 @@ class RDKIT_FMCS_EXPORT RingMatchTableSet {
|
||||
inline unsigned getQueryRingIndex(const INT_VECT* r1) const {
|
||||
std::map<const INT_VECT*, unsigned>::const_iterator i =
|
||||
QueryRingIndex.find(r1);
|
||||
if (QueryRingIndex.end() == i) throw -1; // never
|
||||
if (QueryRingIndex.end() == i) {
|
||||
throw -1; // never
|
||||
}
|
||||
return i->second;
|
||||
}
|
||||
inline const RingMatchTable& getTargetMatchMatrix(const ROMol* mol2) const {
|
||||
std::map<const ROMol*, RingMatchTable>::const_iterator mi =
|
||||
MatchMatrixSet.find(mol2);
|
||||
if (MatchMatrixSet.end() == mi) throw -1; // never
|
||||
if (MatchMatrixSet.end() == mi) {
|
||||
throw -1; // never
|
||||
}
|
||||
return mi->second;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,11 @@ class RDKIT_FMCS_EXPORT SeedSet { // sorted by amount of bonds
|
||||
Value& add(const Value& seed) {
|
||||
iterator where;
|
||||
for (where = Seeds.begin(); where != Seeds.end();
|
||||
where++) // find position in sorted list
|
||||
if (where->getNumBonds() < seed.getNumBonds()) break;
|
||||
where++) { // find position in sorted list
|
||||
if (where->getNumBonds() < seed.getNumBonds()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
iterator it = Seeds.insert(where, EmptySeed);
|
||||
Value& val = *it;
|
||||
val.setMoleculeFragment(seed);
|
||||
|
||||
@@ -52,15 +52,20 @@ class RDKIT_FMCS_EXPORT SubstructureCache {
|
||||
std::vector<unsigned long> currCodes(nv);
|
||||
std::vector<unsigned long> prevCodes(nv);
|
||||
size_t nIterations = seed.getNumBonds();
|
||||
if (nIterations > 5) nIterations = 5;
|
||||
if (nIterations > 5) {
|
||||
nIterations = 5;
|
||||
}
|
||||
|
||||
for (unsigned seedAtomIdx = 0; seedAtomIdx < seed.getNumAtoms();
|
||||
seedAtomIdx++)
|
||||
seedAtomIdx++) {
|
||||
currCodes[seedAtomIdx] =
|
||||
queryAtomLabels[seed.MoleculeFragment.AtomsIdx[seedAtomIdx]];
|
||||
}
|
||||
|
||||
for (size_t iter = 0; iter < nIterations; iter++) {
|
||||
for (size_t i = 0; i < nv; i++) prevCodes[i] = currCodes[i];
|
||||
for (size_t i = 0; i < nv; i++) {
|
||||
prevCodes[i] = currCodes[i];
|
||||
}
|
||||
|
||||
for (size_t seedBondIdx = 0; seedBondIdx < ne; seedBondIdx++) {
|
||||
const Bond* bond = seed.MoleculeFragment.Bonds[seedBondIdx];
|
||||
@@ -124,7 +129,9 @@ class RDKIT_FMCS_EXPORT SubstructureCache {
|
||||
key.computeKey(seed, queryAtomLabels, queryBondLabels);
|
||||
std::map<KeyNumericMetrics::TValue, size_t>::const_iterator entryit =
|
||||
NumericIndex.find(key.NumericMetrics.Value);
|
||||
if (NumericIndex.end() != entryit) return &ValueStorage[entryit->second];
|
||||
if (NumericIndex.end() != entryit) {
|
||||
return &ValueStorage[entryit->second];
|
||||
}
|
||||
return nullptr; // not found
|
||||
}
|
||||
|
||||
@@ -147,8 +154,9 @@ class RDKIT_FMCS_EXPORT SubstructureCache {
|
||||
if (!NumericIndex
|
||||
.insert(std::pair<KeyNumericMetrics::TValue, size_t>(
|
||||
key.NumericMetrics.Value, ValueStorage.size() - 1))
|
||||
.second)
|
||||
.second) {
|
||||
return; // not enough memory room to add the item, but it is just cache
|
||||
}
|
||||
}
|
||||
|
||||
size_t keyssize() const { // for statistics only
|
||||
@@ -158,8 +166,9 @@ class RDKIT_FMCS_EXPORT SubstructureCache {
|
||||
size_t fullsize() const { // for statistics only
|
||||
size_t n = 0;
|
||||
for (std::vector<TIndexEntry>::const_iterator e = ValueStorage.begin();
|
||||
e != ValueStorage.end(); e++)
|
||||
e != ValueStorage.end(); e++) {
|
||||
n += e->size();
|
||||
}
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -66,10 +66,12 @@ struct TargetMatch {
|
||||
for(size_t i = 0; i < TargetBondIdx.size(); i++)
|
||||
TargetBondIdx[i] = -1;
|
||||
*/
|
||||
for (size_t i = 0; i < VisitedTargetBonds.size(); i++)
|
||||
for (size_t i = 0; i < VisitedTargetBonds.size(); i++) {
|
||||
VisitedTargetBonds[i] = false;
|
||||
for (size_t i = 0; i < VisitedTargetAtoms.size(); i++)
|
||||
}
|
||||
for (size_t i = 0; i < VisitedTargetAtoms.size(); i++) {
|
||||
VisitedTargetAtoms[i] = false;
|
||||
}
|
||||
|
||||
MatchedAtomSize = match.size();
|
||||
for (match_V_t::const_iterator mit = match.begin(); mit != match.end();
|
||||
|
||||
@@ -975,7 +975,9 @@ const std::string GetV3000MolFileAtomLine(
|
||||
}
|
||||
if (atom->getPropIfPresent(common_properties::molInversionFlag, iprop) &&
|
||||
iprop) {
|
||||
if (iprop == 1 || iprop == 2) ss << " INVRET=" << iprop;
|
||||
if (iprop == 1 || iprop == 2) {
|
||||
ss << " INVRET=" << iprop;
|
||||
}
|
||||
}
|
||||
if (atom->getPropIfPresent(common_properties::molStereoCare, iprop) &&
|
||||
iprop) {
|
||||
|
||||
@@ -81,7 +81,9 @@ class RDKIT_FILEPARSERS_EXPORT SmilesWriter : public MolWriter {
|
||||
dp_ostream->flush();
|
||||
} catch (...) {
|
||||
try {
|
||||
if (dp_ostream->good()) dp_ostream->setstate(std::ios::badbit);
|
||||
if (dp_ostream->good()) {
|
||||
dp_ostream->setstate(std::ios::badbit);
|
||||
}
|
||||
} catch (const std::runtime_error &) {
|
||||
}
|
||||
}
|
||||
@@ -159,7 +161,9 @@ class RDKIT_FILEPARSERS_EXPORT SDWriter : public MolWriter {
|
||||
dp_ostream->flush();
|
||||
} catch (...) {
|
||||
try {
|
||||
if (dp_ostream->good()) dp_ostream->setstate(std::ios::badbit);
|
||||
if (dp_ostream->good()) {
|
||||
dp_ostream->setstate(std::ios::badbit);
|
||||
}
|
||||
} catch (const std::runtime_error &) {
|
||||
}
|
||||
}
|
||||
@@ -230,7 +234,9 @@ class RDKIT_FILEPARSERS_EXPORT TDTWriter : public MolWriter {
|
||||
dp_ostream->flush();
|
||||
} catch (...) {
|
||||
try {
|
||||
if (dp_ostream->good()) dp_ostream->setstate(std::ios::badbit);
|
||||
if (dp_ostream->good()) {
|
||||
dp_ostream->setstate(std::ios::badbit);
|
||||
}
|
||||
} catch (const std::runtime_error &) {
|
||||
}
|
||||
}
|
||||
@@ -298,7 +304,9 @@ class RDKIT_FILEPARSERS_EXPORT PDBWriter : public MolWriter {
|
||||
dp_ostream->flush();
|
||||
} catch (...) {
|
||||
try {
|
||||
if (dp_ostream->good()) dp_ostream->setstate(std::ios::badbit);
|
||||
if (dp_ostream->good()) {
|
||||
dp_ostream->setstate(std::ios::badbit);
|
||||
}
|
||||
} catch (const std::runtime_error &) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,9 @@ namespace RDKit {
|
||||
|
||||
namespace {
|
||||
std::string getArgName(const boost::shared_ptr<FilterMatcherBase> &arg) {
|
||||
if (arg.get()) return arg->getName();
|
||||
if (arg.get()) {
|
||||
return arg->getName();
|
||||
}
|
||||
return "<nullmatcher>";
|
||||
}
|
||||
} // namespace
|
||||
@@ -403,8 +405,11 @@ class RDKIT_FILTERCATALOG_EXPORT ExclusionList : public FilterMatcherBase {
|
||||
}
|
||||
|
||||
bool isValid() const override {
|
||||
for (size_t i = 0; i < d_offPatterns.size(); ++i)
|
||||
if (!d_offPatterns[i]->isValid()) return false;
|
||||
for (size_t i = 0; i < d_offPatterns.size(); ++i) {
|
||||
if (!d_offPatterns[i]->isValid()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,9 @@ void OptimizeMoleculeConfsHelper_(ForceFields::ForceField ff, ROMol *mol,
|
||||
ff.positions().resize(mol->getNumAtoms());
|
||||
for (ROMol::ConformerIterator cit = mol->beginConformers();
|
||||
cit != mol->endConformers(); ++cit, ++i) {
|
||||
if (i % numThreads != threadIdx) continue;
|
||||
if (i % numThreads != threadIdx) {
|
||||
continue;
|
||||
}
|
||||
for (unsigned int aidx = 0; aidx < mol->getNumAtoms(); ++aidx) {
|
||||
ff.positions()[aidx] = &(*cit)->getAtomPos(aidx);
|
||||
}
|
||||
@@ -50,7 +52,9 @@ void OptimizeMoleculeConfsMT(ROMol &mol, const ForceFields::ForceField &ff,
|
||||
&res, ti, numThreads, maxIters));
|
||||
}
|
||||
for (auto &thread : tg) {
|
||||
if (thread.joinable()) thread.join();
|
||||
if (thread.joinable()) {
|
||||
thread.join();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -86,10 +86,11 @@ void testMMFFMultiThread() {
|
||||
fut.get();
|
||||
}
|
||||
std::cerr << "done" << std::endl;
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
for (unsigned int i = 0; i < count; ++i) {
|
||||
for (auto *mol : mols[i]) {
|
||||
delete mol;
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_LOG(rdErrorLog) << " done" << std::endl;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,9 @@ class RDKIT_FRAGCATALOG_EXPORT FragCatalogEntry
|
||||
}
|
||||
|
||||
bool hasProp(const char *key) const {
|
||||
if (!dp_props) return false;
|
||||
if (!dp_props) {
|
||||
return false;
|
||||
}
|
||||
return dp_props->hasVal(key);
|
||||
}
|
||||
bool hasProp(const std::string &key) const { return hasProp(key.c_str()); }
|
||||
|
||||
@@ -206,7 +206,9 @@ class RDKIT_MOLALIGN_EXPORT SDM {
|
||||
}
|
||||
// assignment operator
|
||||
SDM &operator=(const SDM &other) {
|
||||
if (this == &other) return *this;
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
d_prbConf = other.d_prbConf;
|
||||
d_refConf = other.d_refConf;
|
||||
d_o3aConstraintVect = other.d_o3aConstraintVect;
|
||||
|
||||
@@ -61,7 +61,9 @@ class MolBundle : public RDProps {
|
||||
virtual size_t size() const { return d_mols.size(); }
|
||||
//! returns a particular molecule in the bundle
|
||||
virtual const boost::shared_ptr<ROMol> getMol(size_t idx) const {
|
||||
if (idx >= d_mols.size()) throw IndexErrorException(static_cast<int>(idx));
|
||||
if (idx >= d_mols.size()) {
|
||||
throw IndexErrorException(static_cast<int>(idx));
|
||||
}
|
||||
return d_mols[idx];
|
||||
}
|
||||
//! returns a particular molecule from the bundle
|
||||
@@ -100,13 +102,15 @@ class FixedMolSizeMolBundle : public MolBundle {
|
||||
size_t addMol(boost::shared_ptr<ROMol> nmol) override {
|
||||
PRECONDITION(nmol.get(), "bad mol pointer");
|
||||
if (d_mols.size()) {
|
||||
if (nmol->getNumAtoms() != d_mols[0]->getNumAtoms())
|
||||
if (nmol->getNumAtoms() != d_mols[0]->getNumAtoms()) {
|
||||
throw ValueErrorException(
|
||||
"all molecules in a bundle must have the same number of atoms");
|
||||
}
|
||||
// REVIEW: should we allow different numbers of bonds?
|
||||
if (nmol->getNumBonds() != d_mols[0]->getNumBonds())
|
||||
if (nmol->getNumBonds() != d_mols[0]->getNumBonds()) {
|
||||
throw ValueErrorException(
|
||||
"all molecules in a bundle must have the same number of bonds");
|
||||
}
|
||||
}
|
||||
d_mols.push_back(nmol);
|
||||
return (d_mols.size());
|
||||
|
||||
@@ -75,7 +75,9 @@ class RDKIT_MOLCATALOG_EXPORT MolCatalogEntry : public RDCatalog::CatalogEntry {
|
||||
|
||||
//! returns true if such a property exists
|
||||
bool hasProp(const char *key) const {
|
||||
if (!dp_props) return false;
|
||||
if (!dp_props) {
|
||||
return false;
|
||||
}
|
||||
return dp_props->hasVal(key);
|
||||
}
|
||||
//! \overload
|
||||
|
||||
@@ -64,7 +64,9 @@ RDKIT_MOLDRAW2D_EXPORT void addStereoAnnotation(
|
||||
RDKIT_MOLDRAW2D_EXPORT inline void addAtomIndices(const ROMol &mol) {
|
||||
// we don't need this in the global set of tags since it will only be used
|
||||
// here
|
||||
if (mol.hasProp("_atomIndicesAdded")) return;
|
||||
if (mol.hasProp("_atomIndicesAdded")) {
|
||||
return;
|
||||
}
|
||||
bool computed = true;
|
||||
mol.setProp("_atomIndicesAdded", 1, computed);
|
||||
for (auto atom : mol.atoms()) {
|
||||
@@ -80,7 +82,9 @@ RDKIT_MOLDRAW2D_EXPORT inline void addAtomIndices(const ROMol &mol) {
|
||||
RDKIT_MOLDRAW2D_EXPORT inline void addBondIndices(const ROMol &mol) {
|
||||
// we don't need this in the global set of tags since it will only be used
|
||||
// here
|
||||
if (mol.hasProp("_bondIndicesAdded")) return;
|
||||
if (mol.hasProp("_bondIndicesAdded")) {
|
||||
return;
|
||||
}
|
||||
bool computed = true;
|
||||
mol.setProp("_bondIndicesAdded", 1, computed);
|
||||
for (auto bond : mol.bonds()) {
|
||||
|
||||
@@ -474,7 +474,9 @@ void MolDraw2DSVG::tagAtoms(const ROMol &mol, double radius,
|
||||
|
||||
// ****************************************************************************
|
||||
void MolDraw2DSVG::outputClasses() {
|
||||
if (d_activeClass.empty() && !hasActiveAtmIdx()) return;
|
||||
if (d_activeClass.empty() && !hasActiveAtmIdx()) {
|
||||
return;
|
||||
}
|
||||
|
||||
d_os << "class='";
|
||||
if (!d_activeClass.empty()) {
|
||||
|
||||
@@ -537,7 +537,9 @@ void test1() {
|
||||
// https://stackoverflow.com/questions/22489073/counting-the-number-of-occurrences-of-a-string-within-a-string
|
||||
auto countSubstring = [](const std::string &str,
|
||||
const std::string &sub) -> int {
|
||||
if (sub.length() == 0) return 0;
|
||||
if (sub.length() == 0) {
|
||||
return 0;
|
||||
}
|
||||
int count = 0;
|
||||
for (size_t offset = str.find(sub); offset != std::string::npos;
|
||||
offset = str.find(sub, offset + sub.length())) {
|
||||
|
||||
@@ -29,7 +29,9 @@ void getVariations(size_t level, std::vector<size_t> base,
|
||||
getVariations(level + 1, base, variations, variationCounts,
|
||||
maxToEnumerate, doRandom);
|
||||
}
|
||||
if (variations.size() >= maxToEnumerate) return;
|
||||
if (variations.size() >= maxToEnumerate) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void enumerateVariations(std::vector<std::vector<size_t>> &variations,
|
||||
|
||||
@@ -487,7 +487,9 @@ Query<int, Atom const *, true> *unpickleQuery(std::istream &ss,
|
||||
|
||||
res->setNegation(isNegated);
|
||||
res->setDescription(descr);
|
||||
if (!typeLabel.empty()) res->setTypeLabel(typeLabel);
|
||||
if (!typeLabel.empty()) {
|
||||
res->setTypeLabel(typeLabel);
|
||||
}
|
||||
|
||||
QueryOps::finalizeQueryFromDescription(res, owner);
|
||||
|
||||
|
||||
@@ -212,7 +212,9 @@ class RDKIT_MOLSTANDARDIZE_EXPORT TautomerEnumerator {
|
||||
d_removeIsotopicHs(other.d_removeIsotopicHs),
|
||||
d_reassignStereo(other.d_reassignStereo) {}
|
||||
TautomerEnumerator &operator=(const TautomerEnumerator &other) {
|
||||
if (this == &other) return *this;
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
dp_catalog = other.dp_catalog;
|
||||
d_callback = other.d_callback;
|
||||
d_maxTautomers = other.d_maxTautomers;
|
||||
|
||||
@@ -78,15 +78,17 @@ class RDKIT_GRAPHMOL_EXPORT PeriodicTable {
|
||||
// this little optimization actually makes a measurable difference
|
||||
// in molecule-construction time
|
||||
int anum = -1;
|
||||
if (elementSymbol == "C")
|
||||
if (elementSymbol == "C") {
|
||||
anum = 6;
|
||||
else if (elementSymbol == "N")
|
||||
} else if (elementSymbol == "N") {
|
||||
anum = 7;
|
||||
else if (elementSymbol == "O")
|
||||
} else if (elementSymbol == "O") {
|
||||
anum = 8;
|
||||
else {
|
||||
} else {
|
||||
STR_UINT_MAP::const_iterator iter = byname.find(elementSymbol);
|
||||
if (iter != byname.end()) anum = iter->second;
|
||||
if (iter != byname.end()) {
|
||||
anum = iter->second;
|
||||
}
|
||||
}
|
||||
POSTCONDITION(anum > -1, "Element '" + elementSymbol + "' not found");
|
||||
return anum;
|
||||
|
||||
@@ -54,7 +54,9 @@ class RDKIT_GRAPHMOL_EXPORT QueryAtom : public Atom {
|
||||
}
|
||||
}
|
||||
QueryAtom &operator=(const QueryAtom &other) {
|
||||
if (this == &other) return *this;
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
Atom::operator=(other);
|
||||
delete dp_query;
|
||||
if (other.dp_query) {
|
||||
@@ -134,7 +136,9 @@ namespace detail {
|
||||
inline std::string qhelper(Atom::QUERYATOM_QUERY *q, unsigned int depth) {
|
||||
std::string res = "";
|
||||
if (q) {
|
||||
for (unsigned int i = 0; i < depth; ++i) res += " ";
|
||||
for (unsigned int i = 0; i < depth; ++i) {
|
||||
res += " ";
|
||||
}
|
||||
res += q->getFullDescription() + "\n";
|
||||
for (Atom::QUERYATOM_QUERY::CHILD_VECT_CI ci = q->beginChildren();
|
||||
ci != q->endChildren(); ++ci) {
|
||||
|
||||
@@ -121,7 +121,9 @@ namespace detail {
|
||||
inline std::string qhelper(Bond::QUERYBOND_QUERY *q, unsigned int depth) {
|
||||
std::string res;
|
||||
if (q) {
|
||||
for (unsigned int i = 0; i < depth; ++i) res += " ";
|
||||
for (unsigned int i = 0; i < depth; ++i) {
|
||||
res += " ";
|
||||
}
|
||||
res += q->getFullDescription() + "\n";
|
||||
for (Bond::QUERYBOND_QUERY::CHILD_VECT_CI ci = q->beginChildren();
|
||||
ci != q->endChildren(); ++ci) {
|
||||
|
||||
@@ -142,11 +142,15 @@ static inline void parseAtomType(int val, int &atomic_num, bool &aromatic) {
|
||||
}
|
||||
}
|
||||
static inline bool getAtomTypeIsAromatic(int val) {
|
||||
if (val > 1000) return true;
|
||||
if (val > 1000) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static inline int getAtomTypeAtomicNum(int val) {
|
||||
if (val > 1000) return val - 1000;
|
||||
if (val > 1000) {
|
||||
return val - 1000;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,8 +110,12 @@ int main(int argc, char* argv[]) {
|
||||
int batch = vm["batch"].as<int>();
|
||||
while (getline(fh, line)) {
|
||||
count++;
|
||||
if (count < start) continue;
|
||||
if (count > start + batch) break;
|
||||
if (count < start) {
|
||||
continue;
|
||||
}
|
||||
if (count > start + batch) {
|
||||
break;
|
||||
}
|
||||
int pos = line.find_last_of("\t");
|
||||
auto smiles = line.substr(pos + 1);
|
||||
shared_ptr<ROMol> mol(SmilesToMol(smiles));
|
||||
|
||||
@@ -206,7 +206,9 @@ RDKIT_RGROUPDECOMPOSITION_EXPORT unsigned int RGroupDecompose(
|
||||
|
||||
inline bool checkForTimeout(const std::chrono::steady_clock::time_point &t0,
|
||||
double timeout, bool throwOnTimeout = true) {
|
||||
if (timeout <= 0) return false;
|
||||
if (timeout <= 0) {
|
||||
return false;
|
||||
}
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
std::chrono::duration<double> elapsed = t1 - t0;
|
||||
if (elapsed.count() >= timeout) {
|
||||
|
||||
@@ -39,7 +39,9 @@ void addFingerprintToRGroupData(RGroupData *rgroupData) {
|
||||
// TODO- Handle multiple attachments differently?
|
||||
if (atom->getAtomicNum() == 0) {
|
||||
atom->setAtomicNum(5);
|
||||
if (atom->getIsotope() > 0) atom->setIsotope(0);
|
||||
if (atom->getIsotope() > 0) {
|
||||
atom->setIsotope(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
@@ -266,7 +268,9 @@ void VarianceDataForLabel::removeRgroupData(RGroupData *rgroupData) {
|
||||
// calculate the mean variance for a bit counts array
|
||||
double VarianceDataForLabel::variance() const {
|
||||
auto lambda = [this](double sum, int bitCount) {
|
||||
if (bitCount == 0) return sum;
|
||||
if (bitCount == 0) {
|
||||
return sum;
|
||||
}
|
||||
// variance calculation because fingerprint is binary:
|
||||
// sum == squared sum == bit count
|
||||
// ss = sqrSum - (sum * sum) / cnt;
|
||||
|
||||
@@ -105,7 +105,9 @@ RGroupGa::RGroupGa(const RGroupDecompData& rGroupData,
|
||||
numPermutations = 1L;
|
||||
auto pos = 0;
|
||||
for (auto m : matches) {
|
||||
if (m.size() == 1) continue;
|
||||
if (m.size() == 1) {
|
||||
continue;
|
||||
}
|
||||
chromosomePolicy.setMax(pos, m.size());
|
||||
unsigned long count = numPermutations * m.size();
|
||||
numPermutations = count / m.size() == numPermutations
|
||||
@@ -118,7 +120,9 @@ RGroupGa::RGroupGa(const RGroupDecompData& rGroupData,
|
||||
|
||||
// TODO refine these settings
|
||||
auto popsize = 100 + chromLength / 10;
|
||||
if (popsize > 200) popsize = 200;
|
||||
if (popsize > 200) {
|
||||
popsize = 200;
|
||||
}
|
||||
const auto& params = rGroupData.params;
|
||||
if (params.gaPopulationSize > 0) {
|
||||
popsize = params.gaPopulationSize;
|
||||
@@ -167,7 +171,9 @@ void RGroupGa::rGroupMutateOperation(
|
||||
child->decode();
|
||||
|
||||
auto& fingerprintVarianceScoreData = child->getFingerprintVarianceScoreData();
|
||||
if (fingerprintVarianceScoreData.labelsToVarianceData.size() == 0) return;
|
||||
if (fingerprintVarianceScoreData.labelsToVarianceData.size() == 0) {
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
std::cerr << "RGroup mutate start" << std::endl;
|
||||
#endif
|
||||
|
||||
@@ -104,7 +104,9 @@ bool isUserRLabel(const Atom &atom) {
|
||||
}
|
||||
|
||||
bool isAtomWithMultipleNeighborsOrNotUserRLabel(const Atom &atom) {
|
||||
if (atom.getDegree() > 1) return true;
|
||||
if (atom.getDegree() > 1) {
|
||||
return true;
|
||||
}
|
||||
return !isUserRLabel(atom);
|
||||
}
|
||||
|
||||
|
||||
@@ -1852,7 +1852,9 @@ void testMultipleCoreRelabellingIssues() {
|
||||
auto smiles = line.substr(pos + 1);
|
||||
std::shared_ptr<ROMol> mol(SmilesToMol(smiles));
|
||||
molecules.push_back(mol);
|
||||
if (molecules.size() == 30) break;
|
||||
if (molecules.size() == 30) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -222,7 +222,9 @@ int addBranchToMol(std::vector<RWMol *> &molList, unsigned int molIdx,
|
||||
for (ROMol::ATOM_BOOKMARK_MAP::const_iterator bmIt =
|
||||
branch->getAtomBookmarks()->begin();
|
||||
bmIt != branch->getAtomBookmarks()->end(); ++bmIt) {
|
||||
if (bmIt->first < 0) continue;
|
||||
if (bmIt->first < 0) {
|
||||
continue;
|
||||
}
|
||||
if (mp->hasAtomBookmark(bmIt->first)) {
|
||||
std::stringstream err;
|
||||
err << "SLN Parser error: Atom ID " << bmIt->first
|
||||
|
||||
@@ -316,7 +316,9 @@ bool removedParentInHierarchy(
|
||||
const boost::dynamic_bitset<> &toRemove,
|
||||
const std::map<unsigned int, unsigned int> &indexLookup) {
|
||||
PRECONDITION(idx < sgs.size(), "cannot find SubstanceGroup");
|
||||
if (toRemove[idx]) return true;
|
||||
if (toRemove[idx]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int parent;
|
||||
if (sgs[idx].getPropIfPresent("PARENT", parent)) {
|
||||
|
||||
@@ -43,10 +43,18 @@ struct Pair {
|
||||
* The ordering by in/out degree
|
||||
*/
|
||||
static bool nodeInfoComp1(const NodeInfo &a, const NodeInfo &b) {
|
||||
if (a.out < b.out) return true;
|
||||
if (a.out > b.out) return false;
|
||||
if (a.in < b.in) return true;
|
||||
if (a.in > b.in) return false;
|
||||
if (a.out < b.out) {
|
||||
return true;
|
||||
}
|
||||
if (a.out > b.out) {
|
||||
return false;
|
||||
}
|
||||
if (a.in < b.in) {
|
||||
return true;
|
||||
}
|
||||
if (a.in > b.in) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -55,12 +63,24 @@ static bool nodeInfoComp1(const NodeInfo &a, const NodeInfo &b) {
|
||||
* The frequency is in the out field, the valence in `in'.
|
||||
*/
|
||||
static int nodeInfoComp2(const NodeInfo &a, const NodeInfo &b) {
|
||||
if (!a.in && b.in) return 1;
|
||||
if (a.in && !b.in) return -1;
|
||||
if (a.out < b.out) return -1;
|
||||
if (a.out > b.out) return 1;
|
||||
if (a.in < b.in) return -1;
|
||||
if (a.in > b.in) return 1;
|
||||
if (!a.in && b.in) {
|
||||
return 1;
|
||||
}
|
||||
if (a.in && !b.in) {
|
||||
return -1;
|
||||
}
|
||||
if (a.out < b.out) {
|
||||
return -1;
|
||||
}
|
||||
if (a.out > b.out) {
|
||||
return 1;
|
||||
}
|
||||
if (a.in < b.in) {
|
||||
return -1;
|
||||
}
|
||||
if (a.in > b.in) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -106,8 +126,9 @@ node_id *SortNodesByFrequency(const Graph *g) {
|
||||
for (unsigned int i = 0; i < vect.size(); i += run) {
|
||||
for (run = 1; i + run < vect.size() && vect[i + run].in == vect[i].in &&
|
||||
vect[i + run].out == vect[i].out;
|
||||
++run)
|
||||
++run) {
|
||||
;
|
||||
}
|
||||
for (unsigned int j = 0; j < run; ++j) {
|
||||
vect[i + j].in += vect[i + j].out;
|
||||
vect[i + j].out = run;
|
||||
@@ -240,11 +261,14 @@ class VF2SubState {
|
||||
Graph *GetGraph2() { return g2; }
|
||||
|
||||
bool NextPair(Pair<Graph> &pair) {
|
||||
if (pair.n1 == NULL_NODE) pair.n1 = 0;
|
||||
if (pair.n2 == NULL_NODE)
|
||||
if (pair.n1 == NULL_NODE) {
|
||||
pair.n1 = 0;
|
||||
}
|
||||
if (pair.n2 == NULL_NODE) {
|
||||
pair.n2 = 0;
|
||||
else
|
||||
} else {
|
||||
pair.n2++;
|
||||
}
|
||||
|
||||
#if 0
|
||||
std::cerr<<" **** np: "<< prev_n1<<","<<prev_n2<<std::endl;
|
||||
@@ -278,8 +302,9 @@ class VF2SubState {
|
||||
boost::tie(n1iter_beg, n1iter_end) =
|
||||
boost::adjacent_vertices(pair.n1, *g1);
|
||||
|
||||
while (n1iter_beg != n1iter_end && core_1[*n1iter_beg] == NULL_NODE)
|
||||
while (n1iter_beg != n1iter_end && core_1[*n1iter_beg] == NULL_NODE) {
|
||||
++n1iter_beg;
|
||||
}
|
||||
|
||||
assert(n1iter_beg != n1iter_end);
|
||||
|
||||
@@ -293,8 +318,12 @@ class VF2SubState {
|
||||
// pair.n1=order[core_len];
|
||||
// :)
|
||||
unsigned int i = 0;
|
||||
while (i < n1 && core_1[pair.n1 = order[i]] != NULL_NODE) i++;
|
||||
if (i == n1) pair.n1 = n1;
|
||||
while (i < n1 && core_1[pair.n1 = order[i]] != NULL_NODE) {
|
||||
i++;
|
||||
}
|
||||
if (i == n1) {
|
||||
pair.n1 = n1;
|
||||
}
|
||||
} else {
|
||||
while (pair.n1 < n1 && core_1[pair.n1] != NULL_NODE) {
|
||||
pair.n1++;
|
||||
@@ -344,9 +373,12 @@ class VF2SubState {
|
||||
// }
|
||||
|
||||
// O(1) check for adjacency list
|
||||
if (boost::out_degree(node1, *g1) > boost::out_degree(node2, *g2))
|
||||
if (boost::out_degree(node1, *g1) > boost::out_degree(node2, *g2)) {
|
||||
return false;
|
||||
if (!vc(node1, node2)) return false;
|
||||
}
|
||||
if (!vc(node1, node2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int other1, other2;
|
||||
#ifdef RDK_VF2_PRUNING
|
||||
@@ -494,17 +526,22 @@ class VF2SubState {
|
||||
bool Match(node_id c1[], node_id c2[]) {
|
||||
if (IsGoal()) {
|
||||
GetCoreSet(c1, c2);
|
||||
if (MatchChecks(c1, c2)) return true;
|
||||
if (MatchChecks(c1, c2)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsDead()) return false;
|
||||
if (IsDead()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Pair<Graph> pair;
|
||||
while (NextPair(pair)) {
|
||||
if (IsFeasiblePair(pair.n1, pair.n2)) {
|
||||
AddPair(pair.n1, pair.n2);
|
||||
if (Match(c1, c2)) // recurse
|
||||
if (Match(c1, c2)) { // recurse
|
||||
return true;
|
||||
}
|
||||
BackTrack(pair.n1, pair.n2);
|
||||
}
|
||||
}
|
||||
@@ -526,14 +563,17 @@ class VF2SubState {
|
||||
}
|
||||
}
|
||||
|
||||
if (IsDead()) return false;
|
||||
if (IsDead()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Pair<Graph> pair;
|
||||
while (NextPair(pair)) {
|
||||
if (IsFeasiblePair(pair.n1, pair.n2)) {
|
||||
AddPair(pair.n1, pair.n2);
|
||||
if (MatchAll(c1, c2, res, lim)) // recurse
|
||||
if (MatchAll(c1, c2, res, lim)) { // recurse
|
||||
return true;
|
||||
}
|
||||
BackTrack(pair.n1, pair.n2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,9 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT MolHolder : public MolHolderBase {
|
||||
}
|
||||
|
||||
boost::shared_ptr<ROMol> getMol(unsigned int idx) const override {
|
||||
if (idx >= mols.size()) throw IndexErrorException(idx);
|
||||
if (idx >= mols.size()) {
|
||||
throw IndexErrorException(idx);
|
||||
}
|
||||
return mols[idx];
|
||||
}
|
||||
|
||||
@@ -133,7 +135,9 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT CachedMolHolder : public MolHolderBase {
|
||||
}
|
||||
|
||||
boost::shared_ptr<ROMol> getMol(unsigned int idx) const override {
|
||||
if (idx >= mols.size()) throw IndexErrorException(idx);
|
||||
if (idx >= mols.size()) {
|
||||
throw IndexErrorException(idx);
|
||||
}
|
||||
boost::shared_ptr<ROMol> mol(new ROMol);
|
||||
MolPickler::molFromPickle(mols[idx], mol.get());
|
||||
return mol;
|
||||
@@ -177,7 +181,9 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT CachedSmilesMolHolder
|
||||
}
|
||||
|
||||
boost::shared_ptr<ROMol> getMol(unsigned int idx) const override {
|
||||
if (idx >= mols.size()) throw IndexErrorException(idx);
|
||||
if (idx >= mols.size()) {
|
||||
throw IndexErrorException(idx);
|
||||
}
|
||||
|
||||
boost::shared_ptr<ROMol> mol(SmilesToMol(mols[idx]));
|
||||
return mol;
|
||||
@@ -226,7 +232,9 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT CachedTrustedSmilesMolHolder
|
||||
}
|
||||
|
||||
boost::shared_ptr<ROMol> getMol(unsigned int idx) const override {
|
||||
if (idx >= mols.size()) throw IndexErrorException(idx);
|
||||
if (idx >= mols.size()) {
|
||||
throw IndexErrorException(idx);
|
||||
}
|
||||
|
||||
RWMol *m = SmilesToMol(mols[idx], 0, false);
|
||||
if (m) {
|
||||
@@ -249,7 +257,9 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT FPHolderBase {
|
||||
|
||||
public:
|
||||
virtual ~FPHolderBase() {
|
||||
for (size_t i = 0; i < fps.size(); ++i) delete fps[i];
|
||||
for (size_t i = 0; i < fps.size(); ++i) {
|
||||
delete fps[i];
|
||||
}
|
||||
}
|
||||
|
||||
virtual unsigned int size() const { return rdcast<unsigned int>(fps.size()); }
|
||||
@@ -277,7 +287,9 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT FPHolderBase {
|
||||
|
||||
//! Return false if a substructure search can never match the molecule
|
||||
bool passesFilter(unsigned int idx, const ExplicitBitVect &query) const {
|
||||
if (idx >= fps.size()) throw IndexErrorException(idx);
|
||||
if (idx >= fps.size()) {
|
||||
throw IndexErrorException(idx);
|
||||
}
|
||||
|
||||
return AllProbeBitsMatch(query, *fps[idx]);
|
||||
}
|
||||
@@ -285,7 +297,9 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT FPHolderBase {
|
||||
//! Get the bit vector at the specified index (throws IndexError if out of
|
||||
//! range)
|
||||
const ExplicitBitVect &getFingerprint(unsigned int idx) const {
|
||||
if (idx >= fps.size()) throw IndexErrorException(idx);
|
||||
if (idx >= fps.size()) {
|
||||
throw IndexErrorException(idx);
|
||||
}
|
||||
return *fps[idx];
|
||||
}
|
||||
|
||||
@@ -388,7 +402,9 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT KeyFromPropHolder : public KeyHolderBase {
|
||||
}
|
||||
|
||||
const std::string &getKey(unsigned int idx) const override {
|
||||
if (idx >= keys.size()) throw IndexErrorException(idx);
|
||||
if (idx >= keys.size()) {
|
||||
throw IndexErrorException(idx);
|
||||
}
|
||||
return keys[idx];
|
||||
}
|
||||
|
||||
@@ -604,30 +620,34 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT SubstructLibrary {
|
||||
//! Get the underlying fingerprint implementation.
|
||||
/*! Throws a value error if no fingerprints have been set */
|
||||
FPHolderBase &getFingerprints() {
|
||||
if (!fps)
|
||||
if (!fps) {
|
||||
throw ValueErrorException("Substruct Library does not have fingerprints");
|
||||
}
|
||||
return *fps;
|
||||
}
|
||||
|
||||
const FPHolderBase &getFingerprints() const {
|
||||
if (!fps)
|
||||
if (!fps) {
|
||||
throw ValueErrorException("Substruct Library does not have fingerprints");
|
||||
}
|
||||
return *fps;
|
||||
}
|
||||
|
||||
//! Get the underlying key holder implementation.
|
||||
/*! Throws a value error if no keyholder have been set */
|
||||
KeyHolderBase &getKeys() {
|
||||
if (!keyholder.get())
|
||||
if (!keyholder.get()) {
|
||||
throw ValueErrorException("Substruct Library does not have fingerprints");
|
||||
}
|
||||
return *keyholder.get();
|
||||
}
|
||||
|
||||
//! Get the underlying key holder implementation.
|
||||
/*! Throws a value error if no keyholder have been set */
|
||||
const KeyHolderBase &getKeys() const {
|
||||
if (!keyholder.get())
|
||||
if (!keyholder.get()) {
|
||||
throw ValueErrorException("Substruct Library does not have fingerprints");
|
||||
}
|
||||
return *keyholder.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,9 @@ void load(Archive &ar, RDKit::FPHolderBase &fpholder,
|
||||
std::vector<ExplicitBitVect *> &fps = fpholder.getFingerprints();
|
||||
|
||||
ar &pickles;
|
||||
for (size_t i = 0; i < fps.size(); ++i) delete fps[i];
|
||||
for (size_t i = 0; i < fps.size(); ++i) {
|
||||
delete fps[i];
|
||||
}
|
||||
fps.clear();
|
||||
|
||||
for (auto &pkl : pickles) {
|
||||
|
||||
@@ -102,7 +102,9 @@ class TautomerQueryMatcher {
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Got Match " << std::endl;
|
||||
#endif
|
||||
if (d_matchingTautomers) d_matchingTautomers->push_back(tautomer);
|
||||
if (d_matchingTautomers) {
|
||||
d_matchingTautomers->push_back(tautomer);
|
||||
}
|
||||
}
|
||||
return matchingTautomer;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,9 @@ TEST_CASE("TEMPLATE_ERROR") {
|
||||
std::cout << "Tautomer " << MolToSmiles(*taut) << " match " << test
|
||||
<< std::endl;
|
||||
#endif
|
||||
if (test) match = true;
|
||||
if (test) {
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
CHECK(match);
|
||||
|
||||
|
||||
@@ -82,15 +82,33 @@ boost::python::dict GetPropsAsDict(const T &obj, bool includePrivate,
|
||||
// std::vector<int>, std::vector<unsigned>, string
|
||||
STR_VECT keys = obj.getPropList(includePrivate, includeComputed);
|
||||
for (size_t i = 0; i < keys.size(); ++i) {
|
||||
if (AddToDict<int>(obj, dict, keys[i])) continue;
|
||||
if (AddToDict<unsigned int>(obj, dict, keys[i])) continue;
|
||||
if (AddToDict<bool>(obj, dict, keys[i])) continue;
|
||||
if (AddToDict<double>(obj, dict, keys[i])) continue;
|
||||
if (AddToDict<std::vector<int>>(obj, dict, keys[i])) continue;
|
||||
if (AddToDict<std::vector<unsigned int>>(obj, dict, keys[i])) continue;
|
||||
if (AddToDict<std::vector<double>>(obj, dict, keys[i])) continue;
|
||||
if (AddToDict<std::vector<std::string>>(obj, dict, keys[i])) continue;
|
||||
if (AddToDict<std::string>(obj, dict, keys[i])) continue;
|
||||
if (AddToDict<int>(obj, dict, keys[i])) {
|
||||
continue;
|
||||
}
|
||||
if (AddToDict<unsigned int>(obj, dict, keys[i])) {
|
||||
continue;
|
||||
}
|
||||
if (AddToDict<bool>(obj, dict, keys[i])) {
|
||||
continue;
|
||||
}
|
||||
if (AddToDict<double>(obj, dict, keys[i])) {
|
||||
continue;
|
||||
}
|
||||
if (AddToDict<std::vector<int>>(obj, dict, keys[i])) {
|
||||
continue;
|
||||
}
|
||||
if (AddToDict<std::vector<unsigned int>>(obj, dict, keys[i])) {
|
||||
continue;
|
||||
}
|
||||
if (AddToDict<std::vector<double>>(obj, dict, keys[i])) {
|
||||
continue;
|
||||
}
|
||||
if (AddToDict<std::vector<std::string>>(obj, dict, keys[i])) {
|
||||
continue;
|
||||
}
|
||||
if (AddToDict<std::string>(obj, dict, keys[i])) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,9 @@ PyObject *helpGetSubstructMatch(T1 &mol, T2 &query,
|
||||
std::vector<MatchVectType> matches;
|
||||
pySubstructHelper(mol, query, params, matches);
|
||||
MatchVectType match;
|
||||
if (matches.size()) match = matches[0];
|
||||
if (matches.size()) {
|
||||
match = matches[0];
|
||||
}
|
||||
return convertMatches(match);
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,9 @@ class RDKIT_GRAPHMOL_EXPORT SpecialChiralityAtomCompareFunctor {
|
||||
ii < dp_atoms[i].bonds.size() && ii < dp_atoms[j].bonds.size(); ++ii) {
|
||||
int cmp =
|
||||
bondholder::compare(dp_atoms[i].bonds[ii], dp_atoms[j].bonds[ii]);
|
||||
if (cmp) return cmp;
|
||||
if (cmp) {
|
||||
return cmp;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::pair<unsigned int, unsigned int>> swapsi;
|
||||
@@ -177,7 +179,9 @@ class RDKIT_GRAPHMOL_EXPORT SpecialChiralityAtomCompareFunctor {
|
||||
}
|
||||
for (unsigned int ii = 0; ii < swapsi.size() && ii < swapsj.size(); ++ii) {
|
||||
int cmp = swapsi[ii].second - swapsj[ii].second;
|
||||
if (cmp) return cmp;
|
||||
if (cmp) {
|
||||
return cmp;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -229,7 +233,9 @@ class RDKIT_GRAPHMOL_EXPORT SpecialSymmetryAtomCompareFunctor {
|
||||
ii < dp_atoms[i].bonds.size() && ii < dp_atoms[j].bonds.size(); ++ii) {
|
||||
int cmp =
|
||||
bondholder::compare(dp_atoms[i].bonds[ii], dp_atoms[j].bonds[ii]);
|
||||
if (cmp) return cmp;
|
||||
if (cmp) {
|
||||
return cmp;
|
||||
}
|
||||
}
|
||||
|
||||
if (dp_atoms[i].bonds.size() < dp_atoms[j].bonds.size()) {
|
||||
@@ -243,7 +249,9 @@ class RDKIT_GRAPHMOL_EXPORT SpecialSymmetryAtomCompareFunctor {
|
||||
|
||||
class RDKIT_GRAPHMOL_EXPORT AtomCompareFunctor {
|
||||
unsigned int getAtomRingNbrCode(unsigned int i) const {
|
||||
if (!dp_atoms[i].hasRingNbr) return 0;
|
||||
if (!dp_atoms[i].hasRingNbr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int *nbrs = dp_atoms[i].nbrIds;
|
||||
unsigned int code = 0;
|
||||
@@ -469,26 +477,29 @@ class RDKIT_GRAPHMOL_EXPORT ChiralAtomCompareFunctor {
|
||||
// always start with the current class:
|
||||
ivi = dp_atoms[i].index;
|
||||
ivj = dp_atoms[j].index;
|
||||
if (ivi < ivj)
|
||||
if (ivi < ivj) {
|
||||
return -1;
|
||||
else if (ivi > ivj)
|
||||
} else if (ivi > ivj) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// move onto atomic number
|
||||
ivi = dp_atoms[i].atom->getAtomicNum();
|
||||
ivj = dp_atoms[j].atom->getAtomicNum();
|
||||
if (ivi < ivj)
|
||||
if (ivi < ivj) {
|
||||
return -1;
|
||||
else if (ivi > ivj)
|
||||
} else if (ivi > ivj) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// isotopes:
|
||||
ivi = dp_atoms[i].atom->getIsotope();
|
||||
ivj = dp_atoms[j].atom->getIsotope();
|
||||
if (ivi < ivj)
|
||||
if (ivi < ivj) {
|
||||
return -1;
|
||||
else if (ivi > ivj)
|
||||
} else if (ivi > ivj) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// atom stereochem:
|
||||
ivi = 0;
|
||||
@@ -502,10 +513,11 @@ class RDKIT_GRAPHMOL_EXPORT ChiralAtomCompareFunctor {
|
||||
cipCode)) {
|
||||
ivj = cipCode == "R" ? 2 : 1;
|
||||
}
|
||||
if (ivi < ivj)
|
||||
if (ivi < ivj) {
|
||||
return -1;
|
||||
else if (ivi > ivj)
|
||||
} else if (ivi > ivj) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// bond stereo is taken care of in the neighborhood comparison
|
||||
return 0;
|
||||
@@ -523,7 +535,9 @@ class RDKIT_GRAPHMOL_EXPORT ChiralAtomCompareFunctor {
|
||||
PRECONDITION(dp_mol, "no molecule");
|
||||
PRECONDITION(i != j, "bad call");
|
||||
int v = basecomp(i, j);
|
||||
if (v) return v;
|
||||
if (v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
if (df_useNbrs) {
|
||||
getAtomNeighborhood(dp_atoms[i].bonds);
|
||||
@@ -537,14 +551,18 @@ class RDKIT_GRAPHMOL_EXPORT ChiralAtomCompareFunctor {
|
||||
++ii) {
|
||||
int cmp = bondholder::compare(
|
||||
dp_atoms[i].bonds[ii], dp_atoms[j].bonds[ii], ATNUM_CLASS_OFFSET);
|
||||
if (cmp) return cmp;
|
||||
if (cmp) {
|
||||
return cmp;
|
||||
}
|
||||
}
|
||||
for (unsigned int ii = 0;
|
||||
ii < dp_atoms[i].bonds.size() && ii < dp_atoms[j].bonds.size();
|
||||
++ii) {
|
||||
int cmp =
|
||||
bondholder::compare(dp_atoms[i].bonds[ii], dp_atoms[j].bonds[ii]);
|
||||
if (cmp) return cmp;
|
||||
if (cmp) {
|
||||
return cmp;
|
||||
}
|
||||
}
|
||||
if (dp_atoms[i].bonds.size() < dp_atoms[j].bonds.size()) {
|
||||
return -1;
|
||||
@@ -621,7 +639,9 @@ void RefinePartitions(const ROMol &mol, canon_atom *atoms, CompareFunc compar,
|
||||
// count:"<<count[index]<<std::endl;
|
||||
for (i = count[index]; i < len; i++) {
|
||||
index = start[i];
|
||||
if (count[index]) symclass = offset + i;
|
||||
if (count[index]) {
|
||||
symclass = offset + i;
|
||||
}
|
||||
atoms[index].index = symclass;
|
||||
// std::cerr<<" "<<index+1<<"("<<symclass<<")";
|
||||
// if(mode && (activeset<0 || count[index]>count[activeset]) ){
|
||||
|
||||
@@ -126,8 +126,12 @@ class RDKIT_INFOTHEORY_EXPORT InfoBitRanker {
|
||||
}
|
||||
|
||||
~InfoBitRanker() {
|
||||
if (dp_topBits) delete[] dp_topBits;
|
||||
if (dp_maskBits) delete dp_maskBits;
|
||||
if (dp_topBits) {
|
||||
delete[] dp_topBits;
|
||||
}
|
||||
if (dp_maskBits) {
|
||||
delete dp_maskBits;
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief Accumulate the votes for all the bits turned on in a bit vector
|
||||
|
||||
@@ -72,9 +72,13 @@ inline void Contour(const double *d, size_t ilb, size_t iub, size_t jlb,
|
||||
temp1 = std::max(d[i * ny + j], d[i * ny + j + 1]);
|
||||
temp2 = std::max(d[(i + 1) * ny + j], d[(i + 1) * ny + j + 1]);
|
||||
dmax = std::max(temp1, temp2);
|
||||
if (dmax < z[0] || dmin > z[nc - 1]) continue;
|
||||
if (dmax < z[0] || dmin > z[nc - 1]) {
|
||||
continue;
|
||||
}
|
||||
for (k = 0; k < nc; k++) {
|
||||
if (z[k] < dmin || z[k] > dmax) continue;
|
||||
if (z[k] < dmin || z[k] > dmax) {
|
||||
continue;
|
||||
}
|
||||
for (m = 4; m >= 0; m--) {
|
||||
if (m > 0) {
|
||||
h[m] = d[(i + im[m - 1]) * ny + j + jm[m - 1]] - z[k];
|
||||
@@ -85,12 +89,13 @@ inline void Contour(const double *d, size_t ilb, size_t iub, size_t jlb,
|
||||
xh[0] = 0.50 * (x[i] + x[i + 1]);
|
||||
yh[0] = 0.50 * (y[j] + y[j + 1]);
|
||||
}
|
||||
if (h[m] > 0.0)
|
||||
if (h[m] > 0.0) {
|
||||
sh[m] = 1;
|
||||
else if (h[m] < 0.0)
|
||||
} else if (h[m] < 0.0) {
|
||||
sh[m] = -1;
|
||||
else
|
||||
} else {
|
||||
sh[m] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -120,12 +125,14 @@ inline void Contour(const double *d, size_t ilb, size_t iub, size_t jlb,
|
||||
for (m = 1; m <= 4; m++) {
|
||||
m1 = m;
|
||||
m2 = 0;
|
||||
if (m != 4)
|
||||
if (m != 4) {
|
||||
m3 = m + 1;
|
||||
else
|
||||
} else {
|
||||
m3 = 1;
|
||||
if ((case_value = castab[sh[m1] + 1][sh[m2] + 1][sh[m3] + 1]) == 0)
|
||||
}
|
||||
if ((case_value = castab[sh[m1] + 1][sh[m2] + 1][sh[m3] + 1]) == 0) {
|
||||
continue;
|
||||
}
|
||||
switch (case_value) {
|
||||
case 1: /* Line between vertices 1 and 2 */
|
||||
x1 = xh[m1];
|
||||
|
||||
@@ -65,12 +65,16 @@ void linearSearch(unsigned int dim, double *oldPt, double oldVal, double *grad,
|
||||
|
||||
// get the length of the direction vector:
|
||||
sum = 0.0;
|
||||
for (unsigned int i = 0; i < dim; i++) sum += dir[i] * dir[i];
|
||||
for (unsigned int i = 0; i < dim; i++) {
|
||||
sum += dir[i] * dir[i];
|
||||
}
|
||||
sum = sqrt(sum);
|
||||
|
||||
// rescale if we're trying to move too far:
|
||||
if (sum > maxStep) {
|
||||
for (unsigned int i = 0; i < dim; i++) dir[i] *= maxStep / sum;
|
||||
for (unsigned int i = 0; i < dim; i++) {
|
||||
dir[i] *= maxStep / sum;
|
||||
}
|
||||
}
|
||||
|
||||
// make sure our direction has at least some component along
|
||||
@@ -86,7 +90,9 @@ void linearSearch(unsigned int dim, double *oldPt, double oldVal, double *grad,
|
||||
test = 0.0;
|
||||
for (unsigned int i = 0; i < dim; i++) {
|
||||
double temp = fabs(dir[i]) / std::max(fabs(oldPt[i]), 1.0);
|
||||
if (temp > test) test = temp;
|
||||
if (temp > test) {
|
||||
test = temp;
|
||||
}
|
||||
}
|
||||
|
||||
lambdaMin = MOVETOL / test;
|
||||
@@ -242,7 +248,9 @@ int minimize(unsigned int dim, double *pos, double gradTol,
|
||||
xi[i] = newPos[i] - pos[i];
|
||||
pos[i] = newPos[i];
|
||||
double temp = fabs(xi[i]) / std::max(fabs(pos[i]), 1.0);
|
||||
if (temp > test) test = temp;
|
||||
if (temp > test) {
|
||||
test = temp;
|
||||
}
|
||||
dGrad[i] = grad[i];
|
||||
}
|
||||
// std::cerr<<" iter: "<<iter<<" "<<fp<<" "<<test<<"
|
||||
|
||||
@@ -299,9 +299,13 @@ typedef Vector<double> DoubleVector;
|
||||
template <typename T>
|
||||
double TanimotoSimilarity(const Vector<T> &v1, const Vector<T> &v2) {
|
||||
double numer = v1.dotProduct(v2);
|
||||
if (numer == 0.0) return 0.0;
|
||||
if (numer == 0.0) {
|
||||
return 0.0;
|
||||
}
|
||||
double denom = v1.normL2Sq() + v2.normL2Sq() - numer;
|
||||
if (denom == 0.0) return 0.0;
|
||||
if (denom == 0.0) {
|
||||
return 0.0;
|
||||
}
|
||||
return numer / denom;
|
||||
}
|
||||
} // end of namespace RDNumeric
|
||||
|
||||
@@ -985,8 +985,12 @@ extern "C" bytea *makeLowSparseFingerPrint(CSfp data, int numInts) {
|
||||
#endif
|
||||
}
|
||||
|
||||
if (s[n].low == 0 || s[n].low > iterV) s[n].low = iterV;
|
||||
if (s[n].high < iterV) s[n].high = iterV;
|
||||
if (s[n].low == 0 || s[n].low > iterV) {
|
||||
s[n].low = iterV;
|
||||
}
|
||||
if (s[n].high < iterV) {
|
||||
s[n].high = iterV;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -1015,8 +1019,9 @@ extern "C" void countOverlapValues(bytea *sign, CSfp data, int numBits,
|
||||
} else {
|
||||
/* Assume, sign has only true bits */
|
||||
for (iter = v->getNonzeroElements().begin();
|
||||
iter != v->getNonzeroElements().end(); iter++)
|
||||
iter != v->getNonzeroElements().end(); iter++) {
|
||||
*sum += iter->second;
|
||||
}
|
||||
|
||||
*overlapSum = *sum;
|
||||
*overlapN = v->getNonzeroElements().size();
|
||||
@@ -1050,9 +1055,10 @@ extern "C" void countLowOverlapValues(bytea *sign, CSfp data, int numInts,
|
||||
|
||||
for (n = 0; n < numInts; n++) {
|
||||
*keySum += s[n].low;
|
||||
if (s[n].low != s[n].high)
|
||||
*keySum += s[n].high; /* there is at least two key mapped into current
|
||||
backet */
|
||||
if (s[n].low != s[n].high) {
|
||||
*keySum += s[n].high;
|
||||
} /* there is at least two key mapped into current
|
||||
backet */
|
||||
}
|
||||
|
||||
Assert(*overlapUp <= *keySum);
|
||||
@@ -2151,9 +2157,10 @@ extern "C" char *findMCSsmiles(char *smiles, char *params) {
|
||||
try {
|
||||
MCSResult res = RDKit::findMCS(molecules, &p);
|
||||
mcs = res.SmartsString;
|
||||
if (!res.isCompleted())
|
||||
if (!res.isCompleted()) {
|
||||
ereport(WARNING, (errcode(ERRCODE_WARNING),
|
||||
errmsg("findMCS timed out, result is not maximal")));
|
||||
}
|
||||
} catch (...) {
|
||||
ereport(WARNING, (errcode(ERRCODE_WARNING), errmsg("findMCS: failed")));
|
||||
mcs.clear();
|
||||
@@ -2206,9 +2213,10 @@ extern "C" char *findMCS(void *vmols, char *params) {
|
||||
|
||||
try {
|
||||
MCSResult res = RDKit::findMCS(*molecules, &p);
|
||||
if (!res.isCompleted())
|
||||
if (!res.isCompleted()) {
|
||||
ereport(WARNING, (errcode(ERRCODE_WARNING),
|
||||
errmsg("findMCS timed out, result is not maximal")));
|
||||
}
|
||||
mcs = res.SmartsString;
|
||||
} catch (...) {
|
||||
ereport(WARNING, (errcode(ERRCODE_WARNING), errmsg("findMCS: failed")));
|
||||
|
||||
@@ -34,7 +34,9 @@ class RDKIT_QUERY_EXPORT AndQuery
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this->getNegation()) res = !res;
|
||||
if (this->getNegation()) {
|
||||
res = !res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
Query<MatchFuncArgType, DataFuncArgType, needsConversion> *copy()
|
||||
|
||||
@@ -83,10 +83,11 @@ class RDKIT_QUERY_EXPORT EqualityQuery
|
||||
std::ostringstream res;
|
||||
res << this->getDescription();
|
||||
res << " " << this->d_val;
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
res << " != ";
|
||||
else
|
||||
} else {
|
||||
res << " = ";
|
||||
}
|
||||
res << "val";
|
||||
return res.str();
|
||||
}
|
||||
|
||||
@@ -39,15 +39,17 @@ class RDKIT_QUERY_EXPORT GreaterEqualQuery
|
||||
MatchFuncArgType mfArg =
|
||||
this->TypeConvert(what, Int2Type<needsConversion>());
|
||||
if (queryCmp(this->d_val, mfArg, this->d_tol) >= 0) {
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
return false;
|
||||
else
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
return true;
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Query<MatchFuncArgType, DataFuncArgType, needsConversion> *copy()
|
||||
@@ -68,10 +70,11 @@ class RDKIT_QUERY_EXPORT GreaterEqualQuery
|
||||
std::ostringstream res;
|
||||
res << this->getDescription();
|
||||
res << " " << this->d_val;
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
res << " ! >= ";
|
||||
else
|
||||
} else {
|
||||
res << " >= ";
|
||||
}
|
||||
return res.str();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,15 +39,17 @@ class RDKIT_QUERY_EXPORT GreaterQuery
|
||||
MatchFuncArgType mfArg =
|
||||
this->TypeConvert(what, Int2Type<needsConversion>());
|
||||
if (queryCmp(this->d_val, mfArg, this->d_tol) > 0) {
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
return false;
|
||||
else
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
return true;
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,10 +70,11 @@ class RDKIT_QUERY_EXPORT GreaterQuery
|
||||
std::ostringstream res;
|
||||
res << this->getDescription();
|
||||
res << " " << this->d_val;
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
res << " ! > ";
|
||||
else
|
||||
} else {
|
||||
res << " > ";
|
||||
}
|
||||
return res.str();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,15 +39,17 @@ class RDKIT_QUERY_EXPORT LessEqualQuery
|
||||
MatchFuncArgType mfArg =
|
||||
this->TypeConvert(what, Int2Type<needsConversion>());
|
||||
if (queryCmp(this->d_val, mfArg, this->d_tol) <= 0) {
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
return false;
|
||||
else
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
return true;
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +71,11 @@ class RDKIT_QUERY_EXPORT LessEqualQuery
|
||||
std::ostringstream res;
|
||||
res << this->getDescription();
|
||||
res << " " << this->d_val;
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
res << " ! <= ";
|
||||
else
|
||||
} else {
|
||||
res << " <= ";
|
||||
}
|
||||
return res.str();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,15 +39,17 @@ class RDKIT_QUERY_EXPORT LessQuery
|
||||
MatchFuncArgType mfArg =
|
||||
this->TypeConvert(what, Int2Type<needsConversion>());
|
||||
if (queryCmp(this->d_val, mfArg, this->d_tol) < 0) {
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
return false;
|
||||
else
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
return true;
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,10 +70,11 @@ class RDKIT_QUERY_EXPORT LessQuery
|
||||
std::ostringstream res;
|
||||
res << this->getDescription();
|
||||
res << " " << this->d_val;
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
res << " ! < ";
|
||||
else
|
||||
} else {
|
||||
res << " < ";
|
||||
}
|
||||
return res.str();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -33,7 +33,9 @@ class RDKIT_QUERY_EXPORT OrQuery
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this->getNegation()) res = !res;
|
||||
if (this->getNegation()) {
|
||||
res = !res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,10 +70,11 @@ class RDKIT_QUERY_EXPORT Query {
|
||||
const std::string &getDescription() const { return this->d_description; }
|
||||
//! returns a fuller text description
|
||||
virtual std::string getFullDescription() const {
|
||||
if (!getNegation())
|
||||
if (!getNegation()) {
|
||||
return getDescription();
|
||||
else
|
||||
} else {
|
||||
return "not " + getDescription();
|
||||
}
|
||||
}
|
||||
|
||||
//! sets our type label
|
||||
@@ -109,15 +110,17 @@ class RDKIT_QUERY_EXPORT Query {
|
||||
virtual bool Match(const DataFuncArgType arg) const {
|
||||
MatchFuncArgType mfArg = TypeConvert(arg, Int2Type<needsConversion>());
|
||||
bool tRes;
|
||||
if (this->d_matchFunc)
|
||||
if (this->d_matchFunc) {
|
||||
tRes = this->d_matchFunc(mfArg);
|
||||
else
|
||||
} else {
|
||||
tRes = static_cast<bool>(mfArg);
|
||||
}
|
||||
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
return !tRes;
|
||||
else
|
||||
} else {
|
||||
return tRes;
|
||||
}
|
||||
}
|
||||
|
||||
//! returns a copy of this Query
|
||||
|
||||
@@ -64,20 +64,23 @@ class RDKIT_QUERY_EXPORT RangeQuery
|
||||
int lCmp = queryCmp(this->d_lower, mfArg, this->d_tol);
|
||||
int uCmp = queryCmp(this->d_upper, mfArg, this->d_tol);
|
||||
bool lowerRes, upperRes;
|
||||
if (this->df_lowerOpen)
|
||||
if (this->df_lowerOpen) {
|
||||
lowerRes = lCmp < 0;
|
||||
else
|
||||
} else {
|
||||
lowerRes = lCmp <= 0;
|
||||
if (this->df_upperOpen)
|
||||
}
|
||||
if (this->df_upperOpen) {
|
||||
upperRes = uCmp > 0;
|
||||
else
|
||||
} else {
|
||||
upperRes = uCmp >= 0;
|
||||
}
|
||||
|
||||
bool tempR = !(lowerRes && upperRes);
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
return tempR;
|
||||
else
|
||||
} else {
|
||||
return !tempR;
|
||||
}
|
||||
}
|
||||
|
||||
Query<MatchFuncArgType, DataFuncArgType, needsConversion> *copy()
|
||||
@@ -98,7 +101,9 @@ class RDKIT_QUERY_EXPORT RangeQuery
|
||||
std::string getFullDescription() const override {
|
||||
std::ostringstream res;
|
||||
res << this->getDescription();
|
||||
if (this->getNegation()) res << " ! ";
|
||||
if (this->getNegation()) {
|
||||
res << " ! ";
|
||||
}
|
||||
res << " " << this->d_lower << " val " << this->d_upper;
|
||||
return res.str();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,9 @@ class RDKIT_QUERY_EXPORT SetQuery
|
||||
|
||||
//! insert an entry into our \c set
|
||||
void insert(const MatchFuncArgType what) {
|
||||
if (d_set.find(what) == this->d_set.end()) this->d_set.insert(what);
|
||||
if (d_set.find(what) == this->d_set.end()) {
|
||||
this->d_set.insert(what);
|
||||
}
|
||||
}
|
||||
|
||||
//! clears our \c set
|
||||
@@ -67,10 +69,11 @@ class RDKIT_QUERY_EXPORT SetQuery
|
||||
std::string getFullDescription() const override {
|
||||
std::ostringstream res;
|
||||
res << this->getDescription() << " val";
|
||||
if (this->getNegation())
|
||||
if (this->getNegation()) {
|
||||
res << " not in ";
|
||||
else
|
||||
} else {
|
||||
res << " in (";
|
||||
}
|
||||
std::copy(d_set.begin(), d_set.end(),
|
||||
std::ostream_iterator<MatchFuncArgType>(res, ", "));
|
||||
res << ")";
|
||||
|
||||
@@ -38,7 +38,9 @@ class RDKIT_QUERY_EXPORT XOrQuery
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this->getNegation()) res = !res;
|
||||
if (this->getNegation()) {
|
||||
res = !res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,9 @@ class list_indexing_suite
|
||||
extract<long> i(i_);
|
||||
if (i.check()) {
|
||||
long index = i();
|
||||
if (index < 0) index += DerivedPolicies::size(container);
|
||||
if (index < 0) {
|
||||
index += DerivedPolicies::size(container);
|
||||
}
|
||||
if (index >= long(container.size()) || index < 0) {
|
||||
PyErr_SetString(PyExc_IndexError, "Index out of range");
|
||||
throw_error_already_set();
|
||||
|
||||
@@ -215,16 +215,18 @@ class streambuf : public std::basic_streambuf<char> {
|
||||
switch (mode) {
|
||||
case 's': /// yeah, is redundant, but it is somehow natural to do "s"
|
||||
case 't':
|
||||
if (!df_isTextMode)
|
||||
if (!df_isTextMode) {
|
||||
throw ValueErrorException(
|
||||
"Need a text mode file object like StringIO or a file opened "
|
||||
"with mode 't'");
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
if (df_isTextMode)
|
||||
if (df_isTextMode) {
|
||||
throw ValueErrorException(
|
||||
"Need a binary mode file object like BytesIO or a file opened "
|
||||
"with mode 'b'");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw std::invalid_argument("bad mode character");
|
||||
@@ -233,7 +235,9 @@ class streambuf : public std::basic_streambuf<char> {
|
||||
|
||||
/// Mundane destructor freeing the allocated resources
|
||||
~streambuf() override {
|
||||
if (write_buffer) delete[] write_buffer;
|
||||
if (write_buffer) {
|
||||
delete[] write_buffer;
|
||||
}
|
||||
}
|
||||
|
||||
/// C.f. C++ standard section 27.5.2.4.3
|
||||
@@ -243,7 +247,9 @@ class streambuf : public std::basic_streambuf<char> {
|
||||
std::streamsize showmanyc() override {
|
||||
int_type const failure = traits_type::eof();
|
||||
int_type status = underflow();
|
||||
if (status == failure) return -1;
|
||||
if (status == failure) {
|
||||
return -1;
|
||||
}
|
||||
return egptr() - gptr();
|
||||
}
|
||||
|
||||
@@ -268,7 +274,9 @@ class streambuf : public std::basic_streambuf<char> {
|
||||
pos_of_read_buffer_end_in_py_file += n_read;
|
||||
setg(read_buffer_data, read_buffer_data, read_buffer_data + n_read);
|
||||
// ^^^27.5.2.3.1 (4)
|
||||
if (n_read == 0) return failure;
|
||||
if (n_read == 0) {
|
||||
return failure;
|
||||
}
|
||||
return traits_type::to_int_type(read_buffer_data[0]);
|
||||
}
|
||||
|
||||
@@ -335,10 +343,16 @@ class streambuf : public std::basic_streambuf<char> {
|
||||
if (farthest_pptr && farthest_pptr > pbase()) {
|
||||
off_type delta = pptr() - farthest_pptr;
|
||||
int_type status = overflow();
|
||||
if (traits_type::eq_int_type(status, traits_type::eof())) result = -1;
|
||||
if (py_seek != bp::object()) py_seek(delta, 1);
|
||||
if (traits_type::eq_int_type(status, traits_type::eof())) {
|
||||
result = -1;
|
||||
}
|
||||
if (py_seek != bp::object()) {
|
||||
py_seek(delta, 1);
|
||||
}
|
||||
} else if (gptr() && gptr() < egptr()) {
|
||||
if (py_seek != bp::object()) py_seek(gptr() - egptr(), 1);
|
||||
if (py_seek != bp::object()) {
|
||||
py_seek(gptr() - egptr(), 1);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -393,16 +407,21 @@ class streambuf : public std::basic_streambuf<char> {
|
||||
seekoff_without_calling_python(off, way, which);
|
||||
if (!result) {
|
||||
// we need to call Python
|
||||
if (which == std::ios_base::out) overflow();
|
||||
if (which == std::ios_base::out) {
|
||||
overflow();
|
||||
}
|
||||
if (way == std::ios_base::cur) {
|
||||
if (which == std::ios_base::in)
|
||||
if (which == std::ios_base::in) {
|
||||
off -= egptr() - gptr();
|
||||
else if (which == std::ios_base::out)
|
||||
} else if (which == std::ios_base::out) {
|
||||
off += pptr() - pbase();
|
||||
}
|
||||
}
|
||||
py_seek(off, whence);
|
||||
result = off_type(bp::extract<off_type>(py_tell()));
|
||||
if (which == std::ios_base::in) underflow();
|
||||
if (which == std::ios_base::in) {
|
||||
underflow();
|
||||
}
|
||||
}
|
||||
return *result;
|
||||
}
|
||||
@@ -475,13 +494,16 @@ class streambuf : public std::basic_streambuf<char> {
|
||||
}
|
||||
|
||||
// if the sought position is not in the buffer, give up
|
||||
if (buf_sought < buf_begin || buf_sought >= upper_bound) return failure;
|
||||
if (buf_sought < buf_begin || buf_sought >= upper_bound) {
|
||||
return failure;
|
||||
}
|
||||
|
||||
// we are in wonderland
|
||||
if (which == std::ios_base::in)
|
||||
if (which == std::ios_base::in) {
|
||||
gbump(buf_sought - buf_cur);
|
||||
else if (which == std::ios_base::out)
|
||||
} else if (which == std::ios_base::out) {
|
||||
pbump(buf_sought - buf_cur);
|
||||
}
|
||||
return pos_of_buffer_end_in_py_file + (buf_sought - buf_end);
|
||||
}
|
||||
|
||||
@@ -509,7 +531,9 @@ class streambuf : public std::basic_streambuf<char> {
|
||||
}
|
||||
|
||||
~ostream() override {
|
||||
if (this->good()) this->flush();
|
||||
if (this->good()) {
|
||||
this->flush();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -70,7 +70,9 @@ class RDKIT_RDGENERAL_EXPORT Dict {
|
||||
if (!preserveExisting) {
|
||||
*this = other;
|
||||
} else {
|
||||
if (other._hasNonPodData) _hasNonPodData = true;
|
||||
if (other._hasNonPodData) {
|
||||
_hasNonPodData = true;
|
||||
}
|
||||
for (size_t i = 0; i < other._data.size(); ++i) {
|
||||
const Pair &pair = other._data[i];
|
||||
Pair *target = nullptr;
|
||||
@@ -144,7 +146,9 @@ class RDKIT_RDGENERAL_EXPORT Dict {
|
||||
//! key.
|
||||
bool hasVal(const std::string &what) const {
|
||||
for (const auto &data : _data) {
|
||||
if (data.key == what) return true;
|
||||
if (data.key == what) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -304,8 +304,9 @@ struct RDValue {
|
||||
// copy act's like a move for better value semantics.
|
||||
// Containers may need to copy though.
|
||||
inline void copy_rdvalue(RDValue &dest, const RDValue &src) {
|
||||
if (&dest == &src) // don't copy over yourself
|
||||
if (&dest == &src) { // don't copy over yourself
|
||||
return;
|
||||
}
|
||||
dest.destroy();
|
||||
dest.type = src.type;
|
||||
switch (src.type) {
|
||||
@@ -349,7 +350,9 @@ template <class T>
|
||||
inline bool rdvalue_is(RDValue_cast_t v) {
|
||||
const short tag =
|
||||
RDTypeTag::GetTag<typename boost::remove_reference<T>::type>();
|
||||
if (v.getTag() == tag) return true;
|
||||
if (v.getTag() == tag) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we are an Any tag, check the any type info
|
||||
if (v.getTag() == RDTypeTag::AnyTag) {
|
||||
@@ -389,45 +392,67 @@ inline T rdvalue_cast(RDValue_cast_t v) {
|
||||
// POD casts
|
||||
template <>
|
||||
inline double rdvalue_cast<double>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<double>(v)) return v.value.d;
|
||||
if (rdvalue_is<float>(v)) return v.value.f;
|
||||
if (rdvalue_is<double>(v)) {
|
||||
return v.value.d;
|
||||
}
|
||||
if (rdvalue_is<float>(v)) {
|
||||
return v.value.f;
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline float rdvalue_cast<float>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<float>(v)) return v.value.f;
|
||||
if (rdvalue_is<double>(v)) return boost::numeric_cast<float>(v.value.d);
|
||||
if (rdvalue_is<float>(v)) {
|
||||
return v.value.f;
|
||||
}
|
||||
if (rdvalue_is<double>(v)) {
|
||||
return boost::numeric_cast<float>(v.value.d);
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline int rdvalue_cast<int>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<int>(v)) return v.value.i;
|
||||
if (rdvalue_is<unsigned int>(v)) return boost::numeric_cast<int>(v.value.u);
|
||||
if (rdvalue_is<int>(v)) {
|
||||
return v.value.i;
|
||||
}
|
||||
if (rdvalue_is<unsigned int>(v)) {
|
||||
return boost::numeric_cast<int>(v.value.u);
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::int8_t rdvalue_cast<std::int8_t>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<int>(v)) return boost::numeric_cast<std::int8_t>(v.value.i);
|
||||
if (rdvalue_is<unsigned int>(v))
|
||||
if (rdvalue_is<int>(v)) {
|
||||
return boost::numeric_cast<std::int8_t>(v.value.i);
|
||||
}
|
||||
if (rdvalue_is<unsigned int>(v)) {
|
||||
return boost::numeric_cast<std::int8_t>(v.value.u);
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::int16_t rdvalue_cast<std::int16_t>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<int>(v)) return boost::numeric_cast<std::int16_t>(v.value.i);
|
||||
if (rdvalue_is<unsigned int>(v))
|
||||
if (rdvalue_is<int>(v)) {
|
||||
return boost::numeric_cast<std::int16_t>(v.value.i);
|
||||
}
|
||||
if (rdvalue_is<unsigned int>(v)) {
|
||||
return boost::numeric_cast<std::int16_t>(v.value.u);
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::int64_t rdvalue_cast<std::int64_t>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<int>(v)) return static_cast<std::int64_t>(v.value.i);
|
||||
if (rdvalue_is<unsigned int>(v)) return static_cast<std::int64_t>(v.value.u);
|
||||
if (rdvalue_is<int>(v)) {
|
||||
return static_cast<std::int64_t>(v.value.i);
|
||||
}
|
||||
if (rdvalue_is<unsigned int>(v)) {
|
||||
return static_cast<std::int64_t>(v.value.u);
|
||||
}
|
||||
if (rdvalue_is<boost::any>(v)) {
|
||||
return boost::any_cast<std::int64_t>(*v.ptrCast<boost::any>());
|
||||
}
|
||||
@@ -436,31 +461,45 @@ inline std::int64_t rdvalue_cast<std::int64_t>(RDValue_cast_t v) {
|
||||
|
||||
template <>
|
||||
inline unsigned int rdvalue_cast<unsigned int>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<unsigned int>(v)) return v.value.u;
|
||||
if (rdvalue_is<int>(v)) return boost::numeric_cast<unsigned int>(v.value.i);
|
||||
if (rdvalue_is<unsigned int>(v)) {
|
||||
return v.value.u;
|
||||
}
|
||||
if (rdvalue_is<int>(v)) {
|
||||
return boost::numeric_cast<unsigned int>(v.value.i);
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::uint8_t rdvalue_cast<std::uint8_t>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<int>(v)) return boost::numeric_cast<std::uint8_t>(v.value.i);
|
||||
if (rdvalue_is<unsigned int>(v))
|
||||
if (rdvalue_is<int>(v)) {
|
||||
return boost::numeric_cast<std::uint8_t>(v.value.i);
|
||||
}
|
||||
if (rdvalue_is<unsigned int>(v)) {
|
||||
return boost::numeric_cast<std::uint8_t>(v.value.u);
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::uint16_t rdvalue_cast<std::uint16_t>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<int>(v)) return boost::numeric_cast<std::uint16_t>(v.value.i);
|
||||
if (rdvalue_is<unsigned int>(v))
|
||||
if (rdvalue_is<int>(v)) {
|
||||
return boost::numeric_cast<std::uint16_t>(v.value.i);
|
||||
}
|
||||
if (rdvalue_is<unsigned int>(v)) {
|
||||
return boost::numeric_cast<std::uint16_t>(v.value.u);
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::uint64_t rdvalue_cast<std::uint64_t>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<unsigned int>(v)) return static_cast<std::uint64_t>(v.value.u);
|
||||
if (rdvalue_is<int>(v)) return boost::numeric_cast<std::uint64_t>(v.value.i);
|
||||
if (rdvalue_is<unsigned int>(v)) {
|
||||
return static_cast<std::uint64_t>(v.value.u);
|
||||
}
|
||||
if (rdvalue_is<int>(v)) {
|
||||
return boost::numeric_cast<std::uint64_t>(v.value.i);
|
||||
}
|
||||
if (rdvalue_is<boost::any>(v)) {
|
||||
return boost::any_cast<std::uint64_t>(*v.ptrCast<boost::any>());
|
||||
}
|
||||
@@ -469,7 +508,9 @@ inline std::uint64_t rdvalue_cast<std::uint64_t>(RDValue_cast_t v) {
|
||||
|
||||
template <>
|
||||
inline bool rdvalue_cast<bool>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<bool>(v)) return v.value.b;
|
||||
if (rdvalue_is<bool>(v)) {
|
||||
return v.value.b;
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,88 +44,104 @@ namespace RDKit {
|
||||
// string casts
|
||||
template <>
|
||||
inline std::string rdvalue_cast<std::string>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<std::string>(v)) return *v.ptrCast<std::string>();
|
||||
if (rdvalue_is<std::string>(v)) {
|
||||
return *v.ptrCast<std::string>();
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::string &rdvalue_cast<std::string &>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<std::string>(v)) return *v.ptrCast<std::string>();
|
||||
if (rdvalue_is<std::string>(v)) {
|
||||
return *v.ptrCast<std::string>();
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
// Special Vecor Casts
|
||||
template <>
|
||||
inline std::vector<double> rdvalue_cast<std::vector<double>>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<std::vector<double>>(v))
|
||||
if (rdvalue_is<std::vector<double>>(v)) {
|
||||
return *v.ptrCast<std::vector<double>>();
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::vector<double> &rdvalue_cast<std::vector<double> &>(
|
||||
RDValue_cast_t v) {
|
||||
if (rdvalue_is<std::vector<double>>(v))
|
||||
if (rdvalue_is<std::vector<double>>(v)) {
|
||||
return *v.ptrCast<std::vector<double>>();
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::vector<float> rdvalue_cast<std::vector<float>>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<std::vector<float>>(v))
|
||||
if (rdvalue_is<std::vector<float>>(v)) {
|
||||
return *v.ptrCast<std::vector<float>>();
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::vector<float> &rdvalue_cast<std::vector<float> &>(
|
||||
RDValue_cast_t v) {
|
||||
if (rdvalue_is<std::vector<float>>(v))
|
||||
if (rdvalue_is<std::vector<float>>(v)) {
|
||||
return *v.ptrCast<std::vector<float>>();
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::vector<std::string> rdvalue_cast<std::vector<std::string>>(
|
||||
RDValue_cast_t v) {
|
||||
if (rdvalue_is<std::vector<std::string>>(v))
|
||||
if (rdvalue_is<std::vector<std::string>>(v)) {
|
||||
return *v.ptrCast<std::vector<std::string>>();
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::vector<std::string> &rdvalue_cast<std::vector<std::string> &>(
|
||||
RDValue_cast_t v) {
|
||||
if (rdvalue_is<std::vector<std::string>>(v))
|
||||
if (rdvalue_is<std::vector<std::string>>(v)) {
|
||||
return *v.ptrCast<std::vector<std::string>>();
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::vector<int> rdvalue_cast<std::vector<int>>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<std::vector<int>>(v)) return *v.ptrCast<std::vector<int>>();
|
||||
if (rdvalue_is<std::vector<int>>(v)) {
|
||||
return *v.ptrCast<std::vector<int>>();
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::vector<int> &rdvalue_cast<std::vector<int> &>(RDValue_cast_t v) {
|
||||
if (rdvalue_is<std::vector<int>>(v)) return *v.ptrCast<std::vector<int>>();
|
||||
if (rdvalue_is<std::vector<int>>(v)) {
|
||||
return *v.ptrCast<std::vector<int>>();
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::vector<unsigned int> rdvalue_cast<std::vector<unsigned int>>(
|
||||
RDValue_cast_t v) {
|
||||
if (rdvalue_is<std::vector<unsigned int>>(v))
|
||||
if (rdvalue_is<std::vector<unsigned int>>(v)) {
|
||||
return *v.ptrCast<std::vector<unsigned int>>();
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::vector<unsigned int> &rdvalue_cast<std::vector<unsigned int> &>(
|
||||
RDValue_cast_t v) {
|
||||
if (rdvalue_is<std::vector<unsigned int>>(v))
|
||||
if (rdvalue_is<std::vector<unsigned int>>(v)) {
|
||||
return *v.ptrCast<std::vector<unsigned int>>();
|
||||
}
|
||||
throw boost::bad_any_cast();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,9 @@ void rankVect(const std::vector<T1> &vect, T2 &res) {
|
||||
unsigned int nEntries = rdcast<unsigned int>(vect.size());
|
||||
|
||||
std::vector<unsigned int> indices(nEntries);
|
||||
for (unsigned int i = 0; i < nEntries; ++i) indices[i] = i;
|
||||
for (unsigned int i = 0; i < nEntries; ++i) {
|
||||
indices[i] = i;
|
||||
}
|
||||
std::sort(indices.begin(), indices.end(), argless<std::vector<T1>>(vect));
|
||||
|
||||
int currRank = 0;
|
||||
|
||||
@@ -42,7 +42,9 @@ enum EEndian {
|
||||
// parameter (could sizeof be used?).
|
||||
template <class T, unsigned int size>
|
||||
inline T SwapBytes(T value) {
|
||||
if (size < 2) return value;
|
||||
if (size < 2) {
|
||||
return value;
|
||||
}
|
||||
|
||||
union {
|
||||
T value;
|
||||
@@ -71,13 +73,17 @@ inline T EndianSwapBytes(T value) {
|
||||
// A : La donnée à swapper à une taille de 2, 4 ou 8 octets
|
||||
BOOST_STATIC_ASSERT(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 ||
|
||||
sizeof(T) == 8);
|
||||
if (sizeof(T) == 1) return value;
|
||||
if (sizeof(T) == 1) {
|
||||
return value;
|
||||
}
|
||||
|
||||
// A : La donnée à swapper est d'un type arithmetic
|
||||
// BOOST_STATIC_ASSERT(boost::is_arithmetic<T>::value);
|
||||
|
||||
// Si from et to sont du même type on ne swap pas.
|
||||
if (from == to) return value;
|
||||
if (from == to) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return SwapBytes<T, sizeof(T)>(value);
|
||||
}
|
||||
@@ -266,7 +272,9 @@ inline void streamWrite(std::ostream &ss, const std::string &what) {
|
||||
template <typename T>
|
||||
void streamWriteVec(std::ostream &ss, const T &val) {
|
||||
streamWrite(ss, static_cast<boost::uint64_t>(val.size()));
|
||||
for (size_t i = 0; i < val.size(); ++i) streamWrite(ss, val[i]);
|
||||
for (size_t i = 0; i < val.size(); ++i) {
|
||||
streamWrite(ss, val[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//! does a binary read of an object from a stream
|
||||
@@ -309,7 +317,9 @@ void streamReadVec(std::istream &ss, T &val) {
|
||||
streamRead(ss, size);
|
||||
val.resize(boost::numeric_cast<size_t>(size));
|
||||
|
||||
for (size_t i = 0; i < size; ++i) streamRead(ss, val[i]);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
streamRead(ss, val[i]);
|
||||
}
|
||||
}
|
||||
|
||||
inline void streamReadStringVec(std::istream &ss, std::vector<std::string> &val,
|
||||
@@ -318,7 +328,9 @@ inline void streamReadStringVec(std::istream &ss, std::vector<std::string> &val,
|
||||
streamRead(ss, size);
|
||||
val.resize(size);
|
||||
|
||||
for (size_t i = 0; i < size; ++i) streamRead(ss, val[i], version);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
streamRead(ss, val[i], version);
|
||||
}
|
||||
}
|
||||
|
||||
//! grabs the next line from an instream and returns it.
|
||||
|
||||
@@ -73,16 +73,18 @@ bool hanoi(int *base, int nel, int *temp, int *count, int *changed,
|
||||
if (hanoi(b1, n1, t1, count, changed, compar)) {
|
||||
if (hanoi(b2, n2, t2, count, changed, compar)) {
|
||||
s2 = t2;
|
||||
} else
|
||||
} else {
|
||||
s2 = b2;
|
||||
}
|
||||
result = false;
|
||||
ptr = base;
|
||||
s1 = t1;
|
||||
} else {
|
||||
if (hanoi(b2, n2, t2, count, changed, compar)) {
|
||||
s2 = t2;
|
||||
} else
|
||||
} else {
|
||||
s2 = b2;
|
||||
}
|
||||
result = true;
|
||||
ptr = temp;
|
||||
s1 = b1;
|
||||
@@ -103,7 +105,9 @@ bool hanoi(int *base, int nel, int *temp, int *count, int *changed,
|
||||
ptr += len1;
|
||||
n1 -= len1;
|
||||
if (n1 == 0) {
|
||||
if (ptr != s2) memmove(ptr, s2, n2 * sizeof(int));
|
||||
if (ptr != s2) {
|
||||
memmove(ptr, s2, n2 * sizeof(int));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
s1 += len1;
|
||||
@@ -122,7 +126,9 @@ bool hanoi(int *base, int nel, int *temp, int *count, int *changed,
|
||||
ptr += len1;
|
||||
n1 -= len1;
|
||||
if (n1 == 0) {
|
||||
if (ptr != s2) memmove(ptr, s2, n2 * sizeof(int));
|
||||
if (ptr != s2) {
|
||||
memmove(ptr, s2, n2 * sizeof(int));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
s1 += len1;
|
||||
@@ -147,8 +153,9 @@ void hanoisort(int *base, int nel, int *count, int *changed,
|
||||
assert(base);
|
||||
int *temp = (int *)malloc(nel * sizeof(int));
|
||||
assert(temp);
|
||||
if (hanoi(base, nel, temp, count, changed, compar))
|
||||
if (hanoi(base, nel, temp, count, changed, compar)) {
|
||||
memmove(base, temp, nel * sizeof(int));
|
||||
}
|
||||
free(temp);
|
||||
}
|
||||
} // namespace RDKit
|
||||
|
||||
@@ -86,10 +86,11 @@ RDKIT_RDGENERAL_EXPORT std::string augmentTagName(const std::string &tag);
|
||||
template <unsigned n>
|
||||
inline double int_pow(double x) {
|
||||
double half = int_pow<n / 2>(x);
|
||||
if (n % 2 == 0) // even
|
||||
if (n % 2 == 0) { // even
|
||||
return half * half;
|
||||
else
|
||||
} else {
|
||||
return half * half * x;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
|
||||
@@ -99,9 +99,12 @@ class LeaderPicker : public DistPicker {
|
||||
unsigned int pickSize, const RDKit::INT_VECT &firstPicks,
|
||||
double threshold, int nthreads) const {
|
||||
CHECK_INVARIANT(distMat, "Invalid Distance Matrix");
|
||||
if (!poolSize) throw ValueErrorException("empty pool to pick from");
|
||||
if (poolSize < pickSize)
|
||||
if (!poolSize) {
|
||||
throw ValueErrorException("empty pool to pick from");
|
||||
}
|
||||
if (poolSize < pickSize) {
|
||||
throw ValueErrorException("pickSize cannot be larger than the poolSize");
|
||||
}
|
||||
distmatFunctor functor(distMat);
|
||||
return this->lazyPick(functor, poolSize, pickSize, firstPicks, threshold,
|
||||
nthreads);
|
||||
@@ -160,7 +163,9 @@ struct LeaderPickerState {
|
||||
|
||||
LeaderPickerState(unsigned int count, int nt) {
|
||||
v.resize(count);
|
||||
for (unsigned int i = 0; i < count; i++) v[i] = i;
|
||||
for (unsigned int i = 0; i < count; i++) {
|
||||
v[i] = i;
|
||||
}
|
||||
|
||||
// InitializeBlocks
|
||||
unsigned int bcount;
|
||||
@@ -170,7 +175,9 @@ struct LeaderPickerState {
|
||||
bcount = (count + (bsize - 1)) / bsize;
|
||||
unsigned int tasks = (bcount + 1) / 2;
|
||||
// limit number of threads to available work
|
||||
if (nt > (int)tasks) nt = tasks;
|
||||
if (nt > (int)tasks) {
|
||||
nt = tasks;
|
||||
}
|
||||
} else {
|
||||
bsize = 32768;
|
||||
bcount = (count + (bsize - 1)) / bsize;
|
||||
@@ -219,16 +226,18 @@ struct LeaderPickerState {
|
||||
pthread_create(&threads[i].tid, NULL, LeaderPickerWork<T>,
|
||||
(void *)&threads[i]);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
nthreads = 1;
|
||||
}
|
||||
}
|
||||
|
||||
~LeaderPickerState() {
|
||||
if (nthreads > 1) {
|
||||
thread_op = 1;
|
||||
pthread_barrier_wait(&wait);
|
||||
for (unsigned int i = 0; i < nthreads; i++)
|
||||
for (unsigned int i = 0; i < nthreads; i++) {
|
||||
pthread_join(threads[i].tid, 0);
|
||||
}
|
||||
pthread_barrier_destroy(&wait);
|
||||
pthread_barrier_destroy(&done);
|
||||
}
|
||||
@@ -236,9 +245,13 @@ struct LeaderPickerState {
|
||||
|
||||
bool empty() {
|
||||
while (head_block) {
|
||||
if (head_block->len) return false;
|
||||
if (head_block->len) {
|
||||
return false;
|
||||
}
|
||||
unsigned int next_tick = head_block->next[tick];
|
||||
if (!next_tick) return true;
|
||||
if (!next_tick) {
|
||||
return true;
|
||||
}
|
||||
head_block = &blocks[next_tick];
|
||||
}
|
||||
return true;
|
||||
@@ -247,7 +260,9 @@ struct LeaderPickerState {
|
||||
unsigned int compact(int *dst, int *src, unsigned int len) {
|
||||
unsigned int count = 0;
|
||||
for (unsigned int i = 0; i < len; i++) {
|
||||
if ((*func)(query, src[i]) > threshold) dst[count++] = src[i];
|
||||
if ((*func)(query, src[i]) > threshold) {
|
||||
dst[count++] = src[i];
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@@ -273,16 +288,19 @@ struct LeaderPickerState {
|
||||
if (next->len) {
|
||||
list->next[tock] = next_tick;
|
||||
next->next[tock] = next_next_tick;
|
||||
} else
|
||||
} else {
|
||||
list->next[tock] = next_next_tick;
|
||||
}
|
||||
}
|
||||
cycle = nthreads - 1;
|
||||
} else
|
||||
} else {
|
||||
cycle--;
|
||||
}
|
||||
if (next_next_tick) {
|
||||
list = &blocks[next_next_tick];
|
||||
} else
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (cycle == 0) {
|
||||
list->len = compact(list->ptr, list->ptr, list->len);
|
||||
@@ -299,8 +317,9 @@ struct LeaderPickerState {
|
||||
thread_op = 0;
|
||||
pthread_barrier_wait(&wait);
|
||||
pthread_barrier_wait(&done);
|
||||
} else
|
||||
} else {
|
||||
compact_job(0);
|
||||
}
|
||||
tick ^= 1;
|
||||
}
|
||||
|
||||
@@ -319,7 +338,9 @@ void *LeaderPickerWork(void *arg) {
|
||||
|
||||
for (;;) {
|
||||
pthread_barrier_wait(&stat->wait);
|
||||
if (stat->thread_op) return (void *)0;
|
||||
if (stat->thread_op) {
|
||||
return (void *)0;
|
||||
}
|
||||
stat->compact_job(thread->id);
|
||||
pthread_barrier_wait(&stat->done);
|
||||
}
|
||||
@@ -337,7 +358,9 @@ struct LeaderPickerState {
|
||||
LeaderPickerState(unsigned int count, int)
|
||||
: left(count), threshold(0.0), query(0), func(nullptr) {
|
||||
v.resize(count);
|
||||
for (unsigned int i = 0; i < count; i++) v[i] = i;
|
||||
for (unsigned int i = 0; i < count; i++) {
|
||||
v[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
bool empty() { return left == 0; }
|
||||
@@ -347,7 +370,9 @@ struct LeaderPickerState {
|
||||
for (unsigned int i = 0; i < len; i++) {
|
||||
double ld = (*func)(query, src[i]);
|
||||
// std::cerr << query << "-" << src[i] << " " << ld << std::endl;
|
||||
if (ld > threshold) dst[count++] = src[i];
|
||||
if (ld > threshold) {
|
||||
dst[count++] = src[i];
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@@ -372,12 +397,17 @@ RDKit::INT_VECT LeaderPicker::lazyPick(T &func, unsigned int poolSize,
|
||||
unsigned int pickSize,
|
||||
const RDKit::INT_VECT &firstPicks,
|
||||
double threshold, int nthreads) const {
|
||||
if (!poolSize) throw ValueErrorException("empty pool to pick from");
|
||||
if (!poolSize) {
|
||||
throw ValueErrorException("empty pool to pick from");
|
||||
}
|
||||
|
||||
if (poolSize < pickSize)
|
||||
if (poolSize < pickSize) {
|
||||
throw ValueErrorException("pickSize cannot be larger than the poolSize");
|
||||
}
|
||||
|
||||
if (!pickSize) pickSize = poolSize;
|
||||
if (!pickSize) {
|
||||
pickSize = poolSize;
|
||||
}
|
||||
RDKit::INT_VECT picks;
|
||||
|
||||
nthreads = RDKit::getNumThreadsToUse(nthreads);
|
||||
|
||||
@@ -114,9 +114,12 @@ class RDKIT_SIMDIVPICKERS_EXPORT MaxMinPicker : public DistPicker {
|
||||
unsigned int pickSize, RDKit::INT_VECT firstPicks,
|
||||
int seed = -1) const {
|
||||
CHECK_INVARIANT(distMat, "Invalid Distance Matrix");
|
||||
if (!poolSize) throw ValueErrorException("empty pool to pick from");
|
||||
if (poolSize < pickSize)
|
||||
if (!poolSize) {
|
||||
throw ValueErrorException("empty pool to pick from");
|
||||
}
|
||||
if (poolSize < pickSize) {
|
||||
throw ValueErrorException("pickSize cannot be larger than the poolSize");
|
||||
}
|
||||
distmatFunctor functor(distMat);
|
||||
return this->lazyPick(functor, poolSize, pickSize, firstPicks, seed);
|
||||
}
|
||||
@@ -142,10 +145,13 @@ RDKit::INT_VECT MaxMinPicker::lazyPick(T &func, unsigned int poolSize,
|
||||
unsigned int pickSize,
|
||||
const RDKit::INT_VECT &firstPicks,
|
||||
int seed, double &threshold) const {
|
||||
if (!poolSize) throw ValueErrorException("empty pool to pick from");
|
||||
if (!poolSize) {
|
||||
throw ValueErrorException("empty pool to pick from");
|
||||
}
|
||||
|
||||
if (poolSize < pickSize)
|
||||
if (poolSize < pickSize) {
|
||||
throw ValueErrorException("pickSize cannot be larger than the poolSize");
|
||||
}
|
||||
|
||||
RDKit::INT_VECT picks;
|
||||
|
||||
@@ -201,11 +207,12 @@ RDKit::INT_VECT MaxMinPicker::lazyPick(T &func, unsigned int poolSize,
|
||||
unsigned int pool_list = 0;
|
||||
unsigned int *prev = &pool_list;
|
||||
// enter the pool into a list so that we can pick out of it easily
|
||||
for (unsigned int i = 0; i < poolSize; i++)
|
||||
for (unsigned int i = 0; i < poolSize; i++) {
|
||||
if (pinfo[i].picks == 0) {
|
||||
*prev = i;
|
||||
prev = &pinfo[i].next;
|
||||
}
|
||||
}
|
||||
*prev = 0;
|
||||
|
||||
unsigned int poolIdx;
|
||||
@@ -240,7 +247,9 @@ RDKit::INT_VECT MaxMinPicker::lazyPick(T &func, unsigned int poolSize,
|
||||
pi++;
|
||||
if (dist <= minTOi) {
|
||||
minTOi = dist;
|
||||
if (minTOi <= maxOFmin) break;
|
||||
if (minTOi <= maxOFmin) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
pinfo[poolIdx].dist_bound = minTOi;
|
||||
@@ -255,7 +264,9 @@ RDKit::INT_VECT MaxMinPicker::lazyPick(T &func, unsigned int poolSize,
|
||||
} while (*prev != 0);
|
||||
|
||||
// if the current distance is closer then threshold, we're done
|
||||
if (maxOFmin <= threshold && threshold >= 0.0) break;
|
||||
if (maxOFmin <= threshold && threshold >= 0.0) {
|
||||
break;
|
||||
}
|
||||
tmpThreshold = maxOFmin;
|
||||
// now add the new pick to picks and remove it from the pool
|
||||
*pick_prev = pinfo[pick].next;
|
||||
|
||||
8
External/GA/ga/LinkedPopLinearSel.h
vendored
8
External/GA/ga/LinkedPopLinearSel.h
vendored
@@ -200,7 +200,9 @@ LinkedPopLinearSel<Chromosome, PopulationPolicy>::selectParent() {
|
||||
double sum = SELECT_START, currentFitness = SELECT_START;
|
||||
auto iterator = population.begin();
|
||||
for (size_t i = 0; i < popsize; i++) {
|
||||
if (val <= sum) return iterator->second;
|
||||
if (val <= sum) {
|
||||
return iterator->second;
|
||||
}
|
||||
currentFitness += scaledFitnessStep;
|
||||
sum += currentFitness;
|
||||
++iterator;
|
||||
@@ -436,7 +438,9 @@ LinkedPopLinearSel<Chromosome, PopulationPolicy>::findExactMatch(
|
||||
for (auto iterator = iterators.first; iterator != iterators.second;
|
||||
++iterator) {
|
||||
const std::shared_ptr<Chromosome>& other = iterator->second;
|
||||
if (c.equals(*other)) return iterator;
|
||||
if (c.equals(*other)) {
|
||||
return iterator;
|
||||
}
|
||||
}
|
||||
return population.end();
|
||||
}
|
||||
|
||||
28
External/GA/ga/StringChromosome.cpp
vendored
28
External/GA/ga/StringChromosome.cpp
vendored
@@ -26,7 +26,9 @@ int StringChromosome<bool, BinaryStringChromosomePolicy>::decodeToInt(
|
||||
int mask = 1, result = 0;
|
||||
bool *ptr = string.get() + start;
|
||||
for (int i = 0; i < nBits; i++, mask <<= 1) {
|
||||
if (*ptr++ == true) result |= mask;
|
||||
if (*ptr++ == true) {
|
||||
result |= mask;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -49,13 +51,13 @@ void StringChromosome<int, IntegerStringChromosomePolicy>::fullMixing(
|
||||
int *p2 = parent2.getString();
|
||||
|
||||
for (int i = 0; i < length; i++, c1++, c2++, p1++, p2++) {
|
||||
if (*p1 == -1 && *p2 == -1)
|
||||
if (*p1 == -1 && *p2 == -1) {
|
||||
*c1 = *c2 = -1;
|
||||
else if (*p1 != -1 && *p2 == -1)
|
||||
} else if (*p1 != -1 && *p2 == -1) {
|
||||
*c1 = *c2 = *p1;
|
||||
else if (*p1 == -1 && *p2 != -1)
|
||||
} else if (*p1 == -1 && *p2 != -1) {
|
||||
*c1 = *c2 = *p2;
|
||||
else {
|
||||
} else {
|
||||
*c1 = *p1;
|
||||
*c2 = *p2;
|
||||
}
|
||||
@@ -78,7 +80,9 @@ void StringChromosome<int, IntegerStringChromosomePolicy>::fullMixingAndCrossove
|
||||
int site = getRng().randomInt(0, length);
|
||||
|
||||
bool switchFlag = false;
|
||||
if (getChromosomePolicy().isAllowSwitch()) switchFlag = getRng().randomBoolean();
|
||||
if (getChromosomePolicy().isAllowSwitch()) {
|
||||
switchFlag = getRng().randomBoolean();
|
||||
}
|
||||
|
||||
int *c1 = switchFlag ? child2.string.get() : child1.string.get();
|
||||
int *c2 = switchFlag ? child1.string.get() : child2.string.get();
|
||||
@@ -88,11 +92,11 @@ void StringChromosome<int, IntegerStringChromosomePolicy>::fullMixingAndCrossove
|
||||
// create child before cross point
|
||||
int i = 0;
|
||||
for (; i < site; i++, p1++, p2++, c1++, c2++) {
|
||||
if (*p1 == -1 && *p2 != -1)
|
||||
if (*p1 == -1 && *p2 != -1) {
|
||||
*c1 = *c2 = *p2;
|
||||
else if (*p1 != -1 && *p2 == -1)
|
||||
} else if (*p1 != -1 && *p2 == -1) {
|
||||
*c1 = *c2 = *p1;
|
||||
else {
|
||||
} else {
|
||||
*c2 = *p2;
|
||||
*c1 = *p1;
|
||||
}
|
||||
@@ -100,11 +104,11 @@ void StringChromosome<int, IntegerStringChromosomePolicy>::fullMixingAndCrossove
|
||||
|
||||
// child after cross point
|
||||
for (; i < length; i++, p1++, p2++, c1++, c2++) {
|
||||
if (*p1 == -1 && *p2 != -1)
|
||||
if (*p1 == -1 && *p2 != -1) {
|
||||
*c1 = *c2 = *p2;
|
||||
else if (*p1 != -1 && *p2 == -1)
|
||||
} else if (*p1 != -1 && *p2 == -1) {
|
||||
*c1 = *c2 = *p1;
|
||||
else {
|
||||
} else {
|
||||
*c2 = *p1;
|
||||
*c1 = *p2;
|
||||
}
|
||||
|
||||
20
External/GA/ga/StringChromosomeBase.h
vendored
20
External/GA/ga/StringChromosomeBase.h
vendored
@@ -123,7 +123,9 @@ void StringChromosomeBase<T, ChromosomePolicy>::copyGene(
|
||||
*/
|
||||
template <typename T, typename ChromosomePolicy>
|
||||
void StringChromosomeBase<T, ChromosomePolicy>::mutate(double pMutate) {
|
||||
if (pMutate < 0.0) pMutate = 1.0 / (length);
|
||||
if (pMutate < 0.0) {
|
||||
pMutate = 1.0 / (length);
|
||||
}
|
||||
bool mutated = false;
|
||||
|
||||
T *ptr = string.get();
|
||||
@@ -154,16 +156,18 @@ void StringChromosomeBase<T, ChromosomePolicy>::twoPointCrossover(
|
||||
// choose cross point sites
|
||||
int site1 = rng.randomInt(0, length);
|
||||
int site2 = rng.randomInt(0, length - 1);
|
||||
if (site2 >= site1)
|
||||
if (site2 >= site1) {
|
||||
site2++;
|
||||
else {
|
||||
} else {
|
||||
int n = site1;
|
||||
site1 = site2;
|
||||
site2 = n;
|
||||
}
|
||||
|
||||
bool switchFlag = false;
|
||||
if (chromosomePolicy.isAllowSwitch()) switchFlag = rng.randomBoolean();
|
||||
if (chromosomePolicy.isAllowSwitch()) {
|
||||
switchFlag = rng.randomBoolean();
|
||||
}
|
||||
|
||||
T *c1 = switchFlag ? child2.string.get() : child1.string.get();
|
||||
T *c2 = switchFlag ? child1.string.get() : child2.string.get();
|
||||
@@ -204,7 +208,9 @@ void StringChromosomeBase<T, ChromosomePolicy>::onePointCrossover(
|
||||
// choose cross point site
|
||||
int site = rng.randomInt(0, length - 1);
|
||||
bool switchFlag = false;
|
||||
if (chromosomePolicy.isAllowSwitch()) switchFlag = rng.randomBoolean();
|
||||
if (chromosomePolicy.isAllowSwitch()) {
|
||||
switchFlag = rng.randomBoolean();
|
||||
}
|
||||
|
||||
T *c1 = switchFlag ? child2.string.get() : child1.string.get();
|
||||
T *c2 = switchFlag ? child1.string.get() : child2.string.get();
|
||||
@@ -233,7 +239,9 @@ template <typename T, typename ChromosomePolicy>
|
||||
std::string StringChromosomeBase<T, ChromosomePolicy>::geneInfo() const {
|
||||
std::stringstream ss;
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (i > 0) ss << ' ';
|
||||
if (i > 0) {
|
||||
ss << ' ';
|
||||
}
|
||||
ss << string[i];
|
||||
}
|
||||
return ss.str();
|
||||
|
||||
16
External/GA/util/Util.cpp
vendored
16
External/GA/util/Util.cpp
vendored
@@ -33,7 +33,9 @@ string currentTime() {
|
||||
}
|
||||
|
||||
bool startsWith(string str, string prefix) {
|
||||
if (prefix.length() > str.length()) return false;
|
||||
if (prefix.length() > str.length()) {
|
||||
return false;
|
||||
}
|
||||
return str.compare(0, prefix.length(), prefix) == 0;
|
||||
}
|
||||
|
||||
@@ -44,16 +46,18 @@ string getUserName() {
|
||||
const int bufsize = 100;
|
||||
char buffer[bufsize];
|
||||
|
||||
if (!getlogin_r(buffer, bufsize))
|
||||
if (!getlogin_r(buffer, bufsize)) {
|
||||
return string(buffer);
|
||||
else
|
||||
} else {
|
||||
return string("");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
string &removeTrailingLF(string &line) {
|
||||
if (!line.empty() && line[line.length() - 1] == '\r')
|
||||
if (!line.empty() && line[line.length() - 1] == '\r') {
|
||||
line.erase(line.length() - 1);
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
@@ -81,7 +85,9 @@ bool equalsIgnoreCase(const string &str1, const string &str2) {
|
||||
}
|
||||
|
||||
bool endsWith(const string &str, const string &suffix) {
|
||||
if (suffix.length() > str.length()) return false;
|
||||
if (suffix.length() > str.length()) {
|
||||
return false;
|
||||
}
|
||||
return str.compare(str.length() - suffix.length(), string::npos, suffix) == 0;
|
||||
}
|
||||
|
||||
|
||||
35
External/GA/util/Util.h
vendored
35
External/GA/util/Util.h
vendored
@@ -65,21 +65,26 @@ namespace GarethUtil {
|
||||
template<typename T>
|
||||
T convertString(const string &str, bool *const ok =
|
||||
nullptr, size_t start = 0, size_t noChars = 0) {
|
||||
if (ok != nullptr)
|
||||
*ok = false;
|
||||
if (ok != nullptr) {
|
||||
*ok = false;
|
||||
}
|
||||
T rtn;
|
||||
if (str.empty())
|
||||
return rtn;
|
||||
if (start >= str.length())
|
||||
return rtn;
|
||||
if (noChars == 0)
|
||||
noChars = str.length() - start;
|
||||
if (str.empty()) {
|
||||
return rtn;
|
||||
}
|
||||
if (start >= str.length()) {
|
||||
return rtn;
|
||||
}
|
||||
if (noChars == 0) {
|
||||
noChars = str.length() - start;
|
||||
}
|
||||
string field = str.substr(start, noChars);
|
||||
stringstream ss(field);
|
||||
ss >> rtn;
|
||||
if (!ss.fail()) {
|
||||
if (ok != nullptr)
|
||||
*ok = true;
|
||||
if (ok != nullptr) {
|
||||
*ok = true;
|
||||
}
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
@@ -99,8 +104,9 @@ namespace GarethUtil {
|
||||
ostream_iterator<typename T::value_type>(ss, seperator.c_str()));
|
||||
// erase trailing separator
|
||||
string rtn = ss.str();
|
||||
if (!rtn.empty())
|
||||
rtn.erase(rtn.length() - seperator.length(), seperator.length());
|
||||
if (!rtn.empty()) {
|
||||
rtn.erase(rtn.length() - seperator.length(), seperator.length());
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
||||
@@ -124,8 +130,9 @@ namespace GarethUtil {
|
||||
V *const value = nullptr) {
|
||||
auto iter = map.find(key);
|
||||
if (iter != map.end()) {
|
||||
if (value != nullptr)
|
||||
*value = iter->second;
|
||||
if (value != nullptr) {
|
||||
*value = iter->second;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user