Debian Codegraph @

atac-driver/chimera/happy-clones-span-clumps.C

raw symbols SCIP
1 #cxx . . $ `<file>/atac-driver/chimera/happy-clones-span-clumps.C`/include <stdio.h>
2 #include <stdlib.h>
3
4 using namespace std;
5 #include <map>
6
7 #include "util++.H"cxx . . $ `<file>/libutil/util++.H`/
8
9 // Reads a clump-annotated atac file, builds a search tree of all the
10 // matches in those clumps. Then reads a list of happy clones mapped
11 // to the sequence, figures out what clump each read in the clone is
12 // in, and reports whenever the clone spans a clump.
13
14
15 // Contains a list of intervalLists, one for each clump. The
16 // intervalList stores the positions of the matches in this clump.
17 //
18 class atacClumpCoordTreeScaffoldcxx . . $ atacClumpCoordTreeScaffold# {
19 public:
20 atacClumpCoordTreeScaffoldcxx . . $ atacClumpCoordTreeScaffold#atacClumpCoordTreeScaffold(49f6e7a06ebc5aa8).() {
21 clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen. = 0;
22 clumpsMaxcxx . . $ atacClumpCoordTreeScaffold#clumpsMax. = 64;
23 clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID. = new uint32cxx . . $ uint32# [clumpsMaxcxx . . $ atacClumpCoordTreeScaffold#clumpsMax.];
24 clumpscxx . . $ atacClumpCoordTreeScaffold#clumps. = new intervalListcxx . . $ intervalList#<uint64cxx . . $ uint64#> * [clumpsMaxcxx . . $ atacClumpCoordTreeScaffold#clumpsMax.];
25 clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin. = new uint32cxx . . $ uint32# [clumpsMaxcxx . . $ atacClumpCoordTreeScaffold#clumpsMax.];
26 clumpmaxcxx . . $ atacClumpCoordTreeScaffold#clumpmax. = new uint32cxx . . $ uint32# [clumpsMaxcxx . . $ atacClumpCoordTreeScaffold#clumpsMax.];
27
28 clumpconfirmcxx . . $ atacClumpCoordTreeScaffold#clumpconfirm. = new uint32cxx . . $ uint32# [clumpsMaxcxx . . $ atacClumpCoordTreeScaffold#clumpsMax. * clumpsMaxcxx . . $ atacClumpCoordTreeScaffold#clumpsMax.];
29
30 for (uint32cxx . . $ uint32# i=0; i<clumpsMaxcxx . . $ atacClumpCoordTreeScaffold#clumpsMax. * clumpsMaxcxx . . $ atacClumpCoordTreeScaffold#clumpsMax.; i++)
31 clumpconfirmcxx . . $ atacClumpCoordTreeScaffold#clumpconfirm.[i] = 0;
32
33 intervalsLencxx . . $ atacClumpCoordTreeScaffold#intervalsLen. = 0;
34 intervalsMaxcxx . . $ atacClumpCoordTreeScaffold#intervalsMax. = 0;
35 intervalscxx . . $ atacClumpCoordTreeScaffold#intervals. = 0L;
36 };
37
38 ~cxx . . $ atacClumpCoordTreeScaffold#`~atacClumpCoordTreeScaffold`(ced63f7c635d850d).atacClumpCoordTreeScaffoldcxx . . $ atacClumpCoordTreeScaffold#() {
39 for (uint32cxx . . $ uint32# i=0; i<clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.; i++)
40 delete clumpscxx . . $ atacClumpCoordTreeScaffold#clumps.[i];
41 delete [] clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.;
42 delete [] clumpscxx . . $ atacClumpCoordTreeScaffold#clumps.;
43 delete [] clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin.;
44 delete [] clumpmaxcxx . . $ atacClumpCoordTreeScaffold#clumpmax.;
45 delete [] clumpconfirmcxx . . $ atacClumpCoordTreeScaffold#clumpconfirm.;
46 delete [] intervalscxx . . $ atacClumpCoordTreeScaffold#intervals.;
47 };
48
49 // Add a match to some clump.
50 //
51 void addMatchcxx . . $ atacClumpCoordTreeScaffold#addMatch(2029de666eaec704).(int32cxx . . $ int32# clumpid, uint32cxx . . $ uint32# begin, uint32cxx . . $ uint32# length) {
52
53 // Not in a clump, get the heck outta here!
54 //
55 if (clumpid < 0)
56 return;
57
58 // Linear search through the clumps to find the correct id, we
59 // don't expect to have many clumps per scaffold.
60 //
61 for (uint32cxx . . $ uint32# i=0; i<clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.; i++) {
62 if (clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[i] == (uint32cxx . . $ uint32#)clumpid) {
63 clumpscxx . . $ atacClumpCoordTreeScaffold#clumps.[i]->addcxx . . $ intervalList#add(4d3091562df4e52e).(begin, length);
64 if (clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin.[i] > begin)
65 clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin.[i] = begin;
66 if (clumpmaxcxx . . $ atacClumpCoordTreeScaffold#clumpmax.[i] < begin + length)
67 clumpmaxcxx . . $ atacClumpCoordTreeScaffold#clumpmax.[i] = begin + length;
68 return;
69 }
70 }
71
72 if (clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen. == clumpsMaxcxx . . $ atacClumpCoordTreeScaffold#clumpsMax.) {
73 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: increase clumpsMax!\n");
74 exitcxx . . $ exit(44ed87f96534fad7).(1);
75 }
76
77 // Didn't add to an existing clump, so must be a new clump.
78 //
79 clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.] = clumpid;
80 clumpscxx . . $ atacClumpCoordTreeScaffold#clumps.[clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.] = new intervalListcxx . . $ intervalList#<uint64cxx . . $ uint64#>;
81 clumpscxx . . $ atacClumpCoordTreeScaffold#clumps.[clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.]->addcxx . . $ intervalList#add(4d3091562df4e52e).(begin, length);
82 clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin.[clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.] = begin;
83 clumpmaxcxx . . $ atacClumpCoordTreeScaffold#clumpmax.[clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.] = begin + length;
84 clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.++;
85 };
86
87
88 uint32cxx . . $ uint32# getClumpIDcxx . . $ atacClumpCoordTreeScaffold#getClumpID(83f10ac8959d5577).(uint32cxx . . $ uint32# begin, uint32cxx . . $ uint32# end) {
89 uint32cxx . . $ uint32# clumpid = 0;
90 uint32cxx . . $ uint32# numhits = 0;
91
92 // We can make this much quicker if we remember the extent of
93 // each interval list.
94 //
95 // We want to allow partial matches, so check that the end is
96 // above the min, and the begin is before the max.
97 //
98 // b-------e b-----e
99 // -------clump------
100 //
101 for (uint32cxx . . $ uint32# i=0; i<clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.; i++) {
102 if ((clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin.[i] <= end) && (begin <= clumpmaxcxx . . $ atacClumpCoordTreeScaffold#clumpmax.[i])) {
103 if (clumpscxx . . $ atacClumpCoordTreeScaffold#clumps.[i]->overlappingcxx . . $ intervalList#overlapping(842bb11ce078fb25).(begin, end, intervalscxx . . $ atacClumpCoordTreeScaffold#intervals., intervalsLencxx . . $ atacClumpCoordTreeScaffold#intervalsLen., intervalsMaxcxx . . $ atacClumpCoordTreeScaffold#intervalsMax.) > 0) {
104 clumpid = clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[i];
105 numhits++;
106 }
107 } else {
108 // If you really want to check....
109 //if (clumps[i]->overlapping(begin, end, intervals, intervalsLen, intervalsMax) > 0)
110 // fprintf(stderr, "WARNING: Found overlapping clump outside extent!\n");
111 }
112 }
113
114 if (numhits == 0)
115 return(0);
116 if (numhits == 1)
117 return(clumpid);
118
119 //fprintf(stderr, "FOUND MORE THAN ONE CLUMP MATCHING!\n");
120 return(~uint32ZEROcxx . . $ `libutil/util.h:60:10`!);
121 };
122
123
124 void sortClumpscxx . . $ atacClumpCoordTreeScaffold#sortClumps(49f6e7a06ebc5aa8).(void) {
125 uint32cxx . . $ uint32# ciid;
126 intervalListcxx . . $ intervalList#<uint64cxx . . $ uint64#> *cptr;
127 uint32cxx . . $ uint32# cmin;
128 uint32cxx . . $ uint32# cmax;
129
130 uint32cxx . . $ uint32# i = 0;
131 uint32cxx . . $ uint32# j = 0;
132
133 // an insertion sort
134
135 for (i=clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.; i--; ) {
136 ciid = clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[i];
137 cptr = clumpscxx . . $ atacClumpCoordTreeScaffold#clumps.[i];
138 cmin = clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin.[i];
139 cmax = clumpmaxcxx . . $ atacClumpCoordTreeScaffold#clumpmax.[i];
140
141 for (j=i+1; (j < clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.) && (cmin > clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin.[j]); j++) {
142 clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[j-1] = clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[j];
143 clumpscxx . . $ atacClumpCoordTreeScaffold#clumps.[j-1] = clumpscxx . . $ atacClumpCoordTreeScaffold#clumps.[j];
144 clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin.[j-1] = clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin.[j];
145 clumpmaxcxx . . $ atacClumpCoordTreeScaffold#clumpmax.[j-1] = clumpmaxcxx . . $ atacClumpCoordTreeScaffold#clumpmax.[j];
146 }
147
148 clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[j-1] = ciid;
149 clumpscxx . . $ atacClumpCoordTreeScaffold#clumps.[j-1] = cptr;
150 clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin.[j-1] = cmin;
151 clumpmaxcxx . . $ atacClumpCoordTreeScaffold#clumpmax.[j-1] = cmax;
152 }
153 };
154
155
156 void confirmcxx . . $ atacClumpCoordTreeScaffold#confirm(b4d55b1286ff73e8).(uint32cxx . . $ uint32# ca, uint32cxx . . $ uint32# cb) {
157 uint32cxx . . $ uint32# caidx = 0;
158 uint32cxx . . $ uint32# cbidx = 0;
159 for (uint32cxx . . $ uint32# i=0; i<clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.; i++) {
160 if (ca == clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[i])
161 caidx = i;
162 if (cb == clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[i])
163 cbidx = i;
164 }
165 clumpconfirmcxx . . $ atacClumpCoordTreeScaffold#clumpconfirm.[caidx * clumpsMaxcxx . . $ atacClumpCoordTreeScaffold#clumpsMax. + cbidx]++;
166 };
167
168
169 uint32cxx . . $ uint32# clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.;
170 uint32cxx . . $ uint32# clumpsMaxcxx . . $ atacClumpCoordTreeScaffold#clumpsMax.;
171 uint32cxx . . $ uint32# *clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.;
172 intervalListcxx . . $ intervalList#<uint64cxx . . $ uint64#> **clumpscxx . . $ atacClumpCoordTreeScaffold#clumps.;
173 uint32cxx . . $ uint32# *clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin.;
174 uint32cxx . . $ uint32# *clumpmaxcxx . . $ atacClumpCoordTreeScaffold#clumpmax.;
175
176 uint32cxx . . $ uint32# *clumpconfirmcxx . . $ atacClumpCoordTreeScaffold#clumpconfirm.;
177
178 uint32cxx . . $ uint32# intervalsLencxx . . $ atacClumpCoordTreeScaffold#intervalsLen.;
179 uint32cxx . . $ uint32# intervalsMaxcxx . . $ atacClumpCoordTreeScaffold#intervalsMax.;
180 uint32cxx . . $ uint32# *intervalscxx . . $ atacClumpCoordTreeScaffold#intervals.;
181 };
182
183
184 class atacClumpCoordTreecxx . . $ atacClumpCoordTree# {
185 public:
186 atacClumpCoordTreecxx . . $ atacClumpCoordTree#atacClumpCoordTree(49f6e7a06ebc5aa8).() {
187 scaffoldsMaxcxx . . $ atacClumpCoordTree#scaffoldsMax. = 262144;
188 scaffoldscxx . . $ atacClumpCoordTree#scaffolds. = new atacClumpCoordTreeScaffoldcxx . . $ atacClumpCoordTreeScaffold# * [scaffoldsMaxcxx . . $ atacClumpCoordTree#scaffoldsMax.];
189 for (uint32cxx . . $ uint32# i=0; i<scaffoldsMaxcxx . . $ atacClumpCoordTree#scaffoldsMax.; i++)
190 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i] = 0L;
191 };
192 ~cxx . . $ atacClumpCoordTree#`~atacClumpCoordTree`(ced63f7c635d850d).atacClumpCoordTreecxx . . $ atacClumpCoordTree#() {
193 for (uint32cxx . . $ uint32# i=0; i<scaffoldsMaxcxx . . $ atacClumpCoordTree#scaffoldsMax.; i++)
194 if (scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i])
195 delete scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i];
196 delete [] scaffoldscxx . . $ atacClumpCoordTree#scaffolds.;
197 };
198
199
200 void addMatchcxx . . $ atacClumpCoordTree#addMatch(30d30f11f531fc25).(uint32cxx . . $ uint32# scaffoldid, int32cxx . . $ int32# clumpid, uint32cxx . . $ uint32# begin, uint32cxx . . $ uint32# length) {
201 if (scaffoldid >= scaffoldsMaxcxx . . $ atacClumpCoordTree#scaffoldsMax.) {
202 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: increase scaffoldsMax "uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", scaffoldid);
203 exitcxx . . $ exit(44ed87f96534fad7).(1);
204 }
205
206 if (scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[scaffoldid] == 0L)
207 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[scaffoldid] = new atacClumpCoordTreeScaffoldcxx . . $ atacClumpCoordTreeScaffold#;
208
209 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[scaffoldid]->addMatchcxx . . $ atacClumpCoordTreeScaffold#addMatch(2029de666eaec704).(clumpid, begin, length);
210 };
211
212
213 void removeSingleClumpScaffoldscxx . . $ atacClumpCoordTree#removeSingleClumpScaffolds(49f6e7a06ebc5aa8).(void) {
214 uint32cxx . . $ uint32# deleted = 0;
215 uint32cxx . . $ uint32# remain = 0;
216
217
218 for (uint32cxx . . $ uint32# i=0; i<scaffoldsMaxcxx . . $ atacClumpCoordTree#scaffoldsMax.; i++) {
219 if ((scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]) && (scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen. < 2)) {
220 delete scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i];
221 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i] = 0L;
222 deleted++;
223 }
224 if (scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]) {
225 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->sortClumpscxx . . $ atacClumpCoordTreeScaffold#sortClumps(49f6e7a06ebc5aa8).();
226 remain++;
227 }
228 }
229 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Deleted "uint32FMTcxx . . $ `libutil/util.h:65:10`!" scaffolds with less than 2 clumps.\n", deleted);
230 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Remain "uint32FMTcxx . . $ `libutil/util.h:65:10`!" scaffolds with more than 2 clumps.\n", remain);
231 };
232
233
234 void showMultipleClumpScaffoldscxx . . $ atacClumpCoordTree#showMultipleClumpScaffolds(49f6e7a06ebc5aa8).(void) {
235
236 for (uint32cxx . . $ uint32# i=0; i<scaffoldsMaxcxx . . $ atacClumpCoordTree#scaffoldsMax.; i++) {
237 if ((scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]) && (scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen. >= 2)) {
238
239 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "\n");
240
241 for (uint32cxx . . $ uint32# j=0; j<scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.; j++) {
242 bool overlap = false;
243
244 if ((j+1 < scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.) &&
245 (scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpmaxcxx . . $ atacClumpCoordTreeScaffold#clumpmax.[j] > scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin.[j+1]))
246 overlap = true;
247
248 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "scaffold "uint32FMTcxx . . $ `libutil/util.h:65:10`!" clump "uint32FMTcxx . . $ `libutil/util.h:65:10`!" begin "uint32FMTcxx . . $ `libutil/util.h:65:10`!" end "uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n",
249 i,
250 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[j],
251 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpmincxx . . $ atacClumpCoordTreeScaffold#clumpmin.[j],
252 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpmaxcxx . . $ atacClumpCoordTreeScaffold#clumpmax.[j]);
253
254 if (overlap)
255 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "scaffold "uint32FMTcxx . . $ `libutil/util.h:65:10`!" clump "uint32FMTcxx . . $ `libutil/util.h:65:10`!" and clump "uint32FMTcxx . . $ `libutil/util.h:65:10`!" OVERLAP\n",
256 i,
257 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[j],
258 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[j+1]);
259
260 for (uint32cxx . . $ uint32# b=0; b<scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpsLencxx . . $ atacClumpCoordTreeScaffold#clumpsLen.; b++) {
261 uint32cxx . . $ uint32# cc = j * scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpsMaxcxx . . $ atacClumpCoordTreeScaffold#clumpsMax. + b;
262 if (scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpconfirmcxx . . $ atacClumpCoordTreeScaffold#clumpconfirm.[cc]) {
263 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "scaffold "uint32FMTcxx . . $ `libutil/util.h:65:10`!" clump "uint32FMTcxx . . $ `libutil/util.h:65:10`!" and "uint32FMTcxx . . $ `libutil/util.h:65:10`!" confirmed by "uint32FMTcxx . . $ `libutil/util.h:65:10`!" clones.\n",
264 i,
265 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[j],
266 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpIDcxx . . $ atacClumpCoordTreeScaffold#clumpID.[b],
267 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[i]->clumpconfirmcxx . . $ atacClumpCoordTreeScaffold#clumpconfirm.[cc]);
268
269 }
270 }
271 }
272 }
273 }
274 };
275
276
277 uint32cxx . . $ uint32# getClumpIDcxx . . $ atacClumpCoordTree#getClumpID(4eebda9b5e4ecc9c).(uint32cxx . . $ uint32# scaffoldid, uint32cxx . . $ uint32# begin, uint32cxx . . $ uint32# end) {
278 if (scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[scaffoldid])
279 return(scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[scaffoldid]->getClumpIDcxx . . $ atacClumpCoordTreeScaffold#getClumpID(83f10ac8959d5577).(begin, end));
280 return(0);
281 };
282
283 void confirmClumpcxx . . $ atacClumpCoordTree#confirmClump(6df00707c193238d).(uint32cxx . . $ uint32# scaffoldid, uint32cxx . . $ uint32# ca, uint32cxx . . $ uint32# cb) {
284 if (scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[scaffoldid]) {
285 scaffoldscxx . . $ atacClumpCoordTree#scaffolds.[scaffoldid]->confirmcxx . . $ atacClumpCoordTreeScaffold#confirm(b4d55b1286ff73e8).(ca, cb);
286 }
287 };
288
289
290 uint32cxx . . $ uint32# scaffoldsMaxcxx . . $ atacClumpCoordTree#scaffoldsMax.;
291 atacClumpCoordTreeScaffoldcxx . . $ atacClumpCoordTreeScaffold# **scaffoldscxx . . $ atacClumpCoordTree#scaffolds.;
292 };
293
294
295
296
297
298 atacClumpCoordTreecxx . . $ atacClumpCoordTree#*
299 buildCoordTreecxx . . $ buildCoordTree(412e168c718a41ae).(char *clumpFile) {
300 atacClumpCoordTreecxx . . $ atacClumpCoordTree# *ct = new atacClumpCoordTreecxx . . $ atacClumpCoordTree#;
301
302 FILE *inf;
303 char inl[1024];
304
305 // We can't use the built-in atac reader, because it strips out
306 // clump information. Bummer.
307
308 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
309 inf = fopen(clumpFile, "r");
310 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)
311 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Failed to open '%s': %s\n", clumpFile, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)), exitcxx . . $ exit(44ed87f96534fad7).(1);
312
313 fgets(inl, 1024, inf);
314
315 if (feof(inf))
316 return(0L);
317
318 while (!feof(inf)) {
319 if ((inl[0] == 'M') &&
320 (inl[2] == 'u')) {
321 splitToWordscxx . . $ splitToWords# Scxx . . $ splitToWords#splitToWords(fda57c8427c60377).(inl);
322
323 //fprintf(stderr, "%s", inl);
324
325 if (S[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).12][0] != '#')
326 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "no clump for '%s'\n", inl);
327
328 if (S[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).13][0] != '-') {
329 char *scfid = S[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).8];
330 while (*scfid != ':')
331 scfid++;
332
333 ct->addMatchcxx . . $ atacClumpCoordTree#addMatch(30d30f11f531fc25).(atoicxx . . $ atoi(f5ecf3191ed0cd93).(scfid + 1),
334 atoicxx . . $ atoi(f5ecf3191ed0cd93).(S[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).13]),
335 atoicxx . . $ atoi(f5ecf3191ed0cd93).(S[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).9]),
336 atoicxx . . $ atoi(f5ecf3191ed0cd93).(S[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).10]));
337 }
338 }
339
340 fgets(inl, 1024, inf);
341 }
342
343 fclose(inf);
344
345 return(ct);
346 }
347
348
349
350
351
352
353
354
355 int
356 maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) {
357 char *clumpFile = 0L;
358 char *happyFile = 0L;
359
360 int arg=1;
361 int err=0;
362 while (arg < argc) {
363 if (strcmp(argv[arg], "-clumps") == 0) {
364 clumpFile = argv[++arg];
365 } else if (strcmp(argv[arg], "-happy") == 0) {
366 happyFile = argv[++arg];
367 } else {
368 err++;
369 }
370
371 arg++;
372 }
373
374 if (clumpFile == 0L)
375 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "No -clumps supplied!\n"), err++;
376 if (happyFile == 0L)
377 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "No -happy clones supplied!\n"), err++;
378 if (err)
379 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: %s ...\n", argv[0]), exitcxx . . $ exit(44ed87f96534fad7).(1);
380
381 atacClumpCoordTreecxx . . $ atacClumpCoordTree# *ct = buildCoordTreecxx . . $ buildCoordTree(412e168c718a41ae).(clumpFile);
382
383 ct->removeSingleClumpScaffoldscxx . . $ atacClumpCoordTree#removeSingleClumpScaffolds(49f6e7a06ebc5aa8).();
384 ct->showMultipleClumpScaffoldscxx . . $ atacClumpCoordTree#showMultipleClumpScaffolds(49f6e7a06ebc5aa8).();
385
386 ////////////////////////////////////////
387 //
388 // ugly hack -- read in the map from HUREF6A UID to scaffold
389 //
390 mapcxx . . $ std/map#<uint64cxx . . $ uint64#,uint32cxx . . $ uint32#> UIDtoIIDcxx . . $ std/map#map(49f6e7a06ebc5aa8).;
391
392 {
393 char *uidmapName = "/project/huref6/assembly/fasta/HUREF6A.info";
394
395 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
396 FILE *F = fopen(uidmapName, "r");
397 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)
398 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Failed to open '%s': %s\n", uidmapName, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)), exitcxx . . $ exit(44ed87f96534fad7).(1);
399
400 char L[1024];
401
402 fgets(L, 1024, F);
403 while (!feof(F)) {
404 if (L[0] == 'G') {
405 splitToWordscxx . . $ splitToWords# Scxx . . $ splitToWords#splitToWords(fda57c8427c60377).(L);
406
407 UIDtoIID[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).strtouint64cxx . . $ `libutil/util.h:83:10`!(S[13]+1, 0L)] = strtouint32cxx . . $ `libutil/util.h:82:10`!(S[10], 0L);
408 }
409 fgets(L, 1024, F);
410 }
411 }
412 //
413 ////////////////////////////////////////
414
415 FILE *inf;
416 char ina[1024];
417 char inb[1024];
418
419 speedCountercxx . . $ speedCounter# Scxx . . $ speedCounter#speedCounter(cdc90e45b9a80ad5).("%9.0f clones (%6.1f clones/sec)\r", 1, 4096, true);
420
421 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
422 inf = fopen(happyFile, "r");
423 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)
424 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Failed to open '%s': %s\n", happyFile, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)), exitcxx . . $ exit(44ed87f96534fad7).(1);
425
426 fgets(ina, 1024, inf); chompcxx . . $ `libutil/util.h:330:9`!(ina);
427 fgets(inb, 1024, inf); chompcxx . . $ `libutil/util.h:330:9`!(inb);
428 while (!feof(inf)) {
429 splitToWordscxx . . $ splitToWords# Acxx . . $ splitToWords#splitToWords(fda57c8427c60377).(ina);
430 splitToWordscxx . . $ splitToWords# Bcxx . . $ splitToWords#splitToWords(fda57c8427c60377).(inb);
431
432 // Some sanity checking.
433 if (strcmp(A[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).2], B[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).2]) != 0) {
434 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: Different clone!\n%s\n%s\n", ina, inb);
435 }
436
437
438 uint32cxx . . $ uint32# scfa = UIDtoIID[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).strtouint64cxx . . $ `libutil/util.h:83:10`!(A[7], 0L)];
439 uint32cxx . . $ uint32# scfb = UIDtoIID[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).strtouint64cxx . . $ `libutil/util.h:83:10`!(B[7], 0L)];
440
441 uint32cxx . . $ uint32# cla = ct->getClumpIDcxx . . $ atacClumpCoordTree#getClumpID(4eebda9b5e4ecc9c).(scfa,
442 atoicxx . . $ atoi(f5ecf3191ed0cd93).(A[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).8]),
443 atoicxx . . $ atoi(f5ecf3191ed0cd93).(A[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).9]));
444 uint32cxx . . $ uint32# clb = ct->getClumpIDcxx . . $ atacClumpCoordTree#getClumpID(4eebda9b5e4ecc9c).(scfb,
445 atoicxx . . $ atoi(f5ecf3191ed0cd93).(B[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).8]),
446 atoicxx . . $ atoi(f5ecf3191ed0cd93).(B[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).9]));
447
448 if (cla == ~uint32ZEROcxx . . $ `libutil/util.h:60:10`!) {
449 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s spans clump in scaffold %s,"uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", ina, A[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).7], scfa);
450 cla = 0;
451 }
452 if (clb == ~uint32ZEROcxx . . $ `libutil/util.h:60:10`!) {
453 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "%s spans clump in scaffold %s,"uint32FMTcxx . . $ `libutil/util.h:65:10`!" \n", inb, B[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).7], scfb);
454 clb = 0;
455 }
456
457 if ((cla != 0) &&
458 (clb != 0) &&
459 (cla != clb)) {
460 ct->confirmClumpcxx . . $ atacClumpCoordTree#confirmClump(6df00707c193238d).(scfa,
461 (cla < clb) ? cla : clb,
462 (cla < clb) ? clb : cla);
463
464 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "scaffold %s,"uint32FMTcxx . . $ `libutil/util.h:65:10`!" clump "uint32FMTcxx . . $ `libutil/util.h:65:10`!" "uint32FMTcxx . . $ `libutil/util.h:65:10`!" confirmed by %s\n",
465 A[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).7], scfa,
466 (cla < clb) ? cla : clb,
467 (cla < clb) ? clb : cla,
468 A[cxx . . $ splitToWords#`operator[]`(f109d7e0a0ca42b3).2]);
469 }
470
471 S.tickcxx . . $ speedCounter#tick(c9857a73d68e59ba).();
472
473 fgets(ina, 1024, inf); chompcxx . . $ `libutil/util.h:330:9`!(ina);
474 fgets(inb, 1024, inf); chompcxx . . $ `libutil/util.h:330:9`!(inb);
475 }
476
477 fclose(inf);
478
479 S.finishcxx . . $ speedCounter#finish(49f6e7a06ebc5aa8).();
480
481 ct->showMultipleClumpScaffoldscxx . . $ atacClumpCoordTree#showMultipleClumpScaffolds(49f6e7a06ebc5aa8).();
482
483 delete ct;
484 }