Debian Codegraph @

leaff/leaff.C

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 #cxx . . $ `<file>/leaff/leaff.C`/include "bio++.H"cxx . . $ `<file>/libbio/bio++.H`/
2 #include "seqCache.H"cxx . . $ `<file>/libseq/seqCache.H`/
3 #include "seqStore.H"cxx . . $ `<file>/libseq/seqStore.H`/
4
5
6 // Analysis functions
7 //
8 void dumpBlockscxx . . $ dumpBlocks(fda57c8427c60377).(char *filename);
9 void statscxx . . $ stats(a14cc78460091691).(char *filename, uint64cxx . . $ uint64# refLen);
10 void partitionBySizecxx . . $ partitionBySize(26b798d52fc7d208).(char *prefix, uint64cxx . . $ uint64# partitionSize, char *filename);
11 void partitionByBucketcxx . . $ partitionByBucket(26b798d52fc7d208).(char *prefix, uint64cxx . . $ uint64# partitionSize, char *filename);
12 void partitionBySegmentcxx . . $ partitionBySegment(26b798d52fc7d208).(char *prefix, uint64cxx . . $ uint64# numSegments, char *filename);
13 void simseqcxx . . $ simseq(ecfae29d39139173).(char *,char *,int,int,int,int,double);
14 void computeGCcontentcxx . . $ computeGCcontent(fda57c8427c60377).(char *name);
15 void findDuplicatescxx . . $ findDuplicates(fda57c8427c60377).(char *filename);
16 void mapDuplicatescxx . . $ mapDuplicates(d0489a02ea06dfc6).(char *filea, char *fileb);
17
18 void processFilecxx . . $ processFile(fda57c8427c60377).(char *filename);
19 void processArraycxx . . $ processArray(c759356ac01a31e7).(int argc, char **argv);
20
21 bool doReversecxx . . $ doReverse. = false;
22 bool doComplementcxx . . $ doComplement. = false;
23 bool withDefLinecxx . . $ withDefLine. = true;
24 char *specialDefLinecxx . . $ specialDefLine. = 0L;
25 uint32cxx . . $ uint32# withLineBreakscxx . . $ withLineBreaks. = 0;
26
27 bool toUppercasecxx . . $ toUppercase. = false;
28 char translatecxx . . $ translate.[256] = {0};
29
30 seqCachecxx . . $ seqCache# *fastacxx . . $ fasta. = 0L;
31
32 uint32cxx . . $ uint32# begPoscxx . . $ begPos. = (uint32cxx . . $ uint32#)0;
33 uint32cxx . . $ uint32# endPoscxx . . $ endPos. = ~(uint32cxx . . $ uint32#)0;
34
35 uint32cxx . . $ uint32# endExtractcxx . . $ endExtract. = ~(uint32cxx . . $ uint32#)0;
36
37 mt_s *mtctxcxx . . $ mtctx. = 0L;
38
39
40 static
41 void
42 failIfNoSourcecxx . . $ failIfNoSource(49f6e7a06ebc5aa8).(void) {
43 if (fastacxx . . $ fasta. == 0L)
44 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "No source file specified.\n"), exitcxx . . $ exit(44ed87f96534fad7).(1);
45 }
46
47 static
48 void
49 failIfNotRandomAccesscxx . . $ failIfNotRandomAccess(49f6e7a06ebc5aa8).(void) {
50 if (fastacxx . . $ fasta.->randomAccessSupportedcxx . . $ seqCache#randomAccessSupported(c9857a73d68e59ba).() == false)
51 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Algorithm required random access; soruce file not supported.\n"), exitcxx . . $ exit(44ed87f96534fad7).(1);
52 }
53
54
55 static
56 void
57 helpStandardcxx . . $ helpStandard(fda57c8427c60377).(char *program) {
58 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: %s [-f fasta-file] [options]\n", program);
59 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
60 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SOURCE FILES\n");
61 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -f file: use sequence in 'file' (-F is also allowed for historical reasons)\n");
62 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -A file: read actions from 'file'\n");
63 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
64 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SOURCE FILE EXAMINATION\n");
65 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -d: print the number of sequences in the fasta\n");
66 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -i name: print an index, labelling the source 'name'\n");
67 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
68 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "OUTPUT OPTIONS\n");
69 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -6 <#>: insert a newline every 60 letters\n");
70 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " (if the next arg is a number, newlines are inserted every\n");
71 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " n letters, e.g., -6 80. Disable line breaks with -6 0,\n");
72 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " or just don't use -6!)\n");
73 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -e beg end: Print only the bases from position 'beg' to position 'end'\n");
74 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " (space based, relative to the FORWARD sequence!) If\n");
75 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " beg == end, then the entire sequence is printed. It is an\n");
76 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " error to specify beg > end, or beg > len, or end > len.\n");
77 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -ends n Print n bases from each end of the sequence. One input\n");
78 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " sequence generates two output sequences, with '_5' or '_3'\n");
79 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " appended to the ID. If 2n >= length of the sequence, the\n");
80 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " sequence itself is printed, no ends are extracted (they\n");
81 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " overlap).\n");
82 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -C: complement the sequences\n");
83 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -H: DON'T print the defline\n");
84 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -h: Use the next word as the defline (\"-H -H\" will reset to the\n");
85 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " original defline\n");
86 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -R: reverse the sequences\n");
87 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -u: uppercase all bases\n");
88 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
89 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SEQUENCE SELECTION\n");
90 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -G n s l: print n randomly generated sequences, 0 < s <= length <= l\n");
91 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -L s l: print all sequences such that s <= length < l\n");
92 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -N l h: print all sequences such that l <= %% N composition < h\n");
93 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " (NOTE 0.0 <= l < h < 100.0)\n");
94 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " (NOTE that you cannot print sequences with 100%% N\n");
95 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " This is a useful bug).\n");
96 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -q file: print sequences from the seqid list in 'file'\n");
97 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -r num: print 'num' randomly picked sequences\n");
98 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -s seqid: print the single sequence 'seqid'\n");
99 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -S f l: print all the sequences from ID 'f' to 'l' (inclusive)\n");
100 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -W: print all sequences (do the whole file)\n");
101 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
102 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "LONGER HELP\n");
103 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -help analysis\n");
104 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -help examples\n");
105 }
106
107
108 static
109 void
110 helpAnalysiscxx . . $ helpAnalysis(fda57c8427c60377).(char *program) {
111 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: %s [-f <fasta-file>] [options]\n", program);
112 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
113 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " --findduplicates a.fasta\n");
114 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Reports sequences that are present more than once. Output\n");
115 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " is a list of pairs of deflines, separated by a newline.\n");
116 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
117 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " --mapduplicates a.fasta b.fasta\n");
118 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Builds a map of IIDs from a.fasta and b.fasta that have\n");
119 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " identical sequences. Format is \"IIDa <-> IIDb\"\n");
120 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
121 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " --md5 a.fasta:\n");
122 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Don't print the sequence, but print the md5 checksum\n");
123 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " (of the entire sequence) followed by the entire defline.\n");
124 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
125 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " --partition prefix [ n[gmk]bp | n ] a.fasta\n");
126 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " --partitionmap [ n[gmk]bp | n ] a.fasta\n");
127 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Partition the sequences into roughly equal size pieces of\n");
128 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " size nbp, nkbp, nmbp or ngbp; or into n roughly equal sized\n");
•129 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " partitions. Sequences larger that the partition size are\n");
130 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " in a partition by themself. --partitionmap writes a\n");
131 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " description of the partition to stdout; --partiton creates\n");
132 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " a fasta file 'prefix-###.fasta' for each partition.\n");
133 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Example: -F some.fasta --partition parts 130mbp\n");
134 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -F some.fasta --partition parts 16\n");
135 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
136 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " --segment prefix n a.fasta\n");
137 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Splits the sequences into n files, prefix-###.fasta.\n");
138 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Sequences are not reordered.\n");
139 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
140 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " --gccontent a.fasta\n");
141 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Reports the GC content over a sliding window of\n");
142 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " 3, 5, 11, 51, 101, 201, 501, 1001, 2001 bp.\n");
143 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
144 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " --testindex a.fasta\n");
145 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Test the index of 'file'. If index is up-to-date, leaff\n");
146 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " exits successfully, else, leaff exits with code 1. If an\n");
147 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " index file is supplied, that one is tested, otherwise, the\n");
148 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " default index file name is used.\n");
149 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
150 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " --dumpblocks a.fasta\n");
151 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Generates a list of the blocks of N and non-N. Output\n");
152 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " format is 'base seq# beg end len'. 'N 84 483 485 2' means\n");
153 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " that a block of 2 N's starts at space-based position 483\n");
154 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " in sequence ordinal 84. A '.' is the end of sequence\n");
155 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " marker.\n");
156 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
157 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " --errors L N C P a.fasta\n");
158 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " For every sequence in the input file, generate new\n");
159 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " sequences including simulated sequencing errors.\n");
160 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " L -- length of the new sequence. If zero, the length\n");
161 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " of the original sequence will be used.\n");
162 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " N -- number of subsequences to generate. If L=0, all\n");
163 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " subsequences will be the same, and you should use\n");
164 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " C instead.\n");
165 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " C -- number of copies to generate. Each of the N\n");
166 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " subsequences will have C copies, each with different\n");
167 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " errors.\n");
168 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " P -- probability of an error.\n");
169 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
170 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " HINT: to simulate ESTs from genes, use L=500, N=10, C=10\n");
171 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -- make C=10 sequencer runs of N=10 EST sequences\n");
172 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " of length 500bp each.\n");
173 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " to simulate mRNA from genes, use L=0, N=10, C=10\n");
174 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " to simulate reads from genomes, use L=800, N=10, C=1\n");
175 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -- of course, N= should be increased to give the\n");
176 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " appropriate depth of coverage\n");
177 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
178 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " --stats a.fasta [refLen]\n");
179 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Reports size statistics; number, N50, sum, largest.\n");
180 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " If 'refLen' is supplied, N50 is based on this size.\n");
181 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
182 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " --seqstore out.seqStore\n");
183 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Converts the input file (-f) to a seqStore file.\n");
184 }
185
186
187 static
188 void
189 helpExamplescxx . . $ helpExamples(fda57c8427c60377).(char *program) {
190 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: %s [-f <fasta-file>] [options]\n", program);
191 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
192 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Options are ORDER DEPENDENT. Sequences are printed whenever an ACTION occurs\n");
193 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "on the command line. SEQUENCE OPTIONS are not reset when a sequence is printed.\n");
194 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
195 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "SEQUENCES are numbered starting at ZERO, not one.\n");
196 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
197 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Print the first 10 bases of the fourth sequence in file 'genes':\n");
198 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -f genes -e 0 10 -s 3\n");
199 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
200 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Print the first 10 bases of the fourth and fifth sequences:\n");
201 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -f genes -e 0 10 -s 3 -s 4\n");
202 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
203 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Print the fourth and fifth sequences reverse complemented, and the sixth\n");
204 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " sequence forward. The second set of -R -C toggle off reverse-complement:\n");
205 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -f genes -R -C -s 3 -s 4 -R -C -s 5\n");
206 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n");
207 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " Convert file 'genes' to a seqStore 'genes.seqStore'. The seqStore\n");
208 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " provides better performance with the kmer tools.\n");
209 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " -f genes --seqstore genes.seqStore\n");
210 }
211
212
213 static
214 void
215 printSequencecxx . . $ printSequence(61ebbd119d56d911).(char *def,
216 char *seq,
217 uint32cxx . . $ uint32# beg,
218 uint32cxx . . $ uint32# end) {
219
220 if (beg >= end)
221 return;
222
223 if ((endExtractcxx . . $ endExtract. != ~uint32ZEROcxx . . $ `libutil/util.h:60:10`!) &&
224 (endExtractcxx . . $ endExtract. + endExtractcxx . . $ endExtract. < end - beg)) {
225 char d[1024];
226 uint32cxx . . $ uint32# l = strlen(seq);
227
228 sprintf(d, "%s_5", def);
229 printSequencecxx . . $ printSequence(61ebbd119d56d911).(d, seq, 0, endExtractcxx . . $ endExtract.);
230
231 sprintf(d, "%s_3", def);
232 printSequencecxx . . $ printSequence(61ebbd119d56d911).(d, seq, l-endExtractcxx . . $ endExtract., l);
233
234 return;
235 }
236
237 if (specialDefLinecxx . . $ specialDefLine.)
238 def = specialDefLinecxx . . $ specialDefLine.;
239
240 if (withDefLinecxx . . $ withDefLine. == false)
241 def = 0L;
242
243 uint32cxx . . $ uint32# limit = end - beg;
244 char *n = new char [end - beg + 1];
245 char *m;
246
247 if ((doReversecxx . . $ doReverse. == false) && (doComplementcxx . . $ doComplement. == false)) {
248 m = n;
249 seq += beg;
250 while (limit--)
251 *(m++) = translatecxx . . $ translate.[*(seq++)];
252
253 } else if ((doReversecxx . . $ doReverse. == true) && (doComplementcxx . . $ doComplement. == false)) {
254 m = n + limit - 1;
255 seq += beg;
256 while (limit--)
257 *(m--) = translatecxx . . $ translate.[*(seq++)];
258
259 } else if ((doReversecxx . . $ doReverse. == false) && (doComplementcxx . . $ doComplement. == true)) {
260 m = n;
261 seq += beg;
262 while (limit--)
263 *(m++) = complementSymbol[translatecxx . . $ translate.[*(seq++)]];
264
265 } else if ((doReversecxx . . $ doReverse. == true) && (doComplementcxx . . $ doComplement. == true)) {
266 m = n + limit - 1;
267 seq += beg;
268 while (limit--)
269 *(m--) = complementSymbol[translatecxx . . $ translate.[*(seq++)]];
270 }
271
272 n[end-beg] = 0;
273
274 if (def)
275 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, ">%s\n", def);
276
277 if (withLineBreakscxx . . $ withLineBreaks.) {
278 char *t = n;
279 char *a = new char [withLineBreakscxx . . $ withLineBreaks.+1];
280
281 while (*t) {
282 uint32cxx . . $ uint32# i=0;
283 while ((*t) && (i < withLineBreakscxx . . $ withLineBreaks.))
284 a[i++] = *(t++);
285 a[i++] = '\n';
286 a[i] = 0;
287 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s", a);
288 }
289
290 delete [] a;
291 } else {
292 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s\n", n);
293 }
294
295 delete [] n;
296 }
297
298
299 static
300 void
301 printSequencecxx . . $ printSequence(b490fd58fed50ecf).(seqInCorecxx . . $ seqInCore# *sic) {
302 printSequencecxx . . $ printSequence(61ebbd119d56d911).(sic->headercxx . . $ seqInCore#header(e7e5aa338b9d5147).(), sic->sequencecxx . . $ seqInCore#sequence(e7e5aa338b9d5147).(), (begPoscxx . . $ begPos.!=(uint32cxx . . $ uint32#)0) ? begPoscxx . . $ begPos.:0, (endPoscxx . . $ endPos.!=~uint32cxx . . $ uint32#(0)) ? endPoscxx . . $ endPos.:sic->sequenceLengthcxx . . $ seqInCore#sequenceLength(ddd8539a2fcdd4ce).());
303 }
304
305
306 static
307 void
308 printSequencecxx . . $ printSequence(cb2f890c2fdad230).(uint32cxx . . $ uint32# sid) {
309 seqInCorecxx . . $ seqInCore# *sic = fastacxx . . $ fasta.->getSequenceInCorecxx . . $ seqCache#getSequenceInCore(715c05706546271f).(sid);
310 if (sic == 0L)
311 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "WARNING: Didn't find sequence with iid '"uint32FMTcxx . . $ `libutil/util.h:65:10`!"'\n", sid);
312 else
313 printSequencecxx . . $ printSequence(b490fd58fed50ecf).(sic);
314 delete sic;
315 }
316
317
318 static
319 void
320 printSequencecxx . . $ printSequence(fda57c8427c60377).(char *sid) {
321 seqInCorecxx . . $ seqInCore# *sic = fastacxx . . $ fasta.->getSequenceInCorecxx . . $ seqCache#getSequenceInCore(644dd73e98a56612).(sid);
322 if (sic == 0L)
323 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "WARNING: Didn't find sequence with name/iid '%s'\n", sid);
324 else
325 printSequencecxx . . $ printSequence(b490fd58fed50ecf).(sic);
326 delete sic;
327 }
328
329
330 static
331 void
332 printIDsFromFilecxx . . $ printIDsFromFile(fda57c8427c60377).(char *name) {
333 uint32cxx . . $ uint32# idLen = 0;
334 uint32cxx . . $ uint32# idMax = 63;
335 char *id = new char [idMax+1];
336
337 readBuffercxx . . $ readBuffer# Bcxx . . $ readBuffer#readBuffer(7cafb6e0818eff3b).(name);
338 char x = B.readcxx . . $ readBuffer#read(6e9c618e4dd2eafc).();
339
340 // For optimal performance, we should sort the list of ID's given
341 // by their IID, but the user might have a good reason for wanting
342 // them unsorted.
343
344 while (B.eofcxx . . $ readBuffer#eof(c9857a73d68e59ba).() == false) {
345 while (whitespaceSymbol[x] && (B.eofcxx . . $ readBuffer#eof(c9857a73d68e59ba).() == false))
346 x = B.readcxx . . $ readBuffer#read(6e9c618e4dd2eafc).();
347
348 if (B.eofcxx . . $ readBuffer#eof(c9857a73d68e59ba).() == false) {
349 idLen = 0;
350
351 while (!whitespaceSymbol[x] && (B.eofcxx . . $ readBuffer#eof(c9857a73d68e59ba).() == false)) {
352 id[idLen++] = x;
353 x = B.readcxx . . $ readBuffer#read(6e9c618e4dd2eafc).();
354
355 if (idLen >= idMax) {
356 idMax *= 2;
357 char *newid = new char [idMax+1];
358 memcpy(newid, id, sizeof(char) * idLen);
359 delete [] id;
360 id = newid;
361 }
362 }
363
364 id[idLen] = 0;
365
366 seqInCorecxx . . $ seqInCore# *S = fastacxx . . $ fasta.->getSequenceInCorecxx . . $ seqCache#getSequenceInCore(644dd73e98a56612).(id);
367
368 if (S == 0L)
369 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "WARNING: Didn't find sequence with name/iid '%s'\n", id);
370 else
371 printSequencecxx . . $ printSequence(b490fd58fed50ecf).(S);
372 }
373 }
374
375 delete [] id;
376 }
377
378
379 void
380 processArraycxx . . $ processArray(c759356ac01a31e7).(int argc, char **argv) {
381
382 int arg = 1;
383 while (arg < argc) {
384
385 if ((strcmp(argv[arg], "-f") == 0) ||
386 (strcmp(argv[arg], "-F") == 0)) {
387 delete fastacxx . . $ fasta.;
388 fastacxx . . $ fasta. = new seqCachecxx . . $ seqCache#seqCache(cc76bd1196c143a3).(argv[++arg]);
389
390 } else if (strcmp(argv[arg], "-i") == 0) {
391
392 failIfNoSourcecxx . . $ failIfNoSource(49f6e7a06ebc5aa8).();
393
394 ++arg;
395 if ((argv[arg] == 0L) || (argv[arg][0] == '-'))
396 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: next arg to -i should be 'name', I got '%s'\n",
397 (argv[arg] == 0L) ? "(nullpointer)" : argv[arg]), exitcxx . . $ exit(44ed87f96534fad7).(1);
398
399 for (uint32cxx . . $ uint32# s=0; s<fastacxx . . $ fasta.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).(); s++)
400 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "G\tseq\t%s:"uint32FMTcxx . . $ `libutil/util.h:65:10`!"\t"uint32FMTcxx . . $ `libutil/util.h:65:10`!"\t%s\n",
401 argv[arg], s, fastacxx . . $ fasta.->getSequenceLengthcxx . . $ seqCache#getSequenceLength(2141b656ce2cc063).(s), ">unimplemented");
402
403 } else if (strcmp(argv[arg], "-d") == 0) {
404 failIfNoSourcecxx . . $ failIfNoSource(49f6e7a06ebc5aa8).();
405 printf(uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", fastacxx . . $ fasta.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).());
406
407 } else if (strcmp(argv[arg], "-L") == 0) {
408 uint32cxx . . $ uint32# small = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
409 uint32cxx . . $ uint32# large = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
410
411 failIfNoSourcecxx . . $ failIfNoSource(49f6e7a06ebc5aa8).();
412
413 for (uint32cxx . . $ uint32# s=0; s<fastacxx . . $ fasta.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).(); s++)
414 if ((small <= fastacxx . . $ fasta.->getSequenceLengthcxx . . $ seqCache#getSequenceLength(2141b656ce2cc063).(s)) && (fastacxx . . $ fasta.->getSequenceLengthcxx . . $ seqCache#getSequenceLength(2141b656ce2cc063).(s) < large))
415 printSequencecxx . . $ printSequence(cb2f890c2fdad230).(s);
416
417 } else if (strcmp(argv[arg], "-N") == 0) {
418 double small = atofcxx . . $ atof(9b0361fcbc284e4f).(argv[++arg]);
419 double large = atofcxx . . $ atof(9b0361fcbc284e4f).(argv[++arg]);
420
421 failIfNoSourcecxx . . $ failIfNoSource(49f6e7a06ebc5aa8).();
422
423 for (uint32cxx . . $ uint32# s=0; s<fastacxx . . $ fasta.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).(); s++) {
424 seqInCorecxx . . $ seqInCore# *S = fastacxx . . $ fasta.->getSequenceInCorecxx . . $ seqCache#getSequenceInCore(715c05706546271f).(s);
425 uint32cxx . . $ uint32# Ns = 0;
426 uint32cxx . . $ uint32# len = S->sequenceLengthcxx . . $ seqInCore#sequenceLength(ddd8539a2fcdd4ce).();
427 char *seq = S->sequencecxx . . $ seqInCore#sequence(e7e5aa338b9d5147).();
428
429 for (uint32cxx . . $ uint32# i=begPoscxx . . $ begPos.; i<len && i<endPoscxx . . $ endPos.; i++)
430 if ((seq[i] == 'n') || (seq[i] == 'N'))
431 Ns++;
432
433 double Np = 100.0 * Ns / len;
434
435 if ((small <= Np) && (Np < large))
436 printSequencecxx . . $ printSequence(b490fd58fed50ecf).(S);
437
438 delete S;
439 }
440
441 } else if (strcmp(argv[arg], "-W") == 0) {
442 failIfNoSourcecxx . . $ failIfNoSource(49f6e7a06ebc5aa8).();
443
444 for (uint32cxx . . $ uint32# s=0; s<fastacxx . . $ fasta.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).(); s++)
445 printSequencecxx . . $ printSequence(cb2f890c2fdad230).(s);
446
447 } else if (strcmp(argv[arg], "-G") == 0) {
448 uint32cxx . . $ uint32# n = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
449 uint32cxx . . $ uint32# s = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
450 uint32cxx . . $ uint32# l = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
451
452 char bases[4] = {'A', 'C', 'G', 'T'};
453 char *def = new char [1024];
454 char *seq = new char [l + 1];
455
456 if (s == 0)
457 s = 1;
458 if (s > l)
459 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "leaff: usage: -G num-seqs min-length max-length\n"), exitcxx . . $ exit(44ed87f96534fad7).(1);
460
461 for (uint32cxx . . $ uint32# i=0; i<n; i++) {
462 uint32cxx . . $ uint32# j = s + ((l-s == 0) ? 0 : (mtRandom32(mtctxcxx . . $ mtctx.) % (l-s)));
463 uint32cxx . . $ uint32# p = 0;
464
465 while (p < j)
466 seq[p++] = bases[mtRandom32(mtctxcxx . . $ mtctx.) & 0x3];
467 seq[p] = 0;
468
469 sprintf(def, "random"uint32FMTWcxx . . $ `libutil/util.h:64:10`!(06), i);
470
471 printSequencecxx . . $ printSequence(61ebbd119d56d911).(def, seq, 0, j);
472 }
473
474 delete [] seq;
475 delete [] def;
476
477 } else if (strcmp(argv[arg], "-s") == 0) {
478 failIfNoSourcecxx . . $ failIfNoSource(49f6e7a06ebc5aa8).();
479 failIfNotRandomAccesscxx . . $ failIfNotRandomAccess(49f6e7a06ebc5aa8).(); // Easy to fix, just read the first N sequences
480 printSequencecxx . . $ printSequence(fda57c8427c60377).(argv[++arg]);
481
482 } else if (strcmp(argv[arg], "-S") == 0) {
483 failIfNoSourcecxx . . $ failIfNoSource(49f6e7a06ebc5aa8).();
484 failIfNotRandomAccesscxx . . $ failIfNotRandomAccess(49f6e7a06ebc5aa8).(); // Easy to fix, just read the first N sequences
485
486 uint32cxx . . $ uint32# lowID = fastacxx . . $ fasta.->getSequenceIIDcxx . . $ seqCache#getSequenceIID(33ab057182e9f89d).(argv[++arg]);
487 uint32cxx . . $ uint32# highID = fastacxx . . $ fasta.->getSequenceIIDcxx . . $ seqCache#getSequenceIID(33ab057182e9f89d).(argv[++arg]);
488
489 if (lowID > highID) {
490 uint32cxx . . $ uint32# t = lowID;
491 lowID = highID;
492 highID = t;
493 }
494
495 for (uint32cxx . . $ uint32# s=lowID; (s <= highID) && (s <= fastacxx . . $ fasta.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).()); s++)
496 printSequencecxx . . $ printSequence(cb2f890c2fdad230).(s);
497
498 } else if (strcmp(argv[arg], "-r") == 0) {
499 uint32cxx . . $ uint32# num = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
500
501 failIfNoSourcecxx . . $ failIfNoSource(49f6e7a06ebc5aa8).();
502 failIfNotRandomAccesscxx . . $ failIfNotRandomAccess(49f6e7a06ebc5aa8).(); // Impossible to fix, or load whole thing into memory
503
504 if (num >= fastacxx . . $ fasta.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).())
505 num = fastacxx . . $ fasta.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).();
506
507 uint32cxx . . $ uint32# *seqs = new uint32cxx . . $ uint32# [fastacxx . . $ fasta.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).()];
508
509 for (uint32cxx . . $ uint32# i=0; i<fastacxx . . $ fasta.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).(); i++)
510 seqs[i] = i;
511
512 for (uint32cxx . . $ uint32# i=0; i<fastacxx . . $ fasta.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).(); i++) {
513 uint32cxx . . $ uint32# j = mtRandom32(mtctxcxx . . $ mtctx.) % (fastacxx . . $ fasta.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).() - i) + i;
514 uint32cxx . . $ uint32# t = seqs[j];
515 seqs[j] = seqs[i];
516 seqs[i] = t;
517 }
518
519 for (uint32cxx . . $ uint32# i=0; i<num; i++)
520 printSequencecxx . . $ printSequence(cb2f890c2fdad230).(seqs[i]);
521
522 delete [] seqs;
523
524 } else if (strcmp(argv[arg], "-q") == 0) {
525 failIfNoSourcecxx . . $ failIfNoSource(49f6e7a06ebc5aa8).();
526 failIfNotRandomAccesscxx . . $ failIfNotRandomAccess(49f6e7a06ebc5aa8).(); // Impossible to fix, or load whole thing into memory
527 printIDsFromFilecxx . . $ printIDsFromFile(fda57c8427c60377).(argv[++arg]);
528
529 } else if (strcmp(argv[arg], "-6") == 0) {
530 withLineBreakscxx . . $ withLineBreaks. = 60;
531 if ((argv[arg+1] != 0L) && (argv[arg+1][0] != '-'))
532 withLineBreakscxx . . $ withLineBreaks. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
533
534 } else if (strcmp(argv[arg], "-w") == 0) {
535 toUppercasecxx . . $ toUppercase. = !toUppercasecxx . . $ toUppercase.;
536 for (int z=0; z<256; z++)
537 translatecxx . . $ translate.[z] = (toUppercasecxx . . $ toUppercase.) ? (char)toUpper[z] : (char)z;
538
539 } else if (strcmp(argv[arg], "-R") == 0) {
540 doReversecxx . . $ doReverse. = !doReversecxx . . $ doReverse.;
541
542 } else if (strcmp(argv[arg], "-C") == 0) {
543 doComplementcxx . . $ doComplement. = !doComplementcxx . . $ doComplement.;
544
545 } else if (strcmp(argv[arg], "-H") == 0) {
546 withDefLinecxx . . $ withDefLine. = !withDefLinecxx . . $ withDefLine.;
547 specialDefLinecxx . . $ specialDefLine. = 0L;
548
549 } else if (strcmp(argv[arg], "-h") == 0) {
550 withDefLinecxx . . $ withDefLine. = true;
551 specialDefLinecxx . . $ specialDefLine. = argv[++arg];
552
553 } else if (strcmp(argv[arg], "-e") == 0) {
554 begPoscxx . . $ begPos. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
555 endPoscxx . . $ endPos. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
556
557 } else if (strcmp(argv[arg], "-ends") == 0) {
558 endExtractcxx . . $ endExtract. = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
559
560 } else if (strcmp(argv[arg], "-A") == 0) {
561 processFilecxx . . $ processFile(fda57c8427c60377).(argv[++arg]);
562
563
564
565 } else if (strcmp(argv[arg], "--findduplicates") == 0) {
566 findDuplicatescxx . . $ findDuplicates(fda57c8427c60377).(argv[++arg]);
567 exitcxx . . $ exit(44ed87f96534fad7).(0);
568
569 } else if (strcmp(argv[arg], "--mapduplicates") == 0) {
570 mapDuplicatescxx . . $ mapDuplicates(d0489a02ea06dfc6).(argv[arg+1], argv[arg+2]);
571 exitcxx . . $ exit(44ed87f96534fad7).(0);
572
573 } else if (strcmp(argv[arg], "--md5") == 0) {
574 md5_s md5;
575 char sum[33];
576
577 fastacxx . . $ fasta. = new seqCachecxx . . $ seqCache#seqCache(cc76bd1196c143a3).(argv[++arg]);
578
579 for (uint32cxx . . $ uint32# s=0; s<fastacxx . . $ fasta.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).(); s++) {
580 seqInCorecxx . . $ seqInCore# *S = fastacxx . . $ fasta.->getSequenceInCorecxx . . $ seqCache#getSequenceInCore(715c05706546271f).(s);
581 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s %s\n",
582 md5_toascii(md5_string(&md5, S->sequencecxx . . $ seqInCore#sequence(e7e5aa338b9d5147).(), S->sequenceLengthcxx . . $ seqInCore#sequenceLength(ddd8539a2fcdd4ce).()), sum),
583 S->headercxx . . $ seqInCore#header(e7e5aa338b9d5147).());
584 delete S;
585 }
586 delete fastacxx . . $ fasta.;
587 exitcxx . . $ exit(44ed87f96534fad7).(0);
588
589 } else if ((strcmp(argv[arg], "--partition") == 0) ||
590 (strcmp(argv[arg], "--partitionmap") == 0)) {
591
592 char *prefix = 0L;
593 if (strcmp(argv[arg], "--partition") == 0)
594 prefix = argv[++arg];
595
596 // does the next arg end with gbp, mbp, kbp or bp? If so,
597 // partition by length, else partition into buckets.
598 //
599 int al = strlen(argv[arg+1]);
600 uint64cxx . . $ uint64# ps = strtouint64cxx . . $ `libutil/util.h:83:10`!(argv[arg+1], 0L);
601
602 char a3 = (al<3) ? '0' : (char)toLower[argv[arg+1][al-3]];
603 char a2 = (al<2) ? '0' : (char)toLower[argv[arg+1][al-2]];
604 char a1 = (al<1) ? '0' : (char)toLower[argv[arg+1][al-1]];
605
606 // partition!
607
608 if (!isdigit(a1) || !isdigit(a2) || !isdigit(a3)) {
609 if ((a3 == 'g') && (a2 == 'b') && (a1 == 'p')) {
610 ps *= 1000000000;
611 } else if ((a3 == 'm') && (a2 == 'b') && (a1 == 'p')) {
612 ps *= 1000000;
613 } else if ((a3 == 'k') && (a2 == 'b') && (a1 == 'p')) {
614 ps *= 1000;
615 } else if (isdigit(a3) && (a2 == 'b') && (a1 == 'p')) {
616 ps *= 1;
617 } else {
618 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Unknown partition size option '%s'\n", argv[arg+1]), exitcxx . . $ exit(44ed87f96534fad7).(1);
619 }
620
621 if (ps == 0)
622 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Unknown or zero partition size '%s'\n", argv[arg+1]), exitcxx . . $ exit(44ed87f96534fad7).(1);
623 partitionBySizecxx . . $ partitionBySize(26b798d52fc7d208).(prefix, ps, argv[arg+2]);
624 } else {
625 if (ps == 0)
626 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Unknown or zero partition size '%s'\n", argv[arg+1]), exitcxx . . $ exit(44ed87f96534fad7).(1);
627 partitionByBucketcxx . . $ partitionByBucket(26b798d52fc7d208).(prefix, ps, argv[arg+2]);
628 }
629 exitcxx . . $ exit(44ed87f96534fad7).(0);
630
631 } else if (strcmp(argv[arg], "--segment") == 0) {
632 partitionBySegmentcxx . . $ partitionBySegment(26b798d52fc7d208).(argv[arg+1], strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[arg+2], 0L), argv[arg+3]);
633 exitcxx . . $ exit(44ed87f96534fad7).(0);
634
635 } else if (strcmp(argv[arg], "--gccontent") == 0) {
636 computeGCcontentcxx . . $ computeGCcontent(fda57c8427c60377).(argv[++arg]);
637 exitcxx . . $ exit(44ed87f96534fad7).(0);
638
639 } else if (strcmp(argv[arg], "--dumpblocks") == 0) {
640 dumpBlockscxx . . $ dumpBlocks(fda57c8427c60377).(argv[++arg]);
641 exitcxx . . $ exit(44ed87f96534fad7).(0);
642
643 } else if (strcmp(argv[arg], "--stats") == 0) {
644 statscxx . . $ stats(a14cc78460091691).(argv[arg+1], (argv[arg+2] != 0L) ? strtouint64cxx . . $ `libutil/util.h:83:10`!(argv[arg+2], 0L) : 0);
645 exitcxx . . $ exit(44ed87f96534fad7).(0);
646
647 } else if (strcmp(argv[arg], "--errors") == 0) {
648 int L = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L); // Desired length
649 int l = 0; // min of desired length, length of sequence
650 int N = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L); // number of copies per sequence
651 int C = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L); // number of mutations per copy
652 double P = atofcxx . . $ atof(9b0361fcbc284e4f).(argv[++arg]); // probability of mutation
653 uint32cxx . . $ uint32# i = 0;
654
655 fastacxx . . $ fasta. = new seqCachecxx . . $ seqCache#seqCache(cc76bd1196c143a3).(argv[++arg]);
656
657 seqInCorecxx . . $ seqInCore# *S = fastacxx . . $ fasta.->getSequenceInCorecxx . . $ seqCache#getSequenceInCore(715c05706546271f).(i++);
658 while (S) {
659 char *seq = S->sequencecxx . . $ seqInCore#sequence(e7e5aa338b9d5147).();
660 char *hdr = S->headercxx . . $ seqInCore#header(e7e5aa338b9d5147).();
661 int len = S->sequenceLengthcxx . . $ seqInCore#sequenceLength(ddd8539a2fcdd4ce).();
662
663 l = len;
664 if ((L > 0) && (L < len))
665 l = L;
666
667 simseqcxx . . $ simseq(ecfae29d39139173).(seq, hdr, len, N, l, C, P);
668
669 delete S;
670 S = fastacxx . . $ fasta.->getSequenceInCorecxx . . $ seqCache#getSequenceInCore(715c05706546271f).(i++);
671 }
672 delete fastacxx . . $ fasta.;
673 exitcxx . . $ exit(44ed87f96534fad7).(0);
674
675 } else if (strcmp(argv[arg], "--seqstore") == 0) {
676 constructSeqStorecxx . . $ constructSeqStore(d4941c2f02017ee5).(argv[++arg], fastacxx . . $ fasta.);
677 exitcxx . . $ exit(44ed87f96534fad7).(0);
678
679 } else if (strcmp(argv[arg], "-help") == 0) {
680 if ((argv[arg+1]) && (strcmp(argv[arg+1], "analysis") == 0))
681 helpAnalysiscxx . . $ helpAnalysis(fda57c8427c60377).(argv[0]);
682 else if ((argv[arg+1]) && (strcmp(argv[arg+1], "examples") == 0))
683 helpExamplescxx . . $ helpExamples(fda57c8427c60377).(argv[0]);
684 else
685 helpStandardcxx . . $ helpStandard(fda57c8427c60377).(argv[0]);
686 exitcxx . . $ exit(44ed87f96534fad7).(0);
687
688 } else {
689 helpStandardcxx . . $ helpStandard(fda57c8427c60377).(argv[0]);
690 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Unknown option '%s'\n", argv[arg]);
691 exitcxx . . $ exit(44ed87f96534fad7).(1);
692 }
693
694 arg++;
695 }
696
697 delete fastacxx . . $ fasta.;
698 fastacxx . . $ fasta. = 0L;
699 }
700
701
702 void
703 processFilecxx . . $ processFile(fda57c8427c60377).(char *filename) {
704 FILE *F = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
705
706 if (strcmp(filename, "-") == 0) {
707 F = stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!;
708 } else {
709 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
710 F = fopen(filename, "r");
711 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)
712 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Couldn't open '%s': %s\n", filename, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)), exitcxx . . $ exit(44ed87f96534fad7).(1);
713 }
714
715 uint64cxx . . $ uint64# max = 16 * 1024 * 1024;
716 uint64cxx . . $ uint64# pos = 0;
717 size_t len = 0;
718
719 char *data = new char [max];
720
721 // Suck the file into 'data'
722
723 while (!feof(F)) {
724 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
725 len = fread(data+pos, 1, max - pos, F);
726 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)
727 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Couldn't read "uint64FMTcxx . . $ `libutil/util.h:55:10`!" bytes from '%s': %s\n",
728 (uint64cxx . . $ uint64#)(max-pos), filename, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)), exitcxx . . $ exit(44ed87f96534fad7).(1);
729
730 pos += len;
731
732 if (pos >= max) {
733 max += 16 * 1024 * 1024;
734 char *tmpd = new char [max];
735 memcpy(tmpd, data, pos);
736 delete [] data;
737 data = tmpd;
738 }
739 }
740
741 if (strcmp(filename, "-") != 0)
742 fclose(F);
743
744 len = pos;
745
746 // (over)count the number of words; we start at two, since the
747 // first arg is the name of the program, and if there is only one
748 // word and no whitespace in the file, the below loop fails to
749 // count the second word.
750
751 int argc = 2;
752 char **argv = 0L;
753
754 for (uint32cxx . . $ uint32# i=0; i<len; i++) {
755 if (isspace(data[i])) {
756 argc++;
757 data[i] = 0;
758 }
759 }
760
761 // Allocate space for word pointers, then set them. First arg in
762 // argv[] is the name of the program -- we'll substitute the name
763 // of the file instead.
764
765 argv = new char * [argc];
766
767 argv[0] = filename;
768 argc = 1;
769
770 // Three steps: Skip leading whitespace; save the arg if it's a
771 // real arg (and not the end of the file; then skip the word.
772
773 for (uint32cxx . . $ uint32# pos=0; pos<len; pos++) {
774 while ((data[pos] == 0) && (pos < len))
775 pos++;
776 if (pos < len)
777 argv[argc++] = data+pos;
778 while ((data[pos] != 0) && (pos < len))
779 pos++;
780 }
781
782 processArraycxx . . $ processArray(c759356ac01a31e7).(argc, argv);
783
784 delete [] argv;
785 delete [] data;
786 }
787
788
789 int
790 maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) {
791
792 if (argc < 2) {
793 helpStandardcxx . . $ helpStandard(fda57c8427c60377).(argv[0]);
794 exitcxx . . $ exit(44ed87f96534fad7).(1);
795 }
796
797 for (int z=0; z<256; z++)
798 translatecxx . . $ translate.[z] = (char)z;
799
800 mtctxcxx . . $ mtctx. = mtInit(getpid() * time(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!));
801
802 processArraycxx . . $ processArray(c759356ac01a31e7).(argc, argv);
803
804 delete fastacxx . . $ fasta.;
805 }
806
807
808
809