1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.structures.models; |
22 |
|
|
23 |
|
import jalview.api.AlignmentViewPanel; |
24 |
|
import jalview.api.SequenceRenderer; |
25 |
|
import jalview.api.StructureSelectionManagerProvider; |
26 |
|
import jalview.api.structures.JalviewStructureDisplayI; |
27 |
|
import jalview.datamodel.AlignmentI; |
28 |
|
import jalview.datamodel.HiddenColumns; |
29 |
|
import jalview.datamodel.PDBEntry; |
30 |
|
import jalview.datamodel.SequenceI; |
31 |
|
import jalview.io.DataSourceType; |
32 |
|
import jalview.schemes.ColourSchemeI; |
33 |
|
import jalview.structure.AtomSpec; |
34 |
|
import jalview.structure.StructureListener; |
35 |
|
import jalview.structure.StructureMapping; |
36 |
|
import jalview.structure.StructureMappingcommandSet; |
37 |
|
import jalview.structure.StructureSelectionManager; |
38 |
|
import jalview.util.Comparison; |
39 |
|
import jalview.util.MessageManager; |
40 |
|
|
41 |
|
import java.awt.Color; |
42 |
|
import java.util.ArrayList; |
43 |
|
import java.util.Arrays; |
44 |
|
import java.util.BitSet; |
45 |
|
import java.util.List; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
@author |
54 |
|
|
55 |
|
|
|
|
| 76.1% |
Uncovered Elements: 84 (352) |
Complexity: 110 |
Complexity Density: 0.53 |
|
56 |
|
public abstract class AAStructureBindingModel |
57 |
|
extends SequenceStructureBindingModel |
58 |
|
implements StructureListener, StructureSelectionManagerProvider |
59 |
|
{ |
60 |
|
|
61 |
|
private StructureSelectionManager ssm; |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
private PDBEntry[] pdbEntry; |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
private SequenceI[][] sequence; |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
private String[][] chains; |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
DataSourceType protocol = null; |
83 |
|
|
84 |
|
protected boolean colourBySequence = true; |
85 |
|
|
86 |
|
private boolean nucleotide; |
87 |
|
|
88 |
|
private boolean finishedInit = false; |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
protected String[] modelFileNames = null; |
94 |
|
|
95 |
|
public String fileLoadingError; |
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
100 |
|
protected class SuperposeData |
101 |
|
{ |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
@param |
106 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
9 |
public SuperposeData(int width)... |
108 |
|
{ |
109 |
9 |
pdbResNo = new int[width]; |
110 |
|
} |
111 |
|
|
112 |
|
public String filename; |
113 |
|
|
114 |
|
public String pdbId; |
115 |
|
|
116 |
|
public String chain = ""; |
117 |
|
|
118 |
|
public boolean isRna; |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
public int[] pdbResNo; |
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
@param |
130 |
|
@param |
131 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
132 |
0 |
public AAStructureBindingModel(StructureSelectionManager ssm,... |
133 |
|
SequenceI[][] seqs) |
134 |
|
{ |
135 |
0 |
this.ssm = ssm; |
136 |
0 |
this.sequence = seqs; |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
@param |
143 |
|
@param |
144 |
|
@param |
145 |
|
@param |
146 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
147 |
14 |
public AAStructureBindingModel(StructureSelectionManager ssm,... |
148 |
|
PDBEntry[] pdbentry, SequenceI[][] sequenceIs, |
149 |
|
DataSourceType protocol) |
150 |
|
{ |
151 |
14 |
this.ssm = ssm; |
152 |
14 |
this.sequence = sequenceIs; |
153 |
14 |
this.nucleotide = Comparison.isNucleotide(sequenceIs); |
154 |
14 |
this.pdbEntry = pdbentry; |
155 |
14 |
this.protocol = protocol; |
156 |
14 |
resolveChains(); |
157 |
|
} |
158 |
|
|
|
|
| 91.7% |
Uncovered Elements: 3 (36) |
Complexity: 11 |
Complexity Density: 0.46 |
|
159 |
14 |
private boolean resolveChains()... |
160 |
|
{ |
161 |
|
|
162 |
|
|
163 |
|
|
164 |
14 |
int chainmaps = 0; |
165 |
|
|
166 |
|
|
167 |
14 |
String[][] newchains = new String[pdbEntry.length][]; |
168 |
14 |
int pe = 0; |
169 |
14 |
for (PDBEntry pdb : pdbEntry) |
170 |
|
{ |
171 |
20 |
SequenceI[] seqsForPdb = sequence[pe]; |
172 |
20 |
if (seqsForPdb != null) |
173 |
|
{ |
174 |
20 |
newchains[pe] = new String[seqsForPdb.length]; |
175 |
20 |
int se = 0; |
176 |
20 |
for (SequenceI asq : seqsForPdb) |
177 |
|
{ |
178 |
32 |
String chain = (chains != null && chains[pe] != null) |
179 |
|
? chains[pe][se] |
180 |
|
: null; |
181 |
32 |
SequenceI sq = (asq.getDatasetSequence() == null) ? asq |
182 |
|
: asq.getDatasetSequence(); |
183 |
32 |
if (sq.getAllPDBEntries() != null) |
184 |
|
{ |
185 |
32 |
for (PDBEntry pdbentry : sq.getAllPDBEntries()) |
186 |
|
{ |
187 |
32 |
if (pdb.getFile() != null && pdbentry.getFile() != null |
188 |
|
&& pdb.getFile().equals(pdbentry.getFile())) |
189 |
|
{ |
190 |
20 |
String chaincode = pdbentry.getChainCode(); |
191 |
20 |
if (chaincode != null && chaincode.length() > 0) |
192 |
|
{ |
193 |
8 |
chain = chaincode; |
194 |
8 |
chainmaps++; |
195 |
8 |
break; |
196 |
|
} |
197 |
|
} |
198 |
|
} |
199 |
|
} |
200 |
32 |
newchains[pe][se] = chain; |
201 |
32 |
se++; |
202 |
|
} |
203 |
20 |
pe++; |
204 |
|
} |
205 |
|
} |
206 |
|
|
207 |
14 |
chains = newchains; |
208 |
14 |
return chainmaps > 0; |
209 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
210 |
117 |
public StructureSelectionManager getSsm()... |
211 |
|
{ |
212 |
117 |
return ssm; |
213 |
|
} |
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
@param |
219 |
|
@return |
220 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 3 |
Complexity Density: 3 |
|
221 |
141 |
public PDBEntry getPdbEntry(int i)... |
222 |
|
{ |
223 |
141 |
return (pdbEntry != null && pdbEntry.length > i) ? pdbEntry[i] : null; |
224 |
|
} |
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
229 |
|
@param |
230 |
|
@return |
231 |
|
|
|
|
| 66.7% |
Uncovered Elements: 3 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
232 |
1 |
public boolean hasPdbId(String pdbId)... |
233 |
|
{ |
234 |
1 |
if (pdbEntry != null) |
235 |
|
{ |
236 |
1 |
for (PDBEntry pdb : pdbEntry) |
237 |
|
{ |
238 |
1 |
if (pdb.getId().equals(pdbId)) |
239 |
|
{ |
240 |
0 |
return true; |
241 |
|
} |
242 |
|
} |
243 |
|
} |
244 |
1 |
return false; |
245 |
|
} |
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
@return |
251 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
252 |
306 |
public int getPdbCount()... |
253 |
|
{ |
254 |
306 |
return pdbEntry == null ? 0 : pdbEntry.length; |
255 |
|
} |
256 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
257 |
610 |
public SequenceI[][] getSequence()... |
258 |
|
{ |
259 |
610 |
return sequence; |
260 |
|
} |
261 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
262 |
363 |
public String[][] getChains()... |
263 |
|
{ |
264 |
363 |
return chains; |
265 |
|
} |
266 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
267 |
0 |
public DataSourceType getProtocol()... |
268 |
|
{ |
269 |
0 |
return protocol; |
270 |
|
} |
271 |
|
|
272 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
273 |
1 |
protected void setPdbentry(PDBEntry[] pdbentry)... |
274 |
|
{ |
275 |
1 |
this.pdbEntry = pdbentry; |
276 |
|
} |
277 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
278 |
1 |
protected void setSequence(SequenceI[][] sequence)... |
279 |
|
{ |
280 |
1 |
this.sequence = sequence; |
281 |
|
} |
282 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
283 |
1 |
protected void setChains(String[][] chains)... |
284 |
|
{ |
285 |
1 |
this.chains = chains; |
286 |
|
} |
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
@param |
293 |
|
|
294 |
|
@param |
295 |
|
|
296 |
|
@return |
297 |
|
|
|
|
| 66.7% |
Uncovered Elements: 7 (21) |
Complexity: 8 |
Complexity Density: 0.62 |
|
298 |
21 |
public String getViewerTitle(String viewerName, boolean verbose)... |
299 |
|
{ |
300 |
21 |
if (getSequence() == null || getSequence().length < 1 |
301 |
|
|| getPdbCount() < 1 || getSequence()[0].length < 1) |
302 |
|
{ |
303 |
0 |
return ("Jalview " + viewerName + " Window"); |
304 |
|
} |
305 |
|
|
306 |
|
|
307 |
21 |
StringBuilder title = new StringBuilder(64); |
308 |
21 |
final PDBEntry pdbe = getPdbEntry(0); |
309 |
21 |
title.append(viewerName + " view for " + getSequence()[0][0].getName() |
310 |
|
+ ":" + pdbe.getId()); |
311 |
|
|
312 |
21 |
if (verbose) |
313 |
|
{ |
314 |
21 |
String method = (String) pdbe.getProperty("method"); |
315 |
21 |
if (method != null) |
316 |
|
{ |
317 |
0 |
title.append(" Method: ").append(method); |
318 |
|
} |
319 |
21 |
String chain = (String) pdbe.getProperty("chains"); |
320 |
21 |
if (chain != null) |
321 |
|
{ |
322 |
0 |
title.append(" Chain:").append(chain); |
323 |
|
} |
324 |
|
} |
325 |
21 |
return title.toString(); |
326 |
|
} |
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
332 |
0 |
protected void releaseUIResources()... |
333 |
|
{ |
334 |
|
|
335 |
|
} |
336 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
337 |
51 |
public boolean isColourBySequence()... |
338 |
|
{ |
339 |
51 |
return colourBySequence; |
340 |
|
} |
341 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
342 |
33 |
public void setColourBySequence(boolean colourBySequence)... |
343 |
|
{ |
344 |
33 |
this.colourBySequence = colourBySequence; |
345 |
|
} |
346 |
|
|
|
|
| 75.9% |
Uncovered Elements: 14 (58) |
Complexity: 18 |
Complexity Density: 0.6 |
|
347 |
47 |
protected void addSequenceAndChain(int pe, SequenceI[] seq,... |
348 |
|
String[] tchain) |
349 |
|
{ |
350 |
47 |
if (pe < 0 || pe >= getPdbCount()) |
351 |
|
{ |
352 |
0 |
throw new Error(MessageManager.formatMessage( |
353 |
|
"error.implementation_error_no_pdbentry_from_index", |
354 |
|
new Object[] |
355 |
|
{ Integer.valueOf(pe).toString() })); |
356 |
|
} |
357 |
47 |
final String nullChain = "TheNullChain"; |
358 |
47 |
List<SequenceI> s = new ArrayList<SequenceI>(); |
359 |
47 |
List<String> c = new ArrayList<String>(); |
360 |
47 |
if (getChains() == null) |
361 |
|
{ |
362 |
0 |
setChains(new String[getPdbCount()][]); |
363 |
|
} |
364 |
47 |
if (getSequence()[pe] != null) |
365 |
|
{ |
366 |
132 |
for (int i = 0; i < getSequence()[pe].length; i++) |
367 |
|
{ |
368 |
86 |
s.add(getSequence()[pe][i]); |
369 |
86 |
if (getChains()[pe] != null) |
370 |
|
{ |
371 |
84 |
if (i < getChains()[pe].length) |
372 |
|
{ |
373 |
84 |
c.add(getChains()[pe][i]); |
374 |
|
} |
375 |
|
else |
376 |
|
{ |
377 |
0 |
c.add(nullChain); |
378 |
|
} |
379 |
|
} |
380 |
|
else |
381 |
|
{ |
382 |
2 |
if (tchain != null && tchain.length > 0) |
383 |
|
{ |
384 |
0 |
c.add(nullChain); |
385 |
|
} |
386 |
|
} |
387 |
|
} |
388 |
|
} |
389 |
134 |
for (int i = 0; i < seq.length; i++) |
390 |
|
{ |
391 |
87 |
if (!s.contains(seq[i])) |
392 |
|
{ |
393 |
1 |
s.add(seq[i]); |
394 |
1 |
if (tchain != null && i < tchain.length) |
395 |
|
{ |
396 |
0 |
c.add(tchain[i] == null ? nullChain : tchain[i]); |
397 |
|
} |
398 |
|
} |
399 |
|
} |
400 |
47 |
SequenceI[] tmp = s.toArray(new SequenceI[s.size()]); |
401 |
47 |
getSequence()[pe] = tmp; |
402 |
47 |
if (c.size() > 0) |
403 |
|
{ |
404 |
44 |
String[] tch = c.toArray(new String[c.size()]); |
405 |
128 |
for (int i = 0; i < tch.length; i++) |
406 |
|
{ |
407 |
84 |
if (tch[i] == nullChain) |
408 |
|
{ |
409 |
0 |
tch[i] = null; |
410 |
|
} |
411 |
|
} |
412 |
44 |
getChains()[pe] = tch; |
413 |
|
} |
414 |
|
else |
415 |
|
{ |
416 |
3 |
getChains()[pe] = null; |
417 |
|
} |
418 |
|
} |
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
|
423 |
|
|
424 |
|
|
|
|
| 88.9% |
Uncovered Elements: 4 (36) |
Complexity: 7 |
Complexity Density: 0.27 |
|
425 |
1 |
public synchronized PDBEntry[] addSequenceAndChain(PDBEntry[] pdbe,... |
426 |
|
SequenceI[][] seq, String[][] chns) |
427 |
|
{ |
428 |
1 |
List<PDBEntry> v = new ArrayList<PDBEntry>(); |
429 |
1 |
List<int[]> rtn = new ArrayList<int[]>(); |
430 |
2 |
for (int i = 0; i < getPdbCount(); i++) |
431 |
|
{ |
432 |
1 |
v.add(getPdbEntry(i)); |
433 |
|
} |
434 |
2 |
for (int i = 0; i < pdbe.length; i++) |
435 |
|
{ |
436 |
1 |
int r = v.indexOf(pdbe[i]); |
437 |
1 |
if (r == -1 || r >= getPdbCount()) |
438 |
|
{ |
439 |
1 |
rtn.add(new int[] { v.size(), i }); |
440 |
1 |
v.add(pdbe[i]); |
441 |
|
} |
442 |
|
else |
443 |
|
{ |
444 |
|
|
445 |
0 |
addSequenceAndChain(r, seq[i], chns[i]); |
446 |
|
} |
447 |
|
} |
448 |
1 |
pdbe = v.toArray(new PDBEntry[v.size()]); |
449 |
1 |
setPdbentry(pdbe); |
450 |
1 |
if (rtn.size() > 0) |
451 |
|
{ |
452 |
|
|
453 |
1 |
SequenceI[][] sqs = new SequenceI[getPdbCount()][]; |
454 |
1 |
String[][] sch = new String[getPdbCount()][]; |
455 |
1 |
System.arraycopy(getSequence(), 0, sqs, 0, getSequence().length); |
456 |
1 |
System.arraycopy(getChains(), 0, sch, 0, this.getChains().length); |
457 |
1 |
setSequence(sqs); |
458 |
1 |
setChains(sch); |
459 |
1 |
pdbe = new PDBEntry[rtn.size()]; |
460 |
2 |
for (int r = 0; r < pdbe.length; r++) |
461 |
|
{ |
462 |
1 |
int[] stri = (rtn.get(r)); |
463 |
|
|
464 |
1 |
pdbe[r] = getPdbEntry(stri[0]); |
465 |
|
|
466 |
1 |
addSequenceAndChain(stri[0], seq[stri[1]], chns[stri[1]]); |
467 |
|
} |
468 |
|
} |
469 |
|
else |
470 |
|
{ |
471 |
0 |
pdbe = null; |
472 |
|
} |
473 |
1 |
return pdbe; |
474 |
|
} |
475 |
|
|
476 |
|
|
477 |
|
|
478 |
|
|
479 |
|
@param |
480 |
|
@param |
481 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
482 |
46 |
public void addSequence(int pe, SequenceI[] seq)... |
483 |
|
{ |
484 |
46 |
addSequenceAndChain(pe, seq, null); |
485 |
|
} |
486 |
|
|
487 |
|
|
488 |
|
|
489 |
|
|
490 |
|
@param |
491 |
|
|
492 |
|
@param |
493 |
|
|
494 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 3 |
Complexity Density: 1 |
|
495 |
52 |
public void addSequenceForStructFile(String pdbFile, SequenceI[] seq)... |
496 |
|
{ |
497 |
104 |
for (int pe = 0; pe < getPdbCount(); pe++) |
498 |
|
{ |
499 |
52 |
if (getPdbEntry(pe).getFile().equals(pdbFile)) |
500 |
|
{ |
501 |
32 |
addSequence(pe, seq); |
502 |
|
} |
503 |
|
} |
504 |
|
} |
505 |
|
|
506 |
|
@Override |
507 |
|
public abstract void highlightAtoms(List<AtomSpec> atoms); |
508 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
509 |
0 |
protected boolean isNucleotide()... |
510 |
|
{ |
511 |
0 |
return this.nucleotide; |
512 |
|
} |
513 |
|
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
|
|
518 |
|
@param |
519 |
|
@param |
520 |
|
@return |
521 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
522 |
0 |
public String printMappings()... |
523 |
|
{ |
524 |
0 |
if (pdbEntry == null) |
525 |
|
{ |
526 |
0 |
return ""; |
527 |
|
} |
528 |
0 |
StringBuilder sb = new StringBuilder(128); |
529 |
0 |
for (int pdbe = 0; pdbe < getPdbCount(); pdbe++) |
530 |
|
{ |
531 |
0 |
String pdbfile = getPdbEntry(pdbe).getFile(); |
532 |
0 |
List<SequenceI> seqs = Arrays.asList(getSequence()[pdbe]); |
533 |
0 |
sb.append(getSsm().printMappings(pdbfile, seqs)); |
534 |
|
} |
535 |
0 |
return sb.toString(); |
536 |
|
} |
537 |
|
|
538 |
|
|
539 |
|
|
540 |
|
|
541 |
|
|
542 |
|
|
543 |
|
@param |
544 |
|
@param |
545 |
|
@param |
546 |
|
@return |
547 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
548 |
620 |
protected int getMappedPosition(SequenceI seq, int alignedPos,... |
549 |
|
StructureMapping mapping) |
550 |
|
{ |
551 |
620 |
if (alignedPos >= seq.getLength()) |
552 |
|
{ |
553 |
1 |
return -1; |
554 |
|
} |
555 |
|
|
556 |
619 |
if (Comparison.isGap(seq.getCharAt(alignedPos))) |
557 |
|
{ |
558 |
6 |
return -1; |
559 |
|
} |
560 |
613 |
int seqPos = seq.findPosition(alignedPos); |
561 |
613 |
int pos = mapping.getPDBResNum(seqPos); |
562 |
613 |
return pos; |
563 |
|
} |
564 |
|
|
565 |
|
|
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
@param |
573 |
|
|
574 |
|
|
575 |
|
@param |
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
@param |
580 |
|
|
581 |
|
@return |
582 |
|
|
|
|
| 91.8% |
Uncovered Elements: 4 (49) |
Complexity: 13 |
Complexity Density: 0.42 |
|
583 |
3 |
protected int findSuperposableResidues(AlignmentI alignment,... |
584 |
|
BitSet matched, SuperposeData[] structures) |
585 |
|
{ |
586 |
3 |
int refStructure = -1; |
587 |
3 |
String[] files = getStructureFiles(); |
588 |
3 |
if (files == null) |
589 |
|
{ |
590 |
0 |
return -1; |
591 |
|
} |
592 |
11 |
for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) |
593 |
|
{ |
594 |
8 |
StructureMapping[] mappings = getSsm().getMapping(files[pdbfnum]); |
595 |
8 |
int lastPos = -1; |
596 |
|
|
597 |
|
|
598 |
|
|
599 |
|
|
600 |
|
|
601 |
8 |
final int seqCountForPdbFile = getSequence()[pdbfnum].length; |
602 |
16 |
for (int s = 0; s < seqCountForPdbFile; s++) |
603 |
|
{ |
604 |
8 |
for (StructureMapping mapping : mappings) |
605 |
|
{ |
606 |
8 |
final SequenceI theSequence = getSequence()[pdbfnum][s]; |
607 |
8 |
if (mapping.getSequence() == theSequence |
608 |
|
&& alignment.findIndex(theSequence) > -1) |
609 |
|
{ |
610 |
8 |
if (refStructure < 0) |
611 |
|
{ |
612 |
3 |
refStructure = pdbfnum; |
613 |
|
} |
614 |
638 |
for (int r = 0; r < alignment.getWidth(); r++) |
615 |
|
{ |
616 |
630 |
if (!matched.get(r)) |
617 |
|
{ |
618 |
10 |
continue; |
619 |
|
} |
620 |
620 |
int pos = getMappedPosition(theSequence, r, mapping); |
621 |
620 |
if (pos < 1 || pos == lastPos) |
622 |
|
{ |
623 |
7 |
matched.clear(r); |
624 |
7 |
continue; |
625 |
|
} |
626 |
613 |
lastPos = pos; |
627 |
613 |
structures[pdbfnum].pdbResNo[r] = pos; |
628 |
|
} |
629 |
8 |
String chain = mapping.getChain(); |
630 |
8 |
if (chain != null && chain.trim().length() > 0) |
631 |
|
{ |
632 |
8 |
structures[pdbfnum].chain = chain; |
633 |
|
} |
634 |
8 |
structures[pdbfnum].pdbId = mapping.getPdbId(); |
635 |
8 |
structures[pdbfnum].isRna = theSequence.getRNA() != null; |
636 |
|
|
637 |
|
|
638 |
|
|
639 |
|
|
640 |
|
|
641 |
8 |
s = seqCountForPdbFile; |
642 |
8 |
break; |
643 |
|
} |
644 |
|
} |
645 |
|
} |
646 |
|
} |
647 |
3 |
return refStructure; |
648 |
|
} |
649 |
|
|
650 |
|
|
651 |
|
|
652 |
|
|
653 |
|
|
654 |
|
|
655 |
|
@param |
656 |
|
|
|
|
| 70.4% |
Uncovered Elements: 8 (27) |
Complexity: 8 |
Complexity Density: 0.42 |
|
657 |
1 |
protected boolean waitForFileLoad(String[] files)... |
658 |
|
{ |
659 |
|
|
660 |
|
|
661 |
|
|
662 |
1 |
long starttime = System.currentTimeMillis(); |
663 |
1 |
long endTime = 10000 + 1000 * files.length + starttime; |
664 |
1 |
String notLoaded = null; |
665 |
|
|
666 |
1 |
boolean waiting = true; |
667 |
2 |
while (waiting && System.currentTimeMillis() < endTime) |
668 |
|
{ |
669 |
1 |
waiting = false; |
670 |
1 |
for (String file : files) |
671 |
|
{ |
672 |
2 |
notLoaded = file; |
673 |
2 |
if (file == null) |
674 |
|
{ |
675 |
0 |
continue; |
676 |
|
} |
677 |
2 |
try |
678 |
|
{ |
679 |
2 |
StructureMapping[] sm = getSsm().getMapping(file); |
680 |
2 |
if (sm == null || sm.length == 0) |
681 |
|
{ |
682 |
0 |
waiting = true; |
683 |
|
} |
684 |
|
} catch (Throwable x) |
685 |
|
{ |
686 |
0 |
waiting = true; |
687 |
|
} |
688 |
|
} |
689 |
|
} |
690 |
|
|
691 |
1 |
if (waiting) |
692 |
|
{ |
693 |
0 |
System.err.println( |
694 |
|
"Timed out waiting for structure viewer to load file " |
695 |
|
+ notLoaded); |
696 |
0 |
return false; |
697 |
|
} |
698 |
1 |
return true; |
699 |
|
} |
700 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 6 |
Complexity Density: 0.86 |
|
701 |
0 |
@Override... |
702 |
|
public boolean isListeningFor(SequenceI seq) |
703 |
|
{ |
704 |
0 |
if (sequence != null) |
705 |
|
{ |
706 |
0 |
for (SequenceI[] seqs : sequence) |
707 |
|
{ |
708 |
0 |
if (seqs != null) |
709 |
|
{ |
710 |
0 |
for (SequenceI s : seqs) |
711 |
|
{ |
712 |
0 |
if (s == seq || (s.getDatasetSequence() != null |
713 |
|
&& s.getDatasetSequence() == seq.getDatasetSequence())) |
714 |
|
{ |
715 |
0 |
return true; |
716 |
|
} |
717 |
|
} |
718 |
|
} |
719 |
|
} |
720 |
|
} |
721 |
0 |
return false; |
722 |
|
} |
723 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
724 |
180 |
public boolean isFinishedInit()... |
725 |
|
{ |
726 |
180 |
return finishedInit; |
727 |
|
} |
728 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
729 |
20 |
public void setFinishedInit(boolean fi)... |
730 |
|
{ |
731 |
20 |
this.finishedInit = fi; |
732 |
|
} |
733 |
|
|
734 |
|
|
735 |
|
|
736 |
|
|
737 |
|
@return |
738 |
|
|
739 |
|
public abstract List<String> getChainNames(); |
740 |
|
|
741 |
|
|
742 |
|
|
743 |
|
|
744 |
|
@return |
745 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
746 |
0 |
public JalviewStructureDisplayI getViewer()... |
747 |
|
{ |
748 |
0 |
return null; |
749 |
|
} |
750 |
|
|
751 |
|
public abstract void setJalviewColourScheme(ColourSchemeI cs); |
752 |
|
|
753 |
|
|
754 |
|
|
755 |
|
|
756 |
|
|
757 |
|
|
758 |
|
@param |
759 |
|
|
760 |
|
@param |
761 |
|
|
762 |
|
|
763 |
|
|
764 |
|
|
765 |
|
@param |
766 |
|
|
767 |
|
@return |
768 |
|
|
769 |
|
public abstract String superposeStructures(AlignmentI[] alignments, |
770 |
|
int[] structureIndices, HiddenColumns[] hiddenCols); |
771 |
|
|
772 |
|
public abstract void setBackgroundColour(Color col); |
773 |
|
|
774 |
|
protected abstract StructureMappingcommandSet[] getColourBySequenceCommands( |
775 |
|
String[] files, SequenceRenderer sr, AlignmentViewPanel avp); |
776 |
|
|
777 |
|
|
778 |
|
|
779 |
|
|
780 |
|
|
781 |
|
@param |
782 |
|
|
783 |
|
@return |
784 |
|
|
785 |
|
public abstract SequenceRenderer getSequenceRenderer( |
786 |
|
AlignmentViewPanel alignment); |
787 |
|
|
788 |
|
protected abstract void colourBySequence( |
789 |
|
StructureMappingcommandSet[] colourBySequenceCommands); |
790 |
|
|
791 |
|
public abstract void colourByChain(); |
792 |
|
|
793 |
|
public abstract void colourByCharge(); |
794 |
|
|
795 |
|
|
796 |
|
|
797 |
|
|
798 |
|
|
799 |
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
800 |
22 |
public void colourBySequence(AlignmentViewPanel alignmentv)... |
801 |
|
{ |
802 |
22 |
if (!colourBySequence || !isLoadingFinished()) |
803 |
|
{ |
804 |
13 |
return; |
805 |
|
} |
806 |
9 |
if (getSsm() == null) |
807 |
|
{ |
808 |
0 |
return; |
809 |
|
} |
810 |
9 |
String[] files = getStructureFiles(); |
811 |
|
|
812 |
9 |
SequenceRenderer sr = getSequenceRenderer(alignmentv); |
813 |
|
|
814 |
9 |
StructureMappingcommandSet[] colourBySequenceCommands = getColourBySequenceCommands( |
815 |
|
files, sr, alignmentv); |
816 |
9 |
colourBySequence(colourBySequenceCommands); |
817 |
|
} |
818 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
819 |
183 |
public boolean hasFileLoadingError()... |
820 |
|
{ |
821 |
183 |
return fileLoadingError != null && fileLoadingError.length() > 0; |
822 |
|
} |
823 |
|
|
824 |
|
public abstract jalview.api.FeatureRenderer getFeatureRenderer( |
825 |
|
AlignmentViewPanel alignment); |
826 |
|
} |