Skip to content
Snippets Groups Projects
Commit 84861ca3 authored by Marco Biasini's avatar Marco Biasini
Browse files

switch to boost program_options library. windows doesn't have getopt

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