1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.structure; |
22 |
|
|
23 |
|
import java.io.PrintStream; |
24 |
|
import java.util.ArrayList; |
25 |
|
import java.util.Arrays; |
26 |
|
import java.util.Collections; |
27 |
|
import java.util.Enumeration; |
28 |
|
import java.util.HashMap; |
29 |
|
import java.util.IdentityHashMap; |
30 |
|
import java.util.List; |
31 |
|
import java.util.Map; |
32 |
|
import java.util.Vector; |
33 |
|
|
34 |
|
import jalview.analysis.AlignSeq; |
35 |
|
import jalview.api.StructureSelectionManagerProvider; |
36 |
|
import jalview.bin.Cache; |
37 |
|
import jalview.commands.CommandI; |
38 |
|
import jalview.commands.EditCommand; |
39 |
|
import jalview.commands.OrderCommand; |
40 |
|
import jalview.datamodel.AlignedCodonFrame; |
41 |
|
import jalview.datamodel.AlignmentAnnotation; |
42 |
|
import jalview.datamodel.AlignmentI; |
43 |
|
import jalview.datamodel.Annotation; |
44 |
|
import jalview.datamodel.HiddenColumns; |
45 |
|
import jalview.datamodel.PDBEntry; |
46 |
|
import jalview.datamodel.SearchResults; |
47 |
|
import jalview.datamodel.SearchResultsI; |
48 |
|
import jalview.datamodel.SequenceI; |
49 |
|
import jalview.ext.jmol.JmolParser; |
50 |
|
import jalview.gui.IProgressIndicator; |
51 |
|
import jalview.io.AppletFormatAdapter; |
52 |
|
import jalview.io.DataSourceType; |
53 |
|
import jalview.io.StructureFile; |
54 |
|
import jalview.util.MappingUtils; |
55 |
|
import jalview.util.MessageManager; |
56 |
|
import jalview.util.Platform; |
57 |
|
import jalview.ws.sifts.SiftsClient; |
58 |
|
import jalview.ws.sifts.SiftsException; |
59 |
|
import jalview.ws.sifts.SiftsSettings; |
60 |
|
import mc_view.Atom; |
61 |
|
import mc_view.PDBChain; |
62 |
|
import mc_view.PDBfile; |
63 |
|
|
|
|
| 59.6% |
Uncovered Elements: 260 (643) |
Complexity: 187 |
Complexity Density: 0.48 |
|
64 |
|
public class StructureSelectionManager |
65 |
|
{ |
66 |
|
public final static String NEWLINE = System.lineSeparator(); |
67 |
|
|
68 |
|
static IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> instances; |
69 |
|
|
70 |
|
private List<StructureMapping> mappings = new ArrayList<>(); |
71 |
|
|
72 |
|
private boolean processSecondaryStructure = false; |
73 |
|
|
74 |
|
private boolean secStructServices = false; |
75 |
|
|
76 |
|
private boolean addTempFacAnnot = false; |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
private List<AlignedCodonFrame> seqmappings = new ArrayList<>(); |
82 |
|
|
83 |
|
private List<CommandListener> commandListeners = new ArrayList<>(); |
84 |
|
|
85 |
|
private List<SelectionListener> sel_listeners = new ArrayList<>(); |
86 |
|
|
87 |
|
|
88 |
|
@return |
89 |
|
|
90 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
0 |
public boolean isSecStructServices()... |
92 |
|
{ |
93 |
0 |
return secStructServices; |
94 |
|
} |
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
@param |
100 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
101 |
18 |
public void setSecStructServices(boolean secStructServices)... |
102 |
|
{ |
103 |
18 |
this.secStructServices = secStructServices; |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
@return |
110 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
111 |
0 |
public boolean isAddTempFacAnnot()... |
112 |
|
{ |
113 |
0 |
return addTempFacAnnot; |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
@param |
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
20 |
public void setAddTempFacAnnot(boolean addTempFacAnnot)... |
122 |
|
{ |
123 |
20 |
this.addTempFacAnnot = addTempFacAnnot; |
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
@return |
129 |
|
|
130 |
|
|
131 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
132 |
0 |
public boolean isProcessSecondaryStructure()... |
133 |
|
{ |
134 |
0 |
return processSecondaryStructure; |
135 |
|
} |
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
@param |
142 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
143 |
20 |
public void setProcessSecondaryStructure(boolean enable)... |
144 |
|
{ |
145 |
20 |
processSecondaryStructure = enable; |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
151 |
0 |
public void reportMapping()... |
152 |
|
{ |
153 |
0 |
if (mappings.isEmpty()) |
154 |
|
{ |
155 |
0 |
System.err.println("reportMapping: No PDB/Sequence mappings."); |
156 |
|
} |
157 |
|
else |
158 |
|
{ |
159 |
0 |
System.err.println( |
160 |
|
"reportMapping: There are " + mappings.size() + " mappings."); |
161 |
0 |
int i = 0; |
162 |
0 |
for (StructureMapping sm : mappings) |
163 |
|
{ |
164 |
0 |
System.err.println("mapping " + i++ + " : " + sm.pdbfile); |
165 |
|
} |
166 |
|
} |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
Map<String, String> pdbIdFileName = new HashMap<>(); |
174 |
|
|
175 |
|
Map<String, String> pdbFileNameId = new HashMap<>(); |
176 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
177 |
115 |
public void registerPDBFile(String idForFile, String absoluteFile)... |
178 |
|
{ |
179 |
115 |
pdbIdFileName.put(idForFile, absoluteFile); |
180 |
115 |
pdbFileNameId.put(absoluteFile, idForFile); |
181 |
|
} |
182 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
183 |
120 |
public String findIdForPDBFile(String idOrFile)... |
184 |
|
{ |
185 |
120 |
String id = pdbFileNameId.get(idOrFile); |
186 |
120 |
return id; |
187 |
|
} |
188 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
189 |
1 |
public String findFileForPDBId(String idOrFile)... |
190 |
|
{ |
191 |
1 |
String id = pdbIdFileName.get(idOrFile); |
192 |
1 |
return id; |
193 |
|
} |
194 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
195 |
44 |
public boolean isPDBFileRegistered(String idOrFile)... |
196 |
|
{ |
197 |
44 |
return pdbFileNameId.containsKey(idOrFile) |
198 |
|
|| pdbIdFileName.containsKey(idOrFile); |
199 |
|
} |
200 |
|
|
201 |
|
private static StructureSelectionManager nullProvider = null; |
202 |
|
|
|
|
| 92.6% |
Uncovered Elements: 2 (27) |
Complexity: 7 |
Complexity Density: 0.47 |
|
203 |
2476 |
public static StructureSelectionManager getStructureSelectionManager(... |
204 |
|
StructureSelectionManagerProvider context) |
205 |
|
{ |
206 |
2476 |
if (context == null) |
207 |
|
{ |
208 |
161 |
if (nullProvider == null) |
209 |
|
{ |
210 |
18 |
if (instances != null) |
211 |
|
{ |
212 |
0 |
throw new Error(MessageManager.getString( |
213 |
|
"error.implementation_error_structure_selection_manager_null"), |
214 |
|
new NullPointerException(MessageManager |
215 |
|
.getString("exception.ssm_context_is_null"))); |
216 |
|
} |
217 |
|
else |
218 |
|
{ |
219 |
18 |
nullProvider = new StructureSelectionManager(); |
220 |
|
} |
221 |
18 |
return nullProvider; |
222 |
|
} |
223 |
|
} |
224 |
2458 |
if (instances == null) |
225 |
|
{ |
226 |
19 |
instances = new java.util.IdentityHashMap<>(); |
227 |
|
} |
228 |
2458 |
StructureSelectionManager instance = instances.get(context); |
229 |
2458 |
if (instance == null) |
230 |
|
{ |
231 |
36 |
if (nullProvider != null) |
232 |
|
{ |
233 |
35 |
instance = nullProvider; |
234 |
|
} |
235 |
|
else |
236 |
|
{ |
237 |
1 |
instance = new StructureSelectionManager(); |
238 |
|
} |
239 |
36 |
instances.put(context, instance); |
240 |
|
} |
241 |
2458 |
return instance; |
242 |
|
} |
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
boolean relaySeqMappings = true; |
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
@param |
256 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
257 |
0 |
public void setRelaySeqMappings(boolean relay)... |
258 |
|
{ |
259 |
0 |
relaySeqMappings = relay; |
260 |
|
} |
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
|
265 |
|
@return |
266 |
|
|
267 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
268 |
0 |
public boolean isRelaySeqMappingsEnabled()... |
269 |
|
{ |
270 |
0 |
return relaySeqMappings; |
271 |
|
} |
272 |
|
|
273 |
|
Vector listeners = new Vector(); |
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
@param |
279 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
280 |
273 |
public void addStructureViewerListener(Object svl)... |
281 |
|
{ |
282 |
273 |
if (!listeners.contains(svl)) |
283 |
|
{ |
284 |
272 |
listeners.addElement(svl); |
285 |
|
} |
286 |
|
} |
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
@param |
293 |
|
@return |
294 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
295 |
1 |
public String alreadyMappedToFile(String pdbid)... |
296 |
|
{ |
297 |
1 |
for (StructureMapping sm : mappings) |
298 |
|
{ |
299 |
1 |
if (sm.getPdbId().equalsIgnoreCase(pdbid)) |
300 |
|
{ |
301 |
0 |
return sm.pdbfile; |
302 |
|
} |
303 |
|
} |
304 |
1 |
return null; |
305 |
|
} |
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
@param |
312 |
|
|
313 |
|
@param |
314 |
|
|
315 |
|
|
316 |
|
@param |
317 |
|
|
318 |
|
@param |
319 |
|
|
320 |
|
@return |
321 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
322 |
54 |
synchronized public StructureFile setMapping(SequenceI[] sequence,... |
323 |
|
String[] targetChains, String pdbFile, DataSourceType protocol, |
324 |
|
IProgressIndicator progress) |
325 |
|
{ |
326 |
54 |
return computeMapping(true, sequence, targetChains, pdbFile, protocol, |
327 |
|
progress); |
328 |
|
} |
329 |
|
|
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
|
335 |
|
@param |
336 |
|
|
337 |
|
@param |
338 |
|
|
339 |
|
@param |
340 |
|
|
341 |
|
|
342 |
|
@param |
343 |
|
|
344 |
|
@param |
345 |
|
|
346 |
|
@return |
347 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
348 |
3 |
synchronized public StructureFile setMapping(boolean forStructureView,... |
349 |
|
SequenceI[] sequenceArray, String[] targetChainIds, |
350 |
|
String pdbFile, DataSourceType sourceType) |
351 |
|
{ |
352 |
3 |
return computeMapping(forStructureView, sequenceArray, targetChainIds, |
353 |
|
pdbFile, sourceType, null); |
354 |
|
} |
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
|
360 |
|
|
361 |
|
@param |
362 |
|
|
363 |
|
|
364 |
|
@param |
365 |
|
|
366 |
|
@param |
367 |
|
|
368 |
|
|
369 |
|
|
370 |
|
|
371 |
|
@param |
372 |
|
|
373 |
|
@param |
374 |
|
|
375 |
|
@param |
376 |
|
|
377 |
|
|
378 |
|
@return |
379 |
|
|
|
|
| 58.2% |
Uncovered Elements: 64 (153) |
Complexity: 37 |
Complexity Density: 0.33 |
|
380 |
57 |
synchronized public StructureFile computeMapping(... |
381 |
|
boolean forStructureView, SequenceI[] sequenceArray, |
382 |
|
String[] targetChainIds, String pdbFile, DataSourceType sourceType, |
383 |
|
IProgressIndicator progress) |
384 |
|
{ |
385 |
57 |
long progressSessionId = System.currentTimeMillis() * 3; |
386 |
|
|
387 |
|
|
388 |
|
|
389 |
|
|
390 |
|
|
391 |
|
|
392 |
57 |
boolean parseSecStr = processSecondaryStructure |
393 |
|
? isStructureFileProcessed(pdbFile, sequenceArray) |
394 |
|
: false; |
395 |
|
|
396 |
57 |
StructureFile pdb = null; |
397 |
57 |
boolean isMapUsingSIFTs = SiftsSettings.isMapWithSifts(); |
398 |
57 |
try |
399 |
|
{ |
400 |
|
|
401 |
57 |
sourceType = AppletFormatAdapter.checkProtocol(pdbFile); |
402 |
57 |
pdb = new JmolParser(false, pdbFile, sourceType); |
403 |
57 |
pdb.addSettings(parseSecStr && processSecondaryStructure, |
404 |
|
parseSecStr && addTempFacAnnot, |
405 |
|
parseSecStr && secStructServices); |
406 |
57 |
pdb.doParse(); |
407 |
57 |
if (pdb.getId() != null && pdb.getId().trim().length() > 0 |
408 |
|
&& DataSourceType.FILE == sourceType) |
409 |
|
{ |
410 |
45 |
registerPDBFile(pdb.getId().trim(), pdbFile); |
411 |
|
} |
412 |
|
|
413 |
57 |
isMapUsingSIFTs = isMapUsingSIFTs && pdb.isPPDBIdAvailable(); |
414 |
|
|
415 |
|
} catch (Exception ex) |
416 |
|
{ |
417 |
0 |
ex.printStackTrace(); |
418 |
0 |
return null; |
419 |
|
} |
420 |
|
|
421 |
|
|
422 |
|
|
423 |
57 |
SiftsClient siftsClient = null; |
424 |
57 |
try |
425 |
|
{ |
426 |
57 |
if (isMapUsingSIFTs) |
427 |
|
{ |
428 |
0 |
siftsClient = new SiftsClient(pdb); |
429 |
|
} |
430 |
|
} catch (SiftsException e) |
431 |
|
{ |
432 |
0 |
isMapUsingSIFTs = false; |
433 |
0 |
Cache.log.error("SIFTS mapping failed", e); |
434 |
0 |
Cache.log.error("Falling back on Needleman & Wunsch alignment"); |
435 |
0 |
siftsClient = null; |
436 |
|
} |
437 |
|
|
438 |
57 |
String targetChainId; |
439 |
156 |
for (int s = 0; s < sequenceArray.length; s++) |
440 |
|
{ |
441 |
99 |
boolean infChain = true; |
442 |
99 |
final SequenceI seq = sequenceArray[s]; |
443 |
99 |
SequenceI ds = seq; |
444 |
196 |
while (ds.getDatasetSequence() != null) |
445 |
|
{ |
446 |
97 |
ds = ds.getDatasetSequence(); |
447 |
|
} |
448 |
|
|
449 |
99 |
if (targetChainIds != null && targetChainIds[s] != null) |
450 |
|
{ |
451 |
3 |
infChain = false; |
452 |
3 |
targetChainId = targetChainIds[s]; |
453 |
|
} |
454 |
96 |
else if (seq.getName().indexOf("|") > -1) |
455 |
|
{ |
456 |
49 |
targetChainId = seq.getName() |
457 |
|
.substring(seq.getName().lastIndexOf("|") + 1); |
458 |
49 |
if (targetChainId.length() > 1) |
459 |
|
{ |
460 |
1 |
if (targetChainId.trim().length() == 0) |
461 |
|
{ |
462 |
0 |
targetChainId = " "; |
463 |
|
} |
464 |
|
else |
465 |
|
{ |
466 |
|
|
467 |
1 |
targetChainId = ""; |
468 |
|
} |
469 |
|
} |
470 |
|
} |
471 |
|
else |
472 |
|
{ |
473 |
47 |
targetChainId = ""; |
474 |
|
} |
475 |
|
|
476 |
|
|
477 |
|
|
478 |
|
|
479 |
|
|
480 |
99 |
float max = -10; |
481 |
99 |
AlignSeq maxAlignseq = null; |
482 |
99 |
String maxChainId = " "; |
483 |
99 |
PDBChain maxChain = null; |
484 |
99 |
boolean first = true; |
485 |
99 |
for (PDBChain chain : pdb.getChains()) |
486 |
|
{ |
487 |
121 |
if (targetChainId.length() > 0 && !targetChainId.equals(chain.id) |
488 |
|
&& !infChain) |
489 |
|
{ |
490 |
6 |
continue; |
491 |
|
} |
492 |
|
|
493 |
|
|
494 |
115 |
final String type = chain.isNa ? AlignSeq.DNA : AlignSeq.PEP; |
495 |
115 |
AlignSeq as = AlignSeq.doGlobalNWAlignment(seq, chain.sequence, |
496 |
|
type); |
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
501 |
|
|
502 |
115 |
if (first || as.maxscore > max |
503 |
|
|| (as.maxscore == max && chain.id.equals(targetChainId))) |
504 |
|
{ |
505 |
105 |
first = false; |
506 |
105 |
maxChain = chain; |
507 |
105 |
max = as.maxscore; |
508 |
105 |
maxAlignseq = as; |
509 |
105 |
maxChainId = chain.id; |
510 |
|
} |
511 |
|
} |
512 |
99 |
if (maxChain == null) |
513 |
|
{ |
514 |
0 |
continue; |
515 |
|
} |
516 |
|
|
517 |
99 |
if (sourceType == DataSourceType.PASTE) |
518 |
|
{ |
519 |
16 |
pdbFile = "INLINE" + pdb.getId(); |
520 |
|
} |
521 |
|
|
522 |
99 |
List<StructureMapping> seqToStrucMapping = new ArrayList<>(); |
523 |
99 |
if (isMapUsingSIFTs && seq.isProtein()) |
524 |
|
{ |
525 |
0 |
if (progress!=null) { |
526 |
0 |
progress.setProgressBar(MessageManager |
527 |
|
.getString("status.obtaining_mapping_with_sifts"), |
528 |
|
progressSessionId); |
529 |
|
} |
530 |
0 |
jalview.datamodel.Mapping sqmpping = maxAlignseq |
531 |
|
.getMappingFromS1(false); |
532 |
0 |
if (targetChainId != null && !targetChainId.trim().isEmpty()) |
533 |
|
{ |
534 |
0 |
StructureMapping siftsMapping; |
535 |
0 |
try |
536 |
|
{ |
537 |
0 |
siftsMapping = getStructureMapping(seq, pdbFile, targetChainId, |
538 |
|
pdb, maxChain, sqmpping, maxAlignseq, siftsClient); |
539 |
0 |
seqToStrucMapping.add(siftsMapping); |
540 |
0 |
maxChain.makeExactMapping(siftsMapping, seq); |
541 |
0 |
maxChain.transferRESNUMFeatures(seq, "IEA: SIFTS"); |
542 |
0 |
maxChain.transferResidueAnnotation(siftsMapping, null); |
543 |
0 |
ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0)); |
544 |
|
|
545 |
|
} catch (SiftsException e) |
546 |
|
{ |
547 |
|
|
548 |
0 |
Cache.log.error(e.getMessage()); |
549 |
0 |
StructureMapping nwMapping = getNWMappings(seq, pdbFile, |
550 |
|
targetChainId, maxChain, pdb, maxAlignseq); |
551 |
0 |
seqToStrucMapping.add(nwMapping); |
552 |
0 |
maxChain.makeExactMapping(maxAlignseq, seq); |
553 |
0 |
maxChain.transferRESNUMFeatures(seq, "IEA:Jalview"); |
554 |
|
|
555 |
|
|
556 |
0 |
maxChain.transferResidueAnnotation(nwMapping, sqmpping); |
557 |
0 |
ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0)); |
558 |
|
} |
559 |
|
} |
560 |
|
else |
561 |
|
{ |
562 |
0 |
List<StructureMapping> foundSiftsMappings = new ArrayList<>(); |
563 |
0 |
for (PDBChain chain : pdb.getChains()) |
564 |
|
{ |
565 |
0 |
StructureMapping siftsMapping = null; |
566 |
0 |
try |
567 |
|
{ |
568 |
0 |
siftsMapping = getStructureMapping(seq, |
569 |
|
pdbFile, chain.id, pdb, chain, sqmpping, maxAlignseq, |
570 |
|
siftsClient); |
571 |
0 |
foundSiftsMappings.add(siftsMapping); |
572 |
0 |
chain.makeExactMapping(siftsMapping, seq); |
573 |
0 |
chain.transferRESNUMFeatures(seq, "IEA: SIFTS"); |
574 |
|
|
575 |
0 |
chain.transferResidueAnnotation(siftsMapping, null); |
576 |
|
} catch (SiftsException e) |
577 |
|
{ |
578 |
0 |
System.err.println(e.getMessage()); |
579 |
|
} |
580 |
|
catch (Exception e) |
581 |
|
{ |
582 |
0 |
System.err |
583 |
|
.println( |
584 |
|
"Unexpected exception during SIFTS mapping - falling back to NW for this sequence/structure pair"); |
585 |
0 |
System.err.println(e.getMessage()); |
586 |
|
} |
587 |
|
} |
588 |
0 |
if (!foundSiftsMappings.isEmpty()) |
589 |
|
{ |
590 |
0 |
seqToStrucMapping.addAll(foundSiftsMappings); |
591 |
0 |
ds.addPDBId(sqmpping.getTo().getAllPDBEntries().get(0)); |
592 |
|
} |
593 |
|
else |
594 |
|
{ |
595 |
0 |
StructureMapping nwMapping = getNWMappings(seq, pdbFile, |
596 |
|
maxChainId, maxChain, pdb, maxAlignseq); |
597 |
0 |
seqToStrucMapping.add(nwMapping); |
598 |
0 |
maxChain.transferRESNUMFeatures(seq, null); |
599 |
|
|
600 |
0 |
maxChain.transferResidueAnnotation(nwMapping, sqmpping); |
601 |
0 |
ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0)); |
602 |
|
} |
603 |
|
} |
604 |
|
} |
605 |
|
else |
606 |
|
{ |
607 |
99 |
if (progress != null) |
608 |
|
{ |
609 |
0 |
progress.setProgressBar(MessageManager |
610 |
|
.getString("status.obtaining_mapping_with_nw_alignment"), |
611 |
|
progressSessionId); |
612 |
|
} |
613 |
99 |
StructureMapping nwMapping = getNWMappings(seq, pdbFile, maxChainId, |
614 |
|
maxChain, pdb, maxAlignseq); |
615 |
99 |
seqToStrucMapping.add(nwMapping); |
616 |
99 |
ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0)); |
617 |
|
} |
618 |
99 |
if (forStructureView) |
619 |
|
{ |
620 |
99 |
for (StructureMapping sm : seqToStrucMapping) |
621 |
|
{ |
622 |
99 |
addStructureMapping(sm); |
623 |
|
} |
624 |
|
} |
625 |
99 |
if (progress != null) |
626 |
|
{ |
627 |
0 |
progress.setProgressBar(null, progressSessionId); |
628 |
|
} |
629 |
|
} |
630 |
57 |
return pdb; |
631 |
|
} |
632 |
|
|
633 |
|
|
634 |
|
|
635 |
|
|
636 |
|
|
637 |
|
@param |
638 |
|
@param |
639 |
|
@return |
640 |
|
|
|
|
| 90% |
Uncovered Elements: 2 (20) |
Complexity: 5 |
Complexity Density: 0.42 |
|
641 |
44 |
private boolean isStructureFileProcessed(String pdbFile,... |
642 |
|
SequenceI[] sequenceArray) |
643 |
|
{ |
644 |
44 |
boolean parseSecStr = true; |
645 |
44 |
if (isPDBFileRegistered(pdbFile)) |
646 |
|
{ |
647 |
42 |
for (SequenceI sq : sequenceArray) |
648 |
|
{ |
649 |
80 |
SequenceI ds = sq; |
650 |
160 |
while (ds.getDatasetSequence() != null) |
651 |
|
{ |
652 |
80 |
ds = ds.getDatasetSequence(); |
653 |
|
} |
654 |
80 |
; |
655 |
80 |
if (ds.getAnnotation() != null) |
656 |
|
{ |
657 |
64 |
for (AlignmentAnnotation ala : ds.getAnnotation()) |
658 |
|
{ |
659 |
|
|
660 |
|
|
661 |
|
|
662 |
120 |
if (PDBfile.isCalcIdForFile(ala, findIdForPDBFile(pdbFile))) |
663 |
|
{ |
664 |
0 |
parseSecStr = false; |
665 |
|
} |
666 |
|
} |
667 |
|
} |
668 |
|
} |
669 |
|
} |
670 |
44 |
return parseSecStr; |
671 |
|
} |
672 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
673 |
103 |
public void addStructureMapping(StructureMapping sm)... |
674 |
|
{ |
675 |
103 |
if (!mappings.contains(sm)) |
676 |
|
{ |
677 |
42 |
mappings.add(sm); |
678 |
|
} |
679 |
|
} |
680 |
|
|
681 |
|
|
682 |
|
|
683 |
|
|
684 |
|
|
685 |
|
@param |
686 |
|
@param |
687 |
|
@param |
688 |
|
@param |
689 |
|
@param |
690 |
|
@param |
691 |
|
@param |
692 |
|
@param |
693 |
|
|
694 |
|
@return |
695 |
|
@throws |
696 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
697 |
0 |
private StructureMapping getStructureMapping(SequenceI seq,... |
698 |
|
String pdbFile, String targetChainId, StructureFile pdb, |
699 |
|
PDBChain maxChain, jalview.datamodel.Mapping sqmpping, |
700 |
|
AlignSeq maxAlignseq, SiftsClient siftsClient) throws SiftsException |
701 |
|
{ |
702 |
0 |
StructureMapping curChainMapping = siftsClient |
703 |
|
.getSiftsStructureMapping(seq, pdbFile, targetChainId); |
704 |
0 |
try |
705 |
|
{ |
706 |
0 |
PDBChain chain = pdb.findChain(targetChainId); |
707 |
0 |
if (chain != null) |
708 |
|
{ |
709 |
0 |
chain.transferResidueAnnotation(curChainMapping, null); |
710 |
|
} |
711 |
|
} catch (Exception e) |
712 |
|
{ |
713 |
0 |
e.printStackTrace(); |
714 |
|
} |
715 |
0 |
return curChainMapping; |
716 |
|
} |
717 |
|
|
|
|
| 97.4% |
Uncovered Elements: 1 (39) |
Complexity: 6 |
Complexity Density: 0.18 |
|
718 |
99 |
private StructureMapping getNWMappings(SequenceI seq, String pdbFile,... |
719 |
|
String maxChainId, PDBChain maxChain, StructureFile pdb, |
720 |
|
AlignSeq maxAlignseq) |
721 |
|
{ |
722 |
99 |
final StringBuilder mappingDetails = new StringBuilder(128); |
723 |
99 |
mappingDetails.append(NEWLINE) |
724 |
|
.append("Sequence \u27f7 Structure mapping details"); |
725 |
99 |
mappingDetails.append(NEWLINE); |
726 |
99 |
mappingDetails |
727 |
|
.append("Method: inferred with Needleman & Wunsch alignment"); |
728 |
99 |
mappingDetails.append(NEWLINE).append("PDB Sequence is :") |
729 |
|
.append(NEWLINE).append("Sequence = ") |
730 |
|
.append(maxChain.sequence.getSequenceAsString()); |
731 |
99 |
mappingDetails.append(NEWLINE).append("No of residues = ") |
732 |
|
.append(maxChain.residues.size()).append(NEWLINE) |
733 |
|
.append(NEWLINE); |
734 |
99 |
PrintStream ps = new PrintStream(System.out) |
735 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
736 |
99 |
@Override... |
737 |
|
public void print(String x) |
738 |
|
{ |
739 |
99 |
mappingDetails.append(x); |
740 |
|
} |
741 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
742 |
0 |
@Override... |
743 |
|
public void println() |
744 |
|
{ |
745 |
0 |
mappingDetails.append(NEWLINE); |
746 |
|
} |
747 |
|
}; |
748 |
|
|
749 |
99 |
maxAlignseq.printAlignment(ps); |
750 |
|
|
751 |
99 |
mappingDetails.append(NEWLINE).append("PDB start/end "); |
752 |
99 |
mappingDetails.append(String.valueOf(maxAlignseq.seq2start)) |
753 |
|
.append(" "); |
754 |
99 |
mappingDetails.append(String.valueOf(maxAlignseq.seq2end)); |
755 |
99 |
mappingDetails.append(NEWLINE).append("SEQ start/end "); |
756 |
99 |
mappingDetails |
757 |
|
.append(String |
758 |
|
.valueOf(maxAlignseq.seq1start + (seq.getStart() - 1))) |
759 |
|
.append(" "); |
760 |
99 |
mappingDetails.append( |
761 |
|
String.valueOf(maxAlignseq.seq1end + (seq.getStart() - 1))); |
762 |
99 |
mappingDetails.append(NEWLINE); |
763 |
99 |
maxChain.makeExactMapping(maxAlignseq, seq); |
764 |
99 |
jalview.datamodel.Mapping sqmpping = maxAlignseq |
765 |
|
.getMappingFromS1(false); |
766 |
99 |
maxChain.transferRESNUMFeatures(seq, null); |
767 |
|
|
768 |
99 |
HashMap<Integer, int[]> mapping = new HashMap<>(); |
769 |
99 |
int resNum = -10000; |
770 |
99 |
int index = 0; |
771 |
99 |
char insCode = ' '; |
772 |
|
|
773 |
99 |
do |
774 |
|
{ |
775 |
9281 |
Atom tmp = maxChain.atoms.elementAt(index); |
776 |
9281 |
if ((resNum != tmp.resNumber || insCode != tmp.insCode) |
777 |
|
&& tmp.alignmentMapping != -1) |
778 |
|
{ |
779 |
9242 |
resNum = tmp.resNumber; |
780 |
9242 |
insCode = tmp.insCode; |
781 |
9242 |
if (tmp.alignmentMapping >= -1) |
782 |
|
{ |
783 |
9242 |
mapping.put(tmp.alignmentMapping + 1, |
784 |
|
new int[] |
785 |
|
{ tmp.resNumber, tmp.atomIndex }); |
786 |
|
} |
787 |
|
} |
788 |
|
|
789 |
9281 |
index++; |
790 |
9281 |
} while (index < maxChain.atoms.size()); |
791 |
|
|
792 |
99 |
StructureMapping nwMapping = new StructureMapping(seq, pdbFile, |
793 |
|
pdb.getId(), maxChainId, mapping, mappingDetails.toString()); |
794 |
99 |
maxChain.transferResidueAnnotation(nwMapping, sqmpping); |
795 |
99 |
return nwMapping; |
796 |
|
} |
797 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (36) |
Complexity: 9 |
Complexity Density: 0.45 |
|
798 |
211 |
public void removeStructureViewerListener(Object svl, String[] pdbfiles)... |
799 |
|
{ |
800 |
211 |
listeners.removeElement(svl); |
801 |
211 |
if (svl instanceof SequenceListener) |
802 |
|
{ |
803 |
1886 |
for (int i = 0; i < listeners.size(); i++) |
804 |
|
{ |
805 |
1682 |
if (listeners.elementAt(i) instanceof StructureListener) |
806 |
|
{ |
807 |
36 |
((StructureListener) listeners.elementAt(i)) |
808 |
|
.releaseReferences(svl); |
809 |
|
} |
810 |
|
} |
811 |
|
} |
812 |
|
|
813 |
211 |
if (pdbfiles == null) |
814 |
|
{ |
815 |
206 |
return; |
816 |
|
} |
817 |
|
|
818 |
|
|
819 |
|
|
820 |
|
|
821 |
|
|
822 |
5 |
List<String> pdbs = new ArrayList<>(Arrays.asList(pdbfiles)); |
823 |
|
|
824 |
5 |
StructureListener sl; |
825 |
41 |
for (int i = 0; i < listeners.size(); i++) |
826 |
|
{ |
827 |
36 |
if (listeners.elementAt(i) instanceof StructureListener) |
828 |
|
{ |
829 |
1 |
sl = (StructureListener) listeners.elementAt(i); |
830 |
1 |
for (String pdbfile : sl.getStructureFiles()) |
831 |
|
{ |
832 |
2 |
pdbs.remove(pdbfile); |
833 |
|
} |
834 |
|
} |
835 |
|
} |
836 |
|
|
837 |
|
|
838 |
|
|
839 |
|
|
840 |
|
|
841 |
5 |
if (pdbs.size() > 0) |
842 |
|
{ |
843 |
4 |
List<StructureMapping> tmp = new ArrayList<>(); |
844 |
4 |
for (StructureMapping sm : mappings) |
845 |
|
{ |
846 |
13 |
if (!pdbs.contains(sm.pdbfile)) |
847 |
|
{ |
848 |
4 |
tmp.add(sm); |
849 |
|
} |
850 |
|
} |
851 |
|
|
852 |
4 |
mappings = tmp; |
853 |
|
} |
854 |
|
} |
855 |
|
|
856 |
|
|
857 |
|
|
858 |
|
|
859 |
|
@param |
860 |
|
@param |
861 |
|
@param |
862 |
|
@return |
863 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
864 |
1 |
public String mouseOverStructure(int pdbResNum, String chain,... |
865 |
|
String pdbfile) |
866 |
|
{ |
867 |
1 |
AtomSpec atomSpec = new AtomSpec(pdbfile, chain, pdbResNum, 0); |
868 |
1 |
List<AtomSpec> atoms = Collections.singletonList(atomSpec); |
869 |
1 |
return mouseOverStructure(atoms); |
870 |
|
} |
871 |
|
|
872 |
|
|
873 |
|
|
874 |
|
|
875 |
|
@param |
876 |
|
|
|
|
| 78.6% |
Uncovered Elements: 6 (28) |
Complexity: 7 |
Complexity Density: 0.44 |
|
877 |
1 |
public String mouseOverStructure(List<AtomSpec> atoms)... |
878 |
|
{ |
879 |
1 |
if (listeners == null) |
880 |
|
{ |
881 |
|
|
882 |
0 |
return null; |
883 |
|
} |
884 |
1 |
boolean hasSequenceListener = false; |
885 |
4 |
for (int i = 0; i < listeners.size(); i++) |
886 |
|
{ |
887 |
3 |
if (listeners.elementAt(i) instanceof SequenceListener) |
888 |
|
{ |
889 |
2 |
hasSequenceListener = true; |
890 |
|
} |
891 |
|
} |
892 |
1 |
if (!hasSequenceListener) |
893 |
|
{ |
894 |
0 |
return null; |
895 |
|
} |
896 |
|
|
897 |
1 |
SearchResultsI results = findAlignmentPositionsForStructurePositions( |
898 |
|
atoms); |
899 |
1 |
String result = null; |
900 |
1 |
for (Object li : listeners) |
901 |
|
{ |
902 |
3 |
if (li instanceof SequenceListener) |
903 |
|
{ |
904 |
2 |
String s = ((SequenceListener) li).highlightSequence(results); |
905 |
2 |
if (s != null) |
906 |
|
{ |
907 |
0 |
result = s; |
908 |
|
} |
909 |
|
} |
910 |
|
} |
911 |
1 |
return result; |
912 |
|
} |
913 |
|
|
914 |
|
|
915 |
|
|
916 |
|
|
917 |
|
|
918 |
|
|
919 |
|
@param |
920 |
|
@return |
921 |
|
|
|
|
| 88.9% |
Uncovered Elements: 2 (18) |
Complexity: 5 |
Complexity Density: 0.36 |
|
922 |
1 |
public SearchResultsI findAlignmentPositionsForStructurePositions(... |
923 |
|
List<AtomSpec> atoms) |
924 |
|
{ |
925 |
1 |
SearchResultsI results = new SearchResults(); |
926 |
1 |
for (AtomSpec atom : atoms) |
927 |
|
{ |
928 |
1 |
SequenceI lastseq = null; |
929 |
1 |
int lastipos = -1; |
930 |
1 |
for (StructureMapping sm : mappings) |
931 |
|
{ |
932 |
2 |
if (sm.pdbfile.equals(atom.getPdbFile()) |
933 |
|
&& sm.pdbchain.equals(atom.getChain())) |
934 |
|
{ |
935 |
1 |
int indexpos = sm.getSeqPos(atom.getPdbResNum()); |
936 |
1 |
if (lastipos != indexpos || lastseq != sm.sequence) |
937 |
|
{ |
938 |
1 |
results.addResult(sm.sequence, indexpos, indexpos); |
939 |
1 |
lastipos = indexpos; |
940 |
1 |
lastseq = sm.sequence; |
941 |
|
|
942 |
1 |
for (AlignedCodonFrame acf : seqmappings) |
943 |
|
{ |
944 |
0 |
acf.markMappedRegion(sm.sequence, indexpos, results); |
945 |
|
} |
946 |
|
} |
947 |
|
} |
948 |
|
} |
949 |
|
} |
950 |
1 |
return results; |
951 |
|
} |
952 |
|
|
953 |
|
|
954 |
|
|
955 |
|
|
956 |
|
@param |
957 |
|
|
958 |
|
@param |
959 |
|
|
960 |
|
@param |
961 |
|
|
962 |
|
|
963 |
|
|
|
|
| 0% |
Uncovered Elements: 48 (48) |
Complexity: 15 |
Complexity Density: 0.62 |
|
964 |
0 |
public void mouseOverSequence(SequenceI seq, int indexpos, int seqPos,... |
965 |
|
VamsasSource source) |
966 |
|
{ |
967 |
0 |
boolean hasSequenceListeners = handlingVamsasMo |
968 |
|
|| !seqmappings.isEmpty(); |
969 |
0 |
SearchResultsI results = null; |
970 |
0 |
if (seqPos == -1) |
971 |
|
{ |
972 |
0 |
seqPos = seq.findPosition(indexpos); |
973 |
|
} |
974 |
0 |
for (int i = 0; i < listeners.size(); i++) |
975 |
|
{ |
976 |
0 |
Object listener = listeners.elementAt(i); |
977 |
0 |
if (listener == source) |
978 |
|
{ |
979 |
|
|
980 |
|
|
981 |
0 |
continue; |
982 |
|
} |
983 |
0 |
if (listener instanceof StructureListener) |
984 |
|
{ |
985 |
0 |
highlightStructure((StructureListener) listener, seq, seqPos); |
986 |
|
} |
987 |
|
else |
988 |
|
{ |
989 |
0 |
if (listener instanceof SequenceListener) |
990 |
|
{ |
991 |
0 |
final SequenceListener seqListener = (SequenceListener) listener; |
992 |
0 |
if (hasSequenceListeners |
993 |
|
&& seqListener.getVamsasSource() != source) |
994 |
|
{ |
995 |
0 |
if (relaySeqMappings) |
996 |
|
{ |
997 |
0 |
if (results == null) |
998 |
|
{ |
999 |
0 |
results = MappingUtils.buildSearchResults(seq, seqPos, |
1000 |
|
seqmappings); |
1001 |
|
} |
1002 |
0 |
if (handlingVamsasMo) |
1003 |
|
{ |
1004 |
0 |
results.addResult(seq, seqPos, seqPos); |
1005 |
|
|
1006 |
|
} |
1007 |
0 |
if (!results.isEmpty()) |
1008 |
|
{ |
1009 |
0 |
seqListener.highlightSequence(results); |
1010 |
|
} |
1011 |
|
} |
1012 |
|
} |
1013 |
|
} |
1014 |
0 |
else if (listener instanceof VamsasListener && !handlingVamsasMo) |
1015 |
|
{ |
1016 |
0 |
((VamsasListener) listener).mouseOverSequence(seq, indexpos, |
1017 |
|
source); |
1018 |
|
} |
1019 |
0 |
else if (listener instanceof SecondaryStructureListener) |
1020 |
|
{ |
1021 |
0 |
((SecondaryStructureListener) listener).mouseOverSequence(seq, |
1022 |
|
indexpos, seqPos); |
1023 |
|
} |
1024 |
|
} |
1025 |
|
} |
1026 |
|
} |
1027 |
|
|
1028 |
|
|
1029 |
|
|
1030 |
|
|
1031 |
|
|
1032 |
|
@param |
1033 |
|
@param |
1034 |
|
@param |
1035 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 7 |
Complexity Density: 0.64 |
|
1036 |
0 |
public void highlightStructure(StructureListener sl, SequenceI seq,... |
1037 |
|
int... positions) |
1038 |
|
{ |
1039 |
0 |
if (!sl.isListeningFor(seq)) |
1040 |
|
{ |
1041 |
0 |
return; |
1042 |
|
} |
1043 |
0 |
int atomNo; |
1044 |
0 |
List<AtomSpec> atoms = new ArrayList<>(); |
1045 |
0 |
for (StructureMapping sm : mappings) |
1046 |
|
{ |
1047 |
0 |
if (sm.sequence == seq || sm.sequence == seq.getDatasetSequence() |
1048 |
|
|| (sm.sequence.getDatasetSequence() != null && sm.sequence |
1049 |
|
.getDatasetSequence() == seq.getDatasetSequence())) |
1050 |
|
{ |
1051 |
0 |
for (int index : positions) |
1052 |
|
{ |
1053 |
0 |
atomNo = sm.getAtomNum(index); |
1054 |
|
|
1055 |
0 |
if (atomNo > 0) |
1056 |
|
{ |
1057 |
0 |
atoms.add(new AtomSpec(sm.pdbfile, sm.pdbchain, |
1058 |
|
sm.getPDBResNum(index), atomNo)); |
1059 |
|
} |
1060 |
|
} |
1061 |
|
} |
1062 |
|
} |
1063 |
0 |
sl.highlightAtoms(atoms); |
1064 |
|
} |
1065 |
|
|
1066 |
|
|
1067 |
|
|
1068 |
|
|
1069 |
|
|
1070 |
|
boolean handlingVamsasMo = false; |
1071 |
|
|
1072 |
|
long lastmsg = 0; |
1073 |
|
|
1074 |
|
|
1075 |
|
|
1076 |
|
|
1077 |
|
@param |
1078 |
|
@param |
1079 |
|
|
1080 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
1081 |
0 |
public void mouseOverVamsasSequence(SequenceI sequenceI, int position,... |
1082 |
|
VamsasSource source) |
1083 |
|
{ |
1084 |
0 |
handlingVamsasMo = true; |
1085 |
0 |
long msg = sequenceI.hashCode() * (1 + position); |
1086 |
0 |
if (lastmsg != msg) |
1087 |
|
{ |
1088 |
0 |
lastmsg = msg; |
1089 |
0 |
mouseOverSequence(sequenceI, position, -1, source); |
1090 |
|
} |
1091 |
0 |
handlingVamsasMo = false; |
1092 |
|
} |
1093 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1094 |
0 |
public Annotation[] colourSequenceFromStructure(SequenceI seq,... |
1095 |
|
String pdbid) |
1096 |
|
{ |
1097 |
0 |
return null; |
1098 |
|
|
1099 |
|
|
1100 |
|
|
1101 |
|
|
1102 |
|
|
1103 |
|
|
1104 |
|
|
1105 |
|
|
1106 |
|
|
1107 |
|
|
1108 |
|
|
1109 |
|
|
1110 |
|
|
1111 |
|
|
1112 |
|
|
1113 |
|
|
1114 |
|
|
1115 |
|
|
1116 |
|
|
1117 |
|
|
1118 |
|
|
1119 |
|
|
1120 |
|
|
1121 |
|
|
1122 |
|
|
1123 |
|
|
1124 |
|
|
1125 |
|
|
1126 |
|
|
1127 |
|
} |
1128 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
1129 |
0 |
public void structureSelectionChanged()... |
1130 |
|
{ |
1131 |
|
} |
1132 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
1133 |
0 |
public void sequenceSelectionChanged()... |
1134 |
|
{ |
1135 |
|
} |
1136 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
1137 |
1291 |
public void sequenceColoursChanged(Object source)... |
1138 |
|
{ |
1139 |
1291 |
StructureListener sl; |
1140 |
16057 |
for (int i = 0; i < listeners.size(); i++) |
1141 |
|
{ |
1142 |
14766 |
if (listeners.elementAt(i) instanceof StructureListener) |
1143 |
|
{ |
1144 |
400 |
sl = (StructureListener) listeners.elementAt(i); |
1145 |
400 |
sl.updateColours(source); |
1146 |
|
} |
1147 |
|
} |
1148 |
|
} |
1149 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
1150 |
30 |
public StructureMapping[] getMapping(String pdbfile)... |
1151 |
|
{ |
1152 |
30 |
List<StructureMapping> tmp = new ArrayList<>(); |
1153 |
30 |
for (StructureMapping sm : mappings) |
1154 |
|
{ |
1155 |
67 |
if (sm.pdbfile.equals(pdbfile)) |
1156 |
|
{ |
1157 |
33 |
tmp.add(sm); |
1158 |
|
} |
1159 |
|
} |
1160 |
30 |
return tmp.toArray(new StructureMapping[tmp.size()]); |
1161 |
|
} |
1162 |
|
|
1163 |
|
|
1164 |
|
|
1165 |
|
|
1166 |
|
|
1167 |
|
@param |
1168 |
|
@param |
1169 |
|
@return |
1170 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 6 |
Complexity Density: 0.55 |
|
1171 |
0 |
public String printMappings(String pdbfile, List<SequenceI> seqs)... |
1172 |
|
{ |
1173 |
0 |
if (pdbfile == null || seqs == null || seqs.isEmpty()) |
1174 |
|
{ |
1175 |
0 |
return ""; |
1176 |
|
} |
1177 |
|
|
1178 |
0 |
StringBuilder sb = new StringBuilder(64); |
1179 |
0 |
for (StructureMapping sm : mappings) |
1180 |
|
{ |
1181 |
0 |
if (Platform.pathEquals(sm.pdbfile, pdbfile) |
1182 |
|
&& seqs.contains(sm.sequence)) |
1183 |
|
{ |
1184 |
0 |
sb.append(sm.mappingDetails); |
1185 |
0 |
sb.append(NEWLINE); |
1186 |
|
|
1187 |
0 |
sb.append("====================="); |
1188 |
0 |
sb.append(NEWLINE); |
1189 |
|
} |
1190 |
|
} |
1191 |
0 |
sb.append(NEWLINE); |
1192 |
|
|
1193 |
0 |
return sb.toString(); |
1194 |
|
} |
1195 |
|
|
1196 |
|
|
1197 |
|
|
1198 |
|
|
1199 |
|
@param |
1200 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 4 |
Complexity Density: 1 |
|
1201 |
15 |
public void deregisterMapping(AlignedCodonFrame acf)... |
1202 |
|
{ |
1203 |
15 |
if (acf != null) |
1204 |
|
{ |
1205 |
15 |
boolean removed = seqmappings.remove(acf); |
1206 |
15 |
if (removed && seqmappings.isEmpty()) |
1207 |
|
{ |
1208 |
1 |
System.out.println("All mappings removed"); |
1209 |
|
} |
1210 |
|
} |
1211 |
|
} |
1212 |
|
|
1213 |
|
|
1214 |
|
|
1215 |
|
|
1216 |
|
@param |
1217 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1218 |
327 |
public void registerMappings(List<AlignedCodonFrame> mappings)... |
1219 |
|
{ |
1220 |
327 |
if (mappings != null) |
1221 |
|
{ |
1222 |
327 |
for (AlignedCodonFrame acf : mappings) |
1223 |
|
{ |
1224 |
86 |
registerMapping(acf); |
1225 |
|
} |
1226 |
|
} |
1227 |
|
} |
1228 |
|
|
1229 |
|
|
1230 |
|
|
1231 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 3 |
Complexity Density: 1 |
|
1232 |
95 |
public void registerMapping(AlignedCodonFrame acf)... |
1233 |
|
{ |
1234 |
95 |
if (acf != null) |
1235 |
|
{ |
1236 |
95 |
if (!seqmappings.contains(acf)) |
1237 |
|
{ |
1238 |
27 |
seqmappings.add(acf); |
1239 |
|
} |
1240 |
|
} |
1241 |
|
} |
1242 |
|
|
1243 |
|
|
1244 |
|
|
1245 |
|
|
1246 |
|
|
|
|
| 75% |
Uncovered Elements: 8 (32) |
Complexity: 9 |
Complexity Density: 0.56 |
|
1247 |
40 |
public void resetAll()... |
1248 |
|
{ |
1249 |
40 |
if (mappings != null) |
1250 |
|
{ |
1251 |
40 |
mappings.clear(); |
1252 |
|
} |
1253 |
40 |
if (seqmappings != null) |
1254 |
|
{ |
1255 |
40 |
seqmappings.clear(); |
1256 |
|
} |
1257 |
40 |
if (sel_listeners != null) |
1258 |
|
{ |
1259 |
40 |
sel_listeners.clear(); |
1260 |
|
} |
1261 |
40 |
if (listeners != null) |
1262 |
|
{ |
1263 |
40 |
listeners.clear(); |
1264 |
|
} |
1265 |
40 |
if (commandListeners != null) |
1266 |
|
{ |
1267 |
40 |
commandListeners.clear(); |
1268 |
|
} |
1269 |
40 |
if (view_listeners != null) |
1270 |
|
{ |
1271 |
40 |
view_listeners.clear(); |
1272 |
|
} |
1273 |
40 |
if (pdbFileNameId != null) |
1274 |
|
{ |
1275 |
40 |
pdbFileNameId.clear(); |
1276 |
|
} |
1277 |
40 |
if (pdbIdFileName != null) |
1278 |
|
{ |
1279 |
40 |
pdbIdFileName.clear(); |
1280 |
|
} |
1281 |
|
} |
1282 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
1283 |
267 |
public void addSelectionListener(SelectionListener selecter)... |
1284 |
|
{ |
1285 |
267 |
if (!sel_listeners.contains(selecter)) |
1286 |
|
{ |
1287 |
267 |
sel_listeners.add(selecter); |
1288 |
|
} |
1289 |
|
} |
1290 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
1291 |
204 |
public void removeSelectionListener(SelectionListener toremove)... |
1292 |
|
{ |
1293 |
204 |
if (sel_listeners.contains(toremove)) |
1294 |
|
{ |
1295 |
102 |
sel_listeners.remove(toremove); |
1296 |
|
} |
1297 |
|
} |
1298 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1299 |
21 |
public synchronized void sendSelection(... |
1300 |
|
jalview.datamodel.SequenceGroup selection, |
1301 |
|
jalview.datamodel.ColumnSelection colsel, HiddenColumns hidden, |
1302 |
|
SelectionSource source) |
1303 |
|
{ |
1304 |
21 |
for (SelectionListener slis : sel_listeners) |
1305 |
|
{ |
1306 |
105 |
if (slis != source) |
1307 |
|
{ |
1308 |
105 |
slis.selection(selection, colsel, hidden, source); |
1309 |
|
} |
1310 |
|
} |
1311 |
|
} |
1312 |
|
|
1313 |
|
Vector<AlignmentViewPanelListener> view_listeners = new Vector<>(); |
1314 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 5 |
Complexity Density: 0.71 |
|
1315 |
0 |
public synchronized void sendViewPosition(... |
1316 |
|
jalview.api.AlignmentViewPanel source, int startRes, int endRes, |
1317 |
|
int startSeq, int endSeq) |
1318 |
|
{ |
1319 |
|
|
1320 |
0 |
if (view_listeners != null && view_listeners.size() > 0) |
1321 |
|
{ |
1322 |
0 |
Enumeration<AlignmentViewPanelListener> listeners = view_listeners |
1323 |
|
.elements(); |
1324 |
0 |
while (listeners.hasMoreElements()) |
1325 |
|
{ |
1326 |
0 |
AlignmentViewPanelListener slis = listeners.nextElement(); |
1327 |
0 |
if (slis != source) |
1328 |
|
{ |
1329 |
0 |
slis.viewPosition(startRes, endRes, startSeq, endSeq, source); |
1330 |
|
} |
1331 |
0 |
; |
1332 |
|
} |
1333 |
|
} |
1334 |
|
} |
1335 |
|
|
1336 |
|
|
1337 |
|
|
1338 |
|
|
1339 |
|
@param |
1340 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
1341 |
0 |
public static void release(StructureSelectionManagerProvider jalviewLite)... |
1342 |
|
{ |
1343 |
|
|
1344 |
|
{ |
1345 |
0 |
if (instances == null) |
1346 |
|
{ |
1347 |
0 |
return; |
1348 |
|
} |
1349 |
0 |
StructureSelectionManager mnger = (instances.get(jalviewLite)); |
1350 |
0 |
if (mnger != null) |
1351 |
|
{ |
1352 |
0 |
instances.remove(jalviewLite); |
1353 |
0 |
try |
1354 |
|
{ |
1355 |
|
|
1356 |
|
|
1357 |
|
|
1358 |
|
|
1359 |
|
} catch (Throwable x) |
1360 |
|
{ |
1361 |
|
} |
1362 |
|
} |
1363 |
|
} |
1364 |
|
} |
1365 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
1366 |
290 |
public void registerPDBEntry(PDBEntry pdbentry)... |
1367 |
|
{ |
1368 |
290 |
if (pdbentry.getFile() != null |
1369 |
|
&& pdbentry.getFile().trim().length() > 0) |
1370 |
|
{ |
1371 |
70 |
registerPDBFile(pdbentry.getId(), pdbentry.getFile()); |
1372 |
|
} |
1373 |
|
} |
1374 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
1375 |
6 |
public void addCommandListener(CommandListener cl)... |
1376 |
|
{ |
1377 |
6 |
if (!commandListeners.contains(cl)) |
1378 |
|
{ |
1379 |
6 |
commandListeners.add(cl); |
1380 |
|
} |
1381 |
|
} |
1382 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1383 |
0 |
public boolean hasCommandListener(CommandListener cl)... |
1384 |
|
{ |
1385 |
0 |
return this.commandListeners.contains(cl); |
1386 |
|
} |
1387 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1388 |
102 |
public boolean removeCommandListener(CommandListener l)... |
1389 |
|
{ |
1390 |
102 |
return commandListeners.remove(l); |
1391 |
|
} |
1392 |
|
|
1393 |
|
|
1394 |
|
|
1395 |
|
|
1396 |
|
|
1397 |
|
@param |
1398 |
|
|
1399 |
|
@param |
1400 |
|
|
1401 |
|
@param |
1402 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1403 |
0 |
public void commandPerformed(CommandI command, boolean undo,... |
1404 |
|
VamsasSource source) |
1405 |
|
{ |
1406 |
0 |
for (CommandListener listener : commandListeners) |
1407 |
|
{ |
1408 |
0 |
listener.mirrorCommand(command, undo, this, source); |
1409 |
|
} |
1410 |
|
} |
1411 |
|
|
1412 |
|
|
1413 |
|
|
1414 |
|
|
1415 |
|
|
1416 |
|
|
1417 |
|
@param |
1418 |
|
@param |
1419 |
|
@param |
1420 |
|
@param |
1421 |
|
@return |
1422 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
1423 |
0 |
public CommandI mapCommand(CommandI command, boolean undo,... |
1424 |
|
final AlignmentI mapTo, char gapChar) |
1425 |
|
{ |
1426 |
0 |
if (command instanceof EditCommand) |
1427 |
|
{ |
1428 |
0 |
return MappingUtils.mapEditCommand((EditCommand) command, undo, mapTo, |
1429 |
|
gapChar, seqmappings); |
1430 |
|
} |
1431 |
0 |
else if (command instanceof OrderCommand) |
1432 |
|
{ |
1433 |
0 |
return MappingUtils.mapOrderCommand((OrderCommand) command, undo, |
1434 |
|
mapTo, seqmappings); |
1435 |
|
} |
1436 |
0 |
return null; |
1437 |
|
} |
1438 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1439 |
15 |
public List<AlignedCodonFrame> getSequenceMappings()... |
1440 |
|
{ |
1441 |
15 |
return seqmappings; |
1442 |
|
} |
1443 |
|
|
1444 |
|
} |