-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnovelIndelFilter.h
More file actions
executable file
·124 lines (106 loc) · 2.79 KB
/
novelIndelFilter.h
File metadata and controls
executable file
·124 lines (106 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <cstdio>
#include <getopt.h>
#include <cstdlib>
#include <cstring>
struct parameters {
char* var_f;
char* mapping_f;
char* type;
unsigned int unique;
unsigned int skipPileup;
char* chr;
};
struct parameters* interface(struct parameters* param,int argc, char *argv[]);
void delete_param(struct parameters* param);
void usage(void);
const char* program_name;
struct parameters* interface(struct parameters* param, int argc, char *argv[]){
program_name = argv[0];
int c; // the next argument
int help = 0;
if (argc < 2) {
usage();
exit(0);
}
param = new struct parameters;
param->var_f = new char;
param->mapping_f = new char;
param->type = new char;
param->chr = new char;
const struct option long_options[] ={
{"var",1,0, 'v'},
{"mapping",1,0,'m'},
{"type",1,0,'t'},
{"unique",0,0,'u'},
{"skipPileup",0,0,'s'},
{"chr",1,0,'c'},
{"help",0,0,'h'},
{0, 0, 0, 0}
};
while (1) {
int option_index = 0;
c = getopt_long_only (argc, argv,"husv:m:t:c:",long_options, &option_index);
if (c == -1) {
break;
}
switch(c) {
case 0:
break;
case 'v':
param->var_f = optarg;
break;
case 'm':
param->mapping_f = optarg;
break;
case 't':
param->type = optarg;
break;
case 'u':
param->unique = 1;
break;
case 's':
param->skipPileup = 1;
break;
case 'c':
param->chr = optarg;
break;
case 'h':
help = 1;
break;
case '?':
help = 1;
break;
default:
help = 1;
break;
}
}
if(help) {
usage();
delete_param(param);
exit(0);
}
return param;
}
void usage()
{
fprintf(stdout, "\nnovelSnvFilter.cpp, Copyright (C) 2016 Sun Ruping <ruping@stanford.edu>\n");
fprintf(stdout, "\n");
fprintf(stdout, "Usage: %s options [inputfile] \n\n", program_name);
fprintf(stdout, "-h --help print the help message\n");
fprintf(stdout, "-v --var <filename> sorted vcf file contains only variants that are novel.\n");
fprintf(stdout, "-m --mapping <filename> mapping_file (coordinates' sorted bam-file or file of bam-file names).\n");
fprintf(stdout, "-q --unique only calculate for uniquely mapped reads (set this when the bam files contain multi-mapping reads).\n");
fprintf(stdout, "-s --skipPileup skip piled up reads.\n");
fprintf(stdout, "-c --chr <prefix> set to prefix when the chromosome names in bam files starting with a prefix, e.g., chr, Chr, CHR.\n");
fprintf(stdout, "-t --type <p/s> under development\n");
fprintf(stdout, "\n");
}
void delete_param(struct parameters* param)
{
delete(param->var_f);
delete(param->mapping_f);
delete(param->type);
delete(param->chr);
delete(param);
}