diff --git a/Code/DataManip/MetricMatrixCalc/MetricFuncs.h b/Code/DataManip/MetricMatrixCalc/MetricFuncs.h index 20e519216..31cdfb36a 100755 --- a/Code/DataManip/MetricMatrixCalc/MetricFuncs.h +++ b/Code/DataManip/MetricMatrixCalc/MetricFuncs.h @@ -28,13 +28,13 @@ namespace RDDataManip { double TanimotoDistanceMetric(const T1 &bv1, const T2 &bv2, unsigned int dim) { // the dim parameter is actually irrelevant here but we have to include it to deal with // template version of setMetricFunc in MetricMatricCalc - return (1.0 - SimilarityWrapper(bv1, bv2,(const double (*)(const T1&,const T2&))TanimotoSimilarity)); + return (1.0 - SimilarityWrapper(bv1, bv2,(double (*)(const T1&,const T2&))TanimotoSimilarity)); }; //! return the Tanimoto similarity between two bit vectors template double TanimotoSimilarityMetric(const T1 &bv1, const T2 &bv2, unsigned int dim) { - return SimilarityWrapper(bv1,bv2,(const double (*)(const T1&,const T2&))TanimotoSimilarity); + return SimilarityWrapper(bv1,bv2,(double (*)(const T1&,const T2&))TanimotoSimilarity); }; } diff --git a/Code/DataStructs/BitOps.cpp b/Code/DataStructs/BitOps.cpp index f957d9886..0f6849a32 100755 --- a/Code/DataStructs/BitOps.cpp +++ b/Code/DataStructs/BitOps.cpp @@ -210,7 +210,7 @@ NumOnBitsInCommon(const ExplicitBitVect& bv1, // // """ ------------------------------------------------------- template -const double +double TanimotoSimilarity(const T1& bv1, const T2& bv2) { @@ -225,7 +225,7 @@ TanimotoSimilarity(const T1& bv1, template -const double +double TverskySimilarity(const T1& bv1, const T2& bv2, double a, @@ -244,7 +244,7 @@ TverskySimilarity(const T1& bv1, } template -const double +double CosineSimilarity(const T1& bv1, const T2& bv2) { @@ -262,7 +262,7 @@ CosineSimilarity(const T1& bv1, } template -const double +double KulczynskiSimilarity(const T1& bv1, const T2& bv2) { @@ -281,7 +281,7 @@ KulczynskiSimilarity(const T1& bv1, template -const double +double DiceSimilarity(const T1& bv1, const T2& bv2) { @@ -299,7 +299,7 @@ DiceSimilarity(const T1& bv1, } template -const double +double SokalSimilarity(const T1& bv1, const T2& bv2) { @@ -313,7 +313,7 @@ SokalSimilarity(const T1& bv1, } template -const double +double McConnaugheySimilarity(const T1& bv1, const T2& bv2) { @@ -343,7 +343,7 @@ inline T tmax(T v1,T v2) { } template -const double +double AsymmetricSimilarity(const T1& bv1, const T2& bv2) { @@ -361,7 +361,7 @@ AsymmetricSimilarity(const T1& bv1, } template -const double +double BraunBlanquetSimilarity(const T1& bv1, const T2& bv2) { @@ -379,7 +379,7 @@ BraunBlanquetSimilarity(const T1& bv1, } template -const double +double RusselSimilarity(const T1& bv1, const T2& bv2) { @@ -405,7 +405,7 @@ RusselSimilarity(const T1& bv1, // // """ ------------------------------------------------------- template -const double +double OnBitSimilarity(const T1& bv1, const T2& bv2) { @@ -436,7 +436,7 @@ OnBitSimilarity(const T1& bv1, // // """ ------------------------------------------------------- template -const int +int NumBitsInCommon(const T1& bv1, const T2& bv2) { @@ -462,7 +462,7 @@ NumBitsInCommon(const T1& bv1, // // """ ------------------------------------------------------- template -const double +double AllBitSimilarity(const T1& bv1, const T2& bv2) { @@ -644,38 +644,38 @@ BitVectToText(const T1& bv1){ -template const double TanimotoSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); -template const double TverskySimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2,double a, double b); -template const double CosineSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); -template const double KulczynskiSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); -template const double DiceSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); -template const double SokalSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); -template const double McConnaugheySimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); -template const double AsymmetricSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); -template const double BraunBlanquetSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); -template const double RusselSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); -template const double OnBitSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); -template const int NumBitsInCommon(const SparseBitVect& bv1,const SparseBitVect& bv2); -template const double AllBitSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); +template double TanimotoSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); +template double TverskySimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2,double a, double b); +template double CosineSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); +template double KulczynskiSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); +template double DiceSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); +template double SokalSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); +template double McConnaugheySimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); +template double AsymmetricSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); +template double BraunBlanquetSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); +template double RusselSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); +template double OnBitSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); +template int NumBitsInCommon(const SparseBitVect& bv1,const SparseBitVect& bv2); +template double AllBitSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); template int NumOnBitsInCommon(const SparseBitVect& bv1,const SparseBitVect& bv2); template IntVect OnBitsInCommon(const SparseBitVect& bv1,const SparseBitVect& bv2); template IntVect OffBitsInCommon(const SparseBitVect& bv1,const SparseBitVect& bv2); template DoubleVect OnBitProjSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); template DoubleVect OffBitProjSimilarity(const SparseBitVect& bv1,const SparseBitVect& bv2); -template const double TanimotoSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); -template const double TverskySimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2,double a, double b); -template const double CosineSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); -template const double KulczynskiSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); -template const double DiceSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); -template const double SokalSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); -template const double McConnaugheySimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); -template const double AsymmetricSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); -template const double BraunBlanquetSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); -template const double RusselSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); -template const double OnBitSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); -template const int NumBitsInCommon(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); -template const double AllBitSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); +template double TanimotoSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); +template double TverskySimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2,double a, double b); +template double CosineSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); +template double KulczynskiSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); +template double DiceSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); +template double SokalSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); +template double McConnaugheySimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); +template double AsymmetricSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); +template double BraunBlanquetSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); +template double RusselSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); +template double OnBitSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); +template int NumBitsInCommon(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); +template double AllBitSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); template IntVect OnBitsInCommon(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); template IntVect OffBitsInCommon(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); template DoubleVect OnBitProjSimilarity(const ExplicitBitVect& bv1,const ExplicitBitVect& bv2); diff --git a/Code/DataStructs/BitOps.h b/Code/DataStructs/BitOps.h index f4293532a..86f1da5c3 100755 --- a/Code/DataStructs/BitOps.h +++ b/Code/DataStructs/BitOps.h @@ -24,7 +24,7 @@ //! that may be of unequal size (will automatically fold as appropriate) template double SimilarityWrapper(const T &bv1,const T &bv2, - const double (*metric)(const T &,const T &), + double (*metric)(const T &,const T &), bool returnDistance=false){ double res=0.0; if(bv1.GetNumBits()>bv2.GetNumBits()){ @@ -44,7 +44,7 @@ double SimilarityWrapper(const T &bv1,const T &bv2, //! \overload template double SimilarityWrapper(const T &bv1,const T &bv2,double a,double b, - const double (*metric)(const T &,const T &,double,double), + double (*metric)(const T &,const T &,double,double), bool returnDistance=false){ double res=0.0; if(bv1.GetNumBits()>bv2.GetNumBits()){ @@ -90,7 +90,7 @@ NumOnBitsInCommon(const ExplicitBitVect & bv1,const ExplicitBitVect & bv2); \return (bv1&bv2)_o / [bv1_o + bv2_o - (bv1&bv2)_o] */ template -const double +double TanimotoSimilarity(const T1& bv1,const T2& bv2); //! returns the Cosine similarity between two bit vects @@ -98,7 +98,7 @@ TanimotoSimilarity(const T1& bv1,const T2& bv2); \return (bv1&bv2)_o / sqrt(bv1_o + bv2_o) */ template -const double +double CosineSimilarity(const T1& bv1, const T2& bv2); @@ -107,7 +107,7 @@ CosineSimilarity(const T1& bv1, \return (bv1&bv2)_o * [bv1_o + bv2_o] / [2 * bv1_o * bv2_o] */ template -const double +double KulczynskiSimilarity(const T1& bv1, const T2& bv2); @@ -116,7 +116,7 @@ KulczynskiSimilarity(const T1& bv1, \return 2*(bv1&bv2)_o / [bv1_o + bv2_o] */ template -const double +double DiceSimilarity(const T1& bv1, const T2& bv2); @@ -131,7 +131,7 @@ DiceSimilarity(const T1& bv1, */ template -const double +double TverskySimilarity(const T1& bv1, const T2& bv2,double a,double b); @@ -140,7 +140,7 @@ TverskySimilarity(const T1& bv1, \return (bv1&bv2)_o / [2*bv1_o + 2*bv2_o - 3*(bv1&bv2)_o] */ template -const double +double SokalSimilarity(const T1& bv1, const T2& bv2); @@ -149,7 +149,7 @@ SokalSimilarity(const T1& bv1, \return [(bv1&bv2)_o * (bv1_o + bv2_o) - (bv1_o * bv2_o)] / (bv1_o * bv2_o) */ template -const double +double McConnaugheySimilarity(const T1& bv1, const T2& bv2); @@ -158,7 +158,7 @@ McConnaugheySimilarity(const T1& bv1, \return (bv1&bv2)_o / min(bv1_o,bv2_o) */ template -const double +double AsymmetricSimilarity(const T1& bv1, const T2& bv2); @@ -167,7 +167,7 @@ AsymmetricSimilarity(const T1& bv1, \return (bv1&bv2)_o / max(bv1_o,bv2_o) */ template -const double +double BraunBlanquetSimilarity(const T1& bv1, const T2& bv2); @@ -180,7 +180,7 @@ BraunBlanquetSimilarity(const T1& bv1, */ template -const double +double RusselSimilarity(const T1& bv1, const T2& bv2); @@ -190,7 +190,7 @@ RusselSimilarity(const T1& bv1, \return (bv1&bv2)_o / (bv1|bv2)_o */ template -const double +double OnBitSimilarity(const T1& bv1,const T2& bv2); //! returns the number of common bits (on and off) between two bit vects @@ -198,7 +198,7 @@ OnBitSimilarity(const T1& bv1,const T2& bv2); \return bv1_n - (bv1^bv2)_o */ template -const int +int NumBitsInCommon(const T1& bv1,const T2& bv2); //! returns the commong-bit similarity (on and off) between two bit vects @@ -206,7 +206,7 @@ NumBitsInCommon(const T1& bv1,const T2& bv2); \return [bv1_n - (bv1^bv2)_o] / bv1_n */ template -const double +double AllBitSimilarity(const T1& bv1,const T2& bv2); //! returns an IntVect with indices of all on bits in common between two bit vects diff --git a/Code/DataStructs/BitVect.h b/Code/DataStructs/BitVect.h index 7dc04ef19..e625a579e 100755 --- a/Code/DataStructs/BitVect.h +++ b/Code/DataStructs/BitVect.h @@ -27,11 +27,11 @@ public: //! returns the value of a particular bit virtual bool GetBit(const unsigned int which) const = 0; //! returns the number of bits (the length of the BitVect) - virtual const unsigned int GetNumBits() const = 0; + virtual unsigned int GetNumBits() const = 0; //! returns the number of on bits - virtual const unsigned int GetNumOnBits() const = 0; + virtual unsigned int GetNumOnBits() const = 0; //! returns the number of off bits - virtual const unsigned int GetNumOffBits() const =0; + virtual unsigned int GetNumOffBits() const =0; //! replaces the contents of \c v with indices of our on bits virtual void GetOnBits (IntVect& v) const = 0; //! clears (sets to off) all of our bits diff --git a/Code/DataStructs/ExplicitBitVect.cpp b/Code/DataStructs/ExplicitBitVect.cpp index 89f2d6e7b..9e52c43bb 100755 --- a/Code/DataStructs/ExplicitBitVect.cpp +++ b/Code/DataStructs/ExplicitBitVect.cpp @@ -104,13 +104,13 @@ ExplicitBitVect::ExplicitBitVect(const char *data,const unsigned int dataLen) return(ans); }; - const unsigned int ExplicitBitVect::GetNumBits() const { + unsigned int ExplicitBitVect::GetNumBits() const { return d_size; }; - const unsigned int ExplicitBitVect::GetNumOnBits() const { + unsigned int ExplicitBitVect::GetNumOnBits() const { return d_numOnBits; }; - const unsigned int ExplicitBitVect::GetNumOffBits() const { + unsigned int ExplicitBitVect::GetNumOffBits() const { return d_size - d_numOnBits; }; diff --git a/Code/DataStructs/ExplicitBitVect.h b/Code/DataStructs/ExplicitBitVect.h index bbe4100ee..8388d1dd0 100755 --- a/Code/DataStructs/ExplicitBitVect.h +++ b/Code/DataStructs/ExplicitBitVect.h @@ -41,9 +41,9 @@ public: ExplicitBitVect operator& (const ExplicitBitVect &other) const; ExplicitBitVect operator| (const ExplicitBitVect &other) const; ExplicitBitVect operator~ () const; - const unsigned int GetNumBits() const; - const unsigned int GetNumOnBits() const; - const unsigned int GetNumOffBits() const; + unsigned int GetNumBits() const; + unsigned int GetNumOnBits() const; + unsigned int GetNumOffBits() const; void GetOnBits (IntVect& v) const; diff --git a/Code/DataStructs/SparseBitVect.h b/Code/DataStructs/SparseBitVect.h index a3d4fdac7..a2e87b25e 100755 --- a/Code/DataStructs/SparseBitVect.h +++ b/Code/DataStructs/SparseBitVect.h @@ -58,7 +58,7 @@ public: //! returns a (const) pointer to our raw storage const IntSet *GetBitSet() const { return dp_bits;} - const unsigned int GetNumBits() const { return d_size; }; + unsigned int GetNumBits() const { return d_size; }; bool SetBit(const unsigned int which); bool SetBit(const IntSetIter which); bool UnSetBit(const unsigned int which); @@ -66,8 +66,8 @@ public: bool GetBit(const IntVectIter which) const; bool GetBit(const IntSetIter which) const; - const unsigned int GetNumOnBits() const { return dp_bits->size(); }; - const unsigned int GetNumOffBits() const { return d_size - dp_bits->size(); }; + unsigned int GetNumOnBits() const { return dp_bits->size(); }; + unsigned int GetNumOffBits() const { return d_size - dp_bits->size(); }; std::string ToString() const; diff --git a/Code/DataStructs/Wrap/wrap_BitOps.cpp b/Code/DataStructs/Wrap/wrap_BitOps.cpp index d7c7e11d4..5dc2f667d 100755 --- a/Code/DataStructs/Wrap/wrap_BitOps.cpp +++ b/Code/DataStructs/Wrap/wrap_BitOps.cpp @@ -21,13 +21,13 @@ EBV *ff2(const EBV &ev1, int factor=2) { template double SimilarityWrapper(const T &bv1,const std::string &pkl, - const double (*metric)(const T &,const T &),bool returnDistance){ + double (*metric)(const T &,const T &),bool returnDistance){ T bv2(pkl); return SimilarityWrapper(bv1,bv2,metric,returnDistance); } template double SimilarityWrapper(const T &bv1,const std::string &pkl,double a,double b, - const double (*metric)(const T &,const T &,double,double),bool returnDistance){ + double (*metric)(const T &,const T &,double,double),bool returnDistance){ T bv2(pkl); return SimilarityWrapper(bv1,bv2,a,b,metric,returnDistance); } @@ -35,7 +35,7 @@ double SimilarityWrapper(const T &bv1,const std::string &pkl,double a,double b, template python::list BulkWrapper(const T &bv1,python::list bvs, - const double (*metric)(const T &,const T &), + double (*metric)(const T &,const T &), bool returnDistance){ python::list res; unsigned int nbvs=python::extract(bvs.attr("__len__")()); @@ -48,7 +48,7 @@ python::list BulkWrapper(const T &bv1,python::list bvs, template python::list BulkWrapper(const T &bv1,python::list bvs,double a,double b, - const double (*metric)(const T &,const T &,double,double), + double (*metric)(const T &,const T &,double,double), bool returnDistance){ python::list res; unsigned int nbvs=python::extract(bvs.attr("__len__")()); @@ -62,53 +62,53 @@ python::list BulkWrapper(const T &bv1,python::list bvs,double a,double b, template double TanimotoSimilarity_w(const T1 &bv1,const T2 &bv2,bool returnDistance){ return SimilarityWrapper(bv1,bv2, - (const double (*)(const T1&,const T1&))TanimotoSimilarity, + (double (*)(const T1&,const T1&))TanimotoSimilarity, returnDistance); } template python::list BulkTanimotoSimilarity(const T &bv1,python::list bvs,bool returnDistance){ return BulkWrapper(bv1,bvs, - (const double (*)(const T&,const T&))TanimotoSimilarity, + (double (*)(const T&,const T&))TanimotoSimilarity, returnDistance); } template double TverskySimilarity_w(const T1 &bv1,const T2 &bv2,double a,double b,bool returnDistance){ return SimilarityWrapper(bv1,bv2,a,b, - (const double (*)(const T1&,const T1&,double,double))TverskySimilarity, + (double (*)(const T1&,const T1&,double,double))TverskySimilarity, returnDistance); } template python::list BulkTverskySimilarity(const T &bv1,python::list bvs,double a,double b, bool returnDistance){ return BulkWrapper(bv1,bvs,a,b, - (const double (*)(const T&,const T&,double,double))TverskySimilarity, + (double (*)(const T&,const T&,double,double))TverskySimilarity, returnDistance); } template double CosineSimilarity_w(const T1 &bv1,const T2 &bv2,bool returnDistance){ return SimilarityWrapper(bv1,bv2, - (const double (*)(const T1&,const T1&))CosineSimilarity, + (double (*)(const T1&,const T1&))CosineSimilarity, returnDistance); } template python::list BulkCosineSimilarity(const T &bv1,python::list bvs,bool returnDistance){ return BulkWrapper(bv1,bvs, - (const double (*)(const T&,const T&))CosineSimilarity, + (double (*)(const T&,const T&))CosineSimilarity, returnDistance); } template double KulczynskiSimilarity_w(const T1 &bv1,const T2 &bv2,bool returnDistance){ return SimilarityWrapper(bv1,bv2, - (const double (*)(const T1&,const T1&))KulczynskiSimilarity, + (double (*)(const T1&,const T1&))KulczynskiSimilarity, returnDistance); } template python::list BulkKulczynskiSimilarity(const T &bv1,python::list bvs,bool returnDistance){ return BulkWrapper(bv1,bvs, - (const double (*)(const T&,const T&))KulczynskiSimilarity, + (double (*)(const T&,const T&))KulczynskiSimilarity, returnDistance); } @@ -116,99 +116,99 @@ python::list BulkKulczynskiSimilarity(const T &bv1,python::list bvs,bool returnD template double DiceSimilarity_w(const T1 &bv1,const T2 &bv2,bool returnDistance){ return SimilarityWrapper(bv1,bv2, - (const double (*)(const T1&,const T1&))DiceSimilarity, + (double (*)(const T1&,const T1&))DiceSimilarity, returnDistance); } template python::list BulkDiceSimilarity(const T &bv1,python::list bvs,bool returnDistance){ return BulkWrapper(bv1,bvs, - (const double (*)(const T&,const T&))DiceSimilarity, + (double (*)(const T&,const T&))DiceSimilarity, returnDistance); } template double SokalSimilarity_w(const T1 &bv1,const T2 &bv2,bool returnDistance){ return SimilarityWrapper(bv1,bv2, - (const double (*)(const T1&,const T1&))SokalSimilarity, + (double (*)(const T1&,const T1&))SokalSimilarity, returnDistance); } template python::list BulkSokalSimilarity(const T &bv1,python::list bvs,bool returnDistance){ return BulkWrapper(bv1,bvs, - (const double (*)(const T&,const T&))SokalSimilarity, + (double (*)(const T&,const T&))SokalSimilarity, returnDistance); } template double McConnaugheySimilarity_w(const T1 &bv1,const T2 &bv2,bool returnDistance){ return SimilarityWrapper(bv1,bv2, - (const double (*)(const T1&,const T1&))McConnaugheySimilarity, + (double (*)(const T1&,const T1&))McConnaugheySimilarity, returnDistance); } template python::list BulkMcConnaugheySimilarity(const T &bv1,python::list bvs,bool returnDistance){ return BulkWrapper(bv1,bvs, - (const double (*)(const T&,const T&))McConnaugheySimilarity, + (double (*)(const T&,const T&))McConnaugheySimilarity, returnDistance); } template double AsymmetricSimilarity_w(const T1 &bv1,const T2 &bv2,bool returnDistance){ return SimilarityWrapper(bv1,bv2, - (const double (*)(const T1&,const T1&))AsymmetricSimilarity, + (double (*)(const T1&,const T1&))AsymmetricSimilarity, returnDistance); } template python::list BulkAsymmetricSimilarity(const T &bv1,python::list bvs,bool returnDistance){ return BulkWrapper(bv1,bvs, - (const double (*)(const T&,const T&))AsymmetricSimilarity, + (double (*)(const T&,const T&))AsymmetricSimilarity, returnDistance); } template double BraunBlanquetSimilarity_w(const T1 &bv1,const T2 &bv2,bool returnDistance){ return SimilarityWrapper(bv1,bv2, - (const double (*)(const T1&,const T1&))BraunBlanquetSimilarity, + (double (*)(const T1&,const T1&))BraunBlanquetSimilarity, returnDistance); } template python::list BulkBraunBlanquetSimilarity(const T &bv1,python::list bvs,bool returnDistance){ return BulkWrapper(bv1,bvs, - (const double (*)(const T&,const T&))BraunBlanquetSimilarity, + (double (*)(const T&,const T&))BraunBlanquetSimilarity, returnDistance); } template double RusselSimilarity_w(const T1 &bv1,const T2 &bv2,bool returnDistance){ return SimilarityWrapper(bv1,bv2, - (const double (*)(const T1&,const T1&))RusselSimilarity, + (double (*)(const T1&,const T1&))RusselSimilarity, returnDistance); } template python::list BulkRusselSimilarity(const T &bv1,python::list bvs,bool returnDistance){ return BulkWrapper(bv1,bvs, - (const double (*)(const T&,const T&))RusselSimilarity, + (double (*)(const T&,const T&))RusselSimilarity, returnDistance); } template python::list BulkOnBitSimilarity(const T &bv1,python::list bvs,bool returnDistance){ return BulkWrapper(bv1,bvs, - (const double (*)(const T&,const T&))OnBitSimilarity, + (double (*)(const T&,const T&))OnBitSimilarity, returnDistance); } template python::list BulkAllBitSimilarity(const T &bv1,python::list bvs,bool returnDistance){ return BulkWrapper(bv1,bvs, - (const double (*)(const T&,const T&))AllBitSimilarity, + (double (*)(const T&,const T&))AllBitSimilarity, returnDistance); } #define DBL_DEF(_funcname_,_bulkname_,_help_) { \ - python::def( # _funcname_,(const double (*)(const SBV &,const SBV &))_funcname_,\ + python::def( # _funcname_,(double (*)(const SBV &,const SBV &))_funcname_,\ (python::args("v1"),python::args("v2"))); \ - python::def( # _funcname_,(const double (*)(const EBV &,const EBV &))_funcname_,\ + python::def( # _funcname_,(double (*)(const EBV &,const EBV &))_funcname_,\ (python::args("v1"),python::args("v2")),_help_);\ python::def( # _bulkname_,(python::list (*)(const EBV &,python::list,bool))_bulkname_,\ (python::args("v1"),python::args("v2"),python::args("returnDistance")=0));\ @@ -297,9 +297,9 @@ struct BitOps_wrapper { (DoubleVect (*)(const EBV&,const EBV&))OffBitProjSimilarity); python::def("NumBitsInCommon", - (const int (*)(const SBV&,const SBV&))NumBitsInCommon); + (int (*)(const SBV&,const SBV&))NumBitsInCommon); python::def("NumBitsInCommon", - (const int (*)(const EBV&,const EBV&))NumBitsInCommon, + (int (*)(const EBV&,const EBV&))NumBitsInCommon, "Returns the total number of bits in common between the two bit vectors" ); python::def("OnBitsInCommon", diff --git a/Code/Demos/RDKit/GettingStarted/Jamfile b/Code/Demos/RDKit/GettingStarted/Jamfile index 808bc6081..6abd689cc 100644 --- a/Code/Demos/RDKit/GettingStarted/Jamfile +++ b/Code/Demos/RDKit/GettingStarted/Jamfile @@ -9,7 +9,7 @@ exe sample : sample.cpp ../../../GraphMol//GraphMol ../../../DataStructs//DataStructs ../../../RDGeneral//RDGeneral ../../../Geometry//RDGeometry - ../../..//vflib ../../..//lapacklibs + ../../..//lapacklibs ; diff --git a/Code/Demos/SWIG/java_example/Jamfile b/Code/Demos/SWIG/java_example/Jamfile index 435a987b4..a3f2ba9fe 100644 --- a/Code/Demos/SWIG/java_example/Jamfile +++ b/Code/Demos/SWIG/java_example/Jamfile @@ -8,7 +8,6 @@ lib RDKFuncs : RDKFuncs_wrap.cpp RDKFuncs.cpp ../../../GraphMol/Substruct//Substruct ../../../GraphMol/ChemReactions//ChemReactions ../../../RDGeneral//RDGeneral ../../../Geometry//RDGeometry /RDKit//lapacklibs - /RDKit//vflib : -fno-strict-aliasing /usr/include/java /usr/include/java/linux . ; cpp RDKFuncs_wrap.cpp : RDKFuncs.i : JAVA_WRAPPER ; diff --git a/Code/Demos/sqlite/Jamfile b/Code/Demos/sqlite/Jamfile index a902194c2..0f3ffbbbf 100644 --- a/Code/Demos/sqlite/Jamfile +++ b/Code/Demos/sqlite/Jamfile @@ -10,7 +10,7 @@ lib rdk_funcs : rdk_funcs.cpp ../../GraphMol//GraphMol /RDKit//DataStructs /RDKit//RDGeneral /RDKit//Geometry - /RDKit//vflib /RDKit//lapacklibs + /RDKit//lapacklibs ; install lib-install : rdk_funcs : . ; diff --git a/Code/GraphMol/ChemReactions/Jamfile b/Code/GraphMol/ChemReactions/Jamfile index 19b50d154..94fc6bf7c 100644 --- a/Code/GraphMol/ChemReactions/Jamfile +++ b/Code/GraphMol/ChemReactions/Jamfile @@ -11,7 +11,7 @@ install lib-install : ChemReactions : $(RDBASE)/bin ; exe testReaction : testReaction.cpp ChemReactions ../FileParsers//FileParsers ../SmilesParse//SmilesParse ../Substruct//Substruct ..//GraphMol ../../RDGeneral//RDGeneral - ../../Geometry//RDGeometry ../..//vflib ; + ../../Geometry//RDGeometry ; install regrs : testReaction : testExecs ; diff --git a/Code/GraphMol/ChemReactions/Wrap/Jamfile b/Code/GraphMol/ChemReactions/Wrap/Jamfile index c57c62dca..616ffe7c7 100644 --- a/Code/GraphMol/ChemReactions/Wrap/Jamfile +++ b/Code/GraphMol/ChemReactions/Wrap/Jamfile @@ -11,7 +11,7 @@ python-extension rdChemReactions : rdChemReactions.cpp ../..//GraphMol ../../../Geometry//RDGeometry ../../../RDGeneral//RDGeneral ../../../DataStructs//DataStructs ../../../RDBoost//RDBoost -../../..//vflib + ; install pymod : rdChemReactions diff --git a/Code/GraphMol/ChemTransforms/Jamfile b/Code/GraphMol/ChemTransforms/Jamfile index fe1d5e39b..7cd05ceb7 100644 --- a/Code/GraphMol/ChemTransforms/Jamfile +++ b/Code/GraphMol/ChemTransforms/Jamfile @@ -10,7 +10,7 @@ install lib-install : ChemTransforms : $(RDBASE)/bin ; exe main : testChemTransforms.cpp ChemTransforms ../FileParsers//FileParsers ../SmilesParse//SmilesParse -../Substruct//Substruct ..//GraphMol ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry ../..//vflib ; +../Substruct//Substruct ..//GraphMol ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry ; install regrs : main : testExecs ; diff --git a/Code/GraphMol/Depictor/Jamfile b/Code/GraphMol/Depictor/Jamfile index 5fe7e924b..0e69741ae 100644 --- a/Code/GraphMol/Depictor/Jamfile +++ b/Code/GraphMol/Depictor/Jamfile @@ -10,7 +10,7 @@ install lib-install : Depictor : $(RDBASE)/bin ; exe testDepictor : testDepictor.cpp Depictor ../SmilesParse//SmilesParse ../FileParsers//FileParsers -../Substruct//Substruct ..//GraphMol ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry ../..//vflib ; +../Substruct//Substruct ..//GraphMol ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry ; install regrs : testDepictor : testExecs ; diff --git a/Code/GraphMol/Descriptors/Jamfile b/Code/GraphMol/Descriptors/Jamfile index 02c32a825..70ab8b616 100644 --- a/Code/GraphMol/Descriptors/Jamfile +++ b/Code/GraphMol/Descriptors/Jamfile @@ -10,7 +10,7 @@ install lib-install : Descriptors : $(RDBASE)/bin ; exe testDescriptors : test.cpp Descriptors ../FileParsers//FileParsers ../SmilesParse//SmilesParse ../Subgraphs//Subgraphs -../Substruct//Substruct ..//GraphMol ../../DataStructs//DataStructs ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry ../..//lapacklibs ../..//vflib ; +../Substruct//Substruct ..//GraphMol ../../DataStructs//DataStructs ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry ../..//lapacklibs ; install regrs : testDescriptors : testExecs ; diff --git a/Code/GraphMol/Descriptors/Wrap/Jamfile b/Code/GraphMol/Descriptors/Wrap/Jamfile index 73597884c..0427776c1 100644 --- a/Code/GraphMol/Descriptors/Wrap/Jamfile +++ b/Code/GraphMol/Descriptors/Wrap/Jamfile @@ -11,7 +11,7 @@ python-extension rdMolDescriptors : rdMolDescriptors.cpp ../..//GraphMol ../../../Geometry//RDGeometry ../../../RDGeneral//RDGeneral ../../../DataStructs//DataStructs ../../../RDBoost//RDBoost -../../..//vflib ../../..//lapacklibs + ../../..//lapacklibs ; install pymod : rdMolDescriptors diff --git a/Code/GraphMol/DistGeomHelpers/Embedder.cpp b/Code/GraphMol/DistGeomHelpers/Embedder.cpp index 102ebfc3f..91b21e854 100644 --- a/Code/GraphMol/DistGeomHelpers/Embedder.cpp +++ b/Code/GraphMol/DistGeomHelpers/Embedder.cpp @@ -73,38 +73,33 @@ namespace RDKit { chiralCenters, 1.0, 0.1, 0,basinThresh); - unsigned int nPasses=0; - field->initialize(); - if(field->calcEnergy() > ERROR_TOL){ - int needMore = 1; - while(needMore){ - //std::cerr<<"********* Minimize1 from: "<calcEnergy()<minimize(200,optimizerForceTol); - ++nPasses; - } - //std::cerr<<"********* Finished1 at "<calcEnergy()<initialize(); + if(field->calcEnergy() > ERROR_TOL){ + int needMore = 1; + while(needMore){ + needMore = field->minimize(200,optimizerForceTol); + ++nPasses; + } + } // now redo the minimization if we have a chiral center, this // time removing the chiral constraints and // increasing the weight on the fourth dimension if (chiralCenters.size()>0 || useRandomCoords) { ForceFields::ForceField *field2 = DistGeom::constructForceField(*mmat, positions, - chiralCenters, - 0.1, 1.0, 0, - basinThresh); - field2->initialize(); - if(field2->calcEnergy() > ERROR_TOL){ - int needMore = 1; - while(needMore){ - //std::cerr<<"********* Minimize2 from: "<calcEnergy()<minimize(200,optimizerForceTol); - } - //std::cerr<<"********* Finished2 at "<calcEnergy()<calcEnergy()<initialize(); + if(field2->calcEnergy() > ERROR_TOL){ + int needMore = 1; + while(needMore){ + needMore = field2->minimize(200,optimizerForceTol); + } + } + delete field2; } - delete field; + delete field; } return gotCoords; } @@ -121,7 +116,7 @@ namespace RDKit { nbrs.clear(); nbrs.reserve(4); // find the neighbors of this atom and enter them into the - // nbr list along with their CIPRanks + // nbr list along with their CIPRanks boost::tie(beg,end) = mol.getAtomBonds(*ati); while (beg != end) { oatom = mol[*beg]->getOtherAtom(*ati); @@ -132,7 +127,7 @@ namespace RDKit { ++beg; } // if we have less than 4 heavy atoms as neighbors, - // we need to include the chiral center into the mix + // we need to include the chiral center into the mix // we should at least have 3 though bool includeSelf = false; CHECK_INVARIANT(nbrs.size() >= 3, "Cannot be a chiral center"); @@ -153,18 +148,18 @@ namespace RDKit { if (cipCode == "S") { // postive chiral volume DistGeom::ChiralSet *cset = new DistGeom::ChiralSet(nbrs[0].second, - nbrs[1].second, - nbrs[2].second, + nbrs[1].second, + nbrs[2].second, nbrs[3].second, - 5.0, 100.0); + 5.0, 100.0); DistGeom::ChiralSetPtr cptr(cset); chiralCenters.push_back(cptr); } else { DistGeom::ChiralSet *cset = new DistGeom::ChiralSet(nbrs[0].second, - nbrs[1].second, - nbrs[2].second, + nbrs[1].second, + nbrs[2].second, nbrs[3].second, - -100.0, -5.0); + -100.0, -5.0); DistGeom::ChiralSetPtr cptr(cset); chiralCenters.push_back(cptr); } @@ -184,7 +179,7 @@ namespace RDKit { } bool _isConfFarFromRest(const ROMol &mol, const Conformer &conf, - double threshold) { + double threshold) { // NOTE: it is tempting to use some triangle inequality to prune // conformations here but some basic testing has shown very // little advantage and given that the time for pruning fades in @@ -217,7 +212,7 @@ namespace RDKit { bool useRandomCoords,double boxSizeMult, bool randNegEig, unsigned int numZeroFail, const std::map *coordMap, - double optimizerForceTol,double basinThresh){ + double optimizerForceTol,double basinThresh){ INT_VECT confIds; confIds=EmbedMultipleConfs(mol,1,maxIterations,seed,clearConfs, useRandomCoords,boxSizeMult,randNegEig, diff --git a/Code/GraphMol/DistGeomHelpers/Jamfile b/Code/GraphMol/DistGeomHelpers/Jamfile index 62b0f973d..be4226a7c 100644 --- a/Code/GraphMol/DistGeomHelpers/Jamfile +++ b/Code/GraphMol/DistGeomHelpers/Jamfile @@ -16,7 +16,7 @@ exe main.exe : testDgeomHelpers.cpp DistGeomHelpers ../../DistGeom//DistGeom ../../Numerics/Optimizer//Optimizer ../../Numerics/EigenSolvers//EigenSolvers ../../Numerics/Alignment//Alignment ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry - ../..//lapacklibs ../..//vflib ; + ../..//lapacklibs ; install regrs : main.exe : testExecs ; diff --git a/Code/GraphMol/DistGeomHelpers/Wrap/testDistGeom.py b/Code/GraphMol/DistGeomHelpers/Wrap/testDistGeom.py index d4db7cbf7..c0b8142f3 100644 --- a/Code/GraphMol/DistGeomHelpers/Wrap/testDistGeom.py +++ b/Code/GraphMol/DistGeomHelpers/Wrap/testDistGeom.py @@ -254,7 +254,6 @@ class TestCase(unittest.TestCase) : conf.GetAtomPosition(3)) self.failUnless(abs(vol-tgtVol)<1,"%s %s"%(vol,tgtVol)) - tgtVol=3.5 expected = [-3.62, -3.67, -3.72, 3.91, 3.95, 3.98, 3.90, 3.94, 3.98, 3.91] nPos=0 diff --git a/Code/GraphMol/FileParsers/Jamfile b/Code/GraphMol/FileParsers/Jamfile index 0b1415a0d..082e12e25 100644 --- a/Code/GraphMol/FileParsers/Jamfile +++ b/Code/GraphMol/FileParsers/Jamfile @@ -39,9 +39,6 @@ exe testMol2ToMol : testMol2ToMol.cpp FileParsers ../SmilesParse//SmilesParse ..//GraphMol ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry ; -lib profiler : : profiler ; - - install regrs : test1 testMolSupplier testMolWriter testTplParser testMol2ToMol : testExecs ; diff --git a/Code/GraphMol/ForceFieldHelpers/Jamfile b/Code/GraphMol/ForceFieldHelpers/Jamfile index 9642f44b3..51b4ca24f 100644 --- a/Code/GraphMol/ForceFieldHelpers/Jamfile +++ b/Code/GraphMol/ForceFieldHelpers/Jamfile @@ -17,7 +17,7 @@ exe testHelpers : testHelpers.cpp ForceFieldHelpers ../../Numerics/EigenSolvers//EigenSolvers ../..//Numerics/Alignment//Alignment ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry - ../..//vflib ; + ; install regrs : testHelpers : testExecs ; diff --git a/Code/GraphMol/ForceFieldHelpers/Wrap/Jamfile b/Code/GraphMol/ForceFieldHelpers/Wrap/Jamfile index 7eeca7477..8e0959b80 100644 --- a/Code/GraphMol/ForceFieldHelpers/Wrap/Jamfile +++ b/Code/GraphMol/ForceFieldHelpers/Wrap/Jamfile @@ -13,7 +13,7 @@ python-extension rdForceFieldHelpers : rdForceFields.cpp ../../../Geometry//RDGeometry ../../../RDGeneral//RDGeneral ../../../DataStructs//DataStructs ../../../RDBoost//RDBoost - ../../..//vflib + ; install pymod : rdForceFieldHelpers diff --git a/Code/GraphMol/FragCatalog/Jamfile b/Code/GraphMol/FragCatalog/Jamfile index ec6223620..04925511f 100644 --- a/Code/GraphMol/FragCatalog/Jamfile +++ b/Code/GraphMol/FragCatalog/Jamfile @@ -15,7 +15,7 @@ exe test1 : test1.cpp FragCatalog ../Substruct//Substruct ../FileParsers//FileParsers ..//GraphMol ../../DataStructs//DataStructs ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry - ../..//lapacklibs ../..//vflib ; + ../..//lapacklibs ; install regrs : test1 : testExecs ; diff --git a/Code/GraphMol/FragCatalog/Wrap/Jamfile b/Code/GraphMol/FragCatalog/Wrap/Jamfile index 179a51f90..b23512dfc 100644 --- a/Code/GraphMol/FragCatalog/Wrap/Jamfile +++ b/Code/GraphMol/FragCatalog/Wrap/Jamfile @@ -14,7 +14,7 @@ python-extension rdfragcatalog : rdfragcatalog.cpp ../../../Geometry//RDGeometry ../../../RDGeneral//RDGeneral ../../../DataStructs//DataStructs ../../../RDBoost//RDBoost - ../../..//vflib ../../..//lapacklibs + ../../..//lapacklibs ; install pymod : rdfragcatalog diff --git a/Code/GraphMol/Jamfile b/Code/GraphMol/Jamfile index 213b84437..3cf7f6f52 100644 --- a/Code/GraphMol/Jamfile +++ b/Code/GraphMol/Jamfile @@ -21,17 +21,18 @@ exe MolOpsTest : molopstest.cpp GraphMol ../RDGeneral//RDGeneral ../Geometry//RDGeometry ; exe testCanon : testCanon.cpp GraphMol ./SmilesParse//SmilesParse ./Substruct//Substruct - ../RDGeneral//RDGeneral ../Geometry//RDGeometry ..//vflib ; + ../RDGeneral//RDGeneral ../Geometry//RDGeometry ; exe testChirality : testChirality.cpp GraphMol ./SmilesParse//SmilesParse ./FileParsers//FileParsers - ../RDGeneral//RDGeneral ../Geometry//RDGeometry ..//vflib ; + ../RDGeneral//RDGeneral ../Geometry//RDGeometry ; exe testPickler : testPickler.cpp GraphMol ./SmilesParse//SmilesParse ./FileParsers//FileParsers ./Substruct//Substruct - ../RDGeneral//RDGeneral ../Geometry//RDGeometry ..//vflib ; + ../RDGeneral//RDGeneral ../Geometry//RDGeometry ; exe itertest : itertest.cpp GraphMol ./SmilesParse//SmilesParse ../RDGeneral//RDGeneral ../Geometry//RDGeometry ; +alias all : all-libraries all-wrappers regrs ; install regrs : test1 cptest querytest MolOpsTest testCanon testChirality testPickler itertest : testExecs ; diff --git a/Code/GraphMol/MolAlign/Jamfile b/Code/GraphMol/MolAlign/Jamfile index c771dd5a5..e2cb71b14 100644 --- a/Code/GraphMol/MolAlign/Jamfile +++ b/Code/GraphMol/MolAlign/Jamfile @@ -17,7 +17,7 @@ exe testMolAlign : testMolAlign.cpp MolAlign ../MolTransforms//MolTransforms ../..//Numerics/Alignment//Alignment ../Substruct//Substruct ..//GraphMol ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry - ../..//vflib ; + ; install regrs : testMolAlign : testExecs ; diff --git a/Code/GraphMol/MolAlign/Wrap/Jamfile b/Code/GraphMol/MolAlign/Wrap/Jamfile index ace34b5a3..72e79c0c5 100644 --- a/Code/GraphMol/MolAlign/Wrap/Jamfile +++ b/Code/GraphMol/MolAlign/Wrap/Jamfile @@ -14,7 +14,7 @@ python-extension rdMolAlign : rdMolAlign.cpp ../../../Geometry//RDGeometry ../../../RDGeneral//RDGeneral ../../../DataStructs//DataStructs ../../../RDBoost//RDBoost - ../../..//vflib + ; install pymod : rdMolAlign diff --git a/Code/GraphMol/MolChemicalFeatures/Jamfile b/Code/GraphMol/MolChemicalFeatures/Jamfile index 05a5e4dd2..e894d1da8 100644 --- a/Code/GraphMol/MolChemicalFeatures/Jamfile +++ b/Code/GraphMol/MolChemicalFeatures/Jamfile @@ -14,7 +14,7 @@ exe testFeatures : testFeatures.cpp MolChemicalFeatures ../Substruct//Substruct ..//GraphMol ../../DataStructs//DataStructs ../../RDGeneral//RDGeneral - ../../Geometry//RDGeometry ../..//vflib + ../../Geometry//RDGeometry ; install regrs : testFeatures diff --git a/Code/GraphMol/MolChemicalFeatures/Wrap/Jamfile b/Code/GraphMol/MolChemicalFeatures/Wrap/Jamfile index 0aec20601..f58065e92 100644 --- a/Code/GraphMol/MolChemicalFeatures/Wrap/Jamfile +++ b/Code/GraphMol/MolChemicalFeatures/Wrap/Jamfile @@ -12,7 +12,7 @@ python-extension rdMolChemicalFeatures : rdMolChemicalFeatures.cpp ../..//GraphMol ../../../Geometry//RDGeometry ../../../RDGeneral//RDGeneral ../../../DataStructs//DataStructs ../../../RDBoost//RDBoost - ../../..//vflib + ; install pymod : rdMolChemicalFeatures diff --git a/Code/GraphMol/QueryAtom.cpp b/Code/GraphMol/QueryAtom.cpp index c6076e94b..d2a564f69 100755 --- a/Code/GraphMol/QueryAtom.cpp +++ b/Code/GraphMol/QueryAtom.cpp @@ -52,17 +52,106 @@ void QueryAtom::expandQuery(QUERYATOM_QUERY *what, } } -// FIX: the const crap here is all mucked up. bool QueryAtom::Match(const Atom::ATOM_SPTR what) const { return Match(what.get()); } + namespace { + bool localMatch(ATOM_EQUALS_QUERY const *q1,ATOM_EQUALS_QUERY const *q2){ + if(q1->getNegation()==q2->getNegation()){ + return q1->getVal()==q2->getVal(); + } else { + return q1->getVal()!=q2->getVal(); + } + } + bool queriesMatch(QueryAtom::QUERYATOM_QUERY const *q1, + QueryAtom::QUERYATOM_QUERY const *q2){ + PRECONDITION(q1,"no q1"); + PRECONDITION(q2,"no q2"); + + static const unsigned int nQueries=18; + static std::string equalityQueries[nQueries]={"AtomRingBondCount","AtomRingSize","AtomMinRingSize","AtomImplicitValence",\ + "AtomExplicitValence","AtomTotalValence","AtomAtomicNum","AtomExplicitDegree",\ + "AtomTotalDegree","AtomHCount","AtomIsAromatic","AtomIsAliphatic","AtomUnsaturated",\ + "AtomMass","AtomFormalCharge","AtomHybridization","AtomInRing","AtomInNRings"}; + + bool res=false; + std::string d1=q1->getDescription(); + std::string d2=q2->getDescription(); + if(d1=="AtomNull"||d2=="AtomNull"){ + res = true; + } else if(d1=="AtomOr"){ + // FIX: handle negation on AtomOr and AtomAnd + for(QueryAtom::QUERYATOM_QUERY::CHILD_VECT_CI iter1=q1->beginChildren();iter1!=q1->endChildren();++iter1){ + if(d2=="AtomOr"){ + for(QueryAtom::QUERYATOM_QUERY::CHILD_VECT_CI iter2=q2->beginChildren();iter2!=q2->endChildren();++iter2){ + if(queriesMatch(iter1->get(),iter2->get())){ + res=true; + break; + } + } + } else { + if(queriesMatch(iter1->get(),q2)) { + res=true; + } + } + if(res) break; + } + } else if(d1=="AtomAnd"){ + res=true; + for(QueryAtom::QUERYATOM_QUERY::CHILD_VECT_CI iter1=q1->beginChildren();iter1!=q1->endChildren();++iter1){ + bool matched=false; + if(d2=="AtomAnd"){ + for(QueryAtom::QUERYATOM_QUERY::CHILD_VECT_CI iter2=q2->beginChildren();iter2!=q2->endChildren();++iter2){ + if(queriesMatch(iter1->get(),iter2->get())){ + matched=true; + break; + } + } + } else { + matched = queriesMatch(iter1->get(),q2); + } + if(!matched){ + res=false; + break; + } + } + // FIX : handle AtomXOr + } else if(d2=="AtomOr"){ + // FIX: handle negation on AtomOr and AtomAnd + for(QueryAtom::QUERYATOM_QUERY::CHILD_VECT_CI iter2=q2->beginChildren();iter2!=q2->endChildren();++iter2){ + if(queriesMatch(q1,iter2->get())) { + res=true; + break; + } + } + } else if(d2=="AtomAnd"){ + res=true; + for(QueryAtom::QUERYATOM_QUERY::CHILD_VECT_CI iter2=q2->beginChildren();iter2!=q2->endChildren();++iter2){ + if(queriesMatch(q1,iter2->get())){ + res=false; + break; + } + } + } else if(d1==d2){ + if(std::find(&equalityQueries[0],&equalityQueries[nQueries],d1)!= &equalityQueries[nQueries]){ + res=localMatch(static_cast(q1), + static_cast(q2)); + } + } else { + } + return res; + } + } //end of local namespace + bool QueryAtom::Match(Atom const *what) const { PRECONDITION(what,"bad query atom"); PRECONDITION(dp_query,"no query set"); - return dp_query->Match(what); + if(!what->hasQuery()){ + return dp_query->Match(what); + } else { + return queriesMatch(dp_query,what->getQuery()); + } } - - }; // end o' namespace diff --git a/Code/GraphMol/QueryBond.cpp b/Code/GraphMol/QueryBond.cpp index ced5b7496..fb62ad567 100755 --- a/Code/GraphMol/QueryBond.cpp +++ b/Code/GraphMol/QueryBond.cpp @@ -58,21 +58,13 @@ void QueryBond::setBondDir(BondDir bD) { // situations, whatever those may be. // d_dirTag = bD; +#if 0 if(dp_query){ delete dp_query; dp_query = 0; } dp_query = makeBondDirEqualsQuery(bD); -} - - -bool QueryBond::Match(const Bond::BOND_SPTR what) const { - return Match(what.get()); -} - -bool QueryBond::Match(Bond const *what) const { - PRECONDITION(dp_query,"no query set"); - return dp_query->Match(what); +#endif } void QueryBond::expandQuery(QUERYBOND_QUERY *what, @@ -106,4 +98,105 @@ void QueryBond::expandQuery(QUERYBOND_QUERY *what, } } +bool QueryBond::Match(const Bond::BOND_SPTR what) const { + return Match(what.get()); +} + + + namespace { + bool localMatch(BOND_EQUALS_QUERY const *q1,BOND_EQUALS_QUERY const *q2){ + if(q1->getNegation()==q2->getNegation()){ + return q1->getVal()==q2->getVal(); + } else { + return q1->getVal()!=q2->getVal(); + } + } + + bool queriesMatch(QueryBond::QUERYBOND_QUERY const *q1, + QueryBond::QUERYBOND_QUERY const *q2){ + PRECONDITION(q1,"no q1"); + PRECONDITION(q2,"no q2"); + + static const unsigned int nQueries=6; + static std::string equalityQueries[nQueries]={"BondRingSize","BondMinRingSize","BondOrder","BondDir",\ + "BondInRing","BondInNRings"}; + + bool res=false; + std::string d1=q1->getDescription(); + std::string d2=q2->getDescription(); + if(d1=="BondNull"||d2=="BondNull"){ + res = true; + } else if(d1=="BondOr"){ + // FIX: handle negation on BondOr and BondAnd + for(QueryBond::QUERYBOND_QUERY::CHILD_VECT_CI iter1=q1->beginChildren();iter1!=q1->endChildren();++iter1){ + if(d2=="BondOr"){ + for(QueryBond::QUERYBOND_QUERY::CHILD_VECT_CI iter2=q2->beginChildren();iter2!=q2->endChildren();++iter2){ + if(queriesMatch(iter1->get(),iter2->get())){ + res=true; + break; + } + } + } else { + if(queriesMatch(iter1->get(),q2)) { + res=true; + } + } + if(res) break; + } + } else if(d1=="BondAnd"){ + res=true; + for(QueryBond::QUERYBOND_QUERY::CHILD_VECT_CI iter1=q1->beginChildren();iter1!=q1->endChildren();++iter1){ + bool matched=false; + if(d2=="BondAnd"){ + for(QueryBond::QUERYBOND_QUERY::CHILD_VECT_CI iter2=q2->beginChildren();iter2!=q2->endChildren();++iter2){ + if(queriesMatch(iter1->get(),iter2->get())){ + matched=true; + break; + } + } + } else { + matched = queriesMatch(iter1->get(),q2); + } + if(!matched){ + res=false; + break; + } + } + // FIX : handle BondXOr + } else if(d2=="BondOr"){ + // FIX: handle negation on BondOr and BondAnd + for(QueryBond::QUERYBOND_QUERY::CHILD_VECT_CI iter2=q2->beginChildren();iter2!=q2->endChildren();++iter2){ + if(queriesMatch(q1,iter2->get())) { + res=true; + break; + } + } + } else if(d2=="BondAnd"){ + res=true; + for(QueryBond::QUERYBOND_QUERY::CHILD_VECT_CI iter2=q2->beginChildren();iter2!=q2->endChildren();++iter2){ + if(queriesMatch(q1,iter2->get())){ + res=false; + break; + } + } + } else if(std::find(&equalityQueries[0],&equalityQueries[nQueries],d1)!= &equalityQueries[nQueries]){ + res=localMatch(static_cast(q1), + static_cast(q2)); + } + return res; + } + } //end of local namespace + +bool QueryBond::Match(Bond const *what) const { + PRECONDITION(dp_query,"no query set"); + if(!what->hasQuery()){ + return dp_query->Match(what); + } else { + return queriesMatch(dp_query,what->getQuery()); + } +} + + + + } // end o' namespace diff --git a/Code/GraphMol/SLNParse/Jamfile b/Code/GraphMol/SLNParse/Jamfile index 3f65340e1..82b81eb62 100644 --- a/Code/GraphMol/SLNParse/Jamfile +++ b/Code/GraphMol/SLNParse/Jamfile @@ -15,7 +15,7 @@ cpp sln.tab.cpp : sln.yy : yysln_ ; exe test : test.cpp SLNParse ..//GraphMol ../SmilesParse//SmilesParse - ../Substruct//Substruct ../..//vflib + ../Substruct//Substruct ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry ; diff --git a/Code/GraphMol/SLNParse/Wrap/Jamfile b/Code/GraphMol/SLNParse/Wrap/Jamfile index a6819fdab..8034f54c0 100644 --- a/Code/GraphMol/SLNParse/Wrap/Jamfile +++ b/Code/GraphMol/SLNParse/Wrap/Jamfile @@ -10,7 +10,6 @@ python-extension rdSLNParse : rdSLNParse.cpp ../..//GraphMol ../../../Geometry//RDGeometry ../../../RDGeneral//RDGeneral ../../../DataStructs//DataStructs ../../../RDBoost//RDBoost -/RDKit//vflib ; install pymod : rdSLNParse diff --git a/Code/GraphMol/ShapeHelpers/Jamfile b/Code/GraphMol/ShapeHelpers/Jamfile index 5c0013dcf..f982927e4 100644 --- a/Code/GraphMol/ShapeHelpers/Jamfile +++ b/Code/GraphMol/ShapeHelpers/Jamfile @@ -15,7 +15,7 @@ exe main : testShapeHelpers.cpp ShapeHelpers ../../Numerics/Alignment//Alignment ..//GraphMol ../../DataStructs//DataStructs ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry - ../..//lapacklibs ../..//vflib + ../..//lapacklibs ; install regrs : main diff --git a/Code/GraphMol/ShapeHelpers/Wrap/Jamfile b/Code/GraphMol/ShapeHelpers/Wrap/Jamfile index bd2df50fa..15e9cadd2 100644 --- a/Code/GraphMol/ShapeHelpers/Wrap/Jamfile +++ b/Code/GraphMol/ShapeHelpers/Wrap/Jamfile @@ -11,7 +11,7 @@ python-extension rdShapeHelpers : rdShapeHelpers.cpp ../../../Numerics/EigenSolvers//EigenSolvers ../../../Geometry//RDGeometry ../../../RDGeneral//RDGeneral ../../../DataStructs//DataStructs ../../../RDBoost//RDBoost -../../..//vflib ../../..//lapacklibs + ../../..//lapacklibs ; install pymod : rdShapeHelpers diff --git a/Code/GraphMol/SmilesParse/Jamfile b/Code/GraphMol/SmilesParse/Jamfile index 24837c2cb..d6993ba02 100644 --- a/Code/GraphMol/SmilesParse/Jamfile +++ b/Code/GraphMol/SmilesParse/Jamfile @@ -7,7 +7,7 @@ local RDBASE = [ os.environ RDBASE ] ; lib SmilesParse : lex.yysmiles.cpp smiles.tab.cpp lex.yysmarts.cpp smarts.tab.cpp InputFiller.cpp SmilesParse.cpp SmilesParseOps.cpp SmilesWrite.cpp SmartsWrite.cpp - ..//GraphMol ../..//RDGeneral//RDGeneral ../../Geometry//RDGeometry ../..//vflib + ..//GraphMol ../..//RDGeneral//RDGeneral ../../Geometry//RDGeometry : . msvc:static msvc:YY_NO_UNISTD_H ; @@ -29,7 +29,7 @@ exe test : test.cpp SmilesParse ..//GraphMol exe smatest : smatest.cpp SmilesParse ..//GraphMol ../Substruct//Substruct ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry - ../..//vflib ; + ; install regrs : test smatest : testExecs ; diff --git a/Code/GraphMol/SmilesParse/smarts.ll b/Code/GraphMol/SmilesParse/smarts.ll index b80a092d8..3e295b700 100755 --- a/Code/GraphMol/SmilesParse/smarts.ll +++ b/Code/GraphMol/SmilesParse/smarts.ll @@ -262,12 +262,10 @@ A { [\\] { yysmarts_lval.bond = new QueryBond(Bond::SINGLE); yysmarts_lval.bond->setBondDir(Bond::ENDDOWNRIGHT); - yysmarts_lval.bond->setQuery(makeBondDirEqualsQuery(Bond::ENDDOWNRIGHT)); return BOND_TOKEN; } [\/] { yysmarts_lval.bond = new QueryBond(Bond::SINGLE); yysmarts_lval.bond->setBondDir(Bond::ENDUPRIGHT); - yysmarts_lval.bond->setQuery(makeBondDirEqualsQuery(Bond::ENDUPRIGHT)); return BOND_TOKEN; } diff --git a/Code/GraphMol/SmilesParse/smatest.cpp b/Code/GraphMol/SmilesParse/smatest.cpp index f26019be2..5e59dab59 100755 --- a/Code/GraphMol/SmilesParse/smatest.cpp +++ b/Code/GraphMol/SmilesParse/smatest.cpp @@ -1146,6 +1146,20 @@ void testMiscSmartsWriting(){ BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } +void testSmartsStereochem(){ + BOOST_LOG(rdInfoLog) << "-------------------------------------" << std::endl; + BOOST_LOG(rdInfoLog) << "Testing handling (or lack thereof) of stereochem in smarts (sf.net issue 2738320)" << std::endl; + + _checkMatches("C/C=C/C", "CC=CC", 1, 4); + _checkMatches("C/C=C/C", "C/C=C/C", 1, 4); + _checkMatches("C/C=C/C", "C\\C=C\\C", 1, 4); + _checkMatches("C/C=C/C", "C/C=C\\C", 1, 4); + + BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; +} + + + int main(int argc, char *argv[]) { @@ -1174,5 +1188,6 @@ main(int argc, char *argv[]) testIssue1914154(); testMiscSmartsWriting(); //testIssue1804420(); + testSmartsStereochem(); return 0; } diff --git a/Code/GraphMol/Substruct/Jamfile b/Code/GraphMol/Substruct/Jamfile index 6cd3affec..0373a1b97 100644 --- a/Code/GraphMol/Substruct/Jamfile +++ b/Code/GraphMol/Substruct/Jamfile @@ -4,13 +4,13 @@ local RDBASE = [ os.environ RDBASE ] ; lib Substruct : SubstructMatch.cpp SubstructUtils.cpp - ..//GraphMol ../..//RDGeneral//RDGeneral ../..//vflib + ..//GraphMol ../..//RDGeneral//RDGeneral : msvc:static ; #static ; install lib-install : Substruct : $(RDBASE)/bin ; exe test1 : test1.cpp Substruct ..//GraphMol ../../RDGeneral//RDGeneral ../../Geometry//RDGeometry - ../..//vflib + ; install regrs : test1 diff --git a/Code/GraphMol/Wrap/MolOps.cpp b/Code/GraphMol/Wrap/MolOps.cpp index 0bc5b2fbf..e77477ff8 100755 --- a/Code/GraphMol/Wrap/MolOps.cpp +++ b/Code/GraphMol/Wrap/MolOps.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -49,6 +50,34 @@ namespace RDKit{ return res; } + void addRecursiveQuery(ROMol &mol, + const ROMol &query, + unsigned int atomIdx, + bool preserveExistingQuery){ + if(atomIdx>=mol.getNumAtoms()){ + throw_value_error("atom index exceeds mol.GetNumAtoms()"); + } + RecursiveStructureQuery *q = new RecursiveStructureQuery(new ROMol(query)); + + Atom *oAt=mol.getAtomWithIdx(atomIdx); + if(!oAt->hasQuery()){ + QueryAtom qAt(*oAt); + static_cast(mol).replaceAtom(atomIdx,&qAt); + oAt = mol.getAtomWithIdx(atomIdx); + } + + + if(!preserveExistingQuery){ + // FIX: this leaks a query atom on oAt + oAt->setQuery(q); + } else { + oAt->expandQuery(q,Queries::COMPOSITE_AND); + } + + } + + + void sanitizeMol(ROMol &mol) { RWMol &wmol = static_cast(mol); MolOps::sanitizeMol(wmol); @@ -370,7 +399,7 @@ namespace RDKit{ docString.c_str()); // ------------------------------------------------------------------------ - docString="Returns the molecule's distance matrix.\n\ + docString="Returns the molecule's topological distance matrix.\n\ \n\ ARGUMENTS:\n\ \n\ @@ -845,6 +874,28 @@ namespace RDKit{ docString.c_str(), python::return_value_policy()); + // ------------------------------------------------------------------------ + docString="Adds a recursive query to an atom\n\ +\n\ + ARGUMENTS:\n\ +\n\ + - mol: the molecule to be modified\n\ +\n\ + - query: the molecule to be used as the recursive query (this will be copied)\n\ +\n\ + - atomIdx: the atom to modify\n\ +\n\ + - preserveExistingQuery: (optional) if this is set, existing query information on the atom will be preserved\n\ +\n\ + RETURNS: None\n\ +\n"; + python::def("AddRecursiveQuery", addRecursiveQuery, + (python::arg("mol"),python::arg("query"), + python::arg("atomIdx"),python::arg("preserveExistingQuery")=true), + docString.c_str()); + + + }; }; } diff --git a/Code/GraphMol/Wrap/rough_test.py b/Code/GraphMol/Wrap/rough_test.py index e0dcb8585..939ce7300 100755 --- a/Code/GraphMol/Wrap/rough_test.py +++ b/Code/GraphMol/Wrap/rough_test.py @@ -391,9 +391,9 @@ class TestCase(unittest.TestCase): self.failUnless(m2.GetNumAtoms()==5) m2 = Chem.RemoveHs(m2) self.failUnless(m2.GetNumAtoms()==4) + m = Chem.MolFromSmiles('CC[H]',False) self.failUnless(m.GetNumAtoms()==3) - print 'merge' m2 = Chem.MergeQueryHs(m) self.failUnless(m2.GetNumAtoms()==2) self.failUnless(m2.GetAtomWithIdx(1).HasQuery()) @@ -1909,6 +1909,37 @@ CAS<~> sdSup = Chem.CompressedSDMolSupplier(fileN, 0) for mol in sdSup : self.failUnless(not mol.HasProp("numArom")) + + def test57AddRecursiveQuery(self): + q1 = Chem.MolFromSmiles('CC') + q2 = Chem.MolFromSmiles('CO') + Chem.AddRecursiveQuery(q1,q2,1) + + m1 = Chem.MolFromSmiles('OCC') + self.failUnless(m1.HasSubstructMatch(q2)) + self.failUnless(m1.HasSubstructMatch(q1)) + self.failUnless(m1.HasSubstructMatch(q1)) + self.failUnless(m1.GetSubstructMatch(q1)==(2,1)) + + q3 = Chem.MolFromSmiles('CS') + Chem.AddRecursiveQuery(q1,q3,1) + + self.failIf(m1.HasSubstructMatch(q3)) + self.failIf(m1.HasSubstructMatch(q1)) + + m2 = Chem.MolFromSmiles('OC(S)C') + self.failUnless(m2.HasSubstructMatch(q1)) + self.failUnless(m2.GetSubstructMatch(q1)==(3,1)) + + m3 = Chem.MolFromSmiles('SCC') + self.failUnless(m3.HasSubstructMatch(q3)) + self.failIf(m3.HasSubstructMatch(q1)) + + q1 = Chem.MolFromSmiles('CC') + Chem.AddRecursiveQuery(q1,q2,1) + Chem.AddRecursiveQuery(q1,q3,1,False) + self.failUnless(m3.HasSubstructMatch(q1)) + self.failUnless(m3.GetSubstructMatch(q1)==(2,1)) if __name__ == '__main__': unittest.main() diff --git a/Code/GraphMol/querytest.cpp b/Code/GraphMol/querytest.cpp index 85c580b12..a50dc2866 100755 --- a/Code/GraphMol/querytest.cpp +++ b/Code/GraphMol/querytest.cpp @@ -330,7 +330,184 @@ void test6(){ massVal=queryAtomMass(a); TEST_ASSERT(massVal==static_cast(RDKit::round(13.000*massIntegerConversionFactor))); + BOOST_LOG(rdErrorLog) << "Done!" << std::endl; +} + + +void testQueryQueryMatches(){ + BOOST_LOG(rdInfoLog) << "-------------------------------------" << std::endl; + BOOST_LOG(rdInfoLog) << "Testing query--query matches" << std::endl; + + // ===================================== + // ATOMS + // ===================================== + { + QueryAtom a1,a2; + a1.setQuery(makeAtomNullQuery()); + a2.setQuery(makeAtomNullQuery()); + TEST_ASSERT(a1.Match(&a2)); + TEST_ASSERT(a2.Match(&a1)); + } + + { + QueryAtom a1,a2(6); + a1.setQuery(makeAtomNullQuery()); + TEST_ASSERT(a1.Match(&a2)); + TEST_ASSERT(a2.Match(&a1)); + } + + { + QueryAtom a1(6),a2(8); + TEST_ASSERT(!a1.Match(&a2)); + TEST_ASSERT(!a2.Match(&a1)); + } + + { + QueryAtom a1(6),a2(6); + TEST_ASSERT(a1.Match(&a2)); + TEST_ASSERT(a2.Match(&a1)); + } + + { + QueryAtom a1,a2; + a1.setQuery(makeAtomAromaticQuery()); + a2.setQuery(makeAtomAromaticQuery()); + TEST_ASSERT(a1.Match(&a2)); + TEST_ASSERT(a2.Match(&a1)); + } + + { + QueryAtom a1,a2; + a1.setQuery(makeAtomAromaticQuery()); + a2.setQuery(makeAtomAliphaticQuery()); + TEST_ASSERT(!a1.Match(&a2)); + TEST_ASSERT(!a2.Match(&a1)); + } + + { + QueryAtom a1(6),a2(8); + a1.expandQuery(makeAtomNumEqualsQuery(8),Queries::COMPOSITE_OR); + a2.expandQuery(makeAtomNumEqualsQuery(9),Queries::COMPOSITE_OR); + TEST_ASSERT(a1.Match(&a2)); + TEST_ASSERT(a2.Match(&a1)); + } + + { + QueryAtom a1(6),a2(8); + a1.expandQuery(makeAtomNumEqualsQuery(7),Queries::COMPOSITE_OR); + a2.expandQuery(makeAtomNumEqualsQuery(9),Queries::COMPOSITE_OR); + TEST_ASSERT(!a1.Match(&a2)); + TEST_ASSERT(!a2.Match(&a1)); + } + + { + QueryAtom a1(6),a2(6); + a1.expandQuery(makeAtomExplicitValenceQuery(3),Queries::COMPOSITE_AND); + a2.expandQuery(makeAtomExplicitValenceQuery(3),Queries::COMPOSITE_AND); + TEST_ASSERT(a1.Match(&a2)); + TEST_ASSERT(a2.Match(&a1)); + } + + { + QueryAtom a1(6),a2(6); + a1.expandQuery(makeAtomExplicitValenceQuery(3),Queries::COMPOSITE_AND); + a2.expandQuery(makeAtomExplicitValenceQuery(4),Queries::COMPOSITE_AND); + TEST_ASSERT(!a1.Match(&a2)); + TEST_ASSERT(!a2.Match(&a1)); + } + + { + QueryAtom a1(6),a2(8); + a1.expandQuery(makeAtomExplicitValenceQuery(3),Queries::COMPOSITE_AND); + a2.expandQuery(makeAtomExplicitValenceQuery(3),Queries::COMPOSITE_AND); + TEST_ASSERT(!a1.Match(&a2)); + TEST_ASSERT(!a2.Match(&a1)); + } + + { + QueryAtom a1(6),a2(8); + a1.expandQuery(makeAtomNumEqualsQuery(8),Queries::COMPOSITE_OR); + TEST_ASSERT(a1.Match(&a2)); + TEST_ASSERT(a2.Match(&a1)); + } + + // ===================================== + // BONDS + // ===================================== + { + QueryBond a1,a2; + a1.setQuery(makeBondNullQuery()); + a2.setQuery(makeBondNullQuery()); + TEST_ASSERT(a1.Match(&a2)); + TEST_ASSERT(a2.Match(&a1)); + } + + { + QueryBond a1,a2(Bond::SINGLE); + a1.setQuery(makeBondNullQuery()); + TEST_ASSERT(a1.Match(&a2)); + TEST_ASSERT(a2.Match(&a1)); + } + + { + QueryBond a1(Bond::SINGLE),a2(Bond::SINGLE); + TEST_ASSERT(a1.Match(&a2)); + TEST_ASSERT(a2.Match(&a1)); + } + + { + QueryBond a1(Bond::SINGLE),a2(Bond::DOUBLE); + TEST_ASSERT(!a1.Match(&a2)); + TEST_ASSERT(!a2.Match(&a1)); + } + + { + QueryBond a1(Bond::SINGLE),a2(Bond::DOUBLE); + a1.expandQuery(makeBondOrderEqualsQuery(Bond::DOUBLE),Queries::COMPOSITE_OR); + a2.expandQuery(makeBondOrderEqualsQuery(Bond::AROMATIC),Queries::COMPOSITE_OR); + TEST_ASSERT(a1.Match(&a2)); + TEST_ASSERT(a2.Match(&a1)); + } + + { + QueryBond a1(Bond::SINGLE),a2(Bond::DOUBLE); + a1.expandQuery(makeBondOrderEqualsQuery(Bond::TRIPLE),Queries::COMPOSITE_OR); + a2.expandQuery(makeBondOrderEqualsQuery(Bond::AROMATIC),Queries::COMPOSITE_OR); + TEST_ASSERT(!a1.Match(&a2)); + TEST_ASSERT(!a2.Match(&a1)); + } + + { + QueryBond a1(Bond::SINGLE),a2(Bond::DOUBLE); + a1.expandQuery(makeBondMinRingSizeQuery(4),Queries::COMPOSITE_OR); + a2.expandQuery(makeBondMinRingSizeQuery(4),Queries::COMPOSITE_OR); + TEST_ASSERT(a1.Match(&a2)); + TEST_ASSERT(a2.Match(&a1)); + } + + { + QueryBond a1(Bond::SINGLE),a2(Bond::DOUBLE); + a1.expandQuery(makeBondMinRingSizeQuery(4),Queries::COMPOSITE_AND); + a2.expandQuery(makeBondMinRingSizeQuery(4),Queries::COMPOSITE_AND); + TEST_ASSERT(!a1.Match(&a2)); + TEST_ASSERT(!a2.Match(&a1)); + } + + { + QueryBond a1(Bond::SINGLE),a2(Bond::SINGLE); + a1.expandQuery(makeBondMinRingSizeQuery(5),Queries::COMPOSITE_AND); + a2.expandQuery(makeBondMinRingSizeQuery(4),Queries::COMPOSITE_AND); + TEST_ASSERT(!a1.Match(&a2)); + TEST_ASSERT(!a2.Match(&a1)); + } + + { + QueryBond a1(Bond::SINGLE),a2(Bond::AROMATIC); + a1.expandQuery(makeBondOrderEqualsQuery(Bond::AROMATIC),Queries::COMPOSITE_OR); + TEST_ASSERT(a1.Match(&a2)); + TEST_ASSERT(a2.Match(&a1)); + } BOOST_LOG(rdErrorLog) << "Done!" << std::endl; } @@ -344,5 +521,8 @@ int main(){ test4(); test5(); test6(); + testQueryQueryMatches(); + + return 0; } diff --git a/Code/Jamroot b/Code/Jamroot index 314c659a2..7a04f7d7f 100644 --- a/Code/Jamroot +++ b/Code/Jamroot @@ -17,16 +17,13 @@ use-project RDKit_Externals project RDKit : requirements . multi $(BOOSTHOME) - $(RDBASE)/External/Lapack++/include - $(RDBASE)/External/vflib-2.0/include - #USE_VFLIB gcc:-Wno-unused-function gcc:-Wno-deprecated darwin:-Wno-unused-function gcc:-fno-strict-aliasing msvc:WIN32 - /usr/lib/python2.5/site-packages/numpy-1.2.1-py2.5-linux-i686.egg/numpy/core/include - 64:-fPIC + MISSING + 64:-fPIC # RDK_USELAPACKPP #<- uncomment this to use lapack++ windows:BOOST_NUMERIC_BINDINGS_USE_CLAPACK msvc:_CRT_SECURE_NO_DEPRECATE @@ -35,7 +32,10 @@ project RDKit alias all-libraries : Catalogs DistGeom ForceField DataManip/MetricMatrixCalc DataStructs Geometry Query RDBoost RDGeneral Numerics SimDivPickers ChemicalFeatures GraphMol ; +alias all : all-libraries all-wrappers ; +alias minimal : DistGeom ForceField DataStructs Geometry Query RDGeneral Numerics ChemicalFeatures GraphMol//minimal +; alias all-wrappers : RDBoost/Wrap DataStructs/Wrap @@ -83,6 +83,5 @@ lib blas # if you want to use Lapack++, use this version: #alias lapacklibs : /RDKit_Externals//Lapack++ lapack blas ; alias lapacklibs : lapack blas ; -alias vflib : /RDKit_Externals//vflib ; diff --git a/Code/Jamroot.in b/Code/Jamroot.in index 3c06c4363..cbf735247 100644 --- a/Code/Jamroot.in +++ b/Code/Jamroot.in @@ -17,8 +17,6 @@ use-project RDKit_Externals project RDKit : requirements . multi $(BOOSTHOME) - $(RDBASE)/External/vflib-2.0/include - #USE_VFLIB gcc:-Wno-unused-function gcc:-Wno-deprecated darwin:-Wno-unused-function @@ -34,6 +32,7 @@ project RDKit alias all-libraries : Catalogs DistGeom ForceField DataManip/MetricMatrixCalc DataStructs Geometry Query RDBoost RDGeneral Numerics SimDivPickers ChemicalFeatures GraphMol ; +alias all : all-libraries all-wrappers ; alias minimal : DistGeom ForceField DataStructs Geometry Query RDGeneral Numerics ChemicalFeatures GraphMol//minimal ; @@ -84,5 +83,4 @@ lib blas # if you want to use Lapack++, use this version: #alias lapacklibs : /RDKit_Externals//Lapack++ lapack blas ; alias lapacklibs : lapack blas ; -alias vflib : /RDKit_Externals//vflib ;