diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b86a729b..b252cc33f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,7 @@ option(RDK_BUILD_MOLINTERCHANGE_SUPPORT "build in support for CommonChem molecul option(RDK_BUILD_YAEHMOP_SUPPORT "build support for the YAeHMOP wrapper" OFF) option(RDK_INSTALL_DEV_COMPONENT "install libraries and headers" ON) option(RDK_USE_BOOST_REGEX "use boost::regex instead of std::regex (needed for systems with g++-4.8)" OFF) +option(RDK_USE_BOOST_IOSTREAMS "use boost::iostreams" ON) if(NOT MSVC) if(RDK_OPTIMIZE_NATIVE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt") diff --git a/Code/GraphMol/FileParsers/CMakeLists.txt b/Code/GraphMol/FileParsers/CMakeLists.txt index 6bcfb0e3b..37712e5bc 100644 --- a/Code/GraphMol/FileParsers/CMakeLists.txt +++ b/Code/GraphMol/FileParsers/CMakeLists.txt @@ -2,6 +2,7 @@ remove_definitions(-DRDKIT_GRAPHMOL_BUILD) add_definitions(-DRDKIT_FILEPARSERS_BUILD) +if(RDK_USE_BOOST_IOSTREAMS) if(WIN32) find_package(Boost 1.56.0 COMPONENTS system iostreams REQUIRED) find_package(Boost 1.56.0 COMPONENTS zlib) @@ -16,6 +17,8 @@ else() add_definitions("-DBOOST_IOSTREAMS_DYN_LINK") endif() endif() +ADD_DEFINITIONS("-DRDK_USE_BOOST_IOSTREAMS") +endif(RDK_USE_BOOST_IOSTREAMS) if(RDK_BUILD_COORDGEN_SUPPORT) include_directories(${maeparser_INCLUDE_DIRS}) diff --git a/Code/GraphMol/FileParsers/testMolSupplier.cpp b/Code/GraphMol/FileParsers/testMolSupplier.cpp index ebf118a92..fc7ce4286 100644 --- a/Code/GraphMol/FileParsers/testMolSupplier.cpp +++ b/Code/GraphMol/FileParsers/testMolSupplier.cpp @@ -129,7 +129,7 @@ int testMolSup() { } TEST_ASSERT(ok); } -#endif // RDK_BUILD_COORDGEN_SUPPORT +#endif // RDK_BUILD_COORDGEN_SUPPORT return 1; } @@ -319,10 +319,11 @@ void testSmilesSupFromText() { // this was a delightful boundary condition: BOOST_LOG(rdErrorLog) << "------------------------------------------------------" << std::endl; - text = "CC\n" - "CCC\n" - "CCOC\n" - "CCCCOC"; + text = + "CC\n" + "CCC\n" + "CCOC\n" + "CCCCOC"; { nSup2.setData(text, " ", 0, -1, false, true); // BOOST_LOG(rdErrorLog) << "SIZE: " << nSup2.length() << std::endl; @@ -395,11 +396,12 @@ void testSmilesSupFromText() { } // -------------- // basics: - text = "Id SMILES Column_2\n" - "mol-1 C 1.0\n" - "mol-2 CC 4.0\n" - "mol-3 CCC 9.0\n" - "mol-4 CCCC 16.0\n"; + text = + "Id SMILES Column_2\n" + "mol-1 C 1.0\n" + "mol-2 CC 4.0\n" + "mol-3 CCC 9.0\n" + "mol-4 CCCC 16.0\n"; #if 1 nSup2.setData(text, " ", 1, 0, true, true); mol = nSup2[3]; @@ -412,10 +414,11 @@ void testSmilesSupFromText() { delete mol; // ensure that we can call setData a second time: - text = "Id SMILES Column_2\n" - "mol-1 C 1.0\n" - "mol-2 CC 4.0\n" - "mol-3 CCC 9.0\n"; + text = + "Id SMILES Column_2\n" + "mol-1 C 1.0\n" + "mol-2 CC 4.0\n" + "mol-3 CCC 9.0\n"; nSup2.setData(text, " ", 1, 0, true, true); CHECK_INVARIANT(nSup2.length() == 3, ""); mol = nSup2[2]; @@ -426,11 +429,12 @@ void testSmilesSupFromText() { delete mol; // now test for failure handling: - text = "Id SMILES Column_2\n" - "mol-1 C 1.0\n" - "mol-2 CC 4.0\n" - "mol-3 fail 9.0\n" - "mol-4 CCCC 16.0\n"; + text = + "Id SMILES Column_2\n" + "mol-1 C 1.0\n" + "mol-2 CC 4.0\n" + "mol-3 fail 9.0\n" + "mol-4 CCCC 16.0\n"; nSup2.setData(text, " ", 1, 0, true, true); mol = nSup2[3]; // BOOST_LOG(rdErrorLog) << "SIZE: " << nSup2.length() << std::endl; @@ -448,10 +452,11 @@ void testSmilesSupFromText() { #endif // issue 114, no \n at EOF: - text = "Id SMILES Column_2\n" - "mol-1 C 1.0\n" - "mol-2 CC 4.0\n" - "mol-4 CCCC 16.0\n"; + text = + "Id SMILES Column_2\n" + "mol-1 C 1.0\n" + "mol-2 CC 4.0\n" + "mol-4 CCCC 16.0\n"; nSup2.setData(text, " ", 1, 0, true, true); // BOOST_LOG(rdErrorLog) << "SIZE: " << nSup2.length() << std::endl; TEST_ASSERT(nSup2.length() == 3); @@ -464,10 +469,11 @@ void testSmilesSupFromText() { TEST_ASSERT(nSup2.atEnd()); delete mol; - text = "Id SMILES Column_2\n" - "mol-1 C 1.0\n" - "mol-2 CC 4.0\n" - "mol-4 CCCC 16.0"; + text = + "Id SMILES Column_2\n" + "mol-1 C 1.0\n" + "mol-2 CC 4.0\n" + "mol-4 CCCC 16.0"; nSup2.setData(text, " ", 1, 0, true, true); // BOOST_LOG(rdErrorLog) << "SIZE: " << nSup2.length() << std::endl; TEST_ASSERT(nSup2.length() == 3); @@ -488,9 +494,10 @@ void testSmilesSupFromText() { } TEST_ASSERT(failed); - text = "mol-1 C 1.0\n" - "mol-2 CC 4.0\n" - "mol-4 CCCC 16.0"; + text = + "mol-1 C 1.0\n" + "mol-2 CC 4.0\n" + "mol-4 CCCC 16.0"; nSup2.setData(text, " ", 1, 0, false, true); // BOOST_LOG(rdErrorLog) << "SIZE: " << nSup2.length() << std::endl; TEST_ASSERT(nSup2.length() == 3); @@ -502,9 +509,10 @@ void testSmilesSupFromText() { TEST_ASSERT(mname == "16.0"); delete mol; - text = "C\n" - "CC\n" - "CCCC"; + text = + "C\n" + "CC\n" + "CCCC"; nSup2.setData(text, " ", 0, -1, false, true); // BOOST_LOG(rdErrorLog) << "SIZE: " << nSup2.length() << std::endl; TEST_ASSERT(nSup2.length() == 3); @@ -516,10 +524,11 @@ void testSmilesSupFromText() { // this was a delightful boundary condition: BOOST_LOG(rdErrorLog) << "------------------------------------------------------" << std::endl; - text = "CC\n" - "CCC\n" - "CCOC\n" - "CCCCOC"; + text = + "CC\n" + "CCC\n" + "CCOC\n" + "CCCCOC"; nSup2.setData(text, " ", 0, -1, false, true); // BOOST_LOG(rdErrorLog) << "SIZE: " << nSup2.length() << std::endl; mol = nSup2.next(); @@ -541,10 +550,11 @@ void testSmilesSupFromText() { BOOST_LOG(rdErrorLog) << "------------------------------------------------------" << std::endl; // this was a delightful boundary condition: - text = "CC\n" - "CCC\n" - "CCOC\n" - "CCCCOC"; + text = + "CC\n" + "CCC\n" + "CCOC\n" + "CCCCOC"; nSup2.setData(text, " ", 0, -1, false, true); // BOOST_LOG(rdErrorLog) << "SIZE: " << nSup2.length() << std::endl; failed = false; @@ -571,12 +581,13 @@ void testSmilesSupFromText() { TEST_ASSERT(nDone == nSup2.length()); // ensure that we can call setData a second time: - text = "Id SMILES Column_2\n" - "# comment, ignore\n" - "mol-1 C 1.0\n" - "mol-2 CC 4.0\n" - "mol-3 CCC 9.0\n" - "mol-4 CCCC 16.0\n"; + text = + "Id SMILES Column_2\n" + "# comment, ignore\n" + "mol-1 C 1.0\n" + "mol-2 CC 4.0\n" + "mol-3 CCC 9.0\n" + "mol-4 CCCC 16.0\n"; nSup2.setData(text, " ", 1, 0, true, true); mol = nSup2[2]; mol->getProp(common_properties::_Name, mname); @@ -593,12 +604,13 @@ void testSmilesSupFromText() { delete mol; // this was a delightful boundary condition: - text = "CC\n" - "CCC\n" - "CCOC\n" - "CCCCOC\n" - "\n" - "\n"; + text = + "CC\n" + "CCC\n" + "CCOC\n" + "CCCCOC\n" + "\n" + "\n"; nSup2.setData(text, " ", 0, -1, false, true); TEST_ASSERT(nSup2.length() == 4); nSup2.reset(); @@ -837,9 +849,10 @@ void testSuppliersEmptyFile() { void testCisTrans() { std::string text; - text = "mol-1 ClC(C)=C(Br)C\n" - "mol-2 C1=COC=CC1C(Cl)=C(Br)C\n" - "mol-3 C1=COC=CC1\\C(Cl)=C(Br)\\C"; + text = + "mol-1 ClC(C)=C(Br)C\n" + "mol-2 C1=COC=CC1C(Cl)=C(Br)C\n" + "mol-3 C1=COC=CC1\\C(Cl)=C(Br)\\C"; SmilesMolSupplier smiSup; smiSup.setData(text, " ", 1, 0, false, true); @@ -1076,18 +1089,19 @@ int testTDTSupplier3() { TDTMolSupplier suppl; - data = "$SMI\n" - "CAS<17584-12-2>\n" - "|\n" - "$SMI\n" - "CAS<~>\n" - "|\n" - "$SMI\n" - "CAS<932-53-6>\n" - "|\n" - "$SMI\n" - "CAS<~>\n" - "|\n"; + data = + "$SMI\n" + "CAS<17584-12-2>\n" + "|\n" + "$SMI\n" + "CAS<~>\n" + "|\n" + "$SMI\n" + "CAS<932-53-6>\n" + "|\n" + "$SMI\n" + "CAS<~>\n" + "|\n"; suppl.setData(data, "CAS"); i = 0; @@ -1268,8 +1282,7 @@ void testSDSupplierFromTextStrLax1() { while (!reader.atEnd()) { ROMol *mol = reader.next(); TEST_ASSERT(mol->hasProp(common_properties::_Name)); - if (i == 0) - TEST_ASSERT(!mol->hasProp("ID")); + if (i == 0) TEST_ASSERT(!mol->hasProp("ID")); TEST_ASSERT(!mol->hasProp("ANOTHER_PROPERTY")); i++; delete mol; @@ -1358,10 +1371,11 @@ void testSDSupplierFromTextStrLax2() { mol->getProp("ID", s); TEST_ASSERT(s == "Lig1"); mol->getProp("ANOTHER_PROPERTY", s); - TEST_ASSERT(s == "No blank line before dollars\n" - "$$$$\n" - "Structure1\n" - "csChFnd70/05230312262D"); + TEST_ASSERT(s == + "No blank line before dollars\n" + "$$$$\n" + "Structure1\n" + "csChFnd70/05230312262D"); i++; delete mol; } @@ -1403,8 +1417,7 @@ void testSDSupplierStrLax1() { while (!reader.atEnd()) { ROMol *mol = reader.next(); TEST_ASSERT(mol->hasProp(common_properties::_Name)); - if (i == 0) - TEST_ASSERT(!mol->hasProp("ID")); + if (i == 0) TEST_ASSERT(!mol->hasProp("ID")); TEST_ASSERT(!mol->hasProp("ANOTHER_PROPERTY")); i++; delete mol; @@ -1446,10 +1459,11 @@ void testSDSupplierStrLax2() { mol->getProp("ID", s); TEST_ASSERT(s == "Lig1"); mol->getProp("ANOTHER_PROPERTY", s); - TEST_ASSERT(s == "No blank line before dollars\n" - "$$$$\n" - "Structure1\n" - "csChFnd70/05230312262D"); + TEST_ASSERT(s == + "No blank line before dollars\n" + "$$$$\n" + "Structure1\n" + "csChFnd70/05230312262D"); i++; delete mol; } @@ -1569,8 +1583,7 @@ void testIssue381() { count = 0; while (!sdsup->atEnd()) { nmol = sdsup->next(); - if (nmol) - delete nmol; + if (nmol) delete nmol; count++; } TEST_ASSERT(sdsup->atEnd()); @@ -1592,12 +1605,10 @@ void testSetStreamIndices() { std::streampos pos = 0; std::string line; while (notEof) { - if (addIndex) - pos = ifs.tellg(); + if (addIndex) pos = ifs.tellg(); notEof = (std::getline(ifs, line) ? true : false); if (notEof) { - if (addIndex) - indices.push_back(pos); + if (addIndex) indices.push_back(pos); addIndex = (line.substr(0, 4) == "$$$$"); } } @@ -1615,8 +1626,7 @@ void testSetStreamIndices() { count = 0; while (!sdsup->atEnd()) { nmol = sdsup->next(); - if (nmol) - delete nmol; + if (nmol) delete nmol; count++; } TEST_ASSERT(sdsup->atEnd()); @@ -2074,7 +2084,7 @@ int testForwardSDSupplier() { } TEST_ASSERT(i == 16); } - +#ifdef RDK_USE_BOOST_IOSTREAMS // make sure the boost::iostreams are working { io::filtering_istream strm; @@ -2084,10 +2094,8 @@ int testForwardSDSupplier() { while (!strm.eof()) { std::string line; std::getline(strm, line); - if (!strm.eof()) - ++i; - if (i > 1000) - break; + if (!strm.eof()) ++i; + if (i > 1000) break; } TEST_ASSERT(i == 998); } @@ -2097,10 +2105,8 @@ int testForwardSDSupplier() { while (!strm.eof()) { std::string line; std::getline(strm, line); - if (!strm.eof()) - ++i; - if (i > 1000) - break; + if (!strm.eof()) ++i; + if (i > 1000) break; } TEST_ASSERT(i == 997); } @@ -2121,6 +2127,7 @@ int testForwardSDSupplier() { } TEST_ASSERT(i == 16); } +#endif #ifdef RDK_BUILD_COORDGEN_SUPPORT // Now test that Maestro parsing of gz files works @@ -2136,10 +2143,8 @@ int testForwardSDSupplier() { while (!strm.eof()) { std::string line; std::getline(strm, line); - if (!strm.eof()) - ++i; - if (i > 1700) - break; + if (!strm.eof()) ++i; + if (i > 1700) break; } TEST_ASSERT(i == 1663); } @@ -2150,10 +2155,8 @@ int testForwardSDSupplier() { while (!strm.eof()) { std::string line; std::getline(strm, line); - if (!strm.eof()) - ++i; - if (i > 1700) - break; + if (!strm.eof()) ++i; + if (i > 1700) break; } TEST_ASSERT(i == 1663); } @@ -2172,8 +2175,7 @@ int testForwardSDSupplier() { } TEST_ASSERT(i == 16); } -#endif // RDK_BUILD_COORDGEN_SUPPORT - +#endif // RDK_BUILD_COORDGEN_SUPPORT return 1; } @@ -2329,7 +2331,7 @@ void testGitHub2285() { std::vector smiles; { SDMolSupplier sdsup(fname); - while(!sdsup.atEnd()) { + while (!sdsup.atEnd()) { ROMol *nmol = sdsup.next(); TEST_ASSERT(nmol); smiles.push_back(MolToSmiles(*nmol)); @@ -2339,7 +2341,7 @@ void testGitHub2285() { { SDMolSupplier sdsup(fname, true, false); int i = 0; - while(!sdsup.atEnd()) { + while (!sdsup.atEnd()) { ROMol *nmol = sdsup.next(); TEST_ASSERT(nmol); ROMol *m = MolOps::removeHs(*nmol); @@ -2347,7 +2349,7 @@ void testGitHub2285() { delete nmol; delete m; } - TEST_ASSERT(i>0); + TEST_ASSERT(i > 0); } } diff --git a/Code/JavaWrappers/CMakeLists.txt b/Code/JavaWrappers/CMakeLists.txt index cd2d60de2..8ea28bdef 100644 --- a/Code/JavaWrappers/CMakeLists.txt +++ b/Code/JavaWrappers/CMakeLists.txt @@ -37,7 +37,8 @@ foreach(swigRDKitLib ${swigRDKitLibList}) endforeach() set(swigRDKitLibs "${swigRDKitLibs}${Boost_SERIALIZATION_LIBRARY};") - +if(RDK_USE_BOOST_IOSTREAMS) +ADD_DEFINITIONS("-DRDK_USE_BOOST_IOSTREAMS") if(WIN32) find_package(Boost 1.56.0 COMPONENTS system iostreams REQUIRED) set(swigRDKitLibs "${swigRDKitLibs}${Boost_IOSTREAMS_LIBRARY};${Boost_SYSTEM_LIBRARY};") @@ -50,6 +51,7 @@ else() find_package(Boost 1.56.0 COMPONENTS system iostreams REQUIRED) set(swigRDKitLibs "${swigRDKitLibs}${Boost_IOSTREAMS_LIBRARY};${Boost_SYSTEM_LIBRARY};") endif() +endif(RDK_USE_BOOST_IOSTREAMS) diff --git a/Code/RDGeneral/RDConfig.h.cmake b/Code/RDGeneral/RDConfig.h.cmake index d230d2bb9..7dd44c78d 100644 --- a/Code/RDGeneral/RDConfig.h.cmake +++ b/Code/RDGeneral/RDConfig.h.cmake @@ -10,6 +10,7 @@ // RDKit configuration options #cmakedefine RDK_USE_BOOST_SERIALIZATION +#cmakedefine RDK_USE_BOOST_IOSTREAMS #cmakedefine RDK_OPTIMIZE_NATIVE #ifdef RDK_OPTIMIZE_NATIVE diff --git a/Code/RDStreams/CMakeLists.txt b/Code/RDStreams/CMakeLists.txt index 2706c03f7..5915b6395 100644 --- a/Code/RDStreams/CMakeLists.txt +++ b/Code/RDStreams/CMakeLists.txt @@ -1,3 +1,6 @@ +if(RDK_USE_BOOST_IOSTREAMS) +ADD_DEFINITIONS("-DRDK_USE_BOOST_IOSTREAMS") + find_package(Boost 1.56.0 COMPONENTS system iostreams REQUIRED) set (link_iostreams ${Boost_LIBRARIES}) if (NOT Boost_USE_STATIC_LIBS) @@ -12,6 +15,7 @@ if (WIN32) endif() add_definitions(-DRDKIT_RDSTREAMS_BUILD) +endif(RDK_USE_BOOST_IOSTREAMS) rdkit_library(RDStreams streams.cpp LINK_LIBRARIES ${Boost_LIBRARIES} ${link_iostreams} ${zlib_lib} DEST RDStreams) diff --git a/Code/RDStreams/streams.cpp b/Code/RDStreams/streams.cpp index bfc9d0496..311e09b06 100644 --- a/Code/RDStreams/streams.cpp +++ b/Code/RDStreams/streams.cpp @@ -1,11 +1,12 @@ #include "streams.h" +#ifdef RDK_USE_BOOST_IOSTREAMS -namespace RDKit -{ -gzstream::gzstream(const std::string &fname) : - boost::iostreams::filtering_istream(), - is(fname.c_str(), std::ios_base::binary) { +namespace RDKit { +gzstream::gzstream(const std::string &fname) + : boost::iostreams::filtering_istream(), + is(fname.c_str(), std::ios_base::binary) { push(boost::iostreams::gzip_decompressor()); push(is); } -} +} // namespace RDKit +#endif \ No newline at end of file diff --git a/Code/RDStreams/streams.h b/Code/RDStreams/streams.h index 3a3c6795f..96cc8e3db 100644 --- a/Code/RDStreams/streams.h +++ b/Code/RDStreams/streams.h @@ -1,5 +1,7 @@ // #include +#ifdef RDK_USE_BOOST_IOSTREAMS + #include #include #include @@ -13,4 +15,5 @@ class RDKIT_RDSTREAMS_EXPORT gzstream : public boost::iostreams::filtering_istre public: gzstream(const std::string &fname); }; -} +} // namespace RDKit +#endif