1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.datamodel.features; |
22 |
|
|
23 |
|
import jalview.datamodel.ContiguousI; |
24 |
|
import jalview.datamodel.SequenceFeature; |
25 |
|
|
26 |
|
import java.util.ArrayList; |
27 |
|
import java.util.Collections; |
28 |
|
import java.util.Comparator; |
29 |
|
import java.util.HashSet; |
30 |
|
import java.util.List; |
31 |
|
import java.util.Set; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@author |
39 |
|
|
40 |
|
|
|
|
| 97.8% |
Uncovered Elements: 9 (411) |
Complexity: 120 |
Complexity Density: 0.51 |
|
41 |
|
public class FeatureStore |
42 |
|
{ |
43 |
|
|
44 |
|
|
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 6 |
Complexity Density: 1 |
|
46 |
|
abstract static class SearchCriterion |
47 |
|
{ |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
@param |
52 |
|
@return |
53 |
|
|
54 |
|
abstract boolean compare(SequenceFeature entry); |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
@param |
61 |
|
@return |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
40 |
static SearchCriterion byStart(final long target)... |
64 |
|
{ |
65 |
40 |
return new SearchCriterion() { |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
67 |
62 |
@Override... |
68 |
|
boolean compare(SequenceFeature entry) |
69 |
|
{ |
70 |
62 |
return entry.getBegin() >= target; |
71 |
|
} |
72 |
|
}; |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
@param |
80 |
|
@return |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
82 |
3855 |
static SearchCriterion byEnd(final long target)... |
83 |
|
{ |
84 |
3855 |
return new SearchCriterion() |
85 |
|
{ |
86 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
87 |
9027 |
@Override... |
88 |
|
boolean compare(SequenceFeature entry) |
89 |
|
{ |
90 |
9027 |
return entry.getEnd() >= target; |
91 |
|
} |
92 |
|
}; |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
@param |
100 |
|
@return |
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
78085 |
static SearchCriterion byFeature(final ContiguousI to,... |
103 |
|
final Comparator<ContiguousI> rc) |
104 |
|
{ |
105 |
78085 |
return new SearchCriterion() |
106 |
|
{ |
107 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
108 |
462655 |
@Override... |
109 |
|
boolean compare(SequenceFeature entry) |
110 |
|
{ |
111 |
462655 |
return rc.compare(entry, to) >= 0; |
112 |
|
} |
113 |
|
}; |
114 |
|
} |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
List<SequenceFeature> nonPositionalFeatures; |
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
List<SequenceFeature> nonNestedFeatures; |
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
List<SequenceFeature> contactFeatureStarts; |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
List<SequenceFeature> contactFeatureEnds; |
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
NCList<SequenceFeature> nestedFeatures; |
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
Set<String> positionalFeatureGroups; |
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
Set<String> nonPositionalFeatureGroups; |
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
int totalExtent; |
167 |
|
|
168 |
|
float positionalMinScore; |
169 |
|
|
170 |
|
float positionalMaxScore; |
171 |
|
|
172 |
|
float nonPositionalMinScore; |
173 |
|
|
174 |
|
float nonPositionalMaxScore; |
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
179 |
2789 |
public FeatureStore()... |
180 |
|
{ |
181 |
2789 |
nonNestedFeatures = new ArrayList<SequenceFeature>(); |
182 |
2789 |
positionalFeatureGroups = new HashSet<String>(); |
183 |
2789 |
nonPositionalFeatureGroups = new HashSet<String>(); |
184 |
2789 |
positionalMinScore = Float.NaN; |
185 |
2789 |
positionalMaxScore = Float.NaN; |
186 |
2789 |
nonPositionalMinScore = Float.NaN; |
187 |
2789 |
nonPositionalMaxScore = Float.NaN; |
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
} |
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
@param |
200 |
|
|
|
|
| 97.4% |
Uncovered Elements: 1 (38) |
Complexity: 9 |
Complexity Density: 0.41 |
|
201 |
46751 |
public boolean addFeature(SequenceFeature feature)... |
202 |
|
{ |
203 |
46751 |
if (contains(feature)) |
204 |
|
{ |
205 |
15309 |
return false; |
206 |
|
} |
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
31442 |
if (!feature.isNonPositional()) |
212 |
|
{ |
213 |
31375 |
positionalFeatureGroups.add(feature.getFeatureGroup()); |
214 |
|
} |
215 |
|
|
216 |
31442 |
boolean added = false; |
217 |
|
|
218 |
31442 |
if (feature.isContactFeature()) |
219 |
|
{ |
220 |
31 |
added = addContactFeature(feature); |
221 |
|
} |
222 |
31411 |
else if (feature.isNonPositional()) |
223 |
|
{ |
224 |
67 |
added = addNonPositionalFeature(feature); |
225 |
|
} |
226 |
|
else |
227 |
|
{ |
228 |
31344 |
added = addNonNestedFeature(feature); |
229 |
31344 |
if (!added) |
230 |
|
{ |
231 |
|
|
232 |
|
|
233 |
|
|
234 |
277 |
added = addNestedFeature(feature); |
235 |
|
} |
236 |
|
} |
237 |
|
|
238 |
31442 |
if (added) |
239 |
|
{ |
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
31442 |
totalExtent += getFeatureLength(feature); |
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
31442 |
float score = feature.getScore(); |
252 |
31442 |
if (!Float.isNaN(score)) |
253 |
|
{ |
254 |
31298 |
if (feature.isNonPositional()) |
255 |
|
{ |
256 |
44 |
nonPositionalMinScore = min(nonPositionalMinScore, score); |
257 |
44 |
nonPositionalMaxScore = max(nonPositionalMaxScore, score); |
258 |
|
} |
259 |
|
else |
260 |
|
{ |
261 |
31254 |
positionalMinScore = min(positionalMinScore, score); |
262 |
31254 |
positionalMaxScore = max(positionalMaxScore, score); |
263 |
|
} |
264 |
|
} |
265 |
|
} |
266 |
|
|
267 |
31442 |
return added; |
268 |
|
} |
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
@param |
275 |
|
@return |
276 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 7 |
Complexity Density: 1 |
|
277 |
46764 |
public boolean contains(SequenceFeature feature)... |
278 |
|
{ |
279 |
46764 |
if (feature.isNonPositional()) |
280 |
|
{ |
281 |
75 |
return nonPositionalFeatures == null ? false : nonPositionalFeatures |
282 |
|
.contains(feature); |
283 |
|
} |
284 |
|
|
285 |
46689 |
if (feature.isContactFeature()) |
286 |
|
{ |
287 |
35 |
return contactFeatureStarts == null ? false : listContains( |
288 |
|
contactFeatureStarts, feature); |
289 |
|
} |
290 |
|
|
291 |
46654 |
if (listContains(nonNestedFeatures, feature)) |
292 |
|
{ |
293 |
15273 |
return true; |
294 |
|
} |
295 |
|
|
296 |
31381 |
return nestedFeatures == null ? false : nestedFeatures |
297 |
|
.contains(feature); |
298 |
|
} |
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
@param |
305 |
|
@return |
306 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
307 |
31842 |
protected static int getFeatureLength(SequenceFeature feature)... |
308 |
|
{ |
309 |
31842 |
if (feature.isNonPositional()) |
310 |
|
{ |
311 |
68 |
return 0; |
312 |
|
} |
313 |
31774 |
if (feature.isContactFeature()) |
314 |
|
{ |
315 |
43 |
return 1; |
316 |
|
} |
317 |
31731 |
return 1 + feature.getEnd() - feature.getBegin(); |
318 |
|
} |
319 |
|
|
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
|
@param |
328 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
329 |
67 |
protected boolean addNonPositionalFeature(SequenceFeature feature)... |
330 |
|
{ |
331 |
67 |
if (nonPositionalFeatures == null) |
332 |
|
{ |
333 |
62 |
nonPositionalFeatures = new ArrayList<SequenceFeature>(); |
334 |
|
} |
335 |
|
|
336 |
67 |
nonPositionalFeatures.add(feature); |
337 |
|
|
338 |
67 |
nonPositionalFeatureGroups.add(feature.getFeatureGroup()); |
339 |
|
|
340 |
67 |
return true; |
341 |
|
} |
342 |
|
|
343 |
|
|
344 |
|
|
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
349 |
277 |
protected synchronized boolean addNestedFeature(SequenceFeature feature)... |
350 |
|
{ |
351 |
277 |
if (nestedFeatures == null) |
352 |
|
{ |
353 |
202 |
nestedFeatures = new NCList<>(feature); |
354 |
202 |
return true; |
355 |
|
} |
356 |
75 |
return nestedFeatures.add(feature, false); |
357 |
|
} |
358 |
|
|
359 |
|
|
360 |
|
|
361 |
|
|
362 |
|
|
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
@param |
367 |
|
@return |
368 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 5 |
Complexity Density: 0.5 |
|
369 |
31354 |
protected boolean addNonNestedFeature(SequenceFeature feature)... |
370 |
|
{ |
371 |
31354 |
synchronized (nonNestedFeatures) |
372 |
|
{ |
373 |
|
|
374 |
|
|
375 |
|
|
376 |
31354 |
int insertPosition = binarySearch(nonNestedFeatures, |
377 |
|
SearchCriterion.byFeature(feature, RangeComparator.BY_START_POSITION)); |
378 |
|
|
379 |
|
|
380 |
|
|
381 |
|
|
382 |
|
|
383 |
31354 |
if (insertPosition > 0) |
384 |
|
{ |
385 |
28431 |
if (encloses(nonNestedFeatures.get(insertPosition - 1), feature)) |
386 |
|
{ |
387 |
210 |
return false; |
388 |
|
} |
389 |
|
} |
390 |
31144 |
if (insertPosition < nonNestedFeatures.size()) |
391 |
|
{ |
392 |
297 |
if (encloses(feature, nonNestedFeatures.get(insertPosition))) |
393 |
|
{ |
394 |
73 |
return false; |
395 |
|
} |
396 |
|
} |
397 |
|
|
398 |
|
|
399 |
|
|
400 |
|
|
401 |
31071 |
nonNestedFeatures.add(insertPosition, feature); |
402 |
|
|
403 |
31071 |
return true; |
404 |
|
} |
405 |
|
} |
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
@param |
411 |
|
@param |
412 |
|
@return |
413 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 5 |
Complexity Density: 0.56 |
|
414 |
28728 |
protected boolean encloses(ContiguousI range1, ContiguousI range2)... |
415 |
|
{ |
416 |
28728 |
int begin1 = range1.getBegin(); |
417 |
28728 |
int begin2 = range2.getBegin(); |
418 |
28728 |
int end1 = range1.getEnd(); |
419 |
28728 |
int end2 = range2.getEnd(); |
420 |
28728 |
if (begin1 == begin2 && end1 > end2) |
421 |
|
{ |
422 |
68 |
return true; |
423 |
|
} |
424 |
28660 |
if (begin1 < begin2 && end1 >= end2) |
425 |
|
{ |
426 |
215 |
return true; |
427 |
|
} |
428 |
28445 |
return false; |
429 |
|
} |
430 |
|
|
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
@param |
438 |
|
@return |
439 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
440 |
31 |
protected synchronized boolean addContactFeature(SequenceFeature feature)... |
441 |
|
{ |
442 |
31 |
if (contactFeatureStarts == null) |
443 |
|
{ |
444 |
23 |
contactFeatureStarts = new ArrayList<SequenceFeature>(); |
445 |
|
} |
446 |
31 |
if (contactFeatureEnds == null) |
447 |
|
{ |
448 |
23 |
contactFeatureEnds = new ArrayList<SequenceFeature>(); |
449 |
|
} |
450 |
|
|
451 |
|
|
452 |
|
|
453 |
|
|
454 |
31 |
int insertPosition = binarySearch(contactFeatureStarts, |
455 |
|
SearchCriterion.byFeature(feature, |
456 |
|
RangeComparator.BY_START_POSITION)); |
457 |
31 |
contactFeatureStarts.add(insertPosition, feature); |
458 |
|
|
459 |
31 |
Collections.sort(contactFeatureStarts, RangeComparator.BY_START_POSITION); |
460 |
|
|
461 |
31 |
insertPosition = binarySearch(contactFeatureStarts, |
462 |
|
SearchCriterion.byFeature(feature, |
463 |
|
RangeComparator.BY_END_POSITION)); |
464 |
31 |
contactFeatureEnds.add(feature); |
465 |
31 |
Collections.sort(contactFeatureEnds, RangeComparator.BY_END_POSITION); |
466 |
|
|
467 |
31 |
return true; |
468 |
|
} |
469 |
|
|
470 |
|
|
471 |
|
|
472 |
|
|
473 |
|
|
474 |
|
|
475 |
|
@param |
476 |
|
@param |
477 |
|
@return |
478 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 6 |
Complexity Density: 0.5 |
|
479 |
46672 |
protected static boolean listContains(List<SequenceFeature> features,... |
480 |
|
SequenceFeature feature) |
481 |
|
{ |
482 |
46672 |
if (features == null || feature == null) |
483 |
|
{ |
484 |
3 |
return false; |
485 |
|
} |
486 |
|
|
487 |
|
|
488 |
|
|
489 |
|
|
490 |
46669 |
int pos = binarySearch(features, |
491 |
|
SearchCriterion.byFeature(feature, RangeComparator.BY_START_POSITION)); |
492 |
46669 |
int len = features.size(); |
493 |
46823 |
while (pos < len) |
494 |
|
{ |
495 |
15667 |
SequenceFeature sf = features.get(pos); |
496 |
15667 |
if (sf.getBegin() > feature.getBegin()) |
497 |
|
{ |
498 |
236 |
return false; |
499 |
|
} |
500 |
15431 |
if (sf.equals(feature)) |
501 |
|
{ |
502 |
15277 |
return true; |
503 |
|
} |
504 |
154 |
pos++; |
505 |
|
} |
506 |
31156 |
return false; |
507 |
|
} |
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
|
|
513 |
|
|
514 |
|
@param |
515 |
|
|
516 |
|
@param |
517 |
|
|
518 |
|
@return |
519 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
520 |
3815 |
public List<SequenceFeature> findOverlappingFeatures(long start, long end)... |
521 |
|
{ |
522 |
3815 |
List<SequenceFeature> result = new ArrayList<>(); |
523 |
|
|
524 |
3815 |
findNonNestedFeatures(start, end, result); |
525 |
|
|
526 |
3815 |
findContactFeatures(start, end, result); |
527 |
|
|
528 |
3815 |
if (nestedFeatures != null) |
529 |
|
{ |
530 |
18 |
result.addAll(nestedFeatures.findOverlaps(start, end)); |
531 |
|
} |
532 |
|
|
533 |
3815 |
return result; |
534 |
|
} |
535 |
|
|
536 |
|
|
537 |
|
|
538 |
|
|
539 |
|
|
540 |
|
@param |
541 |
|
@param |
542 |
|
@param |
543 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
544 |
3815 |
protected void findContactFeatures(long from, long to,... |
545 |
|
List<SequenceFeature> result) |
546 |
|
{ |
547 |
3815 |
if (contactFeatureStarts != null) |
548 |
|
{ |
549 |
40 |
findContactStartFeatures(from, to, result); |
550 |
|
} |
551 |
3815 |
if (contactFeatureEnds != null) |
552 |
|
{ |
553 |
40 |
findContactEndFeatures(from, to, result); |
554 |
|
} |
555 |
|
} |
556 |
|
|
557 |
|
|
558 |
|
|
559 |
|
|
560 |
|
|
561 |
|
|
562 |
|
@param |
563 |
|
@param |
564 |
|
@param |
565 |
|
|
|
|
| 87.5% |
Uncovered Elements: 3 (24) |
Complexity: 8 |
Complexity Density: 0.57 |
|
566 |
40 |
protected void findContactEndFeatures(long from, long to,... |
567 |
|
List<SequenceFeature> result) |
568 |
|
{ |
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
|
573 |
40 |
int startPosition = binarySearch(contactFeatureEnds, |
574 |
|
SearchCriterion.byEnd(from)); |
575 |
63 |
for (; startPosition < contactFeatureEnds.size(); startPosition++) |
576 |
|
{ |
577 |
48 |
SequenceFeature sf = contactFeatureEnds.get(startPosition); |
578 |
48 |
if (!sf.isContactFeature()) |
579 |
|
{ |
580 |
0 |
System.err.println("Error! non-contact feature type " |
581 |
|
+ sf.getType() + " in contact features list"); |
582 |
0 |
continue; |
583 |
|
} |
584 |
|
|
585 |
48 |
int begin = sf.getBegin(); |
586 |
48 |
if (begin >= from && begin <= to) |
587 |
|
{ |
588 |
|
|
589 |
|
|
590 |
|
|
591 |
|
|
592 |
8 |
continue; |
593 |
|
} |
594 |
|
|
595 |
40 |
int end = sf.getEnd(); |
596 |
40 |
if (end >= from && end <= to) |
597 |
|
{ |
598 |
15 |
result.add(sf); |
599 |
|
} |
600 |
40 |
if (end > to) |
601 |
|
{ |
602 |
25 |
break; |
603 |
|
} |
604 |
|
} |
605 |
|
} |
606 |
|
|
607 |
|
|
608 |
|
|
609 |
|
|
610 |
|
|
611 |
|
|
612 |
|
@param |
613 |
|
@param |
614 |
|
@param |
615 |
|
|
|
|
| 93.8% |
Uncovered Elements: 1 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
616 |
3815 |
protected void findNonNestedFeatures(long from, long to,... |
617 |
|
List<SequenceFeature> result) |
618 |
|
{ |
619 |
|
|
620 |
|
|
621 |
|
|
622 |
|
|
623 |
3815 |
int startIndex = binarySearch(nonNestedFeatures, |
624 |
|
SearchCriterion.byEnd(from)); |
625 |
|
|
626 |
3815 |
final int startIndex1 = startIndex; |
627 |
3815 |
int i = startIndex1; |
628 |
29896 |
while (i < nonNestedFeatures.size()) |
629 |
|
{ |
630 |
28863 |
SequenceFeature sf = nonNestedFeatures.get(i); |
631 |
28863 |
if (sf.getBegin() > to) |
632 |
|
{ |
633 |
2782 |
break; |
634 |
|
} |
635 |
26081 |
if (sf.getBegin() <= to && sf.getEnd() >= from) |
636 |
|
{ |
637 |
26081 |
result.add(sf); |
638 |
|
} |
639 |
26081 |
i++; |
640 |
|
} |
641 |
|
} |
642 |
|
|
643 |
|
|
644 |
|
|
645 |
|
|
646 |
|
|
647 |
|
@param |
648 |
|
@param |
649 |
|
@param |
650 |
|
|
|
|
| 80% |
Uncovered Elements: 3 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
651 |
40 |
protected void findContactStartFeatures(long from, long to,... |
652 |
|
List<SequenceFeature> result) |
653 |
|
{ |
654 |
40 |
int startPosition = binarySearch(contactFeatureStarts, |
655 |
|
SearchCriterion.byStart(from)); |
656 |
|
|
657 |
65 |
for (; startPosition < contactFeatureStarts.size(); startPosition++) |
658 |
|
{ |
659 |
25 |
SequenceFeature sf = contactFeatureStarts.get(startPosition); |
660 |
25 |
if (!sf.isContactFeature()) |
661 |
|
{ |
662 |
0 |
System.err.println("Error! non-contact feature type " |
663 |
|
+ sf.getType() + " in contact features list"); |
664 |
0 |
continue; |
665 |
|
} |
666 |
25 |
int begin = sf.getBegin(); |
667 |
25 |
if (begin >= from && begin <= to) |
668 |
|
{ |
669 |
8 |
result.add(sf); |
670 |
|
} |
671 |
|
} |
672 |
|
} |
673 |
|
|
674 |
|
|
675 |
|
|
676 |
|
|
677 |
|
@return |
678 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
679 |
3615 |
public List<SequenceFeature> getPositionalFeatures()... |
680 |
|
{ |
681 |
|
|
682 |
|
|
683 |
|
|
684 |
3615 |
List<SequenceFeature> result = new ArrayList<>(); |
685 |
3615 |
result.addAll(nonNestedFeatures); |
686 |
|
|
687 |
|
|
688 |
|
|
689 |
|
|
690 |
3615 |
if (contactFeatureStarts != null) |
691 |
|
{ |
692 |
46 |
result.addAll(contactFeatureStarts); |
693 |
|
} |
694 |
|
|
695 |
|
|
696 |
|
|
697 |
|
|
698 |
3615 |
if (nestedFeatures != null) |
699 |
|
{ |
700 |
320 |
result.addAll(nestedFeatures.getEntries()); |
701 |
|
} |
702 |
|
|
703 |
3615 |
return result; |
704 |
|
} |
705 |
|
|
706 |
|
|
707 |
|
|
708 |
|
|
709 |
|
|
710 |
|
@return |
711 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
712 |
7 |
public List<SequenceFeature> getContactFeatures()... |
713 |
|
{ |
714 |
7 |
if (contactFeatureStarts == null) |
715 |
|
{ |
716 |
3 |
return Collections.emptyList(); |
717 |
|
} |
718 |
4 |
return new ArrayList<>(contactFeatureStarts); |
719 |
|
} |
720 |
|
|
721 |
|
|
722 |
|
|
723 |
|
|
724 |
|
|
725 |
|
@return |
726 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
727 |
3552 |
public List<SequenceFeature> getNonPositionalFeatures()... |
728 |
|
{ |
729 |
3552 |
if (nonPositionalFeatures == null) |
730 |
|
{ |
731 |
3439 |
return Collections.emptyList(); |
732 |
|
} |
733 |
113 |
return new ArrayList<>(nonPositionalFeatures); |
734 |
|
} |
735 |
|
|
736 |
|
|
737 |
|
|
738 |
|
|
739 |
|
|
740 |
|
|
741 |
|
|
742 |
|
@param |
743 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 9 |
Complexity Density: 0.64 |
|
744 |
204 |
public synchronized boolean delete(SequenceFeature sf)... |
745 |
|
{ |
746 |
|
|
747 |
|
|
748 |
|
|
749 |
204 |
boolean removed = nonNestedFeatures.remove(sf); |
750 |
|
|
751 |
|
|
752 |
|
|
753 |
|
|
754 |
|
|
755 |
204 |
if (!removed && contactFeatureStarts != null) |
756 |
|
{ |
757 |
40 |
removed = contactFeatureStarts.remove(sf); |
758 |
40 |
if (removed) |
759 |
|
{ |
760 |
8 |
contactFeatureEnds.remove(sf); |
761 |
|
} |
762 |
|
} |
763 |
|
|
764 |
204 |
boolean removedNonPositional = false; |
765 |
|
|
766 |
|
|
767 |
|
|
768 |
|
|
769 |
204 |
if (!removed && nonPositionalFeatures != null) |
770 |
|
{ |
771 |
43 |
removedNonPositional = nonPositionalFeatures.remove(sf); |
772 |
43 |
removed = removedNonPositional; |
773 |
|
} |
774 |
|
|
775 |
|
|
776 |
|
|
777 |
|
|
778 |
204 |
if (!removed && nestedFeatures != null) |
779 |
|
{ |
780 |
30 |
removed = nestedFeatures.delete(sf); |
781 |
|
} |
782 |
|
|
783 |
204 |
if (removed) |
784 |
|
{ |
785 |
120 |
rescanAfterDelete(); |
786 |
|
} |
787 |
|
|
788 |
204 |
return removed; |
789 |
|
} |
790 |
|
|
791 |
|
|
792 |
|
|
793 |
|
|
794 |
|
|
795 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
|
796 |
120 |
protected synchronized void rescanAfterDelete()... |
797 |
|
{ |
798 |
120 |
positionalFeatureGroups.clear(); |
799 |
120 |
nonPositionalFeatureGroups.clear(); |
800 |
120 |
totalExtent = 0; |
801 |
120 |
positionalMinScore = Float.NaN; |
802 |
120 |
positionalMaxScore = Float.NaN; |
803 |
120 |
nonPositionalMinScore = Float.NaN; |
804 |
120 |
nonPositionalMaxScore = Float.NaN; |
805 |
|
|
806 |
|
|
807 |
|
|
808 |
|
|
809 |
120 |
for (SequenceFeature sf : getNonPositionalFeatures()) |
810 |
|
{ |
811 |
18 |
nonPositionalFeatureGroups.add(sf.getFeatureGroup()); |
812 |
18 |
float score = sf.getScore(); |
813 |
18 |
nonPositionalMinScore = min(nonPositionalMinScore, score); |
814 |
18 |
nonPositionalMaxScore = max(nonPositionalMaxScore, score); |
815 |
|
} |
816 |
|
|
817 |
|
|
818 |
|
|
819 |
|
|
820 |
120 |
for (SequenceFeature sf : getPositionalFeatures()) |
821 |
|
{ |
822 |
397 |
positionalFeatureGroups.add(sf.getFeatureGroup()); |
823 |
397 |
float score = sf.getScore(); |
824 |
397 |
positionalMinScore = min(positionalMinScore, score); |
825 |
397 |
positionalMaxScore = max(positionalMaxScore, score); |
826 |
397 |
totalExtent += getFeatureLength(sf); |
827 |
|
} |
828 |
|
} |
829 |
|
|
830 |
|
|
831 |
|
|
832 |
|
|
833 |
|
|
834 |
|
|
835 |
|
@param |
836 |
|
@param |
837 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 4 |
Complexity Density: 1.33 |
|
838 |
31717 |
protected static float min(float f1, float f2)... |
839 |
|
{ |
840 |
31717 |
if (Float.isNaN(f1)) |
841 |
|
{ |
842 |
2851 |
return Float.isNaN(f2) ? f1 : f2; |
843 |
|
} |
844 |
|
else |
845 |
|
{ |
846 |
28866 |
return Float.isNaN(f2) ? f1 : Math.min(f1, f2); |
847 |
|
} |
848 |
|
} |
849 |
|
|
850 |
|
|
851 |
|
|
852 |
|
|
853 |
|
|
854 |
|
|
855 |
|
@param |
856 |
|
@param |
857 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 4 |
Complexity Density: 1.33 |
|
858 |
31717 |
protected static float max(float f1, float f2)... |
859 |
|
{ |
860 |
31717 |
if (Float.isNaN(f1)) |
861 |
|
{ |
862 |
2851 |
return Float.isNaN(f2) ? f1 : f2; |
863 |
|
} |
864 |
|
else |
865 |
|
{ |
866 |
28866 |
return Float.isNaN(f2) ? f1 : Math.max(f1, f2); |
867 |
|
} |
868 |
|
} |
869 |
|
|
870 |
|
|
871 |
|
|
872 |
|
|
873 |
|
@return |
874 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
875 |
1127 |
public boolean isEmpty()... |
876 |
|
{ |
877 |
1127 |
boolean hasFeatures = !nonNestedFeatures.isEmpty() |
878 |
|
|| (contactFeatureStarts != null && !contactFeatureStarts |
879 |
|
.isEmpty()) |
880 |
|
|| (nonPositionalFeatures != null && !nonPositionalFeatures |
881 |
|
.isEmpty()) |
882 |
|
|| (nestedFeatures != null && nestedFeatures.size() > 0); |
883 |
|
|
884 |
1127 |
return !hasFeatures; |
885 |
|
} |
886 |
|
|
887 |
|
|
888 |
|
|
889 |
|
|
890 |
|
|
891 |
|
|
892 |
|
@param |
893 |
|
@return |
894 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 3 |
Complexity Density: 1 |
|
895 |
667 |
public Set<String> getFeatureGroups(boolean positionalFeatures)... |
896 |
|
{ |
897 |
667 |
if (positionalFeatures) |
898 |
|
{ |
899 |
629 |
return Collections.unmodifiableSet(positionalFeatureGroups); |
900 |
|
} |
901 |
|
else |
902 |
|
{ |
903 |
38 |
return nonPositionalFeatureGroups == null ? Collections |
904 |
|
.<String> emptySet() : Collections |
905 |
|
.unmodifiableSet(nonPositionalFeatureGroups); |
906 |
|
} |
907 |
|
} |
908 |
|
|
909 |
|
|
910 |
|
|
911 |
|
|
912 |
|
|
913 |
|
|
914 |
|
@param |
915 |
|
@param |
916 |
|
@return |
917 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 3 |
Complexity Density: 0.25 |
|
918 |
81980 |
protected static int binarySearch(List<SequenceFeature> features,... |
919 |
|
SearchCriterion sc) |
920 |
|
{ |
921 |
81980 |
int start = 0; |
922 |
81980 |
int end = features.size() - 1; |
923 |
81980 |
int matched = features.size(); |
924 |
|
|
925 |
553718 |
while (start <= end) |
926 |
|
{ |
927 |
471737 |
int mid = (start + end) / 2; |
928 |
471740 |
SequenceFeature entry = features.get(mid); |
929 |
471742 |
boolean compare = sc.compare(entry); |
930 |
471740 |
if (compare) |
931 |
|
{ |
932 |
57560 |
matched = mid; |
933 |
57560 |
end = mid - 1; |
934 |
|
} |
935 |
|
else |
936 |
|
{ |
937 |
414180 |
start = mid + 1; |
938 |
|
} |
939 |
|
} |
940 |
|
|
941 |
81980 |
return matched; |
942 |
|
} |
943 |
|
|
944 |
|
|
945 |
|
|
946 |
|
|
947 |
|
|
948 |
|
@param |
949 |
|
@return |
950 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 5 |
Complexity Density: 0.62 |
|
951 |
79 |
public int getFeatureCount(boolean positional)... |
952 |
|
{ |
953 |
79 |
if (!positional) |
954 |
|
{ |
955 |
26 |
return nonPositionalFeatures == null ? 0 : nonPositionalFeatures |
956 |
|
.size(); |
957 |
|
} |
958 |
|
|
959 |
53 |
int size = nonNestedFeatures.size(); |
960 |
|
|
961 |
53 |
if (contactFeatureStarts != null) |
962 |
|
{ |
963 |
|
|
964 |
14 |
size += contactFeatureStarts.size(); |
965 |
|
} |
966 |
|
|
967 |
53 |
if (nestedFeatures != null) |
968 |
|
{ |
969 |
5 |
size += nestedFeatures.size(); |
970 |
|
} |
971 |
|
|
972 |
53 |
return size; |
973 |
|
} |
974 |
|
|
975 |
|
|
976 |
|
|
977 |
|
|
978 |
|
|
979 |
|
@return |
980 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
981 |
42 |
public int getTotalFeatureLength()... |
982 |
|
{ |
983 |
42 |
return totalExtent; |
984 |
|
} |
985 |
|
|
986 |
|
|
987 |
|
|
988 |
|
|
989 |
|
|
990 |
|
|
991 |
|
@param |
992 |
|
@return |
993 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
994 |
174 |
public float getMinimumScore(boolean positional)... |
995 |
|
{ |
996 |
174 |
return positional ? positionalMinScore : nonPositionalMinScore; |
997 |
|
} |
998 |
|
|
999 |
|
|
1000 |
|
|
1001 |
|
|
1002 |
|
|
1003 |
|
|
1004 |
|
@param |
1005 |
|
@return |
1006 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
1007 |
148 |
public float getMaximumScore(boolean positional)... |
1008 |
|
{ |
1009 |
148 |
return positional ? positionalMaxScore : nonPositionalMaxScore; |
1010 |
|
} |
1011 |
|
|
1012 |
|
|
1013 |
|
|
1014 |
|
|
1015 |
|
|
1016 |
|
@param |
1017 |
|
@param |
1018 |
|
@return |
1019 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 10 |
Complexity Density: 1.11 |
|
1020 |
30 |
public List<SequenceFeature> getFeaturesForGroup(boolean positional,... |
1021 |
|
String group) |
1022 |
|
{ |
1023 |
30 |
List<SequenceFeature> result = new ArrayList<>(); |
1024 |
|
|
1025 |
|
|
1026 |
|
|
1027 |
|
|
1028 |
|
|
1029 |
30 |
if (positional && !positionalFeatureGroups.contains(group) |
1030 |
|
|| !positional && !nonPositionalFeatureGroups.contains(group)) |
1031 |
|
{ |
1032 |
7 |
return result; |
1033 |
|
} |
1034 |
|
|
1035 |
23 |
List<SequenceFeature> sfs = positional ? getPositionalFeatures() |
1036 |
|
: getNonPositionalFeatures(); |
1037 |
23 |
for (SequenceFeature sf : sfs) |
1038 |
|
{ |
1039 |
32 |
String featureGroup = sf.getFeatureGroup(); |
1040 |
32 |
if (group == null && featureGroup == null || group != null |
1041 |
|
&& group.equals(featureGroup)) |
1042 |
|
{ |
1043 |
23 |
result.add(sf); |
1044 |
|
} |
1045 |
|
} |
1046 |
23 |
return result; |
1047 |
|
} |
1048 |
|
|
1049 |
|
|
1050 |
|
|
1051 |
|
|
1052 |
|
|
1053 |
|
@param |
1054 |
|
@return |
1055 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 2 |
Complexity Density: 0.18 |
|
1056 |
11 |
public synchronized boolean shiftFeatures(int shift)... |
1057 |
|
{ |
1058 |
|
|
1059 |
|
|
1060 |
|
|
1061 |
|
|
1062 |
|
|
1063 |
11 |
boolean modified = false; |
1064 |
11 |
for (SequenceFeature sf : getPositionalFeatures()) |
1065 |
|
{ |
1066 |
12 |
modified = true; |
1067 |
12 |
int newBegin = sf.getBegin() + shift; |
1068 |
12 |
int newEnd = sf.getEnd() + shift; |
1069 |
|
|
1070 |
|
|
1071 |
|
|
1072 |
|
|
1073 |
12 |
if (newEnd > 0) |
1074 |
|
{ |
1075 |
10 |
newBegin = Math.max(1, newBegin); |
1076 |
10 |
SequenceFeature sf2 = new SequenceFeature(sf, newBegin, newEnd, |
1077 |
|
sf.getFeatureGroup(), sf.getScore()); |
1078 |
10 |
addFeature(sf2); |
1079 |
|
} |
1080 |
12 |
delete(sf); |
1081 |
|
} |
1082 |
11 |
return modified; |
1083 |
|
} |
1084 |
|
} |