| 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 |
|
|
| |
|
| 74.7% |
Uncovered Elements: 20 (79) |
Complexity: 26 |
Complexity Density: 0.55 |
|
| 31 |
|
public class ShiftList |
| 32 |
|
{ |
| 33 |
|
private List<int[]> shifts; |
| 34 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 35 |
40 |
public ShiftList()... |
| 36 |
|
{ |
| 37 |
40 |
shifts = new ArrayList<int[]>(); |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
@param |
| 44 |
|
|
| 45 |
|
@param |
| 46 |
|
|
| 47 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 5 |
Complexity Density: 0.62 |
|
| 48 |
36 |
public void addShift(int pos, int shift)... |
| 49 |
|
{ |
| 50 |
36 |
synchronized (shifts) |
| 51 |
|
{ |
| 52 |
36 |
int sidx = 0; |
| 53 |
36 |
int[] rshift = null; |
| 54 |
? |
while (sidx < shifts.size() && (rshift = shifts.get(sidx))[0] < pos) |
| 55 |
|
{ |
| 56 |
8 |
sidx++; |
| 57 |
|
} |
| 58 |
36 |
if (sidx == shifts.size() || pos!=rshift[0]) |
| 59 |
|
{ |
| 60 |
33 |
shifts.add(sidx, new int[] { pos, shift }); |
| 61 |
|
} |
| 62 |
|
else |
| 63 |
|
{ |
| 64 |
3 |
rshift[1] += shift; |
| 65 |
|
} |
| 66 |
|
} |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
@param |
| 73 |
|
@param |
| 74 |
|
@return |
| 75 |
|
|
| |
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 6 |
Complexity Density: 0.46 |
|
| 76 |
599 |
public boolean extendShift(int pos, int shift)... |
| 77 |
|
{ |
| 78 |
599 |
boolean modified=false; |
| 79 |
599 |
synchronized (shifts) |
| 80 |
|
{ |
| 81 |
599 |
int sidx = 0; |
| 82 |
599 |
int[] rshift = null; |
| 83 |
? |
while (sidx < shifts.size() && (rshift = shifts.get(sidx))[0] < pos) |
| 84 |
|
{ |
| 85 |
15008 |
sidx++; |
| 86 |
|
} |
| 87 |
599 |
if (sidx == shifts.size() || pos!=rshift[0]) |
| 88 |
|
{ |
| 89 |
225 |
modified=true; |
| 90 |
225 |
shifts.add(sidx, new int[] { pos, shift }); |
| 91 |
|
} |
| 92 |
|
else |
| 93 |
|
{ |
| 94 |
374 |
if (rshift[1]<shift) { |
| 95 |
12 |
modified=true; |
| 96 |
12 |
rshift[1] = shift; |
| 97 |
|
} |
| 98 |
|
} |
| 99 |
|
} |
| 100 |
599 |
return modified; |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
@param |
| 106 |
|
|
| 107 |
|
@return |
| 108 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 109 |
211 |
public int shift(int pos)... |
| 110 |
|
{ |
| 111 |
211 |
if (shifts.size() == 0) |
| 112 |
|
{ |
| 113 |
3 |
return pos; |
| 114 |
|
} |
| 115 |
208 |
int shifted = pos; |
| 116 |
208 |
int sidx = 0; |
| 117 |
208 |
int rshift[]; |
| 118 |
? |
while (sidx < shifts.size() |
| 119 |
|
&& (rshift = (shifts.get(sidx++)))[0] <= pos) |
| 120 |
|
{ |
| 121 |
212 |
shifted += rshift[1]; |
| 122 |
|
} |
| 123 |
208 |
return shifted; |
| 124 |
|
} |
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 129 |
0 |
public synchronized void clear()... |
| 130 |
|
{ |
| 131 |
0 |
shifts.clear(); |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
@return |
| 138 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 139 |
0 |
public ShiftList getInverse()... |
| 140 |
|
{ |
| 141 |
0 |
ShiftList inverse = new ShiftList(); |
| 142 |
0 |
synchronized (shifts) |
| 143 |
|
{ |
| 144 |
0 |
if (shifts != null) |
| 145 |
|
{ |
| 146 |
0 |
for (int[] sh : shifts) |
| 147 |
|
{ |
| 148 |
0 |
if (sh != null) |
| 149 |
|
{ |
| 150 |
0 |
inverse.shifts.add(new int[] { sh[0], -sh[1] }); |
| 151 |
|
} |
| 152 |
|
} |
| 153 |
|
} |
| 154 |
|
} |
| 155 |
0 |
return inverse; |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
|
| 162 |
|
@param |
| 163 |
|
@return |
| 164 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
| 165 |
3 |
public static ShiftList parseMap(int[] gapMap)... |
| 166 |
|
{ |
| 167 |
3 |
ShiftList shiftList = null; |
| 168 |
3 |
if (gapMap != null && gapMap.length > 0) |
| 169 |
|
{ |
| 170 |
1 |
shiftList = new ShiftList(); |
| 171 |
8 |
for (int i = 0, p = 0; i < gapMap.length; p++, i++) |
| 172 |
|
{ |
| 173 |
7 |
if (p != gapMap[i]) |
| 174 |
|
{ |
| 175 |
4 |
shiftList.addShift(p, gapMap[i] - p); |
| 176 |
4 |
p = gapMap[i]; |
| 177 |
|
} |
| 178 |
|
} |
| 179 |
|
} |
| 180 |
3 |
return shiftList; |
| 181 |
|
} |
| 182 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 183 |
87 |
public List<int[]> getShifts()... |
| 184 |
|
{ |
| 185 |
87 |
return shifts; |
| 186 |
|
} |
| 187 |
|
} |