Mercurial > repos > chrisd > testing
comparison gene_fraction/src/args.h @ 0:f95150c37d38 draft default tip
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
author | chrisd |
---|---|
date | Sun, 21 Feb 2016 23:31:55 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f95150c37d38 |
---|---|
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 static void usage() { | |
11 fprintf(stderr, "\n"); | |
12 fprintf(stderr, "Program: Coverage Sampler \n"); | |
13 fprintf(stderr, "Contact: Chris Dean <cdean11@rams.colostate.edu\n\n"); | |
14 fprintf(stderr, "Usage: csa [options]\n\n"); | |
15 fprintf(stderr, "Options:\n\n"); | |
16 fprintf(stderr, " -amr_fp amr database path\n"); | |
17 fprintf(stderr, " -sam_fp sam file path\n"); | |
18 fprintf(stderr, " -min starting level\n"); | |
19 fprintf(stderr, " -max ending level\n"); | |
20 fprintf(stderr, " -skip amount of levels to skip\n"); | |
21 fprintf(stderr, " -t gene fraction threshold\n"); | |
22 fprintf(stderr, " -samples amount of samples per level\n"); | |
23 fprintf(stderr, " -d directory parsing\n"); | |
24 fprintf(stderr, " -bam bam file parsing\n"); | |
25 fprintf(stderr, " -out_fp output file path\n\n"); | |
26 } | |
27 | |
28 /** | |
29 * Encapsulates information input | |
30 * from the command line. | |
31 */ | |
32 struct cmd_args { | |
33 std::string amr_fp; | |
34 std::string sam_fp; | |
35 std::list<std::string> sam_dir_fp; | |
36 std::string out_fp; | |
37 | |
38 int threshold; | |
39 int min; | |
40 int max; | |
41 int skip; | |
42 int s_per_lev; | |
43 | |
44 bool sam_dir = false; /* This will be set to true when parsing a | |
45 directory of sam files. */ | |
46 bool bam_stream = false; /* This will be set to true when executing | |
47 samtools view -h example.bam | csa > output | |
48 from the command line. */ | |
49 }; | |
50 | |
51 /** | |
52 * Returns a struct of command line arguments. | |
53 */ | |
54 static inline cmd_args | |
55 parse_command_line(int argc, char *argv[]) { | |
56 std::vector<std::string> args(argv, argv + argc); | |
57 | |
58 cmd_args arg; | |
59 | |
60 for(int i = 1; i < argc; i++) { | |
61 if(args[i].compare("-amr_fp") == 0) | |
62 arg.amr_fp = args[++i]; | |
63 else if(args[i].compare("-sam_fp") == 0) | |
64 arg.sam_fp = args[++i]; | |
65 else if(args[i].compare("-out_fp") == 0) | |
66 arg.out_fp = args[++i]; | |
67 else if(args[i].compare("-t") == 0) | |
68 arg.threshold = s_to_i(args[++i]); | |
69 else if(args[i].compare("-min") == 0) | |
70 arg.min = s_to_i(args[++i]); | |
71 else if(args[i].compare("-max") == 0) | |
72 arg.max = s_to_i(args[++i]); | |
73 else if(args[i].compare("-skip") == 0) | |
74 arg.skip = s_to_i(args[++i]); | |
75 else if(args[i].compare("-samples") == 0) | |
76 arg.s_per_lev = s_to_i(args[++i]); | |
77 else if(args[i].compare("-d") == 0) | |
78 arg.sam_dir = true; | |
79 else if(args[i].compare("-bam") == 0) | |
80 arg.bam_stream = true; | |
81 else { | |
82 usage(); | |
83 exit(EXIT_FAILURE); | |
84 } | |
85 } | |
86 | |
87 return arg; | |
88 } | |
89 | |
90 #endif /* ARGS_H */ |