JAL-1062 use matching region or first section of sequence source regex to select...
[jalview.git] / src / jalview / gui / SequenceFetcher.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3  * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
4  *
5  * This file is part of Jalview.
6  *
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * Jalview is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  * PURPOSE.  See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 package jalview.gui;
19
20 import java.util.*;
21 import java.util.List;
22
23 import java.awt.*;
24 import java.awt.event.*;
25
26 import javax.swing.*;
27 import javax.swing.tree.DefaultMutableTreeNode;
28
29 import com.stevesoft.pat.Regex;
30
31 import jalview.datamodel.*;
32 import jalview.io.*;
33 import jalview.util.DBRefUtils;
34 import jalview.ws.dbsources.das.api.DasSourceRegistryI;
35 import jalview.ws.seqfetcher.DbSourceProxy;
36 import java.awt.BorderLayout;
37
38 public class SequenceFetcher extends JPanel implements Runnable
39 {
40   // ASequenceFetcher sfetch;
41   JInternalFrame frame;
42
43   IProgressIndicator guiWindow;
44
45   AlignFrame alignFrame;
46
47   StringBuffer result;
48
49   final String noDbSelected = "-- Select Database --";
50
51   private static jalview.ws.SequenceFetcher sfetch = null;
52
53   private static long lastDasSourceRegistry = -3;
54
55   private static DasSourceRegistryI dasRegistry = null;
56
57   private static boolean _initingFetcher = false;
58
59   private static Thread initingThread = null;
60
61   /**
62    * Blocking method that initialises and returns the shared instance of the
63    * SequenceFetcher client
64    *
65    * @param guiWindow
66    *          - where the initialisation delay message should be shown
67    * @return the singleton instance of the sequence fetcher client
68    */
69   public static jalview.ws.SequenceFetcher getSequenceFetcherSingleton(
70           final IProgressIndicator guiWindow)
71   {
72     if (_initingFetcher && initingThread != null && initingThread.isAlive())
73     {
74       if (guiWindow != null)
75       {
76         guiWindow.setProgressBar(
77                 "Waiting for Sequence Database Fetchers to initialise",
78                 Thread.currentThread().hashCode());
79       }
80       // initting happening on another thread - so wait around to see if it
81       // finishes.
82       while (_initingFetcher && initingThread != null
83               && initingThread.isAlive())
84       {
85         try
86         {
87           Thread.sleep(10);
88         } catch (Exception e)
89         {
90         }
91         ;
92       }
93       if (guiWindow != null)
94       {
95         guiWindow.setProgressBar(
96                 "Waiting for Sequence Database Fetchers to initialise",
97                 Thread.currentThread().hashCode());
98       }
99     }
100     if (sfetch == null
101             || dasRegistry != jalview.bin.Cache.getDasSourceRegistry()
102             || lastDasSourceRegistry != (jalview.bin.Cache
103                     .getDasSourceRegistry().getDasRegistryURL() + jalview.bin.Cache
104                     .getDasSourceRegistry().getLocalSourceString())
105                     .hashCode())
106     {
107       _initingFetcher = true;
108       initingThread = Thread.currentThread();
109       /**
110        * give a visual indication that sequence fetcher construction is occuring
111        */
112       if (guiWindow != null)
113       {
114         guiWindow.setProgressBar("Initialising Sequence Database Fetchers",
115                 Thread.currentThread().hashCode());
116       }
117       dasRegistry = jalview.bin.Cache.getDasSourceRegistry();
118       dasRegistry.refreshSources();
119
120       jalview.ws.SequenceFetcher sf = new jalview.ws.SequenceFetcher();
121       if (guiWindow != null)
122       {
123         guiWindow.setProgressBar("Initialising Sequence Database Fetchers",
124                 Thread.currentThread().hashCode());
125       }
126       lastDasSourceRegistry = (dasRegistry.getDasRegistryURL() + dasRegistry
127               .getLocalSourceString()).hashCode();
128       sfetch = sf;
129       _initingFetcher = false;
130       initingThread = null;
131     }
132     return sfetch;
133   }
134
135   public SequenceFetcher(IProgressIndicator guiIndic)
136   {
137     final IProgressIndicator guiWindow = guiIndic;
138     final SequenceFetcher us = this;
139     // launch initialiser thread
140     Thread sf = new Thread(new Runnable()
141     {
142
143       @Override
144       public void run()
145       {
146         if (getSequenceFetcherSingleton(guiWindow) != null)
147         {
148           us.initGui(guiWindow);
149         }
150         else
151         {
152           javax.swing.SwingUtilities.invokeLater(new Runnable()
153           {
154             @Override
155             public void run()
156             {
157               JOptionPane
158                       .showInternalMessageDialog(
159                               Desktop.desktop,
160                               "Could not create the sequence fetcher client. Check error logs for details.",
161                               "Couldn't create SequenceFetcher",
162                               JOptionPane.ERROR_MESSAGE);
163             }
164           });
165
166           // raise warning dialog
167         }
168       }
169     });
170     sf.start();
171   }
172
173   private class DatabaseAuthority extends DefaultMutableTreeNode
174   {
175
176   };
177
178   private class DatabaseSource extends DefaultMutableTreeNode
179   {
180
181   };
182
183   /**
184    * called by thread spawned by constructor
185    *
186    * @param guiWindow
187    */
188   private void initGui(IProgressIndicator guiWindow)
189   {
190     this.guiWindow = guiWindow;
191     if (guiWindow instanceof AlignFrame)
192     {
193       alignFrame = (AlignFrame) guiWindow;
194     }
195     database = new JDatabaseTree(sfetch);
196     try
197     {
198       jbInit();
199     } catch (Exception ex)
200     {
201       ex.printStackTrace();
202     }
203
204     frame = new JInternalFrame();
205     frame.setContentPane(this);
206     if (new jalview.util.Platform().isAMac())
207     {
208       Desktop.addInternalFrame(frame, getFrameTitle(), 400, 240);
209     }
210     else
211     {
212       Desktop.addInternalFrame(frame, getFrameTitle(), 400, 180);
213     }
214   }
215
216   private String getFrameTitle()
217   {
218     return ((alignFrame == null) ? "New " : "Additional ")
219             + "Sequence Fetcher";
220   }
221
222   private void jbInit() throws Exception
223   {
224     this.setLayout(borderLayout2);
225
226     database.setFont(JvSwingUtils.getLabelFont());
227     dbeg.setFont(new java.awt.Font("Verdana", Font.BOLD, 11));
228     jLabel1.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
229     jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
230     jLabel1.setText("Separate multiple accession ids with semi colon \";\"");
231
232     replacePunctuation.setHorizontalAlignment(SwingConstants.CENTER);
233     replacePunctuation
234             .setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));
235     replacePunctuation.setText("Replace commas with semi-colons");
236     ok.setText("OK");
237     ok.addActionListener(new ActionListener()
238     {
239       @Override
240       public void actionPerformed(ActionEvent e)
241       {
242         ok_actionPerformed();
243       }
244     });
245     clear.setText("Clear");
246     clear.addActionListener(new ActionListener()
247     {
248       @Override
249       public void actionPerformed(ActionEvent e)
250       {
251         clear_actionPerformed();
252       }
253     });
254
255     example.setText("Example");
256     example.addActionListener(new ActionListener()
257     {
258       @Override
259       public void actionPerformed(ActionEvent e)
260       {
261         example_actionPerformed();
262       }
263     });
264     close.setText("Close");
265     close.addActionListener(new ActionListener()
266     {
267       @Override
268       public void actionPerformed(ActionEvent e)
269       {
270         close_actionPerformed(e);
271       }
272     });
273     textArea.setFont(JvSwingUtils.getLabelFont());
274     textArea.setLineWrap(true);
275     textArea.addKeyListener(new KeyAdapter()
276     {
277       @Override
278       public void keyPressed(KeyEvent e)
279       {
280         if (e.getKeyCode() == KeyEvent.VK_ENTER)
281           ok_actionPerformed();
282       }
283     });
284     jPanel3.setLayout(borderLayout1);
285     borderLayout1.setVgap(5);
286     jPanel1.add(ok);
287     jPanel1.add(example);
288     jPanel1.add(clear);
289     jPanel1.add(close);
290     jPanel3.add(jPanel2, java.awt.BorderLayout.CENTER);
291     jPanel2.setLayout(borderLayout3);
292     databaseButt = database.getDatabaseSelectorButton();
293     databaseButt.setFont(JvSwingUtils.getLabelFont());
294     database.addActionListener(new ActionListener()
295     {
296
297       @Override
298       public void actionPerformed(ActionEvent e)
299       {
300         try
301         {
302           databaseButt.setText(database.getSelectedItem()
303                   + (database.getSelectedSources().size() > 1 ? " (and "
304                           + database.getSelectedSources().size()
305                           + " others)" : ""));
306           String eq = database.getExampleQueries();
307           dbeg.setText("Example query: " + eq);
308           boolean enablePunct=!(eq != null && eq.indexOf(",") > -1);
309           for (DbSourceProxy dbs:database.getSelectedSources()) {
310             if (dbs instanceof jalview.ws.dbsources.das.datamodel.DasSequenceSource)
311             {
312               enablePunct = false;
313               break;
314             }
315           }
316           replacePunctuation.setEnabled(enablePunct);
317
318         } catch (Exception ex)
319         {
320           dbeg.setText("");
321           replacePunctuation.setEnabled(true);
322         }
323         jPanel2.repaint();
324       }
325     });
326     dbeg.setText("");
327     jPanel2.add(databaseButt, java.awt.BorderLayout.NORTH);
328     jPanel2.add(dbeg, java.awt.BorderLayout.CENTER);
329     JPanel jPanel2a = new JPanel(new BorderLayout());
330     jPanel2a.add(jLabel1, java.awt.BorderLayout.NORTH);
331     jPanel2a.add(replacePunctuation, java.awt.BorderLayout.SOUTH);
332     jPanel2.add(jPanel2a, java.awt.BorderLayout.SOUTH);
333     // jPanel2.setPreferredSize(new Dimension())
334     jPanel3.add(jScrollPane1, java.awt.BorderLayout.CENTER);
335     this.add(jPanel1, java.awt.BorderLayout.SOUTH);
336     this.add(jPanel3, java.awt.BorderLayout.CENTER);
337     this.add(jPanel2, java.awt.BorderLayout.NORTH);
338     jScrollPane1.getViewport().add(textArea);
339
340   }
341
342   protected void example_actionPerformed()
343   {
344     DbSourceProxy db = null;
345     try
346     {
347       textArea.setText(database.getExampleQueries());
348     } catch (Exception ex)
349     {
350     }
351     jPanel3.repaint();
352   }
353
354   protected void clear_actionPerformed()
355   {
356     textArea.setText("");
357     jPanel3.repaint();
358   }
359
360   JLabel dbeg = new JLabel();
361
362   JDatabaseTree database;
363
364   JButton databaseButt;
365
366   JLabel jLabel1 = new JLabel();
367
368   JCheckBox replacePunctuation = new JCheckBox();
369
370   JButton ok = new JButton();
371
372   JButton clear = new JButton();
373
374   JButton example = new JButton();
375
376   JButton close = new JButton();
377
378   JPanel jPanel1 = new JPanel();
379
380   JTextArea textArea = new JTextArea();
381
382   JScrollPane jScrollPane1 = new JScrollPane();
383
384   JPanel jPanel2 = new JPanel();
385
386   JPanel jPanel3 = new JPanel();
387
388   JPanel jPanel4 = new JPanel();
389
390   BorderLayout borderLayout1 = new BorderLayout();
391
392   BorderLayout borderLayout2 = new BorderLayout();
393
394   BorderLayout borderLayout3 = new BorderLayout();
395
396   public void close_actionPerformed(ActionEvent e)
397   {
398     try
399     {
400       frame.setClosed(true);
401     } catch (Exception ex)
402     {
403     }
404   }
405
406   public void ok_actionPerformed()
407   {
408     database.setEnabled(false);
409     textArea.setEnabled(false);
410     ok.setEnabled(false);
411     close.setEnabled(false);
412
413     Thread worker = new Thread(this);
414     worker.start();
415   }
416
417   private void resetDialog()
418   {
419     database.setEnabled(true);
420     textArea.setEnabled(true);
421     ok.setEnabled(true);
422     close.setEnabled(true);
423   }
424
425   @Override
426   public void run()
427   {
428     String error = "";
429     if (!database.hasSelection())
430     {
431       error += "Please select the source database\n";
432     }
433     // TODO: make this transformation more configurable
434     com.stevesoft.pat.Regex empty;
435     if (replacePunctuation.isEnabled() && replacePunctuation.isSelected())
436     {
437       empty = new com.stevesoft.pat.Regex(
438       // replace commas and spaces with a semicolon
439               "(\\s|[,; ])+", ";");
440     }
441     else
442     {
443       // just turn spaces and semicolons into single semicolons
444       empty = new com.stevesoft.pat.Regex("(\\s|[; ])+", ";");
445     }
446     textArea.setText(empty.replaceAll(textArea.getText()));
447     // see if there's anthing to search with
448     if (!new com.stevesoft.pat.Regex("[A-Za-z0-9_.]").search(textArea
449             .getText()))
450     {
451       error += "Please enter a (semi-colon separated list of) database id(s)";
452     }
453     if (error.length() > 0)
454     {
455       showErrorMessage(error);
456       resetDialog();
457       return;
458     }
459     // indicate if successive sources should be merged into one alignment.
460     boolean addToLast=false;
461     ArrayList<String> aresultq = new ArrayList<String>(), presultTitle = new ArrayList<String>();
462     ArrayList<AlignmentI> presult = new ArrayList<AlignmentI>(), aresult = new ArrayList<AlignmentI>();
463     Iterator<DbSourceProxy> proxies = database.getSelectedSources()
464             .iterator();
465     String[] qries;
466     List<String> nextfetch = Arrays.asList(qries = textArea.getText()
467             .split(";"));
468     Iterator<String> en = Arrays.asList(new String[0]).iterator();
469     int nqueries = qries.length;
470     while (proxies.hasNext() && (en.hasNext() || nextfetch.size() > 0))
471     {
472       if (!en.hasNext() && nextfetch.size() > 0)
473       {
474         en = nextfetch.iterator();
475         nqueries = nextfetch.size();
476         // save the remaining queries in the original array
477         qries = nextfetch.toArray(new String[nqueries]);
478         nextfetch = new ArrayList<String>();
479       }
480
481       DbSourceProxy proxy = proxies.next();
482       boolean isAliSource = false;
483       try
484       {
485         // update status
486         guiWindow.setProgressBar("Fetching " + nqueries
487                 + " sequence queries from " + proxy.getDbName(), Thread
488                 .currentThread().hashCode());
489         isAliSource = proxy.isA(DBRefSource.ALIGNMENTDB);
490         if (proxy.getAccessionSeparator() == null)
491         {
492           while (en.hasNext())
493           {
494             String item = en.next();
495             try
496             {
497               if (aresult != null)
498               {
499                 try
500                 {
501                   // give the server a chance to breathe
502                   Thread.sleep(5);
503                 } catch (Exception e)
504                 {
505                   //
506                 }
507
508               }
509
510               AlignmentI indres = null;
511               try
512               {
513                 indres = proxy.getSequenceRecords(item);
514               } catch (OutOfMemoryError oome)
515               {
516                 new OOMWarning("fetching " + item + " from "
517                         + proxy.getDbName(), oome, this);
518               }
519               if (indres != null)
520               {
521                 aresultq.add(item);
522                 aresult.add(indres);
523               }
524               else
525               {
526                 nextfetch.add(item);
527               }
528             } catch (Exception e)
529             {
530               jalview.bin.Cache.log.info("Error retrieving " + item
531                       + " from " + proxy.getDbName(), e);
532               nextfetch.add(item);
533             }
534           }
535         }
536         else
537         {
538           StringBuffer multiacc = new StringBuffer();
539           ArrayList<String> tosend = new ArrayList<String>();
540           while (en.hasNext())
541           {
542             String nel = en.next();
543             tosend.add(nel);
544             multiacc.append(nel);
545             if (en.hasNext())
546             {
547               multiacc.append(proxy.getAccessionSeparator());
548             }
549           }
550           try
551           {
552             AlignmentI rslt;
553             SequenceI[] rs;
554             List<String> nores = new ArrayList<String>();
555             rslt = proxy.getSequenceRecords(multiacc.toString());
556             if (rslt == null || rslt.getHeight() == 0)
557             {
558               // no results - pass on all queries to next source
559               nextfetch.addAll(tosend);
560             }
561             else
562             {
563               aresultq.add(multiacc.toString());
564               aresult.add(rslt);
565
566               rs = rslt.getSequencesArray();
567               // search for each query in the dbrefs associated with each
568               // sequence
569               // returned.
570               // ones we do not find will be used to query next source (if any)
571               for (String q : tosend)
572               {
573                 DBRefEntry dbr = new DBRefEntry(), found[] = null;
574                 dbr.setSource(proxy.getDbSource());
575                 dbr.setVersion(null);
576                 if (proxy.getAccessionValidator()!=null) {
577                   Regex vgr=proxy.getAccessionValidator();
578                   vgr.search(q);
579                   if (vgr.numSubs()>0) {
580                     dbr.setAccessionId(vgr.stringMatched(1));
581                   } else {
582                     dbr.setAccessionId(vgr.stringMatched());
583                   }
584                 } else {
585                   dbr.setAccessionId(q);
586                 }
587                 boolean rfound = false;
588                 for (int r = 0; r < rs.length; r++)
589                 {
590                   if (rs[r] != null
591                           && (found = DBRefUtils.searchRefs(
592                                   rs[r].getDBRef(), dbr)) != null
593                           && found.length > 0)
594                   {
595                     rfound = true;
596                     rs[r] = null;
597                     continue;
598                   }
599                 }
600                 if (!rfound)
601                 {
602                   nextfetch.add(q);
603                 }
604               }
605             }
606           } catch (OutOfMemoryError oome)
607           {
608             new OOMWarning("fetching " + multiacc + " from "
609                     + database.getSelectedItem(), oome, this);
610           }
611         }
612
613       } catch (Exception e)
614       {
615         showErrorMessage("Error retrieving " + textArea.getText()
616                 + " from " + database.getSelectedItem());
617         // error
618         // +="Couldn't retrieve sequences from "+database.getSelectedItem();
619         System.err.println("Retrieval failed for source ='"
620                 + database.getSelectedItem() + "' and query\n'"
621                 + textArea.getText() + "'\n");
622         e.printStackTrace();
623       } catch (OutOfMemoryError e)
624       {
625         // resets dialog box - so we don't use OOMwarning here.
626         showErrorMessage("Out of Memory when retrieving "
627                 + textArea.getText()
628                 + " from "
629                 + database.getSelectedItem()
630                 + "\nPlease see the Jalview FAQ for instructions for increasing the memory available to Jalview.\n");
631         e.printStackTrace();
632       } catch (Error e)
633       {
634         showErrorMessage("Serious Error retrieving " + textArea.getText()
635                 + " from " + database.getSelectedItem());
636         e.printStackTrace();
637       }
638       // Stack results ready for opening in alignment windows
639       if (aresult != null && aresult.size() > 0)
640       {
641         AlignmentI ar = null;
642         if (isAliSource)
643         {
644           addToLast=false;
645           // new window for each result
646           while (aresult.size() > 0)
647           {
648             presult.add(aresult.remove(0));
649             presultTitle.add(aresultq.remove(0) + " "
650                     + getDefaultRetrievalTitle());
651           }
652         }
653         else
654         {
655           String titl=null;
656           if (addToLast && presult.size()>0)
657           {
658             ar=presult.remove(presult.size()-1);
659             titl=presultTitle.remove(presultTitle.size()-1);
660           }
661           // concatenate all results in one window
662           while (aresult.size() > 0)
663           {
664             if (ar == null)
665             {
666               ar = aresult.remove(0);
667             }
668             else
669             {
670               ar.append(aresult.remove(0));
671             }
672             ;
673           }
674           addToLast=true;
675           presult.add(ar);
676           presultTitle.add(titl);
677         }
678       }
679       guiWindow.setProgressBar("Finished querying", Thread.currentThread().hashCode());
680     }
681     guiWindow.setProgressBar((presult.size()>0) ? "Parsing results.":"Processing ..", Thread.currentThread().hashCode());
682     // process results
683     while (presult.size() > 0)
684     {
685       parseResult(presult.remove(0), presultTitle.remove(0), null);
686     }
687     // only remove visual delay after we finished parsing.
688     guiWindow.setProgressBar(null, Thread.currentThread().hashCode());
689     if (nextfetch.size() > 0)
690     {
691       StringBuffer sb = new StringBuffer();
692       sb.append("Didn't retrieve the following "
693               + (nextfetch.size() == 1 ? "query" : nextfetch.size()
694                       + " queries") + ": \n");
695       int l = sb.length(),lr=0;
696       for (String s : nextfetch)
697       {
698         if (l != sb.length())
699         {
700           sb.append("; ");
701         }
702         if (lr-sb.length()>40)
703         {
704           sb.append("\n");
705         }
706         sb.append(s);
707       }
708       showErrorMessage(sb.toString());
709     }
710     resetDialog();
711   }
712
713   AlignmentI parseResult(String result, String title)
714   {
715     String format = new IdentifyFile().Identify(result, "Paste");
716     Alignment sequences = null;
717     if (FormatAdapter.isValidFormat(format))
718     {
719       sequences = null;
720       try
721       {
722         sequences = new FormatAdapter().readFile(result.toString(),
723                 "Paste", format);
724       } catch (Exception ex)
725       {
726       }
727
728       if (sequences != null)
729       {
730         return parseResult(sequences, title, format);
731       }
732     }
733     else
734     {
735       showErrorMessage("Error retrieving " + textArea.getText() + " from "
736               + database.getSelectedItem());
737     }
738
739     return null;
740   }
741
742   /**
743    *
744    * @return a standard title for any results retrieved using the currently
745    *         selected source and settings
746    */
747   public String getDefaultRetrievalTitle()
748   {
749     return "Retrieved from " + database.getSelectedItem();
750   }
751
752   AlignmentI parseResult(AlignmentI al, String title,
753           String currentFileFormat)
754   {
755
756     if (al != null && al.getHeight() > 0)
757     {
758       if (alignFrame == null)
759       {
760         AlignFrame af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
761                 AlignFrame.DEFAULT_HEIGHT);
762         if (currentFileFormat != null)
763         {
764           af.currentFileFormat = currentFileFormat; // WHAT IS THE DEFAULT
765           // FORMAT FOR
766           // NON-FormatAdapter Sourced
767           // Alignments?
768         }
769
770         if (title == null)
771         {
772           title = getDefaultRetrievalTitle();
773         }
774         SequenceFeature[] sfs = null;
775         List<SequenceI> alsqs;
776         synchronized (alsqs = al.getSequences())
777         {
778           for (SequenceI sq : alsqs)
779           {
780             if ((sfs = (sq).getDatasetSequence().getSequenceFeatures()) != null)
781             {
782               if (sfs.length > 0)
783               {
784                 af.setShowSeqFeatures(true);
785                 break;
786               }
787             }
788
789           }
790         }
791         Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH,
792                 AlignFrame.DEFAULT_HEIGHT);
793
794         af.statusBar.setText("Successfully pasted alignment file");
795
796         try
797         {
798           af.setMaximum(jalview.bin.Cache.getDefault("SHOW_FULLSCREEN",
799                   false));
800         } catch (Exception ex)
801         {
802         }
803       }
804       else
805       {
806         for (int i = 0; i < al.getHeight(); i++)
807         {
808           alignFrame.viewport.getAlignment().addSequence(
809                   al.getSequenceAt(i)); // this
810           // also
811           // creates
812           // dataset
813           // sequence
814           // entries
815         }
816         alignFrame.viewport.setEndSeq(alignFrame.viewport.getAlignment()
817                 .getHeight());
818         alignFrame.viewport.getAlignment().getWidth();
819         alignFrame.viewport.firePropertyChange("alignment", null,
820                 alignFrame.viewport.getAlignment().getSequences());
821       }
822     }
823     return al;
824   }
825
826   void showErrorMessage(final String error)
827   {
828     resetDialog();
829     javax.swing.SwingUtilities.invokeLater(new Runnable()
830     {
831       @Override
832       public void run()
833       {
834         JOptionPane.showInternalMessageDialog(Desktop.desktop, error,
835                 "Error Retrieving Data", JOptionPane.WARNING_MESSAGE);
836       }
837     });
838   }
839 }