comparison mrcanavar-0.34/mrcanavar.c @ 0:86522a0b5f59 default tip

Uploaded source code for mrCaNaVaR
author calkan
date Tue, 21 Feb 2012 10:44:13 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:86522a0b5f59
1 #include "mrcanavar.h"
2
3
4
5 int main(int argc, char **argv){
6
7 int i;
8
9 char gzSAM;
10
11 char *indirSAM;
12 char *depthFile;
13 char *out_prefix;
14
15
16 init_globals();
17
18 gzSAM = 0;
19 indirSAM = NULL;
20 depthFile = NULL;
21 out_prefix = NULL;
22
23
24 for (i=1; i<argc; i++){
25
26
27 /* modes */
28 if (!strcmp(argv[i], "--prep"))
29 set_runmode(PREP);
30 else if (!strcmp(argv[i], "--read"))
31 set_runmode(READSAM);
32 else if (!strcmp(argv[i], "--call"))
33 set_runmode(CALL);
34
35
36 /* compulsory parameters for all modes */
37 else if (!strcmp(argv[i], "-conf"))
38 set_str(&GENOME_CONF, argv[i+1]);
39
40 /* compulsory parameters for the PREP mode */
41 else if (!strcmp(argv[i], "-fasta"))
42 set_str(&GENOME_FASTA, argv[i+1]);
43 else if (!strcmp(argv[i], "-gaps"))
44 set_str(&GENOME_GAPS, argv[i+1]);
45
46 /* optional parameters for the PREP mode */
47 else if (!strcmp(argv[i], "-lw_size"))
48 LW_SIZE = atoi(argv[i+1]);
49 else if (!strcmp(argv[i], "-sw_size"))
50 SW_SIZE = atoi(argv[i+1]);
51 else if (!strcmp(argv[i], "-cw_size"))
52 CW_SIZE = atoi(argv[i+1]);
53 else if (!strcmp(argv[i], "-lw_slide"))
54 LW_SLIDE = atoi(argv[i+1]);
55 else if (!strcmp(argv[i], "-sw_slide"))
56 SW_SLIDE = atoi(argv[i+1]);
57
58
59 /* compulsory parameters for both READ and CALL modes */
60 else if (!strcmp(argv[i], "-depth"))
61 set_str(&depthFile, argv[i+1]);
62
63 /* compulsory parameters for the READ mode */
64
65 else if (!strcmp(argv[i], "-samdir"))
66 set_str(&indirSAM, argv[i+1]);
67
68
69 /* optional parameters for the SAM mode */
70 else if (!strcmp(argv[i], "--gz"))
71 gzSAM = 1;
72
73
74 /* compulsory parameters for the CALL mode */
75 else if (!strcmp(argv[i], "-o"))
76 set_str(&out_prefix, argv[i+1]);
77
78 /* optional parameters for the CALL mode */
79 else if (!strcmp(argv[i], "-cont_win"))
80 CONT_WINDOW = atoi(argv[i+1]);
81 else if (!strcmp(argv[i], "-cut_win"))
82 CUT_WINDOW = atoi(argv[i+1]);
83 else if (!strcmp(argv[i], "--xx"))
84 set_gender(FEMALE);
85 else if (!strcmp(argv[i], "--xy"))
86 set_gender(MALE);
87 else if (!strcmp(argv[i], "--multgc"))
88 MULTGC = 1;
89
90
91
92
93 /* generic stuff */
94 else if (!strcmp(argv[i], "-v")){
95 fprintf (stdout, "\nmrCaNaVaR version %s.\nLast update: %s.\n\n", VERSION, LAST_UPDATE);
96 return 0;
97 }
98 else if (!strcmp(argv[i], "-h")){
99 printHelp(argv[0]);
100 return 0;
101 }
102 else if (!strcmp(argv[i], "--verbose"))
103 VERBOSE = 1;
104 else if (!strcmp(argv[i], "--disable-sam-check"))
105 CHECKSAM = 0;
106 }
107
108
109 switch(RUNMODE){
110 case NONE:
111 print_error("Select mode: --prep, ---read, or --call\n");
112 break;
113 case PREP:
114 fprintf(stdout, "Mode: Prepare genome...\n");
115 prep_genome();
116 break;
117 case READSAM:
118 fprintf(stdout, "Mode: Read SAM ...\n");
119 read_depth(indirSAM, depthFile, gzSAM);
120 break;
121 case CALL:
122 fprintf(stdout, "Mode: Call copy numbers ...\n");
123 call_cnv(depthFile, out_prefix);
124 break;
125 default:
126 break;
127 }
128
129 return 0;
130
131 }
132
133
134 void printHelp(char *binfile){
135
136 fprintf (stdout, "\nmrCaNaVaR version %s\nLast update: %s\n\n", VERSION, LAST_UPDATE);
137 fprintf (stdout, "%s --<mode> [options] \n\n", binfile);
138
139 fprintf (stdout, "======== RUN MODES ========\n\n");
140
141 fprintf (stdout, "\t--prep : Prepare reference genome configuration file.\n");
142 fprintf (stdout, "\t--read : Read mapping information from SAM files.\n");
143 fprintf (stdout, "\t--call : Call CNVs and predict copy numbers.\n\n");
144
145 fprintf (stdout, "======== PREP MODE COMPULSORY PARAMETERS ========\n\n");
146 fprintf (stdout, "\t-fasta <fasta_file> : FASTA file for the reference genome.\n");
147 fprintf (stdout, "\t-gaps <gaps_file> : Gap coordinates of the reference genome in BED format.\n");
148 fprintf (stdout, "\t-conf <config_file> : Reference configuration file (output).\n\n");
149 fprintf (stdout, "======== PREP MODE OPTIONAL PARAMETERS ========\n\n");
150 fprintf (stdout, "\t-lw_size <lw_size> : Long window span size. Default is 5000.\n");
151 fprintf (stdout, "\t-lw_slide <lw_slide> : Long window slide size. Default is 1000.\n");
152 fprintf (stdout, "\t-sw_size <sw_size> : Short window span size. Default is 1000.\n");
153 fprintf (stdout, "\t-sw_slide <sw_slide> : Short window slide size. Default is 1000.\n");
154 fprintf (stdout, "\t-cw_size <cw_size> : Copy number window size. Default is 1000.\n\n");
155
156 fprintf (stdout, "======== READ MODE COMPULSORY PARAMETERS ========\n\n");
157 fprintf (stdout, "\t-conf <config_file> : Reference configuration file (input).\n");
158 fprintf (stdout, "\t-samdir <sam_dir> : Directory that contains SAM files for mapping information.\n");
159 fprintf (stdout, "\t-depth <depth_file> : Read depth file (output).\n\n");
160 fprintf (stdout, "======== READ MODE OPTIONAL PARAMETERS ========\n\n");
161 fprintf (stdout, "\t--gz : Indicates that the SAM files are compressed in gzip format.\n\n");
162
163 fprintf (stdout, "======== CALL MODE COMPULSORY PARAMETERS ========\n\n");
164 fprintf (stdout, "\t-conf <config_file> : Reference configuration file (input).\n");
165 fprintf (stdout, "\t-depth <depth_file> : Read depth file (input).\n");
166 fprintf (stdout, "\t-o <out_prefix> : Prefix for the output file names.\n\n");
167
168
169 fprintf (stdout, "======== CALL MODE OPTIONAL PARAMETERS ========\n\n");
170 fprintf (stdout, "\t--xx : Set gender of the sequenced sample as female. Mammalian genomes only. Default is autodetect.\n");
171 fprintf (stdout, "\t--xy : Set gender of the sequenced sample as male. Mammalian genomes only. Default is autodetect.\n");
172 fprintf (stdout, "\t--multgc : Perform multiplicative GC correction. Default is additive.\n");
173 fprintf (stdout, "\t--verbose : Verbose output.\n");
174
175
176 /*
177
178 fprintf (stdout, "======== NOT IMPLEMENTED YET ========\n\n");
179 fprintf (stdout, "\t-cont_win <cwin_number> : Contiguous window number to look for high/low depth windows. Default is 7.\n");
180 fprintf (stdout, "\t-cut_win <cwin_cutoff> : Window number cutoff. Default is 6.\n\n");
181
182
183 */
184
185 }