13 #include <boost/program_options.hpp>
14 namespace po = boost::program_options;
16 #if defined(_WIN32) || defined(_WIN64)
18 const char *basename(
const char *path)
21 for (i = path ? strlen(path) : 0; i > 0; --i) {
22 if (path[i] ==
'/' || path[i] ==
'\\') {
33 std::string trim_extension(
const std::string file_name) {
34 if(file_name[file_name.size()-4] ==
'.')
35 return file_name.substr(0, file_name.size() - 4);
40 int main(
int argc,
char **argv)
43 for (
int i = 0; i < argc; i++) std::cerr << argv[i] <<
" ";
44 std::cerr << std::endl;
46 po::options_description desc(
"Usage: <profile_file1> <profile_file2> ...");
48 (
"help",
"Any number of input profiles is supported. \
49 Each profile is read and written back, with simulated error added if necessary")
50 (
"max_q,q", po::value<float>(&max_q)->default_value(0.0),
52 (
"input-files", po::value< std::vector<std::string> >(),
53 "input PDB and profile files")
55 po::positional_options_description p;
56 p.add(
"input-files", -1);
59 po::command_line_parser(argc,argv).options(desc).positional(p).run(), vm);
62 std::vector<std::string> files, dat_files;
63 if(vm.count(
"input-files")) {
64 files = vm[
"input-files"].as< std::vector<std::string> >();
66 if(vm.count(
"help") || files.size() == 0) {
67 std::cout << desc <<
"\n";
71 std::vector<IMP::saxs::Profile *> exp_profiles;
72 for(
unsigned int i=0; i<files.size(); i++) {
74 std::ifstream in_file(files[i].c_str());
76 std::cerr <<
"Can't open file " << files[i] << std::endl;
81 if(profile->
size() == 0) {
82 std::cerr <<
"can't parse input file " << files[i] << std::endl;
85 dat_files.push_back(files[i]);
86 exp_profiles.push_back(profile);
87 std::cout <<
"Profile read from file " << files[i] <<
" size = "
88 << profile->
size() << std::endl;
90 std::string profile_name =
91 trim_extension(basename(const_cast<char *>(files[i].c_str())));
92 std::string file_name = profile_name +
"_v.dat";
94 std::cout <<
"Profile written to file " << file_name << std::endl;