diff --git a/.travis.yml b/.travis.yml index 3bd09f373..c3f7b6658 100644 --- a/.travis.yml +++ b/.travis.yml @@ -73,4 +73,6 @@ script: - make -j2 - make install - - ctest --output-on-failure + - ls "$PREFIX/lib" + - ls "$PY_PREFIX/lib" + - LD_LIBRARY_PATH="$PY_PREFIX/lib:$PREFIX/lib;$SRC_DIR/lib;$LD_LIBRARY_PATH" ctest --output-on-failure diff --git a/Code/GraphMol/FilterCatalog/CMakeLists.txt b/Code/GraphMol/FilterCatalog/CMakeLists.txt index fcd626064..d6ce021df 100644 --- a/Code/GraphMol/FilterCatalog/CMakeLists.txt +++ b/Code/GraphMol/FilterCatalog/CMakeLists.txt @@ -26,7 +26,7 @@ rdkit_library(FilterCatalog FilterCatalog.cpp FilterCatalogEntry.cpp FilterMatchers.cpp - LINK_LIBRARIES ${Boost_SERIALIZATION_LIBRARY} Subgraphs SubstructMatch SmilesParse GraphMol RDGeometryLib Catalogs RDGeneral ) + LINK_LIBRARIES Subgraphs SubstructMatch SmilesParse GraphMol RDGeometryLib Catalogs RDGeneral ) rdkit_headers(FilterCatalogEntry.h FilterCatalog.h @@ -37,5 +37,6 @@ rdkit_headers(FilterCatalogEntry.h add_subdirectory(Wrap) rdkit_test(filterCatalogTest filtercatalogtest.cpp - LINK_LIBRARIES ${Boost_SERIALIZATION_LIBRARY} FilterCatalog - Catalogs SubstructMatch FileParsers SmilesParse GraphMol RDGeometryLib RDGeneral) + LINK_LIBRARIES FilterCatalog + Catalogs SubstructMatch FileParsers SmilesParse GraphMol RDGeometryLib RDGeneral + ${Boost_SERIALIZATION_LIBRARY}) diff --git a/Code/GraphMol/FilterCatalog/FilterCatalog.cpp b/Code/GraphMol/FilterCatalog/FilterCatalog.cpp index da15232d3..54fa74b33 100644 --- a/Code/GraphMol/FilterCatalog/FilterCatalog.cpp +++ b/Code/GraphMol/FilterCatalog/FilterCatalog.cpp @@ -138,7 +138,11 @@ namespace RDKit } unsigned int FilterCatalog::addEntry(entryType_t *entry, bool updateFPLength) { - d_entries.push_back(boost::shared_ptr(entry)); + return addEntry(boost::shared_ptr(entry)); + } + + unsigned int FilterCatalog::addEntry(SENTRY entry, bool updateFPLength) { + d_entries.push_back(entry); return static_cast(d_entries.size() - 1); } @@ -199,19 +203,18 @@ namespace RDKit return getFirstMatch(mol) != 0; } - boost::shared_ptr - FilterCatalog::getFirstMatch(const ROMol &mol) const { + FilterCatalog::CONST_SENTRY FilterCatalog::getFirstMatch(const ROMol &mol) const { for( size_t i=0; ihasFilterMatch(mol)) return d_entries[i]; } - return boost::shared_ptr(); + return CONST_SENTRY(); } - const std::vector > + const std::vector FilterCatalog::getMatches(const ROMol &mol) const { - std::vector > result; + std::vector result; for( size_t i=0; ihasFilterMatch(mol)) diff --git a/Code/GraphMol/FilterCatalog/FilterCatalog.h b/Code/GraphMol/FilterCatalog/FilterCatalog.h index cd938a1f7..e7e4daf19 100644 --- a/Code/GraphMol/FilterCatalog/FilterCatalog.h +++ b/Code/GraphMol/FilterCatalog/FilterCatalog.h @@ -113,14 +113,20 @@ namespace RDKit { { public: // syntactic sugar for getMatch(es) return values. - typedef boost::shared_ptr SENTRY; - typedef boost::shared_ptr CONST_SENTRY; + typedef boost::shared_ptr SENTRY; + typedef boost::shared_ptr CONST_SENTRY; FilterCatalog() : FCatalog(), d_entries() { } - FilterCatalog(const paramType_t ¶ms) : FCatalog(), d_entries() { + FilterCatalog(FilterCatalogParams::FilterCatalogs catalogs) : + FCatalog(), d_entries() { + setCatalogParams(new paramType_t(catalogs)); + } + + + FilterCatalog(const FilterCatalogParams ¶ms) : FCatalog(), d_entries() { setCatalogParams(new paramType_t(params)); } @@ -142,7 +148,18 @@ namespace RDKit { \param updateFPLength unused in the FilterCatalog object. */ - virtual unsigned int addEntry(entryType_t *entry, bool updateFPLength = true); + virtual unsigned int addEntry(FilterCatalogEntry *entry, bool updateFPLength = true); + + // Adds a new FilterCatalogEntry to the catalog + /*! + Adds a new FilterCatalogEntry to the catalog The catalog + owns the entry + + \param entry The shared_ptr of the FilterCatalogEntry to add. + \param updateFPLength unused in the FilterCatalog object. + */ + + virtual unsigned int addEntry(SENTRY entry, bool updateFPLength = true); // Removes a FilterCatalogEntry to the catalog by description /*! @@ -159,7 +176,7 @@ namespace RDKit { //------------------------------------ //! returns a particular FilterCatalogEntry in the Catalog //! required by Catalog.h API - virtual const entryType_t* getEntryWithIdx(unsigned int idx) const; + virtual const FilterCatalogEntry* getEntryWithIdx(unsigned int idx) const; //------------------------------------ //! returns a particular FilterCatalogEntry in the Catalog @@ -169,7 +186,7 @@ namespace RDKit { //------------------------------------ //! returns the idx of the given entry, UINT_MAX if not found. - unsigned int getIdxForEntry(const entryType_t*entry) const; + unsigned int getIdxForEntry(const FilterCatalogEntry *entry) const; unsigned int getIdxForEntry(const CONST_SENTRY &entry) const; //------------------------------------ @@ -181,7 +198,7 @@ namespace RDKit { /* \param params The new FilterCatalogParams specifying the new state of the catalog */ - virtual void setCatalogParams(paramType_t *params); + virtual void setCatalogParams(FilterCatalogParams *params); //------------------------------------ //! Returns true if the molecule matches any entry in the catalog @@ -202,11 +219,11 @@ namespace RDKit { /* \param mol ROMol to match against the catalog */ - const std::vector getMatches(const ROMol &mol) const; + const std::vector getMatches(const ROMol &mol) const; private: void Clear(); - std::vector > d_entries; + std::vector d_entries; }; bool FilterCatalogCanSerialize(); diff --git a/Code/GraphMol/FilterCatalog/FilterCatalogEntry.h b/Code/GraphMol/FilterCatalog/FilterCatalogEntry.h index 6273dc274..7a51ed29b 100644 --- a/Code/GraphMol/FilterCatalog/FilterCatalogEntry.h +++ b/Code/GraphMol/FilterCatalog/FilterCatalogEntry.h @@ -268,7 +268,10 @@ namespace RDKit #endif }; } -BOOST_CLASS_VERSION(RDKit::FilterCatalogEntry, 1) + +#ifdef RDK_USE_BOOST_SERIALIZATION +BOOST_CLASS_VERSION(RDKit::FilterCatalogEntry, 1); +#endif #endif //__RD_FILTER_CATALOG_H__ diff --git a/Code/GraphMol/FilterCatalog/FilterMatcherBase.h b/Code/GraphMol/FilterCatalog/FilterMatcherBase.h index 5cc52d59d..2bc258404 100644 --- a/Code/GraphMol/FilterCatalog/FilterMatcherBase.h +++ b/Code/GraphMol/FilterCatalog/FilterMatcherBase.h @@ -31,7 +31,7 @@ #ifndef __RD_FILTER_MATCHER_BASE_H__ #define __RD_FILTER_MATCHER_BASE_H__ #include -#include "FilterMatcherBase.h" +#include #include #include #include diff --git a/Code/GraphMol/FilterCatalog/Wrap/CMakeLists.txt b/Code/GraphMol/FilterCatalog/Wrap/CMakeLists.txt index 98109f080..1fccb6c17 100644 --- a/Code/GraphMol/FilterCatalog/Wrap/CMakeLists.txt +++ b/Code/GraphMol/FilterCatalog/Wrap/CMakeLists.txt @@ -12,9 +12,10 @@ rdkit_python_extension(rdfiltercatalog FilterCatalog.cpp DEST Chem LINK_LIBRARIES - ${Boost_SERIALIZATION_LIBRARY} FilterCatalog -Subgraphs SubstructMatch SmilesParse Catalogs FileParsers GraphMol DataStructs RDGeometryLib RDGeneral - RDBoost) +Subgraphs SubstructMatch SmilesParse Catalogs FileParsers GraphMol DataStructs +RDGeometryLib RDGeneral RDBoost +${Boost_SERIALIZATION_LIBRARY} +) add_pytest(pyFilterCatalog ${CMAKE_CURRENT_SOURCE_DIR}/rough_test.py) diff --git a/Code/GraphMol/FilterCatalog/Wrap/FilterCatalog.cpp b/Code/GraphMol/FilterCatalog/Wrap/FilterCatalog.cpp index 7f817f620..fd677b84e 100644 --- a/Code/GraphMol/FilterCatalog/Wrap/FilterCatalog.cpp +++ b/Code/GraphMol/FilterCatalog/Wrap/FilterCatalog.cpp @@ -419,6 +419,7 @@ namespace RDKit{ python::init<>()) .def(python::init()) .def(python::init()) + .def(python::init()) .def("Serialize", &FilterCatalog_Serialize) .def("AddEntry", &filter_catalog_add_entry, (python::args("entry"), python::args("updateFPLength")=false), diff --git a/Code/GraphMol/FilterCatalog/Wrap/rough_test.py b/Code/GraphMol/FilterCatalog/Wrap/rough_test.py index 834f69813..813935e39 100644 --- a/Code/GraphMol/FilterCatalog/Wrap/rough_test.py +++ b/Code/GraphMol/FilterCatalog/Wrap/rough_test.py @@ -132,14 +132,15 @@ class TestCase(unittest.TestCase): print ("Testing:", catalog_idx, int(catalog_idx)) self.assertTrue(params.AddCatalog(catalog_idx)) catalog1 = FilterCatalog.FilterCatalog(params) - + if FilterCatalog.FilterCatalogCanSerialize(): pickle = catalog1.Serialize(); catalog2 = FilterCatalog.FilterCatalog(pickle) catalogs = [catalog1, catalog2] else: catalogs = [catalog1] - + + catalogs.append( FilterCatalog.FilterCatalog(catalog_idx) ) for index,catalog in enumerate(catalogs): self.assertEqual(catalog.GetNumEntries(),num) diff --git a/Code/JavaWrappers/CMakeLists.txt b/Code/JavaWrappers/CMakeLists.txt index ab9f6906a..f97a2bcb2 100644 --- a/Code/JavaWrappers/CMakeLists.txt +++ b/Code/JavaWrappers/CMakeLists.txt @@ -1,12 +1,24 @@ find_package(SWIG REQUIRED) include(${SWIG_USE_FILE}) +set(T_LIBS ${Boost_LIBRARIES}) +find_package(Boost 1.39.0 COMPONENTS serialization) +if (Boost_SERIALIZATION_LIBRARY) + # don't add the boost serialization definitions, swig can't compile the + # headers. Hopefully it will stil link and run... + set(Boost_LIBRARIES ${T_LIBS} ${Boost_LIBRARIES}) +else() +endif() + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) SET(CMAKE_SWIG_FLAGS "") if(WIN32) set(RDKit_Wrapper_Libs + FilterCatalog + Catalogs + ${Boost_SERIALIZATION_LIBRARY} FMCS MolDraw2D FileParsers SmilesParse Depictor SubstructMatch ChemReactions Fingerprints ChemTransforms @@ -27,6 +39,9 @@ if(WIN32) endif(RDK_BUILD_AVALON_SUPPORT) else() set(RDKit_Wrapper_Libs + Catalogs_static + FilterCatalog_static + ${Boost_SERIALIZATION_LIBRARY} FMCS_static MolDraw2D_static FileParsers_static SmilesParse_static Depictor_static SubstructMatch_static ChemReactions_static Fingerprints_static ChemTransforms_static diff --git a/Code/JavaWrappers/FilterCatalog.i b/Code/JavaWrappers/FilterCatalog.i new file mode 100644 index 000000000..e6c5dc6bb --- /dev/null +++ b/Code/JavaWrappers/FilterCatalog.i @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2015, Novartis Institutes for BioMedical Research Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Novartis Institutes for BioMedical Research Inc. + * nor the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +//%import "ROMol.i" +%include "std_string.i" +%include "std_vector.i" + + +%{ +#include <../RDGeneral/Dict.h> +#include <../Catalogs/Catalog.h> +#include <../Catalogs/CatalogParams.h> +#include +#include +#include + + // bug fix for swig, it removes these from their namespaces + typedef RDCatalog::Catalog::paramType_t paramType_t; + typedef RDCatalog::Catalog::entryType_t entryType_t; + typedef std::vector STR_VECT; + +%} + +%template(FilterCatalogEntry_Vect) std::vector< boost::shared_ptr >; +%template(FilterCatalogEntryVect) std::vector< const RDKit::FilterCatalogEntry* >; +%template(UChar_Vect) std::vector; + +%include "enums.swg" + +%include <../RDGeneral/Dict.h> +%include <../Catalogs/Catalog.h> +%include <../Catalogs/CatalogParams.h> +%include + + +%typemap(javacode) RDKit::FilterCatalog %{ + public static FilterCatalog Deserialize(byte[] b) { + UChar_Vect vec = new UChar_Vect(); + vec.reserve(b.length); + for (int size=0;sizegetProp(key, res); + return res; + } + } + +%extend RDKit::FilterCatalog { + FilterCatalog(const std::vector & data ) { + std::string str(data.begin(), data.end()); + return new RDKit::FilterCatalog(str); + } + + bool canSerialize() const { + return RDKit::FilterCatalogCanSerialize(); + } + + // boost does a bad job of wrapping shared_ptr so we will do the + // unthinkable and cast away const. + // Also we can't use FilterCatalog::SENTRY because swig thinks it is a new + // type. Bad swig! + boost::shared_ptr getFirstMatch(const ROMol &mol) { + RDKit::FilterCatalog::CONST_SENTRY res = self->getFirstMatch(mol); + return boost::const_pointer_cast(res); + } + + std::vector > getMatches(const ROMol &mol) { + std::vector matches = self->getMatches(mol); + std::vector res; + res.reserve(matches.size()); + for (size_t i=0; i< matches.size(); ++i) { + res.push_back( boost::const_pointer_cast(matches[i]) ); + } + return res; + } + + // re-wrap swig is making duplicate entries for some strange reason + unsigned int addEntry(boost::shared_ptr entry) { + return self->addEntry(entry); + } + + bool removeEntry(boost::shared_ptr entry) { + return self->removeEntry(entry); + } + + // swig const-ptr shenanigans again + boost::shared_ptr getEntry(unsigned int idx) const { + return boost::const_pointer_cast( + self->getEntry(idx)); + } + + unsigned int getIdxForEntry(const boost::shared_ptr &entry) const { + return self->getIdxForEntry(entry); + } +} + +%ignore RDKit::FilterCatalog(const std::string &); +%ignore RDKit::FilterCatalog::getFirstMatch; +%ignore RDKit::FilterCatalog::getMatches; +%ignore RDKit::FilterCatalog::addEntry; +%ignore RDKit::FilterCatalog::removeEntry; +%ignore RDKit::FilterCatalog::setCatalogParams; +%ignore RDKit::FilterCatalog::getIdxForEntry; +%ignore RDKit::FilterCatalog::getEntryWithIdx; + + +//%ignore RDKit::FilterCatalogEntry::getPropList; +%ignore RDKit::Dict::getPropList; + + +%typemap(jni) std::string RDKit::FilterCatalog::Serialize "jbyteArray" +%typemap(jtype) std::string RDKit::FilterCatalog::Serialize "byte[]" +%typemap(jstype) std::string RDKit::FilterCatalog::Serialize "byte[]" +%typemap(javaout) std::string RDKit::FilterCatalog::Serialize { + return $jnicall; +} +%typemap(out) std::string RDKit::FilterCatalog::Serialize { + $result = JCALL1(NewByteArray, jenv, $1.size()); + JCALL4(SetByteArrayRegion, jenv, $result, 0, $1.size(), (const jbyte*)$1.c_str()); +} + +%include +%include +%include + + + +%pragma(java) modulecode=%{ + public static FilterCatalog FilterCatalogDeserialize(byte[] b) { + UChar_Vect vec = new UChar_Vect(); + vec.reserve(b.length); + for (int size=0;size +Paramter Class for initializing a FilterCatalog with the specified set of FilterCatalogs. Current +catalogs include: + +

+  FilterCatalogParams.FilterCatalogs.ALL
+  FilterCatalogParams.FilterCatalogs.BRENK
+  FilterCatalogParams.FilterCatalogs.PAINS_A
+  FilterCatalogParams.FilterCatalogs.PAINS_B
+  FilterCatalogParams.FilterCatalogs.PAINS_C
+  FilterCatalogParams.FilterCatalogs.PAINS
+  FilterCatalogParams.FilterCatalogs.ZINC
+
+ +Details: + +

Brenk

+
    +
  • Reference: Brenk Lessons Learnt from Assembling Screening Libraries for Drug Discovery for Neglected Diseases
  • +
  • Scope: unwanted functionality due to potential tox reasons or unfavourable pharmacokinetic properties
  • +
+ +

NIH

+
    +
  • Reference: NIH A Unified Lead-oriented Synthesis of over Fifty Molecular Scaffolds.
  • +
  • Reference: NIH Quantitative Analyses of Aggregation, Autofluorescence, and Reactivity Artifacts in a Screen for Inhibitors of a Thiol Protease
  • +
  • Scope: uannotate compounds with problematic functional groups
  • +
+ +

PAINS

+
    +
  • Reference: NIH New Substructure Filters for Removal of Pan Assay Interference Compounds (PAINS) from Screening Libraries and for Their Exclusion in Bioassays
  • +
  • Scope: PAINS filters
  • +
+ +

ZINC

+
    +
  • Reference: ZINC
  • +
  • Scope: drug-likeness and unwanted functional group filters
  • +
+ +**/" diff --git a/Code/JavaWrappers/FilterCatalog_doc.i b/Code/JavaWrappers/FilterCatalog_doc.i new file mode 100644 index 000000000..f85c1322d --- /dev/null +++ b/Code/JavaWrappers/FilterCatalog_doc.i @@ -0,0 +1,63 @@ +/* +* +* Copyright (c) 2015, Novartis Institutes for BioMedical Research Inc. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are +* met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. +* * Neither the name of Novartis Institutes for BioMedical Research Inc. +* nor the names of its contributors may be used to endorse or promote +* products derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +%typemap(javaimports) RDKit::FilterCatalog " +/** FilterCatalog Class used to filter out undesireable molecules +
+Basic usage: + +

+  FilterCatalog catalog = new FilterCatalog(
+        FilterCatalogParams.FilterCatalogs.PAINS_A);
+
+  // go through a mol supplier
+  while (!molSupplier.atEnd()) {
+   ROMol m = suppl.next();
+   FilterCatalogEntry_Vect matches = catalog.getMatches(mol);
+   if( matches.size() ) {
+      // reject -- get descriptions of rejection
+      for (int entryIdx = 0; entryIdx < matches.size(); ++entryIdx) {
+          entry = matches.get(entryIdx);
+          String description = entry.getDescription(); // why
+          // optional properties
+          String reference  = entry.getProp(\"Reference\");
+          String scope = entry.getProp(\"Scope\");
+      }
+   }
+   else {
+     // accept
+   }
+  }
+
+
+**/ +" diff --git a/Code/JavaWrappers/FilterCatalogs_doc.i b/Code/JavaWrappers/FilterCatalogs_doc.i new file mode 100644 index 000000000..573b24319 --- /dev/null +++ b/Code/JavaWrappers/FilterCatalogs_doc.i @@ -0,0 +1,57 @@ +/* +* +* Copyright (c) 2015, Novartis Institutes for BioMedical Research Inc. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are +* met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. +* * Neither the name of Novartis Institutes for BioMedical Research Inc. +* nor the names of its contributors may be used to endorse or promote +* products derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +%typemap(javaimports) RDKit::FilterCatalogParams::FilterCatalog " +/** +

+Initialize a FilterCatalog with the specified set of FilterCatalogs. Current +catalogs include: + +


+  FilterCatalogParams.FilterCatalogs.ALL
+  FilterCatalogParams.FilterCatalogs.BRENK
+  FilterCatalogParams.FilterCatalogs.PAINS_A
+  FilterCatalogParams.FilterCatalogs.PAINS_B
+  FilterCatalogParams.FilterCatalogs.PAINS_C
+  FilterCatalogParams.FilterCatalogs.PAINS
+  FilterCatalogParams.FilterCatalogs.ZINC
+
+ +Details: + +

Brenk

+
    +
  • # Reference: Brenk R et al. Lessons Learnt from Assembling Screening Libraries for Drug Discovery for Neglected Diseases. ChemMedChem 3 (2008) 435-444. doi:10.1002/cmdc.200700139.
  • +
  • +
+ +**/" diff --git a/Code/JavaWrappers/ROMol.i b/Code/JavaWrappers/ROMol.i index c41aba27d..8bf7d227f 100644 --- a/Code/JavaWrappers/ROMol.i +++ b/Code/JavaWrappers/ROMol.i @@ -31,6 +31,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ %include "std_pair.i" +%include "std_string.i" %include "std_vector.i" %{ #include diff --git a/Code/JavaWrappers/gmwrapper/CMakeLists.txt b/Code/JavaWrappers/gmwrapper/CMakeLists.txt index 737361600..461bce4b1 100644 --- a/Code/JavaWrappers/gmwrapper/CMakeLists.txt +++ b/Code/JavaWrappers/gmwrapper/CMakeLists.txt @@ -82,7 +82,7 @@ SWIG_ADD_MODULE(GraphMolWrap "java" GraphMolJava.i ) # as of Oct 2012 using boost 1.51 under at least ubuntu 12.04 we get a # link error if they aren't there. SWIG_LINK_LIBRARIES(GraphMolWrap ${RDKit_Wrapper_Libs} - ${RDKit_THREAD_LIBS}) + ${Boost_SERIALIZATION_LIBRARY} ${RDKit_THREAD_LIBS}) # code adapted from the wrapper code for # GDCM: http://gdcm.svn.sf.net/viewvc/gdcm/trunk/Wrapping/Java/CMakeLists.txt?view=markup @@ -153,6 +153,12 @@ ADD_CUSTOM_TARGET(RunJavaWrapperTests COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/runUnitTests.sh ) +# need to add boost libs for testing +SET (CTEST_ENVIRONMENT + "LD_LIBRARY_PATH=${Boost_LIBRARY_DIRS}" + "DYLD_LIBRARY_PATH=${Boost_LIBRARY_DIRS}" + ) + ADD_TEST(JavaAromaticTests java -Djava.library.path=${CMAKE_CURRENT_SOURCE_DIR} -cp "${JUNIT_JAR}${PATH_SEP}${CMAKE_JAVA_TEST_OUTDIR}${PATH_SEP}${CMAKE_CURRENT_SOURCE_DIR}/org.RDKit.jar" @@ -291,5 +297,12 @@ ADD_TEST(JavaMolQueryTests java -Djava.library.path=${CMAKE_CURRENT_SOURCE_DIR} -cp "${JUNIT_JAR}${PATH_SEP}${CMAKE_JAVA_TEST_OUTDIR}${PATH_SEP}${CMAKE_CURRENT_SOURCE_DIR}/org.RDKit.jar" org.RDKit.MolQueryTests) + +ADD_TEST(JavaFilterCatalogTests + java -Djava.library.path=${CMAKE_CURRENT_SOURCE_DIR} + -cp "${JUNIT_JAR}${PATH_SEP}${CMAKE_JAVA_TEST_OUTDIR}${PATH_SEP}${CMAKE_CURRENT_SOURCE_DIR}/org.RDKit.jar" + org.RDKit.FilterCatalogTests) + + INSTALL(TARGETS GraphMolWrap DESTINATION ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/Code/JavaWrappers/gmwrapper/GraphMolJava.i b/Code/JavaWrappers/gmwrapper/GraphMolJava.i index 4c96f9bd2..c85e7f258 100644 --- a/Code/JavaWrappers/gmwrapper/GraphMolJava.i +++ b/Code/JavaWrappers/gmwrapper/GraphMolJava.i @@ -112,6 +112,7 @@ typedef unsigned long long int uintmax_t; %shared_ptr(ForceFields::UFF::vdWContrib); %shared_ptr(ForceFields::UFF::TorsionAngleContrib); %shared_ptr(ForceFields::UFF::InversionContrib); +%shared_ptr(RDKit::FilterCatalogEntry); /* Some utility classes for passing arrays in and out */ %array_class(double, Double_Array); @@ -140,6 +141,9 @@ typedef unsigned long long int uintmax_t; %include "../TDTWriter_doc.i" %include "../Transform2D_doc.i" %include "../Transform3D_doc.i" +%include "../FilterCatalog_doc.i" +%include "../FilterCatalogParams_doc.i" +%include "../FilterCatalogs_doc.i" // DO THIS BEFORE ANY OF THE OTHER INCLUDES %include "../RDKitExceptions.i" @@ -185,6 +189,7 @@ typedef unsigned long long int uintmax_t; %include "../MolTransforms.i" %include "../FMCS.i" %include "../MolDraw2D.i" +%include "../FilterCatalog.i" // Create a class to throw various sorts of errors for testing. Required for unit tests in ErrorHandlingTests.java #ifdef INCLUDE_ERROR_GENERATOR diff --git a/Code/JavaWrappers/gmwrapper/src-test/org/RDKit/FilterCatalogTests.java b/Code/JavaWrappers/gmwrapper/src-test/org/RDKit/FilterCatalogTests.java new file mode 100644 index 000000000..3c327885a --- /dev/null +++ b/Code/JavaWrappers/gmwrapper/src-test/org/RDKit/FilterCatalogTests.java @@ -0,0 +1,128 @@ +/* + * + * Copyright (c) 2015, Novartis Institutes for BioMedical Research Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Novartis Institutes for BioMedical Research Inc. + * nor the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.RDKit; + +import static org.junit.Assert.*; +import org.junit.*; + +public class FilterCatalogTests extends GraphMolTest { + private ROMol mol; + + @Before public void setUp() { + } + + @Test + public void test1Basics() { + FilterCatalog catalog = new FilterCatalog(); + assertEquals(0, catalog.getNumEntries()); + + //assertEquals(16, catalog.getNumEntries()); + + } + + @Test + public void test2Basics() { + + FilterCatalog catalog = new FilterCatalog( + FilterCatalogParams.FilterCatalogs.PAINS_A); + assertEquals(16, catalog.getNumEntries()); + + mol = RWMol.MolFromSmiles("O=C(Cn1cnc2c1c(=O)n(C)c(=O)n2C)N/N=C/c1c(O)ccc2c1cccc2"); + FilterCatalogEntry entry = catalog.getFirstMatch(mol); + Str_Vect props = entry.getPropList(); + + String ref = entry.getProp("Reference"); + String source = entry.getProp("Scope"); + assertEquals(ref, + "Baell JB, Holloway GA. New Substructure Filters for " + + "Removal of Pan Assay Interference Compounds (PAINS) " + + "from Screening Libraries and for Their Exclusion in " + + "Bioassays. J Med Chem 53 (2010) 2719D40. " + + "doi:10.1021/jm901137j."); + + assertEquals(source, "PAINS filters (family A)"); + assertEquals(entry.getDescription(),"hzone_phenol_A(479)"); + + // check the getMatches api point + FilterCatalogEntry_Vect matches = catalog.getMatches(mol); + assertEquals(1, matches.size()); + + for (int entryIdx = 0; entryIdx < matches.size(); ++entryIdx) { + entry = matches.get(entryIdx); + String refa = entry.getProp("Reference"); + String sourcea = entry.getProp("Scope"); + assertEquals(refa, + "Baell JB, Holloway GA. New Substructure Filters for " + + "Removal of Pan Assay Interference Compounds (PAINS) " + + "from Screening Libraries and for Their Exclusion in " + + "Bioassays. J Med Chem 53 (2010) 2719D40. " + + "doi:10.1021/jm901137j."); + assertEquals(source, "PAINS filters (family A)"); + assertEquals(entry.getDescription(),"hzone_phenol_A(479)"); + } + + if (catalog.canSerialize()) { + byte pickle[] = catalog.Serialize(); + System.out.println(pickle); + assertTrue(pickle != null); + FilterCatalog catalog2 = FilterCatalog.Deserialize(pickle); + assertFalse(catalog2 == null); + assertEquals(16, catalog2.getNumEntries()); + entry = catalog2.getFirstMatch(mol); + assertEquals(entry.getDescription(),"hzone_phenol_A(479)"); + } + } + + @Test + public void testRemoveEntry() { + FilterCatalog catalog = new FilterCatalog( + FilterCatalogParams.FilterCatalogs.PAINS_A); + assertEquals(16, catalog.getNumEntries()); + + mol = RWMol.MolFromSmiles("O=C(Cn1cnc2c1c(=O)n(C)c(=O)n2C)N/N=C/c1c(O)ccc2c1cccc2"); + FilterCatalogEntry entry = catalog.getFirstMatch(mol); + assertEquals(entry.getDescription(),"hzone_phenol_A(479)"); + + assertTrue(catalog.removeEntry(entry)); + FilterCatalogEntry entry_removed = catalog.getFirstMatch(mol); + assertEquals(entry_removed, null); + + catalog.addEntry(entry); + entry = catalog.getFirstMatch(mol); + assertEquals(entry.getDescription(),"hzone_phenol_A(479)"); + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main("org.RDKit.FilterCatalogTests"); + } + +}