1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
package ext.edu.ucsf.rbvi.strucviz2; |
34 |
|
|
35 |
|
import java.util.ArrayList; |
36 |
|
import java.util.List; |
37 |
|
import java.util.regex.Matcher; |
38 |
|
import java.util.regex.Pattern; |
39 |
|
|
40 |
|
import org.slf4j.LoggerFactory; |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
@author |
46 |
|
|
47 |
|
|
48 |
|
|
|
|
| 0% |
Uncovered Elements: 125 (125) |
Complexity: 39 |
Complexity Density: 0.53 |
|
49 |
|
public class ChimeraResidue |
50 |
|
implements ChimeraStructuralObject, Comparable<ChimeraResidue> |
51 |
|
{ |
52 |
|
|
53 |
|
|
54 |
|
public static final int SINGLE_LETTER = 0; |
55 |
|
|
56 |
|
|
57 |
|
public static final int THREE_LETTER = 1; |
58 |
|
|
59 |
|
public static final int FULL_NAME = 2; |
60 |
|
|
61 |
|
private String type; |
62 |
|
|
63 |
|
private String index; |
64 |
|
|
65 |
|
private String chainId; |
66 |
|
|
67 |
|
private int modelNumber; |
68 |
|
|
69 |
|
private int subModelNumber; |
70 |
|
|
71 |
|
protected int residueNumber; |
72 |
|
|
73 |
|
protected String insertionCode; |
74 |
|
|
75 |
|
private ChimeraModel chimeraModel; |
76 |
|
|
77 |
|
private Object userData; |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
private static int displayType = THREE_LETTER; |
83 |
|
|
84 |
|
private boolean selected = false; |
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
@param |
90 |
|
|
91 |
|
@param |
92 |
|
|
93 |
|
@param |
94 |
|
|
95 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
96 |
0 |
public ChimeraResidue(String type, String index, int modelNumber)... |
97 |
|
{ |
98 |
0 |
this(type, index, modelNumber, 0); |
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
@param |
105 |
|
|
106 |
|
@param |
107 |
|
|
108 |
|
@param |
109 |
|
|
110 |
|
@param |
111 |
|
|
112 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
113 |
0 |
public ChimeraResidue(String type, String index, int modelNumber,... |
114 |
|
int subModelNumber) |
115 |
|
{ |
116 |
0 |
this.type = type; |
117 |
0 |
this.index = index; |
118 |
0 |
this.modelNumber = modelNumber; |
119 |
0 |
this.subModelNumber = subModelNumber; |
120 |
0 |
splitInsertionCode(this.index); |
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
@param |
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 5 |
Complexity Density: 0.23 |
|
135 |
0 |
public ChimeraResidue(String chimeraInputLine)... |
136 |
|
{ |
137 |
|
|
138 |
0 |
String[] split1 = chimeraInputLine.split(":"); |
139 |
|
|
140 |
|
|
141 |
0 |
int numberOffset = split1[0].indexOf('#'); |
142 |
0 |
String model = split1[0].substring(numberOffset + 1); |
143 |
0 |
int decimalOffset = model.indexOf('.'); |
144 |
0 |
try |
145 |
|
{ |
146 |
0 |
this.subModelNumber = 0; |
147 |
0 |
if (decimalOffset > 0) |
148 |
|
{ |
149 |
0 |
this.subModelNumber = Integer |
150 |
|
.parseInt(model.substring(decimalOffset + 1)); |
151 |
0 |
this.modelNumber = Integer |
152 |
|
.parseInt(model.substring(0, decimalOffset)); |
153 |
|
} |
154 |
|
else |
155 |
|
{ |
156 |
0 |
this.modelNumber = Integer.parseInt(model); |
157 |
|
} |
158 |
|
} catch (Exception e) |
159 |
|
{ |
160 |
0 |
LoggerFactory.getLogger(ChimeraResidue.class) |
161 |
|
.error("Unexpected return from Chimera: " + model); |
162 |
0 |
this.modelNumber = -1; |
163 |
|
} |
164 |
|
|
165 |
|
|
166 |
0 |
String[] rTokens = split1[1].split(" "); |
167 |
0 |
this.type = rTokens[2]; |
168 |
|
|
169 |
0 |
String[] iTokens = rTokens[0].split("\\."); |
170 |
0 |
if (iTokens.length > 0) |
171 |
|
{ |
172 |
0 |
this.index = iTokens[0]; |
173 |
|
|
174 |
|
|
175 |
0 |
if (iTokens.length > 1) |
176 |
0 |
this.chainId = iTokens[1]; |
177 |
|
else |
178 |
0 |
this.chainId = "_"; |
179 |
|
} |
180 |
|
else |
181 |
0 |
this.index = rTokens[0]; |
182 |
|
|
183 |
0 |
splitInsertionCode(this.index); |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
@param |
190 |
|
|
191 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
192 |
0 |
public void setSelected(boolean selected)... |
193 |
|
{ |
194 |
0 |
this.selected = selected; |
195 |
|
} |
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
@return |
201 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
202 |
0 |
public boolean isSelected()... |
203 |
|
{ |
204 |
0 |
return selected; |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
@return |
212 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
213 |
0 |
public List<ChimeraStructuralObject> getChildren()... |
214 |
|
{ |
215 |
0 |
List<ChimeraStructuralObject> v = new ArrayList<ChimeraStructuralObject>(); |
216 |
0 |
v.add(this); |
217 |
0 |
return v; |
218 |
|
} |
219 |
|
|
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
@return |
227 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
228 |
0 |
public String displayName()... |
229 |
|
{ |
230 |
0 |
return toString(); |
231 |
|
} |
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
@return |
240 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
241 |
0 |
public String toString()... |
242 |
|
{ |
243 |
0 |
if (displayType == FULL_NAME) |
244 |
|
{ |
245 |
0 |
return (ChimUtils.toFullName(type) + " " + index); |
246 |
|
} |
247 |
0 |
else if (displayType == SINGLE_LETTER) |
248 |
|
{ |
249 |
0 |
return (ChimUtils.toSingleLetter(type) + " " + index); |
250 |
|
} |
251 |
0 |
else if (displayType == THREE_LETTER) |
252 |
|
{ |
253 |
0 |
return (ChimUtils.toThreeLetter(type) + " " + index); |
254 |
|
} |
255 |
|
else |
256 |
|
{ |
257 |
0 |
return (type + " " + index); |
258 |
|
} |
259 |
|
} |
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
@return |
265 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
266 |
0 |
public String toSpec()... |
267 |
|
{ |
268 |
0 |
if (!chainId.equals("_")) |
269 |
0 |
return ("#" + modelNumber + ":" + index + "." + chainId); |
270 |
|
else |
271 |
0 |
return ("#" + modelNumber + ":" + index + "."); |
272 |
|
} |
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
@return |
278 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
279 |
0 |
public String getIndex()... |
280 |
|
{ |
281 |
0 |
return this.index; |
282 |
|
} |
283 |
|
|
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
@return |
288 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
289 |
0 |
public String getChainId()... |
290 |
|
{ |
291 |
0 |
return this.chainId; |
292 |
|
} |
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
@return |
298 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
299 |
0 |
public String getType()... |
300 |
|
{ |
301 |
0 |
return this.type; |
302 |
|
} |
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
@return |
308 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
309 |
0 |
public int getModelNumber()... |
310 |
|
{ |
311 |
0 |
return this.modelNumber; |
312 |
|
} |
313 |
|
|
314 |
|
|
315 |
|
|
316 |
|
|
317 |
|
@return |
318 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
319 |
0 |
public int getSubModelNumber()... |
320 |
|
{ |
321 |
0 |
return this.subModelNumber; |
322 |
|
} |
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
|
@return |
328 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
329 |
0 |
public ChimeraModel getChimeraModel()... |
330 |
|
{ |
331 |
0 |
return this.chimeraModel; |
332 |
|
} |
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
337 |
|
@param |
338 |
|
|
339 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
340 |
0 |
public void setChimeraModel(ChimeraModel chimeraModel)... |
341 |
|
{ |
342 |
0 |
this.chimeraModel = chimeraModel; |
343 |
|
} |
344 |
|
|
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
@return |
349 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
350 |
0 |
public Object getUserData()... |
351 |
|
{ |
352 |
0 |
return userData; |
353 |
|
} |
354 |
|
|
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
@param |
359 |
|
|
360 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
361 |
0 |
public void setUserData(Object data)... |
362 |
|
{ |
363 |
0 |
this.userData = data; |
364 |
|
} |
365 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 7 |
Complexity Density: 0.64 |
|
366 |
0 |
public int compareTo(ChimeraResidue c2)... |
367 |
|
{ |
368 |
0 |
if (residueNumber < c2.residueNumber) |
369 |
0 |
return -1; |
370 |
0 |
else if (residueNumber == c2.residueNumber) |
371 |
|
{ |
372 |
0 |
if (insertionCode == null && c2.insertionCode == null) |
373 |
0 |
return 0; |
374 |
0 |
else if (insertionCode == null) |
375 |
0 |
return -1; |
376 |
0 |
else if (c2.insertionCode == null) |
377 |
0 |
return 1; |
378 |
0 |
return (insertionCode.compareTo(c2.insertionCode)); |
379 |
|
} |
380 |
0 |
return 1; |
381 |
|
} |
382 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
383 |
0 |
public void splitInsertionCode(String residue)... |
384 |
|
{ |
385 |
|
|
386 |
|
|
387 |
|
|
388 |
0 |
Pattern p = Pattern.compile("(\\d*)([A-Z]?)"); |
389 |
0 |
Matcher m = p.matcher(residue); |
390 |
0 |
if (m.matches()) |
391 |
|
{ |
392 |
0 |
this.residueNumber = Integer.parseInt(m.group(1)); |
393 |
0 |
if (m.groupCount() > 1) |
394 |
0 |
this.insertionCode = m.group(2); |
395 |
|
else |
396 |
0 |
this.insertionCode = null; |
397 |
|
} |
398 |
|
} |
399 |
|
|
400 |
|
|
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
|
423 |
|
|
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
|
|
440 |
|
|
441 |
|
@param |
442 |
|
|
443 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
444 |
0 |
public static void setDisplayType(int type)... |
445 |
|
{ |
446 |
0 |
displayType = type; |
447 |
|
} |
448 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
449 |
0 |
public static int getDisplayType()... |
450 |
|
{ |
451 |
0 |
return displayType; |
452 |
|
} |
453 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
454 |
0 |
public boolean hasSelectedChildren()... |
455 |
|
{ |
456 |
0 |
return false; |
457 |
|
} |
458 |
|
} |