1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import jalview.api.FeatureSettingsModelI; |
24 |
|
import jalview.bin.Cache; |
25 |
|
import jalview.datamodel.AlignmentI; |
26 |
|
import jalview.datamodel.DBRefEntry; |
27 |
|
import jalview.datamodel.SequenceI; |
28 |
|
import jalview.fts.core.GFTSPanel; |
29 |
|
import jalview.fts.service.pdb.PDBFTSPanel; |
30 |
|
import jalview.fts.service.uniprot.UniprotFTSPanel; |
31 |
|
import jalview.io.FileFormatI; |
32 |
|
import jalview.io.gff.SequenceOntologyI; |
33 |
|
import jalview.util.DBRefUtils; |
34 |
|
import jalview.util.MessageManager; |
35 |
|
import jalview.util.Platform; |
36 |
|
import jalview.ws.seqfetcher.DbSourceProxy; |
37 |
|
|
38 |
|
import java.awt.BorderLayout; |
39 |
|
import java.awt.Font; |
40 |
|
import java.awt.event.ActionEvent; |
41 |
|
import java.awt.event.ActionListener; |
42 |
|
import java.awt.event.KeyAdapter; |
43 |
|
import java.awt.event.KeyEvent; |
44 |
|
import java.util.ArrayList; |
45 |
|
import java.util.Arrays; |
46 |
|
import java.util.HashSet; |
47 |
|
import java.util.Iterator; |
48 |
|
import java.util.List; |
49 |
|
|
50 |
|
import javax.swing.JButton; |
51 |
|
import javax.swing.JCheckBox; |
52 |
|
import javax.swing.JComboBox; |
53 |
|
import javax.swing.JInternalFrame; |
54 |
|
import javax.swing.JLabel; |
55 |
|
import javax.swing.JPanel; |
56 |
|
import javax.swing.JScrollPane; |
57 |
|
import javax.swing.JTextArea; |
58 |
|
import javax.swing.SwingConstants; |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
|
|
| 1.4% |
Uncovered Elements: 423 (429) |
Complexity: 101 |
Complexity Density: 0.34 |
|
67 |
|
public class SequenceFetcher extends JPanel implements Runnable |
68 |
|
{ |
69 |
|
private static jalview.ws.SequenceFetcher sfetch = null; |
70 |
|
|
71 |
|
JLabel exampleAccession; |
72 |
|
|
73 |
|
JComboBox<String> database; |
74 |
|
|
75 |
|
JCheckBox replacePunctuation; |
76 |
|
|
77 |
|
JButton okBtn; |
78 |
|
|
79 |
|
JButton exampleBtn; |
80 |
|
|
81 |
|
JButton closeBtn; |
82 |
|
|
83 |
|
JButton backBtn; |
84 |
|
|
85 |
|
JTextArea textArea; |
86 |
|
|
87 |
|
JInternalFrame frame; |
88 |
|
|
89 |
|
IProgressIndicator guiWindow; |
90 |
|
|
91 |
|
AlignFrame alignFrame; |
92 |
|
|
93 |
|
GFTSPanel parentSearchPanel; |
94 |
|
|
95 |
|
IProgressIndicator progressIndicator; |
96 |
|
|
97 |
|
volatile boolean _isConstructing = false; |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
@return |
103 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
104 |
1746 |
public static jalview.ws.SequenceFetcher getSequenceFetcherSingleton()... |
105 |
|
{ |
106 |
1746 |
if (sfetch == null) |
107 |
|
{ |
108 |
1 |
sfetch = new jalview.ws.SequenceFetcher(); |
109 |
|
} |
110 |
1746 |
return sfetch; |
111 |
|
} |
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
@param |
118 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
119 |
0 |
public SequenceFetcher(IProgressIndicator guiIndic)... |
120 |
|
{ |
121 |
0 |
this(guiIndic, null, null); |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
@param |
128 |
|
@param |
129 |
|
@param |
130 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
131 |
0 |
public SequenceFetcher(IProgressIndicator guiIndic,... |
132 |
|
final String selectedDb, final String queryString) |
133 |
|
{ |
134 |
0 |
this.progressIndicator = guiIndic; |
135 |
0 |
getSequenceFetcherSingleton(); |
136 |
0 |
this.guiWindow = progressIndicator; |
137 |
|
|
138 |
0 |
if (progressIndicator instanceof AlignFrame) |
139 |
|
{ |
140 |
0 |
alignFrame = (AlignFrame) progressIndicator; |
141 |
|
} |
142 |
|
|
143 |
0 |
jbInit(selectedDb); |
144 |
0 |
textArea.setText(queryString); |
145 |
|
|
146 |
0 |
frame = new JInternalFrame(); |
147 |
0 |
frame.setContentPane(this); |
148 |
0 |
Desktop.addInternalFrame(frame, getFrameTitle(), true, 400, |
149 |
0 |
Platform.isAMacAndNotJS() ? 240 : 180); |
150 |
|
} |
151 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
152 |
0 |
private String getFrameTitle()... |
153 |
|
{ |
154 |
0 |
return ((alignFrame == null) |
155 |
|
? MessageManager.getString("label.new_sequence_fetcher") |
156 |
|
: MessageManager |
157 |
|
.getString("label.additional_sequence_fetcher")); |
158 |
|
} |
159 |
|
|
|
|
| 0% |
Uncovered Elements: 61 (61) |
Complexity: 2 |
Complexity Density: 0.03 |
|
160 |
0 |
private void jbInit(String selectedDb)... |
161 |
|
{ |
162 |
0 |
this.setLayout(new BorderLayout()); |
163 |
|
|
164 |
0 |
database = new JComboBox<>(); |
165 |
0 |
database.setFont(JvSwingUtils.getLabelFont()); |
166 |
0 |
database.setPrototypeDisplayValue("ENSEMBLGENOMES "); |
167 |
0 |
String[] sources = new jalview.ws.SequenceFetcher().getSupportedDb(); |
168 |
0 |
Arrays.sort(sources, String.CASE_INSENSITIVE_ORDER); |
169 |
0 |
database.addItem(MessageManager.getString("action.select_ddbb")); |
170 |
0 |
for (String source : sources) |
171 |
|
{ |
172 |
0 |
database.addItem(source); |
173 |
|
} |
174 |
0 |
database.setSelectedItem(selectedDb); |
175 |
0 |
if (database.getSelectedIndex() == -1) |
176 |
|
{ |
177 |
0 |
database.setSelectedIndex(0); |
178 |
|
} |
179 |
0 |
database.setMaximumRowCount(database.getItemCount()); |
180 |
0 |
database.addActionListener(new ActionListener() |
181 |
|
{ |
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
182 |
0 |
@Override... |
183 |
|
public void actionPerformed(ActionEvent e) |
184 |
|
{ |
185 |
0 |
String currentSelection = (String) database.getSelectedItem(); |
186 |
0 |
updateExampleQuery(currentSelection); |
187 |
|
|
188 |
0 |
if ("pdb".equalsIgnoreCase(currentSelection)) |
189 |
|
{ |
190 |
0 |
frame.dispose(); |
191 |
0 |
new PDBFTSPanel(SequenceFetcher.this); |
192 |
|
} |
193 |
0 |
else if ("uniprot".equalsIgnoreCase(currentSelection)) |
194 |
|
{ |
195 |
0 |
frame.dispose(); |
196 |
0 |
new UniprotFTSPanel(SequenceFetcher.this); |
197 |
|
} |
198 |
|
else |
199 |
|
{ |
200 |
0 |
otherSourceAction(); |
201 |
|
} |
202 |
|
} |
203 |
|
}); |
204 |
|
|
205 |
0 |
exampleAccession = new JLabel(""); |
206 |
0 |
exampleAccession.setFont(new Font("Verdana", Font.BOLD, 11)); |
207 |
0 |
JLabel jLabel1 = new JLabel(MessageManager |
208 |
|
.getString("label.separate_multiple_accession_ids")); |
209 |
0 |
jLabel1.setFont(new Font("Verdana", Font.ITALIC, 11)); |
210 |
0 |
jLabel1.setHorizontalAlignment(SwingConstants.LEFT); |
211 |
|
|
212 |
0 |
replacePunctuation = new JCheckBox( |
213 |
|
MessageManager.getString("label.replace_commas_semicolons")); |
214 |
0 |
replacePunctuation.setHorizontalAlignment(SwingConstants.LEFT); |
215 |
0 |
replacePunctuation.setFont(new Font("Verdana", Font.ITALIC, 11)); |
216 |
0 |
okBtn = new JButton(MessageManager.getString("action.ok")); |
217 |
0 |
okBtn.addActionListener(new ActionListener() |
218 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
219 |
0 |
@Override... |
220 |
|
public void actionPerformed(ActionEvent e) |
221 |
|
{ |
222 |
0 |
ok_actionPerformed(); |
223 |
|
} |
224 |
|
}); |
225 |
0 |
JButton clear = new JButton(MessageManager.getString("action.clear")); |
226 |
0 |
clear.addActionListener(new ActionListener() |
227 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
228 |
0 |
@Override... |
229 |
|
public void actionPerformed(ActionEvent e) |
230 |
|
{ |
231 |
0 |
clear_actionPerformed(); |
232 |
|
} |
233 |
|
}); |
234 |
|
|
235 |
0 |
exampleBtn = new JButton(MessageManager.getString("label.example")); |
236 |
0 |
exampleBtn.addActionListener(new ActionListener() |
237 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
238 |
0 |
@Override... |
239 |
|
public void actionPerformed(ActionEvent e) |
240 |
|
{ |
241 |
0 |
example_actionPerformed(); |
242 |
|
} |
243 |
|
}); |
244 |
0 |
closeBtn = new JButton(MessageManager.getString("action.cancel")); |
245 |
0 |
closeBtn.addActionListener(new ActionListener() |
246 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
247 |
0 |
@Override... |
248 |
|
public void actionPerformed(ActionEvent e) |
249 |
|
{ |
250 |
0 |
close_actionPerformed(e); |
251 |
|
} |
252 |
|
}); |
253 |
0 |
backBtn = new JButton(MessageManager.getString("action.back")); |
254 |
0 |
backBtn.addActionListener(new ActionListener() |
255 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
256 |
0 |
@Override... |
257 |
|
public void actionPerformed(ActionEvent e) |
258 |
|
{ |
259 |
0 |
parentSearchPanel.btn_back_ActionPerformed(); |
260 |
|
} |
261 |
|
}); |
262 |
|
|
263 |
0 |
backBtn.setVisible(false); |
264 |
|
|
265 |
0 |
textArea = new JTextArea(); |
266 |
0 |
textArea.setFont(JvSwingUtils.getLabelFont()); |
267 |
0 |
textArea.setLineWrap(true); |
268 |
0 |
textArea.addKeyListener(new KeyAdapter() |
269 |
|
{ |
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
270 |
0 |
@Override... |
271 |
|
public void keyPressed(KeyEvent e) |
272 |
|
{ |
273 |
0 |
if (e.getKeyCode() == KeyEvent.VK_ENTER) |
274 |
|
{ |
275 |
0 |
ok_actionPerformed(); |
276 |
|
} |
277 |
|
} |
278 |
|
}); |
279 |
|
|
280 |
0 |
JPanel actionPanel = new JPanel(); |
281 |
0 |
actionPanel.add(backBtn); |
282 |
0 |
actionPanel.add(exampleBtn); |
283 |
0 |
actionPanel.add(clear); |
284 |
0 |
actionPanel.add(okBtn); |
285 |
0 |
actionPanel.add(closeBtn); |
286 |
|
|
287 |
0 |
JPanel databasePanel = new JPanel(); |
288 |
0 |
databasePanel.setLayout(new BorderLayout()); |
289 |
0 |
databasePanel.add(database, BorderLayout.NORTH); |
290 |
0 |
databasePanel.add(exampleAccession, BorderLayout.CENTER); |
291 |
0 |
JPanel jPanel2a = new JPanel(new BorderLayout()); |
292 |
0 |
jPanel2a.add(jLabel1, BorderLayout.NORTH); |
293 |
0 |
jPanel2a.add(replacePunctuation, BorderLayout.SOUTH); |
294 |
0 |
databasePanel.add(jPanel2a, BorderLayout.SOUTH); |
295 |
|
|
296 |
0 |
JPanel idsPanel = new JPanel(); |
297 |
0 |
idsPanel.setLayout(new BorderLayout(0, 5)); |
298 |
0 |
JScrollPane jScrollPane1 = new JScrollPane(); |
299 |
0 |
jScrollPane1.getViewport().add(textArea); |
300 |
0 |
idsPanel.add(jScrollPane1, BorderLayout.CENTER); |
301 |
|
|
302 |
0 |
this.add(actionPanel, BorderLayout.SOUTH); |
303 |
0 |
this.add(idsPanel, BorderLayout.CENTER); |
304 |
0 |
this.add(databasePanel, BorderLayout.NORTH); |
305 |
|
} |
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
@param |
312 |
|
@return |
313 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
314 |
0 |
protected String getExampleQueries(String db)... |
315 |
|
{ |
316 |
0 |
StringBuilder sb = new StringBuilder(); |
317 |
0 |
HashSet<String> hs = new HashSet<>(); |
318 |
0 |
for (DbSourceProxy dbs : sfetch.getSourceProxy(db)) |
319 |
|
{ |
320 |
0 |
String tq = dbs.getTestQuery(); |
321 |
0 |
if (hs.add(tq)) |
322 |
|
{ |
323 |
0 |
if (sb.length() > 0) |
324 |
|
{ |
325 |
0 |
sb.append(";"); |
326 |
|
} |
327 |
0 |
sb.append(tq); |
328 |
|
} |
329 |
|
} |
330 |
0 |
return sb.toString(); |
331 |
|
} |
332 |
|
|
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
337 |
0 |
protected void otherSourceAction()... |
338 |
|
{ |
339 |
0 |
try |
340 |
|
{ |
341 |
0 |
String eq = exampleAccession.getText(); |
342 |
|
|
343 |
|
|
344 |
|
|
345 |
0 |
boolean enablePunct = !(eq != null && eq.indexOf(",") > -1); |
346 |
0 |
replacePunctuation.setEnabled(enablePunct); |
347 |
|
|
348 |
|
} catch (Exception ex) |
349 |
|
{ |
350 |
0 |
exampleAccession.setText(""); |
351 |
0 |
replacePunctuation.setEnabled(true); |
352 |
|
} |
353 |
0 |
repaint(); |
354 |
|
} |
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
|
360 |
|
@param |
361 |
|
@return |
362 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
363 |
0 |
protected String updateExampleQuery(String selectedDatabase)... |
364 |
|
{ |
365 |
0 |
String eq = getExampleQueries(selectedDatabase); |
366 |
0 |
exampleAccession.setText(MessageManager |
367 |
|
.formatMessage("label.example_query_param", new String[] |
368 |
|
{ eq })); |
369 |
0 |
return eq; |
370 |
|
} |
371 |
|
|
372 |
|
|
373 |
|
|
374 |
|
|
375 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
376 |
0 |
protected void example_actionPerformed()... |
377 |
|
{ |
378 |
0 |
String eq = getExampleQueries((String) database.getSelectedItem()); |
379 |
0 |
textArea.setText(eq); |
380 |
0 |
repaint(); |
381 |
|
} |
382 |
|
|
383 |
|
|
384 |
|
|
385 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
386 |
0 |
protected void clear_actionPerformed()... |
387 |
|
{ |
388 |
0 |
textArea.setText(""); |
389 |
0 |
repaint(); |
390 |
|
} |
391 |
|
|
392 |
|
|
393 |
|
|
394 |
|
|
395 |
|
|
396 |
|
@param |
397 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
398 |
0 |
protected void close_actionPerformed(ActionEvent e)... |
399 |
|
{ |
400 |
0 |
try |
401 |
|
{ |
402 |
0 |
frame.setClosed(true); |
403 |
0 |
if (parentSearchPanel != null) |
404 |
|
{ |
405 |
0 |
parentSearchPanel.btn_cancel_ActionPerformed(); |
406 |
|
} |
407 |
|
} catch (Exception ex) |
408 |
|
{ |
409 |
|
} |
410 |
|
} |
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 6 |
Complexity Density: 0.27 |
|
415 |
0 |
public void ok_actionPerformed()... |
416 |
|
{ |
417 |
|
|
418 |
|
|
419 |
|
|
420 |
0 |
String t0 = textArea.getText(); |
421 |
0 |
String text = t0.trim(); |
422 |
0 |
if (replacePunctuation.isEnabled() && replacePunctuation.isSelected()) |
423 |
|
{ |
424 |
0 |
text = text.replace(",", ";"); |
425 |
|
} |
426 |
0 |
text = text.replaceAll("(\\s|[; ])+", ";"); |
427 |
0 |
if (!t0.equals(text)) |
428 |
|
{ |
429 |
0 |
textArea.setText(text); |
430 |
|
} |
431 |
0 |
if (text.isEmpty()) |
432 |
|
{ |
433 |
|
|
434 |
0 |
showErrorMessage( |
435 |
|
"Please enter a (semi-colon separated list of) database id(s)"); |
436 |
0 |
resetDialog(); |
437 |
0 |
return; |
438 |
|
} |
439 |
0 |
if (database.getSelectedIndex() == 0) |
440 |
|
{ |
441 |
|
|
442 |
0 |
showErrorMessage("Please choose a database"); |
443 |
0 |
resetDialog(); |
444 |
0 |
return; |
445 |
|
} |
446 |
|
|
447 |
0 |
exampleBtn.setEnabled(false); |
448 |
0 |
textArea.setEnabled(false); |
449 |
0 |
okBtn.setEnabled(false); |
450 |
0 |
closeBtn.setEnabled(false); |
451 |
0 |
backBtn.setEnabled(false); |
452 |
|
|
453 |
0 |
Thread worker = new Thread(this); |
454 |
0 |
worker.start(); |
455 |
|
} |
456 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
457 |
0 |
private void resetDialog()... |
458 |
|
{ |
459 |
0 |
exampleBtn.setEnabled(true); |
460 |
0 |
textArea.setEnabled(true); |
461 |
0 |
okBtn.setEnabled(true); |
462 |
0 |
closeBtn.setEnabled(true); |
463 |
0 |
backBtn.setEnabled(parentSearchPanel != null); |
464 |
|
} |
465 |
|
|
|
|
| 0% |
Uncovered Elements: 108 (108) |
Complexity: 27 |
Complexity Density: 0.38 |
|
466 |
0 |
@Override... |
467 |
|
public void run() |
468 |
|
{ |
469 |
0 |
boolean addToLast = false; |
470 |
0 |
List<String> aresultq = new ArrayList<>(); |
471 |
0 |
List<String> presultTitle = new ArrayList<>(); |
472 |
0 |
List<AlignmentI> presult = new ArrayList<>(); |
473 |
0 |
List<AlignmentI> aresult = new ArrayList<>(); |
474 |
0 |
List<DbSourceProxy> sources = sfetch |
475 |
|
.getSourceProxy((String) database.getSelectedItem()); |
476 |
0 |
Iterator<DbSourceProxy> proxies = sources.iterator(); |
477 |
0 |
String[] qries = textArea.getText().trim().split(";"); |
478 |
0 |
List<String> nextFetch = Arrays.asList(qries); |
479 |
0 |
Iterator<String> en = Arrays.asList(new String[0]).iterator(); |
480 |
0 |
int nqueries = qries.length; |
481 |
|
|
482 |
0 |
FeatureSettingsModelI preferredFeatureColours = null; |
483 |
0 |
while (proxies.hasNext() && (en.hasNext() || nextFetch.size() > 0)) |
484 |
|
{ |
485 |
0 |
if (!en.hasNext() && nextFetch.size() > 0) |
486 |
|
{ |
487 |
0 |
en = nextFetch.iterator(); |
488 |
0 |
nqueries = nextFetch.size(); |
489 |
|
|
490 |
0 |
qries = nextFetch.toArray(new String[nqueries]); |
491 |
0 |
nextFetch = new ArrayList<>(); |
492 |
|
} |
493 |
|
|
494 |
0 |
DbSourceProxy proxy = proxies.next(); |
495 |
0 |
try |
496 |
|
{ |
497 |
|
|
498 |
0 |
guiWindow.setProgressBar(MessageManager.formatMessage( |
499 |
|
"status.fetching_sequence_queries_from", new String[] |
500 |
|
{ Integer.valueOf(nqueries).toString(), |
501 |
|
proxy.getDbName() }), |
502 |
|
Thread.currentThread().hashCode()); |
503 |
0 |
if (proxy.getMaximumQueryCount() == 1) |
504 |
|
{ |
505 |
|
|
506 |
|
|
507 |
|
|
508 |
0 |
while (en.hasNext()) |
509 |
|
{ |
510 |
0 |
String acc = en.next(); |
511 |
0 |
if (!fetchSingleAccession(proxy, acc, aresultq, aresult)) |
512 |
|
{ |
513 |
0 |
nextFetch.add(acc); |
514 |
|
} |
515 |
|
} |
516 |
|
} |
517 |
|
else |
518 |
|
{ |
519 |
|
|
520 |
|
|
521 |
|
|
522 |
0 |
fetchMultipleAccessions(proxy, en, aresultq, aresult, nextFetch); |
523 |
|
} |
524 |
|
} catch (Exception e) |
525 |
|
{ |
526 |
0 |
showErrorMessage("Error retrieving " + textArea.getText() + " from " |
527 |
|
+ database.getSelectedItem()); |
528 |
|
|
529 |
|
|
530 |
0 |
System.err.println("Retrieval failed for source ='" |
531 |
|
+ database.getSelectedItem() + "' and query\n'" |
532 |
|
+ textArea.getText() + "'\n"); |
533 |
0 |
e.printStackTrace(); |
534 |
|
} catch (OutOfMemoryError e) |
535 |
|
{ |
536 |
0 |
showErrorMessage("Out of Memory when retrieving " |
537 |
|
+ textArea.getText() + " from " + database.getSelectedItem() |
538 |
|
+ "\nPlease see the Jalview FAQ for instructions for increasing the memory available to Jalview.\n"); |
539 |
0 |
e.printStackTrace(); |
540 |
|
} catch (Error e) |
541 |
|
{ |
542 |
0 |
showErrorMessage("Serious Error retrieving " + textArea.getText() |
543 |
|
+ " from " + database.getSelectedItem()); |
544 |
0 |
e.printStackTrace(); |
545 |
|
} |
546 |
|
|
547 |
|
|
548 |
0 |
if (aresult != null && aresult.size() > 0) |
549 |
|
{ |
550 |
0 |
FeatureSettingsModelI proxyColourScheme = proxy |
551 |
|
.getFeatureColourScheme(); |
552 |
0 |
if (proxyColourScheme != null) |
553 |
|
{ |
554 |
0 |
preferredFeatureColours = proxyColourScheme; |
555 |
|
} |
556 |
|
|
557 |
0 |
AlignmentI ar = null; |
558 |
0 |
if (proxy.isAlignmentSource()) |
559 |
|
{ |
560 |
0 |
addToLast = false; |
561 |
|
|
562 |
0 |
while (aresult.size() > 0) |
563 |
|
{ |
564 |
0 |
presult.add(aresult.remove(0)); |
565 |
0 |
presultTitle.add( |
566 |
|
aresultq.remove(0) + " " + getDefaultRetrievalTitle()); |
567 |
|
} |
568 |
|
} |
569 |
|
else |
570 |
|
{ |
571 |
0 |
String titl = null; |
572 |
0 |
if (addToLast && presult.size() > 0) |
573 |
|
{ |
574 |
0 |
ar = presult.remove(presult.size() - 1); |
575 |
0 |
titl = presultTitle.remove(presultTitle.size() - 1); |
576 |
|
} |
577 |
|
|
578 |
0 |
while (aresult.size() > 0) |
579 |
|
{ |
580 |
0 |
if (ar == null) |
581 |
|
{ |
582 |
0 |
ar = aresult.remove(0); |
583 |
|
} |
584 |
|
else |
585 |
|
{ |
586 |
0 |
ar.append(aresult.remove(0)); |
587 |
|
} |
588 |
|
} |
589 |
0 |
addToLast = true; |
590 |
0 |
presult.add(ar); |
591 |
0 |
presultTitle.add(titl); |
592 |
|
} |
593 |
|
} |
594 |
0 |
guiWindow.setProgressBar( |
595 |
|
MessageManager.getString("status.finshed_querying"), |
596 |
|
Thread.currentThread().hashCode()); |
597 |
|
} |
598 |
0 |
guiWindow |
599 |
|
.setProgressBar( |
600 |
0 |
(presult.size() > 0) |
601 |
|
? MessageManager |
602 |
|
.getString("status.parsing_results") |
603 |
|
: MessageManager.getString("status.processing"), |
604 |
|
Thread.currentThread().hashCode()); |
605 |
|
|
606 |
0 |
while (presult.size() > 0) |
607 |
|
{ |
608 |
0 |
parseResult(presult.remove(0), presultTitle.remove(0), null, |
609 |
|
preferredFeatureColours); |
610 |
|
} |
611 |
|
|
612 |
0 |
guiWindow.setProgressBar(null, Thread.currentThread().hashCode()); |
613 |
0 |
if (nextFetch.size() > 0) |
614 |
|
{ |
615 |
0 |
StringBuffer sb = new StringBuffer(); |
616 |
0 |
sb.append("Didn't retrieve the following " |
617 |
0 |
+ (nextFetch.size() == 1 ? "query" |
618 |
|
: nextFetch.size() + " queries") |
619 |
|
+ ": \n"); |
620 |
0 |
int l = sb.length(), lr = 0; |
621 |
0 |
for (String s : nextFetch) |
622 |
|
{ |
623 |
0 |
if (l != sb.length()) |
624 |
|
{ |
625 |
0 |
sb.append("; "); |
626 |
|
} |
627 |
0 |
if (lr - sb.length() > 40) |
628 |
|
{ |
629 |
0 |
sb.append("\n"); |
630 |
|
} |
631 |
0 |
sb.append(s); |
632 |
|
} |
633 |
0 |
showErrorMessage(sb.toString()); |
634 |
|
} |
635 |
0 |
resetDialog(); |
636 |
|
} |
637 |
|
|
638 |
|
|
639 |
|
|
640 |
|
|
641 |
|
@param |
642 |
|
@param |
643 |
|
|
644 |
|
@param |
645 |
|
|
646 |
|
@param |
647 |
|
|
648 |
|
@param |
649 |
|
|
650 |
|
@throws |
651 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 7 |
Complexity Density: 0.39 |
|
652 |
0 |
void fetchMultipleAccessions(DbSourceProxy proxy,... |
653 |
|
Iterator<String> accessions, List<String> aresultq, |
654 |
|
List<AlignmentI> aresult, List<String> nextFetch) throws Exception |
655 |
|
{ |
656 |
0 |
StringBuilder multiacc = new StringBuilder(); |
657 |
0 |
List<String> tosend = new ArrayList<>(); |
658 |
0 |
while (accessions.hasNext()) |
659 |
|
{ |
660 |
0 |
String nel = accessions.next(); |
661 |
0 |
tosend.add(nel); |
662 |
0 |
multiacc.append(nel); |
663 |
0 |
if (accessions.hasNext()) |
664 |
|
{ |
665 |
0 |
multiacc.append(proxy.getAccessionSeparator()); |
666 |
|
} |
667 |
|
} |
668 |
|
|
669 |
0 |
try |
670 |
|
{ |
671 |
0 |
String query = multiacc.toString(); |
672 |
0 |
AlignmentI rslt = proxy.getSequenceRecords(query); |
673 |
0 |
if (rslt == null || rslt.getHeight() == 0) |
674 |
|
{ |
675 |
|
|
676 |
0 |
nextFetch.addAll(tosend); |
677 |
|
} |
678 |
|
else |
679 |
|
{ |
680 |
0 |
aresultq.add(query); |
681 |
0 |
aresult.add(rslt); |
682 |
0 |
if (tosend.size() > 1) |
683 |
|
{ |
684 |
0 |
checkResultForQueries(rslt, tosend, nextFetch, proxy); |
685 |
|
} |
686 |
|
} |
687 |
|
} catch (OutOfMemoryError oome) |
688 |
|
{ |
689 |
0 |
new OOMWarning("fetching " + multiacc + " from " |
690 |
|
+ database.getSelectedItem(), oome, this); |
691 |
|
} |
692 |
|
} |
693 |
|
|
694 |
|
|
695 |
|
|
696 |
|
|
697 |
|
@param |
698 |
|
@param |
699 |
|
@param |
700 |
|
|
701 |
|
@param |
702 |
|
|
703 |
|
@return |
704 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 6 |
Complexity Density: 0.4 |
|
705 |
0 |
boolean fetchSingleAccession(DbSourceProxy proxy, String accession,... |
706 |
|
List<String> aresultq, List<AlignmentI> aresult) |
707 |
|
{ |
708 |
0 |
boolean success = false; |
709 |
0 |
try |
710 |
|
{ |
711 |
0 |
if (aresult != null) |
712 |
|
{ |
713 |
0 |
try |
714 |
|
{ |
715 |
|
|
716 |
0 |
Thread.sleep(5); |
717 |
|
} catch (Exception e) |
718 |
|
{ |
719 |
|
|
720 |
|
} |
721 |
|
} |
722 |
|
|
723 |
0 |
AlignmentI indres = null; |
724 |
0 |
try |
725 |
|
{ |
726 |
0 |
indres = proxy.getSequenceRecords(accession); |
727 |
|
} catch (OutOfMemoryError oome) |
728 |
|
{ |
729 |
0 |
new OOMWarning( |
730 |
|
"fetching " + accession + " from " + proxy.getDbName(), |
731 |
|
oome, this); |
732 |
|
} |
733 |
0 |
if (indres != null) |
734 |
|
{ |
735 |
0 |
aresultq.add(accession); |
736 |
0 |
aresult.add(indres); |
737 |
0 |
success = true; |
738 |
|
} |
739 |
|
} catch (Exception e) |
740 |
|
{ |
741 |
0 |
Cache.log.info("Error retrieving " + accession + " from " |
742 |
|
+ proxy.getDbName(), e); |
743 |
|
} |
744 |
0 |
return success; |
745 |
|
} |
746 |
|
|
747 |
|
|
748 |
|
|
749 |
|
|
750 |
|
|
751 |
|
|
752 |
|
@param |
753 |
|
@param |
754 |
|
@param |
755 |
|
@param |
756 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.42 |
|
757 |
0 |
void checkResultForQueries(AlignmentI rslt, List<String> queries,... |
758 |
|
List<String> nextFetch, DbSourceProxy proxy) |
759 |
|
{ |
760 |
0 |
SequenceI[] rs = rslt.getSequencesArray(); |
761 |
|
|
762 |
0 |
for (String q : queries) |
763 |
|
{ |
764 |
|
|
765 |
|
|
766 |
|
|
767 |
|
|
768 |
0 |
String accId = proxy.getAccessionIdFromQuery(q); |
769 |
|
|
770 |
0 |
boolean rfound = false; |
771 |
0 |
for (int r = 0, nr = rs.length; r < nr; r++) |
772 |
|
{ |
773 |
0 |
if (rs[r] != null) |
774 |
|
{ |
775 |
0 |
List<DBRefEntry> found = DBRefUtils.searchRefs(rs[r].getDBRefs(), |
776 |
|
accId); |
777 |
0 |
if (!found.isEmpty()) |
778 |
|
{ |
779 |
0 |
rfound = true; |
780 |
0 |
break; |
781 |
|
} |
782 |
|
} |
783 |
|
} |
784 |
0 |
if (!rfound) |
785 |
|
{ |
786 |
0 |
nextFetch.add(q); |
787 |
|
} |
788 |
|
} |
789 |
|
} |
790 |
|
|
791 |
|
|
792 |
|
|
793 |
|
@return |
794 |
|
|
795 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
796 |
0 |
public String getDefaultRetrievalTitle()... |
797 |
|
{ |
798 |
0 |
return "Retrieved from " + database.getSelectedItem(); |
799 |
|
} |
800 |
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 10 |
Complexity Density: 0.43 |
|
801 |
0 |
AlignmentI parseResult(AlignmentI al, String title,... |
802 |
|
FileFormatI currentFileFormat, |
803 |
|
FeatureSettingsModelI preferredFeatureColours) |
804 |
|
{ |
805 |
|
|
806 |
0 |
if (al != null && al.getHeight() > 0) |
807 |
|
{ |
808 |
0 |
if (title == null) |
809 |
|
{ |
810 |
0 |
title = getDefaultRetrievalTitle(); |
811 |
|
} |
812 |
0 |
if (alignFrame == null) |
813 |
|
{ |
814 |
0 |
AlignFrame af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH, |
815 |
|
AlignFrame.DEFAULT_HEIGHT); |
816 |
0 |
if (currentFileFormat != null) |
817 |
|
{ |
818 |
0 |
af.currentFileFormat = currentFileFormat; |
819 |
|
} |
820 |
|
|
821 |
0 |
List<SequenceI> alsqs = al.getSequences(); |
822 |
0 |
synchronized (alsqs) |
823 |
|
{ |
824 |
0 |
for (SequenceI sq : alsqs) |
825 |
|
{ |
826 |
0 |
if (sq.getFeatures().hasFeatures()) |
827 |
|
{ |
828 |
0 |
af.setShowSeqFeatures(true); |
829 |
0 |
break; |
830 |
|
} |
831 |
|
} |
832 |
|
} |
833 |
|
|
834 |
0 |
if (preferredFeatureColours != null) |
835 |
|
{ |
836 |
0 |
af.getViewport().applyFeaturesStyle(preferredFeatureColours); |
837 |
|
} |
838 |
0 |
if (Cache.getDefault("HIDE_INTRONS", true)) |
839 |
|
{ |
840 |
0 |
af.hideFeatureColumns(SequenceOntologyI.EXON, false); |
841 |
|
} |
842 |
0 |
Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH, |
843 |
|
AlignFrame.DEFAULT_HEIGHT); |
844 |
|
|
845 |
0 |
af.setStatus(MessageManager |
846 |
|
.getString("label.successfully_pasted_alignment_file")); |
847 |
|
|
848 |
0 |
try |
849 |
|
{ |
850 |
0 |
af.setMaximum(Cache.getDefault("SHOW_FULLSCREEN", false)); |
851 |
|
} catch (Exception ex) |
852 |
|
{ |
853 |
|
} |
854 |
|
} |
855 |
|
else |
856 |
|
{ |
857 |
0 |
alignFrame.viewport.addAlignment(al, title); |
858 |
|
} |
859 |
|
} |
860 |
0 |
return al; |
861 |
|
} |
862 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
863 |
0 |
void showErrorMessage(final String error)... |
864 |
|
{ |
865 |
0 |
resetDialog(); |
866 |
0 |
javax.swing.SwingUtilities.invokeLater(new Runnable() |
867 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
868 |
0 |
@Override... |
869 |
|
public void run() |
870 |
|
{ |
871 |
0 |
JvOptionPane.showInternalMessageDialog(Desktop.desktop, error, |
872 |
|
MessageManager.getString("label.error_retrieving_data"), |
873 |
|
JvOptionPane.WARNING_MESSAGE); |
874 |
|
} |
875 |
|
}); |
876 |
|
} |
877 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
878 |
0 |
public IProgressIndicator getProgressIndicator()... |
879 |
|
{ |
880 |
0 |
return progressIndicator; |
881 |
|
} |
882 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
883 |
0 |
public void setProgressIndicator(IProgressIndicator progressIndicator)... |
884 |
|
{ |
885 |
0 |
this.progressIndicator = progressIndicator; |
886 |
|
} |
887 |
|
|
888 |
|
|
889 |
|
|
890 |
|
|
891 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
892 |
0 |
void hidePanel()... |
893 |
|
{ |
894 |
0 |
frame.setVisible(false); |
895 |
|
} |
896 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
897 |
0 |
public void setQuery(String ids)... |
898 |
|
{ |
899 |
0 |
textArea.setText(ids); |
900 |
|
} |
901 |
|
|
902 |
|
|
903 |
|
|
904 |
|
|
905 |
|
|
906 |
|
|
907 |
|
|
908 |
|
@param |
909 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
910 |
0 |
public void embedIn(GFTSPanel parentPanel)... |
911 |
|
{ |
912 |
0 |
database.setVisible(false); |
913 |
0 |
backBtn.setVisible(true); |
914 |
0 |
parentSearchPanel = parentPanel; |
915 |
|
} |
916 |
|
} |