1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
package jalview.gui; |
23 |
|
|
24 |
|
import jalview.api.structures.JalviewStructureDisplayI; |
25 |
|
import jalview.bin.Cache; |
26 |
|
import jalview.bin.Jalview; |
27 |
|
import jalview.datamodel.DBRefEntry; |
28 |
|
import jalview.datamodel.DBRefSource; |
29 |
|
import jalview.datamodel.PDBEntry; |
30 |
|
import jalview.datamodel.SequenceI; |
31 |
|
import jalview.fts.api.FTSData; |
32 |
|
import jalview.fts.api.FTSDataColumnI; |
33 |
|
import jalview.fts.api.FTSRestClientI; |
34 |
|
import jalview.fts.core.FTSRestRequest; |
35 |
|
import jalview.fts.core.FTSRestResponse; |
36 |
|
import jalview.fts.service.pdb.PDBFTSRestClient; |
37 |
|
import jalview.io.DataSourceType; |
38 |
|
import jalview.jbgui.GStructureChooser; |
39 |
|
import jalview.structure.StructureMapping; |
40 |
|
import jalview.structure.StructureSelectionManager; |
41 |
|
import jalview.util.MessageManager; |
42 |
|
import jalview.ws.DBRefFetcher; |
43 |
|
import jalview.ws.sifts.SiftsSettings; |
44 |
|
|
45 |
|
import java.awt.event.ItemEvent; |
46 |
|
import java.util.ArrayList; |
47 |
|
import java.util.Collection; |
48 |
|
import java.util.HashSet; |
49 |
|
import java.util.LinkedHashSet; |
50 |
|
import java.util.List; |
51 |
|
import java.util.Objects; |
52 |
|
import java.util.Set; |
53 |
|
import java.util.Vector; |
54 |
|
|
55 |
|
import javax.swing.JCheckBox; |
56 |
|
import javax.swing.JComboBox; |
57 |
|
import javax.swing.JLabel; |
58 |
|
import javax.swing.JTable; |
59 |
|
import javax.swing.SwingUtilities; |
60 |
|
import javax.swing.table.AbstractTableModel; |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
@author |
66 |
|
|
67 |
|
|
68 |
|
@SuppressWarnings("serial") |
|
|
| 26.2% |
Uncovered Elements: 493 (668) |
Complexity: 147 |
Complexity Density: 0.32 |
|
69 |
|
public class StructureChooser extends GStructureChooser |
70 |
|
implements IProgressIndicator |
71 |
|
{ |
72 |
|
private static final String AUTOSUPERIMPOSE = "AUTOSUPERIMPOSE"; |
73 |
|
|
74 |
|
private static int MAX_QLENGTH = 7820; |
75 |
|
|
76 |
|
private SequenceI selectedSequence; |
77 |
|
|
78 |
|
private SequenceI[] selectedSequences; |
79 |
|
|
80 |
|
private IProgressIndicator progressIndicator; |
81 |
|
|
82 |
|
private Collection<FTSData> discoveredStructuresSet; |
83 |
|
|
84 |
|
private FTSRestRequest lastPdbRequest; |
85 |
|
|
86 |
|
private FTSRestClientI pdbRestCleint; |
87 |
|
|
88 |
|
private String selectedPdbFileName; |
89 |
|
|
90 |
|
private boolean isValidPBDEntry; |
91 |
|
|
92 |
|
private boolean cachedPDBExists; |
93 |
|
|
94 |
|
private static StructureViewer lastTargetedView = null; |
95 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
96 |
1 |
public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,... |
97 |
|
AlignmentPanel ap) |
98 |
|
{ |
99 |
1 |
this.ap = ap; |
100 |
1 |
this.selectedSequence = selectedSeq; |
101 |
1 |
this.selectedSequences = selectedSeqs; |
102 |
1 |
this.progressIndicator = (ap == null) ? null : ap.alignFrame; |
103 |
1 |
init(); |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
109 |
1 |
protected void init()... |
110 |
|
{ |
111 |
1 |
if (!Jalview.isHeadlessMode()) |
112 |
|
{ |
113 |
1 |
progressBar = new ProgressBar(this.statusPanel, this.statusBar); |
114 |
|
} |
115 |
|
|
116 |
1 |
chk_superpose.setSelected(Cache.getDefault(AUTOSUPERIMPOSE, true)); |
117 |
|
|
118 |
|
|
119 |
1 |
populateFilterComboBox(true, cachedPDBExists); |
120 |
1 |
Thread discoverPDBStructuresThread = new Thread(new Runnable() |
121 |
|
{ |
|
|
| 72.7% |
Uncovered Elements: 3 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
|
122 |
1 |
@Override... |
123 |
|
public void run() |
124 |
|
{ |
125 |
1 |
long startTime = System.currentTimeMillis(); |
126 |
1 |
updateProgressIndicator(MessageManager |
127 |
|
.getString("status.loading_cached_pdb_entries"), startTime); |
128 |
1 |
loadLocalCachedPDBEntries(); |
129 |
1 |
updateProgressIndicator(null, startTime); |
130 |
1 |
updateProgressIndicator(MessageManager.getString( |
131 |
|
"status.searching_for_pdb_structures"), startTime); |
132 |
1 |
fetchStructuresMetaData(); |
133 |
|
|
134 |
1 |
populateFilterComboBox(isStructuresDiscovered(), cachedPDBExists); |
135 |
1 |
discoverStructureViews(); |
136 |
0 |
updateProgressIndicator(null, startTime); |
137 |
0 |
mainFrame.setVisible(true); |
138 |
0 |
updateCurrentView(); |
139 |
|
} |
140 |
|
}); |
141 |
1 |
discoverPDBStructuresThread.start(); |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
|
|
| 34.5% |
Uncovered Elements: 19 (29) |
Complexity: 9 |
Complexity Density: 0.53 |
|
149 |
1 |
private void discoverStructureViews()... |
150 |
|
{ |
151 |
1 |
if (Desktop.instance != null) |
152 |
|
{ |
153 |
1 |
targetView.removeAllItems(); |
154 |
1 |
if (lastTargetedView != null && !lastTargetedView.isVisible()) |
155 |
|
{ |
156 |
0 |
lastTargetedView = null; |
157 |
|
} |
158 |
1 |
int linkedViewsAt = 0; |
159 |
1 |
for (StructureViewerBase view : Desktop.instance |
160 |
|
.getStructureViewers(null, null)) |
161 |
|
{ |
162 |
1 |
StructureViewer viewHandler = (lastTargetedView != null |
163 |
|
&& lastTargetedView.sview == view) ? lastTargetedView |
164 |
|
: StructureViewer.reconfigure(view); |
165 |
|
|
166 |
0 |
if (view.isLinkedWith(ap)) |
167 |
|
{ |
168 |
0 |
targetView.insertItemAt(viewHandler, |
169 |
|
linkedViewsAt++); |
170 |
|
} |
171 |
|
else |
172 |
|
{ |
173 |
0 |
targetView.addItem(viewHandler); |
174 |
|
} |
175 |
|
} |
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
0 |
targetView.setVisible(false); |
181 |
0 |
if (targetView.getItemCount() > 0) |
182 |
|
{ |
183 |
0 |
targetView.setVisible(true); |
184 |
0 |
if (lastTargetedView != null) |
185 |
|
{ |
186 |
0 |
targetView.setSelectedItem(lastTargetedView); |
187 |
|
} |
188 |
|
else |
189 |
|
{ |
190 |
0 |
targetView.setSelectedIndex(0); |
191 |
|
} |
192 |
|
} |
193 |
0 |
btn_add.setVisible(targetView.isVisible()); |
194 |
|
} |
195 |
|
} |
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
@param |
201 |
|
|
202 |
|
@param |
203 |
|
|
204 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
205 |
3 |
protected void updateProgressIndicator(String message, long id)... |
206 |
|
{ |
207 |
3 |
if (progressIndicator != null) |
208 |
|
{ |
209 |
0 |
progressIndicator.setProgressBar(message, id); |
210 |
|
} |
211 |
|
} |
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
|
|
| 76.2% |
Uncovered Elements: 10 (42) |
Complexity: 7 |
Complexity Density: 0.19 |
|
217 |
1 |
void fetchStructuresMetaData()... |
218 |
|
{ |
219 |
1 |
long startTime = System.currentTimeMillis(); |
220 |
1 |
pdbRestCleint = PDBFTSRestClient.getInstance(); |
221 |
1 |
Collection<FTSDataColumnI> wantedFields = pdbDocFieldPrefs |
222 |
|
.getStructureSummaryFields(); |
223 |
|
|
224 |
1 |
discoveredStructuresSet = new LinkedHashSet<>(); |
225 |
1 |
HashSet<String> errors = new HashSet<>(); |
226 |
1 |
for (SequenceI seq : selectedSequences) |
227 |
|
{ |
228 |
1 |
FTSRestRequest pdbRequest = new FTSRestRequest(); |
229 |
1 |
pdbRequest.setAllowEmptySeq(false); |
230 |
1 |
pdbRequest.setResponseSize(500); |
231 |
1 |
pdbRequest.setFieldToSearchBy("("); |
232 |
1 |
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption |
233 |
|
.getSelectedItem()); |
234 |
1 |
pdbRequest.setFieldToSortBy(selectedFilterOpt.getValue(), |
235 |
|
!chk_invertFilter.isSelected()); |
236 |
1 |
pdbRequest.setWantedFields(wantedFields); |
237 |
1 |
pdbRequest.setSearchTerm(buildQuery(seq) + ")"); |
238 |
1 |
pdbRequest.setAssociatedSequence(seq); |
239 |
1 |
FTSRestResponse resultList; |
240 |
1 |
try |
241 |
|
{ |
242 |
1 |
resultList = pdbRestCleint.executeRequest(pdbRequest); |
243 |
|
} catch (Exception e) |
244 |
|
{ |
245 |
1 |
e.printStackTrace(); |
246 |
1 |
errors.add(e.getMessage()); |
247 |
1 |
continue; |
248 |
|
} |
249 |
0 |
lastPdbRequest = pdbRequest; |
250 |
0 |
if (resultList.getSearchSummary() != null |
251 |
|
&& !resultList.getSearchSummary().isEmpty()) |
252 |
|
{ |
253 |
0 |
discoveredStructuresSet.addAll(resultList.getSearchSummary()); |
254 |
|
} |
255 |
|
} |
256 |
|
|
257 |
1 |
int noOfStructuresFound = 0; |
258 |
1 |
String totalTime = (System.currentTimeMillis() - startTime) |
259 |
|
+ " milli secs"; |
260 |
1 |
if (discoveredStructuresSet != null |
261 |
|
&& !discoveredStructuresSet.isEmpty()) |
262 |
|
{ |
263 |
0 |
getResultTable().setModel(FTSRestResponse |
264 |
|
.getTableModel(lastPdbRequest, discoveredStructuresSet)); |
265 |
0 |
noOfStructuresFound = discoveredStructuresSet.size(); |
266 |
0 |
mainFrame.setTitle(MessageManager.formatMessage( |
267 |
|
"label.structure_chooser_no_of_structures", |
268 |
|
noOfStructuresFound, totalTime)); |
269 |
|
} |
270 |
|
else |
271 |
|
{ |
272 |
1 |
mainFrame.setTitle(MessageManager |
273 |
|
.getString("label.structure_chooser_manual_association")); |
274 |
1 |
if (errors.size() > 0) |
275 |
|
{ |
276 |
1 |
StringBuilder errorMsg = new StringBuilder(); |
277 |
1 |
for (String error : errors) |
278 |
|
{ |
279 |
1 |
errorMsg.append(error).append("\n"); |
280 |
|
} |
281 |
1 |
JvOptionPane.showMessageDialog(this, errorMsg.toString(), |
282 |
|
MessageManager.getString("label.pdb_web-service_error"), |
283 |
|
JvOptionPane.ERROR_MESSAGE); |
284 |
|
} |
285 |
|
} |
286 |
|
} |
287 |
|
|
|
|
| 61.5% |
Uncovered Elements: 5 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
288 |
1 |
protected void loadLocalCachedPDBEntries()... |
289 |
|
{ |
290 |
1 |
ArrayList<CachedPDB> entries = new ArrayList<>(); |
291 |
1 |
for (SequenceI seq : selectedSequences) |
292 |
|
{ |
293 |
1 |
if (seq.getDatasetSequence() != null |
294 |
|
&& seq.getDatasetSequence().getAllPDBEntries() != null) |
295 |
|
{ |
296 |
1 |
for (PDBEntry pdbEntry : seq.getDatasetSequence() |
297 |
|
.getAllPDBEntries()) |
298 |
|
{ |
299 |
0 |
if (pdbEntry.getFile() != null) |
300 |
|
{ |
301 |
0 |
entries.add(new CachedPDB(seq, pdbEntry)); |
302 |
|
} |
303 |
|
} |
304 |
|
} |
305 |
|
} |
306 |
1 |
cachedPDBExists = !entries.isEmpty(); |
307 |
1 |
PDBEntryTableModel tableModelx = new PDBEntryTableModel(entries); |
308 |
1 |
tbl_local_pdb.setModel(tableModelx); |
309 |
|
} |
310 |
|
|
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
@param |
315 |
|
|
316 |
|
@return |
317 |
|
|
318 |
|
|
|
|
| 90.6% |
Uncovered Elements: 5 (53) |
Complexity: 14 |
Complexity Density: 0.4 |
|
319 |
5 |
static String buildQuery(SequenceI seq)... |
320 |
|
{ |
321 |
5 |
boolean isPDBRefsFound = false; |
322 |
5 |
boolean isUniProtRefsFound = false; |
323 |
5 |
StringBuilder queryBuilder = new StringBuilder(); |
324 |
5 |
Set<String> seqRefs = new LinkedHashSet<>(); |
325 |
|
|
326 |
5 |
if (seq.getAllPDBEntries() != null |
327 |
|
&& queryBuilder.length() < MAX_QLENGTH) |
328 |
|
{ |
329 |
5 |
for (PDBEntry entry : seq.getAllPDBEntries()) |
330 |
|
{ |
331 |
2 |
if (isValidSeqName(entry.getId())) |
332 |
|
{ |
333 |
2 |
queryBuilder.append("pdb_id:").append(entry.getId().toLowerCase()) |
334 |
|
.append(" OR "); |
335 |
2 |
isPDBRefsFound = true; |
336 |
|
} |
337 |
|
} |
338 |
|
} |
339 |
|
|
340 |
5 |
if (seq.getDBRefs() != null && seq.getDBRefs().length != 0) |
341 |
|
{ |
342 |
4 |
for (DBRefEntry dbRef : seq.getDBRefs()) |
343 |
|
{ |
344 |
18 |
if (isValidSeqName(getDBRefId(dbRef)) |
345 |
|
&& queryBuilder.length() < MAX_QLENGTH) |
346 |
|
{ |
347 |
18 |
if (dbRef.getSource().equalsIgnoreCase(DBRefSource.UNIPROT)) |
348 |
|
{ |
349 |
1 |
queryBuilder.append("uniprot_accession:") |
350 |
|
.append(getDBRefId(dbRef)).append(" OR "); |
351 |
1 |
queryBuilder.append("uniprot_id:").append(getDBRefId(dbRef)) |
352 |
|
.append(" OR "); |
353 |
1 |
isUniProtRefsFound = true; |
354 |
|
} |
355 |
17 |
else if (dbRef.getSource().equalsIgnoreCase(DBRefSource.PDB)) |
356 |
|
{ |
357 |
|
|
358 |
1 |
queryBuilder.append("pdb_id:") |
359 |
|
.append(getDBRefId(dbRef).toLowerCase()).append(" OR "); |
360 |
1 |
isPDBRefsFound = true; |
361 |
|
} |
362 |
|
else |
363 |
|
{ |
364 |
16 |
seqRefs.add(getDBRefId(dbRef)); |
365 |
|
} |
366 |
|
} |
367 |
|
} |
368 |
|
} |
369 |
|
|
370 |
5 |
if (!isPDBRefsFound && !isUniProtRefsFound) |
371 |
|
{ |
372 |
2 |
String seqName = seq.getName(); |
373 |
2 |
seqName = sanitizeSeqName(seqName); |
374 |
2 |
String[] names = seqName.toLowerCase().split("\\|"); |
375 |
2 |
for (String name : names) |
376 |
|
{ |
377 |
|
|
378 |
8 |
name.trim(); |
379 |
8 |
if (isValidSeqName(name)) |
380 |
|
{ |
381 |
4 |
seqRefs.add(name); |
382 |
|
} |
383 |
|
} |
384 |
|
|
385 |
2 |
for (String seqRef : seqRefs) |
386 |
|
{ |
387 |
6 |
queryBuilder.append("text:").append(seqRef).append(" OR "); |
388 |
|
} |
389 |
|
} |
390 |
|
|
391 |
5 |
int endIndex = queryBuilder.lastIndexOf(" OR "); |
392 |
5 |
if (queryBuilder.toString().length() < 6) |
393 |
|
{ |
394 |
0 |
return null; |
395 |
|
} |
396 |
5 |
String query = queryBuilder.toString().substring(0, endIndex); |
397 |
5 |
return query; |
398 |
|
} |
399 |
|
|
400 |
|
|
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
@param |
405 |
|
@return |
406 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
407 |
6 |
static String sanitizeSeqName(String seqName)... |
408 |
|
{ |
409 |
6 |
Objects.requireNonNull(seqName); |
410 |
6 |
return seqName.replaceAll("\\[\\d*\\]", "") |
411 |
|
.replaceAll("[^\\dA-Za-z|_]", "").replaceAll("\\s+", "+"); |
412 |
|
} |
413 |
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
@param |
419 |
|
@return |
420 |
|
|
|
|
| 87.5% |
Uncovered Elements: 2 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
421 |
28 |
static boolean isValidSeqName(String seqName)... |
422 |
|
{ |
423 |
|
|
424 |
28 |
String ignoreList = "pdb,uniprot,swiss-prot"; |
425 |
28 |
if (seqName.length() < 3) |
426 |
|
{ |
427 |
2 |
return false; |
428 |
|
} |
429 |
26 |
if (seqName.contains(":")) |
430 |
|
{ |
431 |
0 |
return false; |
432 |
|
} |
433 |
26 |
seqName = seqName.toLowerCase(); |
434 |
26 |
for (String ignoredEntry : ignoreList.split(",")) |
435 |
|
{ |
436 |
74 |
if (seqName.contains(ignoredEntry)) |
437 |
|
{ |
438 |
2 |
return false; |
439 |
|
} |
440 |
|
} |
441 |
24 |
return true; |
442 |
|
} |
443 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
444 |
37 |
static String getDBRefId(DBRefEntry dbRef)... |
445 |
|
{ |
446 |
37 |
String ref = dbRef.getAccessionId().replaceAll("GO:", ""); |
447 |
37 |
return ref; |
448 |
|
} |
449 |
|
|
450 |
|
|
451 |
|
|
452 |
|
|
453 |
|
@param |
454 |
|
|
455 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
456 |
0 |
void filterResultSet(final String fieldToFilterBy)... |
457 |
|
{ |
458 |
0 |
Thread filterThread = new Thread(new Runnable() |
459 |
|
{ |
|
|
| 0% |
Uncovered Elements: 63 (63) |
Complexity: 7 |
Complexity Density: 0.13 |
|
460 |
0 |
@Override... |
461 |
|
public void run() |
462 |
|
{ |
463 |
0 |
long startTime = System.currentTimeMillis(); |
464 |
0 |
pdbRestCleint = PDBFTSRestClient.getInstance(); |
465 |
0 |
lbl_loading.setVisible(true); |
466 |
0 |
Collection<FTSDataColumnI> wantedFields = pdbDocFieldPrefs |
467 |
|
.getStructureSummaryFields(); |
468 |
0 |
Collection<FTSData> filteredResponse = new HashSet<>(); |
469 |
0 |
HashSet<String> errors = new HashSet<>(); |
470 |
|
|
471 |
0 |
for (SequenceI seq : selectedSequences) |
472 |
|
{ |
473 |
0 |
FTSRestRequest pdbRequest = new FTSRestRequest(); |
474 |
0 |
if (fieldToFilterBy.equalsIgnoreCase("uniprot_coverage")) |
475 |
|
{ |
476 |
0 |
pdbRequest.setAllowEmptySeq(false); |
477 |
0 |
pdbRequest.setResponseSize(1); |
478 |
0 |
pdbRequest.setFieldToSearchBy("("); |
479 |
0 |
pdbRequest.setSearchTerm(buildQuery(seq) + ")"); |
480 |
0 |
pdbRequest.setWantedFields(wantedFields); |
481 |
0 |
pdbRequest.setAssociatedSequence(seq); |
482 |
0 |
pdbRequest.setFacet(true); |
483 |
0 |
pdbRequest.setFacetPivot(fieldToFilterBy + ",entry_entity"); |
484 |
0 |
pdbRequest.setFacetPivotMinCount(1); |
485 |
|
} |
486 |
|
else |
487 |
|
{ |
488 |
0 |
pdbRequest.setAllowEmptySeq(false); |
489 |
0 |
pdbRequest.setResponseSize(1); |
490 |
0 |
pdbRequest.setFieldToSearchBy("("); |
491 |
0 |
pdbRequest.setFieldToSortBy(fieldToFilterBy, |
492 |
|
!chk_invertFilter.isSelected()); |
493 |
0 |
pdbRequest.setSearchTerm(buildQuery(seq) + ")"); |
494 |
0 |
pdbRequest.setWantedFields(wantedFields); |
495 |
0 |
pdbRequest.setAssociatedSequence(seq); |
496 |
|
} |
497 |
0 |
FTSRestResponse resultList; |
498 |
0 |
try |
499 |
|
{ |
500 |
0 |
resultList = pdbRestCleint.executeRequest(pdbRequest); |
501 |
|
} catch (Exception e) |
502 |
|
{ |
503 |
0 |
e.printStackTrace(); |
504 |
0 |
errors.add(e.getMessage()); |
505 |
0 |
continue; |
506 |
|
} |
507 |
0 |
lastPdbRequest = pdbRequest; |
508 |
0 |
if (resultList.getSearchSummary() != null |
509 |
|
&& !resultList.getSearchSummary().isEmpty()) |
510 |
|
{ |
511 |
0 |
filteredResponse.addAll(resultList.getSearchSummary()); |
512 |
|
} |
513 |
|
} |
514 |
|
|
515 |
0 |
String totalTime = (System.currentTimeMillis() - startTime) |
516 |
|
+ " milli secs"; |
517 |
0 |
if (!filteredResponse.isEmpty()) |
518 |
|
{ |
519 |
0 |
final int filterResponseCount = filteredResponse.size(); |
520 |
0 |
Collection<FTSData> reorderedStructuresSet = new LinkedHashSet<>(); |
521 |
0 |
reorderedStructuresSet.addAll(filteredResponse); |
522 |
0 |
reorderedStructuresSet.addAll(discoveredStructuresSet); |
523 |
0 |
getResultTable().setModel(FTSRestResponse |
524 |
|
.getTableModel(lastPdbRequest, reorderedStructuresSet)); |
525 |
|
|
526 |
0 |
FTSRestResponse.configureTableColumn(getResultTable(), |
527 |
|
wantedFields, tempUserPrefs); |
528 |
0 |
getResultTable().getColumn("Ref Sequence").setPreferredWidth(120); |
529 |
0 |
getResultTable().getColumn("Ref Sequence").setMinWidth(100); |
530 |
0 |
getResultTable().getColumn("Ref Sequence").setMaxWidth(200); |
531 |
|
|
532 |
0 |
getResultTable().addRowSelectionInterval(0, |
533 |
|
filterResponseCount - 1); |
534 |
0 |
mainFrame.setTitle(MessageManager.formatMessage( |
535 |
|
"label.structure_chooser_filter_time", totalTime)); |
536 |
|
} |
537 |
|
else |
538 |
|
{ |
539 |
0 |
mainFrame.setTitle(MessageManager.formatMessage( |
540 |
|
"label.structure_chooser_filter_time", totalTime)); |
541 |
0 |
if (errors.size() > 0) |
542 |
|
{ |
543 |
0 |
StringBuilder errorMsg = new StringBuilder(); |
544 |
0 |
for (String error : errors) |
545 |
|
{ |
546 |
0 |
errorMsg.append(error).append("\n"); |
547 |
|
} |
548 |
0 |
JvOptionPane.showMessageDialog(null, errorMsg.toString(), |
549 |
|
MessageManager.getString("label.pdb_web-service_error"), |
550 |
|
JvOptionPane.ERROR_MESSAGE); |
551 |
|
} |
552 |
|
} |
553 |
|
|
554 |
0 |
lbl_loading.setVisible(false); |
555 |
|
|
556 |
0 |
validateSelections(); |
557 |
|
} |
558 |
|
}); |
559 |
0 |
filterThread.start(); |
560 |
|
} |
561 |
|
|
562 |
|
|
563 |
|
|
564 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
565 |
0 |
@Override... |
566 |
|
protected void pdbFromFile_actionPerformed() |
567 |
|
{ |
568 |
|
|
569 |
|
|
570 |
0 |
jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser( |
571 |
|
jalview.bin.Cache.getProperty("LAST_DIRECTORY")); |
572 |
0 |
chooser.setFileView(new jalview.io.JalviewFileView()); |
573 |
0 |
chooser.setDialogTitle( |
574 |
|
MessageManager.formatMessage("label.select_pdb_file_for", |
575 |
|
selectedSequence.getDisplayId(false))); |
576 |
0 |
chooser.setToolTipText(MessageManager.formatMessage( |
577 |
|
"label.load_pdb_file_associate_with_sequence", |
578 |
|
selectedSequence.getDisplayId(false))); |
579 |
|
|
580 |
0 |
int value = chooser.showOpenDialog(null); |
581 |
0 |
if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION) |
582 |
|
{ |
583 |
0 |
selectedPdbFileName = chooser.getSelectedFile().getPath(); |
584 |
0 |
jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedPdbFileName); |
585 |
0 |
validateSelections(); |
586 |
|
} |
587 |
|
} |
588 |
|
|
589 |
|
|
590 |
|
|
591 |
|
|
592 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 3 |
Complexity Density: 0.2 |
|
593 |
5 |
protected void populateFilterComboBox(boolean haveData,... |
594 |
|
boolean cachedPDBExist) |
595 |
|
{ |
596 |
|
|
597 |
|
|
598 |
|
|
599 |
5 |
cmb_filterOption.removeItemListener(this); |
600 |
|
|
601 |
5 |
cmb_filterOption.removeAllItems(); |
602 |
5 |
if (haveData) |
603 |
|
{ |
604 |
3 |
cmb_filterOption.addItem(new FilterOption( |
605 |
|
MessageManager.getString("label.best_quality"), |
606 |
|
"overall_quality", VIEWS_FILTER, false)); |
607 |
3 |
cmb_filterOption.addItem(new FilterOption( |
608 |
|
MessageManager.getString("label.best_resolution"), |
609 |
|
"resolution", VIEWS_FILTER, false)); |
610 |
3 |
cmb_filterOption.addItem(new FilterOption( |
611 |
|
MessageManager.getString("label.most_protein_chain"), |
612 |
|
"number_of_protein_chains", VIEWS_FILTER, false)); |
613 |
3 |
cmb_filterOption.addItem(new FilterOption( |
614 |
|
MessageManager.getString("label.most_bound_molecules"), |
615 |
|
"number_of_bound_molecules", VIEWS_FILTER, false)); |
616 |
3 |
cmb_filterOption.addItem(new FilterOption( |
617 |
|
MessageManager.getString("label.most_polymer_residues"), |
618 |
|
"number_of_polymer_residues", VIEWS_FILTER, true)); |
619 |
|
} |
620 |
5 |
cmb_filterOption.addItem( |
621 |
|
new FilterOption(MessageManager.getString("label.enter_pdb_id"), |
622 |
|
"-", VIEWS_ENTER_ID, false)); |
623 |
5 |
cmb_filterOption.addItem( |
624 |
|
new FilterOption(MessageManager.getString("label.from_file"), |
625 |
|
"-", VIEWS_FROM_FILE, false)); |
626 |
|
|
627 |
5 |
if (cachedPDBExist) |
628 |
|
{ |
629 |
1 |
FilterOption cachedOption = new FilterOption( |
630 |
|
MessageManager.getString("label.cached_structures"), |
631 |
|
"-", VIEWS_LOCAL_PDB, false); |
632 |
1 |
cmb_filterOption.addItem(cachedOption); |
633 |
1 |
cmb_filterOption.setSelectedItem(cachedOption); |
634 |
|
} |
635 |
|
|
636 |
5 |
cmb_filterOption.addItemListener(this); |
637 |
|
} |
638 |
|
|
639 |
|
|
640 |
|
|
641 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 4 |
Complexity Density: 0.29 |
|
642 |
0 |
protected void updateCurrentView()... |
643 |
|
{ |
644 |
0 |
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption |
645 |
|
.getSelectedItem()); |
646 |
0 |
layout_switchableViews.show(pnl_switchableViews, |
647 |
|
selectedFilterOpt.getView()); |
648 |
0 |
String filterTitle = mainFrame.getTitle(); |
649 |
0 |
mainFrame.setTitle(frameTitle); |
650 |
0 |
chk_invertFilter.setVisible(false); |
651 |
0 |
if (selectedFilterOpt.getView() == VIEWS_FILTER) |
652 |
|
{ |
653 |
0 |
mainFrame.setTitle(filterTitle); |
654 |
0 |
chk_invertFilter.setVisible(true); |
655 |
0 |
filterResultSet(selectedFilterOpt.getValue()); |
656 |
|
} |
657 |
0 |
else if (selectedFilterOpt.getView() == VIEWS_ENTER_ID |
658 |
|
|| selectedFilterOpt.getView() == VIEWS_FROM_FILE) |
659 |
|
{ |
660 |
0 |
mainFrame.setTitle(MessageManager |
661 |
|
.getString("label.structure_chooser_manual_association")); |
662 |
0 |
idInputAssSeqPanel.loadCmbAssSeq(); |
663 |
0 |
fileChooserAssSeqPanel.loadCmbAssSeq(); |
664 |
|
} |
665 |
0 |
validateSelections(); |
666 |
|
} |
667 |
|
|
668 |
|
|
669 |
|
|
670 |
|
|
671 |
|
|
672 |
|
|
673 |
|
|
674 |
|
|
675 |
|
|
676 |
|
|
677 |
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 7 |
Complexity Density: 0.39 |
|
678 |
0 |
@Override... |
679 |
|
protected void validateSelections() |
680 |
|
{ |
681 |
0 |
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption |
682 |
|
.getSelectedItem()); |
683 |
0 |
btn_add.setEnabled(false); |
684 |
0 |
String currentView = selectedFilterOpt.getView(); |
685 |
0 |
int selectedCount = 0; |
686 |
0 |
if (currentView == VIEWS_FILTER) |
687 |
|
{ |
688 |
0 |
selectedCount = getResultTable().getSelectedRows().length; |
689 |
0 |
if (selectedCount > 0) |
690 |
|
{ |
691 |
0 |
btn_add.setEnabled(true); |
692 |
|
} |
693 |
|
} |
694 |
0 |
else if (currentView == VIEWS_LOCAL_PDB) |
695 |
|
{ |
696 |
0 |
selectedCount = tbl_local_pdb.getSelectedRows().length; |
697 |
0 |
if (selectedCount > 0) |
698 |
|
{ |
699 |
0 |
btn_add.setEnabled(true); |
700 |
|
} |
701 |
|
} |
702 |
0 |
else if (currentView == VIEWS_ENTER_ID) |
703 |
|
{ |
704 |
0 |
validateAssociationEnterPdb(); |
705 |
|
} |
706 |
0 |
else if (currentView == VIEWS_FROM_FILE) |
707 |
|
{ |
708 |
0 |
validateAssociationFromFile(); |
709 |
|
} |
710 |
|
|
711 |
0 |
btn_newView.setEnabled(btn_add.isEnabled()); |
712 |
|
|
713 |
|
|
714 |
|
|
715 |
|
|
716 |
|
|
717 |
0 |
chk_superpose |
718 |
|
.setEnabled(selectedCount > 1 || targetView.getItemCount() > 0); |
719 |
|
} |
720 |
|
|
721 |
|
|
722 |
|
|
723 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 6 |
Complexity Density: 0.38 |
|
724 |
0 |
protected void validateAssociationEnterPdb()... |
725 |
|
{ |
726 |
0 |
AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) idInputAssSeqPanel |
727 |
|
.getCmb_assSeq().getSelectedItem(); |
728 |
0 |
lbl_pdbManualFetchStatus.setIcon(errorImage); |
729 |
0 |
lbl_pdbManualFetchStatus.setToolTipText(""); |
730 |
0 |
if (txt_search.getText().length() > 0) |
731 |
|
{ |
732 |
0 |
lbl_pdbManualFetchStatus.setToolTipText(JvSwingUtils.wrapTooltip(true, |
733 |
|
MessageManager.formatMessage("info.no_pdb_entry_found_for", |
734 |
|
txt_search.getText()))); |
735 |
|
} |
736 |
|
|
737 |
0 |
if (errorWarning.length() > 0) |
738 |
|
{ |
739 |
0 |
lbl_pdbManualFetchStatus.setIcon(warningImage); |
740 |
0 |
lbl_pdbManualFetchStatus.setToolTipText( |
741 |
|
JvSwingUtils.wrapTooltip(true, errorWarning.toString())); |
742 |
|
} |
743 |
|
|
744 |
0 |
if (selectedSequences.length == 1 || !assSeqOpt.getName() |
745 |
|
.equalsIgnoreCase("-Select Associated Seq-")) |
746 |
|
{ |
747 |
0 |
txt_search.setEnabled(true); |
748 |
0 |
if (isValidPBDEntry) |
749 |
|
{ |
750 |
0 |
btn_add.setEnabled(true); |
751 |
0 |
lbl_pdbManualFetchStatus.setToolTipText(""); |
752 |
0 |
lbl_pdbManualFetchStatus.setIcon(goodImage); |
753 |
|
} |
754 |
|
} |
755 |
|
else |
756 |
|
{ |
757 |
0 |
txt_search.setEnabled(false); |
758 |
0 |
lbl_pdbManualFetchStatus.setIcon(errorImage); |
759 |
|
} |
760 |
|
} |
761 |
|
|
762 |
|
|
763 |
|
|
764 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 6 |
Complexity Density: 0.67 |
|
765 |
0 |
protected void validateAssociationFromFile()... |
766 |
|
{ |
767 |
0 |
AssociateSeqOptions assSeqOpt = (AssociateSeqOptions) fileChooserAssSeqPanel |
768 |
|
.getCmb_assSeq().getSelectedItem(); |
769 |
0 |
lbl_fromFileStatus.setIcon(errorImage); |
770 |
0 |
if (selectedSequences.length == 1 || (assSeqOpt != null && !assSeqOpt |
771 |
|
.getName().equalsIgnoreCase("-Select Associated Seq-"))) |
772 |
|
{ |
773 |
0 |
btn_pdbFromFile.setEnabled(true); |
774 |
0 |
if (selectedPdbFileName != null && selectedPdbFileName.length() > 0) |
775 |
|
{ |
776 |
0 |
btn_add.setEnabled(true); |
777 |
0 |
lbl_fromFileStatus.setIcon(goodImage); |
778 |
|
} |
779 |
|
} |
780 |
|
else |
781 |
|
{ |
782 |
0 |
btn_pdbFromFile.setEnabled(false); |
783 |
0 |
lbl_fromFileStatus.setIcon(errorImage); |
784 |
|
} |
785 |
|
} |
786 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
787 |
0 |
@Override... |
788 |
|
protected void cmbAssSeqStateChanged() |
789 |
|
{ |
790 |
0 |
validateSelections(); |
791 |
|
} |
792 |
|
|
793 |
|
|
794 |
|
|
795 |
|
|
796 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
797 |
0 |
@Override... |
798 |
|
protected void stateChanged(ItemEvent e) |
799 |
|
{ |
800 |
0 |
if (e.getSource() instanceof JCheckBox) |
801 |
|
{ |
802 |
0 |
updateCurrentView(); |
803 |
|
} |
804 |
|
else |
805 |
|
{ |
806 |
0 |
if (e.getStateChange() == ItemEvent.SELECTED) |
807 |
|
{ |
808 |
0 |
updateCurrentView(); |
809 |
|
} |
810 |
|
} |
811 |
|
|
812 |
|
} |
813 |
|
|
814 |
|
|
815 |
|
|
816 |
|
|
817 |
|
@param |
818 |
|
@return |
819 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 7 |
Complexity Density: 0.54 |
|
820 |
0 |
public boolean selectStructure(String... pdbids)... |
821 |
|
{ |
822 |
0 |
boolean found = false; |
823 |
|
|
824 |
0 |
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption |
825 |
|
.getSelectedItem()); |
826 |
0 |
String currentView = selectedFilterOpt.getView(); |
827 |
0 |
JTable restable = (currentView == VIEWS_FILTER) ? getResultTable() |
828 |
0 |
: (currentView == VIEWS_LOCAL_PDB) ? tbl_local_pdb : null; |
829 |
|
|
830 |
0 |
if (restable == null) |
831 |
|
{ |
832 |
|
|
833 |
|
|
834 |
0 |
return false; |
835 |
|
} |
836 |
|
|
837 |
0 |
int pdbIdColIndex = restable.getColumn("PDB Id").getModelIndex(); |
838 |
0 |
for (int r = 0; r < restable.getRowCount(); r++) |
839 |
|
{ |
840 |
0 |
for (int p = 0; p < pdbids.length; p++) |
841 |
|
{ |
842 |
0 |
if (String.valueOf(restable.getValueAt(r, pdbIdColIndex)) |
843 |
|
.equalsIgnoreCase(pdbids[p])) |
844 |
|
{ |
845 |
0 |
restable.setRowSelectionInterval(r, r); |
846 |
0 |
found = true; |
847 |
|
} |
848 |
|
} |
849 |
|
} |
850 |
0 |
return found; |
851 |
|
} |
852 |
|
|
853 |
|
|
854 |
|
|
855 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
856 |
0 |
@Override... |
857 |
|
protected void newView_ActionPerformed() |
858 |
|
{ |
859 |
0 |
targetView.setSelectedItem(null); |
860 |
0 |
showStructures(false); |
861 |
|
} |
862 |
|
|
863 |
|
|
864 |
|
|
865 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
866 |
0 |
@Override... |
867 |
|
protected void add_ActionPerformed() |
868 |
|
{ |
869 |
0 |
showStructures(false); |
870 |
|
} |
871 |
|
|
872 |
|
|
873 |
|
|
874 |
|
|
875 |
|
private StructureViewer sViewer = null; |
876 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 6 |
Complexity Density: 0.67 |
|
877 |
0 |
public void showStructures(boolean waitUntilFinished)... |
878 |
|
{ |
879 |
|
|
880 |
0 |
final StructureSelectionManager ssm = ap.getStructureSelectionManager(); |
881 |
|
|
882 |
0 |
final int preferredHeight = pnl_filter.getHeight(); |
883 |
|
|
884 |
0 |
Runnable viewStruc = new Runnable() |
885 |
|
{ |
|
|
| 0% |
Uncovered Elements: 84 (84) |
Complexity: 12 |
Complexity Density: 0.19 |
|
886 |
0 |
@Override... |
887 |
|
public void run() |
888 |
|
{ |
889 |
0 |
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption |
890 |
|
.getSelectedItem()); |
891 |
0 |
String currentView = selectedFilterOpt.getView(); |
892 |
0 |
JTable restable = (currentView == VIEWS_FILTER) ? getResultTable() |
893 |
|
: tbl_local_pdb; |
894 |
|
|
895 |
0 |
if (currentView == VIEWS_FILTER) |
896 |
|
{ |
897 |
0 |
int pdbIdColIndex = restable.getColumn("PDB Id") |
898 |
|
.getModelIndex(); |
899 |
0 |
int refSeqColIndex = restable.getColumn("Ref Sequence") |
900 |
|
.getModelIndex(); |
901 |
0 |
int[] selectedRows = restable.getSelectedRows(); |
902 |
0 |
PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length]; |
903 |
0 |
int count = 0; |
904 |
0 |
List<SequenceI> selectedSeqsToView = new ArrayList<>(); |
905 |
0 |
for (int row : selectedRows) |
906 |
|
{ |
907 |
0 |
String pdbIdStr = restable |
908 |
|
.getValueAt(row, pdbIdColIndex).toString(); |
909 |
0 |
SequenceI selectedSeq = (SequenceI) restable |
910 |
|
.getValueAt(row, refSeqColIndex); |
911 |
0 |
selectedSeqsToView.add(selectedSeq); |
912 |
0 |
PDBEntry pdbEntry = selectedSeq.getPDBEntry(pdbIdStr); |
913 |
0 |
if (pdbEntry == null) |
914 |
|
{ |
915 |
0 |
pdbEntry = getFindEntry(pdbIdStr, |
916 |
|
selectedSeq.getAllPDBEntries()); |
917 |
|
} |
918 |
|
|
919 |
0 |
if (pdbEntry == null) |
920 |
|
{ |
921 |
0 |
pdbEntry = new PDBEntry(); |
922 |
0 |
pdbEntry.setId(pdbIdStr); |
923 |
0 |
pdbEntry.setType(PDBEntry.Type.PDB); |
924 |
0 |
selectedSeq.getDatasetSequence().addPDBId(pdbEntry); |
925 |
|
} |
926 |
0 |
pdbEntriesToView[count++] = pdbEntry; |
927 |
|
} |
928 |
0 |
SequenceI[] selectedSeqs = selectedSeqsToView |
929 |
|
.toArray(new SequenceI[selectedSeqsToView.size()]); |
930 |
0 |
sViewer = launchStructureViewer(ssm, pdbEntriesToView, ap, |
931 |
|
selectedSeqs); |
932 |
|
} |
933 |
0 |
else if (currentView == VIEWS_LOCAL_PDB) |
934 |
|
{ |
935 |
0 |
int[] selectedRows = tbl_local_pdb.getSelectedRows(); |
936 |
0 |
PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length]; |
937 |
0 |
int count = 0; |
938 |
0 |
int pdbIdColIndex = tbl_local_pdb.getColumn("PDB Id") |
939 |
|
.getModelIndex(); |
940 |
0 |
int refSeqColIndex = tbl_local_pdb.getColumn("Ref Sequence") |
941 |
|
.getModelIndex(); |
942 |
0 |
List<SequenceI> selectedSeqsToView = new ArrayList<>(); |
943 |
0 |
for (int row : selectedRows) |
944 |
|
{ |
945 |
0 |
PDBEntry pdbEntry = (PDBEntry) tbl_local_pdb.getValueAt(row, |
946 |
|
pdbIdColIndex); |
947 |
0 |
pdbEntriesToView[count++] = pdbEntry; |
948 |
0 |
SequenceI selectedSeq = (SequenceI) tbl_local_pdb |
949 |
|
.getValueAt(row, refSeqColIndex); |
950 |
0 |
selectedSeqsToView.add(selectedSeq); |
951 |
|
} |
952 |
0 |
SequenceI[] selectedSeqs = selectedSeqsToView |
953 |
|
.toArray(new SequenceI[selectedSeqsToView.size()]); |
954 |
0 |
sViewer = launchStructureViewer(ssm, pdbEntriesToView, ap, |
955 |
|
selectedSeqs); |
956 |
|
} |
957 |
0 |
else if (currentView == VIEWS_ENTER_ID) |
958 |
|
{ |
959 |
0 |
SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel |
960 |
|
.getCmb_assSeq().getSelectedItem()).getSequence(); |
961 |
0 |
if (userSelectedSeq != null) |
962 |
|
{ |
963 |
0 |
selectedSequence = userSelectedSeq; |
964 |
|
} |
965 |
0 |
String pdbIdStr = txt_search.getText(); |
966 |
0 |
PDBEntry pdbEntry = selectedSequence.getPDBEntry(pdbIdStr); |
967 |
0 |
if (pdbEntry == null) |
968 |
|
{ |
969 |
0 |
pdbEntry = new PDBEntry(); |
970 |
0 |
if (pdbIdStr.split(":").length > 1) |
971 |
|
{ |
972 |
0 |
pdbEntry.setId(pdbIdStr.split(":")[0]); |
973 |
0 |
pdbEntry.setChainCode(pdbIdStr.split(":")[1].toUpperCase()); |
974 |
|
} |
975 |
|
else |
976 |
|
{ |
977 |
0 |
pdbEntry.setId(pdbIdStr); |
978 |
|
} |
979 |
0 |
pdbEntry.setType(PDBEntry.Type.PDB); |
980 |
0 |
selectedSequence.getDatasetSequence().addPDBId(pdbEntry); |
981 |
|
} |
982 |
|
|
983 |
0 |
PDBEntry[] pdbEntriesToView = new PDBEntry[] { pdbEntry }; |
984 |
0 |
sViewer = launchStructureViewer(ssm, pdbEntriesToView, ap, |
985 |
|
new SequenceI[] |
986 |
|
{ selectedSequence }); |
987 |
|
} |
988 |
0 |
else if (currentView == VIEWS_FROM_FILE) |
989 |
|
{ |
990 |
0 |
SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel |
991 |
|
.getCmb_assSeq().getSelectedItem()).getSequence(); |
992 |
0 |
if (userSelectedSeq != null) |
993 |
|
{ |
994 |
0 |
selectedSequence = userSelectedSeq; |
995 |
|
} |
996 |
0 |
PDBEntry fileEntry = new AssociatePdbFileWithSeq() |
997 |
|
.associatePdbWithSeq(selectedPdbFileName, |
998 |
|
DataSourceType.FILE, selectedSequence, true, |
999 |
|
Desktop.instance); |
1000 |
|
|
1001 |
0 |
sViewer = launchStructureViewer( |
1002 |
|
ssm, new PDBEntry[] |
1003 |
|
{ fileEntry }, ap, |
1004 |
|
new SequenceI[] |
1005 |
|
{ selectedSequence }); |
1006 |
|
} |
1007 |
0 |
SwingUtilities.invokeLater(new Runnable() |
1008 |
|
{ |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1009 |
0 |
@Override... |
1010 |
|
public void run() |
1011 |
|
{ |
1012 |
0 |
closeAction(preferredHeight); |
1013 |
0 |
mainFrame.dispose(); |
1014 |
|
} |
1015 |
|
}); |
1016 |
|
} |
1017 |
|
}; |
1018 |
0 |
Thread runner = new Thread(viewStruc); |
1019 |
0 |
runner.start(); |
1020 |
0 |
if (waitUntilFinished) |
1021 |
|
{ |
1022 |
0 |
while (sViewer == null ? runner.isAlive() |
1023 |
0 |
: (sViewer.sview == null ? true |
1024 |
|
: !sViewer.sview.hasMapping())) |
1025 |
|
{ |
1026 |
0 |
try |
1027 |
|
{ |
1028 |
0 |
Thread.sleep(300); |
1029 |
|
} catch (InterruptedException ie) |
1030 |
|
{ |
1031 |
|
|
1032 |
|
} |
1033 |
|
} |
1034 |
|
} |
1035 |
|
} |
1036 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
1037 |
0 |
private PDBEntry getFindEntry(String id, Vector<PDBEntry> pdbEntries)... |
1038 |
|
{ |
1039 |
0 |
Objects.requireNonNull(id); |
1040 |
0 |
Objects.requireNonNull(pdbEntries); |
1041 |
0 |
PDBEntry foundEntry = null; |
1042 |
0 |
for (PDBEntry entry : pdbEntries) |
1043 |
|
{ |
1044 |
0 |
if (entry.getId().equalsIgnoreCase(id)) |
1045 |
|
{ |
1046 |
0 |
return entry; |
1047 |
|
} |
1048 |
|
} |
1049 |
0 |
return foundEntry; |
1050 |
|
} |
1051 |
|
|
1052 |
|
|
1053 |
|
|
1054 |
|
|
1055 |
|
|
1056 |
|
@param |
1057 |
|
@return |
1058 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
1059 |
0 |
StructureViewer getTargetedStructureViewer(... |
1060 |
|
StructureSelectionManager ssm) |
1061 |
|
{ |
1062 |
0 |
Object sv = targetView.getSelectedItem(); |
1063 |
|
|
1064 |
0 |
return sv == null ? new StructureViewer(ssm) : (StructureViewer) sv; |
1065 |
|
} |
1066 |
|
|
1067 |
|
|
1068 |
|
|
1069 |
|
|
1070 |
|
@param |
1071 |
|
@param |
1072 |
|
@param |
1073 |
|
@param |
1074 |
|
@return |
1075 |
|
|
|
|
| 0% |
Uncovered Elements: 50 (50) |
Complexity: 10 |
Complexity Density: 0.28 |
|
1076 |
0 |
private StructureViewer launchStructureViewer(... |
1077 |
|
StructureSelectionManager ssm, |
1078 |
|
final PDBEntry[] pdbEntriesToView, |
1079 |
|
final AlignmentPanel alignPanel, SequenceI[] sequences) |
1080 |
|
{ |
1081 |
0 |
long progressId = sequences.hashCode(); |
1082 |
0 |
setProgressBar(MessageManager |
1083 |
|
.getString("status.launching_3d_structure_viewer"), progressId); |
1084 |
0 |
final StructureViewer theViewer = getTargetedStructureViewer(ssm); |
1085 |
0 |
boolean superimpose = chk_superpose.isSelected(); |
1086 |
0 |
theViewer.setSuperpose(superimpose); |
1087 |
|
|
1088 |
|
|
1089 |
|
|
1090 |
|
|
1091 |
0 |
Cache.setProperty(AUTOSUPERIMPOSE, |
1092 |
|
Boolean.valueOf(superimpose).toString()); |
1093 |
|
|
1094 |
0 |
setProgressBar(null, progressId); |
1095 |
0 |
if (SiftsSettings.isMapWithSifts()) |
1096 |
|
{ |
1097 |
0 |
List<SequenceI> seqsWithoutSourceDBRef = new ArrayList<>(); |
1098 |
0 |
int p = 0; |
1099 |
|
|
1100 |
|
|
1101 |
|
|
1102 |
0 |
for (SequenceI seq : sequences) |
1103 |
|
{ |
1104 |
0 |
PDBEntry pdbe = pdbEntriesToView[p++]; |
1105 |
0 |
if (pdbe != null && pdbe.getFile() != null) |
1106 |
|
{ |
1107 |
0 |
StructureMapping[] smm = ssm.getMapping(pdbe.getFile()); |
1108 |
0 |
if (smm != null && smm.length > 0) |
1109 |
|
{ |
1110 |
0 |
for (StructureMapping sm : smm) |
1111 |
|
{ |
1112 |
0 |
if (sm.getSequence() == seq) |
1113 |
|
{ |
1114 |
0 |
continue; |
1115 |
|
} |
1116 |
|
} |
1117 |
|
} |
1118 |
|
} |
1119 |
0 |
if (seq.getPrimaryDBRefs().isEmpty()) |
1120 |
|
{ |
1121 |
0 |
seqsWithoutSourceDBRef.add(seq); |
1122 |
0 |
continue; |
1123 |
|
} |
1124 |
|
} |
1125 |
0 |
if (!seqsWithoutSourceDBRef.isEmpty()) |
1126 |
|
{ |
1127 |
0 |
int y = seqsWithoutSourceDBRef.size(); |
1128 |
0 |
setProgressBar(MessageManager.formatMessage( |
1129 |
|
"status.fetching_dbrefs_for_sequences_without_valid_refs", |
1130 |
|
y), progressId); |
1131 |
0 |
SequenceI[] seqWithoutSrcDBRef = seqsWithoutSourceDBRef |
1132 |
|
.toArray(new SequenceI[y]); |
1133 |
0 |
DBRefFetcher dbRefFetcher = new DBRefFetcher(seqWithoutSrcDBRef); |
1134 |
0 |
dbRefFetcher.fetchDBRefs(true); |
1135 |
|
|
1136 |
0 |
setProgressBar("Fetch complete.", progressId); |
1137 |
|
} |
1138 |
|
} |
1139 |
0 |
if (pdbEntriesToView.length > 1) |
1140 |
|
{ |
1141 |
0 |
setProgressBar(MessageManager.getString( |
1142 |
|
"status.fetching_3d_structures_for_selected_entries"), |
1143 |
|
progressId); |
1144 |
0 |
theViewer.viewStructures(pdbEntriesToView, sequences, alignPanel); |
1145 |
|
} |
1146 |
|
else |
1147 |
|
{ |
1148 |
0 |
setProgressBar(MessageManager.formatMessage( |
1149 |
|
"status.fetching_3d_structures_for", |
1150 |
|
pdbEntriesToView[0].getId()),progressId); |
1151 |
0 |
theViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel); |
1152 |
|
} |
1153 |
0 |
setProgressBar(null, progressId); |
1154 |
|
|
1155 |
0 |
lastTargetedView = theViewer; |
1156 |
0 |
return theViewer; |
1157 |
|
} |
1158 |
|
|
1159 |
|
|
1160 |
|
|
1161 |
|
|
1162 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
1163 |
0 |
@Override... |
1164 |
|
protected void populateCmbAssociateSeqOptions( |
1165 |
|
JComboBox<AssociateSeqOptions> cmb_assSeq, |
1166 |
|
JLabel lbl_associateSeq) |
1167 |
|
{ |
1168 |
0 |
cmb_assSeq.removeAllItems(); |
1169 |
0 |
cmb_assSeq.addItem( |
1170 |
|
new AssociateSeqOptions("-Select Associated Seq-", null)); |
1171 |
0 |
lbl_associateSeq.setVisible(false); |
1172 |
0 |
if (selectedSequences.length > 1) |
1173 |
|
{ |
1174 |
0 |
for (SequenceI seq : selectedSequences) |
1175 |
|
{ |
1176 |
0 |
cmb_assSeq.addItem(new AssociateSeqOptions(seq)); |
1177 |
|
} |
1178 |
|
} |
1179 |
|
else |
1180 |
|
{ |
1181 |
0 |
String seqName = selectedSequence.getDisplayId(false); |
1182 |
0 |
seqName = seqName.length() <= 40 ? seqName : seqName.substring(0, 39); |
1183 |
0 |
lbl_associateSeq.setText(seqName); |
1184 |
0 |
lbl_associateSeq.setVisible(true); |
1185 |
0 |
cmb_assSeq.setVisible(false); |
1186 |
|
} |
1187 |
|
} |
1188 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1189 |
1 |
protected boolean isStructuresDiscovered()... |
1190 |
|
{ |
1191 |
1 |
return discoveredStructuresSet != null |
1192 |
|
&& !discoveredStructuresSet.isEmpty(); |
1193 |
|
} |
1194 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1195 |
0 |
@Override... |
1196 |
|
protected void txt_search_ActionPerformed() |
1197 |
|
{ |
1198 |
0 |
new Thread() |
1199 |
|
{ |
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 5 |
Complexity Density: 0.21 |
|
1200 |
0 |
@Override... |
1201 |
|
public void run() |
1202 |
|
{ |
1203 |
0 |
errorWarning.setLength(0); |
1204 |
0 |
isValidPBDEntry = false; |
1205 |
0 |
if (txt_search.getText().length() > 0) |
1206 |
|
{ |
1207 |
0 |
String searchTerm = txt_search.getText().toLowerCase(); |
1208 |
0 |
searchTerm = searchTerm.split(":")[0]; |
1209 |
|
|
1210 |
0 |
List<FTSDataColumnI> wantedFields = new ArrayList<>(); |
1211 |
0 |
FTSRestRequest pdbRequest = new FTSRestRequest(); |
1212 |
0 |
pdbRequest.setAllowEmptySeq(false); |
1213 |
0 |
pdbRequest.setResponseSize(1); |
1214 |
0 |
pdbRequest.setFieldToSearchBy("(pdb_id:"); |
1215 |
0 |
pdbRequest.setWantedFields(wantedFields); |
1216 |
0 |
pdbRequest.setSearchTerm(searchTerm + ")"); |
1217 |
0 |
pdbRequest.setAssociatedSequence(selectedSequence); |
1218 |
0 |
pdbRestCleint = PDBFTSRestClient.getInstance(); |
1219 |
0 |
wantedFields.add(pdbRestCleint.getPrimaryKeyColumn()); |
1220 |
0 |
FTSRestResponse resultList; |
1221 |
0 |
try |
1222 |
|
{ |
1223 |
0 |
resultList = pdbRestCleint.executeRequest(pdbRequest); |
1224 |
|
} catch (Exception e) |
1225 |
|
{ |
1226 |
0 |
errorWarning.append(e.getMessage()); |
1227 |
0 |
return; |
1228 |
|
} finally |
1229 |
|
{ |
1230 |
0 |
validateSelections(); |
1231 |
|
} |
1232 |
0 |
if (resultList.getSearchSummary() != null |
1233 |
|
&& resultList.getSearchSummary().size() > 0) |
1234 |
|
{ |
1235 |
0 |
isValidPBDEntry = true; |
1236 |
|
} |
1237 |
|
} |
1238 |
0 |
validateSelections(); |
1239 |
|
} |
1240 |
|
}.start(); |
1241 |
|
} |
1242 |
|
|
|
|
| 40% |
Uncovered Elements: 3 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1243 |
1 |
@Override... |
1244 |
|
protected void tabRefresh() |
1245 |
|
{ |
1246 |
1 |
if (selectedSequences != null) |
1247 |
|
{ |
1248 |
0 |
Thread refreshThread = new Thread(new Runnable() |
1249 |
|
{ |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1250 |
0 |
@Override... |
1251 |
|
public void run() |
1252 |
|
{ |
1253 |
0 |
fetchStructuresMetaData(); |
1254 |
0 |
filterResultSet( |
1255 |
|
((FilterOption) cmb_filterOption.getSelectedItem()) |
1256 |
|
.getValue()); |
1257 |
|
} |
1258 |
|
}); |
1259 |
0 |
refreshThread.start(); |
1260 |
|
} |
1261 |
|
} |
1262 |
|
|
|
|
| 21.1% |
Uncovered Elements: 30 (38) |
Complexity: 15 |
Complexity Density: 0.58 |
|
1263 |
|
public class PDBEntryTableModel extends AbstractTableModel |
1264 |
|
{ |
1265 |
|
String[] columns = { "Ref Sequence", "PDB Id", "Chain", "Type", |
1266 |
|
"File" }; |
1267 |
|
|
1268 |
|
private List<CachedPDB> pdbEntries; |
1269 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1270 |
1 |
public PDBEntryTableModel(List<CachedPDB> pdbEntries)... |
1271 |
|
{ |
1272 |
1 |
this.pdbEntries = new ArrayList<>(pdbEntries); |
1273 |
|
} |
1274 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1275 |
5 |
@Override... |
1276 |
|
public String getColumnName(int columnIndex) |
1277 |
|
{ |
1278 |
5 |
return columns[columnIndex]; |
1279 |
|
} |
1280 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1281 |
4 |
@Override... |
1282 |
|
public int getRowCount() |
1283 |
|
{ |
1284 |
4 |
return pdbEntries.size(); |
1285 |
|
} |
1286 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1287 |
6 |
@Override... |
1288 |
|
public int getColumnCount() |
1289 |
|
{ |
1290 |
6 |
return columns.length; |
1291 |
|
} |
1292 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1293 |
0 |
@Override... |
1294 |
|
public boolean isCellEditable(int row, int column) |
1295 |
|
{ |
1296 |
0 |
return false; |
1297 |
|
} |
1298 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 7 |
Complexity Density: 0.37 |
|
1299 |
0 |
@Override... |
1300 |
|
public Object getValueAt(int rowIndex, int columnIndex) |
1301 |
|
{ |
1302 |
0 |
Object value = "??"; |
1303 |
0 |
CachedPDB entry = pdbEntries.get(rowIndex); |
1304 |
0 |
switch (columnIndex) |
1305 |
|
{ |
1306 |
0 |
case 0: |
1307 |
0 |
value = entry.getSequence(); |
1308 |
0 |
break; |
1309 |
0 |
case 1: |
1310 |
0 |
value = entry.getPdbEntry(); |
1311 |
0 |
break; |
1312 |
0 |
case 2: |
1313 |
0 |
value = entry.getPdbEntry().getChainCode() == null ? "_" |
1314 |
|
: entry.getPdbEntry().getChainCode(); |
1315 |
0 |
break; |
1316 |
0 |
case 3: |
1317 |
0 |
value = entry.getPdbEntry().getType(); |
1318 |
0 |
break; |
1319 |
0 |
case 4: |
1320 |
0 |
value = entry.getPdbEntry().getFile(); |
1321 |
0 |
break; |
1322 |
|
} |
1323 |
0 |
return value; |
1324 |
|
} |
1325 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
1326 |
0 |
@Override... |
1327 |
|
public Class<?> getColumnClass(int columnIndex) |
1328 |
|
{ |
1329 |
0 |
return columnIndex == 0 ? SequenceI.class : PDBEntry.class; |
1330 |
|
} |
1331 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1332 |
0 |
public CachedPDB getPDBEntryAt(int row)... |
1333 |
|
{ |
1334 |
0 |
return pdbEntries.get(row); |
1335 |
|
} |
1336 |
|
|
1337 |
|
} |
1338 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.75 |
|
1339 |
|
private class CachedPDB |
1340 |
|
{ |
1341 |
|
private SequenceI sequence; |
1342 |
|
|
1343 |
|
private PDBEntry pdbEntry; |
1344 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1345 |
0 |
public CachedPDB(SequenceI sequence, PDBEntry pdbEntry)... |
1346 |
|
{ |
1347 |
0 |
this.sequence = sequence; |
1348 |
0 |
this.pdbEntry = pdbEntry; |
1349 |
|
} |
1350 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1351 |
0 |
public SequenceI getSequence()... |
1352 |
|
{ |
1353 |
0 |
return sequence; |
1354 |
|
} |
1355 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1356 |
0 |
public PDBEntry getPdbEntry()... |
1357 |
|
{ |
1358 |
0 |
return pdbEntry; |
1359 |
|
} |
1360 |
|
|
1361 |
|
} |
1362 |
|
|
1363 |
|
private IProgressIndicator progressBar; |
1364 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1365 |
0 |
@Override... |
1366 |
|
public void setProgressBar(String message, long id) |
1367 |
|
{ |
1368 |
0 |
progressBar.setProgressBar(message, id); |
1369 |
|
} |
1370 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1371 |
0 |
@Override... |
1372 |
|
public void registerHandler(long id, IProgressIndicatorHandler handler) |
1373 |
|
{ |
1374 |
0 |
progressBar.registerHandler(id, handler); |
1375 |
|
} |
1376 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1377 |
0 |
@Override... |
1378 |
|
public boolean operationInProgress() |
1379 |
|
{ |
1380 |
0 |
return progressBar.operationInProgress(); |
1381 |
|
} |
1382 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
1383 |
0 |
public JalviewStructureDisplayI getOpenedStructureViewer()... |
1384 |
|
{ |
1385 |
0 |
return sViewer == null ? null : sViewer.sview; |
1386 |
|
} |
1387 |
|
} |