8 #ifndef COMMAND_LINE_HPP
9 #define COMMAND_LINE_HPP
13 #include <boost/program_options/variables_map.hpp>
14 #include <boost/program_options/parsers.hpp>
20 namespace po = boost::program_options;
66 void sanity_check()
const
69 throw except::invalid_options(
"I have no input file to work with, use --fn <file> to give me a scaffold graph.");
70 if(out_seq_filename !=
"" && !
file_exists(in_seq_filename))
71 throw except::invalid_options(
"I want to output fasta sequences to '" + out_seq_filename +
"' but I cannot open the sequence database '" + in_seq_filename +
"' (given with --is) for reading");
77 const T&
get_option(
const po::variables_map& vm,
const std::string& option_name,
const T& default_value){
78 if(vm.count(option_name))
79 return vm[option_name].as<T>();
88 po::options_description desc((std::string)
"syntax: " + argv[0] +
" [options] --fn <scaffold graph file>\nwhere valid options are");
90 (
"help",
"produce help message")
91 (
"fn", po::value<std::string>(),
"file to read scaffold graph from")
92 (
"is", po::value<std::string>(),
"file to read contig sequences from (required for --os)")
93 (
"os", po::value<std::string>(),
"file to output solution sequences in fasta format (requires --is)")
94 (
"og", po::value<std::string>(),
"file to output solution graph in dot format")
95 (
"om", po::value<std::string>(),
"file to output CPLEX model to (see cplex::exportModel()) ")
96 (
"o", po::value<unsigned>(),
"allowed number of objects (paths or cycles) (default 6)")
97 (
"p", po::value<unsigned>(),
"allowed number of paths (default #objects (see -o))")
98 (
"c", po::value<unsigned>(),
"allowed number of cycles (default #objects (see -o))")
99 (
"co", po::value<unsigned>(),
"cut off all edges whose weight is strictly below the argument (default 0)")
100 (
"ta",
"let the solution take all weight of an edge when using it at least once, instead of gaining linearly (& scaling the weight)")
101 (
"nj",
"ignore contig jumps")
102 (
"pp",
"preprocess the input graph")
105 po::variables_map vm;
106 po::store(po::parse_command_line(argc, argv, desc), vm);
108 if(vm.count(
"help") || !vm.count(
"fn")) { std::cout << desc <<
"\n"; exit(EXIT_SUCCESS); }
110 options.in_graph_filename = get_option<std::string>(vm,
"fn",
"");
111 options.out_graph_filename = get_option<std::string>(vm,
"og",
"");
112 options.in_seq_filename = get_option<std::string>(vm,
"is",
"");
113 options.out_seq_filename = get_option<std::string>(vm,
"os",
"");
114 options.out_model_filename = get_option<std::string>(vm,
"om",
"");
116 options.objects = get_option<unsigned>(vm,
"o", 6);
119 options.cut_off = get_option<unsigned>(vm,
"co", 0);
121 options.multi_take_all = vm.count(
"ta");
122 options.ignore_contig_jumps = vm.count(
"nj");
123 options.preprocess = vm.count(
"pp");
128 std::cout <<
"Command line option error: "<<e.what() << std::endl;
129 std::cout << desc << std::endl;
struct @3 options
options that configure the scaffolder
bool multi_take_all
bool indicating whether taking a contig-connection with multiplicity will gain all its weight ...
Definition: command_line.hpp:47
unsigned paths
maximum number of paths that a solution graph should consist of
Definition: command_line.hpp:56
unsigned cycles
maximum number of cycles that a solution graph should consist of
Definition: command_line.hpp:58
bool file_exists(const std::string &filename)
testing whether a file exists by trying to open it
Definition: utils.hpp:206
an exception for the case that the given program options are not valid
Definition: exceptions.hpp:41
bool preprocess
bool indicating whether to run preprocessing or not (currently defunct)
Definition: command_line.hpp:41
const T & get_option(const po::variables_map &vm, const std::string &option_name, const T &default_value)
return the value of an option or the given default if the value has not been supplied ...
Definition: command_line.hpp:77
std::string out_graph_filename
filename of a file to export the solution graph to
Definition: command_line.hpp:35
std::string in_seq_filename
filename of the input sequence file in fasta format
Definition: command_line.hpp:29
std::string in_graph_filename
filename of the input graph
Definition: command_line.hpp:26
unsigned cut_off
cut-off threshold: remove all links between contigs whose weight is strictly below this threshold ...
Definition: command_line.hpp:61
std::string out_model_filename
filename of a file to export the cplex model to
Definition: command_line.hpp:32
void handle_options(const int argc, const char **argv)
process the program options given on the command line
Definition: command_line.hpp:85
bool ignore_contig_jumps
bool incidating whether contig jumps should be considered
Definition: command_line.hpp:51
unsigned objects
maximum number of objects (paths or cycles) that a solution graph should consist of ...
Definition: command_line.hpp:54
std::string out_seq_filename
filename of a file to export solution sequences to
Definition: command_line.hpp:38