79ab713b954667b908f58128c7b5f9a8b2043757
[jalview.git] / forester / java / src / org / forester / analysis / TaxonomyDataManager.java
1 // $Id:
2 //
3 // forester -- software libraries and applications
4 // for genomics and evolutionary biology research.
5 //
6 // Copyright (C) 2010 Christian M Zmasek
7 // Copyright (C) 2010 Sanford-Burnham Medical Research Institute
8 // All rights reserved
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 //
24 // Contact: phylosoft @ gmail . com
25 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26
27 package org.forester.analysis;
28
29 import java.io.IOException;
30 import java.net.UnknownHostException;
31 import java.util.ArrayList;
32 import java.util.HashMap;
33 import java.util.List;
34 import java.util.SortedSet;
35 import java.util.TreeSet;
36
37 import javax.swing.JOptionPane;
38
39 import org.forester.archaeopteryx.MainFrameApplication;
40 import org.forester.archaeopteryx.TreePanel;
41 import org.forester.archaeopteryx.tools.AncestralTaxonomyInferrer;
42 import org.forester.archaeopteryx.tools.RunnableProcess;
43 import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException;
44 import org.forester.phylogeny.Phylogeny;
45 import org.forester.phylogeny.PhylogenyNode;
46 import org.forester.phylogeny.data.Identifier;
47 import org.forester.phylogeny.data.Taxonomy;
48 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
49 import org.forester.util.ForesterUtil;
50 import org.forester.ws.seqdb.SequenceDbWsTools;
51 import org.forester.ws.seqdb.UniProtTaxonomy;
52
53 public final class TaxonomyDataManager extends RunnableProcess {
54
55     enum QUERY_TYPE {
56         CODE, SN, CN, ID, LIN;
57     }
58     private static final int                              MAX_CACHE_SIZE           = 100000;
59     private static final int                              MAX_TAXONOMIES_TO_RETURN = 10;
60     private static final HashMap<String, UniProtTaxonomy> _sn_up_cache_map         = new HashMap<String, UniProtTaxonomy>();
61     private static final HashMap<String, UniProtTaxonomy> _lineage_up_cache_map    = new HashMap<String, UniProtTaxonomy>();
62     private static final HashMap<String, UniProtTaxonomy> _code_up_cache_map       = new HashMap<String, UniProtTaxonomy>();
63     private static final HashMap<String, UniProtTaxonomy> _cn_up_cache_map         = new HashMap<String, UniProtTaxonomy>();
64     private static final HashMap<String, UniProtTaxonomy> _id_up_cache_map         = new HashMap<String, UniProtTaxonomy>();
65     private final Phylogeny                               _phy;
66     private final MainFrameApplication                    _mf;
67     private final TreePanel                               _treepanel;
68     private final boolean                                 _delete;
69     private final boolean                                 _allow_simple_names;
70
71     public TaxonomyDataManager( final MainFrameApplication mf, final TreePanel treepanel, final Phylogeny phy ) {
72         _phy = phy;
73         _mf = mf;
74         _treepanel = treepanel;
75         _delete = false;
76         _allow_simple_names = false;
77     }
78
79     public TaxonomyDataManager( final MainFrameApplication mf,
80                                 final TreePanel treepanel,
81                                 final Phylogeny phy,
82                                 final boolean delete,
83                                 final boolean allow_simple_name ) {
84         _phy = phy;
85         _mf = mf;
86         _treepanel = treepanel;
87         _delete = delete;
88         _allow_simple_names = allow_simple_name;
89     }
90
91     synchronized static void clearCachesIfTooLarge() {
92         if ( getSnTaxCacheMap().size() > MAX_CACHE_SIZE ) {
93             getSnTaxCacheMap().clear();
94         }
95         if ( getLineageTaxCacheMap().size() > MAX_CACHE_SIZE ) {
96             getLineageTaxCacheMap().clear();
97         }
98         if ( getCnTaxCacheMap().size() > MAX_CACHE_SIZE ) {
99             getCnTaxCacheMap().clear();
100         }
101         if ( getCodeTaxCacheMap().size() > MAX_CACHE_SIZE ) {
102             getCodeTaxCacheMap().clear();
103         }
104         if ( getIdTaxCacheMap().size() > MAX_CACHE_SIZE ) {
105             getIdTaxCacheMap().clear();
106         }
107     }
108
109     synchronized final static HashMap<String, UniProtTaxonomy> getCnTaxCacheMap() {
110         return _cn_up_cache_map;
111     }
112
113     synchronized final static HashMap<String, UniProtTaxonomy> getCodeTaxCacheMap() {
114         return _code_up_cache_map;
115     }
116
117     synchronized final static HashMap<String, UniProtTaxonomy> getIdTaxCacheMap() {
118         return _id_up_cache_map;
119     }
120
121     synchronized final static HashMap<String, UniProtTaxonomy> getLineageTaxCacheMap() {
122         return _lineage_up_cache_map;
123     }
124
125     synchronized final static HashMap<String, UniProtTaxonomy> getSnTaxCacheMap() {
126         return _sn_up_cache_map;
127     }
128
129     private final static UniProtTaxonomy obtainTaxonomy( final HashMap<String, UniProtTaxonomy> cache,
130                                                          final Object query,
131                                                          final QUERY_TYPE qt ) throws IOException,
132             AncestralTaxonomyInferenceException {
133         if ( cache.containsKey( query ) ) {
134             return cache.get( query ).copy();
135         }
136         else {
137             List<UniProtTaxonomy> up_taxonomies = null;
138             switch ( qt ) {
139                 case ID:
140                     up_taxonomies = getTaxonomiesFromId( ( String ) query );
141                     break;
142                 case CODE:
143                     up_taxonomies = getTaxonomiesFromTaxonomyCode( ( String ) query );
144                     break;
145                 case SN:
146                     up_taxonomies = getTaxonomiesFromScientificName( ( String ) query );
147                     break;
148                 case CN:
149                     up_taxonomies = getTaxonomiesFromCommonName( ( String ) query );
150                     break;
151                 case LIN:
152                     return obtainUniProtTaxonomyFromLineage( ( List<String> ) query );
153                 default:
154                     throw new RuntimeException();
155             }
156             if ( ( up_taxonomies != null ) && ( up_taxonomies.size() == 1 ) ) {
157                 final UniProtTaxonomy up_tax = up_taxonomies.get( 0 );
158                 if ( !ForesterUtil.isEmpty( up_tax.getScientificName() ) ) {
159                     TaxonomyDataManager.getSnTaxCacheMap().put( up_tax.getScientificName(), up_tax );
160                 }
161                 if ( !ForesterUtil.isEmpty( up_tax.getCode() ) ) {
162                     TaxonomyDataManager.getCodeTaxCacheMap().put( up_tax.getCode(), up_tax );
163                 }
164                 if ( !ForesterUtil.isEmpty( up_tax.getCommonName() ) ) {
165                     TaxonomyDataManager.getCnTaxCacheMap().put( up_tax.getCommonName(), up_tax );
166                 }
167                 if ( !ForesterUtil.isEmpty( up_tax.getId() ) ) {
168                     TaxonomyDataManager.getIdTaxCacheMap().put( up_tax.getId(), up_tax );
169                 }
170                 return up_tax;
171             }
172             else {
173                 return null;
174             }
175         }
176     }
177
178     private final static List<UniProtTaxonomy> getTaxonomiesFromCommonName( final String query ) throws IOException {
179         return SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( query, MAX_TAXONOMIES_TO_RETURN );
180     }
181
182     private final static List<UniProtTaxonomy> getTaxonomiesFromId( final String query ) throws IOException {
183         return SequenceDbWsTools.getTaxonomiesFromId( query, MAX_TAXONOMIES_TO_RETURN );
184     }
185
186     private final static List<UniProtTaxonomy> getTaxonomiesFromScientificName( final String query ) throws IOException {
187         if ( query.equalsIgnoreCase( UniProtTaxonomy.BACTERIA ) ||
188                 query.equalsIgnoreCase( UniProtTaxonomy.ARCHAEA ) ||
189                 query.equalsIgnoreCase( UniProtTaxonomy.VIRUSES ) ||
190                 query.equalsIgnoreCase( UniProtTaxonomy.EUKARYOTA ) 
191                 ) {
192             final List<UniProtTaxonomy> l = new ArrayList<UniProtTaxonomy>();
193             l.add( UniProtTaxonomy.createSpecialFromScientificName( query ) );
194             return l;
195         }
196         
197         return SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( query, MAX_TAXONOMIES_TO_RETURN );
198     }
199
200     private final static List<UniProtTaxonomy> getTaxonomiesFromTaxonomyCode( final String query ) throws IOException {
201         return SequenceDbWsTools.getTaxonomiesFromTaxonomyCode( query, MAX_TAXONOMIES_TO_RETURN );
202     }
203
204     static final boolean isHasAppropriateId( final Taxonomy tax ) {
205         return ( ( tax.getIdentifier() != null ) && ( !ForesterUtil.isEmpty( tax.getIdentifier().getValue() ) && ( tax
206                 .getIdentifier().getProvider().equalsIgnoreCase( "ncbi" )
207                 || tax.getIdentifier().getProvider().equalsIgnoreCase( "uniprot" ) || tax.getIdentifier().getProvider()
208                 .equalsIgnoreCase( "uniprotkb" ) ) ) );
209     }
210
211     synchronized final private static SortedSet<String> obtainDetailedTaxonomicInformation( final Phylogeny phy,
212                                                                                             final boolean delete,
213                                                                                             final boolean allow_to_use_basic_node_names )
214             throws IOException, AncestralTaxonomyInferenceException {
215         clearCachesIfTooLarge();
216         final SortedSet<String> not_found = new TreeSet<String>();
217         List<PhylogenyNode> not_found_external_nodes = null;
218         if ( delete ) {
219             not_found_external_nodes = new ArrayList<PhylogenyNode>();
220         }
221         for( final PhylogenyNodeIterator iter = phy.iteratorPostorder(); iter.hasNext(); ) {
222             final PhylogenyNode node = iter.next();
223             final QUERY_TYPE qt = null;
224             Taxonomy tax = null;
225             if ( node.getNodeData().isHasTaxonomy() ) {
226                 tax = node.getNodeData().getTaxonomy();
227             }
228             else if ( allow_to_use_basic_node_names && !ForesterUtil.isEmpty( node.getName() ) ) {
229                 // Nothing to be done.
230             }
231             else if ( node.isExternal() ) {
232                 if ( !ForesterUtil.isEmpty( node.getName() ) ) {
233                     not_found.add( node.getName() );
234                 }
235                 else {
236                     not_found.add( node.toString() );
237                 }
238                 if ( delete ) {
239                     not_found_external_nodes.add( node );
240                 }
241             }
242             UniProtTaxonomy uniprot_tax = null;
243             if ( ( ( tax != null ) && ( isHasAppropriateId( tax ) || !ForesterUtil.isEmpty( tax.getScientificName() )
244                     || !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) || !ForesterUtil.isEmpty( tax.getCommonName() ) ) )
245                     || ( allow_to_use_basic_node_names && !ForesterUtil.isEmpty( node.getName() ) ) ) {
246                 if ( tax != null ) {
247                     uniprot_tax = obtainUniProtTaxonomy( tax, null, qt );
248                 }
249                 else {
250                     uniprot_tax = obtainUniProtTaxonomy( node.getName(), qt );
251                 }
252                 if ( uniprot_tax != null ) {
253                     if ( tax == null ) {
254                         tax = new Taxonomy();
255                         node.getNodeData().addTaxonomy( tax );
256                         node.setName( "" );
257                     }
258                     updateTaxonomy( qt, node, tax, uniprot_tax );
259                 }
260                 else {
261                     if ( tax != null ) {
262                         not_found.add( tax.toString() );
263                     }
264                     else {
265                         not_found.add( node.getName() );
266                     }
267                     if ( delete && node.isExternal() ) {
268                         not_found_external_nodes.add( node );
269                     }
270                 }
271             }
272         }
273         if ( delete ) {
274             for( final PhylogenyNode node : not_found_external_nodes ) {
275                 phy.deleteSubtree( node, true );
276             }
277             phy.externalNodesHaveChanged();
278             phy.clearHashIdToNodeMap();
279             phy.recalculateNumberOfExternalDescendants( true );
280         }
281         return not_found;
282     }
283
284     public final static UniProtTaxonomy obtainUniProtTaxonomy( final Taxonomy tax, Object query, QUERY_TYPE qt )
285             throws IOException, AncestralTaxonomyInferenceException {
286         if ( tax == null ) {
287             throw new IllegalArgumentException( "illegal attempt to use empty taxonomy object" );
288         }
289         if ( TaxonomyDataManager.isHasAppropriateId( tax ) ) {
290             query = tax.getIdentifier().getValue();
291             qt = QUERY_TYPE.ID;
292             return obtainTaxonomy( TaxonomyDataManager.getIdTaxCacheMap(), query, qt );
293         }
294         else if ( !ForesterUtil.isEmpty( tax.getScientificName() ) ) {
295             if ( !ForesterUtil.isEmpty( tax.getLineage() ) ) {
296                 query = tax.getLineage();
297                 qt = QUERY_TYPE.LIN;
298                 return obtainTaxonomy( TaxonomyDataManager.getLineageTaxCacheMap(), query, qt );
299             }
300             else {
301                 query = tax.getScientificName();
302                 qt = QUERY_TYPE.SN;
303                 return obtainTaxonomy( TaxonomyDataManager.getSnTaxCacheMap(), query, qt );
304             }
305         }
306         else if ( !ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
307             query = tax.getTaxonomyCode();
308             qt = QUERY_TYPE.CODE;
309             return obtainTaxonomy( TaxonomyDataManager.getCodeTaxCacheMap(), query, qt );
310         }
311         else {
312             query = tax.getCommonName();
313             qt = QUERY_TYPE.CN;
314             return obtainTaxonomy( TaxonomyDataManager.getCnTaxCacheMap(), query, qt );
315         }
316     }
317
318     public final static UniProtTaxonomy obtainUniProtTaxonomy( final String simple_name, QUERY_TYPE qt )
319             throws IOException, AncestralTaxonomyInferenceException {
320         if ( ForesterUtil.isEmpty( simple_name ) ) {
321             throw new IllegalArgumentException( "illegal attempt to use empty simple name" );
322         }
323         qt = QUERY_TYPE.SN;
324         UniProtTaxonomy ut = obtainTaxonomy( TaxonomyDataManager.getSnTaxCacheMap(), simple_name, qt );
325         if ( ut == null ) {
326             qt = QUERY_TYPE.CODE;
327             ut = obtainTaxonomy( TaxonomyDataManager.getCodeTaxCacheMap(), simple_name, qt );
328         }
329         if ( ut == null ) {
330             qt = QUERY_TYPE.CN;
331             ut = obtainTaxonomy( TaxonomyDataManager.getCnTaxCacheMap(), simple_name, qt );
332         }
333         return ut;
334     }
335
336     static final UniProtTaxonomy obtainUniProtTaxonomyFromLineage( final List<String> lineage )
337             throws AncestralTaxonomyInferenceException, IOException {
338         final String lineage_str = ForesterUtil.stringListToString( lineage, ">" );
339         if ( TaxonomyDataManager.getLineageTaxCacheMap().containsKey( lineage_str ) ) {
340             return TaxonomyDataManager.getLineageTaxCacheMap().get( lineage_str ).copy();
341         }
342         else {
343             final List<UniProtTaxonomy> matching_taxonomies = new ArrayList<UniProtTaxonomy>();
344             final List<UniProtTaxonomy> up_taxonomies = getTaxonomiesFromScientificName( lineage
345                     .get( lineage.size() - 1 ) );
346             if ( ( up_taxonomies != null ) && ( up_taxonomies.size() > 0 ) ) {
347                 for( final UniProtTaxonomy up_taxonomy : up_taxonomies ) {
348                     boolean match = true;
349                     I: for( int i = 0; i < lineage.size(); ++i ) {
350                         if ( ( i == up_taxonomy.getLineage().size() )
351                                 || !lineage.get( i ).equalsIgnoreCase( up_taxonomy.getLineage().get( i ) ) ) {
352                             match = false;
353                             break I;
354                         }
355                     }
356                     if ( match ) {
357                         matching_taxonomies.add( up_taxonomy );
358                     }
359                 }
360                 if ( matching_taxonomies.isEmpty() ) {
361                     throw new AncestralTaxonomyInferenceException( "lineage \""
362                             + ForesterUtil.stringListToString( lineage, " > " ) + "\" not found" );
363                 }
364                 //in case of more than one (e.g. "Xenopus" Genus and Subgenus), keep shorter, less specific  one:
365                 int shortest = Integer.MAX_VALUE;
366                 UniProtTaxonomy least_specific_up_tax = null;
367                 for( final UniProtTaxonomy m : matching_taxonomies ) {
368                     final int s = m.getLineage().size();
369                     if ( s < shortest ) {
370                         shortest = s;
371                         least_specific_up_tax = m;
372                     }
373                 }
374                 TaxonomyDataManager.getLineageTaxCacheMap().put( lineage_str, least_specific_up_tax );
375                 if ( !ForesterUtil.isEmpty( least_specific_up_tax.getScientificName() ) ) {
376                     TaxonomyDataManager.getSnTaxCacheMap().put( least_specific_up_tax.getScientificName(),
377                                                                 least_specific_up_tax );
378                 }
379                 if ( !ForesterUtil.isEmpty( least_specific_up_tax.getCode() ) ) {
380                     TaxonomyDataManager.getCodeTaxCacheMap().put( least_specific_up_tax.getCode(),
381                                                                   least_specific_up_tax );
382                 }
383                 if ( !ForesterUtil.isEmpty( least_specific_up_tax.getCommonName() ) ) {
384                     TaxonomyDataManager.getCnTaxCacheMap().put( least_specific_up_tax.getCommonName(),
385                                                                 least_specific_up_tax );
386                 }
387                 if ( !ForesterUtil.isEmpty( least_specific_up_tax.getId() ) ) {
388                     TaxonomyDataManager.getIdTaxCacheMap().put( least_specific_up_tax.getId(), least_specific_up_tax );
389                 }
390                 return least_specific_up_tax;
391             }
392             else {
393                 throw new AncestralTaxonomyInferenceException( "taxonomy \"" + ( lineage.get( lineage.size() - 1 ) )
394                         + "\" not found" );
395             }
396         }
397     }
398
399     synchronized final private static void updateTaxonomy( final QUERY_TYPE qt,
400                                                            final PhylogenyNode node,
401                                                            final Taxonomy tax,
402                                                            final UniProtTaxonomy up_tax )
403             throws PhyloXmlDataFormatException {
404         if ( ( qt != QUERY_TYPE.SN ) && !ForesterUtil.isEmpty( up_tax.getScientificName() )
405                 && ForesterUtil.isEmpty( tax.getScientificName() ) ) {
406             tax.setScientificName( up_tax.getScientificName() );
407         }
408         if ( node.isExternal() && ( qt != QUERY_TYPE.CODE ) && !ForesterUtil.isEmpty( up_tax.getCode() )
409                 && ForesterUtil.isEmpty( tax.getTaxonomyCode() ) ) {
410             tax.setTaxonomyCode( up_tax.getCode() );
411         }
412         if ( ( qt != QUERY_TYPE.CN ) && !ForesterUtil.isEmpty( up_tax.getCommonName() )
413                 && ForesterUtil.isEmpty( tax.getCommonName() ) ) {
414             tax.setCommonName( up_tax.getCommonName() );
415         }
416         if ( !ForesterUtil.isEmpty( up_tax.getSynonym() ) && !tax.getSynonyms().contains( up_tax.getSynonym() ) ) {
417             tax.getSynonyms().add( up_tax.getSynonym() );
418         }
419         if ( !ForesterUtil.isEmpty( up_tax.getRank() ) && ForesterUtil.isEmpty( tax.getRank() ) ) {
420             try {
421                 tax.setRank( up_tax.getRank().toLowerCase() );
422             }
423             catch ( final PhyloXmlDataFormatException ex ) {
424                 tax.setRank( "" );
425             }
426         }
427         if ( ( qt != QUERY_TYPE.ID ) && !ForesterUtil.isEmpty( up_tax.getId() )
428                 && ( ( tax.getIdentifier() == null ) || ForesterUtil.isEmpty( tax.getIdentifier().getValue() ) ) ) {
429             tax.setIdentifier( new Identifier( up_tax.getId(), "uniprot" ) );
430         }
431         if ( up_tax.getLineage() != null ) {
432             tax.setLineage( new ArrayList<String>() );
433             for( final String lin : up_tax.getLineage() ) {
434                 if ( !ForesterUtil.isEmpty( lin ) ) {
435                     tax.getLineage().add( lin );
436                 }
437             }
438         }
439     }
440
441     private final void execute() {
442         start( _mf, "taxonomy data" );
443         SortedSet<String> not_found = null;
444         try {
445             not_found = obtainDetailedTaxonomicInformation( _phy, _delete, _allow_simple_names );
446         }
447         catch ( final UnknownHostException e ) {
448             JOptionPane.showMessageDialog( _mf,
449                                            "Could not connect to \"" + getBaseUrl() + "\"",
450                                            "Network error during taxonomic information gathering",
451                                            JOptionPane.ERROR_MESSAGE );
452             return;
453         }
454         catch ( final IOException e ) {
455             e.printStackTrace();
456             JOptionPane.showMessageDialog( _mf,
457                                            e.toString(),
458                                            "Failed to obtain taxonomic information",
459                                            JOptionPane.ERROR_MESSAGE );
460             return;
461         }
462         catch ( final AncestralTaxonomyInferenceException e ) {
463             e.printStackTrace();
464             JOptionPane.showMessageDialog( _mf,
465                                            e.toString(),
466                                            "Failed to obtain taxonomic information",
467                                            JOptionPane.ERROR_MESSAGE );
468             return;
469         }
470         finally {
471             end( _mf );
472         }
473         if ( ( _phy == null ) || _phy.isEmpty() ) {
474             try {
475                 JOptionPane.showMessageDialog( _mf,
476                                                "None of the external node taxonomies could be resolved",
477                                                "Taxonomy Tool Failed",
478                                                JOptionPane.WARNING_MESSAGE );
479             }
480             catch ( final Exception e ) {
481                 // Not important if this fails, do nothing. 
482             }
483             return;
484         }
485         _treepanel.setTree( _phy );
486         _mf.showWhole();
487         _treepanel.setEdited( true );
488         if ( ( not_found != null ) && ( not_found.size() > 0 ) ) {
489             int max = not_found.size();
490             boolean more = false;
491             if ( max > 20 ) {
492                 more = true;
493                 max = 20;
494             }
495             final StringBuffer sb = new StringBuffer();
496             sb.append( "Not all taxonomies could be resolved.\n" );
497             if ( not_found.size() == 1 ) {
498                 if ( _delete ) {
499                     sb.append( "The following taxonomy was not found and deleted (if external):\n" );
500                 }
501                 else {
502                     sb.append( "The following taxonomy was not found:\n" );
503                 }
504             }
505             else {
506                 if ( _delete ) {
507                     sb.append( "The following taxonomies were not found and deleted (if external) (total: "
508                             + not_found.size() + "):\n" );
509                 }
510                 else {
511                     sb.append( "The following taxonomies were not found (total: " + not_found.size() + "):\n" );
512                 }
513             }
514             int i = 0;
515             for( final String string : not_found ) {
516                 if ( i > 19 ) {
517                     break;
518                 }
519                 sb.append( string );
520                 sb.append( "\n" );
521                 ++i;
522             }
523             if ( more ) {
524                 sb.append( "..." );
525             }
526             try {
527                 JOptionPane.showMessageDialog( _mf,
528                                                sb.toString(),
529                                                "Taxonomy Tool Completed",
530                                                JOptionPane.WARNING_MESSAGE );
531             }
532             catch ( final Exception e ) {
533                 // Not important if this fails, do nothing. 
534             }
535         }
536         else {
537             try {
538                 JOptionPane.showMessageDialog( _mf,
539                                                "Taxonomy tool successfully completed",
540                                                "Taxonomy Tool Completed",
541                                                JOptionPane.INFORMATION_MESSAGE );
542             }
543             catch ( final Exception e ) {
544                 // Not important if this fails, do nothing.
545             }
546         }
547     }
548
549     private final String getBaseUrl() {
550         return AncestralTaxonomyInferrer.getBaseUrl();
551     }
552
553     @Override
554     public void run() {
555         execute();
556     }
557 }