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 java.util.ArrayList; |
24 |
|
import java.util.Collections; |
25 |
|
import java.util.HashSet; |
26 |
|
import java.util.List; |
27 |
|
import java.util.Set; |
28 |
|
|
29 |
|
import intervalstore.api.IntervalStoreI; |
30 |
|
import intervalstore.impl.BinarySearcher; |
31 |
|
import intervalstore.impl.BinarySearcher.Compare; |
32 |
|
import intervalstore.impl.IntervalStore; |
33 |
|
import jalview.datamodel.SequenceFeature; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@author |
41 |
|
|
42 |
|
|
|
|
| 95.5% |
Uncovered Elements: 15 (331) |
Complexity: 97 |
Complexity Density: 0.52 |
|
43 |
|
public class FeatureStore |
44 |
|
{ |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
List<SequenceFeature> nonPositionalFeatures; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
List<SequenceFeature> contactFeatureStarts; |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
List<SequenceFeature> contactFeatureEnds; |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
IntervalStoreI<SequenceFeature> features; |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
Set<String> positionalFeatureGroups; |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
Set<String> nonPositionalFeatureGroups; |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
int totalExtent; |
84 |
|
|
85 |
|
float positionalMinScore; |
86 |
|
|
87 |
|
float positionalMaxScore; |
88 |
|
|
89 |
|
float nonPositionalMinScore; |
90 |
|
|
91 |
|
float nonPositionalMaxScore; |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
96 |
2267 |
public FeatureStore()... |
97 |
|
{ |
98 |
2267 |
features = new IntervalStore<>(); |
99 |
2267 |
positionalFeatureGroups = new HashSet<>(); |
100 |
2267 |
nonPositionalFeatureGroups = new HashSet<>(); |
101 |
2267 |
positionalMinScore = Float.NaN; |
102 |
2267 |
positionalMaxScore = Float.NaN; |
103 |
2267 |
nonPositionalMinScore = Float.NaN; |
104 |
2267 |
nonPositionalMaxScore = Float.NaN; |
105 |
|
|
106 |
|
|
107 |
|
} |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
@param |
116 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (30) |
Complexity: 7 |
Complexity Density: 0.39 |
|
117 |
174380 |
public boolean addFeature(SequenceFeature feature)... |
118 |
|
{ |
119 |
174380 |
if (contains(feature)) |
120 |
|
{ |
121 |
72419 |
return false; |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
101961 |
if (!feature.isNonPositional()) |
128 |
|
{ |
129 |
101898 |
positionalFeatureGroups.add(feature.getFeatureGroup()); |
130 |
|
} |
131 |
|
|
132 |
101961 |
if (feature.isContactFeature()) |
133 |
|
{ |
134 |
42 |
addContactFeature(feature); |
135 |
|
} |
136 |
101919 |
else if (feature.isNonPositional()) |
137 |
|
{ |
138 |
63 |
addNonPositionalFeature(feature); |
139 |
|
} |
140 |
|
else |
141 |
|
{ |
142 |
101856 |
addNestedFeature(feature); |
143 |
|
} |
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
101961 |
totalExtent += getFeatureLength(feature); |
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
101961 |
float score = feature.getScore(); |
157 |
101961 |
if (!Float.isNaN(score)) |
158 |
|
{ |
159 |
101817 |
if (feature.isNonPositional()) |
160 |
|
{ |
161 |
40 |
nonPositionalMinScore = min(nonPositionalMinScore, score); |
162 |
40 |
nonPositionalMaxScore = max(nonPositionalMaxScore, score); |
163 |
|
} |
164 |
|
else |
165 |
|
{ |
166 |
101777 |
positionalMinScore = min(positionalMinScore, score); |
167 |
101777 |
positionalMaxScore = max(positionalMaxScore, score); |
168 |
|
} |
169 |
|
} |
170 |
|
|
171 |
101961 |
return true; |
172 |
|
} |
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
@param |
179 |
|
@return |
180 |
|
|
|
|
| 93.3% |
Uncovered Elements: 1 (15) |
Complexity: 6 |
Complexity Density: 1.2 |
|
181 |
174393 |
public boolean contains(SequenceFeature feature)... |
182 |
|
{ |
183 |
174393 |
if (feature.isNonPositional()) |
184 |
|
{ |
185 |
71 |
return nonPositionalFeatures == null ? false : nonPositionalFeatures |
186 |
|
.contains(feature); |
187 |
|
} |
188 |
|
|
189 |
174322 |
if (feature.isContactFeature()) |
190 |
|
{ |
191 |
46 |
return contactFeatureStarts == null ? false : listContains( |
192 |
|
contactFeatureStarts, feature); |
193 |
|
} |
194 |
|
|
195 |
174276 |
return features == null ? false : features |
196 |
|
.contains(feature); |
197 |
|
} |
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
@param |
204 |
|
@return |
205 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
206 |
105012 |
protected static int getFeatureLength(SequenceFeature feature)... |
207 |
|
{ |
208 |
105012 |
if (feature.isNonPositional()) |
209 |
|
{ |
210 |
64 |
return 0; |
211 |
|
} |
212 |
104948 |
if (feature.isContactFeature()) |
213 |
|
{ |
214 |
62 |
return 1; |
215 |
|
} |
216 |
104886 |
return 1 + feature.getEnd() - feature.getBegin(); |
217 |
|
} |
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
@param |
227 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
228 |
63 |
protected boolean addNonPositionalFeature(SequenceFeature feature)... |
229 |
|
{ |
230 |
63 |
if (nonPositionalFeatures == null) |
231 |
|
{ |
232 |
58 |
nonPositionalFeatures = new ArrayList<>(); |
233 |
|
} |
234 |
|
|
235 |
63 |
nonPositionalFeatures.add(feature); |
236 |
|
|
237 |
63 |
nonPositionalFeatureGroups.add(feature.getFeatureGroup()); |
238 |
|
|
239 |
63 |
return true; |
240 |
|
} |
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
246 |
101856 |
protected synchronized void addNestedFeature(SequenceFeature feature)... |
247 |
|
{ |
248 |
101856 |
if (features == null) |
249 |
|
{ |
250 |
0 |
features = new IntervalStore<>(); |
251 |
|
} |
252 |
101856 |
features.add(feature); |
253 |
|
} |
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
@param |
262 |
|
@return |
263 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
264 |
42 |
protected synchronized boolean addContactFeature(SequenceFeature feature)... |
265 |
|
{ |
266 |
42 |
if (contactFeatureStarts == null) |
267 |
|
{ |
268 |
25 |
contactFeatureStarts = new ArrayList<>(); |
269 |
|
} |
270 |
42 |
if (contactFeatureEnds == null) |
271 |
|
{ |
272 |
25 |
contactFeatureEnds = new ArrayList<>(); |
273 |
|
} |
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
42 |
int insertPosition = BinarySearcher.findFirst(contactFeatureStarts, |
280 |
|
true, Compare.GE, feature.getBegin()); |
281 |
42 |
contactFeatureStarts.add(insertPosition, feature); |
282 |
|
|
283 |
|
|
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
|
288 |
42 |
insertPosition = BinarySearcher.findFirst(contactFeatureEnds, |
289 |
|
false, Compare.GE, feature.getEnd()); |
290 |
42 |
contactFeatureEnds.add(insertPosition, feature); |
291 |
|
|
292 |
42 |
return true; |
293 |
|
} |
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
@param |
301 |
|
@param |
302 |
|
@return |
303 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 6 |
Complexity Density: 0.5 |
|
304 |
27 |
protected static boolean listContains(List<SequenceFeature> features,... |
305 |
|
SequenceFeature feature) |
306 |
|
{ |
307 |
27 |
if (features == null || feature == null) |
308 |
|
{ |
309 |
3 |
return false; |
310 |
|
} |
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
|
315 |
|
|
316 |
|
|
317 |
24 |
int pos = BinarySearcher.findFirst(features, true, Compare.GE, |
318 |
|
feature.getBegin()); |
319 |
24 |
int len = features.size(); |
320 |
33 |
while (pos < len) |
321 |
|
{ |
322 |
18 |
SequenceFeature sf = features.get(pos); |
323 |
18 |
if (sf.getBegin() > feature.getBegin()) |
324 |
|
{ |
325 |
5 |
return false; |
326 |
|
} |
327 |
13 |
if (sf.equals(feature)) |
328 |
|
{ |
329 |
4 |
return true; |
330 |
|
} |
331 |
9 |
pos++; |
332 |
|
} |
333 |
15 |
return false; |
334 |
|
} |
335 |
|
|
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
|
@param |
342 |
|
|
343 |
|
@param |
344 |
|
|
345 |
|
@return |
346 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
347 |
4152 |
public List<SequenceFeature> findOverlappingFeatures(long start, long end)... |
348 |
|
{ |
349 |
4152 |
List<SequenceFeature> result = new ArrayList<>(); |
350 |
|
|
351 |
4152 |
findContactFeatures(start, end, result); |
352 |
|
|
353 |
4152 |
if (features != null) |
354 |
|
{ |
355 |
4152 |
result.addAll(features.findOverlaps(start, end)); |
356 |
|
} |
357 |
|
|
358 |
4152 |
return result; |
359 |
|
} |
360 |
|
|
361 |
|
|
362 |
|
|
363 |
|
|
364 |
|
|
365 |
|
@param |
366 |
|
@param |
367 |
|
@param |
368 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
369 |
4152 |
protected void findContactFeatures(long from, long to,... |
370 |
|
List<SequenceFeature> result) |
371 |
|
{ |
372 |
4152 |
if (contactFeatureStarts != null) |
373 |
|
{ |
374 |
41 |
findContactStartOverlaps(from, to, result); |
375 |
|
} |
376 |
4152 |
if (contactFeatureEnds != null) |
377 |
|
{ |
378 |
41 |
findContactEndOverlaps(from, to, result); |
379 |
|
} |
380 |
|
} |
381 |
|
|
382 |
|
|
383 |
|
|
384 |
|
|
385 |
|
|
386 |
|
|
387 |
|
@param |
388 |
|
@param |
389 |
|
@param |
390 |
|
|
|
|
| 82.6% |
Uncovered Elements: 4 (23) |
Complexity: 6 |
Complexity Density: 0.4 |
|
391 |
41 |
protected void findContactEndOverlaps(long from, long to,... |
392 |
|
List<SequenceFeature> result) |
393 |
|
{ |
394 |
|
|
395 |
|
|
396 |
|
|
397 |
|
|
398 |
41 |
int index = BinarySearcher.findFirst(contactFeatureEnds, |
399 |
|
false, Compare.GE, (int) from); |
400 |
|
|
401 |
67 |
while (index < contactFeatureEnds.size()) |
402 |
|
{ |
403 |
52 |
SequenceFeature sf = contactFeatureEnds.get(index); |
404 |
52 |
if (!sf.isContactFeature()) |
405 |
|
{ |
406 |
0 |
System.err.println("Error! non-contact feature type " |
407 |
|
+ sf.getType() + " in contact features list"); |
408 |
0 |
index++; |
409 |
0 |
continue; |
410 |
|
} |
411 |
|
|
412 |
52 |
int begin = sf.getBegin(); |
413 |
52 |
if (begin >= from && begin <= to) |
414 |
|
{ |
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
10 |
index++; |
420 |
10 |
continue; |
421 |
|
} |
422 |
|
|
423 |
42 |
if (sf.getEnd() > to) |
424 |
|
{ |
425 |
|
|
426 |
|
|
427 |
|
|
428 |
26 |
break; |
429 |
|
} |
430 |
|
|
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
16 |
result.add(sf); |
436 |
16 |
index++; |
437 |
|
} |
438 |
|
} |
439 |
|
|
440 |
|
|
441 |
|
|
442 |
|
|
443 |
|
|
444 |
|
@param |
445 |
|
@param |
446 |
|
@param |
447 |
|
|
|
|
| 76.5% |
Uncovered Elements: 4 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
448 |
41 |
protected void findContactStartOverlaps(long from, long to,... |
449 |
|
List<SequenceFeature> result) |
450 |
|
{ |
451 |
41 |
int index = BinarySearcher.findFirst(contactFeatureStarts, |
452 |
|
true, Compare.GE, (int) from); |
453 |
|
|
454 |
51 |
while (index < contactFeatureStarts.size()) |
455 |
|
{ |
456 |
20 |
SequenceFeature sf = contactFeatureStarts.get(index); |
457 |
20 |
if (!sf.isContactFeature()) |
458 |
|
{ |
459 |
0 |
System.err.println("Error! non-contact feature " + sf.toString() |
460 |
|
+ " in contact features list"); |
461 |
0 |
index++; |
462 |
0 |
continue; |
463 |
|
} |
464 |
20 |
if (sf.getBegin() > to) |
465 |
|
{ |
466 |
|
|
467 |
|
|
468 |
|
|
469 |
10 |
break; |
470 |
|
} |
471 |
|
|
472 |
|
|
473 |
|
|
474 |
|
|
475 |
|
|
476 |
10 |
result.add(sf); |
477 |
10 |
index++; |
478 |
|
} |
479 |
|
} |
480 |
|
|
481 |
|
|
482 |
|
|
483 |
|
|
484 |
|
@return |
485 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
486 |
3936 |
public List<SequenceFeature> getPositionalFeatures()... |
487 |
|
{ |
488 |
3936 |
List<SequenceFeature> result = new ArrayList<>(); |
489 |
|
|
490 |
|
|
491 |
|
|
492 |
|
|
493 |
3936 |
if (contactFeatureStarts != null) |
494 |
|
{ |
495 |
63 |
result.addAll(contactFeatureStarts); |
496 |
|
} |
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
501 |
3936 |
if (features != null) |
502 |
|
{ |
503 |
3936 |
result.addAll(features); |
504 |
|
} |
505 |
|
|
506 |
3936 |
return result; |
507 |
|
} |
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
|
|
513 |
|
@return |
514 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
515 |
19 |
public List<SequenceFeature> getContactFeatures()... |
516 |
|
{ |
517 |
19 |
if (contactFeatureStarts == null) |
518 |
|
{ |
519 |
14 |
return Collections.emptyList(); |
520 |
|
} |
521 |
5 |
return new ArrayList<>(contactFeatureStarts); |
522 |
|
} |
523 |
|
|
524 |
|
|
525 |
|
|
526 |
|
|
527 |
|
|
528 |
|
@return |
529 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
530 |
3856 |
public List<SequenceFeature> getNonPositionalFeatures()... |
531 |
|
{ |
532 |
3856 |
if (nonPositionalFeatures == null) |
533 |
|
{ |
534 |
3736 |
return Collections.emptyList(); |
535 |
|
} |
536 |
120 |
return new ArrayList<>(nonPositionalFeatures); |
537 |
|
} |
538 |
|
|
539 |
|
|
540 |
|
|
541 |
|
|
542 |
|
|
543 |
|
|
544 |
|
|
545 |
|
@param |
546 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 9 |
Complexity Density: 0.64 |
|
547 |
390 |
public synchronized boolean delete(SequenceFeature sf)... |
548 |
|
{ |
549 |
390 |
boolean removed = false; |
550 |
|
|
551 |
|
|
552 |
|
|
553 |
|
|
554 |
|
|
555 |
390 |
if (!removed && contactFeatureStarts != null) |
556 |
|
{ |
557 |
55 |
removed = contactFeatureStarts.remove(sf); |
558 |
55 |
if (removed) |
559 |
|
{ |
560 |
14 |
contactFeatureEnds.remove(sf); |
561 |
|
} |
562 |
|
} |
563 |
|
|
564 |
390 |
boolean removedNonPositional = false; |
565 |
|
|
566 |
|
|
567 |
|
|
568 |
|
|
569 |
390 |
if (!removed && nonPositionalFeatures != null) |
570 |
|
{ |
571 |
59 |
removedNonPositional = nonPositionalFeatures.remove(sf); |
572 |
59 |
removed = removedNonPositional; |
573 |
|
} |
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
|
578 |
390 |
if (!removed && features != null) |
579 |
|
{ |
580 |
359 |
removed = features.remove(sf); |
581 |
|
} |
582 |
|
|
583 |
390 |
if (removed) |
584 |
|
{ |
585 |
295 |
rescanAfterDelete(); |
586 |
|
} |
587 |
|
|
588 |
390 |
return removed; |
589 |
|
} |
590 |
|
|
591 |
|
|
592 |
|
|
593 |
|
|
594 |
|
|
595 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
|
596 |
295 |
protected synchronized void rescanAfterDelete()... |
597 |
|
{ |
598 |
295 |
positionalFeatureGroups.clear(); |
599 |
295 |
nonPositionalFeatureGroups.clear(); |
600 |
295 |
totalExtent = 0; |
601 |
295 |
positionalMinScore = Float.NaN; |
602 |
295 |
positionalMaxScore = Float.NaN; |
603 |
295 |
nonPositionalMinScore = Float.NaN; |
604 |
295 |
nonPositionalMaxScore = Float.NaN; |
605 |
|
|
606 |
|
|
607 |
|
|
608 |
|
|
609 |
295 |
for (SequenceFeature sf : getNonPositionalFeatures()) |
610 |
|
{ |
611 |
19 |
nonPositionalFeatureGroups.add(sf.getFeatureGroup()); |
612 |
19 |
float score = sf.getScore(); |
613 |
19 |
nonPositionalMinScore = min(nonPositionalMinScore, score); |
614 |
19 |
nonPositionalMaxScore = max(nonPositionalMaxScore, score); |
615 |
|
} |
616 |
|
|
617 |
|
|
618 |
|
|
619 |
|
|
620 |
295 |
for (SequenceFeature sf : getPositionalFeatures()) |
621 |
|
{ |
622 |
3048 |
positionalFeatureGroups.add(sf.getFeatureGroup()); |
623 |
3048 |
float score = sf.getScore(); |
624 |
3048 |
positionalMinScore = min(positionalMinScore, score); |
625 |
3048 |
positionalMaxScore = max(positionalMaxScore, score); |
626 |
3048 |
totalExtent += getFeatureLength(sf); |
627 |
|
} |
628 |
|
} |
629 |
|
|
630 |
|
|
631 |
|
|
632 |
|
|
633 |
|
|
634 |
|
|
635 |
|
@param |
636 |
|
@param |
637 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 4 |
Complexity Density: 1.33 |
|
638 |
104888 |
protected static float min(float f1, float f2)... |
639 |
|
{ |
640 |
104888 |
if (Float.isNaN(f1)) |
641 |
|
{ |
642 |
2502 |
return Float.isNaN(f2) ? f1 : f2; |
643 |
|
} |
644 |
|
else |
645 |
|
{ |
646 |
102386 |
return Float.isNaN(f2) ? f1 : Math.min(f1, f2); |
647 |
|
} |
648 |
|
} |
649 |
|
|
650 |
|
|
651 |
|
|
652 |
|
|
653 |
|
|
654 |
|
|
655 |
|
@param |
656 |
|
@param |
657 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 4 |
Complexity Density: 1.33 |
|
658 |
104888 |
protected static float max(float f1, float f2)... |
659 |
|
{ |
660 |
104888 |
if (Float.isNaN(f1)) |
661 |
|
{ |
662 |
2502 |
return Float.isNaN(f2) ? f1 : f2; |
663 |
|
} |
664 |
|
else |
665 |
|
{ |
666 |
102386 |
return Float.isNaN(f2) ? f1 : Math.max(f1, f2); |
667 |
|
} |
668 |
|
} |
669 |
|
|
670 |
|
|
671 |
|
|
672 |
|
|
673 |
|
@return |
674 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
675 |
1134 |
public boolean isEmpty()... |
676 |
|
{ |
677 |
1134 |
boolean hasFeatures = (contactFeatureStarts != null |
678 |
|
&& !contactFeatureStarts |
679 |
|
.isEmpty()) |
680 |
|
|| (nonPositionalFeatures != null && !nonPositionalFeatures |
681 |
|
.isEmpty()) |
682 |
|
|| (features != null && features.size() > 0); |
683 |
|
|
684 |
1134 |
return !hasFeatures; |
685 |
|
} |
686 |
|
|
687 |
|
|
688 |
|
|
689 |
|
|
690 |
|
|
691 |
|
|
692 |
|
@param |
693 |
|
@return |
694 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 3 |
Complexity Density: 1 |
|
695 |
2294 |
public Set<String> getFeatureGroups(boolean positionalFeatures)... |
696 |
|
{ |
697 |
2294 |
if (positionalFeatures) |
698 |
|
{ |
699 |
2220 |
return Collections.unmodifiableSet(positionalFeatureGroups); |
700 |
|
} |
701 |
|
else |
702 |
|
{ |
703 |
74 |
return nonPositionalFeatureGroups == null ? Collections |
704 |
|
.<String> emptySet() : Collections |
705 |
|
.unmodifiableSet(nonPositionalFeatureGroups); |
706 |
|
} |
707 |
|
} |
708 |
|
|
709 |
|
|
710 |
|
|
711 |
|
|
712 |
|
|
713 |
|
@param |
714 |
|
@return |
715 |
|
|
|
|
| 93.8% |
Uncovered Elements: 1 (16) |
Complexity: 5 |
Complexity Density: 0.62 |
|
716 |
79 |
public int getFeatureCount(boolean positional)... |
717 |
|
{ |
718 |
79 |
if (!positional) |
719 |
|
{ |
720 |
26 |
return nonPositionalFeatures == null ? 0 : nonPositionalFeatures |
721 |
|
.size(); |
722 |
|
} |
723 |
|
|
724 |
53 |
int size = 0; |
725 |
|
|
726 |
53 |
if (contactFeatureStarts != null) |
727 |
|
{ |
728 |
|
|
729 |
14 |
size += contactFeatureStarts.size(); |
730 |
|
} |
731 |
|
|
732 |
53 |
if (features != null) |
733 |
|
{ |
734 |
53 |
size += features.size(); |
735 |
|
} |
736 |
|
|
737 |
53 |
return size; |
738 |
|
} |
739 |
|
|
740 |
|
|
741 |
|
|
742 |
|
|
743 |
|
|
744 |
|
@return |
745 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
746 |
42 |
public int getTotalFeatureLength()... |
747 |
|
{ |
748 |
42 |
return totalExtent; |
749 |
|
} |
750 |
|
|
751 |
|
|
752 |
|
|
753 |
|
|
754 |
|
|
755 |
|
|
756 |
|
@param |
757 |
|
@return |
758 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
759 |
722 |
public float getMinimumScore(boolean positional)... |
760 |
|
{ |
761 |
722 |
return positional ? positionalMinScore : nonPositionalMinScore; |
762 |
|
} |
763 |
|
|
764 |
|
|
765 |
|
|
766 |
|
|
767 |
|
|
768 |
|
|
769 |
|
@param |
770 |
|
@return |
771 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
772 |
696 |
public float getMaximumScore(boolean positional)... |
773 |
|
{ |
774 |
696 |
return positional ? positionalMaxScore : nonPositionalMaxScore; |
775 |
|
} |
776 |
|
|
777 |
|
|
778 |
|
|
779 |
|
|
780 |
|
|
781 |
|
@param |
782 |
|
@param |
783 |
|
@return |
784 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 10 |
Complexity Density: 1.11 |
|
785 |
48 |
public List<SequenceFeature> getFeaturesForGroup(boolean positional,... |
786 |
|
String group) |
787 |
|
{ |
788 |
48 |
List<SequenceFeature> result = new ArrayList<>(); |
789 |
|
|
790 |
|
|
791 |
|
|
792 |
|
|
793 |
|
|
794 |
48 |
if (positional && !positionalFeatureGroups.contains(group) |
795 |
|
|| !positional && !nonPositionalFeatureGroups.contains(group)) |
796 |
|
{ |
797 |
7 |
return result; |
798 |
|
} |
799 |
|
|
800 |
41 |
List<SequenceFeature> sfs = positional ? getPositionalFeatures() |
801 |
|
: getNonPositionalFeatures(); |
802 |
41 |
for (SequenceFeature sf : sfs) |
803 |
|
{ |
804 |
58 |
String featureGroup = sf.getFeatureGroup(); |
805 |
58 |
if (group == null && featureGroup == null || group != null |
806 |
|
&& group.equals(featureGroup)) |
807 |
|
{ |
808 |
41 |
result.add(sf); |
809 |
|
} |
810 |
|
} |
811 |
41 |
return result; |
812 |
|
} |
813 |
|
|
814 |
|
|
815 |
|
|
816 |
|
|
817 |
|
|
818 |
|
|
819 |
|
@param |
820 |
|
@param |
821 |
|
@return |
822 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 3 |
Complexity Density: 0.25 |
|
823 |
45 |
public synchronized boolean shiftFeatures(int fromPosition, int shiftBy)... |
824 |
|
{ |
825 |
|
|
826 |
|
|
827 |
|
|
828 |
|
|
829 |
|
|
830 |
45 |
boolean modified = false; |
831 |
45 |
for (SequenceFeature sf : getPositionalFeatures()) |
832 |
|
{ |
833 |
250 |
if (sf.getBegin() >= fromPosition) |
834 |
|
{ |
835 |
40 |
modified = true; |
836 |
40 |
int newBegin = sf.getBegin() + shiftBy; |
837 |
40 |
int newEnd = sf.getEnd() + shiftBy; |
838 |
|
|
839 |
|
|
840 |
|
|
841 |
|
|
842 |
40 |
if (newEnd > 0) |
843 |
|
{ |
844 |
38 |
newBegin = Math.max(1, newBegin); |
845 |
38 |
SequenceFeature sf2 = new SequenceFeature(sf, newBegin, newEnd, |
846 |
|
sf.getFeatureGroup(), sf.getScore()); |
847 |
38 |
addFeature(sf2); |
848 |
|
} |
849 |
40 |
delete(sf); |
850 |
|
} |
851 |
|
} |
852 |
45 |
return modified; |
853 |
|
} |
854 |
|
} |