use OOMwarning to warn user when out of Memory occurs
[jalview.git] / src / jalview / gui / SequenceFetcher.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3  * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  * 
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18  */
19 package jalview.gui;
20
21 import java.io.*;
22 import java.util.*;
23
24 import java.awt.*;
25 import java.awt.event.*;
26
27 import javax.swing.*;
28
29 import MCview.*;
30 import jalview.datamodel.*;
31 import jalview.datamodel.xdb.embl.*;
32 import java.io.File;
33 import jalview.io.*;
34 import jalview.ws.DBRefFetcher;
35 import jalview.ws.ebi.EBIFetchClient;
36 import jalview.ws.seqfetcher.ASequenceFetcher;
37 import jalview.ws.seqfetcher.DbSourceProxy;
38
39 import java.awt.Rectangle;
40 import java.awt.BorderLayout;
41 import java.awt.Dimension;
42
43 public class SequenceFetcher extends JPanel implements Runnable
44 {
45   // ASequenceFetcher sfetch;
46   JInternalFrame frame;
47
48   IProgressIndicator guiWindow;
49
50   AlignFrame alignFrame;
51
52   StringBuffer result;
53
54   final String noDbSelected = "-- Select Database --";
55
56   Hashtable sources = new Hashtable();
57
58   private static jalview.ws.SequenceFetcher sfetch = null;
59
60   private static String dasRegistry = null;
61   /**
62    * Blocking method that initialises and returns the shared instance of the SequenceFetcher client 
63    * @param guiWindow - where the initialisation delay message should be shown
64    * @return the singleton instance of the sequence fetcher client
65    */
66   public static jalview.ws.SequenceFetcher getSequenceFetcherSingleton(final IProgressIndicator guiWindow) {
67     if (sfetch == null
68             || dasRegistry != DasSourceBrowser.getDasRegistryURL())
69     {
70       /**
71        * give a visual indication that sequence fetcher construction is
72        * occuring
73        */
74       if (guiWindow != null)
75       {
76         guiWindow.setProgressBar(
77                 "Initialising Sequence Database Fetchers", Thread.currentThread()
78                         .hashCode());
79       }
80       dasRegistry = DasSourceBrowser.getDasRegistryURL();
81       jalview.ws.SequenceFetcher sf = new jalview.ws.SequenceFetcher();
82       if (guiWindow != null)
83       {
84         guiWindow.setProgressBar(
85                 "Initialising Sequence Database Fetchers", Thread.currentThread().hashCode());
86       }
87       sfetch = sf;
88
89     }
90     return sfetch;
91   }
92   public SequenceFetcher(IProgressIndicator guiIndic)
93   {
94     final IProgressIndicator guiWindow = guiIndic;
95     final SequenceFetcher us = this;
96     // launch initialiser thread
97     Thread sf = new Thread(new Runnable()
98     {
99
100       public void run()
101       {
102         if (getSequenceFetcherSingleton(guiWindow)!=null)
103         {
104           us.initGui(guiWindow);
105         } else {
106           javax.swing.SwingUtilities.invokeLater(new Runnable()
107           {
108             public void run()
109             {
110               JOptionPane.showInternalMessageDialog(Desktop.desktop, 
111                       "Could not create the sequence fetcher client. Check error logs for details.",
112                       "Couldn't create SequenceFetcher", JOptionPane.ERROR_MESSAGE);
113             }
114           });
115           
116           // raise warning dialog
117         }
118       }
119     });
120     sf.start();
121   }
122
123   /**
124    * called by thread spawned by constructor
125    * 
126    * @param guiWindow
127    */
128   private void initGui(IProgressIndicator guiWindow)
129   {
130     this.guiWindow = guiWindow;
131     if (guiWindow instanceof AlignFrame)
132     {
133       alignFrame = (AlignFrame) guiWindow;
134     }
135
136     database.addItem(noDbSelected);
137     /*
138      * Dynamically generated database list will need a translation function from
139      * internal source to externally distinct names. UNIPROT and UP_NAME are
140      * identical DB sources, and should be collapsed.
141      */
142
143     String dbs[] = sfetch.getOrderedSupportedSources();
144     for (int i = 0; i < dbs.length; i++)
145     {
146       if (!sources.containsValue(dbs[i]))
147       {
148         String name = sfetch.getSourceProxy(dbs[i]).getDbName();
149         // duplicate source names are thrown away, here.
150         if (!sources.containsKey(name))
151         {
152           database.addItem(name);
153         }
154         // overwrite with latest version of the retriever for this source
155         sources.put(name, dbs[i]);
156       }
157     }
158     try
159     {
160       jbInit();
161     } catch (Exception ex)
162     {
163       ex.printStackTrace();
164     }
165
166     frame = new JInternalFrame();
167     frame.setContentPane(this);
168     if (new jalview.util.Platform().isAMac())
169     {
170       Desktop.addInternalFrame(frame, getFrameTitle(), 400, 180);
171     }
172     else
173     {
174       Desktop.addInternalFrame(frame, getFrameTitle(), 400, 140);
175     }
176   }
177
178   private String getFrameTitle()
179   {
180     return ((alignFrame == null) ? "New " : "Additional ")
181             + "Sequence Fetcher";
182   }
183
184   private void jbInit() throws Exception
185   {
186     this.setLayout(borderLayout2);
187
188     database.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
189     dbeg.setFont(new java.awt.Font("Verdana", Font.BOLD, 11));
190     jLabel1.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
191     jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
192     jLabel1
193             .setText("Separate multiple accession ids with semi colon \";\"");
194     ok.setText("OK");
195     ok.addActionListener(new ActionListener()
196     {
197       public void actionPerformed(ActionEvent e)
198       {
199         ok_actionPerformed();
200       }
201     });
202     clear.setText("Clear");
203     clear.addActionListener(new ActionListener()
204     {
205       public void actionPerformed(ActionEvent e)
206       {
207         clear_actionPerformed();
208       }
209     });
210
211     example.setText("Example");
212     example.addActionListener(new ActionListener()
213     {
214       public void actionPerformed(ActionEvent e)
215       {
216         example_actionPerformed();
217       }
218     });
219     close.setText("Close");
220     close.addActionListener(new ActionListener()
221     {
222       public void actionPerformed(ActionEvent e)
223       {
224         close_actionPerformed(e);
225       }
226     });
227     textArea.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
228     textArea.setLineWrap(true);
229     textArea.addKeyListener(new KeyAdapter()
230     {
231       public void keyPressed(KeyEvent e)
232       {
233         if (e.getKeyCode() == KeyEvent.VK_ENTER)
234           ok_actionPerformed();
235       }
236     });
237     jPanel3.setLayout(borderLayout1);
238     borderLayout1.setVgap(5);
239     jPanel1.add(ok);
240     jPanel1.add(example);
241     jPanel1.add(clear);
242     jPanel1.add(close);
243     jPanel3.add(jPanel2, java.awt.BorderLayout.CENTER);
244     jPanel2.setLayout(borderLayout3);
245
246     database.addActionListener(new ActionListener()
247     {
248
249       public void actionPerformed(ActionEvent e)
250       {
251         DbSourceProxy db = null;
252         try
253         {
254           db = sfetch.getSourceProxy((String) sources.get(database
255                   .getSelectedItem()));
256           dbeg.setText("Example query: " + db.getTestQuery());
257         } catch (Exception ex)
258         {
259           dbeg.setText("");
260         }
261         jPanel2.repaint();
262       }
263     });
264     dbeg.setText("");
265     jPanel2.add(database, java.awt.BorderLayout.NORTH);
266     jPanel2.add(dbeg, java.awt.BorderLayout.CENTER);
267     jPanel2.add(jLabel1, java.awt.BorderLayout.SOUTH);
268     // jPanel2.setPreferredSize(new Dimension())
269     jPanel3.add(jScrollPane1, java.awt.BorderLayout.CENTER);
270     this.add(jPanel1, java.awt.BorderLayout.SOUTH);
271     this.add(jPanel3, java.awt.BorderLayout.CENTER);
272     this.add(jPanel2, java.awt.BorderLayout.NORTH);
273     jScrollPane1.getViewport().add(textArea);
274
275   }
276
277   protected void example_actionPerformed()
278   {
279     DbSourceProxy db = null;
280     try
281     {
282       db = sfetch.getSourceProxy((String) sources.get(database
283               .getSelectedItem()));
284       textArea.setText(db.getTestQuery());
285     } catch (Exception ex)
286     {
287     }
288     jPanel3.repaint();
289   }
290
291   protected void clear_actionPerformed()
292   {
293     textArea.setText("");
294     jPanel3.repaint();
295   }
296
297   JLabel dbeg = new JLabel();
298
299   JComboBox database = new JComboBox();
300
301   JLabel jLabel1 = new JLabel();
302
303   JButton ok = new JButton();
304
305   JButton clear = new JButton();
306
307   JButton example = new JButton();
308
309   JButton close = new JButton();
310
311   JPanel jPanel1 = new JPanel();
312
313   JTextArea textArea = new JTextArea();
314
315   JScrollPane jScrollPane1 = new JScrollPane();
316
317   JPanel jPanel2 = new JPanel();
318
319   JPanel jPanel3 = new JPanel();
320
321   JPanel jPanel4 = new JPanel();
322
323   BorderLayout borderLayout1 = new BorderLayout();
324
325   BorderLayout borderLayout2 = new BorderLayout();
326
327   BorderLayout borderLayout3 = new BorderLayout();
328
329   public void close_actionPerformed(ActionEvent e)
330   {
331     try
332     {
333       frame.setClosed(true);
334     } catch (Exception ex)
335     {
336     }
337   }
338
339   public void ok_actionPerformed()
340   {
341     database.setEnabled(false);
342     textArea.setEnabled(false);
343     ok.setEnabled(false);
344     close.setEnabled(false);
345
346     Thread worker = new Thread(this);
347     worker.start();
348   }
349
350   private void resetDialog()
351   {
352     database.setEnabled(true);
353     textArea.setEnabled(true);
354     ok.setEnabled(true);
355     close.setEnabled(true);
356   }
357
358   public void run()
359   {
360     String error = "";
361     if (database.getSelectedItem().equals(noDbSelected))
362     {
363       error += "Please select the source database\n";
364     }
365     com.stevesoft.pat.Regex empty = new com.stevesoft.pat.Regex("\\s+", "");
366     textArea.setText(empty.replaceAll(textArea.getText()));
367     if (textArea.getText().length() == 0)
368     {
369       error += "Please enter a (semi-colon separated list of) database id(s)";
370     }
371     if (error.length() > 0)
372     {
373       showErrorMessage(error);
374       resetDialog();
375       return;
376     }
377     AlignmentI aresult = null;
378     try
379     {
380       guiWindow.setProgressBar("Fetching Sequences from "
381               + database.getSelectedItem(), Thread.currentThread()
382               .hashCode());
383       aresult = sfetch.getSourceProxy(
384               (String) sources.get(database.getSelectedItem()))
385               .getSequenceRecords(textArea.getText());
386
387     } catch (Exception e)
388     {
389       showErrorMessage("Error retrieving " + textArea.getText() + " from "
390               + database.getSelectedItem());
391       // error +="Couldn't retrieve sequences from "+database.getSelectedItem();
392       System.err.println("Retrieval failed for source ='"
393               + database.getSelectedItem() + "' and query\n'"
394               + textArea.getText() + "'\n");
395       e.printStackTrace();
396     } catch (OutOfMemoryError e)
397     {
398       // resets dialog box - so we don't use OOMwarning here.
399       showErrorMessage("Out of Memory when retrieving "
400               + textArea.getText()
401               + " from "
402               + database.getSelectedItem()
403               + "\nPlease see the Jalview FAQ for instructions for increasing the memory available to Jalview.\n");
404       e.printStackTrace();
405     } catch (Error e)
406     {
407       showErrorMessage("Serious Error retrieving " + textArea.getText()
408               + " from " + database.getSelectedItem());
409       e.printStackTrace();
410     }
411     if (aresult != null)
412     {
413       parseResult(aresult, null, null);
414     }
415     // only remove visual delay after we finished parsing.
416     guiWindow.setProgressBar(null, Thread.currentThread().hashCode());
417     resetDialog();
418   }
419
420   /*
421    * result = new StringBuffer(); if
422    * (database.getSelectedItem().equals("Uniprot")) {
423    * getUniprotFile(textArea.getText()); } else if
424    * (database.getSelectedItem().equals("EMBL") ||
425    * database.getSelectedItem().equals("EMBLCDS")) { String DBRefSource =
426    * database.getSelectedItem().equals("EMBLCDS") ?
427    * jalview.datamodel.DBRefSource.EMBLCDS : jalview.datamodel.DBRefSource.EMBL;
428    * 
429    * StringTokenizer st = new StringTokenizer(textArea.getText(), ";");
430    * SequenceI[] seqs = null; while(st.hasMoreTokens()) { EBIFetchClient dbFetch =
431    * new EBIFetchClient(); String qry =
432    * database.getSelectedItem().toString().toLowerCase( ) + ":" +
433    * st.nextToken(); File reply = dbFetch.fetchDataAsFile( qry, "emblxml",null);
434    * 
435    * jalview.datamodel.xdb.embl.EmblFile efile=null; if (reply != null &&
436    * reply.exists()) { efile =
437    * jalview.datamodel.xdb.embl.EmblFile.getEmblFile(reply); } if (efile!=null) {
438    * for (Iterator i=efile.getEntries().iterator(); i.hasNext(); ) { EmblEntry
439    * entry = (EmblEntry) i.next(); SequenceI[] seqparts =
440    * entry.getSequences(false,true, DBRefSource); if (seqparts!=null) {
441    * SequenceI[] newseqs = null; int si=0; if (seqs==null) { newseqs = new
442    * SequenceI[seqparts.length]; } else { newseqs = new
443    * SequenceI[seqs.length+seqparts.length];
444    * 
445    * for (;si<seqs.length; si++) { newseqs[si] = seqs[si]; seqs[si] = null; } }
446    * for (int j=0;j<seqparts.length; si++, j++) { newseqs[si] =
447    * seqparts[j].deriveSequence(); // place DBReferences on dataset and refer }
448    * seqs=newseqs;
449    *  } } } else { result.append("# no response for "+qry); } } if (seqs!=null &&
450    * seqs.length>0) { if (parseResult(new Alignment(seqs), null, null)!=null) {
451    * result.append("# Successfully parsed the "+database.getSelectedItem()+"
452    * Queries into an Alignment"); } } } else if
453    * (database.getSelectedItem().equals("PDB")) { StringTokenizer qset = new
454    * StringTokenizer(textArea.getText(), ";"); String query; SequenceI[] seqs =
455    * null; while (qset.hasMoreTokens() && ((query = qset.nextToken())!=null)) {
456    * SequenceI[] seqparts = getPDBFile(query.toUpperCase()); if (seqparts !=
457    * null) { if (seqs == null) { seqs = seqparts; } else { SequenceI[] newseqs =
458    * new SequenceI[seqs.length+seqparts.length]; int i=0; for (; i <
459    * seqs.length; i++) { newseqs[i] = seqs[i]; seqs[i] = null; } for (int j=0;j<seqparts.length;
460    * i++, j++) { newseqs[i] = seqparts[j]; } seqs=newseqs; } result.append("#
461    * Success for "+query.toUpperCase()+"\n"); } } if (seqs != null &&
462    * seqs.length > 0) { if (parseResult(new Alignment(seqs), null, null)!=null) {
463    * result.append( "# Successfully parsed the PDB File Queries into an
464    * Alignment"); } } } else if( database.getSelectedItem().equals("PFAM")) {
465    * try { result.append(new FastaFile(
466    * "http://www.sanger.ac.uk/cgi-bin/Pfam/getalignment.pl?format=fal&acc=" +
467    * textArea.getText().toUpperCase(), "URL").print() );
468    * 
469    * if(result.length()>0) { parseResult( result.toString(),
470    * textArea.getText().toUpperCase() ); }
471    *  } catch (java.io.IOException ex) { result = null; } }
472    * 
473    * if (result == null || result.length() == 0) { showErrorMessage("Error
474    * retrieving " + textArea.getText() + " from " + database.getSelectedItem()); }
475    * 
476    * resetDialog(); return; }
477    * 
478    * void getUniprotFile(String id) { EBIFetchClient ebi = new EBIFetchClient();
479    * File file = ebi.fetchDataAsFile("uniprot:" + id, "xml", null);
480    * 
481    * DBRefFetcher dbref = new DBRefFetcher(); Vector entries =
482    * dbref.getUniprotEntries(file);
483    * 
484    * if (entries != null) { //First, make the new sequences Enumeration en =
485    * entries.elements(); while (en.hasMoreElements()) { UniprotEntry entry =
486    * (UniprotEntry) en.nextElement();
487    * 
488    * StringBuffer name = new StringBuffer(">UniProt/Swiss-Prot"); Enumeration
489    * en2 = entry.getAccession().elements(); while (en2.hasMoreElements()) {
490    * name.append("|"); name.append(en2.nextElement()); } en2 =
491    * entry.getName().elements(); while (en2.hasMoreElements()) {
492    * name.append("|"); name.append(en2.nextElement()); }
493    * 
494    * if (entry.getProtein() != null) { name.append(" " +
495    * entry.getProtein().getName().elementAt(0)); }
496    * 
497    * result.append(name + "\n" + entry.getUniprotSequence().getContent() +
498    * "\n");
499    *  }
500    * 
501    * //Then read in the features and apply them to the dataset Alignment al =
502    * parseResult(result.toString(), null); for (int i = 0; i < entries.size();
503    * i++) { UniprotEntry entry = (UniprotEntry) entries.elementAt(i);
504    * Enumeration e = entry.getDbReference().elements(); Vector onlyPdbEntries =
505    * new Vector(); while (e.hasMoreElements()) { PDBEntry pdb = (PDBEntry)
506    * e.nextElement(); if (!pdb.getType().equals("PDB")) { continue; }
507    * 
508    * onlyPdbEntries.addElement(pdb); }
509    * 
510    * Enumeration en2 = entry.getAccession().elements(); while
511    * (en2.hasMoreElements()) {
512    * al.getSequenceAt(i).getDatasetSequence().addDBRef(new DBRefEntry(
513    * DBRefSource.UNIPROT, "0", en2.nextElement().toString())); }
514    * 
515    * 
516    * 
517    * 
518    * al.getSequenceAt(i).getDatasetSequence().setPDBId(onlyPdbEntries); if
519    * (entry.getFeature() != null) { e = entry.getFeature().elements(); while
520    * (e.hasMoreElements()) { SequenceFeature sf = (SequenceFeature)
521    * e.nextElement(); sf.setFeatureGroup("Uniprot");
522    * al.getSequenceAt(i).getDatasetSequence().addSequenceFeature( sf ); } } } } }
523    * 
524    * SequenceI[] getPDBFile(String id) { Vector result = new Vector(); String
525    * chain = null; if (id.indexOf(":") > -1) { chain =
526    * id.substring(id.indexOf(":") + 1); id = id.substring(0, id.indexOf(":")); }
527    * 
528    * EBIFetchClient ebi = new EBIFetchClient(); String file =
529    * ebi.fetchDataAsFile("pdb:" + id, "pdb", "raw"). getAbsolutePath(); if (file ==
530    * null) { return null; } try { PDBfile pdbfile = new PDBfile(file,
531    * jalview.io.AppletFormatAdapter.FILE); for (int i = 0; i <
532    * pdbfile.chains.size(); i++) { if (chain == null || ( (PDBChain)
533    * pdbfile.chains.elementAt(i)).id. toUpperCase().equals(chain)) { PDBChain
534    * pdbchain = (PDBChain) pdbfile.chains.elementAt(i); // Get the Chain's
535    * Sequence - who's dataset includes any special features added from the PDB
536    * file SequenceI sq = pdbchain.sequence; // Specially formatted name for the
537    * PDB chain sequences retrieved from the PDB
538    * sq.setName("PDB|"+id+"|"+sq.getName()); // Might need to add more metadata
539    * to the PDBEntry object // like below /* PDBEntry entry = new PDBEntry(); //
540    * Construct the PDBEntry entry.setId(id); if (entry.getProperty() == null)
541    * entry.setProperty(new Hashtable()); entry.getProperty().put("chains",
542    * pdbchain.id + "=" + sq.getStart() + "-" + sq.getEnd());
543    * sq.getDatasetSequence().addPDBId(entry);
544    *  // Add PDB DB Refs // We make a DBRefEtntry because we have obtained the
545    * PDB file from a verifiable source // JBPNote - PDB DBRefEntry should also
546    * carry the chain and mapping information DBRefEntry dbentry = new
547    * DBRefEntry(jalview.datamodel.DBRefSource.PDB, "0", id + pdbchain.id);
548    * sq.addDBRef(dbentry); // and add seuqence to the retrieved set
549    * result.addElement(sq.deriveSequence()); } }
550    * 
551    * if (result.size() < 1) { throw new Exception("WsDBFetch for PDB id resulted
552    * in zero result size"); } } catch (Exception ex) // Problem parsing PDB file {
553    * jalview.bin.Cache.log.warn("Exception when retrieving " +
554    * textArea.getText() + " from " + database.getSelectedItem(), ex); return
555    * null; }
556    * 
557    * 
558    * SequenceI[] results = new SequenceI[result.size()]; for (int i = 0, j =
559    * result.size(); i < j; i++) { results[i] = (SequenceI) result.elementAt(i);
560    * result.setElementAt(null,i); } return results; }
561    */
562   AlignmentI parseResult(String result, String title)
563   {
564     String format = new IdentifyFile().Identify(result, "Paste");
565     Alignment sequences = null;
566     if (FormatAdapter.isValidFormat(format))
567     {
568       sequences = null;
569       try
570       {
571         sequences = new FormatAdapter().readFile(result.toString(),
572                 "Paste", format);
573       } catch (Exception ex)
574       {
575       }
576
577       if (sequences != null)
578       {
579         return parseResult(sequences, title, format);
580       }
581     }
582     else
583     {
584       showErrorMessage("Error retrieving " + textArea.getText() + " from "
585               + database.getSelectedItem());
586     }
587
588     return null;
589   }
590
591   AlignmentI parseResult(AlignmentI al, String title,
592           String currentFileFormat)
593   {
594
595     if (al != null && al.getHeight() > 0)
596     {
597       if (alignFrame == null)
598       {
599         AlignFrame af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
600                 AlignFrame.DEFAULT_HEIGHT);
601         if (currentFileFormat != null)
602         {
603           af.currentFileFormat = currentFileFormat; // WHAT IS THE DEFAULT
604                                                     // FORMAT FOR
605                                                     // NON-FormatAdapter Sourced
606                                                     // Alignments?
607         }
608
609         if (title == null)
610         {
611           title = "Retrieved from " + database.getSelectedItem();
612         }
613
614         Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH,
615                 AlignFrame.DEFAULT_HEIGHT);
616
617         af.statusBar.setText("Successfully pasted alignment file");
618
619         try
620         {
621           af.setMaximum(jalview.bin.Cache.getDefault("SHOW_FULLSCREEN",
622                   false));
623         } catch (Exception ex)
624         {
625         }
626       }
627       else
628       {
629         for (int i = 0; i < al.getHeight(); i++)
630         {
631           alignFrame.viewport.alignment.addSequence(al.getSequenceAt(i)); // this
632                                                                           // also
633                                                                           // creates
634                                                                           // dataset
635                                                                           // sequence
636                                                                           // entries
637         }
638         alignFrame.viewport.setEndSeq(alignFrame.viewport.alignment
639                 .getHeight());
640         alignFrame.viewport.alignment.getWidth();
641         alignFrame.viewport.firePropertyChange("alignment", null,
642                 alignFrame.viewport.getAlignment().getSequences());
643       }
644     }
645     return al;
646   }
647
648   void showErrorMessage(final String error)
649   {
650     resetDialog();
651     javax.swing.SwingUtilities.invokeLater(new Runnable()
652     {
653       public void run()
654       {
655         JOptionPane.showInternalMessageDialog(Desktop.desktop, error,
656                 "Error Retrieving Data", JOptionPane.WARNING_MESSAGE);
657       }
658     });
659   }
660 }