annotate mrsfast-2.3.0.2/CommandLineParser.c @ 0:ec628ba33878 default tip

Uploaded source code for mrsFAST
author calkan
date Tue, 21 Feb 2012 10:39:28 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
1 /*
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
2 * Copyright (c) <2008 - 2009>, University of Washington, Simon Fraser University
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
3 * All rights reserved.
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
4 *
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
5 * Redistribution and use in source and binary forms, with or without modification,
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
6 * are permitted provided that the following conditions are met:
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
7 *
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
8 * Redistributions of source code must retain the above copyright notice, this list
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
9 * of conditions and the following disclaimer.
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
10 * - Redistributions in binary form must reproduce the above copyright notice, this
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
11 * list of conditions and the following disclaimer in the documentation and/or other
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
12 * materials provided with the distribution.
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
13 * - Neither the name of the <ORGANIZATION> nor the names of its contributors may be
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
14 * used to endorse or promote products derived from this software without specific
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
15 * prior written permission.
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
16 *
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
28 */
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
29
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
30 /*
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
31 * Author : Faraz Hach
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
32 * Email : fhach AT cs DOT sfu
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
33 * Last Update : 2009-01-29
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
34 */
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
35
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
36 #include <stdio.h>
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
37 #include <stdlib.h>
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
38 #include <getopt.h>
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
39 #include <string.h>
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
40 #include <ctype.h>
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
41 #include "Common.h"
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
42 #include "CommandLineParser.h"
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
43
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
44 int uniqueMode=1;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
45 int indexingMode;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
46 int searchingMode;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
47 int bisulfiteMode;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
48 int pairedEndMode;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
49 int pairedEndDiscordantMode;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
50 int pairedEndProfilingMode;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
51 int seqCompressed;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
52 int outCompressed;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
53 int cropSize = 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
54 int progressRep = 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
55 int minPairEndedDistance=-1;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
56 int maxPairEndedDistance=-1;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
57 int minPairEndedDiscordantDistance=-1;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
58 int maxPairEndedDiscordantDistance=-1;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
59 char *seqFile1;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
60 char *seqFile2;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
61 char *mappingOutput = "output";
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
62 char *mappingOutputPath = "";
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
63 char *unmappedOutput = "";
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
64 char fileName[1000][2][FILE_NAME_LENGTH];
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
65 int fileCnt;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
66 unsigned char errThreshold=2;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
67 unsigned char maxHits=0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
68 unsigned char WINDOW_SIZE = 12;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
69 unsigned int CONTIG_SIZE;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
70 unsigned int CONTIG_MAX_SIZE;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
71
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
72 void printHelp();
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
73
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
74 int parseCommandLine (int argc, char *argv[])
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
75 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
76
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
77 int o;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
78 int index;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
79 char *fastaFile = NULL;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
80 char *fastaOutputFile = NULL;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
81 char *indexFile = NULL;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
82 char *batchFile = NULL ;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
83 int batchMode = 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
84 static struct option longOptions[] =
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
85 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
86
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
87 // {"bs", no_argument, &bisulfiteMode, 1},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
88 {"pe", no_argument, &pairedEndMode, 1},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
89 {"discordant-vh", no_argument, &pairedEndDiscordantMode, 1},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
90 {"profile", no_argument, &pairedEndProfilingMode, 1},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
91 {"seqcomp", no_argument, &seqCompressed, 1},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
92 {"outcomp", no_argument, &outCompressed, 1},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
93 {"progress", no_argument, &progressRep, 1},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
94 {"index", required_argument, 0, 'i'},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
95 {"search", required_argument, 0, 's'},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
96 {"help", no_argument, 0, 'h'},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
97 {"version", no_argument, 0, 'v'},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
98 {"seq", required_argument, 0, 'x'},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
99 {"seq1", required_argument, 0, 'x'},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
100 {"seq2", required_argument, 0, 'y'},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
101 {"ws", required_argument, 0, 'w'},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
102 {"min", required_argument, 0, 'l'},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
103 {"max", required_argument, 0, 'm'},
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
104 {"crop", required_argument, 0, 'c'}
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
105
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
106 };
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
107
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
108
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
109
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
110 while ( (o = getopt_long ( argc, argv, "f:i:u:o:s:e:n:bhv", longOptions, &index))!= -1 )
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
111 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
112 switch (o)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
113 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
114 case 'i':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
115 indexingMode = 1;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
116 fastaFile = optarg;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
117 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
118 case 's':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
119 searchingMode = 1;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
120 fastaFile = optarg;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
121 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
122 case 'b':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
123 batchMode = 1;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
124 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
125 case 'c':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
126 cropSize = atoi(optarg);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
127 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
128 case 'w':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
129 WINDOW_SIZE = atoi(optarg);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
130 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
131 case 'x':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
132 seqFile1 = optarg;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
133 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
134 case 'y':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
135 seqFile2 = optarg;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
136 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
137 case 'u':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
138 unmappedOutput = optarg;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
139 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
140 case 'o':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
141 mappingOutput = getMem(FILE_NAME_LENGTH);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
142 mappingOutputPath = getMem(FILE_NAME_LENGTH);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
143 stripPath (optarg, &mappingOutputPath, &mappingOutput);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
144 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
145 case 'n':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
146 maxHits = atoi(optarg);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
147 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
148 case 'e':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
149 errThreshold = atoi(optarg);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
150 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
151 case 'l':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
152 minPairEndedDistance = atoi(optarg);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
153 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
154 case 'm':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
155 maxPairEndedDistance = atoi(optarg);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
156 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
157 case 'h':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
158 printHelp();
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
159 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
160 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
161 case 'v':
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
162 fprintf(stdout, "%s.%s\n", versionNumber, versionNumberF);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
163 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
164 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
165 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
166
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
167 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
168
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
169 if (indexingMode + searchingMode != 1)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
170 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
171 fprintf(stdout, "ERROR: Indexing / Searching mode should be selected\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
172 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
173 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
174
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
175 if (WINDOW_SIZE > 14 || WINDOW_SIZE < 8)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
176 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
177 fprintf(stdout, "ERROR: Window size should be in [8..14]\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
178 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
179 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
180
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
181
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
182 if ( indexingMode )
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
183 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
184 CONTIG_SIZE = 15000000;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
185 CONTIG_MAX_SIZE = 40000000;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
186
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
187 if (batchMode)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
188 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
189 batchFile = fastaFile;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
190 fastaFile = NULL;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
191 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
192
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
193 if (batchFile == NULL && fastaFile == NULL)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
194 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
195 fprintf(stdout, "ERROR: Reference(s) should be indicated for indexing\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
196 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
197 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
198
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
199 if (pairedEndDiscordantMode)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
200 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
201 fprintf(stdout, "ERROR: --discordant cannot be used in indexing mode. \n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
202 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
203 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
204
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
205 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
206
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
207
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
208 if ( searchingMode )
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
209 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
210 CONTIG_SIZE = 300000000;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
211 CONTIG_MAX_SIZE = 300000000;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
212
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
213
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
214 if (batchMode)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
215 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
216 batchFile = fastaFile;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
217 fastaFile = NULL;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
218 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
219
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
220 if (batchFile == NULL && fastaFile == NULL)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
221 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
222 fprintf(stdout, "ERROR: Index File(s) should be indiciated for searching\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
223 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
224 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
225
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
226 if (seqFile1 == NULL && seqFile2 == NULL)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
227 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
228 fprintf(stdout, "ERROR: Please indicate a sequence file for searching.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
229 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
230 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
231
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
232
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
233 if (!pairedEndMode && !bisulfiteMode && seqFile2 != NULL)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
234 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
235 fprintf(stdout, "ERROR: Second File can be indicated in pairedend/bisulfite mode\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
236 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
237 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
238
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
239 if (pairedEndMode && (minPairEndedDistance <0 || maxPairEndedDistance < 0 || minPairEndedDistance > maxPairEndedDistance))
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
240 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
241 fprintf(stdout, "ERROR: Please enter a valid range for pairedend sequences.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
242 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
243 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
244
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
245 if (pairedEndMode && seqFile1 == NULL)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
246 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
247 fprintf(stdout, "ERROR: Please indicate the first file for pairedend search.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
248 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
249 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
250
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
251 if (!pairedEndMode && pairedEndDiscordantMode)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
252 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
253 fprintf(stdout, "ERROR: --discordant should be used with --pe");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
254 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
255 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
256
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
257 if (!pairedEndMode && pairedEndProfilingMode)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
258 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
259 fprintf(stdout, "ERROR: --profile should be used with --pe");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
260 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
261 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
262 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
263
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
264 int i = 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
265
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
266
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
267 if (batchMode)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
268 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
269 FILE *fp = fileOpen(batchFile, "r");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
270
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
271 if (fp == NULL)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
272 return 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
273
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
274 fileCnt = 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
275
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
276 while ( fgets(fileName[fileCnt][0], FILE_NAME_LENGTH, fp))
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
277 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
278 for (i = strlen(fileName[fileCnt][0])-1; i>=0; i--)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
279 if ( !isspace(fileName[fileCnt][0][i]))
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
280 break;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
281 fileName[fileCnt][0][i+1] = '\0';
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
282
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
283 if (strcmp(fileName[fileCnt][0], "") != 0)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
284 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
285 if (bisulfiteMode)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
286 sprintf(fileName[fileCnt][1], "%s.bsindex", fileName[fileCnt][0]);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
287 else
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
288 sprintf(fileName[fileCnt][1], "%s.index", fileName[fileCnt][0]);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
289 fileCnt++;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
290 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
291 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
292 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
293 else
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
294 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
295 sprintf(fileName[fileCnt][0], "%s", fastaFile);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
296 if (bisulfiteMode)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
297 sprintf(fileName[fileCnt][1], "%s.bsindex", fileName[fileCnt][0]);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
298 else
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
299 sprintf(fileName[fileCnt][1], "%s.index", fileName[fileCnt][0]);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
300 fileCnt++;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
301 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
302
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
303
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
304 if (pairedEndProfilingMode)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
305 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
306
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
307 minPairEndedDistance = 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
308 maxPairEndedDistance = 300000000;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
309
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
310 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
311
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
312 if (pairedEndDiscordantMode)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
313 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
314 minPairEndedDiscordantDistance = minPairEndedDistance;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
315 maxPairEndedDiscordantDistance = maxPairEndedDistance;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
316
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
317 minPairEndedDistance = 0;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
318 maxPairEndedDistance = 300000000;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
319 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
320
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
321 return 1;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
322 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
323
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
324
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
325 void printHelp()
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
326 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
327 char *errorType;
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
328 if (mrFAST)
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
329 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
330 fprintf(stdout,"mrFAST : Micro-Read Fast Alignment Search Tool.\n\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
331 fprintf(stdout,"Usage: mrFAST [options]\n\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
332 errorType="edit distance";
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
333 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
334 else
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
335 {
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
336 fprintf(stdout,"mrsFAST : Micro-Read Substitutions (only) Fast Alignment Search Tool.\n\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
337 fprintf(stdout,"mrsFAST is a cache oblivious read mapping tool. mrsFAST capable of mapping\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
338 fprintf(stdout,"single and paired end reads to the reference genome. Bisulfite treated \n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
339 fprintf(stdout,"sequences are not supported in this version. By default mrsFAST reports \n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
340 fprintf(stdout,"the output in SAM format.\n\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
341 fprintf(stdout,"Usage: mrsFAST [options]\n\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
342 errorType="hamming distance";
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
343 }
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
344
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
345 fprintf(stdout,"General Options:\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
346 fprintf(stdout," -v|--version\t\tCurrent Version.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
347 fprintf(stdout," -h\t\t\tShows the help file.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
348 fprintf(stdout,"\n\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
349
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
350 fprintf(stdout,"Indexing Options:\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
351 fprintf(stdout," --index [file]\t\tGenerate an index from the specified fasta file. \n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
352 fprintf(stdout," -b\t\t\tIndicates the indexing will be done in batch mode.\n\t\t\tThe file specified in --index should contain the \n\t\t\tlist of fasta files.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
353 fprintf(stdout," -ws [int]\t\tSet window size for indexing (default:12-min:8 max:14).\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
354 // fprintf(stdout," -bs \t\t\tBisulfite mode.");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
355 fprintf(stdout,"\n\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
356
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
357 fprintf(stdout,"Searching Options:\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
358 fprintf(stdout," --search [file]\tSearch the specified genome. Index file should be \n\t\t\tin same directory as the fasta file.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
359 fprintf(stdout," -b\t\t\tIndicates the mapping will be done in batch mode. \n\t\t\tThe file specified in --search should contain the \n\t\t\tlist of fasta files.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
360 fprintf(stdout," --pe \t\t\tSearch will be done in Pairedend mode.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
361 // fprintf(stdout," --bs \t\t\tSearch will be done in Bisulfite mode.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
362 fprintf(stdout," --seq [file]\t\tInput sequences in fasta/fastq format [file]. If \n\t\t\tpairend reads are interleaved, use this option.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
363 fprintf(stdout," --seq1 [file]\t\tInput sequences in fasta/fastq format [file] (First \n\t\t\tfile). Use this option to indicate the first file of \n\t\t\tpair-end reads. You can use this option alone in \n\t\t\tbisulfite mode. \n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
364 fprintf(stdout," --seq2 [file]\t\tInput sequences in fasta/fastq format [file] (Second \n\t\t\tfile). Use this option to indicate the second file of \n\t\t\tpair-end reads. You can use this option alone in \n\t\t\tbisulfite mode. \n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
365 fprintf(stdout," -o [file]\t\tOutput of the mapped sequences. The default is output.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
366 fprintf(stdout," --seqcomp \t\tIndicates that the input sequences are compressed(gz).\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
367 fprintf(stdout," --outcomp \t\tIndicates that output file should be compressed(gz).\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
368 // fprintf(stdout," -u [file]\t\tSave unmapped sequences to the [file] in fasta format.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
369 fprintf(stdout," -n [int]\t\tMaximum number of locations reported for a sequence \n\t\t\t(default 0, all mappings). \n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
370 fprintf(stdout," -e [int]\t\t%s (default 2).\n", errorType);
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
371 fprintf(stdout," --min [int]\t\tMin inferred distance allowed between two pairend sequences.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
372 fprintf(stdout," --max [int]\t\tMax inferred distance allowed between two pairend sequences.\n");
ec628ba33878 Uploaded source code for mrsFAST
calkan
parents:
diff changeset
373 }