Debian Codegraph @

meryl/mapMers.C

raw symbols SCIP
1 #cxx . . $ `<file>/meryl/mapMers.C`/include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 #include "bio++.H"cxx . . $ `<file>/libbio/bio++.H`/
6 #include "seqCache.H"cxx . . $ `<file>/libseq/seqCache.H`/
7 #include "merStream.H"cxx . . $ `<file>/libseq/merStream.H`/
8 #include "libmeryl.H"cxx . . $ `<file>/libmeryl/libmeryl.H`/
9 #include "existDB.H"cxx . . $ `<file>/libkmer/existDB.H`/
10
11 #define OP_NONEcxx . . $ `meryl/mapMers.C:11:10`! 0
12 #define OP_STATScxx . . $ `meryl/mapMers.C:12:10`! 1
13 #define OP_REGIONScxx . . $ `meryl/mapMers.C:13:10`! 2
14 #define OP_DETAILScxx . . $ `meryl/mapMers.C:14:10`! 3
15
16 int
17 maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) {
18 uint32cxx . . $ uint32# merSize = 16;
19 char *merylFile = 0L;
20 char *fastaFile = 0L;
21 bool beVerbose = false;
22 uint32cxx . . $ uint32# loCount = 0;
23 uint32cxx . . $ uint32# hiCount = ~uint32ZEROcxx . . $ `libutil/util.h:60:10`!;
24 uint32cxx . . $ uint32# operation = OP_NONEcxx . . $ `meryl/mapMers.C:11:10`!;
25
26 // For OP_STATS
27
28 uint32cxx . . $ uint32# Clen = 0;
29 uint32cxx . . $ uint32# Cmax = 4 * 1024 * 1024;
30 uint32cxx . . $ uint32# *C = new uint32cxx . . $ uint32# [Cmax];
31
32 int arg=1;
33 while (arg < argc) {
34 if (strcmp(argv[arg], "-m") == 0) {
35 merSize = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
36
37 } else if (strcmp(argv[arg], "-mers") == 0) {
38 merylFile = argv[++arg];
39
40 } else if (strcmp(argv[arg], "-seq") == 0) {
41 fastaFile = argv[++arg];
42
43 } else if (strcmp(argv[arg], "-v") == 0) {
44 beVerbose = true;
45
46 } else if (strcmp(argv[arg], "-lo") == 0) {
47 loCount = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
48
49 } else if (strcmp(argv[arg], "-hi") == 0) {
50 hiCount = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
51
52 } else if (strcmp(argv[arg], "-stats") == 0) {
53 operation = OP_STATScxx . . $ `meryl/mapMers.C:12:10`!;
54
55 } else if (strcmp(argv[arg], "-regions") == 0) {
56 operation = OP_REGIONScxx . . $ `meryl/mapMers.C:13:10`!;
57
58 } else if (strcmp(argv[arg], "-details") == 0) {
59 operation = OP_DETAILScxx . . $ `meryl/mapMers.C:14:10`!;
60
61 } else {
62 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "unknown option '%s'\n", argv[arg]);
63 }
64 arg++;
65 }
66
67 if ((operation == OP_NONEcxx . . $ `meryl/mapMers.C:11:10`!) || (merylFile == 0L) || (fastaFile == 0L)) {
68 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: %s [-stats | -regions | -details] -m mersize -mers mers -seq fasta > output\n", argv[0]);
69 exitcxx . . $ exit(44ed87f96534fad7).(1);
70 }
71
72 #if 0
73 existDB *E = NULL;
74
75 if (fileExists("junk.existDB")) {
76 fprintf(stderr, "loading from junk.existDB\n");
77 E = new existDB("junk.existDB");
78 fprintf(stderr, "loaded\n");
79 } else {
80 exit(1);
81 E = new existDB(merylFile, merSize, existDBcounts, loCount, hiCount);
82 E->saveState("junk.existDB");
83 }
84 #endif
85
86 existDBcxx . . $ existDB# *E = new existDBcxx . . $ existDB#(merylFile, merSize, existDBcountscxx . . $ existDBcounts., loCount, hiCount);
87 seqCachecxx . . $ seqCache# *F = new seqCachecxx . . $ seqCache#seqCache(cc76bd1196c143a3).(fastaFile);
88
89 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Begin.\n");
90
91
92 for (uint32cxx . . $ uint32# Sid=0; Sid < F->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).(); Sid++) {
93 seqInCorecxx . . $ seqInCore# *S = F->getSequenceInCorecxx . . $ seqCache#getSequenceInCore(715c05706546271f).(Sid);
94 merStreamcxx . . $ merStream# *MS = new merStreamcxx . . $ merStream#(new kMerBuildercxx . . $ kMerBuilder#(merSize),
95 new seqStreamcxx . . $ seqStream#(S->sequencecxx . . $ seqInCore#sequence(e7e5aa338b9d5147).(), S->sequenceLengthcxx . . $ seqInCore#sequenceLength(ddd8539a2fcdd4ce).()),
96 true, true);
97
98 // with counts, report mean, mode, median, min, max for each frag.
99 if (operation == OP_STATScxx . . $ `meryl/mapMers.C:12:10`!) {
100
101 Clen = 0;
102
103 while (MS->nextMercxx . . $ merStream#nextMer(dfa6e707f7696010).())
104 C[Clen++] = E->countcxx . . $ existDB#count(ecdaa1632f49f591).(MS->theFMercxx . . $ merStream#theFMer(52e25c29fea41909).()) + E->countcxx . . $ existDB#count(ecdaa1632f49f591).(MS->theRMercxx . . $ merStream#theRMer(52e25c29fea41909).());
105
106 uint64cxx . . $ uint64# mean = uint64ZEROcxx . . $ `libutil/util.h:50:10`!;
107 uint64cxx . . $ uint64# min = ~uint64ZEROcxx . . $ `libutil/util.h:50:10`!;
108 uint64cxx . . $ uint64# max = uint64ZEROcxx . . $ `libutil/util.h:50:10`!;
109 uint64cxx . . $ uint64# hist[16] = { 0 };
110
111 // Histogram values are powers of two, e.g., <=1, <=2, <=4, <=8, <=16, <=32, <=64, <=128, <=256, <=512, <=1024, <=4096, <=8192, <=328768
112
113 for (uint32cxx . . $ uint32# i=0; i<Clen; i++) {
114 mean += C[i];
115
116 if (min > C[i])
117 min = C[i];
118 if (max < C[i])
119 max = C[i];
120
121 hist[ logBaseTwo64cxx . . $ logBaseTwo64(ecdaa1632f49f591).(C[i]) ]++;
122 }
123
124 if (Clen > 0) {
125 mean /= Clen;
126
127 } else {
128 mean = uint64ZEROcxx . . $ `libutil/util.h:50:10`!;
129 min = uint64ZEROcxx . . $ `libutil/util.h:50:10`!;
130 max = uint64ZEROcxx . . $ `libutil/util.h:50:10`!;
131 }
132
133 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!,
134 "%s\t"
135 uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"
136 uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"
137 uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\n",
138 S->headercxx . . $ seqInCore#header(e7e5aa338b9d5147).(),
139 mean, min, max,
140 hist[ 0], hist[ 1], hist[ 2], hist[ 3], hist[ 4], hist[ 5], hist[ 6], hist[ 7],
141 hist[ 8], hist[ 9], hist[10], hist[11], hist[12], hist[13], hist[14], hist[15]);
142 }
143
144
145 // without counts, reports regions with mer coverage.
146 // Orientation tells us nothing, since the mers are probably canonical
147 if (operation == OP_REGIONScxx . . $ `meryl/mapMers.C:13:10`!) {
148 uint64cxx . . $ uint64# beg = ~uint64ZEROcxx . . $ `libutil/util.h:50:10`!;
149 uint64cxx . . $ uint64# end = ~uint64ZEROcxx . . $ `libutil/util.h:50:10`!;
150 uint64cxx . . $ uint64# pos = ~uint64ZEROcxx . . $ `libutil/util.h:50:10`!;
151
152 uint64cxx . . $ uint64# numCovReg = 0;
153 uint64cxx . . $ uint64# lenCovReg = 0;
154
155 while (MS->nextMercxx . . $ merStream#nextMer(dfa6e707f7696010).()) {
156 if (E->existscxx . . $ existDB#exists(31596a199e1d8a50).(MS->theFMercxx . . $ merStream#theFMer(52e25c29fea41909).()) || E->existscxx . . $ existDB#exists(31596a199e1d8a50).(MS->theRMercxx . . $ merStream#theRMer(52e25c29fea41909).())) {
157 pos = MS->thePositionInSequencecxx . . $ merStream#thePositionInSequence(f708dce9a8856c70).();
158
159 if (beg == ~uint64ZEROcxx . . $ `libutil/util.h:50:10`!)
160 beg = end = pos;
161
162 if (pos <= end + merSize) {
163 end = pos;
164 } else {
165 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\n", S->headercxx . . $ seqInCore#header(e7e5aa338b9d5147).(), beg, end+merSize, end+merSize - beg);
166 numCovReg++;
167 lenCovReg += end+merSize - beg;
168 beg = end = pos;
169 }
170 } else {
171 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\tuncovered\n", S->headercxx . . $ seqInCore#header(e7e5aa338b9d5147).(), MS->thePositionInSequencecxx . . $ merStream#thePositionInSequence(f708dce9a8856c70).());
172 }
173 }
174
175 if (beg != ~uint64ZEROcxx . . $ `libutil/util.h:50:10`!)
176 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\n", S->headercxx . . $ seqInCore#header(e7e5aa338b9d5147).(), beg, end+merSize, end+merSize - beg);
177
178 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "numCovReg: "uint64FMTcxx . . $ `libutil/util.h:55:10`!"\n", numCovReg);
179 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "lenCovReg: "uint64FMTcxx . . $ `libutil/util.h:55:10`!"\n", lenCovReg);
180 }
181
182
183
184 if (operation == OP_DETAILScxx . . $ `meryl/mapMers.C:14:10`!) {
185 char merString[256];
186
187 while (MS->nextMercxx . . $ merStream#nextMer(dfa6e707f7696010).()) {
188 uint64cxx . . $ uint64# beg = MS->thePositionInSequencecxx . . $ merStream#thePositionInSequence(f708dce9a8856c70).();
189 uint64cxx . . $ uint64# end = beg + merSize;
190 uint64cxx . . $ uint64# fnt = E->countcxx . . $ existDB#count(ecdaa1632f49f591).(MS->theFMercxx . . $ merStream#theFMer(52e25c29fea41909).());
191 uint64cxx . . $ uint64# rnt = E->countcxx . . $ existDB#count(ecdaa1632f49f591).(MS->theRMercxx . . $ merStream#theRMer(52e25c29fea41909).());
192
193 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s\t%s\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\t"uint64FMTcxx . . $ `libutil/util.h:55:10`!"\n",
194 S->headercxx . . $ seqInCore#header(e7e5aa338b9d5147).(),
195 MS->theFMercxx . . $ merStream#theFMer(52e25c29fea41909).().merToStringcxx . . $ kMerTiny#merToString(2648ccd788ca02e9).(merString),
196 beg,
197 end,
198 fnt,
199 rnt,
200 fnt + rnt);
201 }
202 }
203
204
205 delete MS;
206 delete S;
207 }
208
209
210 delete F;
211 delete E;
212 }