Debian Codegraph @

seagen/hitReader.C

raw symbols SCIP
1 #cxx . . $ `<file>/seagen/hitReader.C`/include "hitReader.H"cxx . . $ `<file>/seagen/hitReader.H`/
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <errno.h>
5 #include <string.h>
6
7
8 static
9 int
10 hitCompareCoveragecxx . . $ hitCompareCoverage(9148c8c3ff42c9d8).(const void *a, const void *b) {
11 const hit_scxx . . $ hit_s# *A = (const hit_scxx . . $ hit_s# *)a;
12 const hit_scxx . . $ hit_s# *B = (const hit_scxx . . $ hit_s# *)b;
13
14 if (A->coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage. > B->coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.)
15 return(-1);
16 return(A->coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage. < B->coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.);
17 }
18
19 static
20 int
21 hitCompareGenPoscxx . . $ hitCompareGenPos(9148c8c3ff42c9d8).(const void *a, const void *b) {
22 const hit_scxx . . $ hit_s# *A = (const hit_scxx . . $ hit_s# *)a;
23 const hit_scxx . . $ hit_s# *B = (const hit_scxx . . $ hit_s# *)b;
24
25 if (A->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsIdxcxx . . $ aHit#_dsIdx. < B->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsIdxcxx . . $ aHit#_dsIdx.) return(-1);
26 if (A->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsIdxcxx . . $ aHit#_dsIdx. > B->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsIdxcxx . . $ aHit#_dsIdx.) return(1);
27
28 if (A->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._forwardcxx . . $ aHit#_forward. < B->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._forwardcxx . . $ aHit#_forward.) return(-1);
29 if (A->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._forwardcxx . . $ aHit#_forward. > B->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._forwardcxx . . $ aHit#_forward.) return(1);
30
31 if (A->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsLocxx . . $ aHit#_dsLo. < B->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsLocxx . . $ aHit#_dsLo.) return(-1);
32 if (A->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsLocxx . . $ aHit#_dsLo. > B->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsLocxx . . $ aHit#_dsLo.) return(1);
33
34 if (A->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsHicxx . . $ aHit#_dsHi. < B->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsHicxx . . $ aHit#_dsHi.) return(-1);
35 if (A->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsHicxx . . $ aHit#_dsHi. > B->acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsHicxx . . $ aHit#_dsHi.) return(1);
36
37 return(0);
38 }
39
40
41
42
43
44
45
46 hitReadercxx . . $ hitReader#::hitReadercxx . . $ hitReader#hitReader(d4f767463ce0a6b3).(int m) {
47 _filesMaxcxx . . $ hitReader#_filesMax. = m;
48 _filesLencxx . . $ hitReader#_filesLen. = 0;
49 _filescxx . . $ hitReader#_files. = new hitFile_scxx . . $ hitFile_s# [_filesMaxcxx . . $ hitReader#_filesMax.];
50
51 _listLencxx . . $ hitReader#_listLen. = 0;
52 _listMaxcxx . . $ hitReader#_listMax. = 1024 * 1024;
53 _listcxx . . $ hitReader#_list. = new hit_scxx . . $ hit_s# [_listMaxcxx . . $ hitReader#_listMax.];
54
55 _iidcxx . . $ hitReader#_iid. = uint32ZEROcxx . . $ `libutil/util.h:60:10`!;
56 _bestScorecxx . . $ hitReader#_bestScore. = 0.0;
57 _worstScorecxx . . $ hitReader#_worstScore. = 1.0;
58 }
59
60
61 hitReadercxx . . $ hitReader#::~cxx . . $ hitReader#`~hitReader`(ced63f7c635d850d).hitReadercxx . . $ hitReader#() {
62 for (uint32cxx . . $ uint32# i=0; i<_filesLencxx . . $ hitReader#_filesLen.; i++)
63 //fclose(_files[i].file);
64 delete _filescxx . . $ hitReader#_files.[i].buffcxx . . $ $anonymous_type_cf7e7b12f763008e_0#buff.;
65
66 delete [] _filescxx . . $ hitReader#_files.;
67 delete [] _listcxx . . $ hitReader#_list.;
68 }
69
70 void
71 hitReadercxx . . $ hitReader#::addInputFilecxx . . $ hitReader#addInputFile(fda57c8427c60377).(char *filename) {
72 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
73
74 _filescxx . . $ hitReader#_files.[_filesLencxx . . $ hitReader#_filesLen.].stillMorecxx . . $ $anonymous_type_cf7e7b12f763008e_0#stillMore. = true;
75 _filescxx . . $ hitReader#_files.[_filesLencxx . . $ hitReader#_filesLen.].buffcxx . . $ $anonymous_type_cf7e7b12f763008e_0#buff. = new readBuffercxx . . $ readBuffer#(filename);
76
77 // Binary or ASCII input?
78 //
79 _filescxx . . $ hitReader#_files.[_filesLencxx . . $ hitReader#_filesLen.].isBINARYcxx . . $ $anonymous_type_cf7e7b12f763008e_0#isBINARY. = (_filescxx . . $ hitReader#_files.[_filesLencxx . . $ hitReader#_filesLen.].buffcxx . . $ $anonymous_type_cf7e7b12f763008e_0#buff.->peekcxx . . $ readBuffer#peek(6e9c618e4dd2eafc).() != '-');
80
81 // Load the first hit
82 loadHitcxx . . $ hitReader#loadHit(ee2e5c8391ea149e).(_filescxx . . $ hitReader#_files.+_filesLencxx . . $ hitReader#_filesLen.);
83
84 _filesLencxx . . $ hitReader#_filesLen.++;
85 }
86
87
88 void
89 hitReadercxx . . $ hitReader#::loadHitcxx . . $ hitReader#loadHit(ee2e5c8391ea149e).(hitFile_scxx . . $ hitFile_s# *HF) {
90
91 if (HF->isBINARYcxx . . $ $anonymous_type_cf7e7b12f763008e_0#isBINARY.) {
92 ahit_readBinarycxx . . $ ahit_readBinary(ba1c9bd9da020cdc).(&HF->acxx . . $ $anonymous_type_cf7e7b12f763008e_0#a., HF->buffcxx . . $ $anonymous_type_cf7e7b12f763008e_0#buff.);
93 } else {
94 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: hitReader::loadHit() ascii not supported right now.\n");
95 exitcxx . . $ exit(44ed87f96534fad7).(1);
96 //fgets(HF->b, 1024, HF->file);
97 //ahit_parseString(&HF->a, HF->b);
98 }
99
100 if (HF->buffcxx . . $ $anonymous_type_cf7e7b12f763008e_0#buff.->eofcxx . . $ readBuffer#eof(c9857a73d68e59ba).())
101 HF->stillMorecxx . . $ $anonymous_type_cf7e7b12f763008e_0#stillMore. = false;
102 };
103
104
105 bool
106 hitReadercxx . . $ hitReader#::loadHitscxx . . $ hitReader#loadHits(c9857a73d68e59ba).(void) {
107
108 _listLencxx . . $ hitReader#_listLen. = 0;
109 _iidcxx . . $ hitReader#_iid. = uint32ZEROcxx . . $ `libutil/util.h:60:10`!;
110 _bestScorecxx . . $ hitReader#_bestScore. = 0.0;
111 _worstScorecxx . . $ hitReader#_worstScore. = 1.0;
112
113 // See if there are more hits to process.
114 //
115 bool keepGoing = false;
116 for (uint32cxx . . $ uint32# i=0; i<_filesLencxx . . $ hitReader#_filesLen.; i++)
117 keepGoing |= _filescxx . . $ hitReader#_files.[i].stillMorecxx . . $ $anonymous_type_cf7e7b12f763008e_0#stillMore.;
118
119 if (keepGoing == false)
120 return(false);
121
122 // Find the lowest ESTid
123 //
124 _iidcxx . . $ hitReader#_iid. = 1 << 30;
125 for (uint32cxx . . $ uint32# i=0; i<_filesLencxx . . $ hitReader#_filesLen.; i++)
126 if ((_filescxx . . $ hitReader#_files.[i].stillMorecxx . . $ $anonymous_type_cf7e7b12f763008e_0#stillMore.) && (_iidcxx . . $ hitReader#_iid. > _filescxx . . $ hitReader#_files.[i].acxx . . $ $anonymous_type_cf7e7b12f763008e_0#a.._qsIdxcxx . . $ aHit#_qsIdx.))
127 _iidcxx . . $ hitReader#_iid. = _filescxx . . $ hitReader#_files.[i].acxx . . $ $anonymous_type_cf7e7b12f763008e_0#a.._qsIdxcxx . . $ aHit#_qsIdx.;
128
129
130 // For each file, load the next hit if it's the est
131 // we're looking at
132 //
133 for (uint32cxx . . $ uint32# i=0; i<_filesLencxx . . $ hitReader#_filesLen.; i++) {
134 while ((_filescxx . . $ hitReader#_files.[i].stillMorecxx . . $ $anonymous_type_cf7e7b12f763008e_0#stillMore.) && (_filescxx . . $ hitReader#_files.[i].acxx . . $ $anonymous_type_cf7e7b12f763008e_0#a.._qsIdxcxx . . $ aHit#_qsIdx. == _iidcxx . . $ hitReader#_iid.)) {
135 if (_listLencxx . . $ hitReader#_listLen. >= _listMaxcxx . . $ hitReader#_listMax.) {
136 _listMaxcxx . . $ hitReader#_listMax. *= 2;
137 hit_scxx . . $ hit_s# *new_list = new hit_scxx . . $ hit_s# [_listMaxcxx . . $ hitReader#_listMax.];
138 memcpy(new_list, _listcxx . . $ hitReader#_list., _listLencxx . . $ hitReader#_listLen. * sizeof(hit_scxx . . $ hit_s#));
139 delete [] _listcxx . . $ hitReader#_list.;
140 _listcxx . . $ hitReader#_list. = new_list;
141 }
142
143 memcpy(&_listcxx . . $ hitReader#_list.[_listLencxx . . $ hitReader#_listLen.].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a., &_filescxx . . $ hitReader#_files.[i].acxx . . $ $anonymous_type_cf7e7b12f763008e_0#a., sizeof(aHitcxx . . $ aHit#));
144
145 _listcxx . . $ hitReader#_list.[_listLencxx . . $ hitReader#_listLen.].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage. = (double)_filescxx . . $ hitReader#_files.[i].acxx . . $ $anonymous_type_cf7e7b12f763008e_0#a.._coveredcxx . . $ aHit#_covered. / (double)_filescxx . . $ hitReader#_files.[i].acxx . . $ $anonymous_type_cf7e7b12f763008e_0#a.._numMerscxx . . $ aHit#_numMers.;
146 _listcxx . . $ hitReader#_list.[_listLencxx . . $ hitReader#_listLen.].multiplicitycxx . . $ $anonymous_type_cf7e7b12f763008e_1#multiplicity. = (double)_filescxx . . $ hitReader#_files.[i].acxx . . $ $anonymous_type_cf7e7b12f763008e_0#a.._matchedcxx . . $ aHit#_matched. / (double)_filescxx . . $ hitReader#_files.[i].acxx . . $ $anonymous_type_cf7e7b12f763008e_0#a.._coveredcxx . . $ aHit#_covered.;
147
148 // aHit->_covered is in bases, but aHit->_numMers is the
149 // number of mers. Possible for coverage to be > 1.0.
150 //
151 if (_listcxx . . $ hitReader#_list.[_listLencxx . . $ hitReader#_listLen.].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage. > 1.0)
152 _listcxx . . $ hitReader#_list.[_listLencxx . . $ hitReader#_listLen.].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage. = 1.0;
153
154 if (_listcxx . . $ hitReader#_list.[_listLencxx . . $ hitReader#_listLen.].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage. > _bestScorecxx . . $ hitReader#_bestScore.)
155 _bestScorecxx . . $ hitReader#_bestScore. = _listcxx . . $ hitReader#_list.[_listLencxx . . $ hitReader#_listLen.].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.;
156
157 if (_listcxx . . $ hitReader#_list.[_listLencxx . . $ hitReader#_listLen.].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage. < _worstScorecxx . . $ hitReader#_worstScore.)
158 _worstScorecxx . . $ hitReader#_worstScore. = _listcxx . . $ hitReader#_list.[_listLencxx . . $ hitReader#_listLen.].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.;
159
160 #ifdef WITH_ANSWERS
161 // Look for the answer string. If not found, set to zero.
162 //
163 _list[_listLen].mappedIdentity = 0;
164 _list[_listLen].mappedCoverage = 0;
165
166 for (int p=0; _files[i].b[p]; p++) {
167 if ((_files[i].b[p] == 'Y') || (_files[i].b[p] == 'N')) {
168 char *c = _files[i].b+p+1;
169 _list[_listLen].mappedIdentity = (uint32)strtoul(c, &c, 10);
170 _list[_listLen].mappedCoverage = (uint32)strtoul(c, &c, 10);
171 }
172 }
173 #endif
174
175 _listLencxx . . $ hitReader#_listLen.++;
176
177 loadHitcxx . . $ hitReader#loadHit(ee2e5c8391ea149e).(_filescxx . . $ hitReader#_files.+i);
178 }
179 }
180
181 mergeOverlappingHitscxx . . $ hitReader#mergeOverlappingHits(49f6e7a06ebc5aa8).();
182
183 return(true);
184 }
185
186
187
188 void
189 hitReadercxx . . $ hitReader#::sortByCoveragecxx . . $ hitReader#sortByCoverage(49f6e7a06ebc5aa8).(void) {
190 qsortcxx . . $ qsort(ebb60b13a65e77d7).(_listcxx . . $ hitReader#_list., _listLencxx . . $ hitReader#_listLen., sizeof(hit_scxx . . $ hit_s#), hitCompareCoveragecxx . . $ hitCompareCoverage(9148c8c3ff42c9d8).);
191 };
192
193
194
195
196
197 // scan the list of hits (for a single EST, remember) and merge
198 // any that are overlapping
199 //
200 void
201 hitReadercxx . . $ hitReader#::mergeOverlappingHitscxx . . $ hitReader#mergeOverlappingHits(49f6e7a06ebc5aa8).(void) {
202
203 // Sort by the genomic position
204 //
205 qsortcxx . . $ qsort(ebb60b13a65e77d7).(_listcxx . . $ hitReader#_list., _listLencxx . . $ hitReader#_listLen., sizeof(hit_scxx . . $ hit_s#), hitCompareGenPoscxx . . $ hitCompareGenPos(9148c8c3ff42c9d8).);
206
207 // Scan through the list, merging.
208 //
209 uint32cxx . . $ uint32# cur = 0; // Currently active entry
210 uint32cxx . . $ uint32# exa = 1; // Entry we examine for merging
211 while (exa < _listLencxx . . $ hitReader#_listLen.) {
212
213 // Do they overlap?
214 if ((_listcxx . . $ hitReader#_list.[cur].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsIdxcxx . . $ aHit#_dsIdx. == _listcxx . . $ hitReader#_list.[exa].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsIdxcxx . . $ aHit#_dsIdx.) &&
215 (_listcxx . . $ hitReader#_list.[cur].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._forwardcxx . . $ aHit#_forward. == _listcxx . . $ hitReader#_list.[exa].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._forwardcxx . . $ aHit#_forward.) &&
216 (_listcxx . . $ hitReader#_list.[cur].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsHicxx . . $ aHit#_dsHi. >= _listcxx . . $ hitReader#_list.[exa].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsLocxx . . $ aHit#_dsLo.)) {
217
218 // Yup, merge. Extend the current hit if it is smaller.
219
220 if ((_listcxx . . $ hitReader#_list.[cur].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsLocxx . . $ aHit#_dsLo. == _listcxx . . $ hitReader#_list.[exa].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsLocxx . . $ aHit#_dsLo.) &&
221 (_listcxx . . $ hitReader#_list.[cur].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsHicxx . . $ aHit#_dsHi. == _listcxx . . $ hitReader#_list.[exa].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsHicxx . . $ aHit#_dsHi.)) {
222 // Nop, they're the same.
223 } else if (_listcxx . . $ hitReader#_list.[cur].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsHicxx . . $ aHit#_dsHi. >= _listcxx . . $ hitReader#_list.[exa].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsHicxx . . $ aHit#_dsHi.) {
224 // Nop, exa is contained in cur.
225 } else {
226
227 // exa extends cur!
228
229 // If cur is contained in exa, just get rid of cur.
230 // Otherwise, we need to fudge up new scores -- but we
231 // instead just mark them as merged, and don't filter them.
232 //
233 if (_listcxx . . $ hitReader#_list.[cur].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsLocxx . . $ aHit#_dsLo. == _listcxx . . $ hitReader#_list.[exa].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsLocxx . . $ aHit#_dsLo.) {
234 memcpy(_listcxx . . $ hitReader#_list.+cur, _listcxx . . $ hitReader#_list.+exa, sizeof(hit_scxx . . $ hit_s#));
235 } else {
236 #ifdef DEBUG_HITREADER
237 fprintf(stderr,
238 "MERGE: ("uint32FMT","uint32FMT") -e "uint32FMT" "
239 uint32FMT":"uint32FMT"-"uint32FMT"%c("uint32FMT"-"uint32FMT"-"uint32FMT") "
240 uint32FMT":"uint32FMT"-"uint32FMT"%c("uint32FMT"-"uint32FMT"-"uint32FMT")\n",
241 cur, exa,
242 _list[cur].a._qsIdx,
243 _list[cur].a._dsIdx,
244 _list[cur].a._dsLo, _list[cur].a._dsHi, _list[cur].a._forward ? 'f' : 'r',
245 _list[cur].a._covered, _list[cur].a._matched, _list[cur].a._numMers,
246 _list[exa].a._dsIdx,
247 _list[exa].a._dsLo, _list[exa].a._dsHi, _list[exa].a._forward ? 'f' : 'r',
248 _list[exa].a._covered, _list[exa].a._matched, _list[exa].a._numMers);
249 #endif
250 _listcxx . . $ hitReader#_list.[cur].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._mergedcxx . . $ aHit#_merged. = true;
251 _listcxx . . $ hitReader#_list.[cur].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._coveredcxx . . $ aHit#_covered. = 0;
252 _listcxx . . $ hitReader#_list.[cur].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._matchedcxx . . $ aHit#_matched. = 0;
253 _listcxx . . $ hitReader#_list.[cur].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsHicxx . . $ aHit#_dsHi. = _listcxx . . $ hitReader#_list.[exa].acxx . . $ $anonymous_type_cf7e7b12f763008e_1#a.._dsHicxx . . $ aHit#_dsHi.;
254 }
255 }
256
257 // By now, we've updated cur to include all that exa did. exa is junk.
258
259 } else {
260 // Nope, copy exa to the next spot (unless they're the same)
261 // and move there.
262 //
263 cur++;
264 if (cur != exa)
265 memcpy(_listcxx . . $ hitReader#_list.+cur, _listcxx . . $ hitReader#_list.+exa, sizeof(hit_scxx . . $ hit_s#));
266 }
267
268 // Move to the next examination!
269 exa++;
270 }
271
272 _listLencxx . . $ hitReader#_listLen. = cur + 1;
273 }