Debian Codegraph @

seagen/filterEST-complicated.C

raw symbols SCIP
1 #cxx . . $ `<file>/seagen/filterEST-complicated.C`/include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <errno.h>
6 #include "aHit.H"cxx . . $ `<file>/seagen/aHit.H`/
7 #include "hitReader.H"cxx . . $ `<file>/seagen/hitReader.H`/
8
9
10 extern uint32cxx . . $ uint32# uniqThreshcxx . . $ uniqThresh.;
11 extern uint32cxx . . $ uint32# reptThreshcxx . . $ reptThresh.;
12 extern FILE *logFilecxx . . $ logFile.;
13 extern bool decidedcxx . . $ decided.;
14 extern const char *labelcxx . . $ label.;
15 extern uint32cxx . . $ uint32# hitsToSavecxx . . $ hitsToSave.;
16 extern double qualToSavecxx . . $ qualToSave.;
17
18 double differencecxx . . $ difference. = 0.1;
19
20 void
21 complicatedFilter_1_uniquecxx . . $ complicatedFilter_1_unique(3e702fd5c7abe76a).(hitReadercxx . . $ hitReader# &HR) {
22
23 if (HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).() <= uniqThreshcxx . . $ uniqThresh.) {
24 decidedcxx . . $ decided. = true;
25 labelcxx . . $ label. = "unique";
26 hitsToSavecxx . . $ hitsToSave. = HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).();
27 qualToSavecxx . . $ qualToSave. = 0.0;
28
29 // Try being a little more aggressive. Search for the last
30 // point where the score difference across 10 hits is more than
31 // difference and use that for a limit.
32
33
34 // On the 100k test set #1 (ESTmapper paper, 1 Oct 2004) this modification
35 // results in:
36 // tp=106564 fp=1255487 fn=56705 tn=52816595
37 //
38 // compared to saving all hits:
39 // tp=106579 fp=1914659 fn=56690 tn=52157423
40 //
41 // That is, we lost 15 true matches and didn't polish 660,000
42 // matches -- 1.21% of the total, but 50% of what we actually
43 // need to polish.
44 //
45 uint32cxx . . $ uint32# i = HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).() - 1;
46 while ((i >= 10) && ((HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i-10].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage. - HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.) < differencecxx . . $ difference.))
47 i--;
48
49 hitsToSavecxx . . $ hitsToSave. = HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).();
50 qualToSavecxx . . $ qualToSave. = HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.;
51
52 #if 0
53 // Take the middle hit, not the end. This doesn't hurt too much
54 // (20 matches out of 100,000 ESTs, and we missed one EST
55 // completely) but only gains us 0.08% additional filtering.
56 if (i >= 15)
57 qualToSave = HR[i-5].coverage;
58 #endif
59
60 // Save all hits with this coverage score! This isn't really needed, but it
61 // makes the log message correct.
62 //
63 while ((i < HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).()) && (qualToSavecxx . . $ qualToSave. == HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.))
64 i++;
65
66 if (logFilecxx . . $ logFile.)
67 fprintf(logFilecxx . . $ logFile., uint32FMTcxx . . $ `libutil/util.h:65:10`!"] unique: aggressively filtered to "uint32FMTcxx . . $ `libutil/util.h:65:10`!" hits out of "uint32FMTcxx . . $ `libutil/util.h:65:10`!" hits.\n",
68 HR.iidcxx . . $ hitReader#iid(db52760e79bf9054).(), i, HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).());
69 }
70 }
71
72
73
74
75
76 void
77 complicatedFilter_2_kneecxx . . $ complicatedFilter_2_knee(3e702fd5c7abe76a).(hitReadercxx . . $ hitReader# &HR) {
78
79 decidedcxx . . $ decided. = false;
80 hitsToSavecxx . . $ hitsToSave. = 0;
81 qualToSavecxx . . $ qualToSave. = 0.0;
82
83 #if 0
84 decided = true;
85 hitsToSave = 0;
86 qualToSave = 1.1;
87 return;
88 #endif
89
90 // Apply the same filter as used in #1 (the aggressive part), and accept
91 // it if the number of hits saved is below some threshold.
92
93 uint32cxx . . $ uint32# i = HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).() - 1;
94 while ((i >= 10) && ((HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i-10].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage. - HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.) < differencecxx . . $ difference.))
95 i--;
96
97 // If i==9, then we failed to find a knee, and we fail this filter
98 //
99 if (i < 10)
100 return;
101
102 hitsToSavecxx . . $ hitsToSave. = HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).();
103 qualToSavecxx . . $ qualToSave. = HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.;
104
105 // Save all hits with this coverage score!
106 //
107 while ((i < HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).()) && (qualToSavecxx . . $ qualToSave. == HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.))
108 i++;
109
110 if (i <= uniqThreshcxx . . $ uniqThresh.) {
111 decidedcxx . . $ decided. = true;
112 labelcxx . . $ label. = "knee";
113
114 if (logFilecxx . . $ logFile.)
115 fprintf(logFilecxx . . $ logFile., uint32FMTcxx . . $ `libutil/util.h:65:10`!"] knee: filtered "uint32FMTcxx . . $ `libutil/util.h:65:10`!" hits down to "uint32FMTcxx . . $ `libutil/util.h:65:10`!" hits using threshold %f\n",
116 HR.iidcxx . . $ hitReader#iid(db52760e79bf9054).(), HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).(), i, qualToSavecxx . . $ qualToSave.);
117 }
118 }
119
120
121
122 // If all scores are about the same, it's either a repeat or a
123 // lot of spurious matches, depending on the level of signal.
124 //
125 void
126 complicatedFilter_3_uniformcxx . . $ complicatedFilter_3_uniform(3e702fd5c7abe76a).(hitReadercxx . . $ hitReader# &HR) {
127
128 decidedcxx . . $ decided. = false;
129 hitsToSavecxx . . $ hitsToSave. = 0;
130 qualToSavecxx . . $ qualToSave. = 0.0;
131
132 if ((HR.bestScorecxx . . $ hitReader#bestScore(31fa7155c10fdd13).() - HR.worstScorecxx . . $ hitReader#worstScore(31fa7155c10fdd13).()) < differencecxx . . $ difference.) {
133 decidedcxx . . $ decided. = true;
134 labelcxx . . $ label. = "uniform";
135 hitsToSavecxx . . $ hitsToSave. = reptThreshcxx . . $ reptThresh.;
136 qualToSavecxx . . $ qualToSave. = 0.0;
137
138 if (logFilecxx . . $ logFile.) {
139 fprintf(logFilecxx . . $ logFile., uint32FMTcxx . . $ `libutil/util.h:65:10`!"] uniform: uniform signal strength, saving the first "uint32FMTcxx . . $ `libutil/util.h:65:10`!" hits out of "uint32FMTcxx . . $ `libutil/util.h:65:10`!" hits, best=%f, worst=%f\n",
140 HR.iidcxx . . $ hitReader#iid(db52760e79bf9054).(), hitsToSavecxx . . $ hitsToSave., HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).(), HR.bestScorecxx . . $ hitReader#bestScore(31fa7155c10fdd13).(), HR.worstScorecxx . . $ hitReader#worstScore(31fa7155c10fdd13).());
141 }
142 }
143 }
144
145
146
147
148 // If we're not decided here, the EST had too many "good" hits to
149 // be filtered by the threshold method. Try a more sophisticated
150 // (confusing) method.
151 //
152 void
153 complicatedFilter_4_largestdifferencecxx . . $ complicatedFilter_4_largestdifference(3e702fd5c7abe76a).(hitReadercxx . . $ hitReader# &HR) {
154
155 decidedcxx . . $ decided. = false;
156 hitsToSavecxx . . $ hitsToSave. = 0;
157 qualToSavecxx . . $ qualToSave. = 0.0;
158
159 double largestDifference = 0.0;
160 for (uint32cxx . . $ uint32# i=1; i < HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).(); i++)
161 if (largestDifference < (HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i-1].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage. - HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.))
162 largestDifference = HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i-1].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage. - HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.;
163
164 // If the largest difference is below 10% coverage, then it's not
165 // clear how to pick a threshold and we just save a bunch of hits.
166 //
167 if (largestDifference < differencecxx . . $ difference.) {
168 decidedcxx . . $ decided. = true;
169 labelcxx . . $ label. = "diff";
170 hitsToSavecxx . . $ hitsToSave. = reptThreshcxx . . $ reptThresh.;
171 qualToSavecxx . . $ qualToSave. = 0.0;
172
173 if (logFilecxx . . $ logFile.)
174 fprintf(logFilecxx . . $ logFile., uint32FMTcxx . . $ `libutil/util.h:65:10`!"] diff: has no clear signal knee, saving the first "uint32FMTcxx . . $ `libutil/util.h:65:10`!" hits out of "uint32FMTcxx . . $ `libutil/util.h:65:10`!" hits, best=%f, worst=%f, largestdiff=%f\n",
175 HR.iidcxx . . $ hitReader#iid(db52760e79bf9054).(), hitsToSavecxx . . $ hitsToSave., HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).(), HR.bestScorecxx . . $ hitReader#bestScore(31fa7155c10fdd13).(), HR.worstScorecxx . . $ hitReader#worstScore(31fa7155c10fdd13).(), largestDifference);
176 }
177 }
178
179
180
181 // Identify any spike near the start. If we see a spike,
182 // save the first uniqThresh hits.
183 //
184 // If the largest difference (which we guarantee to be >= 10%
185 // coverage here) is in the first uniqThresh hits, then we
186 // have a spike and we output uniqThresh hits.
187 //
188 // To narrow the range more, we find the last spot where the
189 // difference in scores over 10 hits is > difference. This is a
190 // generous heuristic.
191 //
192 void
193 complicatedFilter_5_spikescxx . . $ complicatedFilter_5_spikes(3e702fd5c7abe76a).(hitReadercxx . . $ hitReader# &HR) {
194
195 decidedcxx . . $ decided. = false;
196 hitsToSavecxx . . $ hitsToSave. = 0;
197 qualToSavecxx . . $ qualToSave. = 0.0;
198
199 uint32cxx . . $ uint32# spikeFound = 0;
200 for (uint32cxx . . $ uint32# i=1; i < uniqThreshcxx . . $ uniqThresh.; i++)
201 if ((HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i-1].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage. - HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.) > differencecxx . . $ difference.)
202 spikeFound = i;
203
204 // If we have found a spike, start at hit[uniqThresh], search
205 // backwards for the first point where the difference in
206 // scores across 10 hits is larger than difference
207 //
208 // Seems like a NOP, but it loosens things up a bit. Consider a
209 // spike between hits 3 and 4, but 1=2=3 and 4=5=6=7=8=9=10=11. We
210 // find a spike, then find a nice place to cut it. If we never
211 // find a nice place, we save the top uniqThresh hits.
212
213 if (spikeFound) {
214 decidedcxx . . $ decided. = true;
215 labelcxx . . $ label. = "spike";
216 hitsToSavecxx . . $ hitsToSave. = uniqThreshcxx . . $ uniqThresh.;
217 qualToSavecxx . . $ qualToSave. = 0.0;
218
219 for (uint32cxx . . $ uint32# i=uniqThreshcxx . . $ uniqThresh.-1; i > 9; i--)
220 if ((HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i-10].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage. - HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).i].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.) > differencecxx . . $ difference.) {
221 hitsToSavecxx . . $ hitsToSave. = i + 1;
222 break;
223 }
224
225 qualToSavecxx . . $ qualToSave. = HR[cxx . . $ hitReader#`operator[]`(38191595156c9293).hitsToSavecxx . . $ hitsToSave.].coveragecxx . . $ $anonymous_type_cf7e7b12f763008e_1#coverage.;
226
227 if (logFilecxx . . $ logFile.)
228 fprintf(logFilecxx . . $ logFile., uint32FMTcxx . . $ `libutil/util.h:65:10`!"] spike: at "uint32FMTcxx . . $ `libutil/util.h:65:10`!", "uint32FMTcxx . . $ `libutil/util.h:65:10`!" hits saved: thresh=%f, "uint32FMTcxx . . $ `libutil/util.h:65:10`!" hits, best=%f, worst=%f\n",
229 HR.iidcxx . . $ hitReader#iid(db52760e79bf9054).(), spikeFound, hitsToSavecxx . . $ hitsToSave., qualToSavecxx . . $ qualToSave., HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).(), HR.bestScorecxx . . $ hitReader#bestScore(31fa7155c10fdd13).(), HR.worstScorecxx . . $ hitReader#worstScore(31fa7155c10fdd13).());
230 }
231 }
232
233
234
235
236 void
237 complicatedFiltercxx . . $ complicatedFilter(3e702fd5c7abe76a).(hitReadercxx . . $ hitReader# &HR) {
238 decidedcxx . . $ decided. = false;
239 labelcxx . . $ label. = "NOLABELERROR";
240 qualToSavecxx . . $ qualToSave. = 1.0;
241 hitsToSavecxx . . $ hitsToSave. = 0;
242
243 complicatedFilter_1_uniquecxx . . $ complicatedFilter_1_unique(3e702fd5c7abe76a).(HR);
244
245 if (decidedcxx . . $ decided.)
246 return;
247
248 complicatedFilter_2_kneecxx . . $ complicatedFilter_2_knee(3e702fd5c7abe76a).(HR);
249
250 if (decidedcxx . . $ decided.)
251 return;
252
253 complicatedFilter_3_uniformcxx . . $ complicatedFilter_3_uniform(3e702fd5c7abe76a).(HR);
254
255 if (decidedcxx . . $ decided.)
256 return;
257
258 complicatedFilter_4_largestdifferencecxx . . $ complicatedFilter_4_largestdifference(3e702fd5c7abe76a).(HR);
259
260 if (decidedcxx . . $ decided.)
261 return;
262
263 complicatedFilter_5_spikescxx . . $ complicatedFilter_5_spikes(3e702fd5c7abe76a).(HR);
264
265 if (decidedcxx . . $ decided.)
266 return;
267
268 decidedcxx . . $ decided. = true;
269 labelcxx . . $ label. = "unknown";
270 hitsToSavecxx . . $ hitsToSave. = reptThreshcxx . . $ reptThresh.;
271 qualToSavecxx . . $ qualToSave. = 0.0;
272
273 if (hitsToSavecxx . . $ hitsToSave. > HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).())
274 hitsToSavecxx . . $ hitsToSave. = HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).();
275
276 if (logFilecxx . . $ logFile.)
277 fprintf(logFilecxx . . $ logFile., uint32FMTcxx . . $ `libutil/util.h:65:10`!"] is an unclassified signal, "uint32FMTcxx . . $ `libutil/util.h:65:10`!" hits saved out of "uint32FMTcxx . . $ `libutil/util.h:65:10`!" hits, best=%f, worst=%f\n",
278 HR.iidcxx . . $ hitReader#iid(db52760e79bf9054).(), hitsToSavecxx . . $ hitsToSave., HR.numHitscxx . . $ hitReader#numHits(db52760e79bf9054).(), HR.bestScorecxx . . $ hitReader#bestScore(31fa7155c10fdd13).(), HR.worstScorecxx . . $ hitReader#worstScore(31fa7155c10fdd13).());
279 }