diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cb9804b9c9f81868e163d793afcde0b7bc6b499..aeb7b5528119a6705e84b679f08477c0e335e7e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,9 +206,11 @@ find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS iostreams REQUIRED) set(BOOST_IOSTREAM_LIBRARIES ${Boost_LIBRARIES}) set(Boost_LIBRARIES) find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS program_options REQUIRED) +set(BOOST_PROGRAM_OPTIONS ${Boost_LIBRARIES}) set(Boost_LIBRARIES) find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS regex REQUIRED) set(BOOST_REGEX_LIBRARIES ${Boost_LIBRARIES}) +set(Boost_LIBRARIES) find_package(Qt4 4.5.0 REQUIRED) diff --git a/modules/mol/alg/src/CMakeLists.txt b/modules/mol/alg/src/CMakeLists.txt index 6d418a16c3691840dceb2eb4c33f968f6a6241e5..d1c84aa186a4fb77a47bde198acf8adc1f472371 100644 --- a/modules/mol/alg/src/CMakeLists.txt +++ b/modules/mol/alg/src/CMakeLists.txt @@ -37,7 +37,8 @@ executable(NAME ldt SOURCES ldt.cc module(NAME mol_alg SOURCES ${OST_MOL_ALG_SOURCES} HEADERS ${OST_MOL_ALG_HEADERS} HEADER_OUTPUT_DIR ost/mol/alg - DEPENDS_ON ${MOL_ALG_DEPS}) + DEPENDS_ON ${MOL_ALG_DEPS} + LINK ${BOOST_PROGRAM_OPTIONS}) copy_if_different("." "${STAGE_DIR}/share/openstructure" "atom_scattering_properties.txt" "ATOM_SCATTERING_PROPS" diff --git a/modules/mol/alg/src/ldt.cc b/modules/mol/alg/src/ldt.cc index 4b08ed8cce82359f0af0adc6ce17cba3f7b02aad..eed10f53f263aaf716c066150a417efa6cd01007 100644 --- a/modules/mol/alg/src/ldt.cc +++ b/modules/mol/alg/src/ldt.cc @@ -16,6 +16,7 @@ // along with this library; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA //------------------------------------------------------------------------------ +#include <boost/program_options.hpp> #include <ost/mol/alg/local_dist_test.hh> #include <ost/mol/alg/filter_clashes.hh> #include <ost/io/mol/pdb_reader.hh> @@ -24,6 +25,7 @@ using namespace ost; using namespace ost::io; using namespace ost::mol; +namespace po=boost::program_options; EntityHandle load(const String& file, const IOProfile& profile) { @@ -54,48 +56,52 @@ void usage() std::cerr << " -t fault tolerant parsing" << std::endl; } -int main (int argc, char* const *argv) +int main (int argc, char **argv) { IOProfile profile; // parse options String sel; bool filter_clashes=false; - char ch=0; - while((ch=getopt(argc, argv, "ftcs:"))!=-1) { - switch (ch) { - case 'c': - profile.calpha_only=true; - break; - case 't': - profile.fault_tolerant=true; - break; - case 'f': - filter_clashes=true; - break; - case 's': - sel=optarg; - break; - case '?': - default: - usage(); - return -1; - } + po::options_description desc("Options"); + desc.add_options() + ("calpha,c", "consider only calpha atoms") + ("sel,s", po::value<String>(&sel)->default_value(""), "selection for reference") + ("tolerant,t", "fault tolerant mode") + ("filter-clashes,f", "filter clashes") + ("files", po::value< std::vector<String> >(), "input file") + ; + po::positional_options_description p; + p.add("files", -1); + po::variables_map vm; + po::store(po::command_line_parser(argc, argv). + options(desc).positional(p).run(), + vm); + po::notify(vm); + if (vm.count("calpha")) { + profile.calpha_only=true; + } + if (vm.count("filter-clashes")) { + filter_clashes=true; + } + if (vm.count("tolerant")) { + profile.fault_tolerant=true; } - argc-=optind; - argv+=optind; - if (argc<2) { + std::vector<String> files; + if (vm.count("files")) { + files=vm["files"].as<std::vector<String> >(); + } else { usage(); - return -1; - } - - String ref_file=argv[argc-1]; + exit(-1); + } + String ref_file=files.back(); EntityHandle ref=load(ref_file, profile); if (!ref) { return -1; } + files.pop_back(); EntityView ref_view=ref.Select(sel); - for (int i=0; i<argc-1; ++i) { - EntityHandle model=load(argv[i], profile); + for (size_t i=0; i<files.size(); ++i) { + EntityHandle model=load(files[i], profile); if (!model) { if (!profile.fault_tolerant) { return -1; @@ -112,7 +118,7 @@ int main (int argc, char* const *argv) ldt+=alg::LocalDistTest(v, ref_view, cutoffs[n], 8.0); } ldt/=4.0; - std::cout << argv[i] << " " << ldt << std::endl; + std::cout << files[i] << " " << ldt << std::endl; } return 0; } \ No newline at end of file