1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.util; |
22 |
|
|
23 |
|
import java.util.ArrayList; |
24 |
|
import java.util.Arrays; |
25 |
|
import java.util.BitSet; |
26 |
|
import java.util.List; |
27 |
|
|
28 |
|
import jalview.bin.Console; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
|
|
| 64.8% |
Uncovered Elements: 226 (642) |
Complexity: 167 |
Complexity Density: 0.41 |
|
39 |
|
public class MapList |
40 |
|
{ |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
private List<int[]> fromShifts; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
private List<int[]> toShifts; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
private int fromRatio; |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
private int toRatio; |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
private int fromLowest; |
66 |
|
|
67 |
|
private int fromHighest; |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
private int toLowest; |
73 |
|
|
74 |
|
private int toHighest; |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
79 |
1240 |
public MapList()... |
80 |
|
{ |
81 |
1240 |
fromShifts = new ArrayList<>(); |
82 |
1240 |
toShifts = new ArrayList<>(); |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 8 |
Complexity Density: 1 |
|
89 |
108 |
@Override... |
90 |
|
public boolean equals(Object o) |
91 |
|
{ |
92 |
108 |
if (o == null || !(o instanceof MapList)) |
93 |
|
{ |
94 |
2 |
return false; |
95 |
|
} |
96 |
|
|
97 |
106 |
MapList obj = (MapList) o; |
98 |
106 |
if (obj == this) |
99 |
|
{ |
100 |
18 |
return true; |
101 |
|
} |
102 |
88 |
if (obj.fromRatio != fromRatio || obj.toRatio != toRatio |
103 |
|
|| obj.fromShifts == null || obj.toShifts == null) |
104 |
|
{ |
105 |
25 |
return false; |
106 |
|
} |
107 |
63 |
return Arrays.deepEquals(fromShifts.toArray(), obj.fromShifts.toArray()) |
108 |
|
&& Arrays.deepEquals(toShifts.toArray(), |
109 |
|
obj.toShifts.toArray()); |
110 |
|
} |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
115 |
39 |
@Override... |
116 |
|
public int hashCode() |
117 |
|
{ |
118 |
39 |
int hashCode = 31 * fromRatio; |
119 |
39 |
hashCode = 31 * hashCode + toRatio; |
120 |
39 |
for (int[] shift : fromShifts) |
121 |
|
{ |
122 |
59 |
hashCode = 31 * hashCode + shift[0]; |
123 |
59 |
hashCode = 31 * hashCode + shift[1]; |
124 |
|
} |
125 |
39 |
for (int[] shift : toShifts) |
126 |
|
{ |
127 |
39 |
hashCode = 31 * hashCode + shift[0]; |
128 |
39 |
hashCode = 31 * hashCode + shift[1]; |
129 |
|
} |
130 |
|
|
131 |
39 |
return hashCode; |
132 |
|
} |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
@return |
138 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
139 |
639 |
public List<int[]> getFromRanges()... |
140 |
|
{ |
141 |
639 |
return fromShifts; |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
@return |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
149 |
604 |
public List<int[]> getToRanges()... |
150 |
|
{ |
151 |
604 |
return toShifts; |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
@param |
159 |
|
@return |
160 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
161 |
1 |
protected static int[] getRanges(List<int[]> shifts)... |
162 |
|
{ |
163 |
1 |
int[] rnges = new int[2 * shifts.size()]; |
164 |
1 |
int i = 0; |
165 |
1 |
for (int[] r : shifts) |
166 |
|
{ |
167 |
2 |
rnges[i++] = r[0]; |
168 |
2 |
rnges[i++] = r[1]; |
169 |
|
} |
170 |
1 |
return rnges; |
171 |
|
} |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
@return |
176 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
177 |
22137 |
public int getFromRatio()... |
178 |
|
{ |
179 |
22137 |
return fromRatio; |
180 |
|
} |
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
@return |
185 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
186 |
451 |
public int getToRatio()... |
187 |
|
{ |
188 |
451 |
return toRatio; |
189 |
|
} |
190 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
191 |
97 |
public int getFromLowest()... |
192 |
|
{ |
193 |
97 |
return fromLowest; |
194 |
|
} |
195 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
196 |
98 |
public int getFromHighest()... |
197 |
|
{ |
198 |
98 |
return fromHighest; |
199 |
|
} |
200 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
201 |
28 |
public int getToLowest()... |
202 |
|
{ |
203 |
28 |
return toLowest; |
204 |
|
} |
205 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
206 |
3738 |
public int getToHighest()... |
207 |
|
{ |
208 |
3738 |
return toHighest; |
209 |
|
} |
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
@param |
216 |
|
|
217 |
|
@param |
218 |
|
|
219 |
|
@param |
220 |
|
|
221 |
|
@param |
222 |
|
|
223 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 3 |
Complexity Density: 0.2 |
|
224 |
1021 |
public MapList(int from[], int to[], int fromRatio, int toRatio)... |
225 |
|
{ |
226 |
1021 |
this(); |
227 |
1021 |
this.fromRatio = fromRatio; |
228 |
1021 |
this.toRatio = toRatio; |
229 |
1021 |
fromLowest = Integer.MAX_VALUE; |
230 |
1021 |
fromHighest = Integer.MIN_VALUE; |
231 |
|
|
232 |
2276 |
for (int i = 0; i < from.length; i += 2) |
233 |
|
{ |
234 |
|
|
235 |
|
|
236 |
|
|
237 |
|
|
238 |
1256 |
fromLowest = Math.min(fromLowest, Math.min(from[i], from[i + 1])); |
239 |
1256 |
fromHighest = Math.max(fromHighest, Math.max(from[i], from[i + 1])); |
240 |
1256 |
fromShifts.add(new int[] { from[i], from[i + 1] }); |
241 |
|
} |
242 |
|
|
243 |
1020 |
toLowest = Integer.MAX_VALUE; |
244 |
1020 |
toHighest = Integer.MIN_VALUE; |
245 |
2351 |
for (int i = 0; i < to.length; i += 2) |
246 |
|
{ |
247 |
1332 |
toLowest = Math.min(toLowest, Math.min(to[i], to[i + 1])); |
248 |
1332 |
toHighest = Math.max(toHighest, Math.max(to[i], to[i + 1])); |
249 |
1332 |
toShifts.add(new int[] { to[i], to[i + 1] }); |
250 |
|
} |
251 |
|
} |
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
@param |
257 |
|
|
|
|
| 88.2% |
Uncovered Elements: 2 (17) |
Complexity: 3 |
Complexity Density: 0.23 |
|
258 |
23 |
public MapList(MapList map)... |
259 |
|
{ |
260 |
23 |
this(); |
261 |
|
|
262 |
23 |
this.fromLowest = map.fromLowest; |
263 |
23 |
this.fromHighest = map.fromHighest; |
264 |
23 |
this.toLowest = map.toLowest; |
265 |
23 |
this.toHighest = map.toHighest; |
266 |
|
|
267 |
23 |
this.fromRatio = map.fromRatio; |
268 |
23 |
this.toRatio = map.toRatio; |
269 |
23 |
if (map.fromShifts != null) |
270 |
|
{ |
271 |
23 |
for (int[] r : map.fromShifts) |
272 |
|
{ |
273 |
35 |
fromShifts.add(new int[] { r[0], r[1] }); |
274 |
|
} |
275 |
|
} |
276 |
23 |
if (map.toShifts != null) |
277 |
|
{ |
278 |
23 |
for (int[] r : map.toShifts) |
279 |
|
{ |
280 |
28 |
toShifts.add(new int[] { r[0], r[1] }); |
281 |
|
} |
282 |
|
} |
283 |
|
} |
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
@param |
290 |
|
@param |
291 |
|
@param |
292 |
|
@param |
293 |
|
|
|
|
| 84% |
Uncovered Elements: 4 (25) |
Complexity: 3 |
Complexity Density: 0.14 |
|
294 |
196 |
public MapList(List<int[]> fromRange, List<int[]> toRange, int fromRatio,... |
295 |
|
int toRatio) |
296 |
|
{ |
297 |
196 |
this(); |
298 |
196 |
fromRange = coalesceRanges(fromRange); |
299 |
196 |
toRange = coalesceRanges(toRange); |
300 |
196 |
this.fromShifts = fromRange; |
301 |
196 |
this.toShifts = toRange; |
302 |
196 |
this.fromRatio = fromRatio; |
303 |
196 |
this.toRatio = toRatio; |
304 |
|
|
305 |
196 |
fromLowest = Integer.MAX_VALUE; |
306 |
196 |
fromHighest = Integer.MIN_VALUE; |
307 |
196 |
for (int[] range : fromRange) |
308 |
|
{ |
309 |
241 |
if (range.length != 2) |
310 |
|
{ |
311 |
|
|
312 |
0 |
Console.error("Invalid format for fromRange " |
313 |
|
+ Arrays.toString(range) + " may cause errors"); |
314 |
|
} |
315 |
241 |
fromLowest = Math.min(fromLowest, Math.min(range[0], range[1])); |
316 |
241 |
fromHighest = Math.max(fromHighest, Math.max(range[0], range[1])); |
317 |
|
} |
318 |
|
|
319 |
196 |
toLowest = Integer.MAX_VALUE; |
320 |
196 |
toHighest = Integer.MIN_VALUE; |
321 |
196 |
for (int[] range : toRange) |
322 |
|
{ |
323 |
348 |
if (range.length != 2) |
324 |
|
{ |
325 |
|
|
326 |
0 |
Console.error("Invalid format for toRange " + Arrays.toString(range) |
327 |
|
+ " may cause errors"); |
328 |
|
} |
329 |
348 |
toLowest = Math.min(toLowest, Math.min(range[0], range[1])); |
330 |
348 |
toHighest = Math.max(toHighest, Math.max(range[0], range[1])); |
331 |
|
} |
332 |
|
} |
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
|
|
342 |
|
|
343 |
|
|
344 |
|
|
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
|
349 |
|
@param |
350 |
|
@return |
351 |
|
|
352 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (37) |
Complexity: 10 |
Complexity Density: 0.43 |
|
353 |
401 |
public static List<int[]> coalesceRanges(final List<int[]> ranges)... |
354 |
|
{ |
355 |
401 |
if (ranges == null || ranges.size() < 2) |
356 |
|
{ |
357 |
331 |
return ranges; |
358 |
|
} |
359 |
|
|
360 |
70 |
boolean changed = false; |
361 |
70 |
List<int[]> merged = new ArrayList<>(); |
362 |
70 |
int[] lastRange = ranges.get(0); |
363 |
70 |
int lastDirection = lastRange[1] >= lastRange[0] ? 1 : -1; |
364 |
70 |
lastRange = new int[] { lastRange[0], lastRange[1] }; |
365 |
70 |
merged.add(lastRange); |
366 |
70 |
boolean first = true; |
367 |
|
|
368 |
70 |
for (final int[] range : ranges) |
369 |
|
{ |
370 |
287 |
if (first) |
371 |
|
{ |
372 |
70 |
first = false; |
373 |
70 |
continue; |
374 |
|
} |
375 |
|
|
376 |
217 |
int direction = range[1] >= range[0] ? 1 : -1; |
377 |
|
|
378 |
|
|
379 |
|
|
380 |
|
|
381 |
|
|
382 |
217 |
boolean sameDirection = range[1] == range[0] |
383 |
|
|| direction == lastDirection; |
384 |
217 |
boolean extending = range[0] == lastRange[1] + lastDirection; |
385 |
217 |
if (sameDirection && extending) |
386 |
|
{ |
387 |
10 |
lastRange[1] = range[1]; |
388 |
10 |
changed = true; |
389 |
|
} |
390 |
|
else |
391 |
|
{ |
392 |
207 |
lastRange = new int[] { range[0], range[1] }; |
393 |
207 |
merged.add(lastRange); |
394 |
|
|
395 |
207 |
lastDirection = (range[1] == range[0]) ? lastDirection : direction; |
396 |
|
} |
397 |
|
} |
398 |
|
|
399 |
70 |
return changed ? merged : ranges; |
400 |
|
} |
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
|
405 |
|
@return |
406 |
|
|
407 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
408 |
0 |
protected int[][] makeFromMap()... |
409 |
|
{ |
410 |
|
|
411 |
0 |
return posMap(fromShifts, fromRatio, toShifts, toRatio); |
412 |
|
} |
413 |
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
@return |
418 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
419 |
0 |
protected int[][] makeToMap()... |
420 |
|
{ |
421 |
|
|
422 |
0 |
return posMap(toShifts, toRatio, fromShifts, fromRatio); |
423 |
|
} |
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
@param |
429 |
|
@return |
430 |
|
|
431 |
|
|
|
|
| 0% |
Uncovered Elements: 66 (66) |
Complexity: 15 |
Complexity Density: 0.39 |
|
432 |
0 |
private int[][] posMap(List<int[]> shiftTo, int sourceRatio,... |
433 |
|
List<int[]> shiftFrom, int targetRatio) |
434 |
|
{ |
435 |
|
|
436 |
0 |
int iv = 0, ivSize = shiftTo.size(); |
437 |
0 |
if (iv >= ivSize) |
438 |
|
{ |
439 |
0 |
return null; |
440 |
|
} |
441 |
0 |
int[] intv = shiftTo.get(iv++); |
442 |
0 |
int from = intv[0], to = intv[1]; |
443 |
0 |
if (from > to) |
444 |
|
{ |
445 |
0 |
from = intv[1]; |
446 |
0 |
to = intv[0]; |
447 |
|
} |
448 |
0 |
while (iv < ivSize) |
449 |
|
{ |
450 |
0 |
intv = shiftTo.get(iv++); |
451 |
0 |
if (intv[0] < from) |
452 |
|
{ |
453 |
0 |
from = intv[0]; |
454 |
|
} |
455 |
0 |
if (intv[1] < from) |
456 |
|
{ |
457 |
0 |
from = intv[1]; |
458 |
|
} |
459 |
0 |
if (intv[0] > to) |
460 |
|
{ |
461 |
0 |
to = intv[0]; |
462 |
|
} |
463 |
0 |
if (intv[1] > to) |
464 |
|
{ |
465 |
0 |
to = intv[1]; |
466 |
|
} |
467 |
|
} |
468 |
0 |
int tF = 0, tT = 0; |
469 |
0 |
int mp[][] = new int[to - from + 2][]; |
470 |
0 |
for (int i = 0; i < mp.length; i++) |
471 |
|
{ |
472 |
0 |
int[] m = shift(i + from, shiftTo, sourceRatio, shiftFrom, |
473 |
|
targetRatio); |
474 |
0 |
if (m != null) |
475 |
|
{ |
476 |
0 |
if (i == 0) |
477 |
|
{ |
478 |
0 |
tF = tT = m[0]; |
479 |
|
} |
480 |
|
else |
481 |
|
{ |
482 |
0 |
if (m[0] < tF) |
483 |
|
{ |
484 |
0 |
tF = m[0]; |
485 |
|
} |
486 |
0 |
if (m[0] > tT) |
487 |
|
{ |
488 |
0 |
tT = m[0]; |
489 |
|
} |
490 |
|
} |
491 |
|
} |
492 |
0 |
mp[i] = m; |
493 |
|
} |
494 |
0 |
int[][] map = new int[][] { new int[] { from, to, tF, tT }, |
495 |
|
new int[to - from + 2] }; |
496 |
|
|
497 |
0 |
map[0][2] = tF; |
498 |
0 |
map[0][3] = tT; |
499 |
|
|
500 |
0 |
for (int i = 0; i < mp.length; i++) |
501 |
|
{ |
502 |
0 |
if (mp[i] != null) |
503 |
|
{ |
504 |
0 |
map[1][i] = mp[i][0] - tF; |
505 |
|
} |
506 |
|
else |
507 |
|
{ |
508 |
0 |
map[1][i] = -1; |
509 |
|
} |
510 |
|
} |
511 |
0 |
return map; |
512 |
|
} |
513 |
|
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
|
@param |
518 |
|
|
519 |
|
@param |
520 |
|
|
521 |
|
|
522 |
|
|
523 |
|
|
524 |
|
|
525 |
|
|
526 |
|
|
527 |
|
|
528 |
|
|
529 |
|
|
530 |
|
|
531 |
|
|
532 |
|
@param |
533 |
|
|
534 |
|
@return |
535 |
|
|
536 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
537 |
9 |
public int[] shiftFrom(int pos)... |
538 |
|
{ |
539 |
9 |
return shift(pos, fromShifts, fromRatio, toShifts, toRatio); |
540 |
|
} |
541 |
|
|
542 |
|
|
543 |
|
|
544 |
|
|
545 |
|
@param |
546 |
|
|
547 |
|
@return |
548 |
|
|
549 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
550 |
16516 |
public int[] shiftTo(int pos)... |
551 |
|
{ |
552 |
16516 |
return shift(pos, toShifts, toRatio, fromShifts, fromRatio); |
553 |
|
} |
554 |
|
|
555 |
|
|
556 |
|
|
557 |
|
@param |
558 |
|
@param |
559 |
|
@param |
560 |
|
@param |
561 |
|
@return |
562 |
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
563 |
16525 |
protected static int[] shift(int pos, List<int[]> shiftTo, int fromRatio,... |
564 |
|
List<int[]> shiftFrom, int toRatio) |
565 |
|
{ |
566 |
|
|
567 |
16525 |
int[] fromCount = countPositions(shiftTo, pos); |
568 |
16525 |
if (fromCount == null) |
569 |
|
{ |
570 |
20 |
return null; |
571 |
|
} |
572 |
16505 |
int fromRemainder = (fromCount[0] - 1) % fromRatio; |
573 |
16505 |
int toCount = 1 + (((fromCount[0] - 1) / fromRatio) * toRatio); |
574 |
16505 |
int[] toPos = traverseToPosition(shiftFrom, toCount); |
575 |
16505 |
if (toPos == null) |
576 |
|
{ |
577 |
0 |
return null; |
578 |
|
} |
579 |
16505 |
return new int[] { toPos[0], fromRemainder, toPos[1] }; |
580 |
|
} |
581 |
|
|
582 |
|
|
583 |
|
|
584 |
|
|
585 |
|
|
586 |
|
|
587 |
|
|
588 |
|
|
589 |
|
|
590 |
|
|
591 |
|
|
592 |
|
@param |
593 |
|
|
594 |
|
@param |
595 |
|
|
596 |
|
@return |
597 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 7 |
Complexity Density: 0.54 |
|
598 |
16545 |
protected static int[] countPositions(List<int[]> intervals, int pos)... |
599 |
|
{ |
600 |
16545 |
int count = 0; |
601 |
16545 |
int iv = 0; |
602 |
16545 |
int ivSize = intervals.size(); |
603 |
|
|
604 |
16671 |
while (iv < ivSize) |
605 |
|
{ |
606 |
16646 |
int[] intv = intervals.get(iv++); |
607 |
16646 |
if (intv[0] <= intv[1]) |
608 |
|
{ |
609 |
|
|
610 |
|
|
611 |
|
|
612 |
16635 |
if (pos >= intv[0] && pos <= intv[1]) |
613 |
|
{ |
614 |
16514 |
return new int[] { count + pos - intv[0] + 1, +1 }; |
615 |
|
} |
616 |
|
else |
617 |
|
{ |
618 |
121 |
count += intv[1] - intv[0] + 1; |
619 |
|
} |
620 |
|
} |
621 |
|
else |
622 |
|
{ |
623 |
|
|
624 |
|
|
625 |
|
|
626 |
11 |
if (pos >= intv[1] && pos <= intv[0]) |
627 |
|
{ |
628 |
5 |
return new int[] { count + intv[0] - pos + 1, -1 }; |
629 |
|
} |
630 |
|
else |
631 |
|
{ |
632 |
6 |
count += intv[0] - intv[1] + 1; |
633 |
|
} |
634 |
|
} |
635 |
|
} |
636 |
25 |
return null; |
637 |
|
} |
638 |
|
|
639 |
|
|
640 |
|
|
641 |
|
|
642 |
|
|
643 |
|
|
644 |
|
|
645 |
|
|
646 |
|
|
647 |
|
|
648 |
|
|
649 |
|
@param |
650 |
|
|
651 |
|
@param |
652 |
|
|
653 |
|
@return |
654 |
|
|
|
|
| 69.2% |
Uncovered Elements: 8 (26) |
Complexity: 6 |
Complexity Density: 0.38 |
|
655 |
16507 |
protected static int[] traverseToPosition(List<int[]> intervals,... |
656 |
|
final int count) |
657 |
|
{ |
658 |
16507 |
int traversed = 0; |
659 |
16507 |
int ivSize = intervals.size(); |
660 |
16507 |
int iv = 0; |
661 |
|
|
662 |
16507 |
if (count < 1) |
663 |
|
{ |
664 |
2 |
return null; |
665 |
|
} |
666 |
|
|
667 |
16588 |
while (iv < ivSize) |
668 |
|
{ |
669 |
16588 |
int[] intv = intervals.get(iv++); |
670 |
16588 |
int diff = intv[1] - intv[0]; |
671 |
16588 |
if (diff >= 0) |
672 |
|
{ |
673 |
16588 |
if (count <= traversed + 1 + diff) |
674 |
|
{ |
675 |
16505 |
return new int[] { intv[0] + (count - traversed - 1), +1 }; |
676 |
|
} |
677 |
|
else |
678 |
|
{ |
679 |
83 |
traversed += 1 + diff; |
680 |
|
} |
681 |
|
} |
682 |
|
else |
683 |
|
{ |
684 |
0 |
if (count <= traversed + 1 - diff) |
685 |
|
{ |
686 |
0 |
return new int[] { intv[0] - (count - traversed - 1), -1 }; |
687 |
|
} |
688 |
|
else |
689 |
|
{ |
690 |
0 |
traversed += 1 - diff; |
691 |
|
} |
692 |
|
} |
693 |
|
} |
694 |
0 |
return null; |
695 |
|
} |
696 |
|
|
697 |
|
|
698 |
|
|
699 |
|
|
700 |
|
|
701 |
|
@param |
702 |
|
@param |
703 |
|
@param |
704 |
|
@param |
705 |
|
@return |
706 |
|
|
707 |
|
|
|
|
| 0% |
Uncovered Elements: 129 (129) |
Complexity: 37 |
Complexity Density: 0.47 |
|
708 |
0 |
protected static int[] getIntervals(List<int[]> shiftFrom,... |
709 |
|
int[] fromStart, int[] fromEnd, int fromRatio2) |
710 |
|
{ |
711 |
0 |
if (fromStart == null || fromEnd == null) |
712 |
|
{ |
713 |
0 |
return null; |
714 |
|
} |
715 |
0 |
int startpos, endpos; |
716 |
0 |
startpos = fromStart[0]; |
717 |
0 |
endpos = fromEnd[0]; |
718 |
0 |
int endindx = (fromRatio2 - 1); |
719 |
|
|
720 |
0 |
int intv = 0, intvSize = shiftFrom.size(); |
721 |
0 |
int iv[], i = 0, fs = -1, fe_s = -1, fe = -1; |
722 |
|
|
723 |
|
|
724 |
0 |
while (intv < intvSize && (fs == -1 || fe == -1)) |
725 |
|
{ |
726 |
0 |
iv = shiftFrom.get(intv++); |
727 |
0 |
if (fe_s > -1) |
728 |
|
{ |
729 |
0 |
endpos = iv[0]; |
730 |
0 |
endindx--; |
731 |
|
} |
732 |
0 |
if (iv[0] <= iv[1]) |
733 |
|
{ |
734 |
0 |
if (fs == -1 && startpos >= iv[0] && startpos <= iv[1]) |
735 |
|
{ |
736 |
0 |
fs = i; |
737 |
|
} |
738 |
0 |
if (endpos >= iv[0] && endpos <= iv[1]) |
739 |
|
{ |
740 |
0 |
if (fe_s == -1) |
741 |
|
{ |
742 |
0 |
fe_s = i; |
743 |
|
} |
744 |
0 |
if (fe_s != -1) |
745 |
|
{ |
746 |
0 |
if (endpos + endindx <= iv[1]) |
747 |
|
{ |
748 |
0 |
fe = i; |
749 |
0 |
endpos = endpos + endindx; |
750 |
|
|
751 |
|
} |
752 |
|
else |
753 |
|
{ |
754 |
0 |
endindx -= iv[1] - endpos; |
755 |
|
} |
756 |
|
} |
757 |
|
} |
758 |
|
} |
759 |
|
else |
760 |
|
{ |
761 |
0 |
if (fs == -1 && startpos <= iv[0] && startpos >= iv[1]) |
762 |
|
{ |
763 |
0 |
fs = i; |
764 |
|
} |
765 |
0 |
if (endpos <= iv[0] && endpos >= iv[1]) |
766 |
|
{ |
767 |
0 |
if (fe_s == -1) |
768 |
|
{ |
769 |
0 |
fe_s = i; |
770 |
|
} |
771 |
0 |
if (fe_s != -1) |
772 |
|
{ |
773 |
0 |
if (endpos - endindx >= iv[1]) |
774 |
|
{ |
775 |
0 |
fe = i; |
776 |
0 |
endpos = endpos - endindx; |
777 |
|
|
778 |
|
} |
779 |
|
else |
780 |
|
{ |
781 |
0 |
endindx -= endpos - iv[1]; |
782 |
|
} |
783 |
|
} |
784 |
|
} |
785 |
|
} |
786 |
0 |
i++; |
787 |
|
} |
788 |
0 |
if (fs == fe && fe == -1) |
789 |
|
{ |
790 |
0 |
return null; |
791 |
|
} |
792 |
0 |
List<int[]> ranges = new ArrayList<>(); |
793 |
0 |
if (fs <= fe) |
794 |
|
{ |
795 |
0 |
intv = fs; |
796 |
0 |
i = fs; |
797 |
|
|
798 |
0 |
iv = shiftFrom.get(intv++); |
799 |
0 |
iv = new int[] { iv[0], iv[1] }; |
800 |
0 |
if (i == fs) |
801 |
|
{ |
802 |
0 |
iv[0] = startpos; |
803 |
|
} |
804 |
0 |
while (i != fe) |
805 |
|
{ |
806 |
0 |
ranges.add(iv); |
807 |
0 |
iv = shiftFrom.get(intv++); |
808 |
0 |
iv = new int[] { iv[0], iv[1] }; |
809 |
0 |
i++; |
810 |
|
} |
811 |
0 |
if (i == fe) |
812 |
|
{ |
813 |
0 |
iv[1] = endpos; |
814 |
|
} |
815 |
0 |
ranges.add(iv); |
816 |
|
} |
817 |
|
else |
818 |
|
{ |
819 |
|
|
820 |
0 |
i = shiftFrom.size() - 1; |
821 |
0 |
while (i > fs) |
822 |
|
{ |
823 |
0 |
i--; |
824 |
|
} |
825 |
0 |
iv = shiftFrom.get(i); |
826 |
0 |
iv = new int[] { iv[1], iv[0] }; |
827 |
|
|
828 |
0 |
if (i == fs) |
829 |
|
{ |
830 |
0 |
iv[0] = startpos; |
831 |
|
} |
832 |
0 |
while (--i != fe) |
833 |
|
{ |
834 |
0 |
ranges.add(iv); |
835 |
0 |
iv = shiftFrom.get(i); |
836 |
0 |
iv = new int[] { iv[1], iv[0] }; |
837 |
|
} |
838 |
0 |
if (i == fe) |
839 |
|
{ |
840 |
|
|
841 |
0 |
iv[1] = endpos; |
842 |
|
} |
843 |
0 |
ranges.add(iv); |
844 |
|
} |
845 |
|
|
846 |
0 |
int[] range = null; |
847 |
0 |
if (ranges != null && ranges.size() > 0) |
848 |
|
{ |
849 |
0 |
range = new int[ranges.size() * 2]; |
850 |
0 |
intv = 0; |
851 |
0 |
intvSize = ranges.size(); |
852 |
0 |
i = 0; |
853 |
0 |
while (intv < intvSize) |
854 |
|
{ |
855 |
0 |
iv = ranges.get(intv); |
856 |
0 |
range[i++] = iv[0]; |
857 |
0 |
range[i++] = iv[1]; |
858 |
0 |
ranges.set(intv++, null); |
859 |
|
} |
860 |
|
} |
861 |
0 |
return range; |
862 |
|
} |
863 |
|
|
864 |
|
|
865 |
|
|
866 |
|
|
867 |
|
@param |
868 |
|
|
869 |
|
@return |
870 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
871 |
3 |
public int getToPosition(int mpos)... |
872 |
|
{ |
873 |
3 |
int[] mp = shiftTo(mpos); |
874 |
3 |
if (mp != null) |
875 |
|
{ |
876 |
3 |
return mp[0]; |
877 |
|
} |
878 |
0 |
return mpos; |
879 |
|
} |
880 |
|
|
881 |
|
|
882 |
|
|
883 |
|
@return |
884 |
|
|
885 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
886 |
70 |
public MapList getInverse()... |
887 |
|
{ |
888 |
70 |
return new MapList(getToRanges(), getFromRanges(), getToRatio(), |
889 |
|
getFromRatio()); |
890 |
|
} |
891 |
|
|
892 |
|
|
893 |
|
|
894 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
|
895 |
12 |
@Override... |
896 |
|
public String toString() |
897 |
|
{ |
898 |
12 |
StringBuilder sb = new StringBuilder(64); |
899 |
12 |
sb.append("["); |
900 |
12 |
for (int[] shift : fromShifts) |
901 |
|
{ |
902 |
26 |
sb.append(" ").append(Arrays.toString(shift)); |
903 |
|
} |
904 |
12 |
sb.append(" ] "); |
905 |
12 |
sb.append(fromRatio).append(":").append(toRatio); |
906 |
12 |
sb.append(" to ["); |
907 |
12 |
for (int[] shift : toShifts) |
908 |
|
{ |
909 |
17 |
sb.append(" ").append(Arrays.toString(shift)); |
910 |
|
} |
911 |
12 |
sb.append(" ]"); |
912 |
12 |
return sb.toString(); |
913 |
|
} |
914 |
|
|
915 |
|
|
916 |
|
|
917 |
|
|
918 |
|
|
919 |
|
|
920 |
|
@param |
921 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
922 |
12 |
public void addMapList(MapList map)... |
923 |
|
{ |
924 |
12 |
if (this.equals(map)) |
925 |
|
{ |
926 |
3 |
return; |
927 |
|
} |
928 |
9 |
this.fromLowest = Math.min(fromLowest, map.fromLowest); |
929 |
9 |
this.toLowest = Math.min(toLowest, map.toLowest); |
930 |
9 |
this.fromHighest = Math.max(fromHighest, map.fromHighest); |
931 |
9 |
this.toHighest = Math.max(toHighest, map.toHighest); |
932 |
|
|
933 |
9 |
for (int[] range : map.getFromRanges()) |
934 |
|
{ |
935 |
10 |
addRange(range, fromShifts); |
936 |
|
} |
937 |
9 |
for (int[] range : map.getToRanges()) |
938 |
|
{ |
939 |
11 |
addRange(range, toShifts); |
940 |
|
} |
941 |
|
} |
942 |
|
|
943 |
|
|
944 |
|
|
945 |
|
|
946 |
|
|
947 |
|
@param |
948 |
|
@param |
949 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 10 |
Complexity Density: 0.62 |
|
950 |
29 |
static void addRange(int[] range, List<int[]> addTo)... |
951 |
|
{ |
952 |
|
|
953 |
|
|
954 |
|
|
955 |
29 |
if (addTo.size() == 0) |
956 |
|
{ |
957 |
1 |
addTo.add(range); |
958 |
1 |
return; |
959 |
|
} |
960 |
|
|
961 |
28 |
int[] last = addTo.get(addTo.size() - 1); |
962 |
28 |
boolean lastForward = last[1] >= last[0]; |
963 |
28 |
boolean newForward = range[1] >= range[0]; |
964 |
|
|
965 |
|
|
966 |
|
|
967 |
|
|
968 |
28 |
if (lastForward == newForward && last[1] == range[0]) |
969 |
|
{ |
970 |
4 |
last[1] = range[1]; |
971 |
4 |
return; |
972 |
|
} |
973 |
|
|
974 |
|
|
975 |
|
|
976 |
|
|
977 |
24 |
if (lastForward && newForward && range[0] == last[1] + 1) |
978 |
|
{ |
979 |
3 |
last[1] = range[1]; |
980 |
3 |
return; |
981 |
|
} |
982 |
|
|
983 |
|
|
984 |
|
|
985 |
|
|
986 |
21 |
if (!lastForward && !newForward && range[0] == last[1] - 1) |
987 |
|
{ |
988 |
4 |
last[1] = range[1]; |
989 |
4 |
return; |
990 |
|
} |
991 |
|
|
992 |
|
|
993 |
|
|
994 |
|
|
995 |
17 |
addTo.add(range); |
996 |
|
} |
997 |
|
|
998 |
|
|
999 |
|
|
1000 |
|
|
1001 |
|
|
1002 |
|
|
1003 |
|
|
1004 |
|
@return |
1005 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1006 |
3 |
public boolean isFromForwardStrand()... |
1007 |
|
{ |
1008 |
3 |
return isForwardStrand(getFromRanges()); |
1009 |
|
} |
1010 |
|
|
1011 |
|
|
1012 |
|
|
1013 |
|
|
1014 |
|
|
1015 |
|
|
1016 |
|
|
1017 |
|
@return |
1018 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1019 |
27 |
public boolean isToForwardStrand()... |
1020 |
|
{ |
1021 |
27 |
return isForwardStrand(getToRanges()); |
1022 |
|
} |
1023 |
|
|
1024 |
|
|
1025 |
|
|
1026 |
|
|
1027 |
|
|
1028 |
|
@param |
1029 |
|
@return |
1030 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
1031 |
30 |
private boolean isForwardStrand(List<int[]> ranges)... |
1032 |
|
{ |
1033 |
30 |
boolean forwardStrand = true; |
1034 |
30 |
for (int[] range : ranges) |
1035 |
|
{ |
1036 |
38 |
if (range[1] > range[0]) |
1037 |
|
{ |
1038 |
20 |
break; |
1039 |
|
} |
1040 |
18 |
else if (range[1] < range[0]) |
1041 |
|
{ |
1042 |
8 |
forwardStrand = false; |
1043 |
8 |
break; |
1044 |
|
} |
1045 |
|
} |
1046 |
30 |
return forwardStrand; |
1047 |
|
} |
1048 |
|
|
1049 |
|
|
1050 |
|
|
1051 |
|
@return |
1052 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1053 |
94 |
public boolean isTripletMap()... |
1054 |
|
{ |
1055 |
94 |
return (toRatio == 3 && fromRatio == 1) |
1056 |
|
|| (fromRatio == 3 && toRatio == 1); |
1057 |
|
} |
1058 |
|
|
1059 |
|
|
1060 |
|
|
1061 |
|
|
1062 |
|
|
1063 |
|
|
1064 |
|
|
1065 |
|
|
1066 |
|
|
1067 |
|
|
1068 |
|
|
1069 |
|
|
1070 |
|
|
1071 |
|
|
1072 |
|
|
1073 |
|
|
1074 |
|
|
1075 |
|
|
1076 |
|
|
1077 |
|
|
1078 |
|
|
1079 |
|
@param |
1080 |
|
@return |
1081 |
|
|
|
|
| 86.2% |
Uncovered Elements: 4 (29) |
Complexity: 6 |
Complexity Density: 0.29 |
|
1082 |
19 |
public MapList traverse(MapList map)... |
1083 |
|
{ |
1084 |
19 |
if (map == null) |
1085 |
|
{ |
1086 |
0 |
return null; |
1087 |
|
} |
1088 |
|
|
1089 |
|
|
1090 |
|
|
1091 |
|
|
1092 |
|
|
1093 |
|
|
1094 |
|
|
1095 |
|
|
1096 |
|
|
1097 |
|
|
1098 |
19 |
int outFromRatio = getFromRatio() * map.getFromRatio(); |
1099 |
19 |
int outToRatio = getToRatio() * map.getToRatio(); |
1100 |
19 |
int gcd = MathUtils.gcd(outFromRatio, outToRatio); |
1101 |
19 |
outFromRatio /= gcd; |
1102 |
19 |
outToRatio /= gcd; |
1103 |
|
|
1104 |
19 |
List<int[]> toRanges = new ArrayList<>(); |
1105 |
19 |
for (int[] range : getToRanges()) |
1106 |
|
{ |
1107 |
20 |
int fromLength = Math.abs(range[1] - range[0]) + 1; |
1108 |
20 |
int[] transferred = map.locateInTo(range[0], range[1]); |
1109 |
20 |
if (transferred == null || transferred.length % 2 != 0) |
1110 |
|
{ |
1111 |
0 |
return null; |
1112 |
|
} |
1113 |
|
|
1114 |
|
|
1115 |
|
|
1116 |
|
|
1117 |
|
|
1118 |
20 |
int toLength = 0; |
1119 |
169 |
for (int i = 0; i < transferred.length;) |
1120 |
|
{ |
1121 |
149 |
toRanges.add(new int[] { transferred[i], transferred[i + 1] }); |
1122 |
149 |
toLength += Math.abs(transferred[i + 1] - transferred[i]) + 1; |
1123 |
149 |
i += 2; |
1124 |
|
} |
1125 |
|
|
1126 |
|
|
1127 |
|
|
1128 |
|
|
1129 |
20 |
if (fromLength * map.getToRatio() != toLength * map.getFromRatio()) |
1130 |
|
{ |
1131 |
1 |
return null; |
1132 |
|
} |
1133 |
|
} |
1134 |
|
|
1135 |
18 |
return new MapList(getFromRanges(), toRanges, outFromRatio, outToRatio); |
1136 |
|
} |
1137 |
|
|
1138 |
|
|
1139 |
|
|
1140 |
|
|
1141 |
|
|
1142 |
|
@return |
1143 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1144 |
0 |
public boolean isContiguous()... |
1145 |
|
{ |
1146 |
0 |
return fromShifts.size() == 1 && toShifts.size() == 1; |
1147 |
|
} |
1148 |
|
|
1149 |
|
|
1150 |
|
|
1151 |
|
|
1152 |
|
|
1153 |
|
|
1154 |
|
|
1155 |
|
|
1156 |
|
@param |
1157 |
|
@param |
1158 |
|
@return |
1159 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1160 |
168707 |
public int[] locateInFrom(int start, int end)... |
1161 |
|
{ |
1162 |
168707 |
return mapPositions(start, end, toShifts, fromShifts, toRatio, |
1163 |
|
fromRatio); |
1164 |
|
} |
1165 |
|
|
1166 |
|
|
1167 |
|
|
1168 |
|
|
1169 |
|
|
1170 |
|
|
1171 |
|
|
1172 |
|
@param |
1173 |
|
@param |
1174 |
|
@return |
1175 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1176 |
26120 |
public int[] locateInTo(int start, int end)... |
1177 |
|
{ |
1178 |
26120 |
return mapPositions(start, end, fromShifts, toShifts, fromRatio, |
1179 |
|
toRatio); |
1180 |
|
} |
1181 |
|
|
1182 |
|
|
1183 |
|
|
1184 |
|
|
1185 |
|
|
1186 |
|
|
1187 |
|
|
1188 |
|
|
1189 |
|
@param |
1190 |
|
@param |
1191 |
|
@param |
1192 |
|
@param |
1193 |
|
@param |
1194 |
|
@param |
1195 |
|
@return |
1196 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
1197 |
194824 |
final static int[] mapPositions(int start, int end,... |
1198 |
|
List<int[]> sourceRange, List<int[]> targetRange, |
1199 |
|
int sourceWordLength, int targetWordLength) |
1200 |
|
{ |
1201 |
194824 |
if (end < start) |
1202 |
|
{ |
1203 |
2 |
int tmp = end; |
1204 |
2 |
end = start; |
1205 |
2 |
start = tmp; |
1206 |
|
} |
1207 |
|
|
1208 |
|
|
1209 |
|
|
1210 |
|
|
1211 |
|
|
1212 |
194825 |
BitSet offsets = getMappedOffsetsForPositions(start, end, sourceRange, |
1213 |
|
sourceWordLength, targetWordLength); |
1214 |
|
|
1215 |
|
|
1216 |
|
|
1217 |
|
|
1218 |
194821 |
List<int[]> mapped = getPositionsForOffsets(targetRange, offsets); |
1219 |
|
|
1220 |
|
|
1221 |
194816 |
return mapped.isEmpty() ? null : MappingUtils.rangeListToArray(mapped); |
1222 |
|
} |
1223 |
|
|
1224 |
|
|
1225 |
|
|
1226 |
|
|
1227 |
|
|
1228 |
|
|
1229 |
|
|
1230 |
|
|
1231 |
|
|
1232 |
|
|
1233 |
|
|
1234 |
|
|
1235 |
|
|
1236 |
|
|
1237 |
|
|
1238 |
|
|
1239 |
|
|
1240 |
|
|
1241 |
|
|
1242 |
|
|
1243 |
|
|
1244 |
|
|
1245 |
|
|
1246 |
|
|
1247 |
|
|
1248 |
|
|
1249 |
|
@param |
1250 |
|
@param |
1251 |
|
@param |
1252 |
|
@param |
1253 |
|
@param |
1254 |
|
@return |
1255 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (41) |
Complexity: 9 |
Complexity Density: 0.31 |
|
1256 |
194830 |
protected final static BitSet getMappedOffsetsForPositions(int start,... |
1257 |
|
int end, List<int[]> sourceRange, int sourceWordLength, |
1258 |
|
int targetWordLength) |
1259 |
|
{ |
1260 |
194835 |
BitSet overlaps = new BitSet(); |
1261 |
194832 |
int offset = 0; |
1262 |
194833 |
final int s1 = sourceRange.size(); |
1263 |
389952 |
for (int i = 0; i < s1; i++) |
1264 |
|
{ |
1265 |
195115 |
int[] range = sourceRange.get(i); |
1266 |
195115 |
final int offset1 = offset; |
1267 |
195114 |
int overlapStartOffset = -1; |
1268 |
195114 |
int overlapEndOffset = -1; |
1269 |
|
|
1270 |
195113 |
if (range[1] >= range[0]) |
1271 |
|
{ |
1272 |
|
|
1273 |
|
|
1274 |
|
|
1275 |
195001 |
if (start <= range[1] && end >= range[0]) |
1276 |
|
{ |
1277 |
|
|
1278 |
|
|
1279 |
|
|
1280 |
181337 |
int overlapStart = Math.max(start, range[0]); |
1281 |
181337 |
overlapStartOffset = offset1 + overlapStart - range[0]; |
1282 |
181337 |
int overlapEnd = Math.min(end, range[1]); |
1283 |
181334 |
overlapEndOffset = offset1 + overlapEnd - range[0]; |
1284 |
|
} |
1285 |
|
} |
1286 |
|
else |
1287 |
|
{ |
1288 |
|
|
1289 |
|
|
1290 |
|
|
1291 |
114 |
if (start <= range[0] && end >= range[1]) |
1292 |
|
{ |
1293 |
|
|
1294 |
|
|
1295 |
|
|
1296 |
29 |
int overlapStart = Math.max(start, range[1]); |
1297 |
29 |
int overlapEnd = Math.min(end, range[0]); |
1298 |
29 |
overlapStartOffset = offset1 + range[0] - overlapEnd; |
1299 |
29 |
overlapEndOffset = offset1 + range[0] - overlapStart; |
1300 |
|
} |
1301 |
|
} |
1302 |
|
|
1303 |
195114 |
if (overlapStartOffset > -1) |
1304 |
|
{ |
1305 |
|
|
1306 |
|
|
1307 |
|
|
1308 |
181365 |
if (sourceWordLength != targetWordLength) |
1309 |
|
{ |
1310 |
|
|
1311 |
|
|
1312 |
|
|
1313 |
|
|
1314 |
21656 |
overlapStartOffset -= overlapStartOffset % sourceWordLength; |
1315 |
21656 |
overlapStartOffset = overlapStartOffset / sourceWordLength |
1316 |
|
* targetWordLength; |
1317 |
|
|
1318 |
|
|
1319 |
|
|
1320 |
|
|
1321 |
|
|
1322 |
21656 |
overlapEndOffset -= overlapEndOffset % sourceWordLength; |
1323 |
21656 |
overlapEndOffset = overlapEndOffset / sourceWordLength |
1324 |
|
* targetWordLength; |
1325 |
21656 |
overlapEndOffset += targetWordLength - 1; |
1326 |
|
} |
1327 |
181364 |
overlaps.set(overlapStartOffset, overlapEndOffset + 1); |
1328 |
|
} |
1329 |
195118 |
offset += 1 + Math.abs(range[1] - range[0]); |
1330 |
|
} |
1331 |
194835 |
return overlaps; |
1332 |
|
} |
1333 |
|
|
1334 |
|
|
1335 |
|
|
1336 |
|
|
1337 |
|
|
1338 |
|
|
1339 |
|
@param |
1340 |
|
@param |
1341 |
|
@return |
1342 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 4 |
Complexity Density: 0.33 |
|
1343 |
194825 |
protected final static List<int[]> getPositionsForOffsets(... |
1344 |
|
List<int[]> targetRange, BitSet offsets) |
1345 |
|
{ |
1346 |
194825 |
List<int[]> mapped = new ArrayList<>(); |
1347 |
194832 |
if (offsets.isEmpty()) |
1348 |
|
{ |
1349 |
13501 |
return mapped; |
1350 |
|
} |
1351 |
|
|
1352 |
|
|
1353 |
|
|
1354 |
|
|
1355 |
181331 |
int traversed = 0; |
1356 |
|
|
1357 |
|
|
1358 |
|
|
1359 |
|
|
1360 |
|
|
1361 |
|
|
1362 |
181331 |
final int toAdd = offsets.cardinality(); |
1363 |
181324 |
int added = 0; |
1364 |
181325 |
final int s2 = targetRange.size(); |
1365 |
362906 |
for (int i = 0; added < toAdd && i < s2; i++) |
1366 |
|
{ |
1367 |
181576 |
int[] range = targetRange.get(i); |
1368 |
181573 |
added += addOffsetPositions(mapped, traversed, range, offsets); |
1369 |
181583 |
traversed += Math.abs(range[1] - range[0]) + 1; |
1370 |
|
} |
1371 |
181327 |
return mapped; |
1372 |
|
} |
1373 |
|
|
1374 |
|
|
1375 |
|
|
1376 |
|
|
1377 |
|
|
1378 |
|
|
1379 |
|
|
1380 |
|
@param |
1381 |
|
@param |
1382 |
|
@param |
1383 |
|
@param |
1384 |
|
@return |
1385 |
|
|
|
|
| 96% |
Uncovered Elements: 1 (25) |
Complexity: 6 |
Complexity Density: 0.35 |
|
1386 |
181579 |
final static int addOffsetPositions(List<int[]> mapped,... |
1387 |
|
final int mapOffset, final int[] range, final BitSet overlaps) |
1388 |
|
{ |
1389 |
181579 |
final int rangeLength = 1 + Math.abs(range[1] - range[0]); |
1390 |
181578 |
final int step = range[1] < range[0] ? -1 : 1; |
1391 |
181576 |
int offsetStart = 0; |
1392 |
181576 |
int added = 0; |
1393 |
|
|
1394 |
363103 |
while (offsetStart < rangeLength) |
1395 |
|
{ |
1396 |
|
|
1397 |
|
|
1398 |
|
|
1399 |
|
|
1400 |
355219 |
int overlapStart = overlaps.nextSetBit(mapOffset + offsetStart); |
1401 |
355228 |
if (overlapStart == -1 || overlapStart - mapOffset >= rangeLength) |
1402 |
|
{ |
1403 |
|
|
1404 |
|
|
1405 |
|
|
1406 |
173708 |
return added; |
1407 |
|
} |
1408 |
181519 |
overlapStart -= mapOffset; |
1409 |
|
|
1410 |
|
|
1411 |
|
|
1412 |
|
|
1413 |
|
|
1414 |
|
|
1415 |
181519 |
int overlapEnd = overlaps.nextClearBit(mapOffset + overlapStart + 1); |
1416 |
181516 |
overlapEnd = (overlapEnd == -1) ? rangeLength - 1 |
1417 |
|
: Math.min(rangeLength - 1, overlapEnd - mapOffset - 1); |
1418 |
181517 |
int startPosition = range[0] + step * overlapStart; |
1419 |
181517 |
int endPosition = range[0] + step * overlapEnd; |
1420 |
181518 |
mapped.add(new int[] { startPosition, endPosition }); |
1421 |
181527 |
offsetStart = overlapEnd + 1; |
1422 |
181530 |
added += Math.abs(endPosition - startPosition) + 1; |
1423 |
|
} |
1424 |
|
|
1425 |
7885 |
return added; |
1426 |
|
} |
1427 |
|
|
1428 |
|
|
1429 |
|
|
1430 |
|
|
1431 |
|
|
1432 |
|
|
1433 |
|
@param |
1434 |
|
@param |
1435 |
|
@return |
1436 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
1437 |
7 |
public int[] getOverlapsInFrom(final int begin, final int end)... |
1438 |
|
{ |
1439 |
7 |
int[] overlaps = MappingUtils.findOverlap(toShifts, begin, end); |
1440 |
|
|
1441 |
7 |
return overlaps == null ? null : locateInFrom(overlaps[0], overlaps[1]); |
1442 |
|
} |
1443 |
|
|
1444 |
|
|
1445 |
|
|
1446 |
|
|
1447 |
|
|
1448 |
|
|
1449 |
|
@param |
1450 |
|
@param |
1451 |
|
@return |
1452 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
1453 |
15 |
public int[] getOverlapsInTo(final int begin, final int end)... |
1454 |
|
{ |
1455 |
15 |
int[] overlaps = MappingUtils.findOverlap(fromShifts, begin, end); |
1456 |
|
|
1457 |
15 |
return overlaps == null ? null : locateInTo(overlaps[0], overlaps[1]); |
1458 |
|
} |
1459 |
|
} |