X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FAptxUtil.java;h=b874665d18f1a91f131c725e8475e649dce2e28a;hb=b43f94dd9ce1416a2459997d1a1b69cf81036684;hp=823e18f5258156475baae631c4c38968e2cb740f;hpb=9cb3f8c0c0ddf4045d97c04784ceb419397e8b06;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/AptxUtil.java b/forester/java/src/org/forester/archaeopteryx/AptxUtil.java index 823e18f..b874665 100644 --- a/forester/java/src/org/forester/archaeopteryx/AptxUtil.java +++ b/forester/java/src/org/forester/archaeopteryx/AptxUtil.java @@ -75,10 +75,10 @@ import org.forester.io.parsers.tol.TolParser; import org.forester.io.parsers.util.ParserUtils; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyMethods; +import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.data.Accession; import org.forester.phylogeny.data.BranchColor; -import org.forester.phylogeny.data.Sequence; import org.forester.phylogeny.data.Taxonomy; import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory; import org.forester.phylogeny.factories.PhylogenyFactory; @@ -107,22 +107,10 @@ public final class AptxUtil { final Configuration conf, final TreePanel tp ) { String uri_str = null; - if ( node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getAccession() != null ) - && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() ) - && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getValue() ) - && conf.isHasWebLink( node.getNodeData().getSequence().getAccession().getSource().toLowerCase() ) ) { - final Sequence seq = node.getNodeData().getSequence(); - final String source = seq.getAccession().getSource().toLowerCase(); - String url; - if ( source.toLowerCase().equals( "ncbi" ) ) { - url = Constants.NCBI_ALL_DATABASE_SEARCH; - } - else { - final WebLink weblink = conf.getWebLink( source ); - url = weblink.getUrl().toString(); - } + final String upkb = ForesterUtil.extractUniProtKbProteinSeqIdentifier( node ); + if ( !ForesterUtil.isEmpty( upkb ) ) { try { - uri_str = url + URLEncoder.encode( seq.getAccession().getValue(), ForesterConstants.UTF8 ); + uri_str = ForesterUtil.UNIPROT_KB + URLEncoder.encode( upkb, ForesterConstants.UTF8 ); } catch ( final UnsupportedEncodingException e ) { showErrorMessage( tp, e.toString() ); @@ -130,10 +118,15 @@ public final class AptxUtil { } } if ( ForesterUtil.isEmpty( uri_str ) ) { - final String upkb = ForesterUtil.extractUniProtKbProteinSeqIdentifier( node ); - if ( !ForesterUtil.isEmpty( upkb ) ) { + final String v = ForesterUtil.extractGenbankAccessor( node ); + if ( !ForesterUtil.isEmpty( v ) ) { try { - uri_str = ForesterUtil.UNIPROT_KB + URLEncoder.encode( upkb, ForesterConstants.UTF8 ); + if ( SequenceIdParser.isProtein( v ) ) { + uri_str = ForesterUtil.NCBI_PROTEIN + URLEncoder.encode( v, ForesterConstants.UTF8 ); + } + else { + uri_str = ForesterUtil.NCBI_NUCCORE + URLEncoder.encode( v, ForesterConstants.UTF8 ); + } } catch ( final UnsupportedEncodingException e ) { showErrorMessage( tp, e.toString() ); @@ -142,7 +135,7 @@ public final class AptxUtil { } } if ( ForesterUtil.isEmpty( uri_str ) ) { - final String v = ForesterUtil.extractGenbankAccessor( node ); + final String v = ForesterUtil.extractRefSeqAccessorAccessor( node ); if ( !ForesterUtil.isEmpty( v ) ) { try { if ( SequenceIdParser.isProtein( v ) ) { @@ -159,15 +152,10 @@ public final class AptxUtil { } } if ( ForesterUtil.isEmpty( uri_str ) ) { - final String v = ForesterUtil.extractRefSeqAccessorAccessor( node ); + final String v = ForesterUtil.extractGInumber( node ); if ( !ForesterUtil.isEmpty( v ) ) { try { - if ( SequenceIdParser.isProtein( v ) ) { - uri_str = ForesterUtil.NCBI_PROTEIN + URLEncoder.encode( v, ForesterConstants.UTF8 ); - } - else { - uri_str = ForesterUtil.NCBI_NUCCORE + URLEncoder.encode( v, ForesterConstants.UTF8 ); - } + uri_str = ForesterUtil.NCBI_GI + URLEncoder.encode( v, ForesterConstants.UTF8 ); } catch ( final UnsupportedEncodingException e ) { showErrorMessage( tp, e.toString() ); @@ -807,9 +795,8 @@ public final class AptxUtil { desc.append( "\n" ); desc.append( " Median: " + ForesterUtil.round( bs.median(), 6 ) ); desc.append( "\n" ); - desc.append( " Mean: " + ForesterUtil.round( bs.arithmeticMean(), 6 ) ); - desc.append( "\n" ); - desc.append( " SD: " + ForesterUtil.round( bs.sampleStandardDeviation(), 6 ) ); + desc.append( " Mean: " + ForesterUtil.round( bs.arithmeticMean(), 6 ) + " (stdev: " + + ForesterUtil.round( bs.sampleStandardDeviation(), 6 ) + ")" ); desc.append( "\n" ); desc.append( " Minimum: " + ForesterUtil.round( bs.getMin(), 6 ) ); desc.append( "\n" ); @@ -828,9 +815,8 @@ public final class AptxUtil { desc.append( "\n" ); desc.append( " Median: " + ForesterUtil.round( ds.median(), 2 ) ); desc.append( "\n" ); - desc.append( " Mean: " + ForesterUtil.round( ds.arithmeticMean(), 2 ) ); - desc.append( "\n" ); - desc.append( " SD: " + ForesterUtil.round( ds.sampleStandardDeviation(), 2 ) ); + desc.append( " Mean: " + ForesterUtil.round( ds.arithmeticMean(), 2 ) + " (stdev: " + + ForesterUtil.round( ds.sampleStandardDeviation(), 2 ) + ")" ); desc.append( "\n" ); desc.append( " Minimum: " + ForesterUtil.roundToInt( ds.getMin() ) ); desc.append( "\n" ); @@ -865,11 +851,10 @@ public final class AptxUtil { desc.append( " Median: " + ForesterUtil.round( cs.median(), 6 ) ); desc.append( "\n" ); desc.append( " Mean: " + ForesterUtil.round( cs.arithmeticMean(), 6 ) ); - desc.append( "\n" ); if ( cs.getN() > 2 ) { - desc.append( " SD: " + ForesterUtil.round( cs.sampleStandardDeviation(), 6 ) ); - desc.append( "\n" ); + desc.append( " (stdev: " + ForesterUtil.round( cs.sampleStandardDeviation(), 6 ) + ")" ); } + desc.append( "\n" ); desc.append( " Minimum: " + ForesterUtil.roundToInt( cs.getMin() ) ); desc.append( "\n" ); desc.append( " Maximum: " + ForesterUtil.roundToInt( cs.getMax() ) ); @@ -933,17 +918,6 @@ public final class AptxUtil { return true; } - final static boolean isMac() { - try { - final String s = ForesterUtil.OS_NAME.toLowerCase(); - return s.startsWith( "mac" ); - } - catch ( final Exception e ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "minor error: " + e ); - return false; - } - } - final static boolean isUsOrCanada() { try { if ( ( Locale.getDefault().equals( Locale.CANADA ) ) || ( Locale.getDefault().equals( Locale.US ) ) ) { @@ -956,17 +930,6 @@ public final class AptxUtil { return false; } - final static boolean isWindows() { - try { - final String s = ForesterUtil.OS_NAME.toLowerCase(); - return s.indexOf( "win" ) > -1; - } - catch ( final Exception e ) { - ForesterUtil.printWarningMessage( Constants.PRG_NAME, "minor error: " + e ); - return false; - } - } - final static void lookAtSomeTreePropertiesForAptxControlSettings( final Phylogeny t, final ControlPanel atv_control, final Configuration configuration ) { @@ -1040,8 +1003,9 @@ public final class AptxUtil { final boolean phyloxml_validate_against_xsd, final boolean replace_underscores, final boolean internal_numbers_are_confidences, - final TAXONOMY_EXTRACTION taxonomy_extraction ) - throws FileNotFoundException, IOException { + final TAXONOMY_EXTRACTION taxonomy_extraction, + final boolean midpoint_reroot ) throws FileNotFoundException, + IOException { final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance(); final PhylogenyParser parser; boolean nhx_or_nexus = false; @@ -1070,6 +1034,12 @@ public final class AptxUtil { PhylogenyMethods.transferInternalNodeNamesToConfidence( phy ); } } + if ( midpoint_reroot ) { + for( final Phylogeny phy : phys ) { + PhylogenyMethods.midpointRoot( phy ); + PhylogenyMethods.orderAppearance( phy.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME ); + } + } return phys; } @@ -1305,7 +1275,7 @@ public final class AptxUtil { if ( os.toLowerCase().startsWith( "win" ) ) { Runtime.getRuntime().exec( "rundll32 url.dll,FileProtocolHandler " + url ); } - else if ( isMac() ) { + else if ( ForesterUtil.isMac() ) { final Class file_mgr = Class.forName( "com.apple.eio.FileManager" ); final Method open_url = file_mgr.getDeclaredMethod( "openURL", new Class[] { String.class } ); open_url.invoke( null, new Object[] { url } );