diff --git a/Code/Catalogs/CatalogEntry.cpp b/Code/Catalogs/CatalogEntry.cpp index 0cbb096b4..d90a16adf 100644 --- a/Code/Catalogs/CatalogEntry.cpp +++ b/Code/Catalogs/CatalogEntry.cpp @@ -13,4 +13,4 @@ namespace RDCatalog { CatalogEntry::~CatalogEntry() {} -} +} // namespace RDCatalog diff --git a/Code/ChemicalFeatures/FreeChemicalFeature.cpp b/Code/ChemicalFeatures/FreeChemicalFeature.cpp index d0d1da0c0..b4830600e 100644 --- a/Code/ChemicalFeatures/FreeChemicalFeature.cpp +++ b/Code/ChemicalFeatures/FreeChemicalFeature.cpp @@ -82,4 +82,4 @@ void FreeChemicalFeature::initFromString(const std::string &pickle) { streamRead(ss, d_position.y); streamRead(ss, d_position.z); }; -} +} // namespace ChemicalFeatures diff --git a/Code/ChemicalFeatures/Wrap/FreeChemicalFeature.cpp b/Code/ChemicalFeatures/Wrap/FreeChemicalFeature.cpp index b5d265609..6a27792ea 100644 --- a/Code/ChemicalFeatures/Wrap/FreeChemicalFeature.cpp +++ b/Code/ChemicalFeatures/Wrap/FreeChemicalFeature.cpp @@ -66,6 +66,6 @@ struct freefeat_wrapper { .def_pickle(chemfeat_pickle_suite()); }; }; -} +} // namespace ChemicalFeatures void wrap_freefeat() { ChemicalFeatures::freefeat_wrapper::wrap(); } diff --git a/Code/DataManip/MetricMatrixCalc/Wrap/rdMetricMatrixCalc.cpp b/Code/DataManip/MetricMatrixCalc/Wrap/rdMetricMatrixCalc.cpp index f533c196a..bfb0e8d03 100644 --- a/Code/DataManip/MetricMatrixCalc/Wrap/rdMetricMatrixCalc.cpp +++ b/Code/DataManip/MetricMatrixCalc/Wrap/rdMetricMatrixCalc.cpp @@ -159,7 +159,7 @@ PyObject *getEuclideanDistMat(python::object descripMat) { // assume that we a have a list of list of values (that can be extracted to // double) - std::vector > dData; + std::vector> dData; dData.reserve(nrows); for (unsigned int i = 0; i < nrows; i++) { // PySequenceHolder row(seq[i]); @@ -172,10 +172,11 @@ PyObject *getEuclideanDistMat(python::object descripMat) { dData.push_back(row); } - MetricMatrixCalc >, - PySequenceHolder > mmCalc; + MetricMatrixCalc>, + PySequenceHolder> + mmCalc; mmCalc.setMetricFunc(&EuclideanDistanceMetric, - PySequenceHolder >); + PySequenceHolder>); mmCalc.calcMetricMatrix(dData, nrows, ncols, dMat); } return PyArray_Return(distRes); @@ -251,7 +252,7 @@ PyObject *getTanimotoSimMat(python::object bitVectList) { } return PyArray_Return(simRes); } -} +} // namespace RDDataManip BOOST_PYTHON_MODULE(rdMetricMatrixCalc) { python::scope().attr("__doc__") = diff --git a/Code/DataStructs/BitOps.cpp b/Code/DataStructs/BitOps.cpp index 67dbe0341..821853884 100644 --- a/Code/DataStructs/BitOps.cpp +++ b/Code/DataStructs/BitOps.cpp @@ -173,10 +173,10 @@ bool AllProbeBitsMatch(const T1& probe, const std::string& pkl) { } return true; } -template RDKIT_DATASTRUCTS_EXPORT bool AllProbeBitsMatch(const SparseBitVect& bv1, - const std::string& pkl); -template RDKIT_DATASTRUCTS_EXPORT bool AllProbeBitsMatch(const ExplicitBitVect& bv1, - const std::string& pkl); +template RDKIT_DATASTRUCTS_EXPORT bool AllProbeBitsMatch( + const SparseBitVect& bv1, const std::string& pkl); +template RDKIT_DATASTRUCTS_EXPORT bool AllProbeBitsMatch( + const ExplicitBitVect& bv1, const std::string& pkl); template bool AllProbeBitsMatch(const T1& probe, const T1& ref) { for (unsigned int i = 0; i < probe.getNumBits(); ++i) { @@ -186,8 +186,8 @@ bool AllProbeBitsMatch(const T1& probe, const T1& ref) { } return true; } -template RDKIT_DATASTRUCTS_EXPORT bool AllProbeBitsMatch(const SparseBitVect& bv1, - const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT bool AllProbeBitsMatch( + const SparseBitVect& bv1, const SparseBitVect& bv2); // template bool AllProbeBitsMatch(const ExplicitBitVect& bv1,const // ExplicitBitVect &bv2); @@ -233,7 +233,7 @@ bool EBVToBitmap(const ExplicitBitVect& bv, const unsigned char*& fp, } return true; } -} // end of local namespace +} // namespace unsigned int CalcBitmapNumBitsInCommon(const unsigned char* afp, const unsigned char* bfp, @@ -771,98 +771,109 @@ void UpdateBitVectFromBinaryText(T1& bv1, const std::string& fps) { } } -template RDKIT_DATASTRUCTS_EXPORT double TanimotoSimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double TverskySimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2, double a, double b); -template RDKIT_DATASTRUCTS_EXPORT double CosineSimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double KulczynskiSimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double DiceSimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double SokalSimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double McConnaugheySimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double AsymmetricSimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double BraunBlanquetSimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double RusselSimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double RogotGoldbergSimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double OnBitSimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double TanimotoSimilarity( + const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double TverskySimilarity( + const SparseBitVect& bv1, const SparseBitVect& bv2, double a, double b); +template RDKIT_DATASTRUCTS_EXPORT double CosineSimilarity( + const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double KulczynskiSimilarity( + const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double DiceSimilarity( + const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double SokalSimilarity( + const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double McConnaugheySimilarity( + const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double AsymmetricSimilarity( + const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double BraunBlanquetSimilarity( + const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double RusselSimilarity( + const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double RogotGoldbergSimilarity( + const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double OnBitSimilarity( + const SparseBitVect& bv1, const SparseBitVect& bv2); template RDKIT_DATASTRUCTS_EXPORT int NumBitsInCommon(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double AllBitSimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT int NumOnBitsInCommon(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT IntVect OnBitsInCommon(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT IntVect OffBitsInCommon(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT DoubleVect OnBitProjSimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT DoubleVect OffBitProjSimilarity(const SparseBitVect& bv1, - const SparseBitVect& bv2); + const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double AllBitSimilarity( + const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT int NumOnBitsInCommon( + const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT IntVect +OnBitsInCommon(const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT IntVect +OffBitsInCommon(const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT DoubleVect +OnBitProjSimilarity(const SparseBitVect& bv1, const SparseBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT DoubleVect +OffBitProjSimilarity(const SparseBitVect& bv1, const SparseBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double TanimotoSimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double TverskySimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2, double a, - double b); -template RDKIT_DATASTRUCTS_EXPORT double CosineSimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double KulczynskiSimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double DiceSimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double SokalSimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double McConnaugheySimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double AsymmetricSimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double BraunBlanquetSimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double RusselSimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double RogotGoldbergSimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double OnBitSimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT int NumBitsInCommon(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT double AllBitSimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT IntVect OnBitsInCommon(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT IntVect OffBitsInCommon(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT DoubleVect OnBitProjSimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT DoubleVect OffBitProjSimilarity(const ExplicitBitVect& bv1, - const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double TanimotoSimilarity( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double TverskySimilarity( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2, double a, double b); +template RDKIT_DATASTRUCTS_EXPORT double CosineSimilarity( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double KulczynskiSimilarity( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double DiceSimilarity( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double SokalSimilarity( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double McConnaugheySimilarity( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double AsymmetricSimilarity( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double BraunBlanquetSimilarity( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double RusselSimilarity( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double RogotGoldbergSimilarity( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double OnBitSimilarity( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT int NumBitsInCommon( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT double AllBitSimilarity( + const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT IntVect +OnBitsInCommon(const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT IntVect +OffBitsInCommon(const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT DoubleVect +OnBitProjSimilarity(const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); +template RDKIT_DATASTRUCTS_EXPORT DoubleVect +OffBitProjSimilarity(const ExplicitBitVect& bv1, const ExplicitBitVect& bv2); -template RDKIT_DATASTRUCTS_EXPORT SparseBitVect* FoldFingerprint(const SparseBitVect&, unsigned int); -template RDKIT_DATASTRUCTS_EXPORT ExplicitBitVect* FoldFingerprint(const ExplicitBitVect&, unsigned int); +template RDKIT_DATASTRUCTS_EXPORT SparseBitVect* FoldFingerprint( + const SparseBitVect&, unsigned int); +template RDKIT_DATASTRUCTS_EXPORT ExplicitBitVect* FoldFingerprint( + const ExplicitBitVect&, unsigned int); -template RDKIT_DATASTRUCTS_EXPORT std::string BitVectToText(const SparseBitVect&); -template RDKIT_DATASTRUCTS_EXPORT std::string BitVectToText(const ExplicitBitVect&); +template RDKIT_DATASTRUCTS_EXPORT std::string BitVectToText( + const SparseBitVect&); +template RDKIT_DATASTRUCTS_EXPORT std::string BitVectToText( + const ExplicitBitVect&); -template RDKIT_DATASTRUCTS_EXPORT std::string BitVectToFPSText(const SparseBitVect&); -template RDKIT_DATASTRUCTS_EXPORT std::string BitVectToFPSText(const ExplicitBitVect&); -template RDKIT_DATASTRUCTS_EXPORT void UpdateBitVectFromFPSText(SparseBitVect&, const std::string&); -template RDKIT_DATASTRUCTS_EXPORT void UpdateBitVectFromFPSText(ExplicitBitVect&, const std::string&); +template RDKIT_DATASTRUCTS_EXPORT std::string BitVectToFPSText( + const SparseBitVect&); +template RDKIT_DATASTRUCTS_EXPORT std::string BitVectToFPSText( + const ExplicitBitVect&); +template RDKIT_DATASTRUCTS_EXPORT void UpdateBitVectFromFPSText( + SparseBitVect&, const std::string&); +template RDKIT_DATASTRUCTS_EXPORT void UpdateBitVectFromFPSText( + ExplicitBitVect&, const std::string&); -template RDKIT_DATASTRUCTS_EXPORT std::string BitVectToBinaryText(const SparseBitVect&); -template RDKIT_DATASTRUCTS_EXPORT std::string BitVectToBinaryText(const ExplicitBitVect&); -template RDKIT_DATASTRUCTS_EXPORT void UpdateBitVectFromBinaryText(SparseBitVect&, const std::string&); -template RDKIT_DATASTRUCTS_EXPORT void UpdateBitVectFromBinaryText(ExplicitBitVect&, const std::string&); +template RDKIT_DATASTRUCTS_EXPORT std::string BitVectToBinaryText( + const SparseBitVect&); +template RDKIT_DATASTRUCTS_EXPORT std::string BitVectToBinaryText( + const ExplicitBitVect&); +template RDKIT_DATASTRUCTS_EXPORT void UpdateBitVectFromBinaryText( + SparseBitVect&, const std::string&); +template RDKIT_DATASTRUCTS_EXPORT void UpdateBitVectFromBinaryText( + ExplicitBitVect&, const std::string&); // from here: // http://stackoverflow.com/questions/3849337/msvc-equivalent-to-builtin-popcount diff --git a/Code/DataStructs/DiscreteDistMat.cpp b/Code/DataStructs/DiscreteDistMat.cpp index b7c6c10db..a90344d99 100644 --- a/Code/DataStructs/DiscreteDistMat.cpp +++ b/Code/DataStructs/DiscreteDistMat.cpp @@ -87,4 +87,4 @@ unsigned int DiscreteDistMat::getDist( static DiscreteDistMat discreteDMat; DiscreteDistMat *getDiscreteDistMat() { return &discreteDMat; } -} +} // namespace RDKit diff --git a/Code/DataStructs/FPBReader.cpp b/Code/DataStructs/FPBReader.cpp index d276bb069..58d06de18 100644 --- a/Code/DataStructs/FPBReader.cpp +++ b/Code/DataStructs/FPBReader.cpp @@ -72,7 +72,7 @@ void extractPopCounts(FPBReader_impl *dp_impl, boost::uint64_t sz, PRECONDITION(dp_impl, "bad pointer"); /* this section of the FPB format is under-documented in Andrew's code, * fortunately it looks pretty simple - */ + */ if (sz % 4) { throw ValueErrorException("POPC chunk size must be a multiple of 4 bytes"); } @@ -202,8 +202,8 @@ boost::uint8_t *copyBytes(const FPBReader_impl *dp_impl, unsigned int which) { }; // caller is responsible for delete'ing the result -RDKIT_DATASTRUCTS_EXPORT boost::dynamic_bitset<> *bytesToBitset(const boost::uint8_t *fpData, - boost::uint32_t nBits) { +RDKIT_DATASTRUCTS_EXPORT boost::dynamic_bitset<> *bytesToBitset( + const boost::uint8_t *fpData, boost::uint32_t nBits) { unsigned int nBytes = nBits / 8; if (!(nBytes % sizeof(boost::dynamic_bitset<>::block_type))) { // I believe this could be faster (needs to be verified of course) @@ -218,7 +218,8 @@ RDKIT_DATASTRUCTS_EXPORT boost::dynamic_bitset<> *bytesToBitset(const boost::uin } // caller is responsible for delete []'ing the result -RDKIT_DATASTRUCTS_EXPORT boost::uint8_t *bitsetToBytes(const boost::dynamic_bitset<> &bitset) { +RDKIT_DATASTRUCTS_EXPORT boost::uint8_t *bitsetToBytes( + const boost::dynamic_bitset<> &bitset) { unsigned int nBits = bitset.size(); unsigned int nBytes = nBits / 8; @@ -425,7 +426,7 @@ std::string extractId(const FPBReader_impl *dp_impl, unsigned int which) { void tanimotoNeighbors(const FPBReader_impl *dp_impl, const boost::uint8_t *bv, double threshold, - std::vector > &res, + std::vector> &res, bool usePopcountScreen, unsigned int readCache = 1000) { PRECONDITION(dp_impl, "bad reader pointer"); PRECONDITION(bv, "bad bv"); @@ -481,7 +482,7 @@ void tanimotoNeighbors(const FPBReader_impl *dp_impl, const boost::uint8_t *bv, void tverskyNeighbors(const FPBReader_impl *dp_impl, const boost::uint8_t *bv, double ca, double cb, double threshold, - std::vector > &res, + std::vector> &res, bool usePopcountScreen) { PRECONDITION(dp_impl, "bad reader pointer"); PRECONDITION(bv, "bad bv"); @@ -562,7 +563,7 @@ void containingNeighbors(const FPBReader_impl *dp_impl, } } -} // end of detail namespace +} // namespace detail void FPBReader::init() { PRECONDITION(dp_istrm, "no stream"); @@ -607,8 +608,8 @@ void FPBReader::init() { } else if (chunkNm == "HASH") { // currently ignored } else { - BOOST_LOG(rdWarningLog) << "Unknown chunk: " << chunkNm << " ignored." - << std::endl; + BOOST_LOG(rdWarningLog) + << "Unknown chunk: " << chunkNm << " ignored." << std::endl; } delete[] chunk; } else { @@ -702,21 +703,21 @@ double FPBReader::getTanimoto(unsigned int idx, return res; } -std::vector > FPBReader::getTanimotoNeighbors( +std::vector> FPBReader::getTanimotoNeighbors( const boost::uint8_t *bv, double threshold, bool usePopcountScreen) const { PRECONDITION(df_init, "not initialized"); - std::vector > res; + std::vector> res; detail::tanimotoNeighbors(dp_impl, bv, threshold, res, usePopcountScreen); std::sort(res.begin(), res.end(), Rankers::pairGreater()); return res; } -std::vector > FPBReader::getTanimotoNeighbors( +std::vector> FPBReader::getTanimotoNeighbors( const ExplicitBitVect &ebv, double threshold, bool usePopcountScreen) const { const boost::uint8_t *bv = detail::bitsetToBytes(*(ebv.dp_bits)); - std::vector > res = + std::vector> res = getTanimotoNeighbors(bv, threshold, usePopcountScreen); delete[] bv; return res; @@ -735,11 +736,11 @@ double FPBReader::getTversky(unsigned int idx, const ExplicitBitVect &ebv, return res; } -std::vector > FPBReader::getTverskyNeighbors( +std::vector> FPBReader::getTverskyNeighbors( const boost::uint8_t *bv, double ca, double cb, double threshold, bool usePopcountScreen) const { PRECONDITION(df_init, "not initialized"); - std::vector > res; + std::vector> res; detail::tverskyNeighbors(dp_impl, bv, ca, cb, threshold, res, usePopcountScreen); std::sort(res.begin(), res.end(), @@ -747,11 +748,11 @@ std::vector > FPBReader::getTverskyNeighbors( return res; } -std::vector > FPBReader::getTverskyNeighbors( +std::vector> FPBReader::getTverskyNeighbors( const ExplicitBitVect &ebv, double ca, double cb, double threshold, bool usePopcountScreen) const { const boost::uint8_t *bv = detail::bitsetToBytes(*(ebv.dp_bits)); - std::vector > res = + std::vector> res = getTverskyNeighbors(bv, ca, cb, threshold, usePopcountScreen); delete[] bv; return res; @@ -775,4 +776,4 @@ std::vector FPBReader::getContainingNeighbors( return res; } -} // end of RDKit namespace +} // namespace RDKit diff --git a/Code/DataStructs/Utils.cpp b/Code/DataStructs/Utils.cpp index 333fb668b..f867d5f9f 100644 --- a/Code/DataStructs/Utils.cpp +++ b/Code/DataStructs/Utils.cpp @@ -73,8 +73,10 @@ void FromDaylightString(T &sbv, const std::string &s) { } } -template RDKIT_DATASTRUCTS_EXPORT void FromDaylightString(SparseBitVect &sbv, const std::string &s); -template RDKIT_DATASTRUCTS_EXPORT void FromDaylightString(ExplicitBitVect &sbv, const std::string &s); +template RDKIT_DATASTRUCTS_EXPORT void FromDaylightString(SparseBitVect &sbv, + const std::string &s); +template RDKIT_DATASTRUCTS_EXPORT void FromDaylightString(ExplicitBitVect &sbv, + const std::string &s); //! \brief Construct a BitVect from the ASCII representation of a //! BitString @@ -89,8 +91,10 @@ void FromBitString(T &sbv, const std::string &s) { } } -template RDKIT_DATASTRUCTS_EXPORT void FromBitString(SparseBitVect &sbv, const std::string &s); -template RDKIT_DATASTRUCTS_EXPORT void FromBitString(ExplicitBitVect &sbv, const std::string &s); +template RDKIT_DATASTRUCTS_EXPORT void FromBitString(SparseBitVect &sbv, + const std::string &s); +template RDKIT_DATASTRUCTS_EXPORT void FromBitString(ExplicitBitVect &sbv, + const std::string &s); //! converts 4 ascii bytes at a4 to 3 binary bytes /*! diff --git a/Code/DataStructs/Wrap/SparseIntVect.cpp b/Code/DataStructs/Wrap/SparseIntVect.cpp index a70abe0d6..ece074f67 100644 --- a/Code/DataStructs/Wrap/SparseIntVect.cpp +++ b/Code/DataStructs/Wrap/SparseIntVect.cpp @@ -62,7 +62,7 @@ python::list pyToList(SparseIntVect &vect) { python::list res; res.append(0); res *= vect.getLength(); - for(auto iter: vect.getNonzeroElements()) { + for (auto iter : vect.getNonzeroElements()) { res[iter.first] = iter.second; } return res; @@ -179,7 +179,7 @@ struct sparseIntVec_wrapper { .def("GetNonzeroElements", &pyGetNonzeroElements, "returns a dictionary of the nonzero elements") .def("ToList", pyToList, - "Return the SparseIntVect as a python list") + "Return the SparseIntVect as a python list") .def_pickle(siv_pickle_suite()); python::def( diff --git a/Code/DataStructs/Wrap/wrap_FPB.cpp b/Code/DataStructs/Wrap/wrap_FPB.cpp index 82e67c67d..906296f95 100644 --- a/Code/DataStructs/Wrap/wrap_FPB.cpp +++ b/Code/DataStructs/Wrap/wrap_FPB.cpp @@ -110,7 +110,7 @@ double getTverskyHelper(const FPBReader *self, unsigned int which, const auto *bv = reinterpret_cast(bytes.c_str()); return self->getTversky(which, bv, ca, cb); } -} +} // namespace struct FPB_wrapper { static void wrap() { diff --git a/Code/DataStructs/Wrap/wrap_SparseBV.cpp b/Code/DataStructs/Wrap/wrap_SparseBV.cpp index 0aa599c71..91870e5c2 100644 --- a/Code/DataStructs/Wrap/wrap_SparseBV.cpp +++ b/Code/DataStructs/Wrap/wrap_SparseBV.cpp @@ -26,16 +26,16 @@ struct sbv_pickle_suite : python::pickle_suite { }; }; -python::list SparseToList(const SparseBitVect& sv) { - python::list l; - if(sv.getNumBits()) { - l.append(0); - l *= sv.getNumBits(); - for(int i: *sv.getBitSet()) { - l[i] = 1; - } - } - return l; +python::list SparseToList(const SparseBitVect &sv) { + python::list l; + if (sv.getNumBits()) { + l.append(0); + l *= sv.getNumBits(); + for (int i : *sv.getBitSet()) { + l[i] = 1; + } + } + return l; } std::string sbvClassDoc = @@ -96,7 +96,7 @@ struct SBV_wrapper { .def("ToBase64", (std::string(*)(SBV &))ToBase64, "Converts the vector to a base64 string (the base64 encoded " "version of the results of ToString()).\n") - .def("ToList", (python::list (*)(const SBV&))SparseToList, + .def("ToList", (python::list(*)(const SBV &))SparseToList, "Return the BitVector as a python list") .def(python::self & python::self) .def(python::self | python::self) diff --git a/Code/DataStructs/testFPB.cpp b/Code/DataStructs/testFPB.cpp index ab3bc28c4..44cf750fe 100644 --- a/Code/DataStructs/testFPB.cpp +++ b/Code/DataStructs/testFPB.cpp @@ -149,7 +149,7 @@ void test3FPBReaderTanimotoNeighbors() { { boost::shared_array bytes = fps.getBytes(0); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = fps.getTanimotoNeighbors(bytes); TEST_ASSERT(nbrs.size() == 1); TEST_ASSERT(feq(nbrs[0].first, 1.)); @@ -158,7 +158,7 @@ void test3FPBReaderTanimotoNeighbors() { { // with a threshold boost::shared_array bytes = fps.getBytes(0); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = fps.getTanimotoNeighbors(bytes, 0.30); TEST_ASSERT(nbrs.size() == 5); TEST_ASSERT(feq(nbrs[0].first, 1.)); @@ -169,7 +169,7 @@ void test3FPBReaderTanimotoNeighbors() { { // with a threshold, no screen boost::shared_array bytes = fps.getBytes(0); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = fps.getTanimotoNeighbors(bytes, 0.30, false); TEST_ASSERT(nbrs.size() == 5); TEST_ASSERT(feq(nbrs[0].first, 1.)); @@ -180,7 +180,7 @@ void test3FPBReaderTanimotoNeighbors() { { // with a threshold boost::shared_array bytes = fps.getBytes(95); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = fps.getTanimotoNeighbors(bytes, 0.30); TEST_ASSERT(nbrs.size() == 2); TEST_ASSERT(feq(nbrs[0].first, 1.)); @@ -310,7 +310,7 @@ void test6LazyFPBReaderTanimotoNeighbors() { { boost::shared_array bytes = fps.getBytes(0); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = fps.getTanimotoNeighbors(bytes); TEST_ASSERT(nbrs.size() == 1); TEST_ASSERT(feq(nbrs[0].first, 1.)); @@ -319,7 +319,7 @@ void test6LazyFPBReaderTanimotoNeighbors() { { // with a threshold boost::shared_array bytes = fps.getBytes(0); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = fps.getTanimotoNeighbors(bytes, 0.30); TEST_ASSERT(nbrs.size() == 5); TEST_ASSERT(feq(nbrs[0].first, 1.)); @@ -330,7 +330,7 @@ void test6LazyFPBReaderTanimotoNeighbors() { { // with a threshold boost::shared_array bytes = fps.getBytes(95); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = fps.getTanimotoNeighbors(bytes, 0.30); TEST_ASSERT(nbrs.size() == 2); TEST_ASSERT(feq(nbrs[0].first, 1.)); @@ -341,7 +341,7 @@ void test6LazyFPBReaderTanimotoNeighbors() { { // ebv with a threshold boost::shared_ptr ebv = fps.getFP(95); TEST_ASSERT(ebv); - std::vector > nbrs = + std::vector> nbrs = fps.getTanimotoNeighbors(*ebv.get(), 0.30); TEST_ASSERT(nbrs.size() == 2); TEST_ASSERT(feq(nbrs[0].first, 1.)); @@ -361,8 +361,8 @@ namespace detail { boost::dynamic_bitset<> *bytesToBitset(const std::uint8_t *fpData, std::uint32_t nBits); std::uint8_t *bitsetToBytes(const boost::dynamic_bitset<> &bitset); -} -} +} // namespace detail +} // namespace RDKit void test7BitsetDetails() { BOOST_LOG(rdInfoLog) << "-----------------------\n Testing some internal bitset details" @@ -509,7 +509,7 @@ void test10FPBReaderTverskyNeighbors() { { boost::shared_array bytes = fps.getBytes(0); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = fps.getTverskyNeighbors(bytes, 1., 1.); TEST_ASSERT(nbrs.size() == 1); TEST_ASSERT(feq(nbrs[0].first, 1.)); @@ -518,7 +518,7 @@ void test10FPBReaderTverskyNeighbors() { { // with a threshold boost::shared_array bytes = fps.getBytes(0); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = fps.getTverskyNeighbors(bytes, 1., 1., 0.3); TEST_ASSERT(nbrs.size() == 5); TEST_ASSERT(feq(nbrs[0].first, 1.)); @@ -529,7 +529,7 @@ void test10FPBReaderTverskyNeighbors() { { // with a threshold, asymmetric boost::shared_array bytes = fps.getBytes(0); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = fps.getTverskyNeighbors(bytes, 1., 0.5, 0.3); TEST_ASSERT(nbrs.size() == 5); TEST_ASSERT(feq(nbrs[0].first, 1.)); @@ -540,7 +540,7 @@ void test10FPBReaderTverskyNeighbors() { { // with a threshold, no screen boost::shared_array bytes = fps.getBytes(0); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = fps.getTverskyNeighbors(bytes, 1., 1., 0.3, false); TEST_ASSERT(nbrs.size() == 5); TEST_ASSERT(feq(nbrs[0].first, 1.)); @@ -551,7 +551,7 @@ void test10FPBReaderTverskyNeighbors() { { // with a threshold, asymmetric, no screen boost::shared_array bytes = fps.getBytes(0); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = fps.getTverskyNeighbors(bytes, 1., 0.5, 0.3, false); TEST_ASSERT(nbrs.size() == 5); TEST_ASSERT(feq(nbrs[0].first, 1.)); diff --git a/Code/DataStructs/testMultiFPB.cpp b/Code/DataStructs/testMultiFPB.cpp index 420910664..d8a44b310 100644 --- a/Code/DataStructs/testMultiFPB.cpp +++ b/Code/DataStructs/testMultiFPB.cpp @@ -70,8 +70,7 @@ void test2MultiFPBReaderTanimoto() { TEST_ASSERT(mfps.length() == 2); { - boost::shared_array bytes = - mfps.getReader(0)->getBytes(0); + boost::shared_array bytes = mfps.getReader(0)->getBytes(0); TEST_ASSERT(bytes); std::vector nbrs = mfps.getTanimotoNeighbors(bytes); @@ -84,8 +83,7 @@ void test2MultiFPBReaderTanimoto() { TEST_ASSERT(nbrs[1].get<2>() == 1); } { // with a threshold - boost::shared_array bytes = - mfps.getReader(0)->getBytes(0); + boost::shared_array bytes = mfps.getReader(0)->getBytes(0); TEST_ASSERT(bytes); std::vector nbrs = mfps.getTanimotoNeighbors(bytes, 0.30); @@ -101,8 +99,7 @@ void test2MultiFPBReaderTanimoto() { TEST_ASSERT(nbrs[2].get<2>() == 0); } { // with a threshold - boost::shared_array bytes = - mfps.getReader(0)->getBytes(95); + boost::shared_array bytes = mfps.getReader(0)->getBytes(95); TEST_ASSERT(bytes); std::vector nbrs = mfps.getTanimotoNeighbors(bytes, 0.30); @@ -138,8 +135,7 @@ void test3MultiFPBReaderTversky() { TEST_ASSERT(mfps.length() == 2); { - boost::shared_array bytes = - mfps.getReader(0)->getBytes(0); + boost::shared_array bytes = mfps.getReader(0)->getBytes(0); TEST_ASSERT(bytes); std::vector nbrs = mfps.getTverskyNeighbors(bytes, 1., 1.); @@ -152,8 +148,7 @@ void test3MultiFPBReaderTversky() { TEST_ASSERT(nbrs[1].get<2>() == 1); } { // with a threshold - boost::shared_array bytes = - mfps.getReader(0)->getBytes(0); + boost::shared_array bytes = mfps.getReader(0)->getBytes(0); TEST_ASSERT(bytes); std::vector nbrs = mfps.getTverskyNeighbors(bytes, 1., 1., 0.30); @@ -169,8 +164,7 @@ void test3MultiFPBReaderTversky() { TEST_ASSERT(nbrs[2].get<2>() == 0); } { // with a threshold, asymmetric - boost::shared_array bytes = - mfps.getReader(0)->getBytes(0); + boost::shared_array bytes = mfps.getReader(0)->getBytes(0); TEST_ASSERT(bytes); std::vector nbrs = mfps.getTverskyNeighbors(bytes, 1., 0.5, 0.30); @@ -205,10 +199,9 @@ void test4MultiFPBReaderContains() { mfps.init(); TEST_ASSERT(mfps.length() == 2); { - boost::shared_array bytes = - mfps.getReader(0)->getBytes(0); + boost::shared_array bytes = mfps.getReader(0)->getBytes(0); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = mfps.getContainingNeighbors(bytes); TEST_ASSERT(nbrs.size() == 2); TEST_ASSERT(nbrs[0].first == 0); @@ -217,10 +210,9 @@ void test4MultiFPBReaderContains() { TEST_ASSERT(nbrs[1].second == 1); } { - boost::shared_array bytes = - mfps.getReader(0)->getBytes(1); + boost::shared_array bytes = mfps.getReader(0)->getBytes(1); TEST_ASSERT(bytes); - std::vector > nbrs = + std::vector> nbrs = mfps.getContainingNeighbors(bytes); TEST_ASSERT(nbrs.size() == 8); TEST_ASSERT(nbrs[0].first == 1); @@ -376,7 +368,7 @@ void test6MultiFPBReaderContainsThreaded() { UpdateBitVectFromFPSText(qbv, fps); { - std::vector > nbrs = + std::vector> nbrs = mfps.getContainingNeighbors(qbv); TEST_ASSERT(nbrs.size() == 9); // for (unsigned int i = 0; i < nbrs.size(); ++i) { @@ -404,7 +396,7 @@ void test6MultiFPBReaderContainsThreaded() { } #ifdef RDK_TEST_MULTITHREADED { - std::vector > nbrs = + std::vector> nbrs = mfps.getContainingNeighbors(qbv, 4); TEST_ASSERT(nbrs.size() == 9); // for (unsigned int i = 0; i < nbrs.size(); ++i) { @@ -431,7 +423,7 @@ void test6MultiFPBReaderContainsThreaded() { TEST_ASSERT(nbrs[8].second == 0); } { // request more threads than we have readers, this shouldn't be a problem - std::vector > nbrs = + std::vector> nbrs = mfps.getContainingNeighbors(qbv, 8); TEST_ASSERT(nbrs.size() == 9); // for (unsigned int i = 0; i < nbrs.size(); ++i) { @@ -481,7 +473,7 @@ void test6MultiFPBReaderContainsThreaded() { UpdateBitVectFromFPSText(qbv, fps); #ifndef RDK_TEST_MULTITHREADED { - std::vector > nbrs = + std::vector> nbrs = mfps.getContainingNeighbors(qbv); TEST_ASSERT(nbrs.size() == 9); // for (unsigned int i = 0; i < nbrs.size(); ++i) { @@ -509,7 +501,7 @@ void test6MultiFPBReaderContainsThreaded() { } #else { - std::vector > nbrs = + std::vector> nbrs = mfps.getContainingNeighbors(qbv, 4); TEST_ASSERT(nbrs.size() == 9); // for (unsigned int i = 0; i < nbrs.size(); ++i) { @@ -558,7 +550,7 @@ void test7MultiFPBReaderEdges() { ExplicitBitVect qbv(1024); UpdateBitVectFromFPSText(qbv, fps); { - std::vector > nbrs = + std::vector> nbrs = mfps.getContainingNeighbors(qbv); TEST_ASSERT(nbrs.size() == 0); } diff --git a/Code/Demos/RDKit/Basement/BinaryIO/iotest.cpp b/Code/Demos/RDKit/Basement/BinaryIO/iotest.cpp index 32cfbbced..327424b90 100644 --- a/Code/Demos/RDKit/Basement/BinaryIO/iotest.cpp +++ b/Code/Demos/RDKit/Basement/BinaryIO/iotest.cpp @@ -205,7 +205,8 @@ void test3() { void test4() { #ifdef SUPPORT_COMPRESSED_IO BOOST_LOG(rdInfoLog) << "testing writing pickles to a single compressed file " - "then reading them back" << std::endl; + "then reading them back" + << std::endl; std::string rdbase = getenv("RDBASE"); std::string fname2 = rdbase + "/Code/Demos/RDKit/BinaryIO/test_data/mols.rdz"; @@ -307,7 +308,8 @@ void test4() { void test5() { #ifdef SUPPORT_COMPRESSED_IO BOOST_LOG(rdInfoLog) << "testing writing compressed pickles to a single file " - "then reading them back" << std::endl; + "then reading them back" + << std::endl; std::string rdbase = getenv("RDBASE"); std::string fname2 = rdbase + "/Code/Demos/RDKit/BinaryIO/test_data/tmp.rdz"; diff --git a/Code/Demos/RDKit/Basement/TemplEnum/TemplEnumTools.cpp b/Code/Demos/RDKit/Basement/TemplEnum/TemplEnumTools.cpp index 2e42edff3..b217efbf9 100644 --- a/Code/Demos/RDKit/Basement/TemplEnum/TemplEnumTools.cpp +++ b/Code/Demos/RDKit/Basement/TemplEnum/TemplEnumTools.cpp @@ -419,4 +419,4 @@ RWMOL_SPTR_VECT enumFromFiles(const char *templateName, return library; } -} // end of TemplateEnum namespace +} // namespace TemplateEnum diff --git a/Code/Demos/RDKit/Basement/xpcom/RDKitImpl.cpp b/Code/Demos/RDKit/Basement/xpcom/RDKitImpl.cpp index 655bc7c4c..cbf337308 100644 --- a/Code/Demos/RDKit/Basement/xpcom/RDKitImpl.cpp +++ b/Code/Demos/RDKit/Basement/xpcom/RDKitImpl.cpp @@ -10,9 +10,11 @@ /* Implementation file */ NS_IMPL_ISUPPORTS1(RDKitImpl, IRDKit) -RDKitImpl::RDKitImpl() { /* member initializers and constructor code */ } +RDKitImpl::RDKitImpl() { /* member initializers and constructor code */ +} -RDKitImpl::~RDKitImpl() { /* destructor code */ } +RDKitImpl::~RDKitImpl() { /* destructor code */ +} /* unsigned long strlen (in string arg); */ NS_IMETHODIMP RDKitImpl::Strlen(const char *arg, PRUint32 *_retval) { diff --git a/Code/Demos/RDKit/Draw/qtDemo/RDKitMolToQPainter.cc b/Code/Demos/RDKit/Draw/qtDemo/RDKitMolToQPainter.cc index 2dcf59e57..ce669b9b5 100644 --- a/Code/Demos/RDKit/Draw/qtDemo/RDKitMolToQPainter.cc +++ b/Code/Demos/RDKit/Draw/qtDemo/RDKitMolToQPainter.cc @@ -20,7 +20,7 @@ #include #include #include -#include // this is what does the 2D drawing! +#include // this is what does the 2D drawing! #include #include @@ -41,67 +41,72 @@ using namespace RDKit; typedef scoped_ptr pRWMol; static const int LINE_WIDTH_MULT = 4; -static const float ORIGINAL_FONT_SIZE = 35.0; // this size seems to work well with the relative scale of the Drawing +// this size seems to work well with the relative scale of the Drawing +static const float ORIGINAL_FONT_SIZE = 35.0; // **************************************************************************** -QColor &colour_for_atomic_num( int atnum ) { +QColor &colour_for_atomic_num(int atnum) { + static QColor colours[10] = { + QColor("Black"), QColor("Blue"), QColor("Red"), QColor("LightGreen"), + QColor("Orange"), QColor("Yellow"), QColor("Green"), QColor("Brown"), + QColor("Purple"), QColor("Cyan")}; - static QColor colours[10] = { QColor( "Black" ) , QColor( "Blue" ) , - QColor( "Red" ) , QColor( "LightGreen" ) , - QColor( "Orange" ) , QColor( "Yellow" ) , - QColor( "Green" ) , QColor( "Brown" ) , - QColor( "Purple" ) , QColor( "Cyan" ) }; - - switch( atnum ) { - case 6 : return colours[0]; - case 7 : return colours[1]; - case 8 : return colours[2]; - case 9 : return colours[3]; - case 15 : return colours[4]; - case 16 : return colours[5]; - case 17 : return colours[6]; - case 37 : return colours[7]; - case 53 : return colours[8]; - default : return colours[9]; + switch (atnum) { + case 6: + return colours[0]; + case 7: + return colours[1]; + case 8: + return colours[2]; + case 9: + return colours[3]; + case 15: + return colours[4]; + case 16: + return colours[5]; + case 17: + return colours[6]; + case 37: + return colours[7]; + case 53: + return colours[8]; + default: + return colours[9]; } - } #ifdef NOTYET // **************************************************************************** -string colour_for_atomic_num( int atnum ) { - - static map colours; - if( colours.empty() ) { - colours.insert( make_pair( 6 , "Black" ) ); //carbon - colours.insert( make_pair( 7 , "Blue" ) ); // nitrogen - colours.insert( make_pair( 8 , "Red" ) ); // oxygen - colours.insert( make_pair( 9 , "LightGreen" ) ); // fluorine - colours.insert( make_pair( 15 , "Orange" ) ); // phosphorous - colours.insert( make_pair( 16 , "Yellow" ) ); // sulfur - colours.insert( make_pair( 17 , "Green" ) ); // chlorine - colours.insert( make_pair( 37 , "Brown" ) ); // bromine - colours.insert( make_pair( 53 , "Purple" ) ); // iodine +string colour_for_atomic_num(int atnum) { + static map colours; + if (colours.empty()) { + colours.insert(make_pair(6, "Black")); // carbon + colours.insert(make_pair(7, "Blue")); // nitrogen + colours.insert(make_pair(8, "Red")); // oxygen + colours.insert(make_pair(9, "LightGreen")); // fluorine + colours.insert(make_pair(15, "Orange")); // phosphorous + colours.insert(make_pair(16, "Yellow")); // sulfur + colours.insert(make_pair(17, "Green")); // chlorine + colours.insert(make_pair(37, "Brown")); // bromine + colours.insert(make_pair(53, "Purple")); // iodine } - map::iterator q = colours.find( atnum ); - if( q == colours.end() ) { + map::iterator q = colours.find(atnum); + if (q == colours.end()) { return "Cyan"; } else { return q->second; } - } #endif // **************************************************************************** -void get_scale( int width , int height , int qp_width , int qp_height , - qreal &gscale ) { +void get_scale(int width, int height, int qp_width, int qp_height, + qreal &gscale) { + qreal xscale = qreal(qp_width) / qreal(width); + qreal yscale = qreal(qp_height) / qreal(height); - qreal xscale = qreal( qp_width ) / qreal( width ); - qreal yscale = qreal( qp_height ) / qreal( height ); - - gscale = std::min( xscale , yscale ); + gscale = std::min(xscale, yscale); #ifdef NOTYET cout << "Scale for picture " << width << " by " << height << endl @@ -109,41 +114,35 @@ void get_scale( int width , int height , int qp_width , int qp_height , << "x and y scales : " << xscale << " , " << yscale << endl; cout << "Final scale : " << gscale << endl; #endif - } // **************************************************************************** -void set_scale( int width , int height , int min_x , int min_y , - int qp_width , int qp_height , - QPainter &qp , qreal &gscale ) { - - qp.scale( gscale , gscale ); - qreal qp_width_in_scale = qreal( qp_width ) / gscale; - qreal qp_height_in_scale = qreal( qp_height ) / gscale; +void set_scale(int width, int height, int min_x, int min_y, int qp_width, + int qp_height, QPainter &qp, qreal &gscale) { + qp.scale(gscale, gscale); + qreal qp_width_in_scale = qreal(qp_width) / gscale; + qreal qp_height_in_scale = qreal(qp_height) / gscale; // move it to a central point in the window - qp.translate( -min_x + 0.5 * ( qp_width_in_scale - width ) , -min_y + 0.5 * ( qp_height_in_scale - height ) ); - + qp.translate(-min_x + 0.5 * (qp_width_in_scale - width), + -min_y + 0.5 * (qp_height_in_scale - height)); } // **************************************************************************** -void set_font( QPainter &qp ) { - +void set_font(QPainter &qp) { static QFont *font = 0; - if( !font ) { - font = new QFont( qp.font() ); + if (!font) { + font = new QFont(qp.font()); } - font->setPointSizeF( ORIGINAL_FONT_SIZE ); - qp.setFont( *font ); - + font->setPointSizeF(ORIGINAL_FONT_SIZE); + qp.setFont(*font); } // **************************************************************************** -void draw_line( vector::iterator &pos , bool bow , QPainter &qp ) { - +void draw_line(vector::iterator &pos, bool bow, QPainter &qp) { int width = *pos++; - pos++; // skip 'dashed' flag + pos++; // skip 'dashed' flag int atom1 = *pos++; int atom2 = *pos++; @@ -152,138 +151,135 @@ void draw_line( vector::iterator &pos , bool bow , QPainter &qp ) { int xp2 = *pos++; int yp2 = *pos++; - static QPen pen( "Black" ); - pen.setJoinStyle( Qt::RoundJoin ); - pen.setWidth( width * LINE_WIDTH_MULT ); - qp.setPen( pen ); + static QPen pen("Black"); + pen.setJoinStyle(Qt::RoundJoin); + pen.setWidth(width * LINE_WIDTH_MULT); + qp.setPen(pen); - if( atom1 == atom2 ) { - if( !bow ) { - pen.setColor( colour_for_atomic_num( atom1 ) ); - qp.setPen( pen ); + if (atom1 == atom2) { + if (!bow) { + pen.setColor(colour_for_atomic_num(atom1)); + qp.setPen(pen); } - qp.drawLine( xp1 , yp1 , xp2 , yp2 ); - } else { - int mx = xp1 + ( xp2 - xp1 ) / 2; - int my = yp1 + ( yp2 - yp1 ) / 2; - if( !bow ) { - pen.setColor( colour_for_atomic_num( atom1 ) ); - qp.setPen( pen ); + qp.drawLine(xp1, yp1, xp2, yp2); + } else { + int mx = xp1 + (xp2 - xp1) / 2; + int my = yp1 + (yp2 - yp1) / 2; + if (!bow) { + pen.setColor(colour_for_atomic_num(atom1)); + qp.setPen(pen); } - qp.drawLine( xp1 , yp1 , mx , my ); - if( !bow ) { - pen.setColor( colour_for_atomic_num( atom2 ) ); - qp.setPen( pen ); + qp.drawLine(xp1, yp1, mx, my); + if (!bow) { + pen.setColor(colour_for_atomic_num(atom2)); + qp.setPen(pen); } - qp.drawLine( mx , my , xp2 , yp2 ); + qp.drawLine(mx, my, xp2, yp2); } } // **************************************************************************** -void draw_atom( vector::iterator &pos , bool bow , QPainter &qp ) { - +void draw_atom(vector::iterator &pos, bool bow, QPainter &qp) { int atnum = *pos++; int xp = *pos++; int yp = *pos++; int slen = *pos++; QString label; - for(int i = 0 ; i < slen ; ++i ){ - label += static_cast( *pos++ ); + for (int i = 0; i < slen; ++i) { + label += static_cast(*pos++); } - pos++; // move past orient flag, which is not being used + pos++; // move past orient flag, which is not being used - char letter[2] = { '\0' , '\0' }; + char letter[2] = {'\0', '\0'}; qp.save(); - QRectF whole_br = qp.boundingRect( 0 , 0 , 100 , 100 , Qt::AlignHCenter , label ); - qp.translate( xp - whole_br.width() / 2.0 , yp - whole_br.height() / 2.0 ); + QRectF whole_br = qp.boundingRect(0, 0, 100, 100, Qt::AlignHCenter, label); + qp.translate(xp - whole_br.width() / 2.0, yp - whole_br.height() / 2.0); - static QPen pen( "Black" ); - qp.setPen( pen ); - pen.setJoinStyle( Qt::RoundJoin ); - if( !bow ) { - pen.setColor( colour_for_atomic_num( atnum ) ); - qp.setPen( pen ); + static QPen pen("Black"); + qp.setPen(pen); + pen.setJoinStyle(Qt::RoundJoin); + if (!bow) { + pen.setColor(colour_for_atomic_num(atnum)); + qp.setPen(pen); } - // blank out behind the letters, so bonds don't go through where the label is. I think - // circles work better than rectangles for this, but it means going through it all twice, - // as the circles overlap so would obscure the letter that came afterwards - // This assumes the bonds are drawn before the atoms, which is how it is set up in MolDrawing.h. - static QBrush letter_brush( qp.background() ); - letter_brush.setStyle( Qt::SolidPattern ); + // blank out behind the letters, so bonds don't go through where the label is. + // I think circles work better than rectangles for this, but it means going + // through it all twice, as the circles overlap so would obscure the letter + // that came afterwards This assumes the bonds are drawn before the atoms, + // which is how it is set up in MolDrawing.h. + static QBrush letter_brush(qp.background()); + letter_brush.setStyle(Qt::SolidPattern); qp.save(); - qp.setPen( qp.background().color() ); // so the ellipse doesn't have a border - qp.setBrush( letter_brush ); - - // do things 1 letter at a time. We needed to stuff the characters into label first, so as to - // get the bounding rectangle for the whole label. - for( int i = 0 ; i < slen ; ++i ) { + qp.setPen(qp.background().color()); // so the ellipse doesn't have a border + qp.setBrush(letter_brush); + // do things 1 letter at a time. We needed to stuff the characters into label + // first, so as to get the bounding rectangle for the whole label. + for (int i = 0; i < slen; ++i) { letter[0] = label.toLocal8Bit().data()[i]; - QString at_lab( letter ); - QRectF br = qp.boundingRect( 0 , 0 , 1000 , 1000 , Qt::AlignHCenter , at_lab ); + QString at_lab(letter); + QRectF br = qp.boundingRect(0, 0, 1000, 1000, Qt::AlignHCenter, at_lab); - // subscript for numbers, superscript for charge. Stretch the ellipse out so the bond - // is obscured over the whole of its extent. - qreal letter_top = 0.0 , letter_height = br.height(); - if( isdigit( letter[0] ) ) { - qp.translate( 0.0 , br.height() / 2.0 ); + // subscript for numbers, superscript for charge. Stretch the ellipse out so + // the bond is obscured over the whole of its extent. + qreal letter_top = 0.0, letter_height = br.height(); + if (isdigit(letter[0])) { + qp.translate(0.0, br.height() / 2.0); letter_top = -br.height() / 2.0; letter_height += br.height() / 2.0; - } else if( '+' == letter[0] || '-' == letter[0] ) { - qp.translate( 0.0 , -br.height() / 2.0 ); + } else if ('+' == letter[0] || '-' == letter[0]) { + qp.translate(0.0, -br.height() / 2.0); letter_height += br.height() / 2.0; } - qp.drawEllipse( QRectF( -2.0 , -2.0 + letter_top , br.width() + 2.0 , letter_height + 2.0 ) ); - qp.translate( br.width() , 0.0 ); + qp.drawEllipse( + QRectF(-2.0, -2.0 + letter_top, br.width() + 2.0, letter_height + 2.0)); + qp.translate(br.width(), 0.0); // remove superscript/subscript - if( isdigit( letter[0] ) ) { - qp.translate( 0.0 , -br.height() / 2.0 ); - } else if( '+' == letter[0] || '-' == letter[0] ) { - qp.translate( 0.0 , br.height() / 2.0 ); + if (isdigit(letter[0])) { + qp.translate(0.0, -br.height() / 2.0); + } else if ('+' == letter[0] || '-' == letter[0]) { + qp.translate(0.0, br.height() / 2.0); } } - qp.setPen( pen ); + qp.setPen(pen); qp.restore(); // now the letters - for( int i = 0 ; i < slen ; ++i ) { - + for (int i = 0; i < slen; ++i) { letter[0] = label.toLocal8Bit().data()[i]; - QString at_lab( letter ); - QRectF br = qp.boundingRect( 0 , 0 , 1000 , 1000 , Qt::AlignHCenter , at_lab ); + QString at_lab(letter); + QRectF br = qp.boundingRect(0, 0, 1000, 1000, Qt::AlignHCenter, at_lab); // subscript for numbers, superscript for charge - if( isdigit( letter[0] ) ) { - qp.translate( 0.0 , br.height() / 2.0 ); - } else if( '+' == letter[0] || '-' == letter[0] ) { - qp.translate( 0.0 , -br.height() / 2.0 ); + if (isdigit(letter[0])) { + qp.translate(0.0, br.height() / 2.0); + } else if ('+' == letter[0] || '-' == letter[0]) { + qp.translate(0.0, -br.height() / 2.0); } - qp.drawText( QRectF( 0.0 , 0.0 , br.width() , br.height() ) , Qt::AlignHCenter , at_lab , &br ); - qp.translate( br.width() , 0.0 ); + qp.drawText(QRectF(0.0, 0.0, br.width(), br.height()), Qt::AlignHCenter, + at_lab, &br); + qp.translate(br.width(), 0.0); // remove superscript/subscript - if( isdigit( letter[0] ) ) { - qp.translate( 0.0 , -br.height() / 2.0 ); - } else if( '+' == letter[0] || '-' == letter[0] ) { - qp.translate( 0.0 , br.height() / 2.0 ); + if (isdigit(letter[0])) { + qp.translate(0.0, -br.height() / 2.0); + } else if ('+' == letter[0] || '-' == letter[0]) { + qp.translate(0.0, br.height() / 2.0); } } qp.restore(); - } // **************************************************************************** -void line_extremes( vector::const_iterator &pos , - int &min_x , int &max_x , - int &min_y , int &max_y ) { - - pos += 4; // past the line width, type and atom numbers +void line_extremes(vector::const_iterator &pos, int &min_x, int &max_x, + int &min_y, int &max_y) { + pos += 4; // past the line width, type and atom numbers int xp1 = *pos++; int yp1 = *pos++; int xp2 = *pos++; @@ -298,65 +294,61 @@ void line_extremes( vector::const_iterator &pos , max_x = xp2 > max_x ? xp2 : max_x; min_y = yp2 < min_y ? yp2 : min_y; max_y = yp2 > max_y ? yp2 : max_y; - } // **************************************************************************** -void atom_extremes( vector::const_iterator &pos , - QPainter &qp , - int &min_x , int &max_x , - int &min_y , int &max_y ) { - - pos++; // skip the atomic number, not needed for this +void atom_extremes(vector::const_iterator &pos, QPainter &qp, int &min_x, + int &max_x, int &min_y, int &max_y) { + pos++; // skip the atomic number, not needed for this int xp = *pos++; int yp = *pos++; int slen = *pos++; QString label; - for(int i = 0 ; i < slen ; ++i ){ - label += static_cast( *pos++ ); + for (int i = 0; i < slen; ++i) { + label += static_cast(*pos++); } - pos++; // move past orient flag, which is not being used, and indeed is not understood! + pos++; // move past orient flag, which is not being used, and indeed is not + // understood! - QRectF whole_br = qp.boundingRect( 0 , 0 , 1000 , 1000 , Qt::AlignHCenter , label ); + QRectF whole_br = qp.boundingRect(0, 0, 1000, 1000, Qt::AlignHCenter, label); - int labx1 = xp - int( whole_br.width() / 2.0 ); - int labx2 = xp + int( whole_br.width() ); - // subscripts and superscripts may occur in the atom label. Just allow for that willy-nilly. - int laby1 = yp - int( 0.5 * whole_br.height() ); - int laby2 = yp + int( 0.5 * whole_br.height() ); + int labx1 = xp - int(whole_br.width() / 2.0); + int labx2 = xp + int(whole_br.width()); + // subscripts and superscripts may occur in the atom label. Just allow for + // that willy-nilly. + int laby1 = yp - int(0.5 * whole_br.height()); + int laby2 = yp + int(0.5 * whole_br.height()); min_x = labx1 < min_x ? labx1 : min_x; max_x = labx2 > max_x ? labx2 : max_x; min_y = laby1 < min_y ? laby1 : min_y; max_y = laby2 > max_y ? laby2 : max_y; - } // **************************************************************************** -void setup_scale( vector &drawing , QPainter &qp , - int qp_width , int qp_height ) { - +void setup_scale(vector &drawing, QPainter &qp, int qp_width, + int qp_height) { // calculate the width of the drawing. The values for width and height as - // supplied in drawing by MolDrawing.h don't allow for the width of atom labels - // so if there are non-carbon atoms at the extremes of the picture, these - // will be drawn off the page. + // supplied in drawing by MolDrawing.h don't allow for the width of atom + // labels so if there are non-carbon atoms at the extremes of the picture, + // these will be drawn off the page. vector::const_iterator pos = drawing.begin() + 7; int min_x = numeric_limits::max(); int max_x = numeric_limits::min(); int min_y = numeric_limits::max(); int max_y = numeric_limits::min(); - while( pos != drawing.end() ) { + while (pos != drawing.end()) { int token = *pos++; - switch( token ) { - case Drawing::LINE : - line_extremes( pos , min_x , max_x , min_y , max_y ); - break; - case Drawing::ATOM : - atom_extremes( pos , qp , min_x , max_x , min_y , max_y ); - break; - default : - break; + switch (token) { + case Drawing::LINE: + line_extremes(pos, min_x, max_x, min_y, max_y); + break; + case Drawing::ATOM: + atom_extremes(pos, qp, min_x, max_x, min_y, max_y); + break; + default: + break; } } @@ -370,20 +362,18 @@ void setup_scale( vector &drawing , QPainter &qp , int height = max_y - min_y; qreal gscale; - get_scale( width , height , qp_width , qp_height , gscale ); - set_scale( width , height , min_x , min_y , qp_width , qp_height , qp , gscale ); - + get_scale(width, height, qp_width, qp_height, gscale); + set_scale(width, height, min_x, min_y, qp_width, qp_height, qp, gscale); } // **************************************************************************** -void MolToQPainter( vector &drawing , int qp_width , int qp_height , - bool bow , QPainter &qp ) { - +void MolToQPainter(vector &drawing, int qp_width, int qp_height, bool bow, + QPainter &qp) { vector::iterator pos = drawing.begin() + 2; - if( *pos != Drawing::BOUNDS ) { + if (*pos != Drawing::BOUNDS) { // no drawing made by RDKit - QString msg( "Bad Drawing" ); - qp.drawText( 0 , qp_height / 2 , msg ); + QString msg("Bad Drawing"); + qp.drawText(0, qp_height / 2, msg); return; } pos += 3; @@ -391,67 +381,62 @@ void MolToQPainter( vector &drawing , int qp_width , int qp_height , // save current transformation matrix() qp.save(); - set_font( qp ); - setup_scale( drawing , qp, qp_width , qp_height ); + set_font(qp); + setup_scale(drawing, qp, qp_width, qp_height); - pos += 2; // for the width and height in the drawing - while( pos != drawing.end() ) { + pos += 2; // for the width and height in the drawing + while (pos != drawing.end()) { int token = *pos++; - switch( token ) { - case Drawing::LINE : - draw_line( pos , bow , qp ); - break; - case Drawing::ATOM : - draw_atom( pos , bow , qp ); - break; - default : - cerr << "Duff token, expect a crash." << token << endl; - break; + switch (token) { + case Drawing::LINE: + draw_line(pos, bow, qp); + break; + case Drawing::ATOM: + draw_atom(pos, bow, qp); + break; + default: + cerr << "Duff token, expect a crash." << token << endl; + break; } } // put the transformation matrix back to how it was on entry qp.restore(); - } // **************************************************************************** -void label_molecule( const QString &label , int width , int height , - int label_height , QPainter &qp ) { - +void label_molecule(const QString &label, int width, int height, + int label_height, QPainter &qp) { int label_y = height - label_height; - qp.drawText( QRect( 0 , label_y , width , label_height ) , Qt::AlignHCenter , label ); - + qp.drawText(QRect(0, label_y, width, label_height), Qt::AlignHCenter, label); } // **************************************************************************** // width and height are the size of the rectangle in qp we are drawing into. // bow is black on white- when false, colours are used in drawing -void smiles_to_qpainter( const string &smiles , const QString &label , - int width , int height , bool bow , - QPainter &qp ) { - +void smiles_to_qpainter(const string &smiles, const QString &label, int width, + int height, bool bow, QPainter &qp) { // render into an RDKit drawing - pRWMol mol( SmilesToMol( smiles ) ); - MolOps::Kekulize( *mol ); - RDDepict::compute2DCoords( *mol ); - vector drawing = Drawing::DrawMol( *mol ); + pRWMol mol(SmilesToMol(smiles)); + MolOps::Kekulize(*mol); + RDDepict::compute2DCoords(*mol); + vector drawing = Drawing::DrawMol(*mol); - qp.setRenderHint( QPainter::Antialiasing , true ); - qp.setRenderHint( QPainter::TextAntialiasing , true ); + qp.setRenderHint(QPainter::Antialiasing, true); + qp.setRenderHint(QPainter::TextAntialiasing, true); - // get the height that will be needed for the label, and allow the picture to accommodate it + // get the height that will be needed for the label, and allow the picture to + // accommodate it QRect br; - if( !label.isEmpty() ) { - br = qp.boundingRect( QRect( 0 , 0 , width , height ) , Qt::AlignHCenter , label ); + if (!label.isEmpty()) { + br = qp.boundingRect(QRect(0, 0, width, height), Qt::AlignHCenter, label); } int label_height = br.height() + 5; int pict_height = height - label_height; - MolToQPainter( drawing , width , pict_height , bow , qp ); + MolToQPainter(drawing, width, pict_height, bow, qp); - if( !label.isEmpty() ) { - label_molecule( label , width , height , label_height , qp ); + if (!label.isEmpty()) { + label_molecule(label, width, height, label_height, qp); } - } diff --git a/Code/Demos/RDKit/Draw/qtDemo/qtdraw_demo.cc b/Code/Demos/RDKit/Draw/qtDemo/qtdraw_demo.cc index ef85a049a..863e18a0a 100644 --- a/Code/Demos/RDKit/Draw/qtDemo/qtdraw_demo.cc +++ b/Code/Demos/RDKit/Draw/qtDemo/qtdraw_demo.cc @@ -19,79 +19,69 @@ // ***************************************************************************** // in file RDKitMolToQPainter.cc -void smiles_to_qpainter( const std::string &smiles , const QString &label , - int width , int height , bool bow , - QPainter &qp ); +void smiles_to_qpainter(const std::string &smiles, const QString &label, + int width, int height, bool bow, QPainter &qp); // ***************************************************************************** class RDKitDraw : public QWidget { + public: + RDKitDraw(QWidget *parent = 0) : QWidget(parent) {} -public : - - RDKitDraw( QWidget *parent = 0 ) : QWidget( parent ) {} - - void set_smiles( const std::string &smi ) { + void set_smiles(const std::string &smi) { smiles_ = smi; update(); } - void set_name( const std::string &name ) { + void set_name(const std::string &name) { name_ = name; update(); } -protected : - - void paintEvent( QPaintEvent *event ) { - + protected: + void paintEvent(QPaintEvent *event) { int w = width(); int h = height(); QPainter qp; - qp.begin( this ); - qp.setBackground( QColor( "White" ) ); - qp.fillRect( 0 , 0 , w , h , QColor( "White" ) ); + qp.begin(this); + qp.setBackground(QColor("White")); + qp.fillRect(0, 0, w, h, QColor("White")); - if( smiles_.empty() ) { + if (smiles_.empty()) { qp.end(); return; } - smiles_to_qpainter( smiles_ , QString( name_.c_str() ) , w , h , true , qp ); + smiles_to_qpainter(smiles_, QString(name_.c_str()), w, h, true, qp); qp.end(); - } -private : - + private: std::string smiles_; std::string name_; - }; // ***************************************************************************** -int main( int argc , char **argv ) { - - QApplication a( argc , argv ); +int main(int argc, char **argv) { + QApplication a(argc, argv); RDKitDraw *rdkd = new RDKitDraw; - rdkd->setGeometry( 50 , 50 , 500 , 500 ); + rdkd->setGeometry(50, 50, 500, 500); rdkd->show(); - if( argc > 1 ) { - rdkd->set_smiles( argv[1] ); + if (argc > 1) { + rdkd->set_smiles(argv[1]); } - if( argc > 2 ) { - rdkd->set_name( argv[2] ); + if (argc > 2) { + rdkd->set_name(argv[2]); } - if( argc == 1 ) { - rdkd->set_smiles( "[Mg]c1c(C#N)cc(C(=O)NCc2sc([NH3+])c([NH3+])c2)cc1" ); - rdkd->set_name( "Molecule 2" ); + if (argc == 1) { + rdkd->set_smiles("[Mg]c1c(C#N)cc(C(=O)NCc2sc([NH3+])c([NH3+])c2)cc1"); + rdkd->set_name("Molecule 2"); } return a.exec(); - } diff --git a/Code/Demos/RDKit/MPI/rdkexample1.cpp b/Code/Demos/RDKit/MPI/rdkexample1.cpp index 9ecaa7ac7..f58fc6325 100644 --- a/Code/Demos/RDKit/MPI/rdkexample1.cpp +++ b/Code/Demos/RDKit/MPI/rdkexample1.cpp @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) { // process it: std::vector res; - std::vector > allRes; + std::vector> allRes; // start by finding our chunk: unsigned int nProcs = world.size(); unsigned int chunkSize = data.size() / nProcs; diff --git a/Code/DistGeom/ChiralViolationContrib.cpp b/Code/DistGeom/ChiralViolationContrib.cpp index 316151660..84ada6aee 100644 --- a/Code/DistGeom/ChiralViolationContrib.cpp +++ b/Code/DistGeom/ChiralViolationContrib.cpp @@ -115,4 +115,4 @@ void ChiralViolationContrib::getGrad(double *pos, double *grad) const { pos[d_idx3 * dim + 1] * (pos[d_idx1 * dim] - pos[d_idx2 * dim])); // std::cerr<<"Chiral Violation grad: "<d_end2Idx + i] -= dGrad; } } -} +} // namespace DistGeom diff --git a/Code/DistGeom/TriangleSmooth.cpp b/Code/DistGeom/TriangleSmooth.cpp index ac44f2e9a..78720d964 100644 --- a/Code/DistGeom/TriangleSmooth.cpp +++ b/Code/DistGeom/TriangleSmooth.cpp @@ -78,4 +78,4 @@ bool triangleSmoothBounds(BoundsMatrix *boundsMat, double tol) { } return true; } -} +} // namespace DistGeom diff --git a/Code/DistGeom/Wrap/DistGeom.cpp b/Code/DistGeom/Wrap/DistGeom.cpp index 57cba0b2b..7cd1778d7 100644 --- a/Code/DistGeom/Wrap/DistGeom.cpp +++ b/Code/DistGeom/Wrap/DistGeom.cpp @@ -171,7 +171,7 @@ PyObject *embedBoundsMatrix(python::object boundsMatArg, int maxIters = 10, return PyArray_Return(res); } -} +} // namespace RDKit BOOST_PYTHON_MODULE(DistGeom) { python::scope().attr("__doc__") = diff --git a/Code/ForceField/MMFF/AngleBend.cpp b/Code/ForceField/MMFF/AngleBend.cpp index c384bd815..7130633e4 100644 --- a/Code/ForceField/MMFF/AngleBend.cpp +++ b/Code/ForceField/MMFF/AngleBend.cpp @@ -161,5 +161,5 @@ void AngleBendContrib::getGrad(double *pos, double *grad) const { Utils::calcAngleBendGrad(r, dist, g, dE_dTheta, cosTheta, sinTheta); } -} -} +} // namespace MMFF +} // namespace ForceFields diff --git a/Code/ForceField/MMFF/BondStretch.cpp b/Code/ForceField/MMFF/BondStretch.cpp index 53b474031..7940a75d3 100644 --- a/Code/ForceField/MMFF/BondStretch.cpp +++ b/Code/ForceField/MMFF/BondStretch.cpp @@ -96,5 +96,5 @@ void BondStretchContrib::getGrad(double *pos, double *grad) const { g2[i] -= dGrad; } } -} -} +} // namespace MMFF +} // namespace ForceFields diff --git a/Code/ForceField/MMFF/DistanceConstraint.cpp b/Code/ForceField/MMFF/DistanceConstraint.cpp index e2988e824..b1a7482ed 100644 --- a/Code/ForceField/MMFF/DistanceConstraint.cpp +++ b/Code/ForceField/MMFF/DistanceConstraint.cpp @@ -99,5 +99,5 @@ void DistanceConstraintContrib::getGrad(double *pos, double *grad) const { grad[3 * d_end2Idx + i] -= dGrad; } } -} -} +} // namespace MMFF +} // namespace ForceFields diff --git a/Code/ForceField/MMFF/OopBend.cpp b/Code/ForceField/MMFF/OopBend.cpp index 0e09af61d..ece4150ed 100644 --- a/Code/ForceField/MMFF/OopBend.cpp +++ b/Code/ForceField/MMFF/OopBend.cpp @@ -153,5 +153,5 @@ void OopBendContrib::getGrad(double *pos, double *grad) const { g4[i] += dE_dChi * tg4[i]; } } -} -} +} // namespace MMFF +} // namespace ForceFields diff --git a/Code/ForceField/MMFF/Params.cpp b/Code/ForceField/MMFF/Params.cpp index b3f94bf9f..b63721a85 100644 --- a/Code/ForceField/MMFF/Params.cpp +++ b/Code/ForceField/MMFF/Params.cpp @@ -1984,8 +1984,7 @@ MMFFHerschbachLaurieCollection::MMFFHerschbachLaurieCollection( #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP unsigned int jRow = boost::lexical_cast(*token); #else - d_jRow.push_back( - (std::uint8_t)boost::lexical_cast(*token)); + d_jRow.push_back((std::uint8_t)boost::lexical_cast(*token)); #endif ++token; mmffHerschbachLaurieObj.a_ij = boost::lexical_cast(*token); diff --git a/Code/ForceField/MMFF/PositionConstraint.cpp b/Code/ForceField/MMFF/PositionConstraint.cpp index b766c2d3a..f53f3089d 100644 --- a/Code/ForceField/MMFF/PositionConstraint.cpp +++ b/Code/ForceField/MMFF/PositionConstraint.cpp @@ -67,5 +67,5 @@ void PositionConstraintContrib::getGrad(double *pos, double *grad) const { grad[3 * d_atIdx + i] += dGrad; } } -} -} +} // namespace MMFF +} // namespace ForceFields diff --git a/Code/ForceField/MMFF/StretchBend.cpp b/Code/ForceField/MMFF/StretchBend.cpp index 57f5ef03b..a902e5bc1 100644 --- a/Code/ForceField/MMFF/StretchBend.cpp +++ b/Code/ForceField/MMFF/StretchBend.cpp @@ -149,5 +149,5 @@ void StretchBendContrib::getGrad(double *pos, double *grad) const { g3[2] += c5 * (p32.z * d_forceConstants.second * angleTerm + dCos_dS6 / (-sinTheta) * distTerm); } -} -} +} // namespace MMFF +} // namespace ForceFields diff --git a/Code/ForceField/MMFF/TorsionAngle.cpp b/Code/ForceField/MMFF/TorsionAngle.cpp index 31f1ca8a1..7921ce14c 100644 --- a/Code/ForceField/MMFF/TorsionAngle.cpp +++ b/Code/ForceField/MMFF/TorsionAngle.cpp @@ -89,7 +89,7 @@ void calcTorsionGrad(RDGeom::Point3D *r, RDGeom::Point3D *t, double *d, g[3][1] += sinTerm * (dCos_dT[5] * r[2].x - dCos_dT[3] * r[2].z); g[3][2] += sinTerm * (dCos_dT[3] * r[2].y - dCos_dT[4] * r[2].x); } -} +} // namespace Utils TorsionAngleContrib::TorsionAngleContrib(ForceField *owner, unsigned int idx1, unsigned int idx2, unsigned int idx3, @@ -169,5 +169,5 @@ void TorsionAngleContrib::getGrad(double *pos, double *grad) const { Utils::calcTorsionGrad(r, t, d, g, sinTerm, cosPhi); } -} -} +} // namespace MMFF +} // namespace ForceFields diff --git a/Code/ForceField/UFF/AngleBend.cpp b/Code/ForceField/UFF/AngleBend.cpp index 142c40faa..04a709942 100644 --- a/Code/ForceField/UFF/AngleBend.cpp +++ b/Code/ForceField/UFF/AngleBend.cpp @@ -251,5 +251,5 @@ double AngleBendContrib::getThetaDeriv(double cosTheta, double sinTheta) const { } return dE_dTheta; } -} -} +} // namespace UFF +} // namespace ForceFields diff --git a/Code/ForceField/UFF/BondStretch.cpp b/Code/ForceField/UFF/BondStretch.cpp index 0f91694b7..ce5f8b63d 100644 --- a/Code/ForceField/UFF/BondStretch.cpp +++ b/Code/ForceField/UFF/BondStretch.cpp @@ -99,5 +99,5 @@ void BondStretchContrib::getGrad(double *pos, double *grad) const { grad[3 * d_end2Idx + i] -= dGrad; } } -} -} +} // namespace UFF +} // namespace ForceFields diff --git a/Code/ForceField/UFF/DistanceConstraint.cpp b/Code/ForceField/UFF/DistanceConstraint.cpp index fe461d279..b06c4db86 100644 --- a/Code/ForceField/UFF/DistanceConstraint.cpp +++ b/Code/ForceField/UFF/DistanceConstraint.cpp @@ -99,5 +99,5 @@ void DistanceConstraintContrib::getGrad(double *pos, double *grad) const { grad[3 * d_end2Idx + i] -= dGrad; } } -} -} +} // namespace UFF +} // namespace ForceFields diff --git a/Code/ForceField/UFF/Inversion.cpp b/Code/ForceField/UFF/Inversion.cpp index fad6d984c..cae0bbf00 100644 --- a/Code/ForceField/UFF/Inversion.cpp +++ b/Code/ForceField/UFF/Inversion.cpp @@ -89,7 +89,8 @@ calcInversionCoefficientsAndForceConstant(int at2AtomicNum, bool isCBoundToO) { InversionContrib::InversionContrib(ForceField *owner, unsigned int idx1, unsigned int idx2, unsigned int idx3, unsigned int idx4, int at2AtomicNum, - bool isCBoundToO, double oobForceScalingFactor) { + bool isCBoundToO, + double oobForceScalingFactor) { PRECONDITION(owner, "bad owner"); URANGE_CHECK(idx1, owner->positions().size()); URANGE_CHECK(idx2, owner->positions().size()); @@ -105,7 +106,8 @@ InversionContrib::InversionContrib(ForceField *owner, unsigned int idx1, boost::tuple invCoeffForceCon = Utils::calcInversionCoefficientsAndForceConstant(at2AtomicNum, isCBoundToO); - d_forceConstant = oobForceScalingFactor * boost::tuples::get<0>(invCoeffForceCon); + d_forceConstant = + oobForceScalingFactor * boost::tuples::get<0>(invCoeffForceCon); d_C0 = boost::tuples::get<1>(invCoeffForceCon); d_C1 = boost::tuples::get<2>(invCoeffForceCon); d_C2 = boost::tuples::get<3>(invCoeffForceCon); @@ -200,5 +202,5 @@ void InversionContrib::getGrad(double *pos, double *grad) const { g4[i] += dE_dW * tg4[i]; } } -} -} +} // namespace UFF +} // namespace ForceFields diff --git a/Code/ForceField/UFF/Nonbonded.cpp b/Code/ForceField/UFF/Nonbonded.cpp index 0848b2637..50f5000c4 100644 --- a/Code/ForceField/UFF/Nonbonded.cpp +++ b/Code/ForceField/UFF/Nonbonded.cpp @@ -27,7 +27,7 @@ double calcNonbondedDepth(const AtomicParams *at1Params, return sqrt(at1Params->D1 * at2Params->D1); } -} // end of namespace utils +} // namespace Utils vdWContrib::vdWContrib(ForceField *owner, unsigned int idx1, unsigned int idx2, const AtomicParams *at1Params, @@ -101,5 +101,5 @@ void vdWContrib::getGrad(double *pos, double *grad) const { grad[3 * d_at2Idx + i] -= dGrad; } } -} -} +} // namespace UFF +} // namespace ForceFields diff --git a/Code/ForceField/UFF/PositionConstraint.cpp b/Code/ForceField/UFF/PositionConstraint.cpp index f0af48169..c6c73ab47 100644 --- a/Code/ForceField/UFF/PositionConstraint.cpp +++ b/Code/ForceField/UFF/PositionConstraint.cpp @@ -67,5 +67,5 @@ void PositionConstraintContrib::getGrad(double *pos, double *grad) const { grad[3 * d_atIdx + i] += dGrad; } } -} -} +} // namespace UFF +} // namespace ForceFields diff --git a/Code/ForceField/UFF/TorsionAngle.cpp b/Code/ForceField/UFF/TorsionAngle.cpp index 9d991f976..0ab078714 100644 --- a/Code/ForceField/UFF/TorsionAngle.cpp +++ b/Code/ForceField/UFF/TorsionAngle.cpp @@ -80,7 +80,7 @@ void calcTorsionGrad(RDGeom::Point3D *r, RDGeom::Point3D *t, double *d, g[3][1] += sinTerm * (dCos_dT[5] * r[2].x - dCos_dT[3] * r[2].z); g[3][2] += sinTerm * (dCos_dT[3] * r[2].y - dCos_dT[4] * r[2].x); } -} +} // namespace Utils TorsionAngleContrib::TorsionAngleContrib( ForceField *owner, unsigned int idx1, unsigned int idx2, unsigned int idx3, @@ -272,5 +272,5 @@ double TorsionAngleContrib::getThetaDeriv(double cosTheta, return res; } -} -} +} // namespace UFF +} // namespace ForceFields diff --git a/Code/ForceField/Wrap/ForceField.cpp b/Code/ForceField/Wrap/ForceField.cpp index dfec7190c..642a1766a 100644 --- a/Code/ForceField/Wrap/ForceField.cpp +++ b/Code/ForceField/Wrap/ForceField.cpp @@ -129,7 +129,9 @@ double PyForceField::calcEnergyWithPos(const python::object &pos) { size_t s = this->field->dimension() * this->field->numPoints(); size_t numElements = python::extract(pos.attr("__len__")()); if (s != numElements) { - throw ValueErrorException("The Python container must have length equal to Dimension() * NumPoints()"); + throw ValueErrorException( + "The Python container must have length equal to Dimension() * " + "NumPoints()"); } std::vector c(s); for (size_t i = 0; i < s; ++i) { @@ -148,7 +150,7 @@ PyObject *PyForceField::positions() { const RDGeom::PointPtrVect &p = this->field->positions(); size_t i = 0; PyObject *coordItem; - for (const auto pptr: p) { + for (const auto pptr : p) { for (size_t j = 0; j < 3; ++j) { coordItem = PyFloat_FromDouble((*pptr)[j]); PyTuple_SetItem(coordTuple, i++, coordItem); @@ -165,7 +167,9 @@ PyObject *PyForceField::calcGradWithPos(const python::object &pos) { if (pos != python::object()) { size_t numElements = python::extract(pos.attr("__len__")()); if (s != numElements) { - throw ValueErrorException("The Python container must have length equal to Dimension() * NumPoints()"); + throw ValueErrorException( + "The Python container must have length equal to Dimension() * " + "NumPoints()"); } std::vector c(s); for (size_t i = 0; i < s; ++i) { @@ -182,18 +186,19 @@ PyObject *PyForceField::calcGradWithPos(const python::object &pos) { return gradTuple; } -python::tuple PyForceField::minimizeTrajectory(unsigned int snapshotFreq, int maxIts, double forceTol, double energyTol) { +python::tuple PyForceField::minimizeTrajectory(unsigned int snapshotFreq, + int maxIts, double forceTol, + double energyTol) { PRECONDITION(this->field, "no force field"); RDKit::SnapshotVect snapshotVect; - int resInt = this->field->minimize(snapshotFreq, &snapshotVect, - maxIts, forceTol, energyTol); + int resInt = this->field->minimize(snapshotFreq, &snapshotVect, maxIts, + forceTol, energyTol); python::list l; for (RDKit::SnapshotVect::const_iterator it = snapshotVect.begin(); it != snapshotVect.end(); ++it) { l.append(new RDKit::Snapshot(*it)); } return python::make_tuple(resInt, l); - } PyObject *PyMMFFMolProperties::getMMFFBondStretchParams( @@ -302,22 +307,24 @@ BOOST_PYTHON_MODULE(rdForceField) { python::class_("ForceField", "A force field", python::no_init) .def("CalcEnergy", - (double (PyForceField::*)(const python::object &) const) &PyForceField::calcEnergyWithPos, + (double (PyForceField::*)(const python::object &) const) & + PyForceField::calcEnergyWithPos, (python::arg("pos") = python::object()), "Returns the energy (in kcal/mol) of the current arrangement\n" "or of the supplied coordinate list (if non-empty)") .def("CalcGrad", &PyForceField::calcGradWithPos, (python::arg("pos") = python::object()), "Returns a tuple filled with the per-coordinate gradients\n" - "of the current arrangement or of the supplied coordinate list (if non-empty)") + "of the current arrangement or of the supplied coordinate list " + "(if non-empty)") .def("Positions", &PyForceField::positions, "Returns a tuple filled with the coordinates of the\n" "points the ForceField is handling") .def("Dimension", - (unsigned int (PyForceField::*)() const) &PyForceField::dimension, + (unsigned int (PyForceField::*)() const) & PyForceField::dimension, "Returns the dimension of the ForceField") .def("NumPoints", - (unsigned int (PyForceField::*)() const) &PyForceField::numPoints, + (unsigned int (PyForceField::*)() const) & PyForceField::numPoints, "Returns the number of points the ForceField is handling") .def("Minimize", &PyForceField::minimize, (python::arg("maxIts") = 200, python::arg("forceTol") = 1e-4, @@ -329,7 +336,8 @@ BOOST_PYTHON_MODULE(rdForceField) { python::arg("forceTol") = 1e-4, python::arg("energyTol") = 1e-6), "Runs some minimization iterations, recording the minimization " "trajectory every snapshotFreq steps.\n\n" - "Returns a (int, []) tuple; the int is 0 if the minimization succeeded, " + "Returns a (int, []) tuple; the int is 0 if the minimization " + "succeeded, " "while the list contains Snapshot objects.") .def("AddDistanceConstraint", ForceFieldAddDistanceConstraint, (python::arg("self"), python::arg("idx1"), python::arg("idx2"), diff --git a/Code/Fuzz/standalone_fuzz_target_runner.cpp b/Code/Fuzz/standalone_fuzz_target_runner.cpp index 3f1a49be3..70b1299ef 100644 --- a/Code/Fuzz/standalone_fuzz_target_runner.cpp +++ b/Code/Fuzz/standalone_fuzz_target_runner.cpp @@ -22,7 +22,7 @@ int main(int argc, char **argv) { std::ifstream in(argv[i]); in.seekg(0, in.end); size_t length = in.tellg(); - in.seekg (0, in.beg); + in.seekg(0, in.beg); std::cout << "Reading " << length << " bytes from " << argv[i] << std::endl; // Allocate exactly length bytes so that we reliably catch buffer overflows. std::vector bytes(length); diff --git a/Code/Geometry/GridUtils.cpp b/Code/Geometry/GridUtils.cpp index a5c910f6e..f19f84c2b 100644 --- a/Code/Geometry/GridUtils.cpp +++ b/Code/Geometry/GridUtils.cpp @@ -20,7 +20,8 @@ using namespace RDKit; namespace RDGeom { template -double tverskyIndex(const GRIDTYPE &grid1, const GRIDTYPE &grid2, double alpha, double beta) { +double tverskyIndex(const GRIDTYPE &grid1, const GRIDTYPE &grid2, double alpha, + double beta) { if (!grid1.compareParams(grid2)) { throw ValueErrorException("Grid parameters do not match"); } @@ -30,17 +31,17 @@ double tverskyIndex(const GRIDTYPE &grid1, const GRIDTYPE &grid2, double alpha, unsigned int totv1 = v1->getTotalVal(); unsigned int totv2 = v2->getTotalVal(); double inter = 0.5 * (totv1 + totv2 - dist); -// double alpha = 1.0; -// double beta = 1.0; - double tversky_res = inter / (alpha * (1.0 * totv1 - inter) + beta * (1.0 * totv2 - inter) + inter); -// double res = dist / (dist + inter); + // double alpha = 1.0; + // double beta = 1.0; + double tversky_res = inter / (alpha * (1.0 * totv1 - inter) + + beta * (1.0 * totv2 - inter) + inter); + // double res = dist / (dist + inter); return tversky_res; } -template RDKIT_RDGEOMETRYLIB_EXPORT double tverskyIndex(const UniformGrid3D &grid1, - const UniformGrid3D &grid2, - double alpha, - double beta); +template RDKIT_RDGEOMETRYLIB_EXPORT double tverskyIndex( + const UniformGrid3D &grid1, const UniformGrid3D &grid2, double alpha, + double beta); template double tanimotoDistance(const GRIDTYPE &grid1, const GRIDTYPE &grid2) { @@ -57,8 +58,8 @@ double tanimotoDistance(const GRIDTYPE &grid1, const GRIDTYPE &grid2) { return res; } -template RDKIT_RDGEOMETRYLIB_EXPORT double tanimotoDistance(const UniformGrid3D &grid1, - const UniformGrid3D &grid2); +template RDKIT_RDGEOMETRYLIB_EXPORT double tanimotoDistance( + const UniformGrid3D &grid1, const UniformGrid3D &grid2); template double protrudeDistance(const GRIDTYPE &grid1, const GRIDTYPE &grid2) { @@ -75,10 +76,10 @@ double protrudeDistance(const GRIDTYPE &grid1, const GRIDTYPE &grid2) { return res; } -template RDKIT_RDGEOMETRYLIB_EXPORT double protrudeDistance(const UniformGrid3D &grid1, - const UniformGrid3D &grid2); +template RDKIT_RDGEOMETRYLIB_EXPORT double protrudeDistance( + const UniformGrid3D &grid1, const UniformGrid3D &grid2); -std::map > gridIdxCache; +std::map> gridIdxCache; std::vector computeGridIndices(const UniformGrid3D &grid, double windowRadius) { double gridSpacing = grid.getSpacing(); @@ -164,4 +165,4 @@ std::vector findGridTerminalPoints(const UniformGrid3D &grid, } return res; } -} +} // namespace RDGeom diff --git a/Code/Geometry/Transform3D.cpp b/Code/Geometry/Transform3D.cpp index 92558a710..a590d9bc3 100644 --- a/Code/Geometry/Transform3D.cpp +++ b/Code/Geometry/Transform3D.cpp @@ -134,7 +134,7 @@ void Transform3D::Reflect() { } } } -} +} // namespace RDGeom RDGeom::Transform3D operator*(const RDGeom::Transform3D &t1, const RDGeom::Transform3D &t2) { diff --git a/Code/GraphMol/AtomIterators.cpp b/Code/GraphMol/AtomIterators.cpp index 59ea31cca..8858ca4a7 100644 --- a/Code/GraphMol/AtomIterators.cpp +++ b/Code/GraphMol/AtomIterators.cpp @@ -332,8 +332,8 @@ AromaticAtomIterator_ return *this; } template -AromaticAtomIterator_ AromaticAtomIterator_:: -operator++(int) { +AromaticAtomIterator_ +AromaticAtomIterator_::operator++(int) { AromaticAtomIterator_ res(*this); _pos = _findNext(_pos + 1); return res; @@ -346,8 +346,8 @@ AromaticAtomIterator_ return *this; } template -AromaticAtomIterator_ AromaticAtomIterator_:: -operator--(int) { +AromaticAtomIterator_ +AromaticAtomIterator_::operator--(int) { AromaticAtomIterator_ res(*this); _pos = _findPrev(_pos - 1); return res; @@ -542,8 +542,9 @@ MatchingAtomIterator_::MatchingAtomIterator_( } template -MatchingAtomIterator_ &MatchingAtomIterator_:: -operator=(const MatchingAtomIterator_ &other) { +MatchingAtomIterator_ + &MatchingAtomIterator_::operator=( + const MatchingAtomIterator_ &other) { if (this != &other) { _mol = other._mol; _pos = other._pos; @@ -576,8 +577,8 @@ MatchingAtomIterator_ return *this; } template -MatchingAtomIterator_ MatchingAtomIterator_:: -operator++(int) { +MatchingAtomIterator_ +MatchingAtomIterator_::operator++(int) { MatchingAtomIterator_ res(*this); _pos = _findNext(_pos + 1); return res; @@ -590,8 +591,8 @@ MatchingAtomIterator_ return *this; } template -MatchingAtomIterator_ MatchingAtomIterator_:: -operator--(int) { +MatchingAtomIterator_ +MatchingAtomIterator_::operator--(int) { MatchingAtomIterator_ res(*this); _pos = _findPrev(_pos - 1); return res; @@ -639,4 +640,4 @@ template class QueryAtomIterator_; template class MatchingAtomIterator_; template class MatchingAtomIterator_; -}; // end o' namespace +}; // namespace RDKit diff --git a/Code/GraphMol/Basement/FeatTrees/FeatTree.cpp b/Code/GraphMol/Basement/FeatTrees/FeatTree.cpp index 1d3c66b01..9935d3ca9 100644 --- a/Code/GraphMol/Basement/FeatTrees/FeatTree.cpp +++ b/Code/GraphMol/Basement/FeatTrees/FeatTree.cpp @@ -75,4 +75,4 @@ FeatTreeGraphSPtr molToBaseTree(const ROMol &mol) { void baseTreeToFeatTree(FeatTreeGraph &baseTree) {} } // end of namespace FeatTrees -} +} // namespace RDKit diff --git a/Code/GraphMol/Basement/FeatTrees/FeatTreeUtils.cpp b/Code/GraphMol/Basement/FeatTrees/FeatTreeUtils.cpp index c1c6d6301..3280dda18 100644 --- a/Code/GraphMol/Basement/FeatTrees/FeatTreeUtils.cpp +++ b/Code/GraphMol/Basement/FeatTrees/FeatTreeUtils.cpp @@ -117,7 +117,7 @@ void mergeRingCycle(FeatTreeGraph &featGraph, FeatTreeGraph &featGraphCopy, } } -} // end of local utility namespace +} // namespace // ----------------------------------------------------------------------- // diff --git a/Code/GraphMol/BondIterators.cpp b/Code/GraphMol/BondIterators.cpp index 86934c494..f011853eb 100644 --- a/Code/GraphMol/BondIterators.cpp +++ b/Code/GraphMol/BondIterators.cpp @@ -110,9 +110,7 @@ bool ConstBondIterator_::operator!=(const ConstBondIterator_ &other) const { return _mol != other._mol || _pos != other._pos; } -Bond const *ConstBondIterator_::operator*() const { - return (*_mol)[*_pos]; -} +Bond const *ConstBondIterator_::operator*() const { return (*_mol)[*_pos]; } // pre-increment ConstBondIterator_ &ConstBondIterator_::operator++() { PRECONDITION(_pos != _end, "bad initial position") @@ -143,4 +141,4 @@ ConstBondIterator_ ConstBondIterator_::operator--(int) { } return res; } -} +} // namespace RDKit diff --git a/Code/GraphMol/CIPLabeler/CIPLabeler.cpp b/Code/GraphMol/CIPLabeler/CIPLabeler.cpp index 6d51d5531..08dc5f06e 100644 --- a/Code/GraphMol/CIPLabeler/CIPLabeler.cpp +++ b/Code/GraphMol/CIPLabeler/CIPLabeler.cpp @@ -41,9 +41,9 @@ const Rules constitutional_rules({new Rule1a, new Rule1b, new Rule2}); const Rules all_rules({new Rule1a, new Rule1b, new Rule2, new Rule3, new Rule4a, new Rule4b, new Rule4c, new Rule5New, new Rule6}); -std::vector> -findConfigs(CIPMol &mol, const boost::dynamic_bitset<> &atoms, - const boost::dynamic_bitset<> &bonds) { +std::vector> findConfigs( + CIPMol &mol, const boost::dynamic_bitset<> &atoms, + const boost::dynamic_bitset<> &bonds) { std::vector> configs; for (auto index = atoms.find_first(); index != boost::dynamic_bitset<>::npos; @@ -52,7 +52,6 @@ findConfigs(CIPMol &mol, const boost::dynamic_bitset<> &atoms, auto chiraltag = atom->getChiralTag(); if (chiraltag == Atom::CHI_TETRAHEDRAL_CW || chiraltag == Atom::CHI_TETRAHEDRAL_CCW) { - std::unique_ptr cfg{new Tetrahedral(mol, atom)}; configs.push_back(std::move(cfg)); } @@ -64,16 +63,16 @@ findConfigs(CIPMol &mol, const boost::dynamic_bitset<> &atoms, auto bond_cfg = Bond::STEREONONE; switch (bond->getStereo()) { - case Bond::STEREOE: - case Bond::STEREOTRANS: - bond_cfg = Bond::STEREOTRANS; - break; - case Bond::STEREOZ: - case Bond::STEREOCIS: - bond_cfg = Bond::STEREOCIS; - break; - default: - continue; + case Bond::STEREOE: + case Bond::STEREOTRANS: + bond_cfg = Bond::STEREOTRANS; + break; + case Bond::STEREOZ: + case Bond::STEREOCIS: + bond_cfg = Bond::STEREOCIS; + break; + default: + continue; } std::unique_ptr cfg(new Sp2Bond(mol, bond, bond->getBeginAtom(), @@ -105,8 +104,9 @@ bool labelAux(std::vector> &configs, if (foci.size() == 2) { for (const auto &edge : node->getEdges(foci[1])) { const auto &other_node = edge->getOther(node); - if (other_node->getDistance() < node->getDistance()) + if (other_node->getDistance() < node->getDistance()) { low = other_node; + } } } if (!low->isDuplicate()) { @@ -147,7 +147,6 @@ bool labelAux(std::vector> &configs, } void label(std::vector> &configs) { - for (const auto &conf : configs) { auto desc = conf->label(constitutional_rules); if (desc != Descriptor::UNKNOWN) { @@ -164,7 +163,7 @@ void label(std::vector> &configs) { } } -} // namespace +} // namespace void assignCIPLabels(ROMol &mol, const boost::dynamic_bitset<> &atoms, const boost::dynamic_bitset<> &bonds) { @@ -181,5 +180,5 @@ void assignCIPLabels(ROMol &mol) { assignCIPLabels(mol, atoms, bonds); } -} // namespace CIPLabeler -} // namespace RDKit +} // namespace CIPLabeler +} // namespace RDKit diff --git a/Code/GraphMol/CIPLabeler/CIPMol.cpp b/Code/GraphMol/CIPLabeler/CIPMol.cpp index 977385684..4bfee24fb 100644 --- a/Code/GraphMol/CIPLabeler/CIPMol.cpp +++ b/Code/GraphMol/CIPLabeler/CIPMol.cpp @@ -71,28 +71,28 @@ int CIPMol::getBondOrder(Bond *bond) const { // Dative bonds might need to be considered with a different bond order // for the end atom at the end of the bond. switch (kekulized_bond->getBondType()) { - case Bond::ZERO: - case Bond::HYDROGEN: - case Bond::DATIVE: - case Bond::DATIVEL: - case Bond::DATIVER: - return 0; - case Bond::SINGLE: - return 1; - case Bond::DOUBLE: - return 2; - case Bond::TRIPLE: - return 3; - case Bond::QUADRUPLE: - return 4; - case Bond::QUINTUPLE: - return 5; - case Bond::HEXTUPLE: - return 6; - default: - throw std::runtime_error("Non integer-order bonds are not allowed."); + case Bond::ZERO: + case Bond::HYDROGEN: + case Bond::DATIVE: + case Bond::DATIVEL: + case Bond::DATIVER: + return 0; + case Bond::SINGLE: + return 1; + case Bond::DOUBLE: + return 2; + case Bond::TRIPLE: + return 3; + case Bond::QUADRUPLE: + return 4; + case Bond::QUINTUPLE: + return 5; + case Bond::HEXTUPLE: + return 6; + default: + throw std::runtime_error("Non integer-order bonds are not allowed."); } }; -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/Digraph.cpp b/Code/GraphMol/CIPLabeler/Digraph.cpp index 709f9ae5a..cb11aed2f 100644 --- a/Code/GraphMol/CIPLabeler/Digraph.cpp +++ b/Code/GraphMol/CIPLabeler/Digraph.cpp @@ -32,11 +32,10 @@ const int MAX_NODE_COUNT = 100000; * Used for debugging only, 0=Infinite */ const int MAX_NODE_DIST = 0; -} // namespace +} // namespace Node &Digraph::addNode(std::vector &&visit, Atom *atom, boost::rational &&frac, int dist, int flags) { - d_nodes.emplace_back(this, std::move(visit), atom, std::move(frac), dist, flags); return d_nodes.back(); @@ -76,7 +75,6 @@ std::vector Digraph::getNodes(Atom *atom) const { auto queue = std::list({getCurrentRoot()}); for (const auto &node : queue) { - if (atom == node->getAtom()) { result.push_back(node); } @@ -108,11 +106,9 @@ void Digraph::setRule6Ref(Atom *ref) { dp_rule6Ref = ref; } * @param newroot the new root */ void Digraph::changeRoot(Node *newroot) { - std::vector toflip; auto queue = std::list({newroot}); for (const auto &node : queue) { - for (const auto &e : node->getEdges()) { if (e->isEnd(node)) { toflip.push_back(e); @@ -167,14 +163,14 @@ void Digraph::expand(Node *beg) { } } } - } else if (bond == prev) { // bond order expansion (backwards) + } else if (bond == prev) { // bond order expansion (backwards) if (dp_origin->getAtom() != nbr) { for (int i = 0; i < virtual_nodes; ++i) { auto end = beg->newBondDuplicateChild(nbrIdx, nbr); addEdge(beg, bond, end); } } - } else { // ring closures + } else { // ring closures auto end = beg->newRingDuplicateChild(nbrIdx, nbr); addEdge(beg, bond, end); @@ -199,5 +195,5 @@ void Digraph::expand(Node *beg) { } } -} // namespace CIPLabeler -} // namespace RDKit +} // namespace CIPLabeler +} // namespace RDKit diff --git a/Code/GraphMol/CIPLabeler/Edge.cpp b/Code/GraphMol/CIPLabeler/Edge.cpp index f27ceae4b..667303dc0 100644 --- a/Code/GraphMol/CIPLabeler/Edge.cpp +++ b/Code/GraphMol/CIPLabeler/Edge.cpp @@ -49,5 +49,5 @@ void Edge::setAux(Descriptor aux) { d_aux = std::move(aux); } void Edge::flip() { std::swap(dp_beg, dp_end); } -} // namespace CIPLabeler -} // namespace RDKit +} // namespace CIPLabeler +} // namespace RDKit diff --git a/Code/GraphMol/CIPLabeler/Mancude.cpp b/Code/GraphMol/CIPLabeler/Mancude.cpp index 3239e29bb..beae32a1c 100644 --- a/Code/GraphMol/CIPLabeler/Mancude.cpp +++ b/Code/GraphMol/CIPLabeler/Mancude.cpp @@ -40,19 +40,18 @@ bool SeedTypes(std::vector &types, const CIPMol &mol) { int btypes = atom->getTotalNumHs(); bool ring = false; for (const auto &bond : mol.getBonds(atom)) { - // Given the possible types we have, we only care // for single and double bonds which are in rings. switch (mol.getBondOrder(bond)) { - case 1: - btypes += 0x00000001; - break; - case 2: - btypes += 0x00000100; - break; - default: - btypes += 0x01000000; - break; + case 1: + btypes += 0x00000001; + break; + case 2: + btypes += 0x00000100; + break; + default: + btypes += 0x01000000; + break; } if (mol.isInRing(bond)) { ring = true; @@ -61,36 +60,36 @@ bool SeedTypes(std::vector &types, const CIPMol &mol) { if (ring) { int q = atom->getFormalCharge(); switch (atom->getAtomicNum()) { - case 6: // C - case 14: // Si - case 32: // Ge - if (q == 0 && btypes == 0x0102) { - types[aidx] = Type::Cv4D3; - } else if (q == -1 && btypes == 0x0003) { - types[aidx] = Type::Cv3D3Minus; - result = true; - } - break; - case 7: // N - case 15: // P - case 33: // As - if (q == 0 && btypes == 0x0101) { - types[aidx] = Type::Nv3D2; - result = true; - } else if (q == -1 && btypes == 0x0002) { - types[aidx] = Type::Nv2D2Minus; - result = true; - } else if (q == +1 && btypes == 0x0102) { - types[aidx] = Type::Nv4D3Plus; - result = true; - } - break; - case 8: // O - if (q == 1 && btypes == 0x0101) { - types[aidx] = Type::Ov3D2Plus; - result = true; - } - break; + case 6: // C + case 14: // Si + case 32: // Ge + if (q == 0 && btypes == 0x0102) { + types[aidx] = Type::Cv4D3; + } else if (q == -1 && btypes == 0x0003) { + types[aidx] = Type::Cv3D3Minus; + result = true; + } + break; + case 7: // N + case 15: // P + case 33: // As + if (q == 0 && btypes == 0x0101) { + types[aidx] = Type::Nv3D2; + result = true; + } else if (q == -1 && btypes == 0x0002) { + types[aidx] = Type::Nv2D2Minus; + result = true; + } else if (q == +1 && btypes == 0x0102) { + types[aidx] = Type::Nv4D3Plus; + result = true; + } + break; + case 8: // O + if (q == 1 && btypes == 0x0101) { + types[aidx] = Type::Ov3D2Plus; + result = true; + } + break; } } } @@ -173,7 +172,7 @@ int VisitParts(std::vector &parts, const std::vector &types, return numparts; } -} // namespace +} // namespace std::vector> calcFracAtomNums(const CIPMol &mol) { const auto num_atoms = mol.getNumAtoms(); @@ -186,7 +185,6 @@ std::vector> calcFracAtomNums(const CIPMol &mol) { // Mark all atoms which are potentially part of a resonance system. auto types = std::vector(num_atoms, Type::Other); if (SeedTypes(types, mol)) { - // Filter out atoms which cannot be resonant because // of not having the proper environment. RelaxTypes(types, mol); @@ -248,7 +246,6 @@ std::vector> calcFracAtomNums(const CIPMol &mol) { int part = resparts[j]; for (auto i = 0u; i < num_atoms; ++i) { if (parts[i] == part) { - // boost::rational does not accept 0 as denominator if (denominator == 0) { fractions[i].assign(0, 1); @@ -273,5 +270,5 @@ std::vector> calcFracAtomNums(const CIPMol &mol) { return fractions; } -} // namespace CIPLabeler -} // namespace RDKit +} // namespace CIPLabeler +} // namespace RDKit diff --git a/Code/GraphMol/CIPLabeler/Node.cpp b/Code/GraphMol/CIPLabeler/Node.cpp index bde328e34..3d2b13c77 100644 --- a/Code/GraphMol/CIPLabeler/Node.cpp +++ b/Code/GraphMol/CIPLabeler/Node.cpp @@ -37,8 +37,12 @@ Node *Node::newTerminalChild(int idx, Atom *atom, int flags) const { Node::Node(Digraph *g, std::vector &&visit, Atom *atom, boost::rational &&frac, int dist, int flags) - : dp_g{g}, dp_atom{atom}, d_dist{dist}, d_atomic_num{std::move(frac)}, - d_flags{flags}, d_visit{std::move(visit)} { + : dp_g{g}, + dp_atom{atom}, + d_dist{dist}, + d_atomic_num{std::move(frac)}, + d_flags{flags}, + d_visit{std::move(visit)} { if (d_flags & DUPLICATE) { d_edges.reserve(4); d_atomic_mass = 0.; @@ -150,5 +154,5 @@ std::vector Node::getNonTerminalOutEdges() const { return edges; } -} // namespace CIPLabeler -} // namespace RDKit +} // namespace CIPLabeler +} // namespace RDKit diff --git a/Code/GraphMol/CIPLabeler/Sort.cpp b/Code/GraphMol/CIPLabeler/Sort.cpp index 2bf70d241..79ad0fcda 100644 --- a/Code/GraphMol/CIPLabeler/Sort.cpp +++ b/Code/GraphMol/CIPLabeler/Sort.cpp @@ -69,8 +69,8 @@ int Sort::compareSubstituents(const Node *node, const Edge *a, const Edge *b, return 0; } -std::vector> -Sort::getGroups(const std::vector &sorted) const { +std::vector> Sort::getGroups( + const std::vector &sorted) const { // would be nice to have this integrated whilst sorting - may provide a // small speed increase but as most of our lists are small we take use // ugly sort then group approach @@ -89,5 +89,5 @@ Sort::getGroups(const std::vector &sorted) const { return groups; } -} // namespace CIPLabeler +} // namespace CIPLabeler } // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/Wrap/rdCIPLabeler.cpp b/Code/GraphMol/CIPLabeler/Wrap/rdCIPLabeler.cpp index 01835b108..d7b698d56 100644 --- a/Code/GraphMol/CIPLabeler/Wrap/rdCIPLabeler.cpp +++ b/Code/GraphMol/CIPLabeler/Wrap/rdCIPLabeler.cpp @@ -22,7 +22,6 @@ using RDKit::CIPLabeler::assignCIPLabels; void assignCIPLabelsWrapHelper(RDKit::ROMol &mol, const python::object &atomsToLabel, const python::object &bondsToLabel) { - auto atoms = pythonObjectToDynBitset(atomsToLabel, mol.getNumAtoms()); auto bonds = pythonObjectToDynBitset(bondsToLabel, mol.getNumBonds()); @@ -49,9 +48,9 @@ BOOST_PYTHON_MODULE(rdCIPLabeler) { std::string docString = "New implementation of Stereo assignment using a true CIP ranking"; - python::def("AssignCIPLabels", assignCIPLabelsWrapHelper, - (python::arg("mol"), - python::arg("atomsToLabel") = python::object(), - python::arg("bondsToLabel") = python::object()), - docString.c_str()); + python::def( + "AssignCIPLabels", assignCIPLabelsWrapHelper, + (python::arg("mol"), python::arg("atomsToLabel") = python::object(), + python::arg("bondsToLabel") = python::object()), + docString.c_str()); } diff --git a/Code/GraphMol/CIPLabeler/configs/Configuration.cpp b/Code/GraphMol/CIPLabeler/configs/Configuration.cpp index 3ca45bf8e..552a48fe7 100644 --- a/Code/GraphMol/CIPLabeler/configs/Configuration.cpp +++ b/Code/GraphMol/CIPLabeler/configs/Configuration.cpp @@ -83,5 +83,5 @@ Descriptor Configuration::label(Node *node, Digraph &digraph, return Descriptor::UNKNOWN; } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/configs/Sp2Bond.cpp b/Code/GraphMol/CIPLabeler/configs/Sp2Bond.cpp index f52a98754..e2f3114c9 100644 --- a/Code/GraphMol/CIPLabeler/configs/Sp2Bond.cpp +++ b/Code/GraphMol/CIPLabeler/configs/Sp2Bond.cpp @@ -35,27 +35,27 @@ Sp2Bond::Sp2Bond(const CIPMol &mol, Bond *bond, Atom *startAtom, Atom *endAtom, void Sp2Bond::setPrimaryLabel(Descriptor desc) { switch (desc) { - case Descriptor::seqTrans: - case Descriptor::E: - case Descriptor::seqCis: - case Descriptor::Z: { - auto carriers = getCarriers(); - dp_bond->setStereoAtoms(carriers[0]->getIdx(), carriers[1]->getIdx()); - dp_bond->setStereo(d_cfg); - dp_bond->setProp(common_properties::_CIPCode, to_string(desc)); - return; - } - case Descriptor::R: - case Descriptor::S: - case Descriptor::r: - case Descriptor::s: - case Descriptor::SP_4: - case Descriptor::TBPY_5: - case Descriptor::OC_6: - throw std::runtime_error( - "Received a Descriptor that is not supported for bonds"); - default: - throw std::runtime_error("Received an invalid Bond Descriptor"); + case Descriptor::seqTrans: + case Descriptor::E: + case Descriptor::seqCis: + case Descriptor::Z: { + auto carriers = getCarriers(); + dp_bond->setStereoAtoms(carriers[0]->getIdx(), carriers[1]->getIdx()); + dp_bond->setStereo(d_cfg); + dp_bond->setProp(common_properties::_CIPCode, to_string(desc)); + return; + } + case Descriptor::R: + case Descriptor::S: + case Descriptor::r: + case Descriptor::s: + case Descriptor::SP_4: + case Descriptor::TBPY_5: + case Descriptor::OC_6: + throw std::runtime_error( + "Received a Descriptor that is not supported for bonds"); + default: + throw std::runtime_error("Received an invalid Bond Descriptor"); } } @@ -134,5 +134,5 @@ Descriptor Sp2Bond::label(Node *root1, Digraph &digraph, const Rules &comp) { return Descriptor::UNKNOWN; } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/configs/Tetrahedral.cpp b/Code/GraphMol/CIPLabeler/configs/Tetrahedral.cpp index 0bf4b76eb..31d8d1548 100644 --- a/Code/GraphMol/CIPLabeler/configs/Tetrahedral.cpp +++ b/Code/GraphMol/CIPLabeler/configs/Tetrahedral.cpp @@ -44,27 +44,27 @@ Tetrahedral::Tetrahedral(const CIPMol &mol, Atom *focus) void Tetrahedral::setPrimaryLabel(Descriptor desc) { switch (desc) { - case Descriptor::R: - case Descriptor::S: - case Descriptor::r: - case Descriptor::s: - getFocus()->setProp(common_properties::_CIPCode, to_string(desc)); - return; - case Descriptor::seqTrans: - case Descriptor::seqCis: - case Descriptor::E: - case Descriptor::Z: - case Descriptor::M: - case Descriptor::P: - case Descriptor::m: - case Descriptor::p: - case Descriptor::SP_4: - case Descriptor::TBPY_5: - case Descriptor::OC_6: - throw std::runtime_error( - "Received a Descriptor that is not supported for atoms"); - default: - throw std::runtime_error("Received an invalid Atom Descriptor"); + case Descriptor::R: + case Descriptor::S: + case Descriptor::r: + case Descriptor::s: + getFocus()->setProp(common_properties::_CIPCode, to_string(desc)); + return; + case Descriptor::seqTrans: + case Descriptor::seqCis: + case Descriptor::E: + case Descriptor::Z: + case Descriptor::M: + case Descriptor::P: + case Descriptor::m: + case Descriptor::p: + case Descriptor::SP_4: + case Descriptor::TBPY_5: + case Descriptor::OC_6: + throw std::runtime_error( + "Received a Descriptor that is not supported for atoms"); + default: + throw std::runtime_error("Received an invalid Atom Descriptor"); } } @@ -177,5 +177,5 @@ Descriptor Tetrahedral::label(Node *node, const Rules &comp) const { return Descriptor::UNKNOWN; } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/rules/Rule1a.cpp b/Code/GraphMol/CIPLabeler/rules/Rule1a.cpp index ab1a8b585..8c76898a6 100644 --- a/Code/GraphMol/CIPLabeler/rules/Rule1a.cpp +++ b/Code/GraphMol/CIPLabeler/rules/Rule1a.cpp @@ -27,5 +27,5 @@ int Rule1a::compare(const Edge *a, const Edge *b) const { return three_way_comparison(afrac, bfrac); } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/rules/Rule1b.cpp b/Code/GraphMol/CIPLabeler/rules/Rule1b.cpp index 42d36b75b..710710c6e 100644 --- a/Code/GraphMol/CIPLabeler/rules/Rule1b.cpp +++ b/Code/GraphMol/CIPLabeler/rules/Rule1b.cpp @@ -39,5 +39,5 @@ int Rule1b::compare(const Edge *a, const Edge *b) const { } } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/rules/Rule2.cpp b/Code/GraphMol/CIPLabeler/rules/Rule2.cpp index eaae8f715..66b7f8488 100644 --- a/Code/GraphMol/CIPLabeler/rules/Rule2.cpp +++ b/Code/GraphMol/CIPLabeler/rules/Rule2.cpp @@ -43,5 +43,5 @@ int Rule2::compare(const Edge *a, const Edge *b) const { return three_way_comparison(aweight, bweight); } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/rules/Rule3.cpp b/Code/GraphMol/CIPLabeler/rules/Rule3.cpp index 35bb71d5b..7c2d28879 100644 --- a/Code/GraphMol/CIPLabeler/rules/Rule3.cpp +++ b/Code/GraphMol/CIPLabeler/rules/Rule3.cpp @@ -17,15 +17,15 @@ namespace CIPLabeler { namespace { int ord(Descriptor lab) { switch (lab) { - case Descriptor::E: - return 1; - case Descriptor::Z: - return 2; - default: - return 0; + case Descriptor::E: + return 1; + case Descriptor::Z: + return 2; + default: + return 0; } } -} +} // namespace Rule3::Rule3() = default; @@ -34,5 +34,5 @@ int Rule3::compare(const Edge *a, const Edge *b) const { ord(b->getEnd()->getAux())); } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/rules/Rule4a.cpp b/Code/GraphMol/CIPLabeler/rules/Rule4a.cpp index 0a3b9d5be..527750b1d 100644 --- a/Code/GraphMol/CIPLabeler/rules/Rule4a.cpp +++ b/Code/GraphMol/CIPLabeler/rules/Rule4a.cpp @@ -17,29 +17,29 @@ namespace CIPLabeler { namespace { int ord(Descriptor lab) { switch (lab) { - case Descriptor::UNKNOWN: - case Descriptor::ns: - case Descriptor::NONE: - return 0; - case Descriptor::r: - case Descriptor::s: - case Descriptor::m: - case Descriptor::p: - case Descriptor::E: - case Descriptor::Z: - return 1; - case Descriptor::R: - case Descriptor::S: - case Descriptor::M: - case Descriptor::P: - case Descriptor::seqTrans: - case Descriptor::seqCis: - return 2; - default: - throw std::logic_error("Invalid stereo descriptor"); + case Descriptor::UNKNOWN: + case Descriptor::ns: + case Descriptor::NONE: + return 0; + case Descriptor::r: + case Descriptor::s: + case Descriptor::m: + case Descriptor::p: + case Descriptor::E: + case Descriptor::Z: + return 1; + case Descriptor::R: + case Descriptor::S: + case Descriptor::M: + case Descriptor::P: + case Descriptor::seqTrans: + case Descriptor::seqCis: + return 2; + default: + throw std::logic_error("Invalid stereo descriptor"); } } -} +} // namespace Rule4a::Rule4a() = default; @@ -55,5 +55,5 @@ int Rule4a::compare(const Edge *a, const Edge *b) const { return three_way_comparison(aOrdinal, bOrdinal); } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/rules/Rule4b.cpp b/Code/GraphMol/CIPLabeler/rules/Rule4b.cpp index 0b24fce95..474956af5 100644 --- a/Code/GraphMol/CIPLabeler/rules/Rule4b.cpp +++ b/Code/GraphMol/CIPLabeler/rules/Rule4b.cpp @@ -26,8 +26,8 @@ Rule4b::Rule4b() = default; Rule4b::Rule4b(Descriptor ref) : d_ref{ref} {} -std::vector -Rule4b::getReferenceDescriptors(const Node *node) const { +std::vector Rule4b::getReferenceDescriptors( + const Node *node) const { std::vector result; auto prev = initialLevel(node); while (!prev.empty()) { @@ -103,7 +103,6 @@ bool Rule4b::hasDescriptors(const Node *node) const { auto queue = std::list({node}); for (const auto &node : queue) { - if (node->getAux() != Descriptor::NONE) { return true; } @@ -127,20 +126,20 @@ bool Rule4b::getReference(const std::vector &nodes, for (const auto &node : nodes) { auto desc = node->getAux(); switch (desc) { - case Descriptor::NONE: - continue; - case Descriptor::R: - case Descriptor::M: - case Descriptor::seqCis: - ++right; - break; - case Descriptor::S: - case Descriptor::P: - case Descriptor::seqTrans: - ++left; - break; - default: - break; + case Descriptor::NONE: + continue; + case Descriptor::R: + case Descriptor::M: + case Descriptor::seqCis: + ++right; + break; + case Descriptor::S: + case Descriptor::P: + case Descriptor::seqTrans: + ++left; + break; + default: + break; } } if (right + left == 0) { @@ -158,8 +157,8 @@ bool Rule4b::getReference(const std::vector &nodes, } } -std::vector> -Rule4b::initialLevel(const Node *node) const { +std::vector> Rule4b::initialLevel( + const Node *node) const { return {{node}}; } @@ -201,8 +200,8 @@ std::vector> Rule4b::getNextLevel( return nextLevel; } -std::vector -Rule4b::toNodeList(const std::vector &eqEdges) const { +std::vector Rule4b::toNodeList( + const std::vector &eqEdges) const { std::vector eqNodes; eqNodes.reserve(eqEdges.size()); for (const auto &edge : eqEdges) { @@ -211,8 +210,8 @@ Rule4b::toNodeList(const std::vector &eqEdges) const { return eqNodes; } -std::vector -Rule4b::newPairLists(const std::vector &descriptors) const { +std::vector Rule4b::newPairLists( + const std::vector &descriptors) const { std::vector pairs; pairs.reserve(descriptors.size()); for (Descriptor descriptor : descriptors) { @@ -227,7 +226,6 @@ void Rule4b::fillPairs(const Node *beg, PairList &plist) const { auto queue = std::list({beg}); for (const auto &node : queue) { - plist.add(node->getAux()); auto edges = node->getEdges(); sorter.prioritize(node, edges); @@ -297,5 +295,5 @@ Sort Rule4b::getRefSorter(const SequenceRule *replacement_rule) const { return {new_rules}; } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/rules/Rule4c.cpp b/Code/GraphMol/CIPLabeler/rules/Rule4c.cpp index 653654c27..e8eae881a 100644 --- a/Code/GraphMol/CIPLabeler/rules/Rule4c.cpp +++ b/Code/GraphMol/CIPLabeler/rules/Rule4c.cpp @@ -17,17 +17,17 @@ namespace CIPLabeler { namespace { int ord(Descriptor lab) { switch (lab) { - case Descriptor::m: - case Descriptor::r: - return 2; - case Descriptor::p: - case Descriptor::s: - return 1; - default: - return 0; + case Descriptor::m: + case Descriptor::r: + return 2; + case Descriptor::p: + case Descriptor::s: + return 1; + default: + return 0; } } -} +} // namespace Rule4c::Rule4c() = default; @@ -45,5 +45,5 @@ int Rule4c::compare(const Edge *a, const Edge *b) const { return three_way_comparison(aOrdinal, bOrdinal); } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/rules/Rule5.cpp b/Code/GraphMol/CIPLabeler/rules/Rule5.cpp index 93f9c8db3..7a263e844 100644 --- a/Code/GraphMol/CIPLabeler/rules/Rule5.cpp +++ b/Code/GraphMol/CIPLabeler/rules/Rule5.cpp @@ -17,19 +17,19 @@ namespace CIPLabeler { namespace { int ord(Descriptor lab) { switch (lab) { - case Descriptor::M: - case Descriptor::R: - case Descriptor::seqCis: - return 2; - case Descriptor::P: - case Descriptor::S: - case Descriptor::seqTrans: - return 1; - default: - return 0; + case Descriptor::M: + case Descriptor::R: + case Descriptor::seqCis: + return 2; + case Descriptor::P: + case Descriptor::S: + case Descriptor::seqTrans: + return 1; + default: + return 0; } } -} +} // namespace Rule5::Rule5() = default; @@ -45,5 +45,5 @@ int Rule5::compare(const Edge *a, const Edge *b) const { return 2 * three_way_comparison(aOrdinal, bOrdinal); } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/rules/Rule5New.cpp b/Code/GraphMol/CIPLabeler/rules/Rule5New.cpp index a2b5b361e..f78b95248 100644 --- a/Code/GraphMol/CIPLabeler/rules/Rule5New.cpp +++ b/Code/GraphMol/CIPLabeler/rules/Rule5New.cpp @@ -76,7 +76,6 @@ void Rule5New::fillPairs(const Node *beg, PairList &plist) const { auto queue = std::list({beg}); for (const auto &node : queue) { - plist.add(node->getAux()); auto edges = node->getEdges(); sorter.prioritize(node, edges); @@ -105,5 +104,5 @@ Sort Rule5New::getRefSorter(const SequenceRule *replacement_rule) const { return {new_rules}; } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/rules/Rule6.cpp b/Code/GraphMol/CIPLabeler/rules/Rule6.cpp index 49d90d31a..2d205be3f 100644 --- a/Code/GraphMol/CIPLabeler/rules/Rule6.cpp +++ b/Code/GraphMol/CIPLabeler/rules/Rule6.cpp @@ -27,12 +27,12 @@ int Rule6::compare(const Edge *a, const Edge *b) const { const auto &aAtom = a->getEnd()->getAtom(); const auto &bAtom = b->getEnd()->getAtom(); if (ref == aAtom && ref != bAtom) { - return +1; // a is ref (has priority) + return +1; // a is ref (has priority) } else if (ref != aAtom && ref == bAtom) { - return -1; // b is ref (has priority) + return -1; // b is ref (has priority) } return 0; } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/CIPLabeler/rules/SequenceRule.cpp b/Code/GraphMol/CIPLabeler/rules/SequenceRule.cpp index 85b17518b..38fa7cc60 100644 --- a/Code/GraphMol/CIPLabeler/rules/SequenceRule.cpp +++ b/Code/GraphMol/CIPLabeler/rules/SequenceRule.cpp @@ -165,5 +165,5 @@ bool SequenceRule::areUpEdges(Node *aNode, Node *bNode, Edge *aEdge, return false; } -} // namespace CIPLabeler -} // namespace RDKit \ No newline at end of file +} // namespace CIPLabeler +} // namespace RDKit \ No newline at end of file diff --git a/Code/GraphMol/ChemReactions/DaylightParser.cpp b/Code/GraphMol/ChemReactions/DaylightParser.cpp index 15c5ad681..b3def0330 100644 --- a/Code/GraphMol/ChemReactions/DaylightParser.cpp +++ b/Code/GraphMol/ChemReactions/DaylightParser.cpp @@ -105,7 +105,6 @@ ROMol *constructMolFromString(const std::string &txt, ChemicalReaction *RxnSmartsToChemicalReaction( const std::string &text, std::map *replacements, bool useSmiles) { - std::vector pos; for (std::size_t i = 0; i < text.length(); ++i) { @@ -194,4 +193,4 @@ ChemicalReaction *RxnSmartsToChemicalReaction( return rxn; } -} +} // namespace RDKit diff --git a/Code/GraphMol/ChemReactions/Enumerate/Enumerate.cpp b/Code/GraphMol/ChemReactions/Enumerate/Enumerate.cpp index 13d14c5c4..83591156d 100644 --- a/Code/GraphMol/ChemReactions/Enumerate/Enumerate.cpp +++ b/Code/GraphMol/ChemReactions/Enumerate/Enumerate.cpp @@ -113,7 +113,7 @@ size_t countMatches(const ROMol &bb, const ROMol &query, int maxMatches) { useQueryQueryMatches, maxMatches + 1); return matches.size(); } -} +} // namespace BBS removeNonmatchingReagents(const ChemicalReaction &rxn, BBS bbs, const EnumerationParams ¶ms) { PRECONDITION(bbs.size() <= rxn.getNumReactantTemplates(), @@ -276,4 +276,4 @@ bool EnumerateLibraryCanSerialize() { return false; #endif } -} +} // namespace RDKit diff --git a/Code/GraphMol/ChemReactions/Enumerate/EnumerationPickler.cpp b/Code/GraphMol/ChemReactions/Enumerate/EnumerationPickler.cpp index 28ecd9132..214dc1508 100644 --- a/Code/GraphMol/ChemReactions/Enumerate/EnumerationPickler.cpp +++ b/Code/GraphMol/ChemReactions/Enumerate/EnumerationPickler.cpp @@ -35,8 +35,7 @@ #include "RandomSample.h" #include "RandomSampleAllBBs.h" - -#ifdef RDK_USE_BOOST_SERIALIZATION +#ifdef RDK_USE_BOOST_SERIALIZATION #include #include #include @@ -63,19 +62,19 @@ namespace EnumerationStrategyPickler { void pickle(const boost::shared_ptr &enumerator, std::ostream &ss) { -#ifdef RDK_USE_BOOST_SERIALIZATION +#ifdef RDK_USE_BOOST_SERIALIZATION boost::archive::text_oarchive ar(ss); ar &enumerator; #else RDUNUSED_PARAM(enumerator); RDUNUSED_PARAM(ss); PRECONDITION(0, "BOOST SERIALIZATION NOT INSTALLED"); -#endif +#endif } void pickle(const boost::shared_ptr &enumerator, std::string &s) { -#ifdef RDK_USE_BOOST_SERIALIZATION +#ifdef RDK_USE_BOOST_SERIALIZATION std::stringstream ss; pickle(enumerator, ss); s = ss.str(); @@ -83,33 +82,31 @@ void pickle(const boost::shared_ptr &enumerator, RDUNUSED_PARAM(enumerator); RDUNUSED_PARAM(s); PRECONDITION(0, "BOOST SERIALIZATION NOT INSTALLED"); -#endif +#endif } boost::shared_ptr fromPickle(std::istream &pickle) { - boost::shared_ptr enumerator; -#ifdef RDK_USE_BOOST_SERIALIZATION + boost::shared_ptr enumerator; +#ifdef RDK_USE_BOOST_SERIALIZATION boost::archive::text_iarchive ar(pickle); ar &enumerator; - return enumerator; + return enumerator; #else RDUNUSED_PARAM(pickle); PRECONDITION(0, "BOOST SERIALIZATION NOT INSTALLED"); #endif - } boost::shared_ptr fromPickle( const std::string &pickle) { -#ifdef RDK_USE_BOOST_SERIALIZATION +#ifdef RDK_USE_BOOST_SERIALIZATION std::stringstream ss(pickle); return fromPickle(ss); #else RDUNUSED_PARAM(pickle); PRECONDITION(0, "BOOST SERIALIZATION NOT INSTALLED"); return boost::shared_ptr(); -#endif - -} -} +#endif } +} // namespace EnumerationStrategyPickler +} // namespace RDKit diff --git a/Code/GraphMol/ChemReactions/MoleculeParser.cpp b/Code/GraphMol/ChemReactions/MoleculeParser.cpp index 45050a7bf..108f221a4 100644 --- a/Code/GraphMol/ChemReactions/MoleculeParser.cpp +++ b/Code/GraphMol/ChemReactions/MoleculeParser.cpp @@ -64,7 +64,7 @@ int getRXNRoleOfMolecule(const RDKit::ROMol &mol) { } return -1; } -} +} // namespace namespace RDKit { @@ -100,4 +100,4 @@ ChemicalReaction *RxnMolToChemicalReaction(const ROMol &mol) { } return rxn; } -} +} // namespace RDKit diff --git a/Code/GraphMol/ChemReactions/PreprocessRxn.cpp b/Code/GraphMol/ChemReactions/PreprocessRxn.cpp index 087f2758f..fe2b888ba 100644 --- a/Code/GraphMol/ChemReactions/PreprocessRxn.cpp +++ b/Code/GraphMol/ChemReactions/PreprocessRxn.cpp @@ -83,4 +83,4 @@ bool preprocessReaction( return false; } -} +} // namespace RDKit diff --git a/Code/GraphMol/ChemTransforms/MolFragmenter.h b/Code/GraphMol/ChemTransforms/MolFragmenter.h index 00685486d..be13cd5ab 100644 --- a/Code/GraphMol/ChemTransforms/MolFragmenter.h +++ b/Code/GraphMol/ChemTransforms/MolFragmenter.h @@ -101,12 +101,7 @@ RDKIT_CHEMTRANSFORMS_EXPORT void constructBRICSBondTypes( std::vector &defs); } // namespace MolFragmenter -enum class MolzipLabel { - AtomMapNumber, - Isotope, - FragmentOnBonds, - AtomType -}; +enum class MolzipLabel { AtomMapNumber, Isotope, FragmentOnBonds, AtomType }; struct RDKIT_CHEMTRANSFORMS_EXPORT MolzipParams { MolzipLabel label = MolzipLabel::AtomMapNumber; diff --git a/Code/GraphMol/ChemTransforms/catch_tests.cpp b/Code/GraphMol/ChemTransforms/catch_tests.cpp index 0aaf4b518..490f5fdfd 100644 --- a/Code/GraphMol/ChemTransforms/catch_tests.cpp +++ b/Code/GraphMol/ChemTransforms/catch_tests.cpp @@ -57,29 +57,29 @@ TEST_CASE("Github #1039", "[]") { CHECK(MolToSmiles(*pieces) == "*C.[1*]C(O)(F)Cl"); } SECTION("bond stereo") { - auto m = "O/C=N/C=C"_smiles; - std::vector> dummyLabels{{1,1}}; - std::vector bonds{0}; - auto resa = RDKit::MolFragmenter::fragmentOnBonds(*m, bonds); - CHECK(MolToSmiles(*resa) == "*/C=N/C=C.[1*]O"); - // make sure we still have stereo atoms - std::vector> expected_stereo_atoms { + auto m = "O/C=N/C=C"_smiles; + std::vector> dummyLabels{{1, 1}}; + std::vector bonds{0}; + auto resa = RDKit::MolFragmenter::fragmentOnBonds(*m, bonds); + CHECK(MolToSmiles(*resa) == "*/C=N/C=C.[1*]O"); + // make sure we still have stereo atoms + std::vector> expected_stereo_atoms { {5,3}, // 5 is the new dummy atom, it was 0 before {}, {}, {}, {}, - }; - std::vector> received_stereo; - for(auto *bond: resa->bonds()) { - received_stereo.push_back(bond->getStereoAtoms()); - } - CHECK(received_stereo==expected_stereo_atoms); - delete resa; + }; + std::vector> received_stereo; + for (auto *bond : resa->bonds()) { + received_stereo.push_back(bond->getStereoAtoms()); + } + CHECK(received_stereo == expected_stereo_atoms); + delete resa; } - { // break non stereo atom bond - auto m = "C/C(O)=N/C=C"_smiles; - std::vector> dummyLabels{{1,1}}; + { // break non stereo atom bond + auto m = "C/C(O)=N/C=C"_smiles; + std::vector> dummyLabels{{1, 1}}; std::vector bonds{0}; auto resa = RDKit::MolFragmenter::fragmentOnBonds(*m, bonds); CHECK(MolToSmiles(*resa) == "*/C(O)=N/C=C.[1*]C"); @@ -93,22 +93,22 @@ TEST_CASE("Github #1039", "[]") { {} }; std::vector> received_stereo; - for(auto *bond: resa->bonds()) { + for (auto *bond : resa->bonds()) { received_stereo.push_back(bond->getStereoAtoms()); } - CHECK(received_stereo==expected_stereo_atoms); + CHECK(received_stereo == expected_stereo_atoms); delete resa; } { // bond stereo should only be removed when deleting the double bond with E/Z - auto m = "O/C=N/C=C"_smiles; - std::vector> dummyLabels{{1,1}}; + auto m = "O/C=N/C=C"_smiles; + std::vector> dummyLabels{{1, 1}}; std::vector expected = { "*/C=N/C=C.[1*]O", "[1*]=NC=C.[2*]=CO", // bond stereo gone "[2*]C=C.[3*]/N=C/O", "[3*]=C.[4*]=C/N=C/O" }; - for(unsigned int i=0;igetNumBonds();++i) { + for (unsigned int i = 0; i < m->getNumBonds(); ++i) { std::vector bonds{i}; auto resa = RDKit::MolFragmenter::fragmentOnBonds(*m, bonds); auto smiles = MolToSmiles(*resa); @@ -118,8 +118,8 @@ TEST_CASE("Github #1039", "[]") { } { // bond stereo should only be removed when deleting the double bond with E/Z // chiral stereo should stay - auto m = "O/C=N/[C@H](I)F"_smiles; - std::vector> dummyLabels{{1,1}}; + auto m = "O/C=N/[C@H](I)F"_smiles; + std::vector> dummyLabels{{1, 1}}; std::vector expected = { "*/C=N/[C@@H](F)I.[1*]O", "[1*]=N[C@@H](F)I.[2*]=CO", // bond stereo gone @@ -127,7 +127,7 @@ TEST_CASE("Github #1039", "[]") { "[3*]I.[4*][C@H](F)/N=C/O", "[3*]F.[5*][C@@H](I)/N=C/O" }; - for(unsigned int i=0;igetNumBonds();++i) { + for (unsigned int i = 0; i < m->getNumBonds(); ++i) { std::vector bonds{i}; auto resa = RDKit::MolFragmenter::fragmentOnBonds(*m, bonds); auto smiles = MolToSmiles(*resa); @@ -138,234 +138,240 @@ TEST_CASE("Github #1039", "[]") { } TEST_CASE("molzip", "[]") { - SECTION("basic tests") - { - auto a = "C[*:1]"_smiles; - auto b = "N[*:1]"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "CN"); - } - { - // 0 isotopes aren't mapped - auto a = "C[*]"_smiles; - auto b = "N[*]"_smiles; - MolzipParams p; - auto mol = molzip(*a,*b,p); - CHECK(MolToSmiles(*mol) == "*C.*N"); - } - { - // 0 isotopes aren't mapped - auto a = "C[*]"_smiles; - auto b = "N[*]"_smiles; - MolzipParams p; - p.label = MolzipLabel::Isotope; - auto mol = molzip(*a,*b,p); - CHECK(MolToSmiles(*mol) == "*C.*N"); - } - { - // 0 isotopes aren't mapped - auto a = "C[1*]"_smiles; - auto b = "N[1*]"_smiles; - MolzipParams p; - p.label = MolzipLabel::Isotope; - auto mol = molzip(*a,*b,p); - CHECK(MolToSmiles(*mol) == "CN"); - } - { - auto a = "[C@H](Br)([*:1])F"_smiles; - auto b = "[*:1]N"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "N[C@@H](F)Br"); - } - { - auto b = "[C@H](Br)([*:1])F"_smiles; - auto a = "[*:1]N"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "N[C@@H](F)Br"); - } - { - auto a = "[C@H]([*:1])(Br)F"_smiles; - auto b = "[*:1]N"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "N[C@H](F)Br"); - } - - { - auto b = "[C@H]([*:1])(Br)F"_smiles; - auto a = "[*:1]N"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "N[C@H](F)Br"); - } - - { - auto a = "[C@H]([*:1])(F)([*:2])"_smiles; - auto b = "[*:1]N.[*:2]I"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "N[C@@H](F)I"); - } - - { - auto b = "[C@H]([*:1])(F)([*:2])"_smiles; - auto a = "[*:1]N.[*:2]I"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "N[C@@H](F)I"); - } - - { - auto a = "[C@H]([Xe])(F)([V])"_smiles; - auto b = "[Xe]N.[V]I"_smiles; - MolzipParams params; - params.label = MolzipLabel::AtomType; - params.atomSymbols = {"Xe", "V"}; - auto mol = molzip(*a,*b, params); - CHECK(MolToSmiles(*mol) == "N[C@@H](F)I"); - } - - { - auto m = "OOO[C@](F)(I)N"_smiles; - std::vector> dummyLabels{{1,1}, {2,2}}; - for(unsigned int i=0;igetNumBonds();++i) { - for(unsigned int j=0;jgetNumBonds();++j) { - if(i!=j) { - std::vector bonds{i,j}; - auto resa = RDKit::MolFragmenter::fragmentOnBonds(*m, bonds); - MolzipParams p; - p.label = MolzipLabel::FragmentOnBonds; - CHECK(MolToSmiles(*molzip(*resa,p)) == MolToSmiles(*m)); - delete resa; - // Now try using atom labels - auto res = RDKit::MolFragmenter::fragmentOnBonds(*m, bonds, true, &dummyLabels); - for(auto *atom : res->atoms()) { - if(atom->getIsotope()) { - atom->setAtomMapNum(atom->getIsotope()); - } - } - CHECK(MolToSmiles(*molzip(*res)) == MolToSmiles(*m)); - delete res; - } - } - } - } - - SECTION("test bond stereo") - { - auto a = "F/C=C/[*:1]"_smiles; - auto b = "[*:1]F"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "F/C=C/F"); - } - { - auto b = "F/C=C/[*:1]"_smiles; - auto a = "[*:1]F"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "F/C=C/F"); - } - - { - auto a = "O/C=N/[*:1]"_smiles; - auto b = "[*:1]C=C"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); - } - { - auto b = "O/C=N/[*:1]"_smiles; - auto a = "[*:1]C=C"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); - } - - { - auto a = "C=C/N=C/[*:1]"_smiles; - auto b = "O[*:1]"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); - } - - { - auto b = "C=C/N=C/[*:1]"_smiles; - auto a = "O[*:1]"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); - } - { - auto a = "C=C[*:1]"_smiles; - auto b = "O/C=N/[*:1]"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); - } - { - auto b = "C=C[*:1]"_smiles; - auto a = "O/C=N/[*:1]"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); - } - - { - auto a = "C=C[*:1].O/C=N/[*:1]"_smiles; - auto mol = molzip(*a); - CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); - } - { // test single mol isotope labels - auto a = "C=C[1*].O/C=N/[1*]"_smiles; - MolzipParams p; - p.label = MolzipLabel::Isotope; - auto mol = molzip(*a,p); - CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); - } - { - // double bondd stereo not handled - //auto m = "O/C=N/C=C/F"_smiles; - auto m = "O/C=N/C=C"_smiles; - std::vector> dummyLabels{{1,1}}; - for(unsigned int i=0;igetNumBonds();++i) { - std::vector bonds{i}; - { - std::unique_ptr resa{RDKit::MolFragmenter::fragmentOnBonds(*m, bonds)}; - auto smiles = MolToSmiles(*resa); - - 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)); - } - { - // Now try using atom labels - std::unique_ptr res{RDKit::MolFragmenter::fragmentOnBonds(*m, bonds, true, &dummyLabels)}; - auto smiles = MolToSmiles(*res); - - 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()); - } - } - - CHECK(MolToSmiles(*molzip(*res)) == MolToSmiles(*m)); + SECTION("basic tests") { + auto a = "C[*:1]"_smiles; + auto b = "N[*:1]"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "CN"); + } + { + // 0 isotopes aren't mapped + auto a = "C[*]"_smiles; + auto b = "N[*]"_smiles; + MolzipParams p; + auto mol = molzip(*a, *b, p); + CHECK(MolToSmiles(*mol) == "*C.*N"); + } + { + // 0 isotopes aren't mapped + auto a = "C[*]"_smiles; + auto b = "N[*]"_smiles; + MolzipParams p; + p.label = MolzipLabel::Isotope; + auto mol = molzip(*a, *b, p); + CHECK(MolToSmiles(*mol) == "*C.*N"); + } + { + // 0 isotopes aren't mapped + auto a = "C[1*]"_smiles; + auto b = "N[1*]"_smiles; + MolzipParams p; + p.label = MolzipLabel::Isotope; + auto mol = molzip(*a, *b, p); + CHECK(MolToSmiles(*mol) == "CN"); + } + { + auto a = "[C@H](Br)([*:1])F"_smiles; + auto b = "[*:1]N"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "N[C@@H](F)Br"); + } + { + auto b = "[C@H](Br)([*:1])F"_smiles; + auto a = "[*:1]N"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "N[C@@H](F)Br"); + } + { + auto a = "[C@H]([*:1])(Br)F"_smiles; + auto b = "[*:1]N"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "N[C@H](F)Br"); + } + + { + auto b = "[C@H]([*:1])(Br)F"_smiles; + auto a = "[*:1]N"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "N[C@H](F)Br"); + } + + { + auto a = "[C@H]([*:1])(F)([*:2])"_smiles; + auto b = "[*:1]N.[*:2]I"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "N[C@@H](F)I"); + } + + { + auto b = "[C@H]([*:1])(F)([*:2])"_smiles; + auto a = "[*:1]N.[*:2]I"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "N[C@@H](F)I"); + } + + { + auto a = "[C@H]([Xe])(F)([V])"_smiles; + auto b = "[Xe]N.[V]I"_smiles; + MolzipParams params; + params.label = MolzipLabel::AtomType; + params.atomSymbols = {"Xe", "V"}; + auto mol = molzip(*a, *b, params); + CHECK(MolToSmiles(*mol) == "N[C@@H](F)I"); + } + + { + auto m = "OOO[C@](F)(I)N"_smiles; + std::vector> dummyLabels{{1, 1}, + {2, 2}}; + for (unsigned int i = 0; i < m->getNumBonds(); ++i) { + for (unsigned int j = 0; j < m->getNumBonds(); ++j) { + if (i != j) { + std::vector bonds{i, j}; + auto resa = RDKit::MolFragmenter::fragmentOnBonds(*m, bonds); + MolzipParams p; + p.label = MolzipLabel::FragmentOnBonds; + CHECK(MolToSmiles(*molzip(*resa, p)) == MolToSmiles(*m)); + delete resa; + // Now try using atom labels + auto res = RDKit::MolFragmenter::fragmentOnBonds(*m, bonds, true, + &dummyLabels); + for (auto *atom : res->atoms()) { + if (atom->getIsotope()) { + atom->setAtomMapNum(atom->getIsotope()); } } - } - SECTION("unzippable molecules") { - auto a = "C[*:1]"_smiles; - auto b = "N[*:2]"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "C[*:1].N[*:2]"); - } - { - auto a = "[*:2]OC[*:1]"_smiles; - auto b = "N[*:1]"_smiles; - auto mol = molzip(*a,*b); - CHECK(MolToSmiles(*mol) == "NCO[*:2]"); - } - { - auto a = "[*:1]OC[*:1]"_smiles; - auto b = "N[*:1]"_smiles; - bool caught = false; - try { - auto mol = molzip(*a,*b); - } catch (Invar::Invariant &e) { - CHECK(e.toUserString().find("molzip: bond info already exists for end atom with label:1") != std::string::npos); - caught = true; + CHECK(MolToSmiles(*molzip(*res)) == MolToSmiles(*m)); + delete res; } - CHECK(caught==true); + } } + } + + SECTION("test bond stereo") { + auto a = "F/C=C/[*:1]"_smiles; + auto b = "[*:1]F"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "F/C=C/F"); + } + { + auto b = "F/C=C/[*:1]"_smiles; + auto a = "[*:1]F"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "F/C=C/F"); + } + + { + auto a = "O/C=N/[*:1]"_smiles; + auto b = "[*:1]C=C"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); + } + { + auto b = "O/C=N/[*:1]"_smiles; + auto a = "[*:1]C=C"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); + } + + { + auto a = "C=C/N=C/[*:1]"_smiles; + auto b = "O[*:1]"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); + } + + { + auto b = "C=C/N=C/[*:1]"_smiles; + auto a = "O[*:1]"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); + } + { + auto a = "C=C[*:1]"_smiles; + auto b = "O/C=N/[*:1]"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); + } + { + auto b = "C=C[*:1]"_smiles; + auto a = "O/C=N/[*:1]"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); + } + + { + auto a = "C=C[*:1].O/C=N/[*:1]"_smiles; + auto mol = molzip(*a); + CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); + } + { // test single mol isotope labels + auto a = "C=C[1*].O/C=N/[1*]"_smiles; + MolzipParams p; + p.label = MolzipLabel::Isotope; + auto mol = molzip(*a, p); + CHECK(MolToSmiles(*mol) == "C=C/N=C/O"); + } + { + // double bondd stereo not handled + // auto m = "O/C=N/C=C/F"_smiles; + auto m = "O/C=N/C=C"_smiles; + std::vector> dummyLabels{{1, 1}}; + for (unsigned int i = 0; i < m->getNumBonds(); ++i) { + std::vector bonds{i}; + { + std::unique_ptr resa{ + RDKit::MolFragmenter::fragmentOnBonds(*m, bonds)}; + auto smiles = MolToSmiles(*resa); + + 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)); + } + { + // Now try using atom labels + std::unique_ptr res{RDKit::MolFragmenter::fragmentOnBonds( + *m, bonds, true, &dummyLabels)}; + auto smiles = MolToSmiles(*res); + + 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()); + } + } + + CHECK(MolToSmiles(*molzip(*res)) == MolToSmiles(*m)); + } + } + } + SECTION("unzippable molecules") { + auto a = "C[*:1]"_smiles; + auto b = "N[*:2]"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "C[*:1].N[*:2]"); + } + { + auto a = "[*:2]OC[*:1]"_smiles; + auto b = "N[*:1]"_smiles; + auto mol = molzip(*a, *b); + CHECK(MolToSmiles(*mol) == "NCO[*:2]"); + } + { + auto a = "[*:1]OC[*:1]"_smiles; + auto b = "N[*:1]"_smiles; + bool caught = false; + try { + auto mol = molzip(*a, *b); + } catch (Invar::Invariant &e) { + CHECK(e.toUserString().find( + "molzip: bond info already exists for end atom with label:1") != + std::string::npos); + caught = true; + } + CHECK(caught == true); + } } diff --git a/Code/GraphMol/Depictor/Basement/Depictor.cpp b/Code/GraphMol/Depictor/Basement/Depictor.cpp index a1ede0a59..067d7cd90 100644 --- a/Code/GraphMol/Depictor/Basement/Depictor.cpp +++ b/Code/GraphMol/Depictor/Basement/Depictor.cpp @@ -45,4 +45,4 @@ int Add2DCoordsToMol(ROMol &mol, bool useDLL) { #endif return res; } -} +} // namespace RDKit diff --git a/Code/GraphMol/Depictor/Basement/DepictorDLL.cpp b/Code/GraphMol/Depictor/Basement/DepictorDLL.cpp index ceb282517..94ce0d327 100644 --- a/Code/GraphMol/Depictor/Basement/DepictorDLL.cpp +++ b/Code/GraphMol/Depictor/Basement/DepictorDLL.cpp @@ -139,4 +139,4 @@ int Add2DCoordsToMolDLL(ROMol &mol, std::string tempFilename) { } #endif -} +} // namespace RDKit diff --git a/Code/GraphMol/Descriptors/BCUT.cpp b/Code/GraphMol/Descriptors/BCUT.cpp index a0b23a5d7..defd81be1 100644 --- a/Code/GraphMol/Descriptors/BCUT.cpp +++ b/Code/GraphMol/Descriptors/BCUT.cpp @@ -18,79 +18,83 @@ namespace RDKit { namespace Descriptors { - // diagonal elements are a property (atomic num, charge, etc) - // off diagonal are 1/sqrt(bond_order) - // Original burden matrix was .1, .2, .3, .15 for single,double,triple or aromatic - // all other elements are .001 +// diagonal elements are a property (atomic num, charge, etc) +// off diagonal are 1/sqrt(bond_order) +// Original burden matrix was .1, .2, .3, .15 for single,double,triple or +// aromatic all other elements are .001 namespace { -std::unique_ptr make_burden(const ROMol &m) { +std::unique_ptr make_burden(const ROMol &m) { auto num_atoms = m.getNumAtoms(); std::unique_ptr burden( - new Eigen::MatrixXd(num_atoms, num_atoms)); - - for(unsigned int i=0;igetBeginAtomIdx(); unsigned int j = bond->getEndAtomIdx(); double score = 0.0; - switch(bond->getBondType()) { - case Bond::AROMATIC: - // score = 0.15; orig burden - score = 0.8164965809277261; // 1/sqrt(1.5) - break; - case Bond::SINGLE: - // score = 0.1; - score = 1.0; // 1/sqrt(1.0) - break; - case Bond::DOUBLE: - // score = 0.2; - score = 0.7071067811865475; // 1/sqrt(2.0) - break; - case Bond::TRIPLE: - // score = 0.3; - score = 0.5773502691896258; // 1/sqrt(3); - break; - default: - CHECK_INVARIANT(0, "Bond order must be Single, Double, Triple or Aromatic"); + switch (bond->getBondType()) { + case Bond::AROMATIC: + // score = 0.15; orig burden + score = 0.8164965809277261; // 1/sqrt(1.5) + break; + case Bond::SINGLE: + // score = 0.1; + score = 1.0; // 1/sqrt(1.0) + break; + case Bond::DOUBLE: + // score = 0.2; + score = 0.7071067811865475; // 1/sqrt(2.0) + break; + case Bond::TRIPLE: + // score = 0.3; + score = 0.5773502691896258; // 1/sqrt(3); + break; + default: + CHECK_INVARIANT( + 0, "Bond order must be Single, Double, Triple or Aromatic"); } - (*burden)(i,j) = (*burden)(j,i) = score; - } + (*burden)(i, j) = (*burden)(j, i) = score; + } return burden; } - -std::pair BCUT2D(std::unique_ptr &burden, - const std::vector &atom_props) { - for(unsigned int i=0; i BCUT2D(std::unique_ptr &burden, + const std::vector &atom_props) { + for (unsigned int i = 0; i < atom_props.size(); ++i) { + (*burden)(i, i) = atom_props[i]; } Eigen::SelfAdjointEigenSolver es(*burden); auto eivals = es.eigenvalues(); double lowest = eivals(0); - double highest = eivals(atom_props.size()-1); - return std::pair(highest,lowest); + double highest = eivals(atom_props.size() - 1); + return std::pair(highest, lowest); } -} - -std::pair BCUT2D(const ROMol &m, const std::vector &atom_props) { +} // namespace + +std::pair BCUT2D(const ROMol &m, + const std::vector &atom_props) { unsigned int num_atoms = m.getNumAtoms(); - PRECONDITION(atom_props.size() == num_atoms, "Number of atom props not equal to number of atoms"); - + PRECONDITION(atom_props.size() == num_atoms, + "Number of atom props not equal to number of atoms"); + if (num_atoms == 0) { - return std::pair(0,0); + return std::pair(0, 0); } auto burden = make_burden(m); return BCUT2D(burden, atom_props); } - -std::pair BCUT2D(const ROMol &m, const std::string &atom_double_prop) { + +std::pair BCUT2D(const ROMol &m, + const std::string &atom_double_prop) { std::vector props; props.reserve(m.getNumAtoms()); - for(auto &atom : m.atoms()) { + for (auto &atom : m.atoms()) { props.push_back(atom->getProp(atom_double_prop)); } return BCUT2D(m, props); @@ -105,15 +109,16 @@ std::vector BCUT2D(const ROMol &m) { charges.reserve(num_atoms); RDKit::computeGasteigerCharges(*mol, 12, true); - for(auto &atom: mol->atoms()) { + for (auto &atom : mol->atoms()) { masses.push_back(atom->getMass()); - charges.push_back(atom->getProp(common_properties::_GasteigerCharge)); + charges.push_back( + atom->getProp(common_properties::_GasteigerCharge)); } - + std::vector slogp(num_atoms, 0.0); std::vector cmr(num_atoms, 0.0); getCrippenAtomContribs(*mol, slogp, cmr); - + // polarizability? - need model // slogp? sasa? auto burden = make_burden(m); @@ -121,14 +126,12 @@ std::vector BCUT2D(const ROMol &m) { auto gasteiger = BCUT2D(burden, charges); auto logp = BCUT2D(burden, slogp); auto mr = BCUT2D(burden, cmr); - std::vector res = {atom_bcut.first, atom_bcut.second, - gasteiger.first, gasteiger.second, - logp.first, logp.second, - mr.first, mr.second - }; + std::vector res = { + atom_bcut.first, atom_bcut.second, gasteiger.first, gasteiger.second, + logp.first, logp.second, mr.first, mr.second}; return res; } -} -} +} // namespace Descriptors +} // namespace RDKit #endif diff --git a/Code/GraphMol/Descriptors/CoulombMat.cpp b/Code/GraphMol/Descriptors/CoulombMat.cpp index 8c9302f5c..0d6fcc401 100644 --- a/Code/GraphMol/Descriptors/CoulombMat.cpp +++ b/Code/GraphMol/Descriptors/CoulombMat.cpp @@ -35,7 +35,8 @@ namespace RDKit { namespace Descriptors { -void CoulombMat(const ROMol &mol, std::vector> &res, int confId) { +void CoulombMat(const ROMol &mol, std::vector> &res, + int confId) { PRECONDITION(mol.getNumConformers() >= 1, "molecule has no conformers"); unsigned int numAtoms = mol.getNumAtoms(); @@ -43,17 +44,17 @@ void CoulombMat(const ROMol &mol, std::vector> &res, int co const auto conf = mol.getConformer(confId); res.resize(numAtoms); - for(unsigned int i=0;igetAtomicNum(); - res[i][i] = 0.5 * pow(Zi,2.4); + res[i][i] = 0.5 * pow(Zi, 2.4); const auto Pi = conf.getAtomPos(i); - for(unsigned int j=0;jgetAtomicNum(); - res[i][j] = res[j][i] = Zi*Zj / (Pi-Pj).length(); + res[i][j] = res[j][i] = Zi * Zj / (Pi - Pj).length(); } } } diff --git a/Code/GraphMol/Descriptors/Crippen.cpp b/Code/GraphMol/Descriptors/Crippen.cpp index 075adfeb2..1ef523cb7 100644 --- a/Code/GraphMol/Descriptors/Crippen.cpp +++ b/Code/GraphMol/Descriptors/Crippen.cpp @@ -21,7 +21,7 @@ #include #include #include -typedef boost::tokenizer > tokenizer; +typedef boost::tokenizer> tokenizer; #include #include @@ -121,22 +121,22 @@ void calcCrippenDescriptors(const ROMol &mol, double &logp, double &mr, mol.setProp(common_properties::_crippenMR, mr, true); }; - double calcClogP(const ROMol &mol) { - double clogp,mr; + double clogp, mr; calcCrippenDescriptors(mol, clogp, mr); return clogp; } double calcMR(const ROMol &mol) { - double clogp,mr; + double clogp, mr; calcCrippenDescriptors(mol, clogp, mr); return mr; } typedef boost::flyweight< boost::flyweights::key_value, - boost::flyweights::no_tracking> param_flyweight; + boost::flyweights::no_tracking> + param_flyweight; const CrippenParamCollection *CrippenParamCollection::getParams( const std::string ¶mData) { @@ -320,4 +320,4 @@ const std::string defaultParamData = "Me2 [#72,#73,#74,#75,#76,#77,#78,#79,#80] -0.0025 \n"; } // end of namespace Descriptors -} +} // namespace RDKit diff --git a/Code/GraphMol/Descriptors/EEM.cpp b/Code/GraphMol/Descriptors/EEM.cpp index 8aafaf935..c576eae23 100644 --- a/Code/GraphMol/Descriptors/EEM.cpp +++ b/Code/GraphMol/Descriptors/EEM.cpp @@ -122,7 +122,7 @@ unsigned int getAtomtype(const ROMol &mol, const RDKit::Atom *atom) { } std::unique_ptr getEEMMatrix(double *dist3D, unsigned int n, - const EEM_arrays& EEMatoms) { + const EEM_arrays &EEMatoms) { PRECONDITION(dist3D != nullptr, "bad dist3D argument") int sizeArray = (n + 1) * (n + 1); auto *EEM = @@ -201,7 +201,7 @@ EEM_arrays::~EEM_arrays() { /* Calculate charges for a particular kappa_data structure */ void calculate_charges(ROMol mol, double *dist3D, unsigned int numAtoms, - const EEM_arrays& EEMatoms, std::vector &res) { + const EEM_arrays &EEMatoms, std::vector &res) { std::unique_ptr A = getEEMMatrix(dist3D, numAtoms, EEMatoms); std::unique_ptr b = getBVector(mol, numAtoms, EEMatoms); diff --git a/Code/GraphMol/Descriptors/test.cpp b/Code/GraphMol/Descriptors/test.cpp index 11dff61ca..c450bed0a 100644 --- a/Code/GraphMol/Descriptors/test.cpp +++ b/Code/GraphMol/Descriptors/test.cpp @@ -1883,7 +1883,7 @@ void testProperties() { std::vector props = sink.computeProperties(*mol); std::vector res; - for (const auto& prop : all_names) { + for (const auto &prop : all_names) { std::vector props; props.push_back(prop); Properties property(props); diff --git a/Code/GraphMol/Descriptors/testATF.cpp b/Code/GraphMol/Descriptors/testATF.cpp index f30dfacda..892d20dfe 100644 --- a/Code/GraphMol/Descriptors/testATF.cpp +++ b/Code/GraphMol/Descriptors/testATF.cpp @@ -27,155 +27,142 @@ using namespace RDKit; void test1() { - - auto m = "CO"_smiles; + auto m = "CO"_smiles; - TEST_ASSERT(m); - - std::vector res; + TEST_ASSERT(m); - int atomid = 0; - RDKit::Descriptors::AtomFeatVect(*m, res, atomid); + std::vector res; - std::vector exp{ 0. , 1. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , + int atomid = 0; + RDKit::Descriptors::AtomFeatVect(*m, res, atomid); + + std::vector exp{ 0. , 1. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. , 0. , 0. , 0. , 0. , 0. , 1. , 0. , 0. , 0. , 0. , 1. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. , 0. , 0.5}; - // 49 features - TEST_ASSERT(res.size() == 49); + // 49 features + TEST_ASSERT(res.size() == 49); - for (std::size_t i = 0; i < res.size() ; i++) { - TEST_ASSERT(fabs( res[i]-exp[i])< 0.001); - //std::cout << res[i] << "," ; - } - - - + for (std::size_t i = 0; i < res.size(); i++) { + TEST_ASSERT(fabs(res[i] - exp[i]) < 0.001); + // std::cout << res[i] << "," ; + } } void test2() { - - auto m = "C1CC=C1[NH3+]"_smiles; + auto m = "C1CC=C1[NH3+]"_smiles; - TEST_ASSERT(m); - - std::vector res; + TEST_ASSERT(m); - std::vector molatf{ 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0.2, + std::vector res; + + std::vector molatf{ 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0.2, 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0.2, 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0.2, 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0.2, 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0.2}; + for (unsigned int j = 0; j < m->getNumAtoms(); j++) { + RDKit::Descriptors::AtomFeatVect(*m, res, j); - for (unsigned int j=0; j< m->getNumAtoms(); j++) { + // 49 features + TEST_ASSERT(res.size() == 49); - RDKit::Descriptors::AtomFeatVect(*m, res, j); - - // 49 features - TEST_ASSERT(res.size() == 49); - - for (std::size_t i = 0; i < res.size() ; i++) { - TEST_ASSERT(fabs( res[i]-molatf[i+j*49])< 0.001); - } - - res.clear(); - res.resize(49); + for (std::size_t i = 0; i < res.size(); i++) { + TEST_ASSERT(fabs(res[i] - molatf[i + j * 49]) < 0.001); } - + + res.clear(); + res.resize(49); + } } void test3() { - - auto m = "O[C@H](F)[C@H](F)O"_smiles; + auto m = "O[C@H](F)[C@H](F)O"_smiles; - TEST_ASSERT(m); + TEST_ASSERT(m); - std::vector molatf{ 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667, + std::vector molatf{ 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667, 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667, 0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0.166667, 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667, 0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0.166667, 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667}; - std::vector res; + std::vector res; - for (unsigned int j=0; j< m->getNumAtoms(); j++) { + for (unsigned int j = 0; j < m->getNumAtoms(); j++) { + RDKit::Descriptors::AtomFeatVect(*m, res, j); - RDKit::Descriptors::AtomFeatVect(*m, res, j); + // 49 features + TEST_ASSERT(res.size() == 49); - - // 49 features - TEST_ASSERT(res.size() == 49); - - for (std::size_t i = 0; i < res.size() ; i++) { - TEST_ASSERT(fabs( res[i]-molatf[i+j*49])< 0.001); - } - - res.clear(); - res.resize(49); + for (std::size_t i = 0; i < res.size(); i++) { + TEST_ASSERT(fabs(res[i] - molatf[i + j * 49]) < 0.001); } + + res.clear(); + res.resize(49); + } } void test4() { - - auto m = "O[C@H](F)[C@H](F)O"_smiles; + auto m = "O[C@H](F)[C@H](F)O"_smiles; - TEST_ASSERT(m); - - std::vector res; + TEST_ASSERT(m); - std::vector molatf{ 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667,0,0,0, + std::vector res; + + std::vector molatf{ 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667,0,0,0, 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667,0,1,0, 0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0.166667,0,0,0, 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667,0,1,0, 0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0.166667,0,0,0, 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667,0,0,0}; - for (unsigned int j=0; j< m->getNumAtoms(); j++) { - RDKit::Descriptors::AtomFeatVect(*m, res, j, true); + for (unsigned int j = 0; j < m->getNumAtoms(); j++) { + RDKit::Descriptors::AtomFeatVect(*m, res, j, true); - // 52 features - TEST_ASSERT(res.size() == 52); + // 52 features + TEST_ASSERT(res.size() == 52); - for (std::size_t i = 0; i < res.size() ; i++) { - TEST_ASSERT(fabs( res[i]-molatf[i+j*52])< 0.001); - } - - res.clear(); - res.resize(52); + for (std::size_t i = 0; i < res.size(); i++) { + TEST_ASSERT(fabs(res[i] - molatf[i + j * 52]) < 0.001); } + + res.clear(); + res.resize(52); + } } void test5() { - - auto m = "O[C@@H](F)[C@@H](F)O"_smiles; + auto m = "O[C@@H](F)[C@@H](F)O"_smiles; - TEST_ASSERT(m); - - std::vector res; + TEST_ASSERT(m); - std::vector molatf{ 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667,0,0,0, + std::vector res; + + std::vector molatf{ 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667,0,0,0, 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667,1,0,0, 0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0.166667,0,0,0, 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667,1,0,0, 0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0.166667,0,0,0, 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0.166667,0,0,0}; - for (unsigned int j=0; j< m->getNumAtoms(); j++) { - RDKit::Descriptors::AtomFeatVect(*m, res, j, true); + for (unsigned int j = 0; j < m->getNumAtoms(); j++) { + RDKit::Descriptors::AtomFeatVect(*m, res, j, true); - // 52 features - TEST_ASSERT(res.size() == 52); + // 52 features + TEST_ASSERT(res.size() == 52); - for (std::size_t i = 0; i < res.size() ; i++) { - TEST_ASSERT(fabs( res[i]-molatf[i+j*52])< 0.001); - } - - res.clear(); - res.resize(52); + for (std::size_t i = 0; i < res.size(); i++) { + TEST_ASSERT(fabs(res[i] - molatf[i + j * 52]) < 0.001); } + + res.clear(); + res.resize(52); + } } int main() { @@ -185,4 +172,4 @@ int main() { test3(); test4(); test5(); -} \ No newline at end of file +} diff --git a/Code/GraphMol/Descriptors/testBCUT.cpp b/Code/GraphMol/Descriptors/testBCUT.cpp index ef76cecc5..7a02a4650 100644 --- a/Code/GraphMol/Descriptors/testBCUT.cpp +++ b/Code/GraphMol/Descriptors/testBCUT.cpp @@ -20,12 +20,11 @@ using namespace RDKit; // from knuth. -bool feq(float a, float b, float epsilon=1e-6) -{ - return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon); +bool feq(float a, float b, float epsilon = 1e-6) { + return fabs(a - b) <= ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon); } -void test1(){ +void test1() { BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl; BOOST_LOG(rdErrorLog) << " Basic BCUT tests." << std::endl; @@ -44,27 +43,27 @@ void test1(){ {31.111807418763107, 11.906469225329653, 1.5848247701762241, -1.5909887821270712, 2.0038391834918317, -1.3277290609201042, 7.422700514979134, 0.5941465179281992} }; - for (size_t i=0; i m(SmilesToMol(vec[i])); auto bcut = Descriptors::BCUT2D(*m); TEST_ASSERT(bcut.size() == expected[i].size()); - for(size_t j=0; j m(reader.next()); TEST_ASSERT(m.get()); std::vector bcuts = Descriptors::BCUT2D(*m); @@ -80,7 +79,6 @@ void test2() { } } - int main() { RDLog::InitLogs(); test1(); diff --git a/Code/GraphMol/Descriptors/testCoulombMat.cpp b/Code/GraphMol/Descriptors/testCoulombMat.cpp index 66487ca58..edc6c3a1b 100644 --- a/Code/GraphMol/Descriptors/testCoulombMat.cpp +++ b/Code/GraphMol/Descriptors/testCoulombMat.cpp @@ -28,57 +28,54 @@ #include #include - std::vector tokenize(const std::string &s) { - boost::char_separator sep(", \n\r\t"); - boost::tokenizer> tok(s, sep); - std::vector tokens; - std::copy(tok.begin(), tok.end(), std::back_inserter >(tokens)); + boost::char_separator sep(", \n\r\t"); + boost::tokenizer> tok(s, sep); + std::vector tokens; + std::copy(tok.begin(), tok.end(), + std::back_inserter>(tokens)); return tokens; } +void testCoulombMat1() { + std::cerr + << "===================== Testing CoulombMat =======================\n"; + std::string pathName = getenv("RDBASE"); -void testCoulombMat1(){ - std::cerr << "===================== Testing CoulombMat =======================\n"; - - std::string pathName = getenv("RDBASE"); + // CM test 1 + std::string fNameCM = + pathName + "/Code/GraphMol/Descriptors/test_data/CM1.out"; - // CM test 1 - std::string fNameCM = - pathName + "/Code/GraphMol/Descriptors/test_data/CM1.out"; + std::string mol_file = + pathName + "/Code/GraphMol/Descriptors/test_data/bobmol.sdf"; - std::string mol_file = - pathName + "/Code/GraphMol/Descriptors/test_data/bobmol.sdf"; + std::ifstream instrmCM(fNameCM.c_str()); + std::string line; + std::vector tokens; - std::ifstream instrmCM(fNameCM.c_str()); - std::string line; - std::vector tokens; + RDKit::ROMOL_SPTR mol(RDKit::MolFileToMol(mol_file, true, false)); - RDKit::ROMOL_SPTR mol( RDKit::MolFileToMol( mol_file , true, false) ); + std::vector> Mres; + int confId = -1; + RDKit::Descriptors::CoulombMat(*mol, Mres, confId); + for (const auto &v : Mres) { + std::getline(instrmCM, line); + tokens = tokenize(line); - std::vector> Mres; - int confId = -1; - RDKit::Descriptors::CoulombMat(*mol, Mres, confId); - - for ( const auto &v : Mres ) { - std::getline(instrmCM, line); - tokens = tokenize(line); - - unsigned int ti = 0; - for ( double x : v ) { - // std::cout << x << ","; - TEST_ASSERT(std::fabs(std::stof(tokens[ti]) - x)< 0.001); - ti++; - } - // std::cout << "\n"; + unsigned int ti = 0; + for (double x : v) { + // std::cout << x << ","; + TEST_ASSERT(std::fabs(std::stof(tokens[ti]) - x) < 0.001); + ti++; } // std::cout << "\n"; - - std::cerr << "CM test 1 mat Done\n"; -} + } + // std::cout << "\n"; + std::cerr << "CM test 1 mat Done\n"; +} int main() { RDLog::InitLogs(); diff --git a/Code/GraphMol/Descriptors/testEEM.cpp b/Code/GraphMol/Descriptors/testEEM.cpp index e7d8265b5..2c77dd5eb 100644 --- a/Code/GraphMol/Descriptors/testEEM.cpp +++ b/Code/GraphMol/Descriptors/testEEM.cpp @@ -86,11 +86,11 @@ void testEEM1() { std::cout << nDone << "\n"; } - if (errorAtoms > 0) { - std::cout << nDone << " " << inm << " " << errorAtoms << "\n"; - ++errorMols; - } - TEST_ASSERT(errorAtoms == 0); + if (errorAtoms > 0) { + std::cout << nDone << " " << inm << " " << errorAtoms << "\n"; + ++errorMols; + } + TEST_ASSERT(errorAtoms == 0); delete m; // break; ++nDone; diff --git a/Code/GraphMol/Descriptors/testPBF.cpp b/Code/GraphMol/Descriptors/testPBF.cpp index 8d4f88cf0..5d8f3d285 100644 --- a/Code/GraphMol/Descriptors/testPBF.cpp +++ b/Code/GraphMol/Descriptors/testPBF.cpp @@ -20,85 +20,92 @@ #include -void test1(){ +void test1() { BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl; BOOST_LOG(rdErrorLog) << " Basic PBF tests." << std::endl; std::string pathName = getenv("RDBASE"); - std::string sdfName = pathName+"/Code/GraphMol/Descriptors/test_data/PBF_egfr.sdf"; - RDKit::SDMolSupplier reader(sdfName,true,false); - std::string fName = pathName+"/Code/GraphMol/Descriptors/test_data/PBF_egfr.out"; + std::string sdfName = + pathName + "/Code/GraphMol/Descriptors/test_data/PBF_egfr.sdf"; + RDKit::SDMolSupplier reader(sdfName, true, false); + std::string fName = + pathName + "/Code/GraphMol/Descriptors/test_data/PBF_egfr.out"; std::ifstream instrm(fName.c_str()); - int nDone=0; - while(!reader.atEnd()){ - RDKit::ROMol *m=reader.next(); + int nDone = 0; + while (!reader.atEnd()) { + RDKit::ROMol *m = reader.next(); TEST_ASSERT(m); std::string nm; - m->getProp("_Name",nm); - double dpbf=RDKit::Descriptors::PBF(*m); + m->getProp("_Name", nm); + double dpbf = RDKit::Descriptors::PBF(*m); std::string inm; double ref; - instrm>>inm; - instrm>>ref; - TEST_ASSERT(inm==nm); - if(fabs(ref-dpbf)>.001){ - std::cerr<<"value mismatch: "<> inm; + instrm >> ref; + TEST_ASSERT(inm == nm); + if (fabs(ref - dpbf) > .001) { + std::cerr << "value mismatch: " << inm << " " << ref << " " << dpbf + << std::endl; } - TEST_ASSERT(fabs(ref-dpbf)<0.001); + TEST_ASSERT(fabs(ref - dpbf) < 0.001); delete m; ++nDone; } BOOST_LOG(rdErrorLog) << " done" << std::endl; } -void testPBFEdges(){ +void testPBFEdges() { BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl; BOOST_LOG(rdErrorLog) << " PBF edge cases." << std::endl; { std::string pathName = getenv("RDBASE"); - std::string sdfName = pathName+"/Code/GraphMol/Descriptors/test_data/linear.mol"; + std::string sdfName = + pathName + "/Code/GraphMol/Descriptors/test_data/linear.mol"; - RDKit::ROMol *m=RDKit::MolFileToMol(sdfName); + RDKit::ROMol *m = RDKit::MolFileToMol(sdfName); TEST_ASSERT(m); - double dpbf=RDKit::Descriptors::PBF(*m); - TEST_ASSERT(dpbf<=1e-4); + double dpbf = RDKit::Descriptors::PBF(*m); + TEST_ASSERT(dpbf <= 1e-4); delete m; } { std::string pathName = getenv("RDBASE"); - std::string sdfName = pathName+"/Code/GraphMol/Descriptors/test_data/linear_2atom.mol"; + std::string sdfName = + pathName + "/Code/GraphMol/Descriptors/test_data/linear_2atom.mol"; - RDKit::ROMol *m=RDKit::MolFileToMol(sdfName); + RDKit::ROMol *m = RDKit::MolFileToMol(sdfName); TEST_ASSERT(m); - double dpbf=RDKit::Descriptors::PBF(*m); - TEST_ASSERT(dpbf<=1e-4); + double dpbf = RDKit::Descriptors::PBF(*m); + TEST_ASSERT(dpbf <= 1e-4); delete m; } { std::string pathName = getenv("RDBASE"); - std::string sdfName = pathName+"/Code/GraphMol/Descriptors/test_data/planar.mol"; + std::string sdfName = + pathName + "/Code/GraphMol/Descriptors/test_data/planar.mol"; - RDKit::ROMol *m=RDKit::MolFileToMol(sdfName); + RDKit::ROMol *m = RDKit::MolFileToMol(sdfName); TEST_ASSERT(m); - double dpbf=RDKit::Descriptors::PBF(*m); - TEST_ASSERT(dpbf<=1e-4); + double dpbf = RDKit::Descriptors::PBF(*m); + TEST_ASSERT(dpbf <= 1e-4); delete m; } { std::string pathName = getenv("RDBASE"); - std::string sdfName = pathName+"/Code/GraphMol/Descriptors/test_data/planar_3atom.mol"; + std::string sdfName = + pathName + "/Code/GraphMol/Descriptors/test_data/planar_3atom.mol"; - RDKit::ROMol *m=RDKit::MolFileToMol(sdfName); + RDKit::ROMol *m = RDKit::MolFileToMol(sdfName); TEST_ASSERT(m); - double dpbf=RDKit::Descriptors::PBF(*m); - TEST_ASSERT(dpbf<=1e-4); + double dpbf = RDKit::Descriptors::PBF(*m); + TEST_ASSERT(dpbf <= 1e-4); delete m; } { RDKit::RWMol m; - bool updateLabel = true; + bool updateLabel = true; bool takeOwnership = true; m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); @@ -107,8 +114,8 @@ void testPBFEdges(){ m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); m.addConformer(new RDKit::Conformer(m.getNumAtoms())); - double dpbf=RDKit::Descriptors::PBF(m); - TEST_ASSERT(dpbf<=1e-4); + double dpbf = RDKit::Descriptors::PBF(m); + TEST_ASSERT(dpbf <= 1e-4); } BOOST_LOG(rdErrorLog) << " done" << std::endl; diff --git a/Code/GraphMol/DistGeomHelpers/Embedder.h b/Code/GraphMol/DistGeomHelpers/Embedder.h index cea227dfd..3c00844ec 100644 --- a/Code/GraphMol/DistGeomHelpers/Embedder.h +++ b/Code/GraphMol/DistGeomHelpers/Embedder.h @@ -283,7 +283,7 @@ inline int EmbedMolecule( bool useBasicKnowledge = false, bool verbose = false, double basinThresh = 5.0, bool onlyHeavyAtomsForRMS = false, unsigned int ETversion = 1, bool useSmallRingTorsions = false, - bool useMacrocycleTorsions = false, bool useMacrocycle14config = false) { + bool useMacrocycleTorsions = false, bool useMacrocycle14config = false) { EmbedParameters params( maxIterations, 1, seed, clearConfs, useRandomCoords, boxSizeMult, randNegEig, numZeroFail, coordMap, optimizerForceTol, @@ -389,7 +389,7 @@ inline void EmbedMultipleConfs( ignoreSmoothingFailures, enforceChirality, useExpTorsionAnglePrefs, useBasicKnowledge, verbose, basinThresh, pruneRmsThresh, onlyHeavyAtomsForRMS, ETversion, nullptr, true, useSmallRingTorsions, - useMacrocycleTorsions, useMacrocycle14config); + useMacrocycleTorsions, useMacrocycle14config); EmbedMultipleConfs(mol, res, numConfs, params); }; //! \overload diff --git a/Code/GraphMol/DistGeomHelpers/Wrap/rdDistGeom.cpp b/Code/GraphMol/DistGeomHelpers/Wrap/rdDistGeom.cpp index f89506f87..0c2a657de 100644 --- a/Code/GraphMol/DistGeomHelpers/Wrap/rdDistGeom.cpp +++ b/Code/GraphMol/DistGeomHelpers/Wrap/rdDistGeom.cpp @@ -428,7 +428,8 @@ BOOST_PYTHON_MODULE(rdDistGeom) { .def_readwrite( "boundsMatForceScaling", &RDKit::DGeomHelpers::EmbedParameters::boundsMatForceScaling, - "scale the weights of the atom pair distance restraints relative to the other types of restraints") + "scale the weights of the atom pair distance restraints relative to " + "the other types of restraints") .def_readwrite( "useSymmetryForPruning", &RDKit::DGeomHelpers::EmbedParameters::useSymmetryForPruning, diff --git a/Code/GraphMol/FMCS/MaximumCommonSubgraph.cpp b/Code/GraphMol/FMCS/MaximumCommonSubgraph.cpp index 18bcf8922..3aef42165 100644 --- a/Code/GraphMol/FMCS/MaximumCommonSubgraph.cpp +++ b/Code/GraphMol/FMCS/MaximumCommonSubgraph.cpp @@ -470,21 +470,18 @@ void MaximumCommonSubgraph::makeInitialSeeds() { if (!QueryMoleculeSingleMatchedAtom) { QueryMoleculeSingleMatchedAtom = queryMolAtom; } else { - QueryMoleculeSingleMatchedAtom = - (std::max)(queryMolAtom, QueryMoleculeSingleMatchedAtom, - [](const Atom* a, const Atom* b) { - if (a->getDegree() != b->getDegree()) { - return (a->getDegree() < b->getDegree()); - } else if (a->getFormalCharge() != - b->getFormalCharge()) { - return (a->getFormalCharge() < - b->getFormalCharge()); - } else if (a->getAtomicNum() != - b->getAtomicNum()) { - return (a->getAtomicNum() < b->getAtomicNum()); - } - return (a->getIdx() < b->getIdx()); - }); + QueryMoleculeSingleMatchedAtom = (std::max)( + queryMolAtom, QueryMoleculeSingleMatchedAtom, + [](const Atom* a, const Atom* b) { + if (a->getDegree() != b->getDegree()) { + return (a->getDegree() < b->getDegree()); + } else if (a->getFormalCharge() != b->getFormalCharge()) { + return (a->getFormalCharge() < b->getFormalCharge()); + } else if (a->getAtomicNum() != b->getAtomicNum()) { + return (a->getAtomicNum() < b->getAtomicNum()); + } + return (a->getIdx() < b->getIdx()); + }); } } break; diff --git a/Code/GraphMol/FMCS/Seed.cpp b/Code/GraphMol/FMCS/Seed.cpp index ad25aa0a0..15f528297 100644 --- a/Code/GraphMol/FMCS/Seed.cpp +++ b/Code/GraphMol/FMCS/Seed.cpp @@ -35,7 +35,7 @@ unsigned Seed::addAtom(const Atom* atom) { unsigned Seed::addBond(const Bond* bond) { unsigned b = bond->getIdx(); if (ExcludedBonds[b]) { - throw - 1; // never, check the implementation + throw -1; // never, check the implementation } ExcludedBonds[b] = true; MoleculeFragment.BondsIdx.push_back(b); @@ -74,7 +74,7 @@ void Seed::fillNewBonds(const ROMol& qmol) { } } NewBonds.emplace_back(srcAtomIdx, bond->getIdx(), ai, end_atom_idx, - NotSet == end_atom_idx ? end_atom : nullptr); + NotSet == end_atom_idx ? end_atom : nullptr); } } } diff --git a/Code/GraphMol/FMCS/Test/testFMCS.cpp b/Code/GraphMol/FMCS/Test/testFMCS.cpp index 970db9276..eac6cc68b 100644 --- a/Code/GraphMol/FMCS/Test/testFMCS.cpp +++ b/Code/GraphMol/FMCS/Test/testFMCS.cpp @@ -346,9 +346,8 @@ void testFileMCSB(const char* test, unsigned timeout = 30, } else { fprintf(f, "# %u REFCMP: res %s %s %u %u %s.\n", n + 1, "FAILED", /*referenceResults[n].NumAtoms > res.NumAtoms ||*/ - referenceResults[n].NumBonds > res.NumBonds - ? "MISSING" - : "GREATER", + referenceResults[n].NumBonds > res.NumBonds ? "MISSING" + : "GREATER", referenceResults[n].NumAtoms, referenceResults[n].NumBonds, referenceResults[n].SmartsString.c_str()); } @@ -1683,7 +1682,7 @@ int main(int argc, const char* argv[]) { */ #ifdef xxWIN32 // brief test set for testing and issue investigation -#ifdef _DEBUG // check memory leaks +#ifdef _DEBUG // check memory leaks _CrtMemState _ms; _CrtMemCheckpoint(&_ms); #endif diff --git a/Code/GraphMol/FileParsers/MultithreadedSDMolSupplier.cpp b/Code/GraphMol/FileParsers/MultithreadedSDMolSupplier.cpp index c24d5330f..9a40647b3 100644 --- a/Code/GraphMol/FileParsers/MultithreadedSDMolSupplier.cpp +++ b/Code/GraphMol/FileParsers/MultithreadedSDMolSupplier.cpp @@ -184,7 +184,7 @@ void MultithreadedSDMolSupplier::readMolProps(ROMol *mol, std::getline(inStream, tempStr); if (inStream.eof()) { if (mol) { - delete mol; + delete mol; } throw FileParseException("End of data field name not found"); } @@ -232,7 +232,7 @@ void MultithreadedSDMolSupplier::readMolProps(ROMol *mol, // FIX: should we be deleting the molecule (which is probably fine) // because we couldn't read the data ??? if (mol) { - delete mol; + delete mol; } throw FileParseException("Problems encountered parsing data fields"); } else { diff --git a/Code/GraphMol/FileParsers/PDBWriter.cpp b/Code/GraphMol/FileParsers/PDBWriter.cpp index ef7aa4635..b0c81f335 100644 --- a/Code/GraphMol/FileParsers/PDBWriter.cpp +++ b/Code/GraphMol/FileParsers/PDBWriter.cpp @@ -128,7 +128,8 @@ std::string GetPDBAtomLine(const Atom *atom, const Conformer *conf, } if (info) { - ss << boost::format("%6.2f%6.2f") % info->getOccupancy() % info->getTempFactor(); + ss << boost::format("%6.2f%6.2f") % info->getOccupancy() % + info->getTempFactor(); ss << " "; } else { ss << " 1.00 0.00 "; diff --git a/Code/GraphMol/FileParsers/SequenceParsers.cpp b/Code/GraphMol/FileParsers/SequenceParsers.cpp index aa501499f..709c3fc90 100644 --- a/Code/GraphMol/FileParsers/SequenceParsers.cpp +++ b/Code/GraphMol/FileParsers/SequenceParsers.cpp @@ -790,8 +790,7 @@ static RWMol *AASequenceToMol(const char *seq, bool lowerD) { } static void CreateNucleicAcid(RWMol *mol, const char *na, Atom *&r1, Atom *&r2, - AtomPDBResidueInfo &info, bool PCap5) -{ + AtomPDBResidueInfo &info, bool PCap5) { Atom *atom[32]; r1 = (Atom *)nullptr; @@ -841,7 +840,7 @@ static void CreateNucleicAcid(RWMol *mol, const char *na, Atom *&r1, Atom *&r2, CreateAABond(mol, atom[8], atom[10], 1); atom[6]->setChiralTag(Atom::CHI_TETRAHEDRAL_CW); atom[8]->setChiralTag(Atom::CHI_TETRAHEDRAL_CW); - if (na[1]==' ') { + if (na[1] == ' ') { atom[11] = CreateAAAtom(mol, " O2'", info); atom[12] = CreateAAAtom(mol, " C1'", info); CreateAABond(mol, atom[10], atom[11], 1); @@ -973,7 +972,6 @@ static void CreateNucleicAcid(RWMol *mol, const char *na, Atom *&r1, Atom *&r2, } } - static void CreatePCap3(RWMol *mol, Atom *prev, AtomPDBResidueInfo &info) { Atom *atom[4]; @@ -992,9 +990,8 @@ static void CreatePCap3(RWMol *mol, Atom *prev, AtomPDBResidueInfo &info) { CreateAABond(mol, atom[0], atom[3], 1); } - -static RWMol *NASequenceToMol(const char *seq, bool Dna, - bool PCap5, bool PCap3) { +static RWMol *NASequenceToMol(const char *seq, bool Dna, bool PCap5, + bool PCap3) { char chain[2]; chain[0] = 'A'; chain[1] = '\0'; @@ -1076,7 +1073,6 @@ static RWMol *NASequenceToMol(const char *seq, bool Dna, return mol; } - RWMol *SequenceToMol(const char *seq, bool sanitize, int flavor) { if (!seq) { return (RWMol *)nullptr; @@ -1085,20 +1081,40 @@ RWMol *SequenceToMol(const char *seq, bool sanitize, int flavor) { switch (flavor) { /* Protein */ - case 0: mol = AASequenceToMol(seq,false); break; - case 1: mol = AASequenceToMol(seq,true); break; + case 0: + mol = AASequenceToMol(seq, false); + break; + case 1: + mol = AASequenceToMol(seq, true); + break; /* RNA */ - case 2: mol = NASequenceToMol(seq,false,false,false); break; - case 3: mol = NASequenceToMol(seq,false,true,false); break; - case 4: mol = NASequenceToMol(seq,false,false,true); break; - case 5: mol = NASequenceToMol(seq,false,true,true); break; + case 2: + mol = NASequenceToMol(seq, false, false, false); + break; + case 3: + mol = NASequenceToMol(seq, false, true, false); + break; + case 4: + mol = NASequenceToMol(seq, false, false, true); + break; + case 5: + mol = NASequenceToMol(seq, false, true, true); + break; /* DNA */ - case 6: mol = NASequenceToMol(seq,true,false,false); break; - case 7: mol = NASequenceToMol(seq,true,true,false); break; - case 8: mol = NASequenceToMol(seq,true,false,true); break; - case 9: mol = NASequenceToMol(seq,true,true,true); break; + case 6: + mol = NASequenceToMol(seq, true, false, false); + break; + case 7: + mol = NASequenceToMol(seq, true, true, false); + break; + case 8: + mol = NASequenceToMol(seq, true, false, true); + break; + case 9: + mol = NASequenceToMol(seq, true, true, true); + break; default: return (RWMol *)nullptr; @@ -1109,7 +1125,6 @@ RWMol *SequenceToMol(const char *seq, bool sanitize, int flavor) { return mol; } - RWMol *SequenceToMol(const std::string &seq, bool sanitize, int flavor) { return SequenceToMol(seq.c_str(), sanitize, flavor); } @@ -1159,7 +1174,7 @@ struct HELMMonomer { Atom *r3{nullptr}; Atom *oxt{nullptr}; - HELMMonomer() {} + HELMMonomer() {} HELMMonomer(Atom *x, Atom *y, Atom *z) : r1(x), r2(y), r3(z), oxt(nullptr) {} }; @@ -1563,7 +1578,7 @@ static const char *ParseHELMNucleic(RWMol *mol, const char *ptr, info.setInsertionCode(" "); info.setChainId(chain); - if (*ptr=='P') { + if (*ptr == 'P') { PCap5 = true; ptr++; if (*ptr == '.') { @@ -1573,57 +1588,57 @@ static const char *ParseHELMNucleic(RWMol *mol, const char *ptr, for (;;) { const char *name = nullptr; - if (*ptr == 'R' && ptr[1]=='(') { - if (ptr[2]=='A') { - if (ptr[3]==')') { + if (*ptr == 'R' && ptr[1] == '(') { + if (ptr[2] == 'A') { + if (ptr[3] == ')') { name = " A"; ptr += 4; } - } else if (ptr[2]=='C') { - if (ptr[3]==')') { + } else if (ptr[2] == 'C') { + if (ptr[3] == ')') { name = " C"; ptr += 4; } - } else if (ptr[2]=='G') { - if (ptr[3]==')') { + } else if (ptr[2] == 'G') { + if (ptr[3] == ')') { name = " G"; ptr += 4; } - } else if (ptr[2]=='T') { - if (ptr[3]==')') { + } else if (ptr[2] == 'T') { + if (ptr[3] == ')') { name = " T"; ptr += 4; } - } else if (ptr[2]=='U') { - if (ptr[3]==')') { + } else if (ptr[2] == 'U') { + if (ptr[3] == ')') { name = " U"; ptr += 4; } } - } else if (*ptr=='[' && ptr[1]=='d' && ptr[2]=='R' && - ptr[3]==']' && ptr[4]=='(') { - if (ptr[5]=='A') { - if (ptr[6]==')') { + } else if (*ptr == '[' && ptr[1] == 'd' && ptr[2] == 'R' && ptr[3] == ']' && + ptr[4] == '(') { + if (ptr[5] == 'A') { + if (ptr[6] == ')') { name = " DA"; ptr += 7; } - } else if (ptr[5]=='C') { - if (ptr[6]==')') { + } else if (ptr[5] == 'C') { + if (ptr[6] == ')') { name = " DC"; ptr += 7; } - } else if (ptr[5]=='G') { - if (ptr[6]==')') { + } else if (ptr[5] == 'G') { + if (ptr[6] == ')') { name = " DG"; ptr += 7; } - } else if (ptr[5]=='T') { - if (ptr[6]==')') { + } else if (ptr[5] == 'T') { + if (ptr[6] == ')') { name = " DT"; ptr += 7; } - } else if (ptr[5]=='U') { - if (ptr[6]==')') { + } else if (ptr[5] == 'U') { + if (ptr[6] == ')') { name = " DU"; ptr += 7; } @@ -1633,7 +1648,7 @@ static const char *ParseHELMNucleic(RWMol *mol, const char *ptr, return (const char *)nullptr; } - CreateNucleicAcid(mol,name,r1,r2,info,PCap5); + CreateNucleicAcid(mol, name, r1, r2, info, PCap5); if (prev && r1) { CreateAABond(mol, prev, r1, 1); } @@ -1650,7 +1665,7 @@ static const char *ParseHELMNucleic(RWMol *mol, const char *ptr, } ptr++; if (*ptr == '}') { - CreatePCap3(mol,prev,info); + CreatePCap3(mol, prev, info); return ptr; } PCap5 = true; @@ -1660,9 +1675,8 @@ static const char *ParseHELMNucleic(RWMol *mol, const char *ptr, } } - static bool ParseHELM(RWMol *mol, const char *ptr) { - std::map > seqs; + std::map> seqs; const char *orig; char chain[2]; chain[0] = 'A'; @@ -1687,8 +1701,8 @@ static bool ParseHELM(RWMol *mol, const char *ptr) { return false; } ptr++; - } else if (ptr[0]=='R' && ptr[1]=='N' && ptr[2]=='A' && - ptr[3]>='1' && ptr[3]<='9') { + } else if (ptr[0] == 'R' && ptr[1] == 'N' && ptr[2] == 'A' && + ptr[3] >= '1' && ptr[3] <= '9') { ptr += 4; while (*ptr >= '0' && *ptr <= '9') { ptr++; diff --git a/Code/GraphMol/FileParsers/SequenceWriters.cpp b/Code/GraphMol/FileParsers/SequenceWriters.cpp index c1135737a..cf8783bf2 100644 --- a/Code/GraphMol/FileParsers/SequenceWriters.cpp +++ b/Code/GraphMol/FileParsers/SequenceWriters.cpp @@ -166,10 +166,9 @@ static char getOneLetterAACode(const AtomPDBResidueInfo *info) { return 'X'; } - static char getOneLetterNACode(const AtomPDBResidueInfo *info) { const char *ptr = info->getResidueName().c_str(); - if (ptr[0]==' ' && (ptr[1]==' ' || ptr[1]=='D')) { + if (ptr[0] == ' ' && (ptr[1] == ' ' || ptr[1] == 'D')) { switch (ptr[2]) { case 'A': case 'C': @@ -182,7 +181,6 @@ static char getOneLetterNACode(const AtomPDBResidueInfo *info) { return 'X'; } - std::string MolToSequence(const ROMol &mol) { std::string result; std::string chain; @@ -512,26 +510,35 @@ static const char *getHELMNAMonomer(const AtomPDBResidueInfo *info) { if (ptr[0] == ' ') { if (ptr[1] == ' ') { switch (ptr[2]) { - case 'A': return "R(A)"; - case 'C': return "R(C)"; - case 'G': return "R(G)"; - case 'T': return "R(T)"; - case 'U': return "R(U)"; + case 'A': + return "R(A)"; + case 'C': + return "R(C)"; + case 'G': + return "R(G)"; + case 'T': + return "R(T)"; + case 'U': + return "R(U)"; } } else if (ptr[1] == 'D') { switch (ptr[2]) { - case 'A': return "[dR](A)"; - case 'C': return "[dR](C)"; - case 'G': return "[dR](G)"; - case 'T': return "[dR](T)"; - case 'U': return "[dR](U)"; + case 'A': + return "[dR](A)"; + case 'C': + return "[dR](C)"; + case 'G': + return "[dR](G)"; + case 'T': + return "[dR](T)"; + case 'U': + return "[dR](U)"; } } } return (const char *)nullptr; } - // Pstate finite state machine // 0 start of string P -> 1 B -> 2 T -> fail // 1 after 5'-P P -> fail B -> 3 T -> fail @@ -637,16 +644,16 @@ std::string MolToHELM(const ROMol &mol) { } else { switch (Pstate) { case 1: -#if 0 // Do the same as state 4 for Biovia friendly HELM +#if 0 // Do the same as state 4 for Biovia friendly HELM Pstate = 3; break; #endif - case 4: - result += '.'; - Pstate = 2; - break; - default: - return ""; + case 4: + result += '.'; + Pstate = 2; + break; + default: + return ""; } } result += mono; diff --git a/Code/GraphMol/FileParsers/XYZFileWriter.cpp b/Code/GraphMol/FileParsers/XYZFileWriter.cpp index b898caa5a..94e110a7f 100644 --- a/Code/GraphMol/FileParsers/XYZFileWriter.cpp +++ b/Code/GraphMol/FileParsers/XYZFileWriter.cpp @@ -37,7 +37,8 @@ std::string MolToXYZBlock(const ROMol& mol, int confId) { for (unsigned int i = 0; i < nAtoms; i++) { const auto& symbol = mol.getAtomWithIdx(i)->getSymbol(); const auto& pos = conf.getAtomPos(i); - ss << boost::format{"%-3s %11.6f %11.6f %11.6f\n"} % symbol % pos.x % pos.y % pos.z; + ss << boost::format{"%-3s %11.6f %11.6f %11.6f\n"} % symbol % pos.x % + pos.y % pos.z; } return ss.str(); } diff --git a/Code/GraphMol/FileParsers/testExtendedStereoParsing.cpp b/Code/GraphMol/FileParsers/testExtendedStereoParsing.cpp index b42af4eb2..aad788fb4 100644 --- a/Code/GraphMol/FileParsers/testExtendedStereoParsing.cpp +++ b/Code/GraphMol/FileParsers/testExtendedStereoParsing.cpp @@ -43,7 +43,8 @@ void testOr() { TEST_ASSERT(stereo_groups[0].getGroupType() == RDKit::StereoGroupType::STEREO_ABSOLUTE); TEST_ASSERT(stereo_groups[0].getAtoms().size() == 1u); - TEST_ASSERT(stereo_groups[1].getGroupType() == RDKit::StereoGroupType::STEREO_OR); + TEST_ASSERT(stereo_groups[1].getGroupType() == + RDKit::StereoGroupType::STEREO_OR); TEST_ASSERT(stereo_groups[1].getAtoms().size() == 2u); BOOST_LOG(rdInfoLog) << "done" << std::endl; @@ -61,7 +62,8 @@ void testAnd() { TEST_ASSERT(stereo_groups.size() == 2); TEST_ASSERT(stereo_groups[0].getGroupType() == RDKit::StereoGroupType::STEREO_ABSOLUTE); - TEST_ASSERT(stereo_groups[1].getGroupType() == RDKit::StereoGroupType::STEREO_AND); + TEST_ASSERT(stereo_groups[1].getGroupType() == + RDKit::StereoGroupType::STEREO_AND); BOOST_LOG(rdInfoLog) << "done" << std::endl; } @@ -81,7 +83,8 @@ void testWrite() { TEST_ASSERT(stereo_groups0.size() == stereo_groups1.size()); for (unsigned i = 0u; i < 2; ++i) { - TEST_ASSERT(stereo_groups0[i].getGroupType() == stereo_groups1[i].getGroupType()); + TEST_ASSERT(stereo_groups0[i].getGroupType() == + stereo_groups1[i].getGroupType()); TEST_ASSERT(stereo_groups0[i].getAtoms().size() == stereo_groups1[i].getAtoms().size()); for (auto &&atom0 = stereo_groups0[i].getAtoms().begin(), diff --git a/Code/GraphMol/FilterCatalog/FilterCatalogRunner.cpp b/Code/GraphMol/FilterCatalog/FilterCatalogRunner.cpp index a39183831..c2187468f 100644 --- a/Code/GraphMol/FilterCatalog/FilterCatalogRunner.cpp +++ b/Code/GraphMol/FilterCatalog/FilterCatalogRunner.cpp @@ -20,34 +20,30 @@ namespace RDKit { namespace { -boost::shared_ptr & makeBadSmilesEntry() { +boost::shared_ptr &makeBadSmilesEntry() { static boost::shared_ptr bad_smiles( - new FilterCatalogEntry("no valid RDKit molecule", - boost::shared_ptr())); + new FilterCatalogEntry("no valid RDKit molecule", + boost::shared_ptr())); return bad_smiles; } -void CatalogSearcher(const FilterCatalog &fc, - const std::vector &smiles, - std::vector> &results, - int start, - int numThreads) { - for(unsigned int idx = start; - idx < smiles.size(); - idx += numThreads) { +void CatalogSearcher( + const FilterCatalog &fc, const std::vector &smiles, + std::vector> &results, int start, + int numThreads) { + for (unsigned int idx = start; idx < smiles.size(); idx += numThreads) { std::unique_ptr mol(SmilesToMol(smiles[idx])); - if(mol.get()) { + if (mol.get()) { results[idx] = fc.getMatches(*mol); } else { - results[idx].push_back( makeBadSmilesEntry() ); + results[idx].push_back(makeBadSmilesEntry()); } - } + } } -} - -std::vector>> RunFilterCatalog( - const FilterCatalog &fc, - const std::vector &smiles, - int numThreads) { +} // namespace + +std::vector>> +RunFilterCatalog(const FilterCatalog &fc, + const std::vector &smiles, int numThreads) { // preallocate results so the threads don't move the vector around in memory // There is one result per input smiles std::vector> results(smiles.size()); @@ -59,17 +55,13 @@ std::vector>> RunFilterC numThreads = std::min(numThreads, (int)getNumThreadsToUse(numThreads)); } - std::vector> thread_group; - for (int thread_group_idx = 0; thread_group_idx < numThreads+1; + std::vector> thread_group; + for (int thread_group_idx = 0; thread_group_idx < numThreads + 1; ++thread_group_idx) { // need to use std::ref otherwise things are passed by value - thread_group.emplace_back( - std::async(std::launch::async, CatalogSearcher, - std::ref(fc), - std::ref(smiles), - std::ref(results), - thread_group_idx, - numThreads)); + thread_group.emplace_back(std::async( + std::launch::async, CatalogSearcher, std::ref(fc), std::ref(smiles), + std::ref(results), thread_group_idx, numThreads)); } for (auto &fut : thread_group) { fut.get(); @@ -82,5 +74,5 @@ std::vector>> RunFilterC #endif return results; } - -} + +} // namespace RDKit diff --git a/Code/GraphMol/FilterCatalog/Filters.cpp b/Code/GraphMol/FilterCatalog/Filters.cpp index 9cb3a2908..08a41e34f 100644 --- a/Code/GraphMol/FilterCatalog/Filters.cpp +++ b/Code/GraphMol/FilterCatalog/Filters.cpp @@ -171,7 +171,7 @@ const unsigned int NUM_BRENK = static_cast(sizeof(BRENK) / sizeof(FilterData_t)); const FilterProperty_t BRENK_PROPS[] = { - {"FilterSet", "Brenk"}, + {"FilterSet", "Brenk"}, {"Reference", "Brenk R et al. Lessons Learnt from Assembling Screening Libraries for " "Drug Discovery for Neglected Diseases. ChemMedChem 3 (2008) 435-444. " @@ -633,7 +633,7 @@ const unsigned int NUM_NIH = static_cast(sizeof(NIH) / sizeof(FilterData_t)); const FilterProperty_t NIH_PROPS[] = { - {"FilterSet", "NIH"}, + {"FilterSet", "NIH"}, {"Scope", "annotate compounds with problematic functional groups"}, {"Reference", "Doveston R, et al. A Unified Lead-oriented Synthesis of over Fifty " @@ -656,12 +656,11 @@ const unsigned int NUM_NIH_PROPS = // #include "pains_a.in" - const unsigned int NUM_PAINS_A = static_cast(sizeof(PAINS_A) / sizeof(FilterData_t)); const FilterProperty_t PAINS_A_PROPS[] = { - {"FilterSet", "PAINS_A"}, + {"FilterSet", "PAINS_A"}, {"Reference", "Baell JB, Holloway GA. New Substructure Filters for Removal of Pan Assay " "Interference Compounds (PAINS) from Screening Libraries and for Their " @@ -686,12 +685,11 @@ const unsigned int NUM_PAINS_A_PROPS = // #include "pains_b.in" - const unsigned int NUM_PAINS_B = static_cast(sizeof(PAINS_B) / sizeof(FilterData_t)); const FilterProperty_t PAINS_B_PROPS[] = { - {"FilterSet", "PAINS_B"}, + {"FilterSet", "PAINS_B"}, {"Reference", "Baell JB, Holloway GA. New Substructure Filters for Removal of Pan Assay " "Interference Compounds (PAINS) from Screening Libraries and for Their " @@ -712,12 +710,11 @@ const unsigned int NUM_PAINS_B_PROPS = // #include "pains_c.in" - const unsigned int NUM_PAINS_C = static_cast(sizeof(PAINS_C) / sizeof(FilterData_t)); const FilterProperty_t PAINS_C_PROPS[] = { - {"FilterSet", "PAINS_C"}, + {"FilterSet", "PAINS_C"}, {"Reference", "Baell JB, Holloway GA. New Substructure Filters for Removal of Pan Assay " "Interference Compounds (PAINS) from Screening Libraries and for Their " @@ -788,7 +785,7 @@ const unsigned int NUM_ZINC = static_cast(sizeof(ZINC) / sizeof(FilterData_t)); const FilterProperty_t ZINC_PROPS[] = { - {"FilterSet", "ZINC"}, + {"FilterSet", "ZINC"}, {"Reference", "http://blaster.docking.org/filtering/"}, {"Scope", "drug-likeness and unwanted functional group filters"}}; const unsigned int NUM_ZINC_PROPS = @@ -872,4 +869,4 @@ const FilterProperty_t* GetFilterProperties( return nullptr; } } -} +} // namespace RDKit diff --git a/Code/GraphMol/FilterCatalog/Filters.cpp.in b/Code/GraphMol/FilterCatalog/Filters.cpp.in index 678bf8e78..95a408883 100644 --- a/Code/GraphMol/FilterCatalog/Filters.cpp.in +++ b/Code/GraphMol/FilterCatalog/Filters.cpp.in @@ -652,8 +652,9 @@ const unsigned int NUM_NIH_PROPS = // doi:10.1021/jm901137j. // # Scope: PAINS filters (family A) // -{{ PAINS_A }} - +{ + { PAINS_A } +} const unsigned int NUM_PAINS_A = static_cast(sizeof(PAINS_A) / sizeof(FilterData_t)); @@ -681,8 +682,9 @@ const unsigned int NUM_PAINS_A_PROPS = // # imidazole_A(19) // n:1:c(:n(:c(:c:1-c:2:c:c:c:c:c:2)-c:3:c:c:c:c:c:3)-[#1])-[#6]:,=[!#1] 0 // -{{ PAINS_B }} - +{ + { PAINS_B } +} const unsigned int NUM_PAINS_B = static_cast(sizeof(PAINS_B) / sizeof(FilterData_t)); @@ -706,9 +708,10 @@ const unsigned int NUM_PAINS_B_PROPS = // doi:10.1021/jm901137j. // # Scope: PAINS filters (family C) // -{{ PAINS_C }} +{ + { PAINS_C } +} - const unsigned int NUM_PAINS_C = static_cast(sizeof(PAINS_C) / sizeof(FilterData_t)); @@ -866,4 +869,4 @@ const FilterProperty_t* GetFilterProperties( return 0; } } -} +} // namespace RDKit diff --git a/Code/GraphMol/FilterCatalog/FunctionalGroupHierarchy.cpp b/Code/GraphMol/FilterCatalog/FunctionalGroupHierarchy.cpp index ad682e717..36975f992 100644 --- a/Code/GraphMol/FilterCatalog/FunctionalGroupHierarchy.cpp +++ b/Code/GraphMol/FilterCatalog/FunctionalGroupHierarchy.cpp @@ -235,7 +235,7 @@ void hierarchy_create() { fd->getName(), boost::shared_ptr(fd))); } } -} +} // namespace const FilterCatalog &GetFunctionalGroupHierarchy() { #ifdef RDK_THREADSAFE_SSS @@ -259,4 +259,4 @@ const std::map &GetFlattenedFunctionalGroupHierarchy( } return flatten_get(); } -} +} // namespace RDKit diff --git a/Code/GraphMol/Fingerprints/MHFP.cpp b/Code/GraphMol/Fingerprints/MHFP.cpp index 6430888c4..b75dccb68 100644 --- a/Code/GraphMol/Fingerprints/MHFP.cpp +++ b/Code/GraphMol/Fingerprints/MHFP.cpp @@ -42,8 +42,10 @@ MHFPEncoder::MHFPEncoder(unsigned int n_permutations, unsigned int seed) boost::mt19937 rand; rand.seed(seed_); - boost::random::uniform_int_distribution dist_a(1, max_hash_); - boost::random::uniform_int_distribution dist_b(0, max_hash_); + boost::random::uniform_int_distribution dist_a( + 1, max_hash_); + boost::random::uniform_int_distribution dist_b( + 0, max_hash_); for (unsigned int i = 0; i < n_permutations_; i++) { uint32_t a = dist_a(rand); diff --git a/Code/GraphMol/Fingerprints/Wrap/MHFPWrapper.cpp b/Code/GraphMol/Fingerprints/Wrap/MHFPWrapper.cpp index 34f68522e..1af87afee 100644 --- a/Code/GraphMol/Fingerprints/Wrap/MHFPWrapper.cpp +++ b/Code/GraphMol/Fingerprints/Wrap/MHFPWrapper.cpp @@ -16,18 +16,16 @@ namespace python = boost::python; using RDKit::MHFPFingerprints::MHFPEncoder; - namespace RDKit { namespace MHFPWrapper { typedef std::vector> VectMinHashVect; typedef std::vector VectExplicitBitVect; -template -std::vector ListToVector(const python::object& obj) -{ +template +std::vector ListToVector(const python::object& obj) { return std::vector(python::stl_input_iterator(obj), - python::stl_input_iterator()); + python::stl_input_iterator()); } UINT_VECT @@ -43,274 +41,192 @@ FromArray(MHFPEncoder* mhfpEnc, python::list& vec) { } STR_VECT -CreateShinglingFromSmiles(MHFPEncoder* mhfpEnc, - std::string smiles, - unsigned char radius = 3, - bool rings = true, - bool isomeric = false, - bool kekulize = true, - unsigned char min_radius = 1) { - return mhfpEnc->CreateShingling(smiles, radius, rings, isomeric, kekulize, min_radius); +CreateShinglingFromSmiles(MHFPEncoder* mhfpEnc, std::string smiles, + unsigned char radius = 3, bool rings = true, + bool isomeric = false, bool kekulize = true, + unsigned char min_radius = 1) { + return mhfpEnc->CreateShingling(smiles, radius, rings, isomeric, kekulize, + min_radius); } STR_VECT -CreateShinglingFromMol(MHFPEncoder* mhfpEnc, - ROMol mol, - unsigned char radius = 3, - bool rings = true, - bool isomeric = false, - bool kekulize = true, - unsigned char min_radius = 1) { - return mhfpEnc->CreateShingling(mol, radius, rings, isomeric, kekulize, min_radius); +CreateShinglingFromMol(MHFPEncoder* mhfpEnc, ROMol mol, + unsigned char radius = 3, bool rings = true, + bool isomeric = false, bool kekulize = true, + unsigned char min_radius = 1) { + return mhfpEnc->CreateShingling(mol, radius, rings, isomeric, kekulize, + min_radius); } UINT_VECT -EncodeSmiles(MHFPEncoder* mhfpEnc, - std::string smiles, - unsigned char radius = 3, - bool rings = true, - bool isomeric = false, - bool kekulize = true, - unsigned char min_radius = 1) { +EncodeSmiles(MHFPEncoder* mhfpEnc, std::string smiles, unsigned char radius = 3, + bool rings = true, bool isomeric = false, bool kekulize = true, + unsigned char min_radius = 1) { return mhfpEnc->Encode(smiles, radius, rings, isomeric, kekulize, min_radius); } UINT_VECT -EncodeMol(MHFPEncoder* mhfpEnc, - ROMol mol, - unsigned char radius = 3, - bool rings = true, - bool isomeric = false, - bool kekulize = true, - unsigned char min_radius = 1) { +EncodeMol(MHFPEncoder* mhfpEnc, ROMol mol, unsigned char radius = 3, + bool rings = true, bool isomeric = false, bool kekulize = true, + unsigned char min_radius = 1) { return mhfpEnc->Encode(mol, radius, rings, isomeric, kekulize, min_radius); } -VectMinHashVect -EncodeSmilesBulk(MHFPEncoder* mhfpEnc, - python::list& smiles, - unsigned char radius = 3, - bool rings = true, - bool isomeric = false, - bool kekulize = true, - unsigned char min_radius = 1) { +VectMinHashVect EncodeSmilesBulk(MHFPEncoder* mhfpEnc, python::list& smiles, + unsigned char radius = 3, bool rings = true, + bool isomeric = false, bool kekulize = true, + unsigned char min_radius = 1) { std::vector vec = ListToVector(smiles); return mhfpEnc->Encode(vec, radius, rings, isomeric, kekulize, min_radius); } - // There are access problems for vector_indexing_suite and std::vector. -// So let's fallback to a unefficient Python list. -VectMinHashVect -EncodeMolsBulk(MHFPEncoder* mhfpEnc, - python::list& mols, - unsigned char radius = 3, - bool rings = true, - bool isomeric = false, - bool kekulize = true, - unsigned char min_radius = 1) { +// So let's fallback to a unefficient Python list. +VectMinHashVect EncodeMolsBulk(MHFPEncoder* mhfpEnc, python::list& mols, + unsigned char radius = 3, bool rings = true, + bool isomeric = false, bool kekulize = true, + unsigned char min_radius = 1) { std::vector vec = ListToVector(mols); return mhfpEnc->Encode(vec, radius, rings, isomeric, kekulize, min_radius); } // SECFP -ExplicitBitVect -EncodeSECFPSmiles(MHFPEncoder* mhfpEnc, - std::string smiles, - unsigned char radius = 3, - bool rings = true, - bool isomeric = false, - bool kekulize = true, - unsigned char min_radius = 1, - size_t length = 2048) { - return mhfpEnc->EncodeSECFP(smiles, radius, rings, isomeric, kekulize, min_radius, length); +ExplicitBitVect EncodeSECFPSmiles(MHFPEncoder* mhfpEnc, std::string smiles, + unsigned char radius = 3, bool rings = true, + bool isomeric = false, bool kekulize = true, + unsigned char min_radius = 1, + size_t length = 2048) { + return mhfpEnc->EncodeSECFP(smiles, radius, rings, isomeric, kekulize, + min_radius, length); } -ExplicitBitVect -EncodeSECFPMol(MHFPEncoder* mhfpEnc, - ROMol mol, - unsigned char radius = 3, - bool rings = true, - bool isomeric = false, - bool kekulize = true, - unsigned char min_radius = 1, - size_t length = 2048) { - return mhfpEnc->EncodeSECFP(mol, radius, rings, isomeric, kekulize, min_radius, length); +ExplicitBitVect EncodeSECFPMol(MHFPEncoder* mhfpEnc, ROMol mol, + unsigned char radius = 3, bool rings = true, + bool isomeric = false, bool kekulize = true, + unsigned char min_radius = 1, + size_t length = 2048) { + return mhfpEnc->EncodeSECFP(mol, radius, rings, isomeric, kekulize, + min_radius, length); } -VectExplicitBitVect -EncodeSECFPSmilesBulk(MHFPEncoder* mhfpEnc, - python::list& smiles, - unsigned char radius = 3, - bool rings = true, - bool isomeric = false, - bool kekulize = true, - unsigned char min_radius = 1, - size_t length = 2048) { +VectExplicitBitVect EncodeSECFPSmilesBulk( + MHFPEncoder* mhfpEnc, python::list& smiles, unsigned char radius = 3, + bool rings = true, bool isomeric = false, bool kekulize = true, + unsigned char min_radius = 1, size_t length = 2048) { std::vector vec = ListToVector(smiles); - return mhfpEnc->EncodeSECFP(vec, radius, rings, isomeric, kekulize, min_radius, length); + return mhfpEnc->EncodeSECFP(vec, radius, rings, isomeric, kekulize, + min_radius, length); } -VectExplicitBitVect -EncodeSECFPMolsBulk(MHFPEncoder* mhfpEnc, - python::list& mols, - unsigned char radius = 3, - bool rings = true, - bool isomeric = false, - bool kekulize = true, - unsigned char min_radius = 1, - size_t length = 2048) { +VectExplicitBitVect EncodeSECFPMolsBulk( + MHFPEncoder* mhfpEnc, python::list& mols, unsigned char radius = 3, + bool rings = true, bool isomeric = false, bool kekulize = true, + unsigned char min_radius = 1, size_t length = 2048) { std::vector vec = ListToVector(mols); - return mhfpEnc->EncodeSECFP(vec, radius, rings, isomeric, kekulize, min_radius, length); + return mhfpEnc->EncodeSECFP(vec, radius, rings, isomeric, kekulize, + min_radius, length); } -BOOST_PYTHON_FUNCTION_OVERLOADS(CreateShinglingFromSmilesOverloads, CreateShinglingFromSmiles, 2, 7) -BOOST_PYTHON_FUNCTION_OVERLOADS(CreateShinglingFromMolOverloads, CreateShinglingFromMol, 2, 7) +BOOST_PYTHON_FUNCTION_OVERLOADS(CreateShinglingFromSmilesOverloads, + CreateShinglingFromSmiles, 2, 7) +BOOST_PYTHON_FUNCTION_OVERLOADS(CreateShinglingFromMolOverloads, + CreateShinglingFromMol, 2, 7) BOOST_PYTHON_FUNCTION_OVERLOADS(EncodeSmilesOverloads, EncodeSmiles, 2, 7) BOOST_PYTHON_FUNCTION_OVERLOADS(EncodeMolOverloads, EncodeMol, 2, 7) -BOOST_PYTHON_FUNCTION_OVERLOADS(EncodeSmilesBulkOverloads, EncodeSmilesBulk, 2, 7) +BOOST_PYTHON_FUNCTION_OVERLOADS(EncodeSmilesBulkOverloads, EncodeSmilesBulk, 2, + 7) BOOST_PYTHON_FUNCTION_OVERLOADS(EncodeMolsBulkOverloads, EncodeMolsBulk, 2, 7) -BOOST_PYTHON_FUNCTION_OVERLOADS(EncodeSECFPSmilesOverloads, EncodeSECFPSmiles, 2, 8) +BOOST_PYTHON_FUNCTION_OVERLOADS(EncodeSECFPSmilesOverloads, EncodeSECFPSmiles, + 2, 8) BOOST_PYTHON_FUNCTION_OVERLOADS(EncodeSECFPMolOverloads, EncodeSECFPMol, 2, 8) -BOOST_PYTHON_FUNCTION_OVERLOADS(EncodeSECFPSmilesBulkOverloads, EncodeSECFPSmilesBulk, 2, 8) -BOOST_PYTHON_FUNCTION_OVERLOADS(EncodeSECFPMolsBulkOverloads, EncodeSECFPMolsBulk, 2, 8) +BOOST_PYTHON_FUNCTION_OVERLOADS(EncodeSECFPSmilesBulkOverloads, + EncodeSECFPSmilesBulk, 2, 8) +BOOST_PYTHON_FUNCTION_OVERLOADS(EncodeSECFPMolsBulkOverloads, + EncodeSECFPMolsBulk, 2, 8) BOOST_PYTHON_MODULE(rdMHFPFingerprint) { - python::class_("MHFPEncoder", python::init>()) - .def("FromStringArray", &FromStringArray, ( - ( - python::arg("vec") - ), - "Creates a MHFP vector from a list of arbitrary strings." - )) - .def("FromArray", &FromArray, ( - ( - python::arg("vec") - ), - "Creates a MHFP vector from a list of unsigned integers." - )) - .def("CreateShinglingFromSmiles", CreateShinglingFromSmiles, CreateShinglingFromSmilesOverloads( - ( - python::arg("smiles"), - python::arg("radius") = 3, - python::arg("rings") = true, - python::arg("isomeric") = false, - python::arg("kekulize") = false, - python::arg("min_radius") = 1 - ), - "Creates a shingling (a list of circular n-grams / substructures) from a SMILES string." - )) - .def("CreateShinglingFromMol", CreateShinglingFromMol, CreateShinglingFromMolOverloads( - ( - python::arg("mol"), - python::arg("radius") = 3, - python::arg("rings") = true, - python::arg("isomeric") = false, - python::arg("kekulize") = false, - python::arg("min_radius") = 1 - ), - "Creates a shingling (a list of circular n-grams / substructures) from a RDKit Mol instance." - )) - .def("EncodeSmiles", EncodeSmiles, EncodeSmilesOverloads( - ( - python::arg("smiles"), - python::arg("radius") = 3, - python::arg("rings") = true, - python::arg("isomeric") = false, - python::arg("kekulize") = false, - python::arg("min_radius") = 1 - ), - "Creates a MHFP vector from a SMILES string." - )) - .def("EncodeMol", EncodeMol, EncodeMolOverloads( - ( - python::arg("mol"), - python::arg("radius") = 3, - python::arg("rings") = true, - python::arg("isomeric") = false, - python::arg("kekulize") = false, - python::arg("min_radius") = 1 - ), - "Creates a MHFP vector from an RDKit Mol instance." - )) - .def("EncodeSmilesBulk", EncodeSmilesBulk, EncodeSmilesBulkOverloads( - ( - python::arg("smiles"), - python::arg("radius") = 3, - python::arg("rings") = true, - python::arg("isomeric") = false, - python::arg("kekulize") = false, - python::arg("min_radius") = 1 - ), - "Creates a MHFP vector from a list of SMILES strings." - )) - .def("EncodeMolsBulk", EncodeMolsBulk, EncodeMolsBulkOverloads( - ( - python::arg("mols"), - python::arg("radius") = 3, - python::arg("rings") = true, - python::arg("isomeric") = false, - python::arg("kekulize") = false, - python::arg("min_radius") = 1 - ), - "Creates a MHFP vector from a list of RDKit Mol instances." - )) - .def("EncodeSECFPSmiles", EncodeSECFPSmiles, EncodeSECFPSmilesOverloads( - ( - python::arg("smiles"), - python::arg("radius") = 3, - python::arg("rings") = true, - python::arg("isomeric") = false, - python::arg("kekulize") = false, - python::arg("min_radius") = 1, - python::arg("length") = 2048 - ), - "Creates a SECFP binary vector from a SMILES string." - )) - .def("EncodeSECFPMol", EncodeSECFPMol, EncodeSECFPMolOverloads( - ( - python::arg("smiles"), - python::arg("radius") = 3, - python::arg("rings") = true, - python::arg("isomeric") = false, - python::arg("kekulize") = false, - python::arg("min_radius") = 1, - python::arg("length") = 2048 - ), - "Creates a SECFP binary vector from an RDKit Mol instance." - )) - .def("EncodeSECFPSmilesBulk", EncodeSECFPSmilesBulk, EncodeSECFPSmilesBulkOverloads( - ( - python::arg("smiles"), - python::arg("radius") = 3, - python::arg("rings") = true, - python::arg("isomeric") = false, - python::arg("kekulize") = false, - python::arg("min_radius") = 1, - python::arg("length") = 2048 - ), - "Creates a SECFP binary vector from a list of SMILES strings." - )) - .def("EncodeSECFPMolsBulk", EncodeSECFPMolsBulk, EncodeSECFPMolsBulkOverloads( - ( - python::arg("smiles"), - python::arg("radius") = 3, - python::arg("rings") = true, - python::arg("isomeric") = false, - python::arg("kekulize") = false, - python::arg("min_radius") = 1, - python::arg("length") = 2048 - ), - "Creates a SECFP binary vector from a list of RDKit Mol instances." - )) - .def("Distance", &MHFPEncoder::Distance) - .staticmethod("Distance"); + python::class_( + "MHFPEncoder", + python::init>()) + .def("FromStringArray", &FromStringArray, + ((python::arg("vec")), + "Creates a MHFP vector from a list of arbitrary strings.")) + .def("FromArray", &FromArray, + ((python::arg("vec")), + "Creates a MHFP vector from a list of unsigned integers.")) + .def("CreateShinglingFromSmiles", CreateShinglingFromSmiles, + CreateShinglingFromSmilesOverloads( + (python::arg("smiles"), python::arg("radius") = 3, + python::arg("rings") = true, python::arg("isomeric") = false, + python::arg("kekulize") = false, python::arg("min_radius") = 1), + "Creates a shingling (a list of circular n-grams / " + "substructures) from a SMILES string.")) + .def("CreateShinglingFromMol", CreateShinglingFromMol, + CreateShinglingFromMolOverloads( + (python::arg("mol"), python::arg("radius") = 3, + python::arg("rings") = true, python::arg("isomeric") = false, + python::arg("kekulize") = false, python::arg("min_radius") = 1), + "Creates a shingling (a list of circular n-grams / " + "substructures) from a RDKit Mol instance.")) + .def("EncodeSmiles", EncodeSmiles, + EncodeSmilesOverloads( + (python::arg("smiles"), python::arg("radius") = 3, + python::arg("rings") = true, python::arg("isomeric") = false, + python::arg("kekulize") = false, python::arg("min_radius") = 1), + "Creates a MHFP vector from a SMILES string.")) + .def("EncodeMol", EncodeMol, + EncodeMolOverloads( + (python::arg("mol"), python::arg("radius") = 3, + python::arg("rings") = true, python::arg("isomeric") = false, + python::arg("kekulize") = false, python::arg("min_radius") = 1), + "Creates a MHFP vector from an RDKit Mol instance.")) + .def("EncodeSmilesBulk", EncodeSmilesBulk, + EncodeSmilesBulkOverloads( + (python::arg("smiles"), python::arg("radius") = 3, + python::arg("rings") = true, python::arg("isomeric") = false, + python::arg("kekulize") = false, python::arg("min_radius") = 1), + "Creates a MHFP vector from a list of SMILES strings.")) + .def("EncodeMolsBulk", EncodeMolsBulk, + EncodeMolsBulkOverloads( + (python::arg("mols"), python::arg("radius") = 3, + python::arg("rings") = true, python::arg("isomeric") = false, + python::arg("kekulize") = false, python::arg("min_radius") = 1), + "Creates a MHFP vector from a list of RDKit Mol instances.")) + .def("EncodeSECFPSmiles", EncodeSECFPSmiles, + EncodeSECFPSmilesOverloads( + (python::arg("smiles"), python::arg("radius") = 3, + python::arg("rings") = true, python::arg("isomeric") = false, + python::arg("kekulize") = false, python::arg("min_radius") = 1, + python::arg("length") = 2048), + "Creates a SECFP binary vector from a SMILES string.")) + .def("EncodeSECFPMol", EncodeSECFPMol, + EncodeSECFPMolOverloads( + (python::arg("smiles"), python::arg("radius") = 3, + python::arg("rings") = true, python::arg("isomeric") = false, + python::arg("kekulize") = false, python::arg("min_radius") = 1, + python::arg("length") = 2048), + "Creates a SECFP binary vector from an RDKit Mol instance.")) + .def("EncodeSECFPSmilesBulk", EncodeSECFPSmilesBulk, + EncodeSECFPSmilesBulkOverloads( + (python::arg("smiles"), python::arg("radius") = 3, + python::arg("rings") = true, python::arg("isomeric") = false, + python::arg("kekulize") = false, python::arg("min_radius") = 1, + python::arg("length") = 2048), + "Creates a SECFP binary vector from a list of SMILES strings.")) + .def("EncodeSECFPMolsBulk", EncodeSECFPMolsBulk, + EncodeSECFPMolsBulkOverloads( + (python::arg("smiles"), python::arg("radius") = 3, + python::arg("rings") = true, python::arg("isomeric") = false, + python::arg("kekulize") = false, python::arg("min_radius") = 1, + python::arg("length") = 2048), + "Creates a SECFP binary vector from a list of RDKit Mol " + "instances.")) + .def("Distance", &MHFPEncoder::Distance) + .staticmethod("Distance"); } - - } // namespace MHFPWrapper } // namespace RDKit diff --git a/Code/GraphMol/Fingerprints/testMHFPFingerprint.cpp b/Code/GraphMol/Fingerprints/testMHFPFingerprint.cpp index 46c64579c..cc64ce1b2 100644 --- a/Code/GraphMol/Fingerprints/testMHFPFingerprint.cpp +++ b/Code/GraphMol/Fingerprints/testMHFPFingerprint.cpp @@ -23,10 +23,10 @@ using namespace RDKit; - void testMHFPInit() { BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl; - BOOST_LOG(rdErrorLog) << "Test MHFP fingerprint encoder initialization" << std::endl; + BOOST_LOG(rdErrorLog) << "Test MHFP fingerprint encoder initialization" + << std::endl; std::string s = "CN1C=NC2=C1C(=O)N(C(=O)N2C)C"; std::string t = "Cn1cnc2c1c(=O)[nH]c(=O)n2C"; @@ -53,29 +53,23 @@ void testMHFPInit() { void testMHFPHashing() { BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl; - BOOST_LOG(rdErrorLog) << "Test MHFP hashing of string and uint arrays" << std::endl; + BOOST_LOG(rdErrorLog) << "Test MHFP hashing of string and uint arrays" + << std::endl; MHFPFingerprints::MHFPEncoder enc(8); - std::vector input_a = { - 1, 2, 4, 5, 6, 7, 8, 9 - }; + std::vector input_a = {1, 2, 4, 5, 6, 7, 8, 9}; - std::vector output_a = { - 188049437, 364485576, 737251017, 810894466, - 300249621, 154369992, 2221926165, 283729444 - }; + std::vector output_a = {188049437, 364485576, 737251017, + 810894466, 300249621, 154369992, + 2221926165, 283729444}; TEST_ASSERT(enc.FromArray(input_a) == output_a); - std::vector input_b = { - "a", "b", "c", "d", "e", "f" - }; + std::vector input_b = {"a", "b", "c", "d", "e", "f"}; - std::vector output_b = { - 631555539, 835857365, 445245415, 4162827301, - 955545975, 943207071, 712975995, 363547692 - }; + std::vector output_b = {631555539, 835857365, 445245415, 4162827301, + 955545975, 943207071, 712975995, 363547692}; TEST_ASSERT(enc.FromStringArray(input_b) == output_b); @@ -144,7 +138,8 @@ void testMHFPDistance() { auto fp_s = enc.Encode(s); auto fp_t = enc.Encode(t); - TEST_ASSERT(feq(MHFPFingerprints::MHFPEncoder::Distance(fp_s, fp_t), 0.2890625)); + TEST_ASSERT( + feq(MHFPFingerprints::MHFPEncoder::Distance(fp_s, fp_t), 0.2890625)); BOOST_LOG(rdErrorLog) << " done" << std::endl; } diff --git a/Code/GraphMol/ForceFieldHelpers/CrystalFF/TorsionAngleM6.cpp b/Code/GraphMol/ForceFieldHelpers/CrystalFF/TorsionAngleM6.cpp index a1fc80ace..f3ddaeff1 100644 --- a/Code/GraphMol/ForceFieldHelpers/CrystalFF/TorsionAngleM6.cpp +++ b/Code/GraphMol/ForceFieldHelpers/CrystalFF/TorsionAngleM6.cpp @@ -135,4 +135,4 @@ void TorsionAngleContribM6::getGrad(double *pos, double *grad) const { Utils::calcTorsionGrad(r, t, d, g, sinTerm, cosPhi); } } // namespace CrystalFF -} // namespace RDKit +} // namespace ForceFields diff --git a/Code/GraphMol/ForceFieldHelpers/CrystalFF/testCrystalFF.cpp b/Code/GraphMol/ForceFieldHelpers/CrystalFF/testCrystalFF.cpp index 53d8cd562..6b930edcd 100644 --- a/Code/GraphMol/ForceFieldHelpers/CrystalFF/testCrystalFF.cpp +++ b/Code/GraphMol/ForceFieldHelpers/CrystalFF/testCrystalFF.cpp @@ -123,8 +123,8 @@ void testTorsionPrefs() { TEST_ASSERT(mol); ForceFields::CrystalFF::CrystalFFDetails details; - ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, false, false, false, 1, - false); + ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, false, + false, false, 1, false); TEST_ASSERT(details.expTorsionAtoms.size() == 1); TEST_ASSERT(details.expTorsionAngles.size() == 1); TEST_ASSERT(details.expTorsionAtoms[0][0] == 0); @@ -136,8 +136,8 @@ void testTorsionPrefs() { mol = SmilesToMol("CCCCC"); TEST_ASSERT(mol); - ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, false, false, false, 1, - false); + ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, false, + false, false, 1, false); TEST_ASSERT(details.expTorsionAtoms.size() == 2); TEST_ASSERT(details.expTorsionAngles.size() == 2); delete mol; @@ -149,15 +149,15 @@ void testTorsionPrefsSmallRings() { mol = SmilesToMol("C1COCC1"); TEST_ASSERT(mol); - //small ring torsion turned off - ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, false, false, - false, 1, false); + // small ring torsion turned off + ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, false, + false, false, 1, false); TEST_ASSERT(details.expTorsionAtoms.size() == 0); TEST_ASSERT(details.expTorsionAngles.size() == 0); - //small ring torsion turned on - ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, true, false, - false, 1, false); + // small ring torsion turned on + ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, true, + false, false, 1, false); TEST_ASSERT(details.expTorsionAtoms.size() > 0); TEST_ASSERT(details.expTorsionAngles.size() > 0); delete mol; @@ -171,9 +171,9 @@ void testTorsionPrefsBridgedSmallRings() { mol = SmilesToMol("O[C@H]1C[C@H]2CC[C@]1(C)C2(C)C"); TEST_ASSERT(mol); - //small ring torsion turned off - ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, true, false, - false, 1, false); + // small ring torsion turned off + ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, true, + false, false, 1, false); TEST_ASSERT(details.expTorsionAtoms.size() == 0); TEST_ASSERT(details.expTorsionAngles.size() == 0); delete mol; @@ -186,14 +186,14 @@ void testTorsionPrefsMacrocycles() { TEST_ASSERT(mol); // macrocycle ring torsion turned off - ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, false, false, - false, 1, false); + ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, false, + false, false, 1, false); TEST_ASSERT(details.expTorsionAtoms.size() == 0); TEST_ASSERT(details.expTorsionAngles.size() == 0); // macrocycle ring torsion turned on - ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, false, true, - false, 1, false); + ForceFields::CrystalFF::getExperimentalTorsions(*mol, details, true, false, + true, false, 1, false); TEST_ASSERT(details.expTorsionAtoms.size() > 0); TEST_ASSERT(details.expTorsionAngles.size() > 0); delete mol; diff --git a/Code/GraphMol/FragCatalog/FragCatParams.cpp b/Code/GraphMol/FragCatalog/FragCatParams.cpp index 6d74bb4cb..dcce284ee 100644 --- a/Code/GraphMol/FragCatalog/FragCatParams.cpp +++ b/Code/GraphMol/FragCatalog/FragCatParams.cpp @@ -102,4 +102,4 @@ void FragCatParams::initFromStream(std::istream &ss) { d_funcGroups = readFuncGroups(ss, nGroups); } -} +} // namespace RDKit diff --git a/Code/GraphMol/FragCatalog/FragCatalogEntry.cpp b/Code/GraphMol/FragCatalog/FragCatalogEntry.cpp index f3045f1c4..94c725e9c 100644 --- a/Code/GraphMol/FragCatalog/FragCatalogEntry.cpp +++ b/Code/GraphMol/FragCatalog/FragCatalogEntry.cpp @@ -83,8 +83,8 @@ void FragCatalogEntry::setDescription(const FragCatParams *params) { fGroup = params->getFuncGroup(*fGroupIdx); fGroup->getProp(common_properties::_Name, temp); label += "<" + temp + ">"; - dp_mol->getAtomWithIdx(atIdx) - ->setProp(common_properties::_supplementalSmilesLabel, label); + dp_mol->getAtomWithIdx(atIdx)->setProp( + common_properties::_supplementalSmilesLabel, label); } std::string smi = MolToSmiles(*dp_mol); // std::cerr << "----" << smi << "----" << std::endl; @@ -269,4 +269,4 @@ void FragCatalogEntry::initFromString(const std::string &text) { // now start reading out values: initFromStream(ss); } -} +} // namespace RDKit diff --git a/Code/GraphMol/FragCatalog/Wrap/FragCatGenerator.cpp b/Code/GraphMol/FragCatalog/Wrap/FragCatGenerator.cpp index 7682d46bf..2dc3202c4 100644 --- a/Code/GraphMol/FragCatalog/Wrap/FragCatGenerator.cpp +++ b/Code/GraphMol/FragCatalog/Wrap/FragCatGenerator.cpp @@ -21,6 +21,6 @@ struct fragcatgen_wrapper { .def("AddFragsFromMol", &FragCatGenerator::addFragsFromMol); }; }; // end of struct -} // end of namespace +} // namespace RDKit void wrap_fragcatgen() { RDKit::fragcatgen_wrapper::wrap(); } diff --git a/Code/GraphMol/FragCatalog/Wrap/FragCatalog.cpp b/Code/GraphMol/FragCatalog/Wrap/FragCatalog.cpp index 741267ad7..9fc2293cd 100644 --- a/Code/GraphMol/FragCatalog/Wrap/FragCatalog.cpp +++ b/Code/GraphMol/FragCatalog/Wrap/FragCatalog.cpp @@ -121,8 +121,9 @@ struct fragcat_wrapper { .def(python::init()) .def("GetNumEntries", &FragCatalog::getNumEntries) .def("GetFPLength", &FragCatalog::getFPLength) - .def("GetCatalogParams", (FragCatParams * (FragCatalog::*)()) & - FragCatalog::getCatalogParams, + .def("GetCatalogParams", + (FragCatParams * (FragCatalog::*)()) & + FragCatalog::getCatalogParams, python::return_value_policy()) .def("Serialize", &FragCatalog::Serialize) @@ -146,6 +147,6 @@ struct fragcat_wrapper { }; }; -} // end of namespace +} // namespace RDKit void wrap_fragcat() { RDKit::fragcat_wrapper::wrap(); } diff --git a/Code/GraphMol/FragCatalog/Wrap/FragFPGenerator.cpp b/Code/GraphMol/FragCatalog/Wrap/FragFPGenerator.cpp index a115724f3..b1b886f48 100644 --- a/Code/GraphMol/FragCatalog/Wrap/FragFPGenerator.cpp +++ b/Code/GraphMol/FragCatalog/Wrap/FragFPGenerator.cpp @@ -22,6 +22,6 @@ struct fragFPgen_wrapper { python::return_value_policy()); }; }; -} +} // namespace RDKit void wrap_fragFPgen() { RDKit::fragFPgen_wrapper::wrap(); } diff --git a/Code/GraphMol/GraphMol.cpp b/Code/GraphMol/GraphMol.cpp index 922df547b..57bce3b1d 100644 --- a/Code/GraphMol/GraphMol.cpp +++ b/Code/GraphMol/GraphMol.cpp @@ -9,4 +9,4 @@ // #include "GraphMol.h" -namespace RDKit {} // end o' namespace +namespace RDKit {} // namespace RDKit diff --git a/Code/GraphMol/MolAlign/Wrap/rdMolAlign.cpp b/Code/GraphMol/MolAlign/Wrap/rdMolAlign.cpp index 0202e44cb..39f50c99c 100644 --- a/Code/GraphMol/MolAlign/Wrap/rdMolAlign.cpp +++ b/Code/GraphMol/MolAlign/Wrap/rdMolAlign.cpp @@ -178,8 +178,8 @@ double CalcRMS(ROMol &prbMol, ROMol &refMol, int prbCid, int refCid, double rmsd; { NOGIL gil; - rmsd = - MolAlign::CalcRMS(prbMol, refMol, prbCid, refCid, aMapVec, maxMatches, wtsVec); + rmsd = MolAlign::CalcRMS(prbMol, refMol, prbCid, refCid, aMapVec, + maxMatches, wtsVec); } return rmsd; } @@ -687,7 +687,8 @@ BOOST_PYTHON_MODULE(rdMolAlign) { "CalcRMS", RDKit::CalcRMS, (python::arg("prbMol"), python::arg("refMol"), python::arg("prbId") = -1, python::arg("refId") = -1, python::arg("map") = python::object(), - python::arg("maxMatches") = 1000000, python::arg("weights") = python::list()), + python::arg("maxMatches") = 1000000, + python::arg("weights") = python::list()), docString.c_str()); docString = diff --git a/Code/GraphMol/MolAlign/testO3AAlign.cpp b/Code/GraphMol/MolAlign/testO3AAlign.cpp index 8a13980a6..a9598ed2a 100644 --- a/Code/GraphMol/MolAlign/testO3AAlign.cpp +++ b/Code/GraphMol/MolAlign/testO3AAlign.cpp @@ -532,7 +532,9 @@ void testMMFFO3AMultiThread() { fut.get(); } - for (auto &&mol : mols) { delete mol; } + for (auto &&mol : mols) { + delete mol; + } BOOST_LOG(rdErrorLog) << " done" << std::endl; } @@ -599,7 +601,9 @@ void testCrippenO3AMultiThread() { fut.get(); } - for (auto *mol : mols) { delete mol; } + for (auto *mol : mols) { + delete mol; + } BOOST_LOG(rdErrorLog) << " done" << std::endl; } #endif @@ -734,7 +738,9 @@ void testO3AMultiThreadBug() { #endif delete refMol; - for (auto &&mol : mols) { delete mol; } + for (auto &&mol : mols) { + delete mol; + } BOOST_LOG(rdErrorLog) << " done" << std::endl; } diff --git a/Code/GraphMol/MolCatalog/Wrap/rdMolCatalog.cpp b/Code/GraphMol/MolCatalog/Wrap/rdMolCatalog.cpp index 131aff8d5..6864144ac 100644 --- a/Code/GraphMol/MolCatalog/Wrap/rdMolCatalog.cpp +++ b/Code/GraphMol/MolCatalog/Wrap/rdMolCatalog.cpp @@ -122,7 +122,7 @@ struct MolCatalogEntry_wrapper { ; }; }; -} +} // namespace BOOST_PYTHON_MODULE(rdMolCatalog) { MolCatalog_wrapper::wrap(); diff --git a/Code/GraphMol/MolChemicalFeatures/MolChemicalFeatureDef.cpp b/Code/GraphMol/MolChemicalFeatures/MolChemicalFeatureDef.cpp index 1f008a6c6..7f97dda4f 100644 --- a/Code/GraphMol/MolChemicalFeatures/MolChemicalFeatureDef.cpp +++ b/Code/GraphMol/MolChemicalFeatures/MolChemicalFeatureDef.cpp @@ -33,4 +33,4 @@ void MolChemicalFeatureDef::normalizeWeights() { *i /= accum; } } -} +} // namespace RDKit diff --git a/Code/GraphMol/MolChemicalFeatures/Wrap/MolChemicalFeature.cpp b/Code/GraphMol/MolChemicalFeatures/Wrap/MolChemicalFeature.cpp index 37feb7c2c..bb5188d7e 100644 --- a/Code/GraphMol/MolChemicalFeatures/Wrap/MolChemicalFeature.cpp +++ b/Code/GraphMol/MolChemicalFeatures/Wrap/MolChemicalFeature.cpp @@ -56,11 +56,12 @@ struct feat_wrapper { MolChemicalFeature::getPos, (python::arg("self"), python::arg("confId")), "Get the location of the chemical feature") - .def("GetPos", - (RDGeom::Point3D(MolChemicalFeature::*)() const) & - MolChemicalFeature::getPos, - python::arg("self"), - "Get the location of the default chemical feature (first position)") + .def( + "GetPos", + (RDGeom::Point3D(MolChemicalFeature::*)() const) & + MolChemicalFeature::getPos, + python::arg("self"), + "Get the location of the default chemical feature (first position)") .def("GetAtomIds", getFeatAtomIds, "Get the IDs of the atoms that participate in the feature") .def("GetMol", &MolChemicalFeature::getMol, diff --git a/Code/GraphMol/MolDraw2D/DrawTextFTSVG.cpp b/Code/GraphMol/MolDraw2D/DrawTextFTSVG.cpp index 01bcd0e35..989f80903 100644 --- a/Code/GraphMol/MolDraw2D/DrawTextFTSVG.cpp +++ b/Code/GraphMol/MolDraw2D/DrawTextFTSVG.cpp @@ -45,8 +45,8 @@ double DrawTextFTSVG::extractOutline() { int DrawTextFTSVG::MoveToFunctionImpl(const FT_Vector *to) { double dx, dy; fontPosToDrawPos(to->x, to->y, dx, dy); - oss_ << "M " << MolDraw2D_detail::formatDouble(dx) - << ' ' << MolDraw2D_detail::formatDouble(dy) << std::endl; + oss_ << "M " << MolDraw2D_detail::formatDouble(dx) << ' ' + << MolDraw2D_detail::formatDouble(dy) << std::endl; return 0; } @@ -55,8 +55,8 @@ int DrawTextFTSVG::MoveToFunctionImpl(const FT_Vector *to) { int DrawTextFTSVG::LineToFunctionImpl(const FT_Vector *to) { double dx, dy; fontPosToDrawPos(to->x, to->y, dx, dy); - oss_ << "L " << MolDraw2D_detail::formatDouble(dx) - << ' ' << MolDraw2D_detail::formatDouble(dy) << std::endl; + oss_ << "L " << MolDraw2D_detail::formatDouble(dx) << ' ' + << MolDraw2D_detail::formatDouble(dy) << std::endl; return 0; } @@ -70,11 +70,10 @@ int DrawTextFTSVG::ConicToFunctionImpl(const FT_Vector *control, double dx, dy; fontPosToDrawPos(to->x, to->y, dx, dy); - oss_ << "Q " << MolDraw2D_detail::formatDouble(controlX) - << ' ' << MolDraw2D_detail::formatDouble(controlY) - << ", " << MolDraw2D_detail::formatDouble(dx) - << ' ' << MolDraw2D_detail::formatDouble(dy) - << std::endl; + oss_ << "Q " << MolDraw2D_detail::formatDouble(controlX) << ' ' + << MolDraw2D_detail::formatDouble(controlY) << ", " + << MolDraw2D_detail::formatDouble(dx) << ' ' + << MolDraw2D_detail::formatDouble(dy) << std::endl; return 0; } @@ -92,11 +91,11 @@ int DrawTextFTSVG::CubicToFunctionImpl(const FT_Vector *controlOne, fontPosToDrawPos(to->x, to->y, dx, dy); oss_ << "C " << MolDraw2D_detail::formatDouble(controlOneX) << ' ' - << MolDraw2D_detail::formatDouble(controlOneY) - << ", " << MolDraw2D_detail::formatDouble(controlTwoX) - << ' ' << MolDraw2D_detail::formatDouble(controlTwoY) - << ", " << MolDraw2D_detail::formatDouble(dx) - << ' ' << MolDraw2D_detail::formatDouble(dy) << std::endl; + << MolDraw2D_detail::formatDouble(controlOneY) << ", " + << MolDraw2D_detail::formatDouble(controlTwoX) << ' ' + << MolDraw2D_detail::formatDouble(controlTwoY) << ", " + << MolDraw2D_detail::formatDouble(dx) << ' ' + << MolDraw2D_detail::formatDouble(dy) << std::endl; return 0; } diff --git a/Code/GraphMol/MolDraw2D/Qt/Demo/MolDisplay2DWidget.cc b/Code/GraphMol/MolDraw2D/Qt/Demo/MolDisplay2DWidget.cc index a630c3cd2..0953b55b7 100644 --- a/Code/GraphMol/MolDraw2D/Qt/Demo/MolDisplay2DWidget.cc +++ b/Code/GraphMol/MolDraw2D/Qt/Demo/MolDisplay2DWidget.cc @@ -31,211 +31,182 @@ using namespace std; namespace RDKit { // **************************************************************************** -MolDisplay2DWidget::MolDisplay2DWidget( QWidget *parent , Qt::WindowFlags f ) : - QWidget( parent , f ) , pick_circle_rad_( -1 ) , atom_picking_( false ) { - -} +MolDisplay2DWidget::MolDisplay2DWidget(QWidget *parent, Qt::WindowFlags f) + : QWidget(parent, f), pick_circle_rad_(-1), atom_picking_(false) {} // **************************************************************************** -void MolDisplay2DWidget::set_display_mol( ROMOL_SPTR new_mol ) { - - if( !new_mol ) { +void MolDisplay2DWidget::set_display_mol(ROMOL_SPTR new_mol) { + if (!new_mol) { disp_mol_.reset(); } else { - disp_mol_ = RWMOL_SPTR( new RWMol( *new_mol ) ); - RDKit::MolOps::Kekulize( *disp_mol_ ); - RDDepict::compute2DCoords( *disp_mol_ ); - if( !disp_mol_->hasProp( "_drawingBondsWedged" ) ) { + disp_mol_ = RWMOL_SPTR(new RWMol(*new_mol)); + RDKit::MolOps::Kekulize(*disp_mol_); + RDDepict::compute2DCoords(*disp_mol_); + if (!disp_mol_->hasProp("_drawingBondsWedged")) { RDKit::Conformer conf = disp_mol_->getConformer(); - RDKit::WedgeMolBonds( *disp_mol_ , &conf ); + RDKit::WedgeMolBonds(*disp_mol_, &conf); } } update(); - } // **************************************************************************** -QSize MolDisplay2DWidget::minimumSize() const { - - return QSize( 100 , 100 ); - -} +QSize MolDisplay2DWidget::minimumSize() const { return QSize(100, 100); } // **************************************************************************** -void MolDisplay2DWidget::set_atom_picking( bool new_val ) { - +void MolDisplay2DWidget::set_atom_picking(bool new_val) { atom_picking_ = new_val; - if( atom_picking_ ) { + if (atom_picking_) { picked_atoms_.clear(); } - } // **************************************************************************** -void MolDisplay2DWidget::set_selected_atoms( const vector &sa ) { - +void MolDisplay2DWidget::set_selected_atoms(const vector &sa) { picked_atoms_ = sa; update(); - } // **************************************************************************** int MolDisplay2DWidget::pick_circle_rad() const { - - if( -1 == pick_circle_rad_ ) { - pick_circle_rad_ = std::min( width() / 100 , height() / 100 ); + if (-1 == pick_circle_rad_) { + pick_circle_rad_ = std::min(width() / 100, height() / 100); } return pick_circle_rad_; - } // **************************************************************************** -QSize MolDisplay2DWidget::sizeHint() const { - - return QSize( 400 , 400 ); - -} +QSize MolDisplay2DWidget::sizeHint() const { return QSize(400, 400); } // **************************************************************************** -void MolDisplay2DWidget::paintEvent( QPaintEvent *event ) { - - pick_circle_rad_ = std::min( width() / 100 , height() / 100 ); +void MolDisplay2DWidget::paintEvent(QPaintEvent *event) { + pick_circle_rad_ = std::min(width() / 100, height() / 100); QPainter qp; - qp.begin( this ); + qp.begin(this); QFont font = qp.font(); - font.setPointSize( 6 ); - qp.setFont( font ); + font.setPointSize(6); + qp.setFont(font); - qp.setRenderHint( QPainter::Antialiasing , true ); - qp.setRenderHint( QPainter::TextAntialiasing , true ); + qp.setRenderHint(QPainter::Antialiasing, true); + qp.setRenderHint(QPainter::TextAntialiasing, true); - if( !disp_mol_ ) { + if (!disp_mol_) { return; } - draw_molecule( qp ); - + draw_molecule(qp); } // **************************************************************************** -void MolDisplay2DWidget::mousePressEvent( QMouseEvent *event ) { - - if( atom_picking_ ) { - select_atom( event ); +void MolDisplay2DWidget::mousePressEvent(QMouseEvent *event) { + if (atom_picking_) { + select_atom(event); } update(); - } // **************************************************************************** -void MolDisplay2DWidget::select_atom( QMouseEvent *event ) { - - int na = find_nearest_atom( event->x() , event->y() ); - if( -1 != na ) { - vector::iterator p = std::find( picked_atoms_.begin() , picked_atoms_.end() , na ); - if( p == picked_atoms_.end() ) { - picked_atoms_.push_back( na ); +void MolDisplay2DWidget::select_atom(QMouseEvent *event) { + int na = find_nearest_atom(event->x(), event->y()); + if (-1 != na) { + vector::iterator p = + std::find(picked_atoms_.begin(), picked_atoms_.end(), na); + if (p == picked_atoms_.end()) { + picked_atoms_.push_back(na); } else { - picked_atoms_.erase( p ); + picked_atoms_.erase(p); } } else { - if( !(event->modifiers() & Qt::ControlModifier) ) { + if (!(event->modifiers() & Qt::ControlModifier)) { // user missed, doesn't have control button down, so clear picked_atoms_.clear(); } } - } // **************************************************************************** -void MolDisplay2DWidget::draw_molecule( QPainter &qp ) { - - string mol_name = disp_mol_->getProp( "_Name" ); +void MolDisplay2DWidget::draw_molecule(QPainter &qp) { + string mol_name = disp_mol_->getProp("_Name"); int h = rect().height(); - if( !mol_name.empty() ) { - h = int( float( rect().height() ) * 0.95 ); + if (!mol_name.empty()) { + h = int(float(rect().height()) * 0.95); } - mol_drawer_.reset( new RDKit::MolDraw2DQt( rect().width() , h , qp ) ); - + mol_drawer_.reset(new RDKit::MolDraw2DQt(rect().width(), h, qp)); + vector sa = selected_atoms(); - mol_drawer_->drawMolecule( *disp_mol_ , &sa ); - add_molecule_title( qp , mol_name , h ); - - identify_selected_atoms( qp ); + mol_drawer_->drawMolecule(*disp_mol_, &sa); + add_molecule_title(qp, mol_name, h); + identify_selected_atoms(qp); } // **************************************************************************** -void MolDisplay2DWidget::add_molecule_title( QPainter &qp , - const string &mol_name , - int label_box_height ) { - - qp.setPen( "Black" ); - if( !mol_name.empty() ) { +void MolDisplay2DWidget::add_molecule_title(QPainter &qp, + const string &mol_name, + int label_box_height) { + qp.setPen("Black"); + if (!mol_name.empty()) { int box_height = height() - label_box_height; - qp.fillRect( 0 , label_box_height , width() , box_height , qp.background() ); - while( true ) { - QRect br = qp.boundingRect( 0 , label_box_height , width() , box_height , - Qt::AlignHCenter | Qt::AlignVCenter , mol_name.c_str() ); - if( br.height() > box_height ) { - float scale = float( box_height ) / float( br.height() ); + qp.fillRect(0, label_box_height, width(), box_height, qp.background()); + while (true) { + QRect br = qp.boundingRect(0, label_box_height, width(), box_height, + Qt::AlignHCenter | Qt::AlignVCenter, + mol_name.c_str()); + if (br.height() > box_height) { + float scale = float(box_height) / float(br.height()); QFont ft = qp.font(); float new_fs = scale * ft.pointSizeF(); - ft.setPointSizeF( new_fs ); - qp.setFont( ft ); + ft.setPointSizeF(new_fs); + qp.setFont(ft); } else { break; } } - qp.drawText( 0 , label_box_height , width() , height() - label_box_height , - Qt::AlignHCenter | Qt::AlignVCenter , mol_name.c_str() ); + qp.drawText(0, label_box_height, width(), height() - label_box_height, + Qt::AlignHCenter | Qt::AlignVCenter, mol_name.c_str()); } - } // **************************************************************************** -void MolDisplay2DWidget::identify_selected_atoms( QPainter &qp ) { - - static QPen sel_pen( QColor( "Orange" ) ); - qp.setPen( sel_pen ); +void MolDisplay2DWidget::identify_selected_atoms(QPainter &qp) { + static QPen sel_pen(QColor("Orange")); + qp.setPen(sel_pen); // put an orange square round selected atoms. vector sa = selected_atoms(); - for( int i = 0 , is = sa.size() ; i < is ; ++i ) { - Point2D at_cds = mol_drawer()->getDrawCoords( sa[i] ); - qp.drawRect( at_cds.x - pick_circle_rad() , at_cds.y - pick_circle_rad() , - 2 * pick_circle_rad() , 2 * pick_circle_rad() ); + for (int i = 0, is = sa.size(); i < is; ++i) { + Point2D at_cds = mol_drawer()->getDrawCoords(sa[i]); + qp.drawRect(at_cds.x - pick_circle_rad(), at_cds.y - pick_circle_rad(), + 2 * pick_circle_rad(), 2 * pick_circle_rad()); } - } // **************************************************************************** -int MolDisplay2DWidget::find_nearest_atom( int x_screen_pos , int y_screen_pos ) const { +int MolDisplay2DWidget::find_nearest_atom(int x_screen_pos, + int y_screen_pos) const { + int nearest_at = -1, nearest_dist = numeric_limits::max(); - int nearest_at = -1 , nearest_dist = numeric_limits::max(); - - for( int i = 0 , is = disp_mol_->getNumAtoms() ; i < is ; ++i ) { - Point2D screen_cds = mol_drawer_->getDrawCoords( i ); - int dist = DACLIB::square( screen_cds.x - x_screen_pos ) + - DACLIB::square( screen_cds.y - y_screen_pos ); - if( dist < nearest_dist ) { + for (int i = 0, is = disp_mol_->getNumAtoms(); i < is; ++i) { + Point2D screen_cds = mol_drawer_->getDrawCoords(i); + int dist = DACLIB::square(screen_cds.x - x_screen_pos) + + DACLIB::square(screen_cds.y - y_screen_pos); + if (dist < nearest_dist) { nearest_dist = dist; nearest_at = i; } } - if( nearest_dist < pick_circle_rad_ * pick_circle_rad_ ) { + if (nearest_dist < pick_circle_rad_ * pick_circle_rad_) { return nearest_at; } else { return -1; } - } -} // EO namespace RDKit +} // namespace RDKit diff --git a/Code/GraphMol/MolDraw2D/Qt/Demo/QT4SelectItems.cc b/Code/GraphMol/MolDraw2D/Qt/Demo/QT4SelectItems.cc index 4b9d7b300..51fc10da3 100644 --- a/Code/GraphMol/MolDraw2D/Qt/Demo/QT4SelectItems.cc +++ b/Code/GraphMol/MolDraw2D/Qt/Demo/QT4SelectItems.cc @@ -25,81 +25,75 @@ using namespace std; namespace DACLIB { // *************************************************************************** -QT4SelectItems::QT4SelectItems( const string &label , - vector &item_labels , - vector &selected_items , bool radio_box , - QWidget *parent ) : QDialog( parent ) { +QT4SelectItems::QT4SelectItems(const string &label, + vector &item_labels, + vector &selected_items, bool radio_box, + QWidget *parent) + : QDialog(parent) { + setWindowTitle("Select Items"); - setWindowTitle( "Select Items" ); - - QWidget *vbox = new QWidget( this ); + QWidget *vbox = new QWidget(this); list_widget_ = new QListWidget(); - if( radio_box ) - list_widget_->setSelectionMode( QAbstractItemView::SingleSelection ); - else - list_widget_->setSelectionMode( QAbstractItemView::ExtendedSelection ); - - vector::iterator p , ps; - int i = 0; - for( p = item_labels.begin() , ps = item_labels.end() ; p != ps ; ++p , ++i ) { - QListWidgetItem *item = new QListWidgetItem( *p , list_widget_ ); - list_widget_->setItemSelected( item , selected_items[i] ); + if (radio_box) { + list_widget_->setSelectionMode(QAbstractItemView::SingleSelection); + } else { + list_widget_->setSelectionMode(QAbstractItemView::ExtendedSelection); } - connect( list_widget_ , SIGNAL( itemDoubleClicked( QListWidgetItem * ) ) , - this , SLOT( slot_list_double_clicked( QListWidgetItem * ) ) ); + vector::iterator p, ps; + int i = 0; + for (p = item_labels.begin(), ps = item_labels.end(); p != ps; ++p, ++i) { + QListWidgetItem *item = new QListWidgetItem(*p, list_widget_); + list_widget_->setItemSelected(item, selected_items[i]); + } + + connect(list_widget_, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, + SLOT(slot_list_double_clicked(QListWidgetItem *))); build_action_box(); vlayout_ = new QVBoxLayout(); - vlayout_->setDirection( QBoxLayout::BottomToTop ); - vlayout_->addWidget( action_box_ ); - vlayout_->addWidget( list_widget_ ); - vlayout_->addWidget( new QLabel( label.c_str() ) ); + vlayout_->setDirection(QBoxLayout::BottomToTop); + vlayout_->addWidget(action_box_); + vlayout_->addWidget(list_widget_); + vlayout_->addWidget(new QLabel(label.c_str())); - vbox->setLayout( vlayout_ ); + vbox->setLayout(vlayout_); vbox->show(); - } // ***************************************************************************** -void QT4SelectItems::get_results( vector &selected_items ) const { - - selected_items = vector( list_widget_->count() , 0 ); - for( int i = 0 , is = list_widget_->count() ; i < is ; ++i ) { - selected_items[i] = list_widget_->isItemSelected( list_widget_->item( i ) ); +void QT4SelectItems::get_results(vector &selected_items) const { + selected_items = vector(list_widget_->count(), 0); + for (int i = 0, is = list_widget_->count(); i < is; ++i) { + selected_items[i] = list_widget_->isItemSelected(list_widget_->item(i)); } - } // ***************************************************************************** void QT4SelectItems::build_action_box() { - - action_box_ = new QWidget( this ); + action_box_ = new QWidget(this); QHBoxLayout *hlayout = new QHBoxLayout(); - QPushButton *button = new QPushButton( "Ok" ); - button->setDefault( true ); - hlayout->addWidget( button ); - connect( button , SIGNAL( clicked() ) , this , SLOT( accept() ) ); + QPushButton *button = new QPushButton("Ok"); + button->setDefault(true); + hlayout->addWidget(button); + connect(button, SIGNAL(clicked()), this, SLOT(accept())); - button = new QPushButton( "Cancel" ); - hlayout->addWidget( button ); - connect( button , SIGNAL( clicked() ) , this , SLOT( reject() ) ); - - action_box_->setLayout( hlayout ); + button = new QPushButton("Cancel"); + hlayout->addWidget(button); + connect(button, SIGNAL(clicked()), this, SLOT(reject())); + action_box_->setLayout(hlayout); } // ***************************************************************************** // select item and out -void QT4SelectItems::slot_list_double_clicked( QListWidgetItem *item ) { - - item->setSelected( true ); +void QT4SelectItems::slot_list_double_clicked(QListWidgetItem *item) { + item->setSelected(true); accept(); - } -} // EO namespace DACLIB +} // namespace DACLIB diff --git a/Code/GraphMol/MolDraw2D/Qt/Demo/QTGet2Strings.cc b/Code/GraphMol/MolDraw2D/Qt/Demo/QTGet2Strings.cc index 29ebd2ef3..f9590e247 100644 --- a/Code/GraphMol/MolDraw2D/Qt/Demo/QTGet2Strings.cc +++ b/Code/GraphMol/MolDraw2D/Qt/Demo/QTGet2Strings.cc @@ -17,67 +17,59 @@ namespace DACLIB { // **************************************************************************** -QTGet2Strings::QTGet2Strings( QString prompt1 , QString initval1 , - QString prompt2 , QString initval2, - QWidget *parent , Qt::WindowFlags f ) : - QDialog( parent , f ) { - - build_widget( prompt1 , initval1 , prompt2 , initval2 ); - +QTGet2Strings::QTGet2Strings(QString prompt1, QString initval1, QString prompt2, + QString initval2, QWidget *parent, + Qt::WindowFlags f) + : QDialog(parent, f) { + build_widget(prompt1, initval1, prompt2, initval2); } // **************************************************************************** -void QTGet2Strings::get_values( QString &string1 , QString &string2 ) { - +void QTGet2Strings::get_values(QString &string1, QString &string2) { string1 = le1_->text(); string2 = le2_->text(); - } // **************************************************************************** -void QTGet2Strings::build_widget( QString prompt1 , QString initval1 , - QString prompt2 , QString initval2 ) { - +void QTGet2Strings::build_widget(QString prompt1, QString initval1, + QString prompt2, QString initval2) { QVBoxLayout *vbox = new QVBoxLayout; QFormLayout *fl = new QFormLayout; le1_ = new QLineEdit; - fl->addRow( prompt1 , le1_ ); - le1_->setText( initval1 ); + fl->addRow(prompt1, le1_); + le1_->setText(initval1); le2_ = new QLineEdit; - fl->addRow( prompt2 , le2_ ); - le2_->setText( initval2 ); - - vbox->addLayout( fl ); - vbox->addWidget( build_action_box() ); - setLayout( vbox ); + fl->addRow(prompt2, le2_); + le2_->setText(initval2); + vbox->addLayout(fl); + vbox->addWidget(build_action_box()); + setLayout(vbox); } // **************************************************************************** QWidget *QTGet2Strings::build_action_box() { - QFrame *action_frame = new QFrame; - action_frame->setFrameStyle( QFrame::Box ); + action_frame->setFrameStyle(QFrame::Box); QHBoxLayout *hlayout = new QHBoxLayout; - QPushButton *button = new QPushButton( "Ok" ); - hlayout->addWidget( button ); - connect( button , SIGNAL( clicked() ) , this , SLOT( accept() ) ); - button->setDefault( true ); - button->setAutoDefault( true ); + QPushButton *button = new QPushButton("Ok"); + hlayout->addWidget(button); + connect(button, SIGNAL(clicked()), this, SLOT(accept())); + button->setDefault(true); + button->setAutoDefault(true); - button = new QPushButton( "Cancel" ); - hlayout->addWidget( button ); - connect( button , SIGNAL( clicked() ) , this , SLOT( reject() ) ); - button->setDefault( false ); - button->setAutoDefault( false ); + button = new QPushButton("Cancel"); + hlayout->addWidget(button); + connect(button, SIGNAL(clicked()), this, SLOT(reject())); + button->setDefault(false); + button->setAutoDefault(false); - action_frame->setLayout( hlayout ); + action_frame->setLayout(hlayout); return action_frame; - } -} // EO namespace DACLIB +} // namespace DACLIB diff --git a/Code/GraphMol/MolDraw2D/Qt/Demo/RDKitSVMainWindow.cc b/Code/GraphMol/MolDraw2D/Qt/Demo/RDKitSVMainWindow.cc index 55df96f3f..cc7512425 100644 --- a/Code/GraphMol/MolDraw2D/Qt/Demo/RDKitSVMainWindow.cc +++ b/Code/GraphMol/MolDraw2D/Qt/Demo/RDKitSVMainWindow.cc @@ -48,602 +48,587 @@ using namespace std; namespace RDKitSV { // **************************************************************************** -RDKitSVMainWindow::RDKitSVMainWindow( int argc , char **argv ) : QMainWindow() { - +RDKitSVMainWindow::RDKitSVMainWindow(int argc, char **argv) : QMainWindow() { build_actions(); build_menubar(); build_widget(); - parse_args( argc , argv ); - + parse_args(argc, argv); } // **************************************************************************** void RDKitSVMainWindow::build_actions() { - build_file_actions(); build_smarts_actions(); - } // **************************************************************************** void RDKitSVMainWindow::build_file_actions() { + file_exit_ = new QAction(tr("Exit"), this); + file_exit_->setShortcut(QString("Ctrl+Q")); + connect(file_exit_, &QAction::triggered, this, &RDKitSVMainWindow::slot_exit); - file_exit_ = new QAction( tr( "Exit" ) , this ); - file_exit_->setShortcut( QString( "Ctrl+Q" ) ); - connect( file_exit_ , &QAction::triggered , - this , &RDKitSVMainWindow::slot_exit ); + file_read_mols_ = new QAction(tr("Molecules"), this); + connect(file_read_mols_, &QAction::triggered, this, + &RDKitSVMainWindow::slot_read_mols); - file_read_mols_ = new QAction( tr( "Molecules" ) , this ); - connect( file_read_mols_ , &QAction::triggered , - this , &RDKitSVMainWindow::slot_read_mols ); + file_read_smarts_ = new QAction(tr("SMARTS"), this); + connect(file_read_smarts_, &QAction::triggered, this, + &RDKitSVMainWindow::slot_read_smarts); - file_read_smarts_ = new QAction( tr( "SMARTS" ) , this ); - connect( file_read_smarts_ , &QAction::triggered , - this , &RDKitSVMainWindow::slot_read_smarts ); + file_write_left_ = new QAction(tr("Molecules (Left Panel)"), this); + connect(file_write_left_, &QAction::triggered, this, + &RDKitSVMainWindow::slot_write_left_molecules); - file_write_left_ = new QAction( tr( "Molecules (Left Panel)" ) , this ); - connect( file_write_left_ , &QAction::triggered , - this , &RDKitSVMainWindow::slot_write_left_molecules ); - - file_write_right_ = new QAction( tr( "Molecules (Right Panel)" ) , this ); - connect( file_write_right_ , &QAction::triggered , - this , &RDKitSVMainWindow::slot_write_right_molecules ); - - file_write_smarts_ = new QAction( tr( "SMARTS" ) , this ); - connect( file_write_smarts_ , &QAction::triggered , - this , &RDKitSVMainWindow::slot_write_smarts ); + file_write_right_ = new QAction(tr("Molecules (Right Panel)"), this); + connect(file_write_right_, &QAction::triggered, this, + &RDKitSVMainWindow::slot_write_right_molecules); + file_write_smarts_ = new QAction(tr("SMARTS"), this); + connect(file_write_smarts_, &QAction::triggered, this, + &RDKitSVMainWindow::slot_write_smarts); } // **************************************************************************** void RDKitSVMainWindow::build_smarts_actions() { + smarts_match_ = new QAction(tr("Match"), this); + smarts_match_->setShortcut(QString("Ctrl+M")); + connect(smarts_match_, &QAction::triggered, this, + &RDKitSVMainWindow::slot_match_smarts); - smarts_match_ = new QAction( tr( "Match" ) , this ); - smarts_match_->setShortcut( QString( "Ctrl+M" ) ); - connect( smarts_match_ , &QAction::triggered , - this , &RDKitSVMainWindow::slot_match_smarts ); - - smarts_edit_ = new QAction( tr( "Edit" ) , this ); - connect( smarts_edit_ , &QAction::triggered , - this , &RDKitSVMainWindow::slot_edit_smarts ); - - smarts_new_ = new QAction( tr( "New" ) , this ); - connect( smarts_new_ , &QAction::triggered , - this , &RDKitSVMainWindow::slot_new_smarts ); + smarts_edit_ = new QAction(tr("Edit"), this); + connect(smarts_edit_, &QAction::triggered, this, + &RDKitSVMainWindow::slot_edit_smarts); + smarts_new_ = new QAction(tr("New"), this); + connect(smarts_new_, &QAction::triggered, this, + &RDKitSVMainWindow::slot_new_smarts); } // **************************************************************************** void RDKitSVMainWindow::build_menubar() { + QMenu *file_menu = menuBar()->addMenu(tr("File")); + QMenu *read_menu = file_menu->addMenu(tr("Read")); + read_menu->addAction(file_read_mols_); + read_menu->addAction(file_read_smarts_); - QMenu *file_menu = menuBar()->addMenu( tr( "File" ) ); - QMenu *read_menu = file_menu->addMenu( tr( "Read" ) ); - read_menu->addAction( file_read_mols_ ); - read_menu->addAction( file_read_smarts_ ); - - QMenu *write_menu = file_menu->addMenu( tr( "Write" ) ); - write_menu->addAction( file_write_left_ ); - write_menu->addAction( file_write_right_ ); - write_menu->addAction( file_write_smarts_ ); + QMenu *write_menu = file_menu->addMenu(tr("Write")); + write_menu->addAction(file_write_left_); + write_menu->addAction(file_write_right_); + write_menu->addAction(file_write_smarts_); file_menu->addSeparator(); - file_menu->addAction( file_exit_ ); - - QMenu *smarts_menu = menuBar()->addMenu( tr( "SMARTS" ) ); - smarts_menu->addAction( smarts_match_ ); - smarts_menu->addAction( smarts_edit_ ); - smarts_menu->addAction( smarts_new_ ); + file_menu->addAction(file_exit_); + QMenu *smarts_menu = menuBar()->addMenu(tr("SMARTS")); + smarts_menu->addAction(smarts_match_); + smarts_menu->addAction(smarts_edit_); + smarts_menu->addAction(smarts_new_); } // **************************************************************************** void RDKitSVMainWindow::build_widget() { - left_panel_ = new RDKitSVPanel; - right_panel_ = new RDKitSVPanel( false ); + right_panel_ = new RDKitSVPanel(false); QWidget *cen_wid = new QWidget; QHBoxLayout *hbox = new QHBoxLayout; - hbox->addWidget( left_panel_ ); - hbox->addWidget( right_panel_ ); + hbox->addWidget(left_panel_); + hbox->addWidget(right_panel_); right_panel_->hide(); - cen_wid->setLayout( hbox ); - setCentralWidget( cen_wid ); - + cen_wid->setLayout(hbox); + setCentralWidget(cen_wid); } // **************************************************************************** -void RDKitSVMainWindow::parse_args( int argc, char **argv ) { - - RDKitSVSettings s( argc , argv ); +void RDKitSVMainWindow::parse_args(int argc, char **argv) { + RDKitSVSettings s(argc, argv); vector mol_files = s.mol_files(); - if( !mol_files.empty() ) { - BOOST_FOREACH( string mf , mol_files ) { - read_mols( mf ); - } + if (!mol_files.empty()) { + BOOST_FOREACH (string mf, mol_files) { read_mols(mf); } } string smarts_file = s.smarts_file(); - if( !smarts_file.empty() ) { - read_smarts( smarts_file ); + if (!smarts_file.empty()) { + read_smarts(smarts_file); } - } // **************************************************************************** -RDKitSVMainWindow::FILE_TYPE RDKitSVMainWindow::get_filetype( const string &filename , - bool &is_compressed ) { - +RDKitSVMainWindow::FILE_TYPE RDKitSVMainWindow::get_filetype( + const string &filename, bool &is_compressed) { is_compressed = false; - if( filename.substr( filename.length() - 3 ) == string( ".gz" ) ) { + if (filename.substr(filename.length() - 3) == string(".gz")) { is_compressed = true; } - if( string( ".smi" ) == filename.substr( filename.length() - 4 ) || - string( ".smi.gz" ) == filename.substr( filename.length() - 7 ) || - string( ".ism" ) == filename.substr( filename.length() - 4 ) || - string( ".ism.gz" ) == filename.substr( filename.length() - 7 ) ) { + if (string(".smi") == filename.substr(filename.length() - 4) || + string(".smi.gz") == filename.substr(filename.length() - 7) || + string(".ism") == filename.substr(filename.length() - 4) || + string(".ism.gz") == filename.substr(filename.length() - 7)) { return SMILES; - } else if( string( ".sdf" ) == filename.substr( filename.length() - 4 ) || - string( ".sdf.gz" ) == filename.substr( filename.length() - 7 ) ) { + } else if (string(".sdf") == filename.substr(filename.length() - 4) || + string(".sdf.gz") == filename.substr(filename.length() - 7)) { return SDF; } return UNKNOWN; - } // **************************************************************************** -void RDKitSVMainWindow::read_mols( const string &filename ) { - - QApplication::setOverrideCursor( Qt::WaitCursor ); +void RDKitSVMainWindow::read_mols(const string &filename) { + QApplication::setOverrideCursor(Qt::WaitCursor); bool is_compressed; - FILE_TYPE file_type = get_filetype( filename , is_compressed ); + FILE_TYPE file_type = get_filetype(filename, is_compressed); boost::iostreams::filtering_istream ins; - if( is_compressed ) { - ins.push( boost::iostreams::gzip_decompressor() ); + if (is_compressed) { + ins.push(boost::iostreams::gzip_decompressor()); } - ins.push( boost::iostreams::file_source( filename.c_str() ) ); - if( !ins || !ins.good() ) { - QMessageBox::warning( this , tr( "File Read Error" ) , - QString( "%1 %2 %3 for reading." ).arg( tr( "Couldn't open" ) ).arg( filename.c_str() ).arg( tr( "for reading." ) ) ); + ins.push(boost::iostreams::file_source(filename.c_str())); + if (!ins || !ins.good()) { + QMessageBox::warning(this, tr("File Read Error"), + QString("%1 %2 %3 for reading.") + .arg(tr("Couldn't open")) + .arg(filename.c_str()) + .arg(tr("for reading."))); return; } vector new_mols; - if( SDF == file_type ) { - RDKit::MolSupplier *mol_supplier = new RDKit::ForwardSDMolSupplier( &ins , true ); - while( !mol_supplier->atEnd() ) { - new_mols.push_back( RDKit::ROMOL_SPTR( mol_supplier->next() ) ); - if( !new_mols.back() ) { + if (SDF == file_type) { + RDKit::MolSupplier *mol_supplier = + new RDKit::ForwardSDMolSupplier(&ins, true); + while (!mol_supplier->atEnd()) { + new_mols.push_back(RDKit::ROMOL_SPTR(mol_supplier->next())); + if (!new_mols.back()) { new_mols.pop_back(); break; } } - } else if( SMILES == file_type ) { + } else if (SMILES == file_type) { // SmilesMolSupplier doesn't seem to work with compressed streams. It might // be because of the use of getline. // For now, assume the file is a simple one with no header and just SMILES // followed by optional name - istreambuf_iterator isb( ins ) , eos; + istreambuf_iterator isb(ins), eos; vector nextline; - while( isb != eos ) { + while (isb != eos) { nextline.clear(); - while( isb != eos && *isb != '\n' ) { - nextline.push_back( *isb ); + while (isb != eos && *isb != '\n') { + nextline.push_back(*isb); ++isb; } - if( '#' != nextline[0] ) { + if ('#' != nextline[0]) { vector split_line; - split( split_line , nextline , is_any_of( " \t" ) ); - string smi( split_line[0] ); + split(split_line, nextline, is_any_of(" \t")); + string smi(split_line[0]); string smi_name; - if( 1 == split_line.size() ) { - smi_name = string( "MOL_" ) + lexical_cast( mols_.size() + 1 ); + if (1 == split_line.size()) { + smi_name = string("MOL_") + lexical_cast(mols_.size() + 1); } else { - smi_name = string( nextline.begin() + split_line[0].length() + 1 , nextline.end() ); + smi_name = string(nextline.begin() + split_line[0].length() + 1, + nextline.end()); } - boost::trim( smi ); - boost::trim( smi_name ); - RDKit::ROMol *mol = RDKit::SmilesToMol( smi ); - if( mol ) { - mol->setProp( "_Name" , smi_name ); - mols_.push_back( RDKit::ROMOL_SPTR( mol ) ); + boost::trim(smi); + boost::trim(smi_name); + RDKit::ROMol *mol = RDKit::SmilesToMol(smi); + if (mol) { + mol->setProp("_Name", smi_name); + mols_.push_back(RDKit::ROMOL_SPTR(mol)); } } - ++isb; // get past '\n' + ++isb; // get past '\n' } } else { - QMessageBox::warning( this , tr( "File Read Error" ) , - QString( "%1 %2." ).arg( tr( "Unrecognised file type for" ) ).arg( filename.c_str() ) ); + QMessageBox::warning(this, tr("File Read Error"), + QString("%1 %2.") + .arg(tr("Unrecognised file type for")) + .arg(filename.c_str())); return; } - mols_.insert( mols_.end() , new_mols.begin() , new_mols.end() ); - left_panel_->set_molecules( mols_ ); + mols_.insert(mols_.end(), new_mols.begin(), new_mols.end()); + left_panel_->set_molecules(mols_); QApplication::restoreOverrideCursor(); - } // **************************************************************************** -void RDKitSVMainWindow::read_smarts( const string &filename ) { - +void RDKitSVMainWindow::read_smarts(const string &filename) { #ifdef NOTYET cout << "reading SMARTS from " << filename << endl; #endif - ifstream ifs( filename.c_str() ); - if( !ifs || !ifs.good() ) { - QMessageBox::warning( this , tr( "File Read Error" ) , - QString( "%1 %2 %3 for reading." ).arg( tr( "Couldn't open" ) ).arg( filename.c_str() ).arg( tr( "for reading." ) ) ); + ifstream ifs(filename.c_str()); + if (!ifs || !ifs.good()) { + QMessageBox::warning(this, tr("File Read Error"), + QString("%1 %2 %3 for reading.") + .arg(tr("Couldn't open")) + .arg(filename.c_str()) + .arg(tr("for reading."))); return; } - while( 1 ) { + while (1) { string next_line; - getline( ifs , next_line ); + getline(ifs, next_line); #ifdef NOTYET cout << next_line << "XX" << endl; #endif - if( !ifs.good() || ifs.eof() ) { + if (!ifs.good() || ifs.eof()) { break; } - boost::trim( next_line ); - if( next_line.empty() ) { + boost::trim(next_line); + if (next_line.empty()) { continue; } - if( '#' == next_line[0] ) { - continue; // it's a comment + if ('#' == next_line[0]) { + continue; // it's a comment } list splits; - boost::split( splits , next_line , boost::is_any_of( " \t" ) ); - string smt , smt_name; - if( splits.size() >= 2 ) { + boost::split(splits, next_line, boost::is_any_of(" \t")); + string smt, smt_name; + if (splits.size() >= 2) { smt = splits.front(); splits.pop_front(); - boost::trim( smt ); - smt_name = boost::join( splits , " " ); - boost::trim( smt_name ); + boost::trim(smt); + smt_name = boost::join(splits, " "); + boost::trim(smt_name); #ifdef NOTYET cout << "smt = " << smt << " name = " << smt_name << endl; #endif - } else if( 1 == splits.size() ) { + } else if (1 == splits.size()) { smt = splits.front(); - boost::trim( smt ); - smt_name = string( "SMARTS_" ) + lexical_cast( smarts_.size() + 1 ); + boost::trim(smt); + smt_name = string("SMARTS_") + lexical_cast(smarts_.size() + 1); } - smarts_.push_back( make_pair( smt_name , smt ) ); + smarts_.push_back(make_pair(smt_name, smt)); } - statusBar()->showMessage( QString( "%1 %2." ).arg( tr( "Number of SMARTS now" ) ).arg( smarts_.size() ) , 2000 ); - + statusBar()->showMessage( + QString("%1 %2.").arg(tr("Number of SMARTS now")).arg(smarts_.size()), + 2000); } // **************************************************************************** -void RDKitSVMainWindow::write_mols( RDKitSVPanel &panel , const string &filename ) { - +void RDKitSVMainWindow::write_mols(RDKitSVPanel &panel, + const string &filename) { vector mols = panel.get_molecules(); - if( mols.empty() ) { - QMessageBox::information( this , tr( "No molecules." ) , - tr( "Panel contains no molecules, so nothing to write." ) ); + if (mols.empty()) { + QMessageBox::information( + this, tr("No molecules."), + tr("Panel contains no molecules, so nothing to write.")); return; } bool is_compressed; - FILE_TYPE file_type = get_filetype( filename , is_compressed ); + FILE_TYPE file_type = get_filetype(filename, is_compressed); boost::iostreams::filtering_ostream ons; - if( is_compressed ) { - ons.push( boost::iostreams::gzip_compressor() ); + if (is_compressed) { + ons.push(boost::iostreams::gzip_compressor()); } - ons.push( boost::iostreams::file_sink( filename.c_str() ) ); - if( !ons || !ons.good() ) { - QMessageBox::warning( this , tr( "Can't write to file" ) , - QString( "%1 %2." ).arg( tr( "Couldn't write to file" ).arg( filename.c_str() ) ) ); + ons.push(boost::iostreams::file_sink(filename.c_str())); + if (!ons || !ons.good()) { + QMessageBox::warning( + this, tr("Can't write to file"), + QString("%1 %2.").arg( + tr("Couldn't write to file").arg(filename.c_str()))); return; } RDKit::MolWriter *mw; - if( SMILES == file_type ) { - bool ism = filename.substr( filename.length() - 4 ) == ".ism" || - filename.substr( filename.length() - 7 ) == ".ism.gz" ? true : false; - mw = new RDKit::SmilesWriter( &ons , " " , "Name" , true , false , ism ); - } else if( SDF == file_type ) { - mw = new RDKit::SDWriter( &ons , false ); + if (SMILES == file_type) { + bool ism = filename.substr(filename.length() - 4) == ".ism" || + filename.substr(filename.length() - 7) == ".ism.gz" + ? true + : false; + mw = new RDKit::SmilesWriter(&ons, " ", "Name", true, false, ism); + } else if (SDF == file_type) { + mw = new RDKit::SDWriter(&ons, false); } else { - QMessageBox::warning( this , tr( "File Write Error" ) , - QString( "%1 %2." ).arg( tr( "Unrecognised file type for" ) ).arg( filename.c_str() ) ); + QMessageBox::warning(this, tr("File Write Error"), + QString("%1 %2.") + .arg(tr("Unrecognised file type for")) + .arg(filename.c_str())); return; } - BOOST_FOREACH( RDKit::ROMOL_SPTR mol , mols ) { - mw->write( *mol ); - } + BOOST_FOREACH (RDKit::ROMOL_SPTR mol, mols) { mw->write(*mol); } delete mw; - } // **************************************************************************** -void RDKitSVMainWindow::match_smarts( const vector > &smts ) { - +void RDKitSVMainWindow::match_smarts(const vector> &smts) { cout << "Matching " << smts.size() << " SMARTS" << endl; - vector > smarts_match( mols_.size() , vector() ); + vector> smarts_match(mols_.size(), vector()); QString smts_label; - for( int i = 0 , is = smts.size() ; i < is ; ++i ) { + for (int i = 0, is = smts.size(); i < is; ++i) { cout << "Matching " << i << " : " << smts[i].second << endl; - smts_label += QString( "%1 (%2)" ).arg( smts[i].first.c_str() ).arg( smts[i].second.c_str() ); - if( i < is - 1 ) { + smts_label += QString("%1 (%2)") + .arg(smts[i].first.c_str()) + .arg(smts[i].second.c_str()); + if (i < is - 1) { smts_label += "|"; } - RDKit::RWMol *q = RDKit::SmartsToMol( smts[i].second ); - for( int j = 0 , js = mols_.size() ; j < js ; ++j ) { + RDKit::RWMol *q = RDKit::SmartsToMol(smts[i].second); + for (int j = 0, js = mols_.size(); j < js; ++j) { vector hits_vect; - if( RDKit::SubstructMatch( *mols_[j] , *q , hits_vect ) ) { + if (RDKit::SubstructMatch(*mols_[j], *q, hits_vect)) { // store the numbers of the atoms that matched - typedef pair INTPAIR; - BOOST_FOREACH( RDKit::MatchVectType hit , hits_vect ) { - BOOST_FOREACH( INTPAIR ip , hit ) { - smarts_match[j].push_back( ip.second ); + typedef pair INTPAIR; + BOOST_FOREACH (RDKit::MatchVectType hit, hits_vect) { + BOOST_FOREACH (INTPAIR ip, hit) { + smarts_match[j].push_back(ip.second); } } - std::sort( smarts_match[j].begin() , smarts_match[j].end() ); - smarts_match[j].erase( unique( smarts_match[j].begin() , smarts_match[j].end() ) , - smarts_match[j].end() ); + std::sort(smarts_match[j].begin(), smarts_match[j].end()); + smarts_match[j].erase( + unique(smarts_match[j].begin(), smarts_match[j].end()), + smarts_match[j].end()); } } delete q; } - vector match_mols , miss_mols; - vector > match_atom_matches; - for( int i = 0 , is = mols_.size() ; i < is ; ++i ) { - if( smarts_match[i].empty() ) { - miss_mols.push_back( mols_[i] ); + vector match_mols, miss_mols; + vector> match_atom_matches; + for (int i = 0, is = mols_.size(); i < is; ++i) { + if (smarts_match[i].empty()) { + miss_mols.push_back(mols_[i]); } else { - match_mols.push_back( mols_[i] ); - match_atom_matches.push_back( smarts_match[i] ); + match_mols.push_back(mols_[i]); + match_atom_matches.push_back(smarts_match[i]); } } right_panel_->show(); - left_panel_->set_molecules( match_mols , match_atom_matches ); + left_panel_->set_molecules(match_mols, match_atom_matches); // Details, details!! - if( 1 == match_mols.size() ) { - left_panel_->set_label( QString( "%1 %2." ).arg( tr( "1 molecule matched." ).arg( smts_label ) ) ); + if (1 == match_mols.size()) { + left_panel_->set_label( + QString("%1 %2.").arg(tr("1 molecule matched.").arg(smts_label))); } else { - left_panel_->set_label( QString( "%1 %2 %3." ).arg( match_mols.size() ).arg( tr( "molecules matched" ) ).arg( smts_label ) ); + left_panel_->set_label(QString("%1 %2 %3.") + .arg(match_mols.size()) + .arg(tr("molecules matched")) + .arg(smts_label)); } - right_panel_->set_molecules( miss_mols ); - if( 1 == miss_mols.size() ) { - right_panel_->set_label( tr( "1 molecule didn't match" ) ); + right_panel_->set_molecules(miss_mols); + if (1 == miss_mols.size()) { + right_panel_->set_label(tr("1 molecule didn't match")); } else { - right_panel_->set_label( QString( "%1 %2" ).arg( miss_mols.size() ).arg( tr( "molecules didn't match." ) ) ); + right_panel_->set_label(QString("%1 %2") + .arg(miss_mols.size()) + .arg(tr("molecules didn't match."))); } - } // **************************************************************************** -vector > RDKitSVMainWindow::select_smarts( bool multi_select ) { +vector> RDKitSVMainWindow::select_smarts( + bool multi_select) { + vector> smts_to_use; - vector > smts_to_use; - - if( smarts_.empty() ) { + if (smarts_.empty()) { return smts_to_use; } - vector selected_smarts( smarts_.size() , 0 ); + vector selected_smarts(smarts_.size(), 0); vector smts; - for( int i = 0 , is = smarts_.size() ; i < is ; ++i ) { + for (int i = 0, is = smarts_.size(); i < is; ++i) { #ifdef NOTYET - cout << i << " : " << smarts_[i].first << " :: " << smarts_[i].second << endl; + cout << i << " : " << smarts_[i].first << " :: " << smarts_[i].second + << endl; #endif - smts.push_back( QString( "%1 (%2)" ).arg( smarts_[i].first.c_str() ).arg( smarts_[i].second.c_str() ) ); + smts.push_back(QString("%1 (%2)") + .arg(smarts_[i].first.c_str()) + .arg(smarts_[i].second.c_str())); } - DACLIB::QT4SelectItems si( string( "Select SMARTS to use." ) , smts , - selected_smarts , !multi_select , this ); - if( QDialog::Accepted != si.exec() ) { + DACLIB::QT4SelectItems si(string("Select SMARTS to use."), smts, + selected_smarts, !multi_select, this); + if (QDialog::Accepted != si.exec()) { return smts_to_use; } - si.get_results( selected_smarts ); + si.get_results(selected_smarts); - for( int i = 0 , is = smarts_.size() ; i < is ; ++i ) { - if( selected_smarts[i] ) { - smts_to_use.push_back( smarts_[i] ); + for (int i = 0, is = smarts_.size(); i < is; ++i) { + if (selected_smarts[i]) { + smts_to_use.push_back(smarts_[i]); } } return smts_to_use; - } // **************************************************************************** -void RDKitSVMainWindow::update_smarts( const string &new_name , - const string &new_val ) { - - vector >::iterator p = std::find_if( smarts_.begin() , smarts_.end() , - bind( equal_to() , new_name , - bind( &pair::first , _1 ) ) ); - if( p == smarts_.end() ) { - smarts_.push_back( make_pair( new_name , new_val ) ); +void RDKitSVMainWindow::update_smarts(const string &new_name, + const string &new_val) { + vector>::iterator p = + std::find_if(smarts_.begin(), smarts_.end(), + bind(equal_to(), new_name, + bind(&pair::first, _1))); + if (p == smarts_.end()) { + smarts_.push_back(make_pair(new_name, new_val)); } else { p->second = new_val; } - } // **************************************************************************** void RDKitSVMainWindow::slot_read_mols() { - - QString filename = QFileDialog::getOpenFileName( this , "Select molecule file" , - last_dir_ , "Mol. files (*.smi *.smi.gz *.ism *.ism.gz *.sdf *.sdf.gz)" ); - if( filename.isEmpty() || filename.isNull() ) { + QString filename = QFileDialog::getOpenFileName( + this, "Select molecule file", last_dir_, + "Mol. files (*.smi *.smi.gz *.ism *.ism.gz *.sdf *.sdf.gz)"); + if (filename.isEmpty() || filename.isNull()) { return; } - QFileInfo fi( filename ); + QFileInfo fi(filename); last_dir_ = fi.absolutePath(); - read_mols( filename.toLocal8Bit().data() ); - + read_mols(filename.toLocal8Bit().data()); } // **************************************************************************** void RDKitSVMainWindow::slot_read_smarts() { - - QString filename = QFileDialog::getOpenFileName( this , "Select SMARTS file" , - last_dir_ , "SMARTS files (*.smt);;Any file (*)" ); - if( filename.isEmpty() || filename.isNull() ) { + QString filename = + QFileDialog::getOpenFileName(this, "Select SMARTS file", last_dir_, + "SMARTS files (*.smt);;Any file (*)"); + if (filename.isEmpty() || filename.isNull()) { return; } - QFileInfo fi( filename ); + QFileInfo fi(filename); last_dir_ = fi.absolutePath(); - read_smarts( filename.toLocal8Bit().data() ); - + read_smarts(filename.toLocal8Bit().data()); } // **************************************************************************** -void RDKitSVMainWindow::slot_exit() { - - exit( 0 ); - -} +void RDKitSVMainWindow::slot_exit() { exit(0); } // **************************************************************************** void RDKitSVMainWindow::slot_match_smarts() { - - vector > smts_to_use = select_smarts( true ); - if( smts_to_use.empty() ) { + vector> smts_to_use = select_smarts(true); + if (smts_to_use.empty()) { return; } - match_smarts( smts_to_use ); - + match_smarts(smts_to_use); } // **************************************************************************** void RDKitSVMainWindow::slot_edit_smarts() { - - if( smarts_.empty() ) { + if (smarts_.empty()) { slot_new_smarts(); } - vector > smts_to_use = select_smarts( false ); - if( smts_to_use.empty() ) { + vector> smts_to_use = select_smarts(false); + if (smts_to_use.empty()) { return; } - DACLIB::QTGet2Strings g2s( tr( "SMARTS name" ) , smts_to_use.front().first.c_str() , - tr( "SMARTS value" ) , smts_to_use.front().second.c_str() , - this ); - if( QDialog::Accepted != g2s.exec() ) { + DACLIB::QTGet2Strings g2s( + tr("SMARTS name"), smts_to_use.front().first.c_str(), tr("SMARTS value"), + smts_to_use.front().second.c_str(), this); + if (QDialog::Accepted != g2s.exec()) { return; } - QString new_name , new_smarts; - g2s.get_values( new_name , new_smarts ); - - update_smarts( new_name.toLocal8Bit().data() , new_smarts.toLocal8Bit().data() ); + QString new_name, new_smarts; + g2s.get_values(new_name, new_smarts); + update_smarts(new_name.toLocal8Bit().data(), new_smarts.toLocal8Bit().data()); } // **************************************************************************** void RDKitSVMainWindow::slot_new_smarts() { - - DACLIB::QTGet2Strings g2s( tr( "SMARTS name" ) , QString( "SMARTS_%1" ).arg( smarts_.size() + 1 ) , - tr( "SMARTS value" ) , QString( "" ) , - this ); - if( QDialog::Accepted != g2s.exec() ) { + DACLIB::QTGet2Strings g2s(tr("SMARTS name"), + QString("SMARTS_%1").arg(smarts_.size() + 1), + tr("SMARTS value"), QString(""), this); + if (QDialog::Accepted != g2s.exec()) { return; } - QString new_name , new_smarts; - g2s.get_values( new_name , new_smarts ); - - update_smarts( new_name.toLocal8Bit().data() , new_smarts.toLocal8Bit().data() ); + QString new_name, new_smarts; + g2s.get_values(new_name, new_smarts); + update_smarts(new_name.toLocal8Bit().data(), new_smarts.toLocal8Bit().data()); } // **************************************************************************** void RDKitSVMainWindow::slot_write_left_molecules() { - - QString filename = QFileDialog::getSaveFileName( this , "File for left panel molecules" , - last_dir_ , - "Mol. files (*.smi *.smi.gz *.ism *.ism.gz *.sdf *.sdf.gz)" ); - if( filename.isEmpty() ) { + QString filename = QFileDialog::getSaveFileName( + this, "File for left panel molecules", last_dir_, + "Mol. files (*.smi *.smi.gz *.ism *.ism.gz *.sdf *.sdf.gz)"); + if (filename.isEmpty()) { return; } - QFileInfo fi( filename ); + QFileInfo fi(filename); last_dir_ = fi.absolutePath(); - write_mols( *left_panel_ , filename.toLocal8Bit().data() ); - + write_mols(*left_panel_, filename.toLocal8Bit().data()); } // **************************************************************************** void RDKitSVMainWindow::slot_write_right_molecules() { - - if( right_panel_->isHidden() ) { + if (right_panel_->isHidden()) { // it's empty, so nothing to do. - QMessageBox::information( this , tr( "No molecules." ) , - tr( "Right panel is inactive, so nothing to write." ) ); + QMessageBox::information( + this, tr("No molecules."), + tr("Right panel is inactive, so nothing to write.")); return; } - QString filename = QFileDialog::getSaveFileName( this , "File for left panel molecules" , - last_dir_ , - "Mol. files (*.smi *.smi.gz *.ism *.ism.gz *.sdf *.sdf.gz)" ); - if( filename.isEmpty() ) { + QString filename = QFileDialog::getSaveFileName( + this, "File for left panel molecules", last_dir_, + "Mol. files (*.smi *.smi.gz *.ism *.ism.gz *.sdf *.sdf.gz)"); + if (filename.isEmpty()) { return; } - QFileInfo fi( filename ); + QFileInfo fi(filename); last_dir_ = fi.absolutePath(); - write_mols( *right_panel_ , filename.toLocal8Bit().data() ); - + write_mols(*right_panel_, filename.toLocal8Bit().data()); } // **************************************************************************** void RDKitSVMainWindow::slot_write_smarts() { - - QString filename = QFileDialog::getSaveFileName( this , "File for SMARTS." , - last_dir_ , - "SMARTS files (*.smt);;Any file (*)" ); - if( filename.isEmpty() ) { + QString filename = + QFileDialog::getSaveFileName(this, "File for SMARTS.", last_dir_, + "SMARTS files (*.smt);;Any file (*)"); + if (filename.isEmpty()) { return; } - QFileInfo fi( filename ); + QFileInfo fi(filename); last_dir_ = fi.absolutePath(); - ofstream ofs( filename.toLocal8Bit().data() ); - if( !ofs || !ofs.good() ) { - QMessageBox::warning( this , tr( "Can't write to file" ) , - QString( "%1 %2." ).arg( tr( "Couldn't write to file" ).arg( filename ) ) ); + ofstream ofs(filename.toLocal8Bit().data()); + if (!ofs || !ofs.good()) { + QMessageBox::warning( + this, tr("Can't write to file"), + QString("%1 %2.").arg(tr("Couldn't write to file").arg(filename))); return; } - vector > smts_to_use = select_smarts( true ); - if( smts_to_use.empty() ) { + vector> smts_to_use = select_smarts(true); + if (smts_to_use.empty()) { return; } - typedef pair STRINGPAIR; - BOOST_FOREACH( STRINGPAIR smt , smts_to_use ) { + typedef pair STRINGPAIR; + BOOST_FOREACH (STRINGPAIR smt, smts_to_use) { ofs << smt.first << " " << smt.second << endl; } - } -} // EO namespace RDKitSV +} // namespace RDKitSV diff --git a/Code/GraphMol/MolDraw2D/Qt/Demo/RDKitSVPanel.cc b/Code/GraphMol/MolDraw2D/Qt/Demo/RDKitSVPanel.cc index 7458a1b65..6f246a810 100644 --- a/Code/GraphMol/MolDraw2D/Qt/Demo/RDKitSVPanel.cc +++ b/Code/GraphMol/MolDraw2D/Qt/Demo/RDKitSVPanel.cc @@ -17,94 +17,85 @@ using namespace std; namespace RDKitSV { // **************************************************************************** -RDKitSVPanel::RDKitSVPanel( bool left_slider , QWidget *parent , Qt::WindowFlags f ) : - QWidget( parent , f ) { - - build_widget( left_slider ); - +RDKitSVPanel::RDKitSVPanel(bool left_slider, QWidget *parent, Qt::WindowFlags f) + : QWidget(parent, f) { + build_widget(left_slider); } // **************************************************************************** -void RDKitSVPanel::set_molecules( const vector &new_mols , - const vector > &highlight_atoms ) { - +void RDKitSVPanel::set_molecules(const vector &new_mols, + const vector> &highlight_atoms) { #ifdef NOTYET cout << "RDKitSVPanel::set_molecules : " << new_mols.size() << endl; #endif mols_ = new_mols; highlight_atoms_ = highlight_atoms; - if( highlight_atoms_.size() != mols_.size() ) { + if (highlight_atoms_.size() != mols_.size()) { highlight_atoms_.clear(); } - if( mols_.empty() ) { - mol_slider_->setDisabled( true ); + if (mols_.empty()) { + mol_slider_->setDisabled(true); } else { - mol_slider_->setEnabled( true ); - mol_slider_->setRange( 0 , mols_.size() - 1 ); - mol_slider_->setValue( 0 ); + mol_slider_->setEnabled(true); + mol_slider_->setRange(0, mols_.size() - 1); + mol_slider_->setValue(0); } - slot_slider_changed(); // to force picture update - + slot_slider_changed(); // to force picture update } // **************************************************************************** -void RDKitSVPanel::set_label( const QString &new_label ) { - - label_->setText( new_label ); - label_->setWordWrap( true ); - label_->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); - if( new_label.isEmpty() ) { +void RDKitSVPanel::set_label(const QString &new_label) { + label_->setText(new_label); + label_->setWordWrap(true); + label_->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + if (new_label.isEmpty()) { label_->hide(); } else { label_->show(); } - } // **************************************************************************** -void RDKitSVPanel::build_widget( bool left_slider ) { - +void RDKitSVPanel::build_widget(bool left_slider) { QHBoxLayout *hbox = new QHBoxLayout; mol_draw_ = new RDKit::MolDisplay2DWidget; mol_slider_ = new QSlider; - connect( mol_slider_ , &QSlider::valueChanged , this , &RDKitSVPanel::slot_slider_changed ); - mol_slider_->setPageStep( 1 ); + connect(mol_slider_, &QSlider::valueChanged, this, + &RDKitSVPanel::slot_slider_changed); + mol_slider_->setPageStep(1); - if( left_slider ) { - hbox->addWidget( mol_slider_ ); - hbox->addWidget( mol_draw_ , 1 ); + if (left_slider) { + hbox->addWidget(mol_slider_); + hbox->addWidget(mol_draw_, 1); } else { - hbox->addWidget( mol_draw_ , 1 ); - hbox->addWidget( mol_slider_ ); + hbox->addWidget(mol_draw_, 1); + hbox->addWidget(mol_slider_); } label_ = new QLabel; QVBoxLayout *vbox = new QVBoxLayout; - vbox->addLayout( hbox , 1 ); - vbox->addWidget( label_ ); - setLayout( vbox ); + vbox->addLayout(hbox, 1); + vbox->addWidget(label_); + setLayout(vbox); label_->hide(); - } // **************************************************************************** void RDKitSVPanel::slot_slider_changed() { - - if( mols_.empty() ) { - mol_draw_->set_display_mol( RDKit::ROMOL_SPTR() ); + if (mols_.empty()) { + mol_draw_->set_display_mol(RDKit::ROMOL_SPTR()); } else { int mol_num = mol_slider_->value(); - mol_draw_->set_display_mol( mols_[mol_num] ); - if( !highlight_atoms_.empty() ) { - mol_draw_->set_selected_atoms( highlight_atoms_[mol_num] ); + mol_draw_->set_display_mol(mols_[mol_num]); + if (!highlight_atoms_.empty()) { + mol_draw_->set_selected_atoms(highlight_atoms_[mol_num]); } } - } -} // EO namespace RDKitSV +} // namespace RDKitSV diff --git a/Code/GraphMol/MolDraw2D/Qt/Demo/RDKitSVSettings.cc b/Code/GraphMol/MolDraw2D/Qt/Demo/RDKitSVSettings.cc index 7152793be..c6b1b2c8a 100644 --- a/Code/GraphMol/MolDraw2D/Qt/Demo/RDKitSVSettings.cc +++ b/Code/GraphMol/MolDraw2D/Qt/Demo/RDKitSVSettings.cc @@ -18,34 +18,29 @@ using namespace std; namespace po = boost::program_options; // ***************************************************************************** -RDKitSVSettings::RDKitSVSettings( int argc , char **argv ) { - - po::options_description desc( "Allowed Options" ); - build_program_options( desc ); +RDKitSVSettings::RDKitSVSettings(int argc, char **argv) { + po::options_description desc("Allowed Options"); + build_program_options(desc); po::variables_map vm; - po::store( po::parse_command_line( argc , argv , desc ) , vm ); - po::notify( vm ); + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); - if( vm.count( "help" ) ) { + if (vm.count("help")) { cout << desc << endl; - exit( 1 ); + exit(1); } ostringstream oss; oss << desc; usage_text_ = oss.str(); - } // ***************************************************************************** -void RDKitSVSettings::build_program_options( po::options_description &desc ) { - - desc.add_options() - ( "help" , "Produce this help text." ) - ( "molecule-file,M" , po::value >( &mol_files_ ) , - "Name of file containing molecules." ) - ( "smarts-file,S" , po::value( &smarts_file_ ) , - "Name of file containing SMARTS strings." ); - +void RDKitSVSettings::build_program_options(po::options_description &desc) { + desc.add_options()("help", "Produce this help text.")( + "molecule-file,M", po::value>(&mol_files_), + "Name of file containing molecules.")( + "smarts-file,S", po::value(&smarts_file_), + "Name of file containing SMARTS strings."); } diff --git a/Code/GraphMol/MolDraw2D/Qt/Demo/rdkitsv_main.cc b/Code/GraphMol/MolDraw2D/Qt/Demo/rdkitsv_main.cc index 25b95d368..9dc70c1e6 100644 --- a/Code/GraphMol/MolDraw2D/Qt/Demo/rdkitsv_main.cc +++ b/Code/GraphMol/MolDraw2D/Qt/Demo/rdkitsv_main.cc @@ -20,18 +20,17 @@ using namespace std; // **************************************************************************** -int main( int argc , char **argv ) { - - QApplication a( argc , argv ); +int main(int argc, char **argv) { + QApplication a(argc, argv); cout << "Built with Qt version " << QT_VERSION_STR << endl << "Running with Qt version " << qVersion() << endl - << "Using RDKit version " << RDKit::rdkitVersion << endl << endl; + << "Using RDKit version " << RDKit::rdkitVersion << endl + << endl; - RDKitSV::RDKitSVMainWindow *mw = new RDKitSV::RDKitSVMainWindow( argc , argv ); - mw->setWindowTitle( QObject::tr( "RDKit SV" ) ); - mw->setGeometry( 0 , 0 , 1000 , 1000 ); + RDKitSV::RDKitSVMainWindow *mw = new RDKitSV::RDKitSVMainWindow(argc, argv); + mw->setWindowTitle(QObject::tr("RDKit SV")); + mw->setGeometry(0, 0, 1000, 1000); mw->show(); return a.exec(); - } diff --git a/Code/GraphMol/MolDraw2D/Qt/DrawTextFTQt.cpp b/Code/GraphMol/MolDraw2D/Qt/DrawTextFTQt.cpp index 20eca8b4c..945acb2af 100644 --- a/Code/GraphMol/MolDraw2D/Qt/DrawTextFTQt.cpp +++ b/Code/GraphMol/MolDraw2D/Qt/DrawTextFTQt.cpp @@ -12,7 +12,6 @@ #include #include - namespace RDKit { // **************************************************************************** diff --git a/Code/GraphMol/MolDraw2D/Qt/MolDraw2DQt.cpp b/Code/GraphMol/MolDraw2D/Qt/MolDraw2DQt.cpp index a5c87f8f9..c686b2b38 100644 --- a/Code/GraphMol/MolDraw2D/Qt/MolDraw2DQt.cpp +++ b/Code/GraphMol/MolDraw2D/Qt/MolDraw2DQt.cpp @@ -19,7 +19,6 @@ #include "DrawTextQt.h" #endif - using namespace boost; using namespace std; diff --git a/Code/GraphMol/MolDraw2D/rxn_test1.cpp b/Code/GraphMol/MolDraw2D/rxn_test1.cpp index b2b8a64e4..bc4b437fa 100644 --- a/Code/GraphMol/MolDraw2D/rxn_test1.cpp +++ b/Code/GraphMol/MolDraw2D/rxn_test1.cpp @@ -126,7 +126,7 @@ std::hash_result_t hash_file(const std::string &filename) { } void check_file_hash(const std::string &filename, - std::hash_result_t exp_hash=0U) { + std::hash_result_t exp_hash = 0U) { // std::cout << filename << " : " << hash_file(filename) << "U" << std::endl; std::map::const_iterator it; diff --git a/Code/GraphMol/MolDraw2D/test1.cpp b/Code/GraphMol/MolDraw2D/test1.cpp index 7daf76934..93ce43fe5 100644 --- a/Code/GraphMol/MolDraw2D/test1.cpp +++ b/Code/GraphMol/MolDraw2D/test1.cpp @@ -1962,8 +1962,8 @@ void testDeuteriumTritium() { if (!ok) { continue; } - // there are no characters to look for, but each atom should - // be made of 2 glyphs, the superscript 2 and the H. + // there are no characters to look for, but each atom should + // be made of 2 glyphs, the superscript 2 and the H. #ifdef RDK_BUILD_FREETYPE_SUPPORT if ((line.find("atom-") != std::string::npos)) { if ((line.find("bond-") == std::string::npos)) { diff --git a/Code/GraphMol/MolStandardize/MolStandardize.h b/Code/GraphMol/MolStandardize/MolStandardize.h index 2d27185d1..091408b03 100644 --- a/Code/GraphMol/MolStandardize/MolStandardize.h +++ b/Code/GraphMol/MolStandardize/MolStandardize.h @@ -26,8 +26,8 @@ class ROMol; namespace MolStandardize { //! The CleanupParameters structure defines the default parameters for the -/// cleanup process and also allows the user to customize the process by changing -/// the parameters. +/// cleanup process and also allows the user to customize the process by +/// changing the parameters. /*! Notes: diff --git a/Code/GraphMol/PartialCharges/GasteigerCharges.cpp b/Code/GraphMol/PartialCharges/GasteigerCharges.cpp index 7ebdea75b..5e4bc7201 100644 --- a/Code/GraphMol/PartialCharges/GasteigerCharges.cpp +++ b/Code/GraphMol/PartialCharges/GasteigerCharges.cpp @@ -262,4 +262,4 @@ void computeGasteigerCharges(const ROMol &mol, std::vector &charges, hChrg[aix], true); } } -} +} // namespace RDKit diff --git a/Code/GraphMol/PartialCharges/GasteigerParams.cpp b/Code/GraphMol/PartialCharges/GasteigerParams.cpp index 298e1f1ec..9e7be8785 100644 --- a/Code/GraphMol/PartialCharges/GasteigerParams.cpp +++ b/Code/GraphMol/PartialCharges/GasteigerParams.cpp @@ -9,7 +9,7 @@ // of the RDKit source tree. // #include -typedef boost::tokenizer > tokenizer; +typedef boost::tokenizer> tokenizer; #include "GasteigerParams.h" #include @@ -70,7 +70,8 @@ Al sp2 5.795 5.020 0.695 \n \ typedef boost::flyweight< boost::flyweights::key_value, - boost::flyweights::no_tracking> gparam_flyweight; + boost::flyweights::no_tracking> + gparam_flyweight; GasteigerParams::GasteigerParams(std::string paramData) { boost::char_separator eolSep("\n"); @@ -122,4 +123,4 @@ const GasteigerParams *GasteigerParams::getParams( const GasteigerParams *res = &(gparam_flyweight(paramData).get()); return res; } -} +} // namespace RDKit diff --git a/Code/GraphMol/PartialCharges/Wrap/rdPartialCharges.cpp b/Code/GraphMol/PartialCharges/Wrap/rdPartialCharges.cpp index 23010a009..7385df04c 100644 --- a/Code/GraphMol/PartialCharges/Wrap/rdPartialCharges.cpp +++ b/Code/GraphMol/PartialCharges/Wrap/rdPartialCharges.cpp @@ -21,7 +21,7 @@ void ComputeGasteigerCharges(const ROMol &mol, int nIter, bool throwOnParamFailure) { computeGasteigerCharges(&mol, nIter, throwOnParamFailure); } -} +} // namespace RDKit BOOST_PYTHON_MODULE(rdPartialCharges) { python::scope().attr("__doc__") = diff --git a/Code/GraphMol/RGroupDecomposition/RGroupDecompData.h b/Code/GraphMol/RGroupDecomposition/RGroupDecompData.h index c3c33ab7c..1e7593958 100644 --- a/Code/GraphMol/RGroupDecomposition/RGroupDecompData.h +++ b/Code/GraphMol/RGroupDecomposition/RGroupDecompData.h @@ -130,7 +130,8 @@ struct RGroupDecompData { } void prune() { // prune all but the current "best" permutation of matches - PRECONDITION(permutation.size() <= matches.size(), "permutation.size() should be <= matches.size()"); + PRECONDITION(permutation.size() <= matches.size(), + "permutation.size() should be <= matches.size()"); size_t offset = matches.size() - permutation.size(); for (size_t mol_idx = 0; mol_idx < permutation.size(); ++mol_idx) { std::vector keepVector; diff --git a/Code/GraphMol/RGroupDecomposition/RGroupFingerprintScore.cpp b/Code/GraphMol/RGroupDecomposition/RGroupFingerprintScore.cpp index 7978d8ed7..0ab50ef80 100644 --- a/Code/GraphMol/RGroupDecomposition/RGroupFingerprintScore.cpp +++ b/Code/GraphMol/RGroupDecomposition/RGroupFingerprintScore.cpp @@ -191,11 +191,11 @@ double FingerprintVarianceScoreData::fingerprintVarianceGroupScore() { [](double sum, std::pair> pair) { auto variance = pair.second->variance(); - // perhaps here the variance should be weighted by occupancy- so that - // sparsely populated rgroups are penalized + // perhaps here the variance should be weighted by occupancy- so that + // sparsely populated rgroups are penalized - // e.g variance *= ((double) numberOfMolecules) / - // ((double)pair.second->numberFingerprints); + // e.g variance *= ((double) numberOfMolecules) / + // ((double)pair.second->numberFingerprints); #ifdef DEBUG std::cerr << variance << ','; #endif diff --git a/Code/GraphMol/RGroupDecomposition/RGroupGa.cpp b/Code/GraphMol/RGroupDecomposition/RGroupGa.cpp index 5fc545664..1682ac76f 100644 --- a/Code/GraphMol/RGroupDecomposition/RGroupGa.cpp +++ b/Code/GraphMol/RGroupDecomposition/RGroupGa.cpp @@ -43,7 +43,8 @@ double RGroupDecompositionChromosome::score() { if (operationName != RgroupMutate) { decode(); } - if (scoreMethod == FingerprintVariance && fingerprintVarianceScoreData.labelsToVarianceData.size() > 0 && + if (scoreMethod == FingerprintVariance && + fingerprintVarianceScoreData.labelsToVarianceData.size() > 0 && operationName == RgroupMutate) { fitness = fingerprintVarianceScoreData.fingerprintVarianceGroupScore(); // Uncomment the following line to check that the @@ -81,7 +82,8 @@ void RGroupDecompositionChromosome::copyGene( const StringChromosomeBase& other) { StringChromosomeBase::copyGene(other); const auto& parent = static_cast(other); - copyVarianceData(parent.fingerprintVarianceScoreData, fingerprintVarianceScoreData); + copyVarianceData(parent.fingerprintVarianceScoreData, + fingerprintVarianceScoreData); } GaResult& GaResult::operator=(const GaResult& other) { @@ -164,7 +166,7 @@ void RGroupGa::rGroupMutateOperation( child->setOperationName(RgroupMutate); child->decode(); - auto &fingerprintVarianceScoreData = child->getFingerprintVarianceScoreData(); + auto& fingerprintVarianceScoreData = child->getFingerprintVarianceScoreData(); if (fingerprintVarianceScoreData.labelsToVarianceData.size() == 0) return; #ifdef DEBUG std::cerr << "RGroup mutate start" << std::endl; @@ -184,12 +186,14 @@ void RGroupGa::rGroupMutateOperation( int parentValue = parentPermutation.at(pos); int childValue = childPermutation.at(pos); if (parentValue != childValue) { - fingerprintVarianceScoreData.removeVarianceData(pos, parentValue, matches, labels); + fingerprintVarianceScoreData.removeVarianceData(pos, parentValue, matches, + labels); #ifdef DEBUG std::cerr << "After removing parent" << std::endl; fingerprintVarianceGroupScore(fingerprintVarianceScoreData); #endif - fingerprintVarianceScoreData.addVarianceData(pos, childValue, matches, labels); + fingerprintVarianceScoreData.addVarianceData(pos, childValue, matches, + labels); #ifdef DEBUG std::cerr << "After adding child" << std::endl; fingerprintVarianceGroupScore(fingerprintVarianceScoreData); @@ -304,7 +308,8 @@ vector RGroupGa::runBatch() { #ifndef RDK_TEST_MULTITHREADED if (gaParallelRuns) { gaParallelRuns = false; - BOOST_LOG(rdWarningLog) << "This RDKit build does not enable GA parallel runs" << std::endl; + BOOST_LOG(rdWarningLog) + << "This RDKit build does not enable GA parallel runs" << std::endl; } #endif diff --git a/Code/GraphMol/RGroupDecomposition/RGroupScore.cpp b/Code/GraphMol/RGroupDecomposition/RGroupScore.cpp index 473bc8ae1..043ede595 100644 --- a/Code/GraphMol/RGroupDecomposition/RGroupScore.cpp +++ b/Code/GraphMol/RGroupDecomposition/RGroupScore.cpp @@ -24,7 +24,8 @@ double RGroupScorer::matchScore( const std::vector &permutation, const std::vector> &matches, const std::set &labels) { - PRECONDITION(permutation.size() <= matches.size(), "permutation.size() should be <= matches.size()"); + PRECONDITION(permutation.size() <= matches.size(), + "permutation.size() should be <= matches.size()"); double score = 0.; const std::string EMPTY_RGROUP = ""; size_t offset = matches.size() - permutation.size(); @@ -34,7 +35,6 @@ double RGroupScorer::matchScore( std::cerr << "Scoring permutation " << " num matches: " << matches.size() << std::endl; - BOOST_LOG(rdDebugLog) << "Scoring" << std::endl; for (size_t m = 0; m < permutation.size(); ++m) { // for each molecule BOOST_LOG(rdDebugLog) << "Molecule " << m << " " @@ -90,15 +90,15 @@ double RGroupScorer::matchScore( unsigned int &count = labelData.matchSetVect[i][smiles]; ++count; #ifdef DEBUG - std::cerr << i << " smiles:" << smiles << " " << count << std::endl; - std::cerr << " Linker Score: " - << labelData.linkerMatchSet[rg->second->attachments] - << std::endl; + std::cerr << i << " smiles:" << smiles << " " << count << std::endl; + std::cerr << " Linker Score: " + << labelData.linkerMatchSet[rg->second->attachments] + << std::endl; #endif ++i; } } - + double tempScore = 0.; for (auto &matchSet : labelData.matchSetVect) { // get the counts for each rgroup found and sort in reverse order @@ -128,8 +128,8 @@ double RGroupScorer::matchScore( #endif } // make sure to rescale groups like [*:1].[*:1]C otherwise this will be - // double counted - // WE SHOULD PROBABLY REJECT THESE OUTRIGHT + // double counted + // WE SHOULD PROBABLY REJECT THESE OUTRIGHT tempScore /= static_cast(labelData.matchSetVect.size()); } @@ -164,7 +164,7 @@ double RGroupScorer::matchScore( << std::endl; std::cerr << "Score = " << score << std::endl; #endif - } // end for each label + } // end for each label #ifdef DEBUG BOOST_LOG(rdDebugLog) << score << std::endl; diff --git a/Code/GraphMol/RGroupDecomposition/RGroupScore.h b/Code/GraphMol/RGroupDecomposition/RGroupScore.h index 75aa8641a..514887057 100644 --- a/Code/GraphMol/RGroupDecomposition/RGroupScore.h +++ b/Code/GraphMol/RGroupDecomposition/RGroupScore.h @@ -121,7 +121,8 @@ class RDKIT_RGROUPDECOMPOSITION_EXPORT RGroupScorer { // heavyCounts is a vector which has the same size of labels // for each label we add an increment if a molecule // bears an R-group at that label - PRECONDITION(permutation.size() <= matches.size(), "permutation.size() should be <= matches.size()"); + PRECONDITION(permutation.size() <= matches.size(), + "permutation.size() should be <= matches.size()"); size_t offset = matches.size() - permutation.size(); // numMatchedUserRGroups counts the total number of user labelled r // groups filled in this permutation. We want to maximize this number diff --git a/Code/GraphMol/RGroupDecomposition/RGroupUtils.cpp b/Code/GraphMol/RGroupDecomposition/RGroupUtils.cpp index 9a1309886..d469bd392 100644 --- a/Code/GraphMol/RGroupDecomposition/RGroupUtils.cpp +++ b/Code/GraphMol/RGroupDecomposition/RGroupUtils.cpp @@ -100,7 +100,7 @@ bool setLabel(Atom *atom, int label, std::set &labels, int &maxLabel, bool isUserRLabel(const Atom &atom) { return atom.hasProp(RLABEL) && atom.hasProp(RLABEL_TYPE) && static_cast(atom.getProp(RLABEL_TYPE)) != - Labelling::INDEX_LABELS; + Labelling::INDEX_LABELS; } bool isAtomWithMultipleNeighborsOrNotUserRLabel(const Atom &atom) { diff --git a/Code/GraphMol/RGroupDecomposition/testRGroupDecomp.cpp b/Code/GraphMol/RGroupDecomposition/testRGroupDecomp.cpp index a60b76645..9262ba4a9 100644 --- a/Code/GraphMol/RGroupDecomposition/testRGroupDecomp.cpp +++ b/Code/GraphMol/RGroupDecomposition/testRGroupDecomp.cpp @@ -198,7 +198,9 @@ void testGaBatch() { decomp.process(); RGroupRows rows = decomp.getRGroupsAsRows(); - bool isParallelGaEnabled = (sstrm.str().find("This RDKit build does not enable GA parallel runs") == std::string::npos); + bool isParallelGaEnabled = + (sstrm.str().find("This RDKit build does not enable GA parallel runs") == + std::string::npos); #ifdef RDK_TEST_MULTITHREADED TEST_ASSERT(isParallelGaEnabled); #else diff --git a/Code/GraphMol/RGroupDecomposition/testRGroupInternals.cpp b/Code/GraphMol/RGroupDecomposition/testRGroupInternals.cpp index 8daf8423f..74dda8f9d 100644 --- a/Code/GraphMol/RGroupDecomposition/testRGroupInternals.cpp +++ b/Code/GraphMol/RGroupDecomposition/testRGroupInternals.cpp @@ -85,7 +85,8 @@ void testCoresLabelledProperly() { } } -std::pair makeRData(int attachment, std::vector attachments, const std::string &smiles) { +std::pair makeRData(int attachment, std::vector attachments, + const std::string &smiles) { auto rData = boost::make_shared(); auto mol = SmilesToMol(smiles); auto frags = MolOps::getMolFrags(*mol); @@ -99,14 +100,15 @@ std::pair makeRData(int attachment, std::vector attachments, co std::pair makeRData(int attachment, const std::string &smiles) { std::vector attachments{attachment}; - return makeRData(attachment, attachments, smiles) ; + return makeRData(attachment, attachments, smiles); } void testRingMatching3Score() { - BOOST_LOG(rdInfoLog) - << "********************************************************\n"; - BOOST_LOG(rdInfoLog) << "Test scoring function for RingMatching3- see GitHub ##3924" << std::endl; + << "********************************************************\n"; + BOOST_LOG(rdInfoLog) + << "Test scoring function for RingMatching3- see GitHub ##3924" + << std::endl; R_DECOMP decomp1Mol1 = { makeRData(-4, "*[H]"), @@ -168,7 +170,7 @@ void testRingMatching3Score() { // expect test1 to have better score than test2 since all halogens are on R1 - TEST_ASSERT(test1 > test2); + TEST_ASSERT(test1 > test2); auto testFp1 = fingerprintVarianceScore(permutation, allMatches1, labels); auto testFp2 = fingerprintVarianceScore(permutation, allMatches2, labels); @@ -178,10 +180,12 @@ void testRingMatching3Score() { void testGeminalRGroups() { BOOST_LOG(rdInfoLog) - << "********************************************************\n"; - BOOST_LOG(rdInfoLog) << "Test scoring function for Geminal R-Groups- see GitHub #3924" << std::endl; + << "********************************************************\n"; + BOOST_LOG(rdInfoLog) + << "Test scoring function for Geminal R-Groups- see GitHub #3924" + << std::endl; - std::vector attachments {5, 6}; + std::vector attachments{5, 6}; R_DECOMP decomp1Mol1 = { makeRData(-6, "*[H]"), makeRData(-5, "*[H]"), @@ -300,7 +304,6 @@ void testGithub3746() { TEST_ASSERT(numberPermutations < ga.getPopsize() * 100); } - int main() { RDLog::InitLogs(); boost::logging::disable_logs("rdApp.debug"); diff --git a/Code/GraphMol/ReducedGraphs/test1.cpp b/Code/GraphMol/ReducedGraphs/test1.cpp index 03684adf4..ad983d007 100644 --- a/Code/GraphMol/ReducedGraphs/test1.cpp +++ b/Code/GraphMol/ReducedGraphs/test1.cpp @@ -172,8 +172,8 @@ void test2() { } void testCanRetrieveProp() { - BOOST_LOG(rdInfoLog) - << "testing retrieving _ErGAtomTypes from property" << std::endl; + BOOST_LOG(rdInfoLog) << "testing retrieving _ErGAtomTypes from property" + << std::endl; auto m = "OCCc1ccccc1"_smiles; std::vector> expected{{0, 1}, {}, {}, {}, {5}}; std::vector> res; diff --git a/Code/GraphMol/Resonance.cpp b/Code/GraphMol/Resonance.cpp index b091a4e58..3f5f779dc 100644 --- a/Code/GraphMol/Resonance.cpp +++ b/Code/GraphMol/Resonance.cpp @@ -1092,23 +1092,18 @@ bool ConjElectrons::popFromBeginStack(unsigned int &ai) { // 7) Sum of the indices of multiple bonds bool CEVect2::resonanceStructureCompare(const ConjElectrons *a, const ConjElectrons *b) { - return ( - (a->nbMissing() != b->nbMissing()) - ? (a->nbMissing() < b->nbMissing()) + return ((a->nbMissing() != b->nbMissing()) ? (a->nbMissing() < b->nbMissing()) : (a->absFormalCharges() != b->absFormalCharges()) - ? (a->absFormalCharges() < b->absFormalCharges()) - : (a->wtdFormalCharges() != b->wtdFormalCharges()) - ? (a->wtdFormalCharges() < b->wtdFormalCharges()) - : (a->fcSameSignDist() != b->fcSameSignDist()) - ? (a->fcSameSignDist() > b->fcSameSignDist()) - : (a->fcOppSignDist() != b->fcOppSignDist()) - ? (a->fcOppSignDist() > b->fcOppSignDist()) - : (a->sumFormalChargeIdxs() != - b->sumFormalChargeIdxs()) - ? (a->sumFormalChargeIdxs() < - b->sumFormalChargeIdxs()) - : (a->sumMultipleBondIdxs() < - b->sumMultipleBondIdxs())); + ? (a->absFormalCharges() < b->absFormalCharges()) + : (a->wtdFormalCharges() != b->wtdFormalCharges()) + ? (a->wtdFormalCharges() < b->wtdFormalCharges()) + : (a->fcSameSignDist() != b->fcSameSignDist()) + ? (a->fcSameSignDist() > b->fcSameSignDist()) + : (a->fcOppSignDist() != b->fcOppSignDist()) + ? (a->fcOppSignDist() > b->fcOppSignDist()) + : (a->sumFormalChargeIdxs() != b->sumFormalChargeIdxs()) + ? (a->sumFormalChargeIdxs() < b->sumFormalChargeIdxs()) + : (a->sumMultipleBondIdxs() < b->sumMultipleBondIdxs())); } CEVect2::CEVect2(const CEMap &ceMap) { diff --git a/Code/GraphMol/SLNParse/SLNAttribs.cpp b/Code/GraphMol/SLNParse/SLNAttribs.cpp index 9aa0833a7..a50d291bf 100644 --- a/Code/GraphMol/SLNParse/SLNAttribs.cpp +++ b/Code/GraphMol/SLNParse/SLNAttribs.cpp @@ -168,8 +168,8 @@ void parseAtomAttribs(Atom *atom, AttribListType attribs, bool doingQuery) { } } else if (attribName == "r") { if (attribVal != "") { - BOOST_LOG(rdWarningLog) << "Query value '" << attribVal - << "' ignored for r query\n"; + BOOST_LOG(rdWarningLog) + << "Query value '" << attribVal << "' ignored for r query\n"; } if (!doingQuery) { BOOST_LOG(rdWarningLog) << "Query property '" << attribName @@ -435,8 +435,8 @@ void parseBondAttribs(Bond *bond, AttribListType attribs, bool doingQuery) { } } else if (attribName == "r") { if (attribVal != "") { - BOOST_LOG(rdWarningLog) << "Query value '" << attribVal - << "' ignored for r query\n"; + BOOST_LOG(rdWarningLog) + << "Query value '" << attribVal << "' ignored for r query\n"; } if (!doingQuery) { BOOST_LOG(rdWarningLog) << "Query property '" << attribName @@ -495,7 +495,7 @@ void adjustAtomChiralities(RWMol *mol) { } else if (attribVal[0] == 'i') { (*atomIt)->setChiralTag(Atom::CHI_TETRAHEDRAL_CCW); } - std::list > neighbors; + std::list> neighbors; RWMol::ADJ_ITER nbrIdx, endNbrs; boost::tie(nbrIdx, endNbrs) = mol->getAtomNeighbors(*atomIt); while (nbrIdx != endNbrs) { @@ -510,7 +510,7 @@ void adjustAtomChiralities(RWMol *mol) { neighbors.sort(); // figure out the bond ordering: std::list bondOrdering; - for (std::list >::const_iterator nbrIt = + for (std::list>::const_iterator nbrIt = neighbors.begin(); nbrIt != neighbors.end(); ++nbrIt) { bondOrdering.push_back(nbrIt->second); @@ -531,5 +531,5 @@ void adjustAtomChiralities(RWMol *mol) { } } } -} // end of SLNParse namespace -} // end of RDKit namespace +} // namespace SLNParse +} // namespace RDKit diff --git a/Code/GraphMol/ShapeHelpers/ShapeEncoder.cpp b/Code/GraphMol/ShapeHelpers/ShapeEncoder.cpp index 77638b2c0..bd7e23915 100644 --- a/Code/GraphMol/ShapeHelpers/ShapeEncoder.cpp +++ b/Code/GraphMol/ShapeHelpers/ShapeEncoder.cpp @@ -49,5 +49,5 @@ void EncodeShape(const Conformer &conf, RDGeom::UniformGrid3D &grid, grid.setSphereOccupancy(loc, vdwScale * rad, stepSize, maxLayers); } } -} -} +} // namespace MolShapes +} // namespace RDKit diff --git a/Code/GraphMol/ShapeHelpers/ShapeUtils.cpp b/Code/GraphMol/ShapeHelpers/ShapeUtils.cpp index 481ba9dec..e7d89c30b 100644 --- a/Code/GraphMol/ShapeHelpers/ShapeUtils.cpp +++ b/Code/GraphMol/ShapeHelpers/ShapeUtils.cpp @@ -97,22 +97,22 @@ void computeUnionBox(const RDGeom::Point3D &leftBottom1, uRightTop.z = std::max(rightTop1.z, rightTop2.z); } -double tverskyIndex(const ROMol &mol1, const ROMol &mol2, double alpha, double beta, int confId1, - int confId2, double gridSpacing, - DiscreteValueVect::DiscreteValueType bitsPerPoint, - double vdwScale, double stepSize, int maxLayers, - bool ignoreHs) { +double tverskyIndex(const ROMol &mol1, const ROMol &mol2, double alpha, + double beta, int confId1, int confId2, double gridSpacing, + DiscreteValueVect::DiscreteValueType bitsPerPoint, + double vdwScale, double stepSize, int maxLayers, + bool ignoreHs) { const Conformer &conf1 = mol1.getConformer(confId1); const Conformer &conf2 = mol2.getConformer(confId2); return tverskyIndex(conf1, conf2, alpha, beta, gridSpacing, bitsPerPoint, - vdwScale, stepSize, maxLayers, ignoreHs); + vdwScale, stepSize, maxLayers, ignoreHs); } -double tverskyIndex(const Conformer &conf1, const Conformer &conf2, double alpha, double beta, - double gridSpacing, - DiscreteValueVect::DiscreteValueType bitsPerPoint, - double vdwScale, double stepSize, int maxLayers, - bool ignoreHs) { +double tverskyIndex(const Conformer &conf1, const Conformer &conf2, + double alpha, double beta, double gridSpacing, + DiscreteValueVect::DiscreteValueType bitsPerPoint, + double vdwScale, double stepSize, int maxLayers, + bool ignoreHs) { RDGeom::Transform3D *trans = MolTransforms::computeCanonicalTransform(conf1); // now use this transform and figure out what size grid we will need @@ -141,7 +141,6 @@ double tverskyIndex(const Conformer &conf1, const Conformer &conf2, double alpha return RDGeom::tverskyIndex(grd1, grd2, alpha, beta); } - double tanimotoDistance(const ROMol &mol1, const ROMol &mol2, int confId1, int confId2, double gridSpacing, DiscreteValueVect::DiscreteValueType bitsPerPoint, @@ -149,8 +148,8 @@ double tanimotoDistance(const ROMol &mol1, const ROMol &mol2, int confId1, bool ignoreHs) { const Conformer &conf1 = mol1.getConformer(confId1); const Conformer &conf2 = mol2.getConformer(confId2); - return tanimotoDistance(conf1, conf2, gridSpacing, bitsPerPoint, - vdwScale, stepSize, maxLayers, ignoreHs); + return tanimotoDistance(conf1, conf2, gridSpacing, bitsPerPoint, vdwScale, + stepSize, maxLayers, ignoreHs); } double tanimotoDistance(const Conformer &conf1, const Conformer &conf2, @@ -240,5 +239,5 @@ double protrudeDistance(const Conformer &conf1, const Conformer &conf2, } return res; } -} -} +} // namespace MolShapes +} // namespace RDKit diff --git a/Code/GraphMol/ShapeHelpers/Wrap/rdShapeHelpers.cpp b/Code/GraphMol/ShapeHelpers/Wrap/rdShapeHelpers.cpp index fe718f99a..e4935c6a8 100644 --- a/Code/GraphMol/ShapeHelpers/Wrap/rdShapeHelpers.cpp +++ b/Code/GraphMol/ShapeHelpers/Wrap/rdShapeHelpers.cpp @@ -121,15 +121,16 @@ void EncodeMolShape( maxLayers, ignoreHs); } } -double tverskyMolShapes(const ROMol &mol1, const ROMol &mol2, double alpha, double beta, int confId1 = -1, - int confId2 = -1, double gridSpacing = 0.5, - DiscreteValueVect::DiscreteValueType bitsPerPoint = - DiscreteValueVect::TWOBITVALUE, - double vdwScale = 0.8, double stepSize = 0.25, - int maxLayers = -1, bool ignoreHs = true) { - return MolShapes::tverskyIndex(mol1, mol2, alpha, beta, confId1, confId2, gridSpacing, - bitsPerPoint, vdwScale, stepSize, - maxLayers, ignoreHs); +double tverskyMolShapes(const ROMol &mol1, const ROMol &mol2, double alpha, + double beta, int confId1 = -1, int confId2 = -1, + double gridSpacing = 0.5, + DiscreteValueVect::DiscreteValueType bitsPerPoint = + DiscreteValueVect::TWOBITVALUE, + double vdwScale = 0.8, double stepSize = 0.25, + int maxLayers = -1, bool ignoreHs = true) { + return MolShapes::tverskyIndex(mol1, mol2, alpha, beta, confId1, confId2, + gridSpacing, bitsPerPoint, vdwScale, stepSize, + maxLayers, ignoreHs); } double tanimotoMolShapes(const ROMol &mol1, const ROMol &mol2, int confId1 = -1, @@ -153,7 +154,7 @@ double protrudeMolShapes(const ROMol &mol1, const ROMol &mol2, int confId1 = -1, bitsPerPoint, vdwScale, stepSize, maxLayers, ignoreHs, allowReordering); } -} +} // namespace RDKit BOOST_PYTHON_MODULE(rdShapeHelpers) { python::scope().attr("__doc__") = @@ -210,15 +211,14 @@ BOOST_PYTHON_MODULE(rdShapeHelpers) { python::def( "ShapeTverskyIndex", RDKit::tverskyMolShapes, - (python::arg("mol1"), python::arg("mol2"), python::arg("alpha"), python::arg("beta"), - python::arg("confId1") = -1, + (python::arg("mol1"), python::arg("mol2"), python::arg("alpha"), + python::arg("beta"), python::arg("confId1") = -1, python::arg("confId2") = -1, python::arg("gridSpacing") = 0.5, python::arg("bitsPerPoint") = RDKit::DiscreteValueVect::TWOBITVALUE, python::arg("vdwScale") = 0.8, python::arg("stepSize") = 0.25, python::arg("maxLayers") = -1, python::arg("ignoreHs") = true), docString.c_str()); - docString = "Compute the shape tanimoto distance between two molecule based on a predefined alignment\n\ \n\ diff --git a/Code/GraphMol/SmilesParse/SmilesWrite.h b/Code/GraphMol/SmilesParse/SmilesWrite.h index 092b49dee..5c150c78f 100644 --- a/Code/GraphMol/SmilesParse/SmilesWrite.h +++ b/Code/GraphMol/SmilesParse/SmilesWrite.h @@ -50,16 +50,15 @@ enum CXSmilesFields : uint32_t { CX_ENHANCEDSTEREO = 1 << 6, CX_SGROUPS = 1 << 7, CX_POLYMER = 1 << 8, - // NB: std::int32_t is intentional as a non-scoped enum is implicitly cast to int - // so numbers larger than std::numeric_limits::max() will be + // NB: std::int32_t is intentional as a non-scoped enum is implicitly cast to + // int so numbers larger than std::numeric_limits::max() will be // negative CX_ALL = std::numeric_limits::max() }; //! \brief returns the cxsmiles data for a molecule RDKIT_SMILESPARSE_EXPORT std::string getCXExtensions( - const ROMol &mol, - std::uint32_t flags = CXSmilesFields::CX_ALL); + const ROMol &mol, std::uint32_t flags = CXSmilesFields::CX_ALL); //! \brief returns true if the atom number is in the SMILES organic subset RDKIT_SMILESPARSE_EXPORT bool inOrganicSubset(int atomicNumber); diff --git a/Code/GraphMol/StructChecker/AtomSymbolMatch.cpp b/Code/GraphMol/StructChecker/AtomSymbolMatch.cpp index cd57df718..40dee7444 100644 --- a/Code/GraphMol/StructChecker/AtomSymbolMatch.cpp +++ b/Code/GraphMol/StructChecker/AtomSymbolMatch.cpp @@ -162,37 +162,58 @@ static const char *trb[] = /* pseudosymbol "trb" */ static const char *tm1[] = /* pseudosymbol "tm1" */ { - "Cu", "Ag", "Au", nullptr, + "Cu", + "Ag", + "Au", + nullptr, }; static const char *tm2[] = /* pseudosymbol "tm2" */ { - "Zn", "Cd", "Hg", nullptr, + "Zn", + "Cd", + "Hg", + nullptr, }; static const char *tm3[] = /* pseudosymbol "tm3" */ { - "Sc", "Y", "La", nullptr, + "Sc", + "Y", + "La", + nullptr, }; static const char *tm4[] = /* pseudosymbol "tm4" */ { - "Ti", "Zr", "Hf", nullptr, + "Ti", + "Zr", + "Hf", + nullptr, }; static const char *tm5[] = /* pseudosymbol "tm5" */ { - "V", "Nb", "Ta", nullptr, + "V", + "Nb", + "Ta", + nullptr, }; static const char *tm6[] = /* pseudosymbol "tm6" */ { - "Cr", "Mo", "W", nullptr, + "Cr", + "Mo", + "W", + nullptr, }; static const char *tm7[] = /* pseudosymbol "tm7" */ { - "Mn", "Tc", "Re", nullptr, + "Mn", + "Tc", + "Re", + nullptr, }; static const char *tm8[] = /* pseudosymbol "tm8" */ diff --git a/Code/GraphMol/StructChecker/AugmentedAtomData.cpp b/Code/GraphMol/StructChecker/AugmentedAtomData.cpp index e927452ad..a432e3a2a 100644 --- a/Code/GraphMol/StructChecker/AugmentedAtomData.cpp +++ b/Code/GraphMol/StructChecker/AugmentedAtomData.cpp @@ -1085,9 +1085,9 @@ static const AugmentedAtom_t DefaultAcidicAtoms[] = { {"I", "I", 0, RT_NONE, TP_NONE}}; struct AugmentedAtomTransforms_t { - const char * from; - const char * to; - const char * label; + const char *from; + const char *to; + const char *label; }; static const AugmentedAtomTransforms_t DefaultAugmentedAtomTransforms[] = { @@ -1241,4 +1241,4 @@ static const AugmentedAtomTransforms_t DefaultAugmentedAtomTransforms[] = { }; } // namespace StructureCheck -} // RDKit +} // namespace RDKit diff --git a/Code/GraphMol/StructChecker/Pattern.cpp b/Code/GraphMol/StructChecker/Pattern.cpp index 969bd8ce7..0cbdc1805 100644 --- a/Code/GraphMol/StructChecker/Pattern.cpp +++ b/Code/GraphMol/StructChecker/Pattern.cpp @@ -72,8 +72,8 @@ AABondType convertBondType(RDKit::Bond::BondType rdbt) { } /* -* Checks if the ligand is compatible with the bond and the atom. -*/ + * Checks if the ligand is compatible with the bond and the atom. + */ bool LigandMatches(const Atom &a, const Bond &b, const Ligand &l, bool use_charge) { if (l.BondType != ANY_BOND && !isBondTypeMatch(b, l.BondType)) return false; @@ -324,11 +324,11 @@ static bool RecMatchNeigh(std::vector &matched_pairs, } /* -* Recursively searches *mp for the next atom to be appended to -* match[0..level]. Returns TRUE if all ligands in aap are mapped -* successfully. nbp[i] describes the neighbour bonds and atoms -* of atom i. -*/ + * Recursively searches *mp for the next atom to be appended to + * match[0..level]. Returns TRUE if all ligands in aap are mapped + * successfully. nbp[i] describes the neighbour bonds and atoms + * of atom i. + */ bool RecMatch(const ROMol &mol, unsigned atomIdx, const AugmentedAtom &aa, const std::vector &nbp, bool verbose) { const Neighbourhood &nbph = nbp[atomIdx]; @@ -430,11 +430,11 @@ aa.Ligands.size()<<" "<< aa.ShortName <<"\n"; } */ /* -* Tests if atom i in *mp matches the augmented atom description -* *aap. nbp[] is used to speed up access to neighbour atoms and -* bonds. The first matching atom mapping is placed into match[1..]. -* i is stored in match[0]. -*/ + * Tests if atom i in *mp matches the augmented atom description + * *aap. nbp[] is used to speed up access to neighbour atoms and + * bonds. The first matching atom mapping is placed into match[1..]. + * i is stored in match[0]. + */ bool AAMatch(const ROMol &mol, unsigned i, // std::vector &match, const AugmentedAtom &aa, @@ -473,10 +473,10 @@ bool AAMatch(const ROMol &mol, unsigned i, } /* -* Computes how many basis rings each bond shares and how many -* ring bonds are attached to an atom. The results are stored in -* atom_status[] and bond_status[] respectively. -*/ + * Computes how many basis rings each bond shares and how many + * ring bonds are attached to an atom. The results are stored in + * atom_status[] and bond_status[] respectively. + */ static void RingState(const ROMol &mol, std::vector &atom_status, std::vector &bond_status) { atom_status.resize(mol.getNumAtoms()); @@ -501,10 +501,10 @@ static void RingState(const ROMol &mol, std::vector &atom_status, } /* -* Checks if every atom in *mp matches one of the augmented atoms -* in good_atoms[0..ngood-1]. It returns TRUE if all atoms gave a match or FALSE -* otherwise. -*/ + * Checks if every atom in *mp matches one of the augmented atoms + * in good_atoms[0..ngood-1]. It returns TRUE if all atoms gave a match or FALSE + * otherwise. + */ bool CheckAtoms(const ROMol &mol, const std::vector &good_atoms, bool verbose) { if (good_atoms.empty()) return true; @@ -565,8 +565,8 @@ bool CheckAtoms(const ROMol &mol, const std::vector &good_atoms, if (neighbours[i].Atoms.size() == good_atoms[j].Ligands.size() && AAMatch(mol, i, good_atoms[j], atom_status, neighbours, verbose)) { if (verbose) { - BOOST_LOG(rdInfoLog) << "AAMatch idx=" << i << " aa_idx=" << j - << " ret TRUE !\n"; + BOOST_LOG(rdInfoLog) + << "AAMatch idx=" << i << " aa_idx=" << j << " ret TRUE !\n"; } // DEBUG: // if (verbose && j >= 12 && j <= 21 && @@ -590,8 +590,8 @@ bool CheckAtoms(const ROMol &mol, const std::vector &good_atoms, << LogNeighbourhood(mol, i, neighbours) << std::endl; if (verbose && j == good_atoms.size()) { // failed this atom .. log it - BOOST_LOG(rdWarningLog) << LogNeighbourhood(mol, i, neighbours) - << std::endl; + BOOST_LOG(rdWarningLog) + << LogNeighbourhood(mol, i, neighbours) << std::endl; } } return (nmatch == mol.getNumAtoms()); diff --git a/Code/GraphMol/StructChecker/ReCharge.cpp b/Code/GraphMol/StructChecker/ReCharge.cpp index bbed8f3cc..82e8dbf57 100644 --- a/Code/GraphMol/StructChecker/ReCharge.cpp +++ b/Code/GraphMol/StructChecker/ReCharge.cpp @@ -15,8 +15,8 @@ namespace RDKit { namespace StructureCheck { /* -* Returns the total charge of all atoms in molecule. -*/ + * Returns the total charge of all atoms in molecule. + */ int TotalCharge(const ROMol &mol) { int charge = 0; for (unsigned i = 0; i < mol.getNumAtoms(); i++) { @@ -27,10 +27,10 @@ int TotalCharge(const ROMol &mol) { } /* -* Checks if all defined stereocenters in *mp are unambiguously -* numbered by numbering, i.e. all four ligands get different -* numbers. It returns TRUE if this is the case and FALSE otherwise. -*/ + * Checks if all defined stereocenters in *mp are unambiguously + * numbered by numbering, i.e. all four ligands get different + * numbers. It returns TRUE if this is the case and FALSE otherwise. + */ bool AllCentersRefined(const ROMol &mol, std::vector &numbering) { std::vector neighbour_array; int parity; @@ -76,13 +76,13 @@ bool AllCentersRefined(const ROMol &mol, std::vector &numbering) { } /* -* Removes hydrogens from *mp until desired_charge is reached. The -* positions for hydrogen removal are selected by "acidity" combined -* with a refinement algorithm. It returns TRUE if molecule could be -* neutralized and FALSE if any problem were encountered. -* *ndeprot and *nrefine are set to the number of deprotonations -* and refinement cycles performed. -*/ + * Removes hydrogens from *mp until desired_charge is reached. The + * positions for hydrogen removal are selected by "acidity" combined + * with a refinement algorithm. It returns TRUE if molecule could be + * neutralized and FALSE if any problem were encountered. + * *ndeprot and *nrefine are set to the number of deprotonations + * and refinement cycles performed. + */ bool ChargeFix::rechargeMolecule(unsigned &ndeprot, unsigned &nrefine) { bool changed = false; int nacid = 0; @@ -152,10 +152,10 @@ void ChargeFix::resetValues() { } /* -* Estimates the pKa value of acidic atoms in molecule *mp and sets -* the 'value' fields to this value. -* It returns TRUE if all went well and FALSE otherwise. -*/ + * Estimates the pKa value of acidic atoms in molecule *mp and sets + * the 'value' fields to this value. + * It returns TRUE if all went well and FALSE otherwise. + */ bool ChargeFix::setpKaValues() { const ROMol &mol = Mol; bool result = true; @@ -389,11 +389,11 @@ bool ChargeFix::setpKaValues() { } /* -* Marks those atoms which have the smallest pKa value of all acidic -* (i.e. already marked) atoms. All other marks are removed. -* *pKa_value is set to the minimum pKa, and *gap is set to the -* pKa difference to the next acidic set of atoms. -*/ + * Marks those atoms which have the smallest pKa value of all acidic + * (i.e. already marked) atoms. All other marks are removed. + * *pKa_value is set to the minimum pKa, and *gap is set to the + * pKa difference to the next acidic set of atoms. + */ int ChargeFix::markMostAcidicAtoms(double &pKa_value, double &gap) { double min_pKa = 1000.0; double next_pKa = 1000.0; @@ -422,8 +422,8 @@ int ChargeFix::markMostAcidicAtoms(double &pKa_value, double &gap) { } /* -* Decrements the charges of all marked atoms. -*/ + * Decrements the charges of all marked atoms. + */ void ChargeFix::decrementMarkedCharges() { for (unsigned i = 0; i < Mol.getNumAtoms(); i++) if (0 != AtomColor[i]) @@ -440,10 +440,10 @@ struct atom_rank_t { }; /* -* Refines the class of acidic atoms to a smaller one based on -* the electronegativity of the neighbouring atoms. -* It returns the size of this class. -*/ + * Refines the class of acidic atoms to a smaller one based on + * the electronegativity of the neighbouring atoms. + * It returns the size of this class. + */ int ChargeFix::refineAcidicAtoms(std::vector &numbering) { int result = 0; bool changed, do_cis_trans; diff --git a/Code/GraphMol/StructChecker/Stereo.cpp b/Code/GraphMol/StructChecker/Stereo.cpp index 25caa5aeb..573b50fef 100644 --- a/Code/GraphMol/StructChecker/Stereo.cpp +++ b/Code/GraphMol/StructChecker/Stereo.cpp @@ -77,10 +77,10 @@ static double Volume(struct npoint_t tetra[4]) { int DubiousStereochemistry(RWMol &mol) { /* - * Checks if there is some ill-defined stereochemistry in the - * molecule *mp. The function returns a bit set integer which defines - * the problems encountered. - */ + * Checks if there is some ill-defined stereochemistry in the + * molecule *mp. The function returns a bit set integer which defines + * the problems encountered. + */ int result = 0; // int is_allene, ndb, jatom; @@ -136,13 +136,15 @@ int DubiousStereochemistry(RWMol &mol) { for (unsigned j = 0; j < n_ligands; j++) { const Bond &bj = *mol.getBondWithIdx(nbp.Bonds[j]); - if (bj.getBeginAtomIdx() == i && - (RDKit::Bond::BEGINWEDGE == bj.getBondDir() || // == UP + if (bj.getBeginAtomIdx() == i && + (RDKit::Bond::BEGINWEDGE == bj.getBondDir() || // == UP RDKit::Bond::BEGINDASH == bj.getBondDir())) { // == DOWN)) std::string name; mol.getPropIfPresent(common_properties::_Name, name); - BOOST_LOG(rdWarningLog) << boost::format("%10s atom %3d : %s")% - name % i % "stereobond to non-stereogenic atom" << std::endl; + BOOST_LOG(rdWarningLog) + << boost::format("%10s atom %3d : %s") % name % i % + "stereobond to non-stereogenic atom" + << std::endl; result |= STEREO_BOND_AT_NON_STEREO_ATOM; } } @@ -152,12 +154,12 @@ int DubiousStereochemistry(RWMol &mol) { int FixDubious3DMolecule(RWMol &mol) { /* - * Checks if the structure has 3D coordinates and/or flat sp3-carbons with - * stereo-bonds and - * converts the designation to 2D, clearing away any Z-component of the - * coordinates. - * Real 3D structures without stereo designations go through untouched. - */ + * Checks if the structure has 3D coordinates and/or flat sp3-carbons with + * stereo-bonds and + * converts the designation to 2D, clearing away any Z-component of the + * coordinates. + * Real 3D structures without stereo designations go through untouched. + */ int result = 0; bool non_zero_z = false; @@ -179,7 +181,7 @@ int FixDubious3DMolecule(RWMol &mol) { if (RDKit::Bond::BEGINWEDGE == bond->getBondDir() || RDKit::Bond::BEGINDASH == bond->getBondDir() //??? || RDKit::Bond::EITHERDOUBLE == bond->getBondDir() - ) + ) nstereo++; } if (0 == nstereo) return 0; @@ -334,7 +336,7 @@ void RemoveDubiousStereochemistry(RWMol &mol) { for (unsigned j = 0; j < n_ligands; j++) { Bond &bj = *mol.getBondWithIdx(nbp.Bonds[j]); if (bj.getBeginAtomIdx() == i && - (RDKit::Bond::BEGINWEDGE == bj.getBondDir() // == UP + (RDKit::Bond::BEGINWEDGE == bj.getBondDir() // == UP || RDKit::Bond::BEGINDASH == bj.getBondDir())) // == DOWN)) bj.setBondDir(RDKit::Bond::NONE); } @@ -382,7 +384,7 @@ static int Atom3Parity(struct stereo_bond_t ligands[3]) { } if (reference == (-1)) { - return (UNDEFINED_PARITY); + return (UNDEFINED_PARITY); } if (reference == 0) { @@ -440,9 +442,9 @@ static int Atom3Parity(struct stereo_bond_t ligands[3]) { static int Atom4Parity(struct stereo_bond_t ligands[4]) { /* - * Computes the stereo parity defined by four ligands. - * Assumes central atom at 0/0/0. - */ + * Computes the stereo parity defined by four ligands. + * Assumes central atom at 0/0/0. + */ struct npoint_t tetrahedron[4], h; int nup, ndown, nopposite; double angle; @@ -509,7 +511,7 @@ static int Atom4Parity(struct stereo_bond_t ligands[4]) { for (unsigned i = 0; i < 4; i++) if ((ligands[i].direction == RDKit::Bond::BEGINWEDGE && ligands[(i + 1) % 4].direction == RDKit::Bond::BEGINWEDGE) // UP - || (ligands[i].direction == RDKit::Bond::BEGINDASH // DOWN + || (ligands[i].direction == RDKit::Bond::BEGINDASH // DOWN && ligands[(i + 1) % 4].direction == RDKit::Bond::BEGINDASH)) { // stereo_error = "Adjacent like stereobonds"; std::cerr << "adjacent like" << std::endl; @@ -545,10 +547,10 @@ static int Atom4Parity(struct stereo_bond_t ligands[4]) { int AtomParity(const ROMol &mol, unsigned iatom, const Neighbourhood &nbp) { /* - * Computes the stereo parity of atom number iatom in *mp relative - * to its numbering. The immediate neighbours are defined by *nbp - * to speed up processing. - */ + * Computes the stereo parity of atom number iatom in *mp relative + * to its numbering. The immediate neighbours are defined by *nbp + * to speed up processing. + */ struct stereo_bond_t stereo_ligands[4], h; bool multiple = false, allene = false, stereo = false; @@ -580,7 +582,7 @@ int AtomParity(const ROMol &mol, unsigned iatom, const Neighbourhood &nbp) { if (bi.getBeginAtomIdx() == iatom) { stereo_ligands[i].direction = bi.getBondDir(); if (stereo_ligands[i].direction == RDKit::Bond::BEGINWEDGE || // UP || - stereo_ligands[i].direction == RDKit::Bond::BEGINDASH) // DOWN + stereo_ligands[i].direction == RDKit::Bond::BEGINDASH) // DOWN stereo = true; } else stereo_ligands[i].direction = RDKit::Bond::NONE; @@ -616,9 +618,9 @@ int AtomParity(const ROMol &mol, unsigned iatom, const Neighbourhood &nbp) { bool CheckStereo(const ROMol &mol) { /* - * Checks if all potential stereocenters are either completely undefined - * or attributed with hashes and wedges according to MDL rules. - */ + * Checks if all potential stereocenters are either completely undefined + * or attributed with hashes and wedges according to MDL rules. + */ bool result = true; int parity; bool center_defined = false; @@ -636,25 +638,24 @@ bool CheckStereo(const ROMol &mol) { || 8 == element // "O" || 15 == element // "P" || 14 == element) // "Si" - ) { + ) { parity = AtomParity(mol, i, nbp); - + const Atom *atom = mol.getAtomWithIdx(i); if (atom->getChiralTag() == Atom::CHI_TETRAHEDRAL_CW || atom->getChiralTag() == Atom::CHI_TETRAHEDRAL_CCW) center_defined = true; - + if (parity == ILLEGAL_REPRESENTATION) { // stereo_error result = false; } else if (parity == EVEN_PARITY || parity == ODD_PARITY || parity == ALLENE_PARITY) { center_defined = true; - } - else { + } else { for (unsigned j = 0; j < nbp.Bonds.size(); j++) { const Bond &bond = *mol.getBondWithIdx(j); if (bond.getBeginAtomIdx() == i && - (RDKit::Bond::BEGINWEDGE == bond.getBondDir() // == UP + (RDKit::Bond::BEGINWEDGE == bond.getBondDir() // == UP || RDKit::Bond::BEGINDASH == bond.getBondDir())) { // == DOWN)) // stereobond to non-stereogenic atom std::cerr << "stereobond to nonstereogenic" << std::endl; @@ -668,7 +669,7 @@ bool CheckStereo(const ROMol &mol) { unsigned int chiralFlag = 0; mol.getPropIfPresent(RDKit::common_properties::_MolFileChiralFlag, chiralFlag); - + if (chiralFlag && !center_defined) { // no stereocenter defined std::cerr << "chiral flag, no stereocenter" << std::endl; result = false; @@ -678,16 +679,16 @@ bool CheckStereo(const ROMol &mol) { bool AtomClash(RWMol &mol, double clash_limit) { /* - * Checks if any two atoms in *mp come closer than 10% of the - * average bond length or if an atom is too close the line - * between two bonded atoms. - */ + * Checks if any two atoms in *mp come closer than 10% of the + * average bond length or if an atom is too close the line + * between two bonded atoms. + */ double bond_square_median, dist, min_dist; double rr, rb, bb, h; std::vector atomPoint( mol.getNumAtoms()); // X,Y,Z coordinates of each atom - bool twod=true; + bool twod = true; getMolAtomPoints(mol, atomPoint, twod); // compute median of square of bond length (quick/dirty) @@ -756,9 +757,10 @@ bool AtomClash(RWMol &mol, double clash_limit) { rb <= bb && // projection of r onto b does not exceed b (rr * bb - rb * rb) / (bb + EPS) < // distance from bond < limit clash_limit * clash_limit * bond_square_median) { - BOOST_LOG(rdWarningLog) << "atom " << j << " " << - 100*sqrt((rr*bb-rb*rb)/(bb*bond_square_median+EPS)) << - "% of average bond length " << a1 << "-" << a2 << std::endl; + BOOST_LOG(rdWarningLog) + << "atom " << j << " " + << 100 * sqrt((rr * bb - rb * rb) / (bb * bond_square_median + EPS)) + << "% of average bond length " << a1 << "-" << a2 << std::endl; std::cerr << "clash 2" << std::endl; return true; } @@ -769,10 +771,10 @@ bool AtomClash(RWMol &mol, double clash_limit) { //-------------------------------------------------------------------------- /* -* Sets the color field of the defined double bonds in *mp to CIS, -* TRANS, or NONE depending on the ligands with the lowest numbering[]. -* It returns the number of defined double bonds found. -*/ + * Sets the color field of the defined double bonds in *mp to CIS, + * TRANS, or NONE depending on the ligands with the lowest numbering[]. + * It returns the number of defined double bonds found. + */ int CisTransPerception(const ROMol &mol, const std::vector &points, const std::vector &numbering, @@ -792,9 +794,8 @@ int CisTransPerception(const ROMol &mol, // RDKit::Bond::ENDDOWNRIGHT // FIX: && mol.getBondWithIdx(i)->getBondDir() != // RDKit::Bond::ENDUPRIGHT - && - mol.getBondWithIdx(i)->getBondDir() != - RDKit::Bond::EITHERDOUBLE) { // != CIS_TRANS_EITHER + && mol.getBondWithIdx(i)->getBondDir() != + RDKit::Bond::EITHERDOUBLE) { // != CIS_TRANS_EITHER unsigned j1 = mol.getBondWithIdx(i)->getBeginAtomIdx(); unsigned j2 = mol.getBondWithIdx(i)->getEndAtomIdx(); if (6 != mol.getAtomWithIdx(j1)->getAtomicNum()) // C diff --git a/Code/GraphMol/StructChecker/StripSmallFragments.cpp b/Code/GraphMol/StructChecker/StripSmallFragments.cpp index e9654e1aa..7d097f747 100644 --- a/Code/GraphMol/StructChecker/StripSmallFragments.cpp +++ b/Code/GraphMol/StructChecker/StripSmallFragments.cpp @@ -70,9 +70,9 @@ bool StripSmallFragments(RWMol &mol, bool verbose) { mol.getPropIfPresent(common_properties::_Name, name); for (size_t i = 0; i < frags.size(); ++i) { if (i != maxFragIdx) { - BOOST_LOG(rdWarningLog) << name << " removed fragment i=" << i - << " with " << frags[i].get()->getNumAtoms() - << " atoms" << std::endl; + BOOST_LOG(rdWarningLog) + << name << " removed fragment i=" << i << " with " + << frags[i].get()->getNumAtoms() << " atoms" << std::endl; } } } diff --git a/Code/GraphMol/StructChecker/StructChecker.cpp b/Code/GraphMol/StructChecker/StructChecker.cpp index 560b5313d..118b86d68 100644 --- a/Code/GraphMol/StructChecker/StructChecker.cpp +++ b/Code/GraphMol/StructChecker/StructChecker.cpp @@ -30,7 +30,7 @@ unsigned StructChecker::checkMolStructure(RWMol &mol) const { if (mol.getNumAtoms() == 0) { return SIZE_CHECK_FAILED; } - + if (!mol.getRingInfo()->isInitialized()) mol.getRingInfo()->initialize(); /* it uses SDL text @@ -46,10 +46,12 @@ unsigned StructChecker::checkMolStructure(RWMol &mol) const { ;//new_data_list = ConvertSTEXTToData(mol, new_data_list); */ if (!Options.AugmentedAtomPairs.empty()) { - if (TransformAugmentedAtoms(mol, Options.AugmentedAtomPairs, Options.Verbose)) { + if (TransformAugmentedAtoms(mol, Options.AugmentedAtomPairs, + Options.Verbose)) { flags |= TRANSFORMED; - if (Options.Verbose) - BOOST_LOG(rdInfoLog) << MolToSmiles(mol) << "\n"; + if (Options.Verbose) { + BOOST_LOG(rdInfoLog) << MolToSmiles(mol) << "\n"; + } } } @@ -57,8 +59,9 @@ unsigned StructChecker::checkMolStructure(RWMol &mol) const { if (0 != (FixDubious3DMolecule(mol) & CONVERTED_TO_2D)) { stereo_result = 1; flags |= DUBIOUS_STEREO_REMOVED; - if (Options.Verbose) + if (Options.Verbose) { BOOST_LOG(rdInfoLog) << MolToSmiles(mol) << "\n"; + } } if (Options.RemoveMinorFragments) { @@ -66,8 +69,8 @@ unsigned StructChecker::checkMolStructure(RWMol &mol) const { if (StripSmallFragments(mol, Options.Verbose)) { flags |= FRAGMENTS_FOUND; if (Options.Verbose) - BOOST_LOG(rdInfoLog) << "Striped SmallFragments" - << MolToSmiles(mol) << "\n"; + BOOST_LOG(rdInfoLog) + << "Striped SmallFragments" << MolToSmiles(mol) << "\n"; } AddMWMF(mol, false); // Add mol mass data field "MW_POST" } @@ -83,8 +86,9 @@ unsigned StructChecker::checkMolStructure(RWMol &mol) const { if (!sct.applyTautomer(i)) break; flags |= TAUTOMER_TRANSFORMED; if (Options.Verbose) - BOOST_LOG(rdInfoLog) << "molecule: has been tautomerized with rule " - << i << ":\n" << MolToSmiles(mol) << "\n"; + BOOST_LOG(rdInfoLog) + << "molecule: has been tautomerized with rule " << i << ":\n" + << MolToSmiles(mol) << "\n"; // sprintf(msg_buffer,"%10s: has been tautomerized with // rule '%s'", mp->name, from_tautomer[i]->name); // AddMsgToList(msg_buffer); @@ -120,11 +124,12 @@ unsigned StructChecker::checkMolStructure(RWMol &mol) const { if (ch.rechargeMolecule(ndeprot, nrefine)) { flags |= RECHARGED; if (Options.Verbose) - BOOST_LOG(rdInfoLog) << "Recharged Molecule:" << MolToSmiles(mol) << "\n"; + BOOST_LOG(rdInfoLog) + << "Recharged Molecule:" << MolToSmiles(mol) << "\n"; } } // - const double clashLimit = Options.CollisionLimitPercent/100.0; + const double clashLimit = Options.CollisionLimitPercent / 100.0; if (Options.CheckCollisions && AtomClash(mol, clashLimit)) { flags |= ATOM_CLASH; if (Options.Verbose) diff --git a/Code/GraphMol/StructChecker/Tautomer.cpp b/Code/GraphMol/StructChecker/Tautomer.cpp index 6f07df65b..529dc9612 100644 --- a/Code/GraphMol/StructChecker/Tautomer.cpp +++ b/Code/GraphMol/StructChecker/Tautomer.cpp @@ -35,7 +35,6 @@ bool StructCheckTautomer::applyTautomer(unsigned it) { const unsigned nta = toTautomer.getNumAtoms(); MatchVectType match; // The format is (queryAtomIdx, molAtomIdx) - if (!SubstructMatch(Mol, *Options.FromTautomer[it], match)) // SSMatch(mp, from_tautomer, SINGLE_MATCH); return false; @@ -44,7 +43,8 @@ bool StructCheckTautomer::applyTautomer(unsigned it) { << " atoms\n"; // init size_t invalid_idx = 1 + Mol.getNumAtoms(); - std::vector atomIdxMap(Mol.getNumAtoms(), invalid_idx); // matched tau atom indices + std::vector atomIdxMap(Mol.getNumAtoms(), + invalid_idx); // matched tau atom indices for (MatchVectType::const_iterator mit = match.begin(); mit != match.end(); ++mit) { unsigned tai = mit->first; // From and To Tautomer Atom index diff --git a/Code/GraphMol/StructChecker/Utilites.cpp b/Code/GraphMol/StructChecker/Utilites.cpp index 12b0552ca..e2aa99e59 100644 --- a/Code/GraphMol/StructChecker/Utilites.cpp +++ b/Code/GraphMol/StructChecker/Utilites.cpp @@ -32,8 +32,7 @@ void SetupNeighbourhood(const ROMol &mol, } } -bool getMolAtomPoints(const ROMol &mol, - std::vector &atomPoint, +bool getMolAtomPoints(const ROMol &mol, std::vector &atomPoint, bool twod) { bool non_zero_z = false; atomPoint.resize(mol.getNumAtoms()); diff --git a/Code/GraphMol/StructChecker/Wrap/structchecker.cpp b/Code/GraphMol/StructChecker/Wrap/structchecker.cpp index a6d205454..b76173781 100644 --- a/Code/GraphMol/StructChecker/Wrap/structchecker.cpp +++ b/Code/GraphMol/StructChecker/Wrap/structchecker.cpp @@ -43,8 +43,8 @@ unsigned int checkMolStructureHelper(const StructChecker &checker, ROMol &m) { RWMol &fixer = static_cast(m); return checker.checkMolStructure(fixer); } -} -} +} // namespace StructureCheck +} // namespace RDKit struct struct_wrapper { static void wrap() { diff --git a/Code/GraphMol/Subgraphs/SubgraphUtils.cpp b/Code/GraphMol/Subgraphs/SubgraphUtils.cpp index 0e7bff443..9eb5b8c30 100644 --- a/Code/GraphMol/Subgraphs/SubgraphUtils.cpp +++ b/Code/GraphMol/Subgraphs/SubgraphUtils.cpp @@ -39,7 +39,7 @@ ROMol *pathToSubmol(const ROMol &mol, const PATH_TYPE &path, bool useQuery, if (useQuery) { // have to do this in two different blocks because of issues with variable // scopes. - for(auto bondidx : sorted_path) { + for (auto bondidx : sorted_path) { auto *bond = new QueryBond(*(mol.getBondWithIdx(bondidx))); int begIdx = bond->getBeginAtomIdx(); @@ -64,7 +64,7 @@ ROMol *pathToSubmol(const ROMol &mol, const PATH_TYPE &path, bool useQuery, subMol->addBond(bond, true); } } else { - for(auto bondidx : sorted_path) { + for (auto bondidx : sorted_path) { Bond *bond = mol.getBondWithIdx(bondidx)->copy(); int begIdx = bond->getBeginAtomIdx(); @@ -127,8 +127,8 @@ PATH_TYPE bondListFromAtomList(const ROMol &mol, const PATH_TYPE &atomIds) { return bids; } -using std::uint32_t; using std::int32_t; +using std::uint32_t; DiscrimTuple calcPathDiscriminators(const ROMol &mol, const PATH_TYPE &path, bool useBO, std::vector *extraInvars) { @@ -189,10 +189,10 @@ DiscrimTuple calcPathDiscriminators(const ROMol &mol, const PATH_TYPE &path, // if the iteration count can be even smaller (and if it // makes a difference in runtime) unsigned int nCycles = path.size() / 2 + 1; - gboost::hash > vectHasher; + gboost::hash> vectHasher; for (unsigned int cycle = 0; cycle < nCycles; ++cycle) { // let each atom feel it's neighbors: - std::vector > locInvars(nAtoms); + std::vector> locInvars(nAtoms); for (int pathIter : path) { const Bond *bond = mol.getBondWithIdx(pathIter); uint32_t v1 = invars[atomsUsed[bond->getBeginAtomIdx()]]; diff --git a/Code/GraphMol/Subgraphs/Subgraphs.cpp b/Code/GraphMol/Subgraphs/Subgraphs.cpp index ae72c8de0..9cc688037 100644 --- a/Code/GraphMol/Subgraphs/Subgraphs.cpp +++ b/Code/GraphMol/Subgraphs/Subgraphs.cpp @@ -43,7 +43,7 @@ void getNbrsList(const ROMol &mol, bool useHs, INT_INT_VECT_MAP &nbrs) { ROMol::OEDGE_ITER bIt1, end; boost::tie(bIt1, end) = mol.getAtomBonds(atom); while (bIt1 != end) { - const Bond* bond1 = mol[*bIt1]; + const Bond *bond1 = mol[*bIt1]; // if this bond connect to a hydrogen and we are not interested // in it ignore if (useHs || bond1->getOtherAtom(atom)->getAtomicNum() != 1) { @@ -54,7 +54,7 @@ void getNbrsList(const ROMol &mol, bool useHs, INT_INT_VECT_MAP &nbrs) { } ROMol::OEDGE_ITER bIt2 = mol.getAtomBonds(atom).first; while (bIt2 != end) { - const Bond* bond2 = mol[*bIt2]; + const Bond *bond2 = mol[*bIt2]; int bid2 = bond2->getIdx(); if (bid1 != bid2 && (useHs || bond2->getOtherAtom(atom)->getAtomicNum() != 1)) { @@ -81,7 +81,7 @@ void recurseWalk( // it gets altered through the processand we want // fresh start every time we buble back up to "FindAllSubGraphs" PATH_LIST &res // the final list of subgraphs - ) { +) { // end case for recursion if (spath.size() == targetLen) { res.push_back(spath); @@ -132,7 +132,7 @@ void recurseWalkRange( // it gets altered through the processand we want // fresh start every time we buble back up to "FindAllSubGraphs" INT_PATH_LIST_MAP &res // the final list of subgraphs - ) { +) { unsigned int nsize = spath.size(); if ((nsize >= lowerLen) && (nsize <= upperLen)) { // if (res.find(nsize) == res.end()) { @@ -279,7 +279,7 @@ pathFinderHelper(int *adjMat, unsigned int dim, unsigned int minLen, return res; } -} // end of Subgraphs namespace +} // namespace Subgraphs PATH_LIST findAllSubgraphsOfLengthN(const ROMol &mol, unsigned int targetLen, bool useHs, int rootedAtAtom) { @@ -288,10 +288,9 @@ PATH_LIST findAllSubgraphsOfLengthN(const ROMol &mol, unsigned int targetLen, - pathListType is defined as a container of "pathType", should it be a container of "pointers to pathtype" - - to make few things clear it might be useful to typedef a "subgraphListType" - even if it is exactly same as the "pathListType", just to not confuse - between - path vs. subgraph definitions + - to make few things clear it might be useful to typedef a + "subgraphListType" even if it is exactly same as the "pathListType", just to + not confuse between path vs. subgraph definitions - To make it consistent with the python version of this function in "subgraph.py" it return a "list of paths" instead of a "list of list of paths" (see @@ -507,7 +506,7 @@ findAllPathsOfLengthsMtoN(const ROMol &mol, unsigned int lowerLen, continue; } - std::vector > invars; + std::vector> invars; for (PATH_LIST::const_iterator vivI = atomPaths[i].begin(); vivI != atomPaths[i].end(); ++vivI) { @@ -547,14 +546,13 @@ PATH_TYPE findAtomEnvironmentOfRadiusN(const ROMol &mol, unsigned int radius, } PATH_TYPE res; - std::list > nbrStack; + std::list> nbrStack; ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = mol.getAtomBonds(mol.getAtomWithIdx(rootedAtAtom)); while (beg != end) { - const Bond* bond = mol[*beg]; - if (useHs || - mol.getAtomWithIdx(bond->getOtherAtomIdx(rootedAtAtom)) - ->getAtomicNum() != 1) { + const Bond *bond = mol[*beg]; + if (useHs || mol.getAtomWithIdx(bond->getOtherAtomIdx(rootedAtAtom)) + ->getAtomicNum() != 1) { nbrStack.emplace_back(rootedAtAtom, bond->getIdx()); } ++beg; @@ -566,7 +564,7 @@ PATH_TYPE findAtomEnvironmentOfRadiusN(const ROMol &mol, unsigned int radius, break; } - std::list > nextLayer; + std::list> nextLayer; while (!nbrStack.empty()) { int bondIdx, startAtom; boost::tie(startAtom, bondIdx) = nbrStack.front(); @@ -579,11 +577,10 @@ PATH_TYPE findAtomEnvironmentOfRadiusN(const ROMol &mol, unsigned int radius, int oAtom = mol.getBondWithIdx(bondIdx)->getOtherAtomIdx(startAtom); boost::tie(beg, end) = mol.getAtomBonds(mol.getAtomWithIdx(oAtom)); while (beg != end) { - const Bond* bond = mol[*beg]; + const Bond *bond = mol[*beg]; if (!bondsIn.test(bond->getIdx())) { - if (useHs || - mol.getAtomWithIdx(bond->getOtherAtomIdx(oAtom)) - ->getAtomicNum() != 1) { + if (useHs || mol.getAtomWithIdx(bond->getOtherAtomIdx(oAtom)) + ->getAtomicNum() != 1) { nextLayer.emplace_back(oAtom, bond->getIdx()); } } @@ -603,4 +600,4 @@ PATH_TYPE findAtomEnvironmentOfRadiusN(const ROMol &mol, unsigned int radius, return res; } -} // end of RDKit namespace +} // namespace RDKit diff --git a/Code/GraphMol/Substruct/cmd_match.cpp b/Code/GraphMol/Substruct/cmd_match.cpp index c3ce86b19..83ef872c5 100644 --- a/Code/GraphMol/Substruct/cmd_match.cpp +++ b/Code/GraphMol/Substruct/cmd_match.cpp @@ -60,8 +60,8 @@ int main(int argc, char *argv[]) { for (i = matches.begin(); i != matches.end(); i++) { MatchVectType::iterator j; for (j = i->begin(); j != i->end(); j++) { - BOOST_LOG(rdInfoLog) << "\t" << j->first << " -> " << j->second - << std::endl; + BOOST_LOG(rdInfoLog) + << "\t" << j->first << " -> " << j->second << std::endl; } BOOST_LOG(rdInfoLog) << std::endl; } diff --git a/Code/GraphMol/SubstructLibrary/SubstructLibrary.cpp b/Code/GraphMol/SubstructLibrary/SubstructLibrary.cpp index eec7d1d44..9af4c6692 100644 --- a/Code/GraphMol/SubstructLibrary/SubstructLibrary.cpp +++ b/Code/GraphMol/SubstructLibrary/SubstructLibrary.cpp @@ -101,13 +101,12 @@ unsigned int SubstructLibrary::addMol(const ROMol &m) { CHECK_INVARIANT(idx == fpidx, "#mols different than #fingerprints in SubstructLibrary"); } - if(keyholder.get() != nullptr) { + if (keyholder.get() != nullptr) { unsigned int keyidx = keyholder->addMol(m); CHECK_INVARIANT(idx == keyidx, "#mols different than #keys in SubstructLibrary"); - } - + return idx; } diff --git a/Code/GraphMol/SubstructLibrary/SubstructLibrary.h b/Code/GraphMol/SubstructLibrary/SubstructLibrary.h index 577721d33..de27094f2 100644 --- a/Code/GraphMol/SubstructLibrary/SubstructLibrary.h +++ b/Code/GraphMol/SubstructLibrary/SubstructLibrary.h @@ -332,22 +332,23 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT TautomerPatternHolder }; class RDKIT_SUBSTRUCTLIBRARY_EXPORT KeyHolderBase { -public: + public: virtual ~KeyHolderBase() {} //! Add a key to the database getting it from the molecule virtual unsigned int addMol(const ROMol &m) = 0; - + //! Add a key to the database, this needs to be in the same order //! as the molecule, no validation is done virtual unsigned int addKey(const std::string &) = 0; // !get the key at the requested index // implementations should throw IndexError on out of range - virtual const std::string & getKey(unsigned int) const = 0; + virtual const std::string &getKey(unsigned int) const = 0; // !get keys from a bunch of indices - virtual std::vector getKeys(const std::vector &indices) const = 0; + virtual std::vector getKeys( + const std::vector &indices) const = 0; //! Get the current keeyholder size virtual unsigned int size() const = 0; }; @@ -356,23 +357,24 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT KeyFromPropHolder : public KeyHolderBase { std::string propname; std::vector keys; const std::string empty_string = {}; - -public: - KeyFromPropHolder(const std::string &propname = "_Name") : propname(propname) { - } - std::string &getPropName() { return propname; } - const std::string &getPropName() const { return propname; } + public: + KeyFromPropHolder(const std::string &propname = "_Name") + : propname(propname) {} - std::vector &getKeys() { return keys; } - const std::vector &getKeys() const { return keys; } + std::string &getPropName() { return propname; } + const std::string &getPropName() const { return propname; } + + std::vector &getKeys() { return keys; } + const std::vector &getKeys() const { return keys; } unsigned int addMol(const ROMol &m) override { std::string key; if (m.getPropIfPresent(propname, key)) { keys.push_back(std::move(key)); } else { - // XXX is this a warning? it could be verbose. Should we push back the string repr of the + // XXX is this a warning? it could be verbose. Should we push back the + // string repr of the // numeric index? const static std::string prefix("LIBIDX-"); keys.emplace_back(prefix + boost::lexical_cast(keys.size())); @@ -385,21 +387,19 @@ public: return keys.size() - 1u; } - const std::string & getKey(unsigned int idx) const override { + const std::string &getKey(unsigned int idx) const override { if (idx >= keys.size()) throw IndexErrorException(idx); return keys[idx]; } - - std::vector getKeys(const std::vector &indices) const override{ + + std::vector getKeys( + const std::vector &indices) const override { std::vector res; std::transform(indices.begin(), indices.end(), std::back_inserter(res), - [=](unsigned idx){return keys.at(idx);}); + [=](unsigned idx) { return keys.at(idx); }); return res; } - unsigned int size() const override { - return keys.size(); - } - + unsigned int size() const override { return keys.size(); } }; //! Substructure Search a library of molecules @@ -484,10 +484,10 @@ public: to any property. \code - boost::shared_ptr molHolder = \ - boost::make_shared(); - boost::shared_ptr keyHolder = \ - boost::make_shared(); + boost::shared_ptr molHolder = \ + boost::make_shared(); + boost::shared_ptr keyHolder = \ + boost::make_shared(); SubstructLibrary lib(molHolder, keyHolder); ... @@ -501,7 +501,7 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT SubstructLibrary { boost::shared_ptr molholder; boost::shared_ptr fpholder; boost::shared_ptr keyholder; - + MolHolderBase *mols; // used for a small optimization FPHolderBase *fps{nullptr}; bool is_tautomerquery = false; @@ -509,7 +509,10 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT SubstructLibrary { public: SubstructLibrary() - : molholder(new MolHolder), fpholder(), keyholder(), mols(molholder.get()) {} + : molholder(new MolHolder), + fpholder(), + keyholder(), + mols(molholder.get()) {} SubstructLibrary(boost::shared_ptr molecules) : molholder(std::move(molecules)), @@ -532,12 +535,12 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT SubstructLibrary { } SubstructLibrary(boost::shared_ptr molecules, - boost::shared_ptr keys) - : molholder(std::move(molecules)), - fpholder(), - keyholder(std::move(keys)), - mols(molholder.get()), - fps(nullptr) { + boost::shared_ptr keys) + : molholder(std::move(molecules)), + fpholder(), + keyholder(std::move(keys)), + mols(molholder.get()), + fps(nullptr) { if (fpholder.get() && dynamic_cast(fpholder.get()) != nullptr) { is_tautomerquery = true; @@ -545,13 +548,13 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT SubstructLibrary { } SubstructLibrary(boost::shared_ptr molecules, - boost::shared_ptr fingerprints, - boost::shared_ptr keys) - : molholder(std::move(molecules)), - fpholder(std::move(fingerprints)), - keyholder(std::move(keys)), - mols(molholder.get()), - fps(fpholder.get()) { + boost::shared_ptr fingerprints, + boost::shared_ptr keys) + : molholder(std::move(molecules)), + fpholder(std::move(fingerprints)), + keyholder(std::move(keys)), + mols(molholder.get()), + fps(fpholder.get()) { if (fpholder.get() && dynamic_cast(fpholder.get()) != nullptr) { is_tautomerquery = true; @@ -592,7 +595,7 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT SubstructLibrary { const boost::shared_ptr &getKeyHolder() const { return keyholder; } - + const MolHolderBase &getMolecules() const { PRECONDITION(mols, "Molecule holder NULL in SubstructLibrary"); return *mols; @@ -615,7 +618,7 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT SubstructLibrary { //! 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(); } @@ -623,7 +626,7 @@ class RDKIT_SUBSTRUCTLIBRARY_EXPORT SubstructLibrary { //! 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(); } diff --git a/Code/GraphMol/SubstructLibrary/SubstructLibrarySerialization.h b/Code/GraphMol/SubstructLibrary/SubstructLibrarySerialization.h index 9931a2afc..01b8c2857 100644 --- a/Code/GraphMol/SubstructLibrary/SubstructLibrarySerialization.h +++ b/Code/GraphMol/SubstructLibrary/SubstructLibrarySerialization.h @@ -48,9 +48,7 @@ namespace boost { namespace serialization { template -void serialize(Archive &, RDKit::MolHolderBase &, - const unsigned int) { -} +void serialize(Archive &, RDKit::MolHolderBase &, const unsigned int) {} template void save(Archive &ar, const RDKit::MolHolder &molholder, @@ -166,9 +164,7 @@ void serialize(Archive &ar, RDKit::TautomerPatternHolder &pattern_holder, } template -void serialize(Archive &, RDKit::KeyHolderBase &, - const unsigned int) { -} +void serialize(Archive &, RDKit::KeyHolderBase &, const unsigned int) {} template void serialize(Archive &ar, RDKit::KeyFromPropHolder &key_holder, diff --git a/Code/GraphMol/SubstructLibrary/Wrap/SubstructLibraryWrap.cpp b/Code/GraphMol/SubstructLibrary/Wrap/SubstructLibraryWrap.cpp index 4c45cecc7..d13e2d3a4 100644 --- a/Code/GraphMol/SubstructLibrary/Wrap/SubstructLibraryWrap.cpp +++ b/Code/GraphMol/SubstructLibrary/Wrap/SubstructLibraryWrap.cpp @@ -105,9 +105,11 @@ const char *TautomerPatternHolderDoc = "2048) used for filtering of molecules.\n" "These fingerprints are designed to be used with TautomerQueries."; -const char *KeyHolderDoc = - "Holds keys to return external references to the molecules in the molholder.\n" - "By default use the _Name property but can be overridden to be any property"; +const char *KeyHolderDoc = + "Holds keys to return external references to the molecules in the " + "molholder.\n" + "By default use the _Name property but can be overridden to be any " + "property"; const char *SubstructLibraryDoc = "SubstructLibrary: This provides a simple API for substructure searching " @@ -201,7 +203,8 @@ const char *SubstructLibraryDoc = "compound names. By default the holder uses the '_Name' property but can\n" "be changed to any property.\n" ">>> library = " - "rdSubstructLibrary.SubstructLibrary(rdSubstructLibrary.MolHolder(), rdSubstructLibrary.KeyFromPropHolder())\n" + "rdSubstructLibrary.SubstructLibrary(rdSubstructLibrary.MolHolder(), " + "rdSubstructLibrary.KeyFromPropHolder())\n" ">>> m = Chem.MolFromSmiles('CCC')\n" ">>> m.SetProp('_Name', 'Z11234')\n" ">>> idx = library.AddMol(m)\n" @@ -523,17 +526,20 @@ struct substructlibrary_wrapper { python::return_value_policy(), "Return the key at the specified index") .def("GetKeys", &KeyHolderBase::getKeys, - "Returns the keys for the given indices as return by GetMatches \n\n" + "Returns the keys for the given indices as return by GetMatches " + "\n\n" " ARGUMENTS:\n" " - indices: The indices of the keys\n\n"); python::class_, - python::bases>("KeyFromPropHolder", KeyHolderDoc, python::init<>()) - .def(python::init()) - .def("GetPropName", (const std::string & (KeyFromPropHolder::*)() const) & - KeyFromPropHolder::getPropName, + python::bases>("KeyFromPropHolder", + KeyHolderDoc, python::init<>()) + .def(python::init()) + .def("GetPropName", + (const std::string &(KeyFromPropHolder::*)() const) & + KeyFromPropHolder::getPropName, python::return_value_policy(), - "Return the key for the given molecule index"); + "Return the key for the given molecule index"); python::class_, @@ -550,14 +556,14 @@ struct substructlibrary_wrapper { .def(python::init, boost::shared_ptr>()) .def(python::init, - boost::shared_ptr, - boost::shared_ptr>()) + boost::shared_ptr, + boost::shared_ptr>()) .def(python::init()) .def("GetMolHolder", &GetMolHolder) .def("GetFpHolder", &GetFpHolder) .def("GetKeyHolder", &GetKeyHolder) - + .def("AddMol", &SubstructLibrary::addMol, (python::arg("mol")), "Adds a molecule to the substruct library") diff --git a/Code/GraphMol/TautomerQuery/catch_tests.cpp b/Code/GraphMol/TautomerQuery/catch_tests.cpp index d09a5fcb6..5da7815d3 100644 --- a/Code/GraphMol/TautomerQuery/catch_tests.cpp +++ b/Code/GraphMol/TautomerQuery/catch_tests.cpp @@ -19,7 +19,8 @@ using namespace RDKit; TEST_CASE("TEMPLATE_ERROR") { - // for this guy the template needs to account for bonds modified when tautomers are sanitized + // for this guy the template needs to account for bonds modified when + // tautomers are sanitized auto mol = "Cc1nc2ccccc2[nH]1"_smiles; REQUIRE(mol); auto target = "CN1C2=C(C(=O)Nc3ccccc3)C(=O)CCN2c2ccccc21"_smiles; @@ -225,7 +226,7 @@ TEST_CASE("TEST_FINGERPRINT") { auto queryBond = new QueryBond(); queryBond->setQuery(makeBondOrderEqualsQuery(Bond::BondType::SINGLE)); queryBond->expandQuery(makeBondOrderEqualsQuery(Bond::BondType::AROMATIC), - Queries::COMPOSITE_OR); + Queries::COMPOSITE_OR); molWithoutTautomerBonds.replaceBond(modifiedBondIdx, queryBond, true); delete queryBond; } @@ -312,15 +313,18 @@ TEST_CASE("TEST_NOT_TAUTOMER") { TEST_CASE("github #3821 TAUTOMERQUERY_COPY_CONSTRUCTOR") { auto mol = "c1ccccc1"_smiles; auto tautomerQuery = - std::unique_ptr(TautomerQuery::fromMol(*mol)); - auto tautomerQueryCopyConstructed = std::unique_ptr(new TautomerQuery(*tautomerQuery)); - CHECK(&(tautomerQuery->getTemplateMolecule()) != &tautomerQueryCopyConstructed->getTemplateMolecule()); + std::unique_ptr(TautomerQuery::fromMol(*mol)); + auto tautomerQueryCopyConstructed = + std::unique_ptr(new TautomerQuery(*tautomerQuery)); + CHECK(&(tautomerQuery->getTemplateMolecule()) != + &tautomerQueryCopyConstructed->getTemplateMolecule()); } TEST_CASE("github #3821 check TAUTOMERQUERY_OPERATOR= does a deep copy") { auto mol = "c1ccccc1"_smiles; auto tautomerQuery = - std::unique_ptr(TautomerQuery::fromMol(*mol)); + std::unique_ptr(TautomerQuery::fromMol(*mol)); auto tautomerQueryAssigned = *tautomerQuery; - CHECK(&(tautomerQuery->getTemplateMolecule()) != &tautomerQueryAssigned.getTemplateMolecule()); + CHECK(&(tautomerQuery->getTemplateMolecule()) != + &tautomerQueryAssigned.getTemplateMolecule()); } diff --git a/Code/GraphMol/Trajectory/Trajectory.cpp b/Code/GraphMol/Trajectory/Trajectory.cpp index daebad882..1054348d1 100644 --- a/Code/GraphMol/Trajectory/Trajectory.cpp +++ b/Code/GraphMol/Trajectory/Trajectory.cpp @@ -224,4 +224,4 @@ unsigned int readGromosTrajectory(const std::string &fName, Trajectory &traj) { } return nSnapshots; } -} +} // namespace RDKit diff --git a/Code/GraphMol/Wrap/Conformer.cpp b/Code/GraphMol/Wrap/Conformer.cpp index 59e6345d8..16154f552 100644 --- a/Code/GraphMol/Wrap/Conformer.cpp +++ b/Code/GraphMol/Wrap/Conformer.cpp @@ -89,13 +89,13 @@ struct conformer_wrapper { .def("GetPositions", GetPos, "Get positions of all the atoms\n") .def("SetAtomPosition", SetAtomPos, "Set the position of the specified atom\n") - .def("SetAtomPosition", (void (Conformer::*)(unsigned int, const RDGeom::Point3D&)) & - Conformer::setAtomPos, + .def("SetAtomPosition", + (void (Conformer::*)(unsigned int, const RDGeom::Point3D &)) & + Conformer::setAtomPos, "Set the position of the specified atom\n") .def("Set3D", &Conformer::set3D, "Set the 3D flag of the conformer\n") - .def("Is3D", &Conformer::is3D, - "returns the 3D flag of the conformer\n") + .def("Is3D", &Conformer::is3D, "returns the 3D flag of the conformer\n") // properties .def("SetProp", MolSetProp, @@ -230,6 +230,6 @@ struct conformer_wrapper { " RETURNS: a dictionary\n"); }; }; -} +} // namespace RDKit void wrap_conformer() { RDKit::conformer_wrapper::wrap(); } diff --git a/Code/GraphMol/Wrap/MonomerInfo.cpp b/Code/GraphMol/Wrap/MonomerInfo.cpp index 5fa808848..b7b948000 100644 --- a/Code/GraphMol/Wrap/MonomerInfo.cpp +++ b/Code/GraphMol/Wrap/MonomerInfo.cpp @@ -25,9 +25,9 @@ struct monomerinfo_wrapper { "The class to store monomer information attached to Atoms\n"; python::class_("AtomMonomerInfo", classDoc.c_str(), python::init<>()) - .def(python::init( - (python::arg("type"), python::arg("name") = ""))) + .def( + python::init( + (python::arg("type"), python::arg("name") = ""))) .def("GetName", &AtomMonomerInfo::getName, python::return_value_policy()) .def("GetMonomerType", &AtomMonomerInfo::getMonomerType) @@ -40,7 +40,7 @@ struct monomerinfo_wrapper { .value("OTHER", AtomMonomerInfo::OTHER); classDoc = "The class to store PDB residue information attached to Atoms\n"; - python::class_ >( + python::class_>( "AtomPDBResidueInfo", classDoc.c_str(), python::init<>()) .def(python::init()) - .def("__next__", - (ROMol * (*)(ResonanceMolSupplier *)) & - MolSupplNext, + .def("__next__", (ROMol * (*)(ResonanceMolSupplier *)) & MolSupplNext, "Returns the next resonance structure in the supplier. Raises " "_StopIteration_ on end.\n", python::return_value_policy()) diff --git a/Code/GraphMol/Wrap/RingInfo.cpp b/Code/GraphMol/Wrap/RingInfo.cpp index d3b4ad784..0e7d68516 100644 --- a/Code/GraphMol/Wrap/RingInfo.cpp +++ b/Code/GraphMol/Wrap/RingInfo.cpp @@ -51,9 +51,10 @@ python::object bondRingFamilies(const RingInfo *self) { } #endif -void addRing(RingInfo *self,python::object atomRing, python::object bondRing){ +void addRing(RingInfo *self, python::object atomRing, python::object bondRing) { unsigned int nAts = python::extract(atomRing.attr("__len__")()); - unsigned int nBnds = python::extract(bondRing.attr("__len__")()); + unsigned int nBnds = + python::extract(bondRing.attr("__len__")()); if (nAts != nBnds) { throw_value_error("list sizes must match"); } @@ -66,9 +67,9 @@ void addRing(RingInfo *self,python::object atomRing, python::object bondRing){ aring[i] = python::extract(atomRing[i])(); bring[i] = python::extract(bondRing[i])(); } - self->addRing(aring,bring); -} + self->addRing(aring, bring); } +} // namespace namespace RDKit { std::string classDoc = "contains information about a molecule's rings\n"; @@ -90,11 +91,14 @@ struct ringinfo_wrapper { .def("NumRelevantCycles", &RingInfo::numRelevantCycles) .def("AtomRingFamilies", atomRingFamilies) .def("BondRingFamilies", bondRingFamilies) - .def("AreRingFamiliesInitialized", &RingInfo::areRingFamiliesInitialized) + .def("AreRingFamiliesInitialized", + &RingInfo::areRingFamiliesInitialized) #endif - .def("AddRing", addRing, (python::arg("self"),python::arg("atomIds"),python::arg("bondIds")), - "Adds a ring to the set. Be very careful with this operation."); + .def("AddRing", addRing, + (python::arg("self"), python::arg("atomIds"), + python::arg("bondIds")), + "Adds a ring to the set. Be very careful with this operation."); }; }; -} // end of namespace +} // namespace RDKit void wrap_ringinfo() { RDKit::ringinfo_wrapper::wrap(); } diff --git a/Code/GraphMol/Wrap/SubstanceGroup.cpp b/Code/GraphMol/Wrap/SubstanceGroup.cpp index 71d6a045d..d19627256 100644 --- a/Code/GraphMol/Wrap/SubstanceGroup.cpp +++ b/Code/GraphMol/Wrap/SubstanceGroup.cpp @@ -258,7 +258,9 @@ struct sgroup_wrap { "Returns a dictionary of the properties set on the " "SubstanceGroup.\n" " n.b. some properties cannot be converted to python types.\n") - .def("ClearProp", (void (RDProps::*)(const std::string &) const) &SubstanceGroup::clearProp, + .def("ClearProp", + (void (RDProps::*)(const std::string &) const) & + SubstanceGroup::clearProp, "Removes a particular property (does nothing if not set).\n\n"); python::def("GetMolSubstanceGroups", &getMolSubstanceGroups, diff --git a/Code/GraphMol/Wrap/Table.cpp b/Code/GraphMol/Wrap/Table.cpp index 84fb61585..90ac7943c 100644 --- a/Code/GraphMol/Wrap/Table.cpp +++ b/Code/GraphMol/Wrap/Table.cpp @@ -71,7 +71,7 @@ struct table_wrapper { .def("GetAtomicNumber", (int (PeriodicTable::*)(const std::string &) const) & PeriodicTable::getAtomicNumber) - .def("GetElementSymbol", (std::string (PeriodicTable::*)(UINT) const) & + .def("GetElementSymbol", (std::string(PeriodicTable::*)(UINT) const) & PeriodicTable::getElementSymbol) .def("GetRvdw", (double (PeriodicTable::*)(UINT) const) & PeriodicTable::getRvdw) @@ -101,27 +101,29 @@ struct table_wrapper { (int (PeriodicTable::*)(const std::string &) const) & PeriodicTable::getNouterElecs) .def("GetMostCommonIsotope", (int (PeriodicTable::*)(UINT) const) & - PeriodicTable::getMostCommonIsotope) + PeriodicTable::getMostCommonIsotope) .def("GetMostCommonIsotope", (int (PeriodicTable::*)(const std::string &) const) & - PeriodicTable::getMostCommonIsotope) - .def("GetMostCommonIsotopeMass", (double (PeriodicTable::*)(UINT) const) & - PeriodicTable::getMostCommonIsotopeMass) + PeriodicTable::getMostCommonIsotope) + .def("GetMostCommonIsotopeMass", + (double (PeriodicTable::*)(UINT) const) & + PeriodicTable::getMostCommonIsotopeMass) .def("GetMostCommonIsotopeMass", (double (PeriodicTable::*)(const std::string &) const) & - PeriodicTable::getMostCommonIsotopeMass) - .def("GetRb0", (double (PeriodicTable::*)(UINT) const) & - PeriodicTable::getRb0) + PeriodicTable::getMostCommonIsotopeMass) .def("GetRb0", - (double (PeriodicTable::*)(const std::string &) const) & - PeriodicTable::getRb0) - .def("GetAbundanceForIsotope", (double (PeriodicTable::*)(UINT, UINT) const) & - PeriodicTable::getAbundanceForIsotope) + (double (PeriodicTable::*)(UINT) const) & PeriodicTable::getRb0) + .def("GetRb0", (double (PeriodicTable::*)(const std::string &) const) & + PeriodicTable::getRb0) + .def("GetAbundanceForIsotope", + (double (PeriodicTable::*)(UINT, UINT) const) & + PeriodicTable::getAbundanceForIsotope) .def("GetAbundanceForIsotope", (double (PeriodicTable::*)(const std::string &, UINT) const) & PeriodicTable::getAbundanceForIsotope) - .def("GetMassForIsotope", (double (PeriodicTable::*)(UINT, UINT) const) & - PeriodicTable::getMassForIsotope) + .def("GetMassForIsotope", + (double (PeriodicTable::*)(UINT, UINT) const) & + PeriodicTable::getMassForIsotope) .def("GetMassForIsotope", (double (PeriodicTable::*)(const std::string &, UINT) const) & PeriodicTable::getMassForIsotope); @@ -132,6 +134,5 @@ struct table_wrapper { python::return_value_policy()); }; }; -} // end of namespace +} // namespace RDKit void wrap_table() { RDKit::table_wrapper::wrap(); } - diff --git a/Code/GraphMol/Wrap/Trajectory.cpp b/Code/GraphMol/Wrap/Trajectory.cpp index ad5c89d30..98312df68 100644 --- a/Code/GraphMol/Wrap/Trajectory.cpp +++ b/Code/GraphMol/Wrap/Trajectory.cpp @@ -38,7 +38,9 @@ Snapshot *copyConstructSnapshot_wrap(Snapshot *other) { return new Snapshot(*other); } -Trajectory *constructTrajectory_wrap(unsigned int dimension, unsigned int numPoints, python::list snapshotList) { +Trajectory *constructTrajectory_wrap(unsigned int dimension, + unsigned int numPoints, + python::list snapshotList) { unsigned int l = python::len(snapshotList); auto *traj = new Trajectory(dimension, numPoints); for (unsigned int i = 0; i < l; ++i) { @@ -55,51 +57,59 @@ Trajectory *copyConstructTrajectory_wrap(Trajectory *other) { struct Trajectory_wrapper { static void wrap() { python::class_( - "Trajectory", "A class which allows storing Snapshots from a trajectory", python::no_init) + "Trajectory", + "A class which allows storing Snapshots from a trajectory", + python::no_init) .def("__init__", python::make_constructor( &constructTrajectory_wrap, python::default_call_policies(), (python::arg("dimension"), python::arg("numPoints"), python::arg("snapshotList") = python::list())), "Constructor;\n" - "dimension: dimensionality of this Trajectory's coordinate tuples;\n" - "numPoints: number of coordinate tuples associated to each Snapshot;\n" - "snapshotList: list of Snapshot objects used to initialize the Trajectory (optional; defaults to []).\n") + "dimension: dimensionality of this Trajectory's coordinate " + "tuples;\n" + "numPoints: number of coordinate tuples associated to each " + "Snapshot;\n" + "snapshotList: list of Snapshot objects used to initialize the " + "Trajectory (optional; defaults to []).\n") .def("__init__", - python::make_constructor( - ©ConstructTrajectory_wrap, python::default_call_policies(), - python::arg("other")), + python::make_constructor(©ConstructTrajectory_wrap, + python::default_call_policies(), + python::arg("other")), "Copy constructor") .def("Dimension", &Trajectory::dimension, (python::arg("self")), - "returns the dimensionality of this Trajectory's coordinate tuples") + "returns the dimensionality of this Trajectory's coordinate " + "tuples") .def("NumPoints", &Trajectory::numPoints, (python::arg("self")), - "returns the number of coordinate tuples associated to each Snapshot") + "returns the number of coordinate tuples associated to each " + "Snapshot") .def("__len__", &Trajectory::size) .def("AddSnapshot", &Trajectory::addSnapshot, (python::arg("self"), python::arg("s")), - "appends Snapshot s to this Trajectory; returns the zero-based index " - "position of the added snapshot\n") + "appends Snapshot s to this Trajectory; returns the zero-based " + "index position of the added snapshot\n") .def("GetSnapshot", getSnapshot_wrap, (python::arg("self"), python::arg("snapshotNum")), - "returns the Snapshot snapshotNum, where the latter is the zero-based " - "index of the retrieved Snapshot\n", + "returns the Snapshot snapshotNum, where the latter is the " + "zero-based index of the retrieved Snapshot\n", python::return_value_policy()) - .def("InsertSnapshot", &Trajectory::insertSnapshot, - (python::arg("self"), python::arg("snapshotNum"), python::arg("s")), - "inserts Snapshot s into the Trajectory at the position snapshotNum, " - "where the latter is the zero-based index of the Trajectory's Snapshot " - "before which the Snapshot s will be inserted; returns the zero-based " - "index position of the inserted snapshot\n") + .def( + "InsertSnapshot", &Trajectory::insertSnapshot, + (python::arg("self"), python::arg("snapshotNum"), python::arg("s")), + "inserts Snapshot s into the Trajectory at the position " + "snapshotNum, where the latter is the zero-based index of the " + "Trajectory's Snapshot before which the Snapshot s will be " + "inserted; returns the zero-based index position of the inserted " + "snapshot\n") .def("RemoveSnapshot", &Trajectory::removeSnapshot, (python::arg("self"), python::arg("snapshotNum")), "removes Snapshot snapshotNum from the Trajectory, where " "snapshotNum is the zero-based index of Snapshot to be removed\n") - .def("Clear", &Trajectory::clear, - (python::arg("self")), + .def("Clear", &Trajectory::clear, (python::arg("self")), "removes all Snapshots from the Trajectory\n") .def("AddConformersToMol", &Trajectory::addConformersToMol, - (python::arg("self"), python::arg("mol"), - python::arg("from") = -1, python::arg("to") = -1), + (python::arg("self"), python::arg("mol"), python::arg("from") = -1, + python::arg("to") = -1), "adds conformations from the Trajectory to mol\n" "from is the first Snapshot that will be added as a Conformer; " "defaults to -1 (first available)\n" @@ -107,40 +117,47 @@ struct Trajectory_wrapper { "defaults to -1 (all)\n"); python::class_( - "Snapshot", "A class which allows storing coordinates from a trajectory", python::no_init) + "Snapshot", + "A class which allows storing coordinates from a trajectory", + python::no_init) .def("__init__", python::make_constructor( &constructSnapshot_wrap, python::default_call_policies(), (python::arg("coordList"), python::arg("energy") = 0.0)), "Constructor;\n" - "coordList: list of floats containing the coordinates for this Snapshot;\n" + "coordList: list of floats containing the coordinates for this " + "Snapshot;\n" "energy: the energy for this Snapshot.\n") .def("__init__", - python::make_constructor( - ©ConstructSnapshot_wrap, python::default_call_policies(), - python::arg("other")), + python::make_constructor(©ConstructSnapshot_wrap, + python::default_call_policies(), + python::arg("other")), "Copy constructor") - .def("GetPoint2D", &Snapshot::getPoint2D, (python::arg("self"), python::arg("pointNum")), + .def("GetPoint2D", &Snapshot::getPoint2D, + (python::arg("self"), python::arg("pointNum")), "return the coordinates at pointNum as a Point2D object; " "requires the Trajectory dimension to be == 2") - .def("GetPoint3D", &Snapshot::getPoint3D, (python::arg("self"), python::arg("pointNum")), + .def("GetPoint3D", &Snapshot::getPoint3D, + (python::arg("self"), python::arg("pointNum")), "return the coordinates at pointNum as a Point3D object; " "requires the Trajectory dimension to be >= 2") .def("GetEnergy", &Snapshot::getEnergy, (python::arg("self")), "returns the energy for this Snapshot") - .def("SetEnergy", &Snapshot::setEnergy, (python::arg("self"), python::arg("energy")), + .def("SetEnergy", &Snapshot::setEnergy, + (python::arg("self"), python::arg("energy")), "sets the energy for this Snapshot"); python::def("ReadAmberTrajectory", &readAmberTrajectory, - (python::arg("fName"), python::arg("traj")), - "reads coordinates from an AMBER trajectory file into the Trajectory object; " - "returns the number of Snapshot objects read in\n"); + (python::arg("fName"), python::arg("traj")), + "reads coordinates from an AMBER trajectory file into the " + "Trajectory object; " + "returns the number of Snapshot objects read in\n"); python::def("ReadGromosTrajectory", &readGromosTrajectory, - (python::arg("fName"), python::arg("traj")), - "reads coordinates from a GROMOS trajectory file into the Trajectory object; " - "returns the number of Snapshot objects read in\n"); + (python::arg("fName"), python::arg("traj")), + "reads coordinates from a GROMOS trajectory file into the " + "Trajectory object; " + "returns the number of Snapshot objects read in\n"); }; - }; -} +} // namespace RDKit void wrap_trajectory() { RDKit::Trajectory_wrapper::wrap(); } diff --git a/Code/GraphMol/Wrap/props.hpp b/Code/GraphMol/Wrap/props.hpp index 5ed91451a..eb8ac5f74 100644 --- a/Code/GraphMol/Wrap/props.hpp +++ b/Code/GraphMol/Wrap/props.hpp @@ -95,7 +95,6 @@ boost::python::dict GetPropsAsDict(const T &obj, bool includePrivate, return dict; } - template T GetProp(RDOb *ob, const char *key) { T res; @@ -105,7 +104,7 @@ T GetProp(RDOb *ob, const char *key) { throw python::error_already_set(); } return res; - } catch (const std::exception&e ) { + } catch (const std::exception &e) { throw ValueErrorException(std::string("key `") + key + "` exists but does not result in " + GetTypeName() + " reason: " + e.what()); diff --git a/Code/GraphMol/Wrap/rdmolfiles.cpp b/Code/GraphMol/Wrap/rdmolfiles.cpp index 7c985f345..7c8b69b0f 100644 --- a/Code/GraphMol/Wrap/rdmolfiles.cpp +++ b/Code/GraphMol/Wrap/rdmolfiles.cpp @@ -1318,13 +1318,13 @@ BOOST_PYTHON_MODULE(rdmolfiles) { .value("CX_POLYMER", RDKit::SmilesWrite::CXSmilesFields::CX_POLYMER) .value("CX_ALL", RDKit::SmilesWrite::CXSmilesFields::CX_ALL); - python::def("MolToCXSmiles", - (std::string(*)(const ROMol &, const SmilesWriteParams &, - std::uint32_t))RDKit::MolToCXSmiles, - (python::arg("mol"), python::arg("params"), - python::arg("flags") = - RDKit::SmilesWrite::CXSmilesFields::CX_ALL), - "Returns the CXSMILES string for a molecule"); + python::def( + "MolToCXSmiles", + (std::string(*)(const ROMol &, const SmilesWriteParams &, + std::uint32_t))RDKit::MolToCXSmiles, + (python::arg("mol"), python::arg("params"), + python::arg("flags") = RDKit::SmilesWrite::CXSmilesFields::CX_ALL), + "Returns the CXSMILES string for a molecule"); docString = "Returns the CXSMILES string for a molecule\n\ diff --git a/Code/GraphMol/hanoitest.cpp b/Code/GraphMol/hanoitest.cpp index 72683e7a9..19e2e1f30 100644 --- a/Code/GraphMol/hanoitest.cpp +++ b/Code/GraphMol/hanoitest.cpp @@ -865,7 +865,7 @@ void test6() { namespace { ROMol *_renumber(const ROMol *m, std::vector &nVect, - const std::string& /*inSmiles*/) { + const std::string & /*inSmiles*/) { ROMol *nm = MolOps::renumberAtoms(*m, nVect); TEST_ASSERT(nm); TEST_ASSERT(nm->getNumAtoms() == m->getNumAtoms()); diff --git a/Code/GraphMol/memtest1.cpp b/Code/GraphMol/memtest1.cpp index 0b281d82e..1f81db30a 100644 --- a/Code/GraphMol/memtest1.cpp +++ b/Code/GraphMol/memtest1.cpp @@ -80,7 +80,8 @@ void testMol() { void testMols() { std::string smis[] = { - "CN1CCC[C@H]1c2cccnc2", "CC1(C)[C@@H](N2[C@@H](CC2=O)S1(=O)=O)C(=O)O", + "CN1CCC[C@H]1c2cccnc2", + "CC1(C)[C@@H](N2[C@@H](CC2=O)S1(=O)=O)C(=O)O", "C[C@]1(Cn2ccnn2)[C@@H](N3[C@@H](CC3=O)S1(=O)=O)C(=O)O", "CCN(CC)C(=O)[C@@H]1CN(C)[C@H]2Cc3c[nH]c4cccc(C2=C1)c34", "CCCN(CCC)[C@H]1CCc2c(O)cccc2C1", @@ -89,7 +90,8 @@ void testMols() { "1OC(=O)C67CCC(C)(C(=O)O6)C7(C)C", "CCC(C)(C)C(=O)C(=O)N1CCC[C@H]1C(=O)OCCCc2cccnc2", "CN1N=C(S/C/1=N/C(=O)C)S(=O)(=O)N", - "COc1ccc(cc1)[C@@H]2Sc3ccccc3N(CCN(C)C)C(=O)[C@@H]2OC(=O)C", "EOS"}; + "COc1ccc(cc1)[C@@H]2Sc3ccccc3N(CCN(C)C)C(=O)[C@@H]2OC(=O)C", + "EOS"}; for (int i = 0; smis[i] != "EOS"; ++i) { SmilesToMol(smis[i], 0, false); } diff --git a/Code/GraphMol/querytest.cpp b/Code/GraphMol/querytest.cpp index 1de6a3854..036c0bbfd 100644 --- a/Code/GraphMol/querytest.cpp +++ b/Code/GraphMol/querytest.cpp @@ -508,13 +508,13 @@ void testIssue2892580() { int massVal; massVal = queryAtomMass(a); - TEST_ASSERT(massVal == static_cast(std::round( - 12.011 * massIntegerConversionFactor))); + TEST_ASSERT(massVal == static_cast( + std::round(12.011 * massIntegerConversionFactor))); a->setIsotope(13); massVal = queryAtomMass(a); - TEST_ASSERT(massVal == static_cast(std::round( - 13.003 * massIntegerConversionFactor))); + TEST_ASSERT(massVal == static_cast( + std::round(13.003 * massIntegerConversionFactor))); delete a; BOOST_LOG(rdErrorLog) << "Done!" << std::endl; diff --git a/Code/GraphMol/resMolSupplierTest.cpp b/Code/GraphMol/resMolSupplierTest.cpp index 4e07ce853..d294001d6 100644 --- a/Code/GraphMol/resMolSupplierTest.cpp +++ b/Code/GraphMol/resMolSupplierTest.cpp @@ -960,7 +960,6 @@ void testGitHub3349() { delete mol; } - int main() { RDLog::InitLogs(); #if 1 diff --git a/Code/GraphMol/testChirality.cpp b/Code/GraphMol/testChirality.cpp index a5e0b3b6e..d94c3efce 100644 --- a/Code/GraphMol/testChirality.cpp +++ b/Code/GraphMol/testChirality.cpp @@ -2803,7 +2803,7 @@ class TestAssignChiralTypesFromMolParity { private: struct BondDef { BondDef(unsigned int bi, unsigned int ei, Bond::BondType t) - : beginIdx(bi), endIdx(ei), type(t){}; + : beginIdx(bi), endIdx(ei), type(t) {} unsigned int beginIdx; unsigned int endIdx; Bond::BondType type; diff --git a/Code/GraphMol/testPicklerGlobalSettings.cpp b/Code/GraphMol/testPicklerGlobalSettings.cpp index 81d8f212f..47343895c 100644 --- a/Code/GraphMol/testPicklerGlobalSettings.cpp +++ b/Code/GraphMol/testPicklerGlobalSettings.cpp @@ -52,17 +52,15 @@ using namespace RDKit; - void testGlobalPickleProps() { BOOST_LOG(rdInfoLog) << "-----------------------\n"; - BOOST_LOG(rdInfoLog) << "Testing pickling of properties" - << std::endl; + BOOST_LOG(rdInfoLog) << "Testing pickling of properties" << std::endl; std::vector v; v.push_back(1234.); v.push_back(444.); v.push_back(1123.); - + ROMol *m = SmilesToMol("CC"); m->setProp("double", 1.0); m->setProp("int", 100); @@ -77,7 +75,7 @@ void testGlobalPickleProps() { a->setProp("boolfalse", false); a->setProp("dvec", v); a->setProp("_private", true); - + Bond *b = m->getBondWithIdx(0); b->setProp("double", 1.0); b->setProp("int", 100); @@ -103,14 +101,14 @@ void testGlobalPickleProps() { TEST_ASSERT(a->getProp("bool") == true); TEST_ASSERT(a->getProp("boolfalse") == false); TEST_ASSERT(a->getProp("_private") == true); - + b = m2->getBondWithIdx(0); TEST_ASSERT(b->getProp("double") == 1.0); TEST_ASSERT(b->getProp("int") == 100); TEST_ASSERT(b->getProp("bool") == true); TEST_ASSERT(b->getProp("boolfalse") == false); TEST_ASSERT(b->getProp("_private") == true); - //TEST_ASSERT(b->getProp >("dvec") == v); + // TEST_ASSERT(b->getProp >("dvec") == v); delete m2; } @@ -193,7 +191,7 @@ void testGlobalPickleProps() { TEST_ASSERT(!b->hasProp("_private")); delete m2; } - + { MolPickler::setDefaultPickleProperties(PicklerOps::BondProps); MolPickler::pickleMol(*m, pkl); @@ -238,7 +236,7 @@ void testGlobalPickleProps() { TEST_ASSERT(!a->hasProp("bool")); TEST_ASSERT(!a->hasProp("boolfalse")); TEST_ASSERT(!a->hasProp("_private")); - + b = m2->getBondWithIdx(0); TEST_ASSERT(b->getProp("double") == 1.0); TEST_ASSERT(b->getProp("int") == 100); @@ -247,14 +245,13 @@ void testGlobalPickleProps() { TEST_ASSERT(b->getProp("_private") == true); delete m2; } - + delete m; - + BOOST_LOG(rdErrorLog) << "\tdone" << std::endl; } - -int main(int, char**) { +int main(int, char **) { RDLog::InitLogs(); testGlobalPickleProps(); diff --git a/Code/JavaWrappers/GenericRDKitException.h b/Code/JavaWrappers/GenericRDKitException.h index 79e99b7af..ef0cf4c01 100644 --- a/Code/JavaWrappers/GenericRDKitException.h +++ b/Code/JavaWrappers/GenericRDKitException.h @@ -16,8 +16,7 @@ // RDKIT_JAVAWRAPPERS_EXPORT does not get defined in RDGeneral/export.h, // and we only use it here for non-windows builds, so just define it based // on RDKIT_RDGENERAL_EXPORT -#if defined(RDKIT_DYN_LINK) && defined(WIN32) && \ - defined(BOOST_HAS_DECLSPEC) +#if defined(RDKIT_DYN_LINK) && defined(WIN32) && defined(BOOST_HAS_DECLSPEC) #define RDKIT_JAVAWRAPPERS_EXPORT #else #define RDKIT_JAVAWRAPPERS_EXPORT RDKIT_RDGENERAL_EXPORT diff --git a/Code/ML/InfoTheory/InfoBitRanker.cpp b/Code/ML/InfoTheory/InfoBitRanker.cpp index 4ce35c031..d538d8e82 100644 --- a/Code/ML/InfoTheory/InfoBitRanker.cpp +++ b/Code/ML/InfoTheory/InfoBitRanker.cpp @@ -285,4 +285,4 @@ void InfoBitRanker::writeTopBitsToFile(const std::string &fileName) const { auto &outStream = static_cast(tmpStream); this->writeTopBitsToStream(&outStream); } -} +} // namespace RDInfoTheory diff --git a/Code/ML/InfoTheory/Wrap/rdInfoTheory.cpp b/Code/ML/InfoTheory/Wrap/rdInfoTheory.cpp index e23b32d4e..c345c5f77 100644 --- a/Code/ML/InfoTheory/Wrap/rdInfoTheory.cpp +++ b/Code/ML/InfoTheory/Wrap/rdInfoTheory.cpp @@ -107,7 +107,7 @@ double chiSquare(python::object resArr) { Py_DECREF(copy); return res; } -} +} // namespace RDInfoTheory void wrap_ranker(); void wrap_corrmatgen(); diff --git a/Code/Numerics/Alignment/AlignPoints.cpp b/Code/Numerics/Alignment/AlignPoints.cpp index 8390b31ce..6b1ad76e7 100644 --- a/Code/Numerics/Alignment/AlignPoints.cpp +++ b/Code/Numerics/Alignment/AlignPoints.cpp @@ -350,5 +350,5 @@ double AlignPoints(const RDGeom::Point3DConstPtrVect &refPoints, trans.SetTranslation(move); return ssr; } -} -} +} // namespace Alignments +} // namespace RDNumeric diff --git a/Code/Numerics/Alignment/Wrap/rdAlignment.cpp b/Code/Numerics/Alignment/Wrap/rdAlignment.cpp index 2e71a42a9..bcf6532d2 100644 --- a/Code/Numerics/Alignment/Wrap/rdAlignment.cpp +++ b/Code/Numerics/Alignment/Wrap/rdAlignment.cpp @@ -160,8 +160,8 @@ PyObject *AlignPointPairs(python::object refPoints, python::object probePoints, PyTuple_SetItem(resTup, 1, PyArray_Return(res)); return resTup; } -} -} +} // namespace Alignments +} // namespace RDNumeric BOOST_PYTHON_MODULE(rdAlignment) { rdkit_import_array(); diff --git a/Code/Numerics/EigenSolvers/PowerEigenSolver.cpp b/Code/Numerics/EigenSolvers/PowerEigenSolver.cpp index 670fa3b4c..612d2f0f5 100644 --- a/Code/Numerics/EigenSolvers/PowerEigenSolver.cpp +++ b/Code/Numerics/EigenSolvers/PowerEigenSolver.cpp @@ -99,5 +99,5 @@ bool powerEigenSolver(unsigned int numEig, DoubleSymmMatrix &mat, } return converged; } -} -} +} // namespace EigenSolvers +} // namespace RDNumeric diff --git a/Code/RDBoost/Wrap.cpp b/Code/RDBoost/Wrap.cpp index 8e8f78d78..c5294fd32 100644 --- a/Code/RDBoost/Wrap.cpp +++ b/Code/RDBoost/Wrap.cpp @@ -36,15 +36,15 @@ void throw_key_error(const std::string key) { python::throw_error_already_set(); } -void translate_index_error(IndexErrorException const& e) { +void translate_index_error(IndexErrorException const &e) { throw_index_error(e.index()); } -void translate_value_error(ValueErrorException const& e) { +void translate_value_error(ValueErrorException const &e) { throw_value_error(e.what()); } -void translate_key_error(KeyErrorException const& e) { +void translate_key_error(KeyErrorException const &e) { throw_key_error(e.key()); } @@ -55,15 +55,16 @@ void throw_runtime_error(const std::string err) { python::throw_error_already_set(); } -void translate_invariant_error(Invar::Invariant const& e) { +void translate_invariant_error(Invar::Invariant const &e) { throw_runtime_error(e.toUserString()); } -boost::dynamic_bitset<> pythonObjectToDynBitset(const python::object &obj, - boost::dynamic_bitset<>::size_type maxV) { +boost::dynamic_bitset<> pythonObjectToDynBitset( + const python::object &obj, boost::dynamic_bitset<>::size_type maxV) { boost::dynamic_bitset<> res(maxV); if (obj) { - python::stl_input_iterator::size_type> beg(obj), end; + python::stl_input_iterator::size_type> beg(obj), + end; while (beg != end) { auto v = *beg; if (v >= maxV) { @@ -79,7 +80,7 @@ boost::dynamic_bitset<> pythonObjectToDynBitset(const python::object &obj, std::vector> *translateAtomMap( const python::object &atomMap) { PySequenceHolder pyAtomMap(atomMap); - std::vector>* res; + std::vector> *res; res = nullptr; unsigned int i; unsigned int n = pyAtomMap.size(); @@ -103,7 +104,7 @@ std::vector>> translateAtomMapSeq( std::vector>> aMapVec; PySequenceHolder pyAtomMapSeq(atomMapSeq); for (size_t i = 0; i < pyAtomMapSeq.size(); ++i) { - std::vector>* res = translateAtomMap(pyAtomMapSeq[i]); + std::vector> *res = translateAtomMap(pyAtomMapSeq[i]); aMapVec.push_back(*res); delete res; } diff --git a/Code/RDBoost/Wrap/RDBase.cpp b/Code/RDBoost/Wrap/RDBase.cpp index e8727026b..67542faa6 100644 --- a/Code/RDBoost/Wrap/RDBase.cpp +++ b/Code/RDBoost/Wrap/RDBase.cpp @@ -157,9 +157,9 @@ BOOST_PYTHON_MODULE(rdBase) { python_streambuf_wrapper::wrap(); python_ostream_wrapper::wrap(); - - python::class_( - "BlockLogs", - "Temporarily block logs from outputting while this instance is in scope."); - + + python::class_( + "BlockLogs", + "Temporarily block logs from outputting while this instance is in " + "scope."); } diff --git a/Code/RDGeneral/LocaleSwitcher.cpp b/Code/RDGeneral/LocaleSwitcher.cpp index a6efd7300..2d2125299 100644 --- a/Code/RDGeneral/LocaleSwitcher.cpp +++ b/Code/RDGeneral/LocaleSwitcher.cpp @@ -112,7 +112,8 @@ class LocaleSwitcherImpl { #ifdef RDK_THREADSAFE_SSS ::setlocale(LC_ALL, old_locale.c_str()); #else - std::setlocale(LC_ALL, old_locale.c_str()); // back to last (global?) locale + // back to last (global?) locale + std::setlocale(LC_ALL, old_locale.c_str()); #endif // RDK_THREADSAFE_SSS recurseLocale(ResetLocale); } @@ -151,12 +152,12 @@ class LocaleSwitcherImpl { #endif // _WIN32 }; -} +} // namespace detail // allows an RAII-like approach to ensuring the locale is temporarily "C" // instead of whatever we started in. LocaleSwitcher::LocaleSwitcher() : impl(new detail::LocaleSwitcherImpl) {} LocaleSwitcher::~LocaleSwitcher() { delete impl; } -} -} +} // namespace Utils +} // namespace RDKit diff --git a/Code/RDGeneral/RDLog.cpp b/Code/RDGeneral/RDLog.cpp index 204d56d9b..ec3590278 100644 --- a/Code/RDGeneral/RDLog.cpp +++ b/Code/RDGeneral/RDLog.cpp @@ -78,29 +78,26 @@ void disable_logs(const std::string &arg) { bool is_log_enabled(RDLogger log) { if (log && log.get() != nullptr) { - if( log->df_enabled ) { + if (log->df_enabled) { return true; } } return false; } -void get_log_status(std::ostream &ss, - const std::string &name, - RDLogger log) { +void get_log_status(std::ostream &ss, const std::string &name, RDLogger log) { ss << name << ":"; if (log && log.get() != nullptr) { - if( log->df_enabled ) { + if (log->df_enabled) { ss << "enabled"; - } - else { + } else { ss << "disabled"; } } else { ss << "unitialized"; } } - + std::string log_status() { std::stringstream ss; get_log_status(ss, "rdApp.debug", rdDebugLog); @@ -112,7 +109,7 @@ std::string log_status() { get_log_status(ss, "rdApp.error", rdErrorLog); return ss.str(); } - + } // namespace logging } // namespace boost @@ -200,11 +197,11 @@ void InitLogs() { #endif namespace RDLog { - + BlockLogs::BlockLogs() { auto logs = {rdDebugLog, rdInfoLog, rdWarningLog, rdErrorLog}; - for(auto log: logs) { - if(log != nullptr && is_log_enabled(log)) { + for (auto log : logs) { + if (log != nullptr && is_log_enabled(log)) { log->df_enabled = false; logs_to_reenable.push_back(log); } @@ -212,10 +209,11 @@ BlockLogs::BlockLogs() { } BlockLogs::~BlockLogs() { - for(auto log : logs_to_reenable) { - if(log != nullptr && log.get() != nullptr) + for (auto log : logs_to_reenable) { + if (log != nullptr && log.get() != nullptr) { log->df_enabled = true; + } } } -} +} // namespace RDLog diff --git a/Code/RDGeneral/testDict.cpp b/Code/RDGeneral/testDict.cpp index 2985436d4..23eeb80d8 100644 --- a/Code/RDGeneral/testDict.cpp +++ b/Code/RDGeneral/testDict.cpp @@ -28,7 +28,7 @@ using namespace std; struct Foo { int bar{0}; float baz{0.f}; - Foo() {} + Foo() {} Foo(int bar, float baz) : bar(bar), baz(baz) {} ~Foo() { std::cerr << "deleted!" << std::endl; } }; diff --git a/Code/RDGeneral/testRDValue.cpp b/Code/RDGeneral/testRDValue.cpp index 6b6676b40..d65272b93 100644 --- a/Code/RDGeneral/testRDValue.cpp +++ b/Code/RDGeneral/testRDValue.cpp @@ -254,84 +254,83 @@ void testPickleBinaryString() { } void testIntConversions() { - RDProps p; - p.setProp("foo", 1); - p.getProp("foo"); - p.getProp("foo"); - p.getProp("foo"); - p.getProp("foo"); - - p.setProp("foo", 1); - p.getProp("foo"); - - p.setProp("foo", 1); - p.getProp("foo"); - p.getProp("foo"); - p.getProp("foo"); - - p.getProp("foo"); - - // Test that min/max values of smaller types do not under/overflow - p.setProp("foo", 0); - p.getProp("foo"); - p.getProp("foo"); + RDProps p; + p.setProp("foo", 1); + p.getProp("foo"); + p.getProp("foo"); + p.getProp("foo"); + p.getProp("foo"); - p.setProp("foo", 255); - p.getProp("foo"); + p.setProp("foo", 1); + p.getProp("foo"); - p.setProp("foo", 65535); - p.getProp("foo"); + p.setProp("foo", 1); + p.getProp("foo"); + p.getProp("foo"); + p.getProp("foo"); - p.setProp("foo", -128); - p.getProp("foo"); + p.getProp("foo"); - p.setProp("foo", -32768); - p.getProp("foo"); + // Test that min/max values of smaller types do not under/overflow + p.setProp("foo", 0); + p.getProp("foo"); + p.getProp("foo"); - p.setProp("foo", 127); - p.getProp("foo"); + p.setProp("foo", 255); + p.getProp("foo"); - p.setProp("foo", 32767); - p.getProp("foo"); - - // Test some overflows - p.setProp("foo", 32767+1); - try { - p.getProp("foo"); // should fail - TEST_ASSERT(0); - } catch (boost::numeric::positive_overflow&) { - } - try { - p.getProp("foo"); // should fail - TEST_ASSERT(0); - } catch (boost::numeric::positive_overflow&) { - } - try { - p.getProp("foo"); // should fail - TEST_ASSERT(0); - } catch (boost::numeric::positive_overflow&) { - } - p.setProp("foo", 65535 + 1); - try { - p.getProp("foo"); // should fail - TEST_ASSERT(0); - } catch (boost::numeric::positive_overflow&) { - } - - p.setProp("foo", -1); - try { - p.getProp("foo"); // should fail - TEST_ASSERT(0); - } catch (boost::numeric::negative_overflow&) { - } - - p.getProp("foo"); // should pass - try { - p.getProp("foo"); // should fail - TEST_ASSERT(0); - } catch (boost::numeric::negative_overflow&) { - } + p.setProp("foo", 65535); + p.getProp("foo"); + p.setProp("foo", -128); + p.getProp("foo"); + + p.setProp("foo", -32768); + p.getProp("foo"); + + p.setProp("foo", 127); + p.getProp("foo"); + + p.setProp("foo", 32767); + p.getProp("foo"); + + // Test some overflows + p.setProp("foo", 32767 + 1); + try { + p.getProp("foo"); // should fail + TEST_ASSERT(0); + } catch (boost::numeric::positive_overflow&) { + } + try { + p.getProp("foo"); // should fail + TEST_ASSERT(0); + } catch (boost::numeric::positive_overflow&) { + } + try { + p.getProp("foo"); // should fail + TEST_ASSERT(0); + } catch (boost::numeric::positive_overflow&) { + } + p.setProp("foo", 65535 + 1); + try { + p.getProp("foo"); // should fail + TEST_ASSERT(0); + } catch (boost::numeric::positive_overflow&) { + } + + p.setProp("foo", -1); + try { + p.getProp("foo"); // should fail + TEST_ASSERT(0); + } catch (boost::numeric::negative_overflow&) { + } + + p.getProp("foo"); // should pass + try { + p.getProp("foo"); // should fail + TEST_ASSERT(0); + } catch (boost::numeric::negative_overflow&) { + } } int main() { std::cerr << "-- running tests -- " << std::endl; diff --git a/Code/SimDivPickers/DistPicker.cpp b/Code/SimDivPickers/DistPicker.cpp index f430e031d..4e253520c 100644 --- a/Code/SimDivPickers/DistPicker.cpp +++ b/Code/SimDivPickers/DistPicker.cpp @@ -21,4 +21,4 @@ double getDistFromLTM(const double *distMat, unsigned int i, unsigned int j) { return distMat[j * (j - 1) / 2 + i]; } } -} +} // namespace RDPickers diff --git a/Code/SimDivPickers/HierarchicalClusterPicker.cpp b/Code/SimDivPickers/HierarchicalClusterPicker.cpp index 25a39ce99..9e7f4efc6 100644 --- a/Code/SimDivPickers/HierarchicalClusterPicker.cpp +++ b/Code/SimDivPickers/HierarchicalClusterPicker.cpp @@ -44,7 +44,7 @@ RDKit::VECT_INT_VECT HierarchicalClusterPicker::cluster( ib, // one more clustering history matrix crit // I believe this is a vector the difference in heights of // two clusters - ); + ); // we have the clusters now merge then until the number of clusters is same // as the number of picks we need @@ -139,4 +139,4 @@ RDKit::INT_VECT HierarchicalClusterPicker::pick(const double *distMat, } return picks; } -} +} // namespace RDPickers diff --git a/Code/SimDivPickers/Wrap/HierarchicalClusterPicker.cpp b/Code/SimDivPickers/Wrap/HierarchicalClusterPicker.cpp index 39de847cd..07c451a06 100644 --- a/Code/SimDivPickers/Wrap/HierarchicalClusterPicker.cpp +++ b/Code/SimDivPickers/Wrap/HierarchicalClusterPicker.cpp @@ -107,6 +107,6 @@ struct HierarchCP_wrap { .export_values(); }; }; -} +} // namespace RDPickers void wrap_HierarchCP() { RDPickers::HierarchCP_wrap::wrap(); } diff --git a/Code/SimDivPickers/Wrap/LeaderPicker.cpp b/Code/SimDivPickers/Wrap/LeaderPicker.cpp index 78a0cd07a..983c853b9 100644 --- a/Code/SimDivPickers/Wrap/LeaderPicker.cpp +++ b/Code/SimDivPickers/Wrap/LeaderPicker.cpp @@ -18,7 +18,6 @@ #include "PickerHelpers.h" - #include #include #include @@ -44,8 +43,6 @@ void LazyLeaderHelper(LeaderPicker *picker, T functor, unsigned int poolSize, } } // end of anonymous namespace - - RDKit::INT_VECT LazyVectorLeaderPicks(LeaderPicker *picker, python::object objs, int poolSize, double threshold, int pickSize, python::object firstPicks, @@ -100,9 +97,8 @@ struct LeaderPicker_wrap { python::arg("firstPicks") = python::tuple(), python::arg("numThreads") = 1), "Pick a subset of items from a pool of items using the " - "user-provided function to determine distances. Note that the " - "numThreads argument is currently ignored.") - ; + "user-provided function to determine distances. Note that the " + "numThreads argument is currently ignored."); }; }; diff --git a/Code/SimDivPickers/Wrap/MaxMinPicker.cpp b/Code/SimDivPickers/Wrap/MaxMinPicker.cpp index 1b5fa72a5..293e1ee41 100644 --- a/Code/SimDivPickers/Wrap/MaxMinPicker.cpp +++ b/Code/SimDivPickers/Wrap/MaxMinPicker.cpp @@ -77,8 +77,8 @@ RDKit::INT_VECT LazyMaxMinPicks(MaxMinPicker *picker, python::object distFunc, python::object firstPicks, int seed, python::object useCache) { if (useCache != python::object()) { - BOOST_LOG(rdWarningLog) << "the useCache argument is deprecated and ignored" - << std::endl; + BOOST_LOG(rdWarningLog) + << "the useCache argument is deprecated and ignored" << std::endl; } pyobjFunctor functor(distFunc); RDKit::INT_VECT res; @@ -102,8 +102,8 @@ RDKit::INT_VECT LazyVectorMaxMinPicks(MaxMinPicker *picker, python::object objs, python::object firstPicks, int seed, python::object useCache) { if (useCache != python::object()) { - BOOST_LOG(rdWarningLog) << "the useCache argument is deprecated and ignored" - << std::endl; + BOOST_LOG(rdWarningLog) + << "the useCache argument is deprecated and ignored" << std::endl; } std::vector bvs(poolSize); for (int i = 0; i < poolSize; ++i) {