comparison gene_fraction/src/args.h @ 0:0fd352f62446 draft default tip

planemo upload for repository https://github.com/ChrisD11/Duplicon commit 3ee0594c692faac542ffa58f4339d79b9b8aefbd-dirty
author chrisd
date Sun, 21 Feb 2016 06:05:24 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0fd352f62446
1 #ifndef ARGS_H
2 #define ARGS_H
3
4 #include "int_util.h"
5
6 #include <string>
7 #include <vector>
8 #include <list>
9
10 /**
11 * Encapsulates information input
12 * from the command line.
13 */
14 struct cmd_args {
15 std::string amr_fp;
16 std::string sam_fp;
17 std::list<std::string> sam_dir_fp;
18 std::string out_fp;
19
20 int threshold;
21 int min;
22 int max;
23 int skip;
24 int s_per_lev;
25
26 bool sam_dir = false; /* This will be set to true when parsing a
27 directory of sam files. */
28 bool bam_stream = false; /* This will be set to true when executing
29 samtools view -h example.bam | csa > output
30 from the command line. */
31 };
32
33 /**
34 * Returns a struct of command line arguments.
35 */
36 static inline cmd_args
37 parse_command_line(int argc, char *argv[]) {
38 std::vector<std::string> args(argv, argv + argc);
39
40 cmd_args arg;
41
42 for(int i = 1; i < argc; i++) {
43 if(args[i].compare("-amr_fp") == 0)
44 arg.amr_fp = args[++i];
45 else if(args[i].compare("-sam_fp") == 0)
46 arg.sam_fp = args[++i];
47 else if(args[i].compare("-out_fp") == 0)
48 arg.out_fp = args[++i];
49 else if(args[i].compare("-t") == 0)
50 arg.threshold = s_to_i(args[++i]);
51 else if(args[i].compare("-min") == 0)
52 arg.min = s_to_i(args[++i]);
53 else if(args[i].compare("-max") == 0)
54 arg.max = s_to_i(args[++i]);
55 else if(args[i].compare("-skip") == 0)
56 arg.skip = s_to_i(args[++i]);
57 else if(args[i].compare("-samples") == 0)
58 arg.s_per_lev = s_to_i(args[++i]);
59 else if(args[i].compare("-d") == 0)
60 arg.sam_dir = true;
61 else if(args[i].compare("-bam") == 0)
62 arg.bam_stream = true;
63 }
64
65 return arg;
66 }
67
68 #endif /* ARGS_H */