Debian Codegraph @

meryl/args.C

raw symbols SCIP
1 #cxx . . $ `<file>/meryl/args.C`/include <stdio.h>
2 #include <stdlib.h>
3 #include <errno.h>
4 #include <string.h>
5
6 #include "bio++.H"cxx . . $ `<file>/libbio/bio++.H`/
7 #include "meryl.H"cxx . . $ `<file>/meryl/meryl.H`/
8
9
10 // Some string handling utilities.
11 //
12 bool
13 writeStringcxx . . $ writeString(91a5c3a6cfa07170).(const char *str, FILE *F) {
14 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
15
16 uint32cxx . . $ uint32# len = 0;
17 if (str) {
18 len = (uint32cxx . . $ uint32#)strlen(str) + 1;
19 fwrite(&len, sizeof(uint32cxx . . $ uint32#), 1, F);
20 fwrite( str, sizeof(char), len, F);
21 } else {
22 fwrite(&len, sizeof(uint32cxx . . $ uint32#), 1, F);
23 }
24
25 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) {
26 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "writeString()-- Failed to write string of length "uint32FMTcxx . . $ `libutil/util.h:65:10`!": %s\n", len, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
27 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "writeString()-- First 80 bytes of string is:\n");
28 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%80.80s\n", str);
29 return(false);
30 }
31
32 return(true);
33 }
34
35 char*
36 readStringcxx . . $ readString(e31226b218f63160).(FILE *F) {
37 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
38
39 uint32cxx . . $ uint32# len = 0;
40 fread(&len, sizeof(uint32cxx . . $ uint32#), 1, F);
41 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) {
42 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "readString()-- Failed to read string: %s\n", strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
43 exitcxx . . $ exit(44ed87f96534fad7).(1);
44 }
45
46 char *str = 0L;
47
48 if (len > 0) {
49 str = new char [len];
50 fread(str, sizeof(char), len, F);
51 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) {
52 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "readString()-- Failed to read string: %s\n", strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
53 exitcxx . . $ exit(44ed87f96534fad7).(1);
54 }
55 }
56
57 return(str);
58 }
59
60 char*
61 duplStringcxx . . $ duplString(7a9722d75b371431).(char *str) {
62 char *dupstr = 0L;
63 if (str) {
64 uint32cxx . . $ uint32# len = (uint32cxx . . $ uint32#)strlen(str);
65 dupstr = new char [len+1];
66 strcpy(dupstr, str);
67 }
68 return(dupstr);
69 }
70
71
72
73 void
74 merylArgscxx . . $ merylArgs#::usagecxx . . $ merylArgs#usage(49f6e7a06ebc5aa8).(void) {
75 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: %s [personality] [global options] [options]\n", execNamecxx . . $ merylArgs#execName.);
76 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
77 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "where personality is:\n");
78 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -P -- compute parameters\n");
79 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -B -- build table\n");
80 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -S -- scan table\n");
81 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -M -- \"math\" operations\n");
82 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -D -- dump table\n");
83 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
84 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "-P: Given a sequence file (-s) or an upper limit on the\n");
85 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " number of mers in the file (-n), compute the table size\n");
86 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " (-t in build) to minimize the memory usage.\n");
87 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -m # (size of a mer; required)\n");
88 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -c # (homopolymer compression; optional)\n");
89 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -p (enable positions)\n");
90 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -s seq.fasta (seq.fasta is scanned to determine the number of mers)\n");
91 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -n # (compute params assuming file with this many mers in it)\n");
92 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
93 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Only one of -s, -n need to be specified. If both are given\n");
94 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -s takes priority.\n");
95 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
96 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
97 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "-B: Given a sequence file (-s) and lots of parameters, compute\n");
98 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " the mer-count tables. By default, both strands are processed.\n");
99 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -f (only build for the forward strand)\n");
100 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -r (only build for the reverse strand)\n");
101 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -C (use canonical mers, assumes both strands)\n");
102 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -L # (DON'T save mers that occur less than # times)\n");
103 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -U # (DON'T save mers that occur more than # times)\n");
104 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -m # (size of a mer; required)\n");
105 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -c # (homopolymer compression; optional)\n");
106 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -p (enable positions)\n");
107 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -s seq.fasta (sequence to build the table for)\n");
108 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -o tblprefix (output table prefix)\n");
109 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -v (entertain the user)\n");
110 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
111 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " By default, the computation is done as one large sequential process.\n");
112 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Multi-threaded operation is possible, at additional memory expense, as\n");
113 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " is segmented operation, at additional I/O expense.\n");
114 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
115 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Threaded operation: Split the counting in to n almost-equally sized\n");
116 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " pieces. This uses an extra h MB (from -P) per thread.\n");
117 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -threads n (use n threads to build)\n");
118 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
119 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Segmented, sequential operation: Split the counting into pieces that\n");
120 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " will fit into no more than m MB of memory, or into n equal sized pieces.\n");
121 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Each piece is computed sequentially, and the results are merged at the end.\n");
122 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Only one of -memory and -segments is needed.\n");
123 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -memory mMB (use at most m MB of memory per segment)\n");
124 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -segments n (use n segments)\n");
125 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
126 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Segmented, batched operation: Same as sequential, except this allows\n");
127 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " each segment to be manually executed in parallel.\n");
128 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Only one of -memory and -segments is needed.\n");
129 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -memory mMB (use at most m MB of memory per segment)\n");
130 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -segments n (use n segments)\n");
131 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -configbatch (create the batches)\n");
132 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -countbatch n (run batch number n)\n");
133 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -mergebatch (merge the batches)\n");
134 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Initialize the compute with -configbatch, which needs all the build options.\n");
135 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Execute all -countbatch jobs, then -mergebatch to complete.\n");
136 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " meryl -configbatch -B [options] -o file\n");
137 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " meryl -countbatch 0 -o file\n");
138 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " meryl -countbatch 1 -o file\n");
139 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " ...\n");
140 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " meryl -countbatch N -o file\n");
141 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " meryl -mergebatch N -o file\n");
142 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Batched mode can run on the grid.\n");
143 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -sge jobname unique job name for this execution. Meryl will submit\n");
144 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " jobs with name mpjobname, ncjobname, nmjobname, for\n");
145 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " phases prepare, count and merge.\n");
146 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -sgebuild \"options\" any additional options to sge, e.g.,\n");
147 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -sgemerge \"options\" \"-p -153 -pe thread 2 -A merylaccount\"\n");
148 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " N.B. - -N will be ignored\n");
149 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " N.B. - be sure to quote the options\n");
150 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
151 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "-M: Given a list of tables, perform a math, logical or threshold operation.\n");
152 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Unless specified, all operations take any number of databases.\n");
153 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
154 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Math operations are:\n");
155 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " min count is the minimum count for all databases. If the mer\n");
156 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " does NOT exist in all databases, the mer has a zero count, and\n");
157 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " is NOT in the output.\n");
158 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " minexist count is the minimum count for all databases that contain the mer\n");
159 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " max count is the maximum count for all databases\n");
160 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " add count is sum of the counts for all databases\n");
161 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " sub count is the first minus the second (binary only)\n");
162 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " abs count is the absolute value of the first minus the second (binary only)\n");
163 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
164 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Logical operations are:\n");
165 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " and outputs mer iff it exists in all databases\n");
166 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " nand outputs mer iff it exists in at least one, but not all, databases\n");
167 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " or outputs mer iff it exists in at least one database\n");
168 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " xor outputs mer iff it exists in an odd number of databases\n");
169 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
170 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Threshold operations are:\n");
171 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " lessthan x outputs mer iff it has count < x\n");
172 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " lessthanorequal x outputs mer iff it has count <= x\n");
173 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " greaterthan x outputs mer iff it has count > x\n");
174 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " greaterthanorequal x outputs mer iff it has count >= x\n");
175 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " equal x outputs mer iff it has count == x\n");
176 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Threshold operations work on exactly one database.\n");
177 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
178 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -s tblprefix (use tblprefix as a database)\n");
179 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -o tblprefix (create this output)\n");
180 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -v (entertain the user)\n");
181 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
182 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " NOTE: Multiple tables are specified with multiple -s switches; e.g.:\n");
183 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " %s -M add -s 1 -s 2 -s 3 -s 4 -o all\n", execNamecxx . . $ merylArgs#execName.);
184 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " NOTE: It is NOT possible to specify more than one operation:\n");
185 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " %s -M add -s 1 -s 2 -sub -s 3\n", execNamecxx . . $ merylArgs#execName.);
186 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " will NOT work.\n");
187 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
188 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
189 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "-D: Dump the table (not all of these work).\n");
190 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
191 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -Dd Dump a histogram of the distance between the same mers.\n");
192 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -Dt Dump mers >= a threshold. Use -n to specify the threshold.\n");
193 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -Dc Count the number of mers, distinct mers and unique mers.\n");
194 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -Dh Dump (to stdout) a histogram of mer counts.\n");
195 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -s Read the count table from here (leave off the .mcdat or .mcidx).\n");
196 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
197 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
198 }
199
200
201
202 void
203 merylArgscxx . . $ merylArgs#::clearcxx . . $ merylArgs#clear(49f6e7a06ebc5aa8).(void) {
204
205 execNamecxx . . $ merylArgs#execName. = 0L;
206 optionscxx . . $ merylArgs#options. = 0L;
207
208 beVerbosecxx . . $ merylArgs#beVerbose. = false;
209 doForwardcxx . . $ merylArgs#doForward. = true;
210 doReversecxx . . $ merylArgs#doReverse. = false;
211 doCanonicalcxx . . $ merylArgs#doCanonical. = false;
212
213 inputFilecxx . . $ merylArgs#inputFile. = 0L;
214 outputFilecxx . . $ merylArgs#outputFile. = 0L;
215 queryFilecxx . . $ merylArgs#queryFile. = 0L;
216
217 merSizecxx . . $ merylArgs#merSize. = 20;
218 merCompcxx . . $ merylArgs#merComp. = 0;
219 positionsEnabledcxx . . $ merylArgs#positionsEnabled. = false;
220
221 numMersEstimatedcxx . . $ merylArgs#numMersEstimated. = 0;
222 numMersActualcxx . . $ merylArgs#numMersActual. = 0;
223
224 numBasesActualcxx . . $ merylArgs#numBasesActual. = 0;
225
226 mersPerBatchcxx . . $ merylArgs#mersPerBatch. = 0;
227 basesPerBatchcxx . . $ merylArgs#basesPerBatch. = 0;
228
229 numBucketscxx . . $ merylArgs#numBuckets. = 0;
230 numBuckets_log2cxx . . $ merylArgs#numBuckets_log2. = 0;
231 merDataWidthcxx . . $ merylArgs#merDataWidth. = 0;
232 merDataMaskcxx . . $ merylArgs#merDataMask. = uint64ZEROcxx . . $ `libutil/util.h:50:10`!;
233 bucketPointerWidthcxx . . $ merylArgs#bucketPointerWidth. = 0;
234
235 numThreadscxx . . $ merylArgs#numThreads. = 0;
236 memoryLimitcxx . . $ merylArgs#memoryLimit. = 0;
237 segmentLimitcxx . . $ merylArgs#segmentLimit. = 0;
238 configBatchcxx . . $ merylArgs#configBatch. = false;
239 countBatchcxx . . $ merylArgs#countBatch. = false;
240 mergeBatchcxx . . $ merylArgs#mergeBatch. = false;
241 batchNumbercxx . . $ merylArgs#batchNumber. = 0;
242
243 sgeJobNamecxx . . $ merylArgs#sgeJobName. = 0L;
244 sgeBuildOptcxx . . $ merylArgs#sgeBuildOpt. = 0L;
245 sgeMergeOptcxx . . $ merylArgs#sgeMergeOpt. = 0L;
246 isOnGridcxx . . $ merylArgs#isOnGrid. = false;
247
248 lowCountcxx . . $ merylArgs#lowCount. = 0;
249 highCountcxx . . $ merylArgs#highCount. = ~lowCountcxx . . $ merylArgs#lowCount.;
250 desiredCountcxx . . $ merylArgs#desiredCount. = 0;
251
252 outputCountcxx . . $ merylArgs#outputCount. = 0;
253 outputAllcxx . . $ merylArgs#outputAll. = 0;
254 outputPositioncxx . . $ merylArgs#outputPosition. = 0;
255
256 mergeFilesMaxcxx . . $ merylArgs#mergeFilesMax. = 0;
257 mergeFilesLencxx . . $ merylArgs#mergeFilesLen. = 0;
258 mergeFilescxx . . $ merylArgs#mergeFiles. = 0L;
259
260 personalitycxx . . $ merylArgs#personality. = 0;
261 }
262
263
264
265
266 merylArgscxx . . $ merylArgs#::merylArgscxx . . $ merylArgs#merylArgs(c759356ac01a31e7).(int argc, char **argv) {
267
268 clearcxx . . $ merylArgs#clear(49f6e7a06ebc5aa8).();
269
270 execNamecxx . . $ merylArgs#execName. = duplStringcxx . . $ duplString(7a9722d75b371431).(argv[0]);
271
272 if (argc == 1) {
273 usagecxx . . $ merylArgs#usage(49f6e7a06ebc5aa8).();
274 exitcxx . . $ exit(44ed87f96534fad7).(1);
275 }
276
277 // Count how many '-s' switches there are, then allocate space
278 // for them in mergeFiles. We also sum the length of all options,
279 // so we can copy them into an 'options' string used when we
280 // resubmit to the grid.
281 //
282 uint32cxx . . $ uint32# optionsLen = 0;
283 for (int arg=1; arg < argc; arg++) {
284 optionsLen += strlen(argv[arg]) + 1;
285 if (strcmp(argv[arg], "-s") == 0)
286 mergeFilesMaxcxx . . $ merylArgs#mergeFilesMax.++;
287 }
288
289 mergeFilescxx . . $ merylArgs#mergeFiles. = new char * [mergeFilesMaxcxx . . $ merylArgs#mergeFilesMax.];
290 optionscxx . . $ merylArgs#options. = new char [2 * optionsLen + 1];
291 optionscxx . . $ merylArgs#options.[0] = 0;
292
293 bool fail = false;
294
295 char *optptr = optionscxx . . $ merylArgs#options.;
296
297 for (int arg=1; arg < argc; arg++) {
298 if (arg > 1)
299 *optptr++ = ' ';
300
301 // Arg! If the arg has spaces or other stuff that the shell
302 // needs escaped we need to escape them again. So, we copy byte
303 // by byte and insert escapes at the right points.
304
305 for (char *op=argv[arg]; *op; op++, optptr++) {
306 if (isspace(*op) || !isalnum(*op))
307 if ((*op != '-') && (*op != '_') && (*op != '.') && (*op != '/'))
308 *optptr++ = '\\';
309 *optptr = *op;
310 }
311
312 //strcat(options, argv[arg]);
313 }
314
315
316 // Parse the options
317 //
318 for (int arg=1; arg < argc; arg++) {
319 if (strncmp(argv[arg], "-V", 2) == 0) {
320 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "meryl the Mighty Mer Counter version (no version)\n");
321 exitcxx . . $ exit(44ed87f96534fad7).(0);
322 } else if (strcmp(argv[arg], "-m") == 0) {
323 arg++;
324 merSizecxx . . $ merylArgs#merSize. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[arg], 0L);
325 } else if (strcmp(argv[arg], "-c") == 0) {
326 arg++;
327 merCompcxx . . $ merylArgs#merComp. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[arg], 0L);
328 } else if (strcmp(argv[arg], "-p") == 0) {
329 positionsEnabledcxx . . $ merylArgs#positionsEnabled. = true;
330 } else if (strcmp(argv[arg], "-s") == 0) {
331 arg++;
332 delete [] inputFilecxx . . $ merylArgs#inputFile.;
333 inputFilecxx . . $ merylArgs#inputFile. = duplStringcxx . . $ duplString(7a9722d75b371431).(argv[arg]);
334 mergeFilescxx . . $ merylArgs#mergeFiles.[mergeFilesLencxx . . $ merylArgs#mergeFilesLen.++] = duplStringcxx . . $ duplString(7a9722d75b371431).(argv[arg]);
335 } else if (strcmp(argv[arg], "-n") == 0) {
336 arg++;
337 numMersEstimatedcxx . . $ merylArgs#numMersEstimated. = strtouint64cxx . . $ `libutil/util.h:83:10`!(argv[arg], 0L);
338 } else if (strcmp(argv[arg], "-f") == 0) {
339 doForwardcxx . . $ merylArgs#doForward. = true;
340 doReversecxx . . $ merylArgs#doReverse. = false;
341 doCanonicalcxx . . $ merylArgs#doCanonical. = false;
342 } else if (strcmp(argv[arg], "-r") == 0) {
343 doForwardcxx . . $ merylArgs#doForward. = false;
344 doReversecxx . . $ merylArgs#doReverse. = true;
345 doCanonicalcxx . . $ merylArgs#doCanonical. = false;
346 } else if (strcmp(argv[arg], "-C") == 0) {
347 doForwardcxx . . $ merylArgs#doForward. = false;
348 doReversecxx . . $ merylArgs#doReverse. = false;
349 doCanonicalcxx . . $ merylArgs#doCanonical. = true;
350 } else if (strcmp(argv[arg], "-L") == 0) {
351 arg++;
352 lowCountcxx . . $ merylArgs#lowCount. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[arg], 0L);
353 } else if (strcmp(argv[arg], "-U") == 0) {
354 arg++;
355 highCountcxx . . $ merylArgs#highCount. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[arg], 0L);
356 } else if (strcmp(argv[arg], "-o") == 0) {
357 arg++;
358 delete [] outputFilecxx . . $ merylArgs#outputFile.;
359 outputFilecxx . . $ merylArgs#outputFile. = duplStringcxx . . $ duplString(7a9722d75b371431).(argv[arg]);
360 } else if (strcmp(argv[arg], "-v") == 0) {
361 beVerbosecxx . . $ merylArgs#beVerbose. = true;
362
363 } else if (strcmp(argv[arg], "-P") == 0) {
364 personalitycxx . . $ merylArgs#personality. = 'P';
365 } else if (strcmp(argv[arg], "-B") == 0) {
366 personalitycxx . . $ merylArgs#personality. = 'B';
367 } else if (strcmp(argv[arg], "-S") == 0) {
368 personalitycxx . . $ merylArgs#personality. = 'S';
369 } else if (strcmp(argv[arg], "-M") == 0) {
370 arg++;
371 if (strcmp(argv[arg], "merge") == 0) {
372 personalitycxx . . $ merylArgs#personality. = PERSONALITY_MERGEcxx . . $ `meryl/meryl.H:6:9`!;
373 } else if (strcmp(argv[arg], "min") == 0) {
374 personalitycxx . . $ merylArgs#personality. = PERSONALITY_MINcxx . . $ `meryl/meryl.H:8:9`!;
375 } else if (strcmp(argv[arg], "minexist") == 0) {
376 personalitycxx . . $ merylArgs#personality. = PERSONALITY_MINEXISTcxx . . $ `meryl/meryl.H:9:9`!;
377 } else if (strcmp(argv[arg], "max") == 0) {
378 personalitycxx . . $ merylArgs#personality. = PERSONALITY_MAXcxx . . $ `meryl/meryl.H:10:9`!;
379 } else if (strcmp(argv[arg], "maxexist") == 0) {
380 personalitycxx . . $ merylArgs#personality. = PERSONALITY_MAXEXISTcxx . . $ `meryl/meryl.H:11:9`!;
381 } else if (strcmp(argv[arg], "add") == 0) {
382 personalitycxx . . $ merylArgs#personality. = PERSONALITY_ADDcxx . . $ `meryl/meryl.H:12:9`!;
383 } else if (strcmp(argv[arg], "sub") == 0) {
384 personalitycxx . . $ merylArgs#personality. = PERSONALITY_SUBcxx . . $ `meryl/meryl.H:13:9`!;
385 } else if (strcmp(argv[arg], "abs") == 0) {
386 personalitycxx . . $ merylArgs#personality. = PERSONALITY_ABScxx . . $ `meryl/meryl.H:15:9`!;
387 } else if (strcmp(argv[arg], "divide") == 0) {
388 personalitycxx . . $ merylArgs#personality. = PERSONALITY_DIVIDEcxx . . $ `meryl/meryl.H:14:9`!;
389 } else if (strcmp(argv[arg], "and") == 0) {
390 personalitycxx . . $ merylArgs#personality. = PERSONALITY_ANDcxx . . $ `meryl/meryl.H:17:9`!;
391 } else if (strcmp(argv[arg], "nand") == 0) {
392 personalitycxx . . $ merylArgs#personality. = PERSONALITY_NANDcxx . . $ `meryl/meryl.H:18:9`!;
393 } else if (strcmp(argv[arg], "or") == 0) {
394 personalitycxx . . $ merylArgs#personality. = PERSONALITY_ORcxx . . $ `meryl/meryl.H:19:9`!;
395 } else if (strcmp(argv[arg], "xor") == 0) {
396 personalitycxx . . $ merylArgs#personality. = PERSONALITY_XORcxx . . $ `meryl/meryl.H:20:9`!;
397 } else if (strcmp(argv[arg], "lessthan") == 0) {
398 personalitycxx . . $ merylArgs#personality. = PERSONALITY_LEQcxx . . $ `meryl/meryl.H:21:9`!;
399 arg++;
400 desiredCountcxx . . $ merylArgs#desiredCount. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[arg], 0L) - 1;
401 } else if (strcmp(argv[arg], "lessthanorequal") == 0) {
402 personalitycxx . . $ merylArgs#personality. = PERSONALITY_LEQcxx . . $ `meryl/meryl.H:21:9`!;
403 arg++;
404 desiredCountcxx . . $ merylArgs#desiredCount. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[arg], 0L);
405 } else if (strcmp(argv[arg], "greaterthan") == 0) {
406 personalitycxx . . $ merylArgs#personality. = PERSONALITY_GEQcxx . . $ `meryl/meryl.H:22:9`!;
407 arg++;
408 desiredCountcxx . . $ merylArgs#desiredCount. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[arg], 0L) + 1;
409 } else if (strcmp(argv[arg], "greaterthanorequal") == 0) {
410 personalitycxx . . $ merylArgs#personality. = PERSONALITY_GEQcxx . . $ `meryl/meryl.H:22:9`!;
411 arg++;
412 desiredCountcxx . . $ merylArgs#desiredCount. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[arg], 0L);
413 } else if (strcmp(argv[arg], "equal") == 0) {
414 personalitycxx . . $ merylArgs#personality. = PERSONALITY_EQcxx . . $ `meryl/meryl.H:23:9`!;
415 arg++;
416 desiredCountcxx . . $ merylArgs#desiredCount. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[arg], 0L);
417 } else {
418 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: unknown math personality %s\n", argv[arg]);
419 exitcxx . . $ exit(44ed87f96534fad7).(1);
420 }
421 } else if (strcmp(argv[arg], "-Dd") == 0) {
422 personalitycxx . . $ merylArgs#personality. = 'd';
423 } else if (strcmp(argv[arg], "-Dt") == 0) {
424 personalitycxx . . $ merylArgs#personality. = 't';
425 } else if (strcmp(argv[arg], "-Dp") == 0) {
426 personalitycxx . . $ merylArgs#personality. = 'p';
427 } else if (strcmp(argv[arg], "-Dc") == 0) {
428 personalitycxx . . $ merylArgs#personality. = 'c';
429 } else if (strcmp(argv[arg], "-Dh") == 0) {
430 personalitycxx . . $ merylArgs#personality. = 'h';
431 } else if (strcmp(argv[arg], "-memory") == 0) {
432 arg++;
433 memoryLimitcxx . . $ merylArgs#memoryLimit. = strtouint64cxx . . $ `libutil/util.h:83:10`!(argv[arg], 0L) * 1024 * 1024;
434 } else if (strcmp(argv[arg], "-segments") == 0) {
435 arg++;
436 segmentLimitcxx . . $ merylArgs#segmentLimit. = strtouint64cxx . . $ `libutil/util.h:83:10`!(argv[arg], 0L);
437 } else if (strcmp(argv[arg], "-threads") == 0) {
438 arg++;
439 numThreadscxx . . $ merylArgs#numThreads. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[arg], 0L);
440 } else if (strcmp(argv[arg], "-configbatch") == 0) {
441 personalitycxx . . $ merylArgs#personality. = 'B';
442 configBatchcxx . . $ merylArgs#configBatch. = true;
443 countBatchcxx . . $ merylArgs#countBatch. = false;
444 mergeBatchcxx . . $ merylArgs#mergeBatch. = false;
445 batchNumbercxx . . $ merylArgs#batchNumber. = uint32ZEROcxx . . $ `libutil/util.h:60:10`!;
446 } else if (strcmp(argv[arg], "-countbatch") == 0) {
447 arg++;
448 personalitycxx . . $ merylArgs#personality. = 'B';
449 configBatchcxx . . $ merylArgs#configBatch. = false;
450 countBatchcxx . . $ merylArgs#countBatch. = true;
451 mergeBatchcxx . . $ merylArgs#mergeBatch. = false;
452 batchNumbercxx . . $ merylArgs#batchNumber. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[arg], 0L);
453 } else if (strcmp(argv[arg], "-mergebatch") == 0) {
454 personalitycxx . . $ merylArgs#personality. = 'B';
455 configBatchcxx . . $ merylArgs#configBatch. = false;
456 countBatchcxx . . $ merylArgs#countBatch. = false;
457 mergeBatchcxx . . $ merylArgs#mergeBatch. = true;
458 batchNumbercxx . . $ merylArgs#batchNumber. = uint32ZEROcxx . . $ `libutil/util.h:60:10`!;
459 } else if (strcmp(argv[arg], "-sge") == 0) {
460 sgeJobNamecxx . . $ merylArgs#sgeJobName. = argv[++arg];
461 } else if (strcmp(argv[arg], "-sgebuild") == 0) {
462 sgeBuildOptcxx . . $ merylArgs#sgeBuildOpt. = argv[++arg];
463 } else if (strcmp(argv[arg], "-sgemerge") == 0) {
464 sgeMergeOptcxx . . $ merylArgs#sgeMergeOpt. = argv[++arg];
465 } else if (strcmp(argv[arg], "-forcebuild") == 0) {
466 isOnGridcxx . . $ merylArgs#isOnGrid. = true;
467 } else {
468 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Unknown option '%s'.\n", argv[arg]);
469 fail = true;
470 }
471 }
472
473 // Using threads is only useful if we are not a batch.
474 //
475 if ((numThreadscxx . . $ merylArgs#numThreads. > 0) && (configBatchcxx . . $ merylArgs#configBatch. || countBatchcxx . . $ merylArgs#countBatch. || mergeBatchcxx . . $ merylArgs#mergeBatch.)) {
476 if (configBatchcxx . . $ merylArgs#configBatch.)
477 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "WARNING: -threads has no effect with -configbatch, disabled.\n");
478 if (countBatchcxx . . $ merylArgs#countBatch.)
479 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "WARNING: -threads has no effect with -countbatch, disabled.\n");
480 if (mergeBatchcxx . . $ merylArgs#mergeBatch.)
481 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "WARNING: -threads has no effect with -mergebatch, disabled.\n");
482 numThreadscxx . . $ merylArgs#numThreads. = 0;
483 }
484
485 // SGE is not useful unless we are in batch mode.
486 //
487 if (sgeJobNamecxx . . $ merylArgs#sgeJobName. && !configBatchcxx . . $ merylArgs#configBatch. && !countBatchcxx . . $ merylArgs#countBatch. && !mergeBatchcxx . . $ merylArgs#mergeBatch.) {
488 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: -sge not useful unless in batch mode (replace -B with -configbatch)\n");
489 exitcxx . . $ exit(44ed87f96534fad7).(1);
490 }
491
492 if (fail)
493 exitcxx . . $ exit(44ed87f96534fad7).(1);
494 }
495
496
497
498 merylArgscxx . . $ merylArgs#::merylArgscxx . . $ merylArgs#merylArgs(85c52e162fed56f9).(const char *prefix) {
499
500 clearcxx . . $ merylArgs#clear(49f6e7a06ebc5aa8).();
501
502 char *filename = new char [strlen(prefix) + 17];
503 sprintf(filename, "%s.merylArgs", prefix);
504
505 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
506 FILE *F = fopen(filename, "rb");
507 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) {
508 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "merylArgs::readConfig()-- Failed to open '%s': %s\n", filename, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
509 exitcxx . . $ exit(44ed87f96534fad7).(1);
510 }
511
512 char magic[17] = {0};
513 fread(magic, sizeof(char), 16, F);
514 if (strncmp(magic, "merylBatcherv02", 16) != 0) {
515 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "merylArgs::readConfig()-- '%s' doesn't appear to be a merylArgs file.\n", filename);
516 exitcxx . . $ exit(44ed87f96534fad7).(1);
517 }
518
519 // Load the config, then reset the pointers.
520
521 fread(this, sizeof(merylArgscxx . . $ merylArgs#), 1, F);
522
523 execNamecxx . . $ merylArgs#execName. = readStringcxx . . $ readString(e31226b218f63160).(F);
524 optionscxx . . $ merylArgs#options. = 0L;
525 inputFilecxx . . $ merylArgs#inputFile. = readStringcxx . . $ readString(e31226b218f63160).(F);
526 outputFilecxx . . $ merylArgs#outputFile. = readStringcxx . . $ readString(e31226b218f63160).(F);
527 queryFilecxx . . $ merylArgs#queryFile. = 0L;
528 sgeJobNamecxx . . $ merylArgs#sgeJobName. = readStringcxx . . $ readString(e31226b218f63160).(F);
529 sgeBuildOptcxx . . $ merylArgs#sgeBuildOpt. = readStringcxx . . $ readString(e31226b218f63160).(F);
530 sgeMergeOptcxx . . $ merylArgs#sgeMergeOpt. = readStringcxx . . $ readString(e31226b218f63160).(F);
531
532 mergeFilescxx . . $ merylArgs#mergeFiles. = new char* [mergeFilesLencxx . . $ merylArgs#mergeFilesLen.];
533
534 for (uint32cxx . . $ uint32# i=0; i<mergeFilesLencxx . . $ merylArgs#mergeFilesLen.; i++)
535 mergeFilescxx . . $ merylArgs#mergeFiles.[i] = readStringcxx . . $ readString(e31226b218f63160).(F);
536
537 fclose(F);
538
539 delete [] filename;
540 }
541
542
543
544 merylArgscxx . . $ merylArgs#::~cxx . . $ merylArgs#`~merylArgs`(ced63f7c635d850d).merylArgscxx . . $ merylArgs#() {
545 delete [] execNamecxx . . $ merylArgs#execName.;
546 delete [] optionscxx . . $ merylArgs#options.;
547 delete [] inputFilecxx . . $ merylArgs#inputFile.;
548 delete [] outputFilecxx . . $ merylArgs#outputFile.;
549
550 for (uint32cxx . . $ uint32# i=0; i<mergeFilesLencxx . . $ merylArgs#mergeFilesLen.; i++)
551 delete [] mergeFilescxx . . $ merylArgs#mergeFiles.[i];
552
553 delete [] mergeFilescxx . . $ merylArgs#mergeFiles.;
554 }
555
556
557
558 bool
559 merylArgscxx . . $ merylArgs#::writeConfigcxx . . $ merylArgs#writeConfig(c9857a73d68e59ba).(void) {
560 char *filename;
561
562 filename = new char [strlen(outputFilecxx . . $ merylArgs#outputFile.) + 17];
563 sprintf(filename, "%s.merylArgs", outputFilecxx . . $ merylArgs#outputFile.);
564
565 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
566 FILE *F = fopen(filename, "wb");
567 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) {
568 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "merylArgs::writeConfig()-- Failed to open '%s': %s\n", filename, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
569 exitcxx . . $ exit(44ed87f96534fad7).(1);
570 }
571
572 fwrite("merylBatcherv02", sizeof(char), 16, F);
573
574 fwrite(this, sizeof(merylArgscxx . . $ merylArgs#), 1, F);
575
576 writeStringcxx . . $ writeString(91a5c3a6cfa07170).(execNamecxx . . $ merylArgs#execName., F);
577 writeStringcxx . . $ writeString(91a5c3a6cfa07170).(inputFilecxx . . $ merylArgs#inputFile., F);
578 writeStringcxx . . $ writeString(91a5c3a6cfa07170).(outputFilecxx . . $ merylArgs#outputFile., F);
579 writeStringcxx . . $ writeString(91a5c3a6cfa07170).(sgeJobNamecxx . . $ merylArgs#sgeJobName., F);
580 writeStringcxx . . $ writeString(91a5c3a6cfa07170).(sgeBuildOptcxx . . $ merylArgs#sgeBuildOpt., F);
581 writeStringcxx . . $ writeString(91a5c3a6cfa07170).(sgeMergeOptcxx . . $ merylArgs#sgeMergeOpt., F);
582
583 for (uint32cxx . . $ uint32# i=0; i<mergeFilesLencxx . . $ merylArgs#mergeFilesLen.; i++)
584 writeStringcxx . . $ writeString(91a5c3a6cfa07170).(mergeFilescxx . . $ merylArgs#mergeFiles.[i], F);
585
586 fclose(F);
587
588 return(true);
589 }