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