X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2Ftools%2FAncestralTaxonomyInferrer.java;h=25ed68aad0d9d2db0bd38e3be25e9f73609f9e1c;hb=9351f2c2e8af0c3bf1280f9696f1459db2819005;hp=fbcc0bf7250e6e813debf3cfd14acb7fedbd4cd2;hpb=0f295917c869b17a9322af3e738e3527ba9b31d4;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/tools/AncestralTaxonomyInferrer.java b/forester/java/src/org/forester/archaeopteryx/tools/AncestralTaxonomyInferrer.java index fbcc0bf..25ed68a 100644 --- a/forester/java/src/org/forester/archaeopteryx/tools/AncestralTaxonomyInferrer.java +++ b/forester/java/src/org/forester/archaeopteryx/tools/AncestralTaxonomyInferrer.java @@ -21,22 +21,22 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // // Contact: phylosoft @ gmail . com -// WWW: www.phylosoft.org/forester +// WWW: https://sites.google.com/site/cmzmasek/home/software/forester package org.forester.archaeopteryx.tools; import java.net.UnknownHostException; -import java.util.SortedSet; import javax.swing.JOptionPane; import org.forester.analysis.AncestralTaxonomyInference; +import org.forester.analysis.AncestralTaxonomyInferenceException; import org.forester.archaeopteryx.MainFrameApplication; import org.forester.archaeopteryx.TreePanel; import org.forester.phylogeny.Phylogeny; -import org.forester.ws.uniprot.UniProtWsTools; +import org.forester.ws.seqdb.SequenceDbWsTools; -public class AncestralTaxonomyInferrer implements Runnable { +public class AncestralTaxonomyInferrer extends RunnableProcess { private final Phylogeny _phy; private final MainFrameApplication _mf; @@ -48,18 +48,17 @@ public class AncestralTaxonomyInferrer implements Runnable { _treepanel = treepanel; } - private String getBaseUrl() { - return UniProtWsTools.BASE_URL; + public static String getBaseUrl() { + return SequenceDbWsTools.BASE_UNIPROT_URL; } private void inferTaxonomies() { - _mf.getMainPanel().getCurrentTreePanel().setWaitCursor(); - SortedSet not_found = null; + start( _mf, "ancestral taxonomy" ); try { - not_found = AncestralTaxonomyInference.inferTaxonomyFromDescendents( _phy ); + AncestralTaxonomyInference.inferTaxonomyFromDescendents( _phy ); } - catch ( final IllegalArgumentException e ) { - _mf.getMainPanel().getCurrentTreePanel().setArrowCursor(); + catch ( final AncestralTaxonomyInferenceException e ) { + end( _mf ); JOptionPane.showMessageDialog( _mf, e.getMessage(), "Error during ancestral taxonomy inference", @@ -67,7 +66,7 @@ public class AncestralTaxonomyInferrer implements Runnable { return; } catch ( final UnknownHostException e ) { - _mf.getMainPanel().getCurrentTreePanel().setArrowCursor(); + end( _mf ); JOptionPane.showMessageDialog( _mf, "Could not connect to \"" + getBaseUrl() + "\"", "Network error during ancestral taxonomy inference", @@ -75,67 +74,35 @@ public class AncestralTaxonomyInferrer implements Runnable { return; } catch ( final Exception e ) { - _mf.getMainPanel().getCurrentTreePanel().setArrowCursor(); + end( _mf ); e.printStackTrace(); JOptionPane.showMessageDialog( _mf, e.toString(), + "Unexpected exception during ancestral taxonomy inference", + JOptionPane.ERROR_MESSAGE ); + return; + } + catch ( final Error e ) { + end( _mf ); + JOptionPane.showMessageDialog( _mf, + e.toString(), "Unexpected error during ancestral taxonomy inference", JOptionPane.ERROR_MESSAGE ); return; } - _mf.getMainPanel().getCurrentTreePanel().setArrowCursor(); _phy.setRerootable( false ); _treepanel.setTree( _phy ); _mf.showWhole(); _treepanel.setEdited( true ); - if ( ( not_found != null ) && ( not_found.size() > 0 ) ) { - int max = not_found.size(); - boolean more = false; - if ( max > 20 ) { - more = true; - max = 20; - } - final StringBuffer sb = new StringBuffer(); - sb.append( "Not all taxonomies could be resolved.\n" ); - sb.append( "The result is incomplete, and, possibly, misleading.\n" ); - if ( not_found.size() == 1 ) { - sb.append( "The following taxonomy was not found:\n" ); - } - else { - sb.append( "The following taxonomies were not found (total: " + not_found.size() + "):\n" ); - } - int i = 0; - for( final String string : not_found ) { - if ( i > 19 ) { - break; - } - sb.append( string ); - sb.append( "\n" ); - ++i; - } - if ( more ) { - sb.append( "..." ); - } - try { - JOptionPane.showMessageDialog( _mf, - sb.toString(), - "Ancestral Taxonomy Inference Completed", - JOptionPane.WARNING_MESSAGE ); - } - catch ( final Exception e ) { - // Not important if this fails, do nothing. - } + end( _mf ); + try { + JOptionPane.showMessageDialog( _mf, + "Ancestral taxonomy inference successfully completed", + "Ancestral Taxonomy Inference Completed", + JOptionPane.INFORMATION_MESSAGE ); } - else { - try { - JOptionPane.showMessageDialog( _mf, - "Ancestral taxonomy inference successfully completed", - "Ancestral Taxonomy Inference Completed", - JOptionPane.INFORMATION_MESSAGE ); - } - catch ( final Exception e ) { - // Not important if this fails, do nothing. - } + catch ( final Exception e ) { + // Not important if this fails, do nothing. } }