1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.renderer; |
22 |
|
|
23 |
|
import java.util.Arrays; |
24 |
|
import java.util.Iterator; |
25 |
|
import java.util.List; |
26 |
|
|
27 |
|
import jalview.datamodel.ColumnSelection; |
28 |
|
import jalview.datamodel.ContactListI; |
29 |
|
import jalview.datamodel.HiddenColumns; |
30 |
|
import jalview.renderer.ContactGeometry.contactInterval; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@author |
37 |
|
|
38 |
|
|
|
|
| 68.2% |
Uncovered Elements: 28 (88) |
Complexity: 27 |
Complexity Density: 0.53 |
|
39 |
|
public class ContactGeometry |
40 |
|
{ |
41 |
|
|
42 |
|
final ContactListI contacts; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
final int pixels_step; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
final double contacts_per_pixel; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
final int contact_height; |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
final int graphHeight; |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
final double contacts_step; |
68 |
|
|
69 |
|
final int lastStep; |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
@param |
75 |
|
@param |
76 |
|
|
77 |
|
|
|
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
78 |
144738 |
public ContactGeometry(final ContactListI contacts, int graphHeight)... |
79 |
|
{ |
80 |
144738 |
this.contacts = contacts; |
81 |
144738 |
this.graphHeight = graphHeight; |
82 |
144738 |
contact_height = contacts.getContactHeight(); |
83 |
|
|
84 |
144738 |
contacts_per_pixel = (graphHeight <= 1) ? contact_height |
85 |
|
: ((double) contact_height) / ((double) graphHeight); |
86 |
|
|
87 |
144738 |
if (contacts_per_pixel >= 1) |
88 |
|
{ |
89 |
|
|
90 |
31703 |
pixels_step = 1; |
91 |
|
} |
92 |
|
else |
93 |
|
{ |
94 |
|
|
95 |
113035 |
pixels_step = (int) Math |
96 |
|
.ceil(((double) graphHeight) / (double) contact_height); |
97 |
|
} |
98 |
144738 |
contacts_step = pixels_step * contacts_per_pixel; |
99 |
144738 |
lastStep = (int) Math.min((double) graphHeight, |
100 |
|
((double) graphHeight) / ((double) pixels_step)); |
101 |
|
} |
102 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 5 |
Complexity Density: 0.56 |
|
103 |
|
public class contactInterval |
104 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
105 |
147116534 |
public contactInterval(int cStart, int cEnd, int pStart, int pEnd)... |
106 |
|
{ |
107 |
147116534 |
this.cStart = cStart; |
108 |
147116534 |
this.cEnd = cEnd; |
109 |
147116534 |
this.pStart = pStart; |
110 |
147116534 |
this.pEnd = pEnd; |
111 |
|
} |
112 |
|
|
113 |
|
|
114 |
|
public final int cStart; |
115 |
|
|
116 |
|
public final int cEnd; |
117 |
|
|
118 |
|
|
119 |
|
public final int pStart; |
120 |
|
|
121 |
|
public final int pEnd; |
122 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
123 |
174 |
@Override... |
124 |
|
public boolean equals(Object obj) |
125 |
|
{ |
126 |
174 |
if (obj == null || !(obj instanceof contactInterval)) |
127 |
|
{ |
128 |
0 |
return false; |
129 |
|
} |
130 |
174 |
contactInterval them = (contactInterval) obj; |
131 |
174 |
return cStart == them.cStart && cEnd == them.cEnd && pEnd == them.pEnd |
132 |
|
&& pStart == them.pStart; |
133 |
|
} |
134 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
4 |
@Override... |
136 |
|
public String toString() |
137 |
|
{ |
138 |
4 |
return "Contacts [" + cStart + "," + cEnd + "] : Pixels [" + pStart |
139 |
|
+ "," + pEnd + "]"; |
140 |
|
} |
141 |
|
} |
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
@param |
146 |
|
@param |
147 |
|
@param |
148 |
|
|
149 |
|
|
150 |
|
@return |
151 |
|
|
152 |
|
|
153 |
|
|
|
|
| 50% |
Uncovered Elements: 12 (24) |
Complexity: 9 |
Complexity Density: 0.64 |
|
154 |
134330 |
boolean intersects(contactInterval ci, ColumnSelection columnSelection,... |
155 |
|
HiddenColumns hiddenColumns, boolean visibleOnly) |
156 |
|
{ |
157 |
134331 |
boolean rowsel = false; |
158 |
134330 |
final int[] mappedRange = contacts.getMappedPositionsFor(ci.cStart, |
159 |
|
ci.cEnd); |
160 |
134332 |
if (mappedRange == null) |
161 |
|
{ |
162 |
0 |
return false; |
163 |
|
} |
164 |
268662 |
for (int p = 0; p < mappedRange.length && !rowsel; p += 2) |
165 |
|
{ |
166 |
134330 |
boolean containsHidden = false; |
167 |
134331 |
if (visibleOnly && hiddenColumns != null |
168 |
|
&& hiddenColumns.hasHiddenColumns()) |
169 |
|
{ |
170 |
|
|
171 |
0 |
Iterator<int[]> viscont = hiddenColumns.getVisContigsIterator( |
172 |
|
-1 + mappedRange[p], -1 + mappedRange[p + 1], false); |
173 |
0 |
containsHidden = !viscont.hasNext(); |
174 |
0 |
if (!containsHidden) |
175 |
|
{ |
176 |
0 |
for (int[] interval = viscont.next(); viscont |
177 |
|
.hasNext(); rowsel |= columnSelection |
178 |
|
.intersects(interval[p], interval[p + 1])) |
179 |
0 |
; |
180 |
|
} |
181 |
|
} |
182 |
|
else |
183 |
|
{ |
184 |
134331 |
rowsel = columnSelection.intersects(-1 + mappedRange[p], |
185 |
|
-1 + mappedRange[p + 1]); |
186 |
|
} |
187 |
|
} |
188 |
134331 |
return rowsel; |
189 |
|
|
190 |
|
} |
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
@param |
199 |
|
|
200 |
|
@param |
201 |
|
@return |
202 |
|
|
203 |
|
|
|
|
| 66.7% |
Uncovered Elements: 6 (18) |
Complexity: 5 |
Complexity Density: 0.5 |
|
204 |
84 |
public contactInterval mapFor(int pStart, int pEnd)... |
205 |
|
{ |
206 |
84 |
if (pStart < 0) |
207 |
|
{ |
208 |
0 |
pStart = 0; |
209 |
|
} |
210 |
84 |
if (pEnd < pStart) |
211 |
|
{ |
212 |
0 |
pEnd = pStart; |
213 |
|
} |
214 |
84 |
if (pEnd >= graphHeight) |
215 |
|
{ |
216 |
4 |
pEnd = graphHeight - 1; |
217 |
|
} |
218 |
84 |
if (pStart >= graphHeight) |
219 |
|
{ |
220 |
0 |
pStart = graphHeight - pixels_step; |
221 |
|
} |
222 |
84 |
int step = Math.floorDiv(pStart, pixels_step); |
223 |
84 |
return findStep(step); |
224 |
|
} |
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
@param |
229 |
|
|
230 |
|
@return |
231 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
232 |
147116534 |
contactInterval findStep(int step)... |
233 |
|
{ |
234 |
147116534 |
if (step < 0 || step > lastStep) |
235 |
|
{ |
236 |
0 |
return null; |
237 |
|
} |
238 |
147116534 |
return new contactInterval((int) Math.floor(contacts_step * step), |
239 |
|
-1 + (int) Math.min(contact_height, |
240 |
|
Math.floor(contacts_step * (step + 1))), |
241 |
|
pixels_step * step, |
242 |
|
Math.min(graphHeight, (step + 1) * pixels_step) - 1); |
243 |
|
} |
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
@param |
249 |
|
@return |
250 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
251 |
134416 |
public contactInterval mapFor(int pCentre)... |
252 |
|
{ |
253 |
134416 |
if (pCentre >= graphHeight + pixels_step) |
254 |
|
{ |
255 |
0 |
return null; |
256 |
|
} |
257 |
134416 |
int step = Math.floorDiv(pCentre, pixels_step); |
258 |
134416 |
return findStep(step); |
259 |
|
} |
260 |
|
|
|
|
| 78.6% |
Uncovered Elements: 3 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
261 |
141374 |
public List<contactInterval> allSteps()... |
262 |
|
{ |
263 |
141374 |
contactInterval[] array = new contactInterval[lastStep + 1]; |
264 |
141374 |
int csum = 0, psum = 0; |
265 |
147123408 |
for (int i = 0; i <= lastStep; i++) |
266 |
|
{ |
267 |
146982034 |
array[i] = findStep(i); |
268 |
146982034 |
csum += 1 + array[i].cEnd - array[i].cStart; |
269 |
146982034 |
psum += 1 + array[i].pEnd - array[i].pStart; |
270 |
|
} |
271 |
141374 |
if (csum != contact_height || psum != graphHeight) |
272 |
|
{ |
273 |
0 |
System.err.println("csum = " + csum + " not " + contact_height + "\n" |
274 |
|
+ "psum = " + psum + " not " + graphHeight); |
275 |
0 |
return null; |
276 |
|
} |
277 |
141374 |
return Arrays.asList(array); |
278 |
|
} |
279 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
280 |
0 |
public Iterator<contactInterval> iterateOverContactIntervals(... |
281 |
|
int graphHeight) |
282 |
|
{ |
283 |
|
|
284 |
0 |
return null; |
285 |
|
|
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
} |
312 |
|
} |