| 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.List; |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| |
|
| 69.5% |
Uncovered Elements: 18 (59) |
Complexity: 19 |
Complexity Density: 0.56 |
|
| 31 |
|
public class ShiftList |
| 32 |
|
{ |
| 33 |
|
private List<int[]> shifts; |
| 34 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 35 |
30 |
public ShiftList()... |
| 36 |
|
{ |
| 37 |
30 |
shifts = new ArrayList<int[]>(); |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
@param |
| 44 |
|
|
| 45 |
|
@param |
| 46 |
|
|
| 47 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 48 |
31 |
public void addShift(int pos, int shift)... |
| 49 |
|
{ |
| 50 |
31 |
synchronized (shifts) |
| 51 |
|
{ |
| 52 |
31 |
int sidx = 0; |
| 53 |
31 |
int[] rshift = null; |
| 54 |
? |
while (sidx < shifts.size() && (rshift = shifts.get(sidx))[0] < pos) |
| 55 |
|
{ |
| 56 |
6 |
sidx++; |
| 57 |
|
} |
| 58 |
31 |
if (sidx == shifts.size()) |
| 59 |
|
{ |
| 60 |
29 |
shifts.add(sidx, new int[] { pos, shift }); |
| 61 |
|
} |
| 62 |
|
else |
| 63 |
|
{ |
| 64 |
2 |
rshift[1] += shift; |
| 65 |
|
} |
| 66 |
|
} |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
@param |
| 73 |
|
|
| 74 |
|
@return |
| 75 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 76 |
191 |
public int shift(int pos)... |
| 77 |
|
{ |
| 78 |
191 |
if (shifts.size() == 0) |
| 79 |
|
{ |
| 80 |
1 |
return pos; |
| 81 |
|
} |
| 82 |
190 |
int shifted = pos; |
| 83 |
190 |
int sidx = 0; |
| 84 |
190 |
int rshift[]; |
| 85 |
? |
while (sidx < shifts.size() |
| 86 |
|
&& (rshift = (shifts.get(sidx++)))[0] <= pos) |
| 87 |
|
{ |
| 88 |
190 |
shifted += rshift[1]; |
| 89 |
|
} |
| 90 |
190 |
return shifted; |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 96 |
0 |
public synchronized void clear()... |
| 97 |
|
{ |
| 98 |
0 |
shifts.clear(); |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
@return |
| 105 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 106 |
0 |
public ShiftList getInverse()... |
| 107 |
|
{ |
| 108 |
0 |
ShiftList inverse = new ShiftList(); |
| 109 |
0 |
synchronized (shifts) |
| 110 |
|
{ |
| 111 |
0 |
if (shifts != null) |
| 112 |
|
{ |
| 113 |
0 |
for (int[] sh : shifts) |
| 114 |
|
{ |
| 115 |
0 |
if (sh != null) |
| 116 |
|
{ |
| 117 |
0 |
inverse.shifts.add(new int[] { sh[0], -sh[1] }); |
| 118 |
|
} |
| 119 |
|
} |
| 120 |
|
} |
| 121 |
|
} |
| 122 |
0 |
return inverse; |
| 123 |
|
} |
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
@param |
| 130 |
|
@return |
| 131 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
| 132 |
3 |
public static ShiftList parseMap(int[] gapMap)... |
| 133 |
|
{ |
| 134 |
3 |
ShiftList shiftList = null; |
| 135 |
3 |
if (gapMap != null && gapMap.length > 0) |
| 136 |
|
{ |
| 137 |
1 |
shiftList = new ShiftList(); |
| 138 |
8 |
for (int i = 0, p = 0; i < gapMap.length; p++, i++) |
| 139 |
|
{ |
| 140 |
7 |
if (p != gapMap[i]) |
| 141 |
|
{ |
| 142 |
4 |
shiftList.addShift(p, gapMap[i] - p); |
| 143 |
4 |
p = gapMap[i]; |
| 144 |
|
} |
| 145 |
|
} |
| 146 |
|
} |
| 147 |
3 |
return shiftList; |
| 148 |
|
} |
| 149 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 150 |
1 |
public List<int[]> getShifts()... |
| 151 |
|
{ |
| 152 |
1 |
return shifts; |
| 153 |
|
} |
| 154 |
|
} |