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)
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)
......
......@@ -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"
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment