import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
+import java.net.URLEncoder;
import java.text.ParseException;
import java.util.Arrays;
import java.util.HashMap;
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.iterators.PreorderTreeIterator;
import org.forester.util.AsciiHistogram;
import org.forester.util.DescriptiveStatistics;
+import org.forester.util.ForesterConstants;
import org.forester.util.ForesterUtil;
+import org.forester.util.SequenceIdParser;
import org.forester.ws.seqdb.UniProtTaxonomy;
public final class AptxUtil {
- final static String UNIPROT_KB = "http://www.uniprot.org/uniprot/";
- final static Pattern UNIPROT_KB_PATTERN_1 = Pattern
- .compile( "\\bsp|tr.\\S([A-Z0-9]{5,6})\\b" );
-
- final static Pattern UNIPROT_KB_PATTERN_2 = Pattern
- .compile( "\\b[A-Z0-9]{5,6}_[A-Z9][A-Z]{2}[A-Z0-9]{2}|RAT|PIG|PEA\\b" );
private final static Pattern seq_identifier_pattern_1 = Pattern
.compile( "^([A-Za-z]{2,5})[|=:]([0-9A-Za-z_\\.]{5,40})\\s*$" );
private final static Pattern seq_identifier_pattern_2 = Pattern
Arrays.sort( AVAILABLE_FONT_FAMILIES_SORTED );
}
+ public final static String createUriForSeqWeb( final PhylogenyNode node,
+ final Configuration conf,
+ final TreePanel tp ) {
+ String uri_str = null;
+ final String upkb = ForesterUtil.extractUniProtKbProteinSeqIdentifier( node );
+ if ( !ForesterUtil.isEmpty( upkb ) ) {
+ try {
+ uri_str = ForesterUtil.UNIPROT_KB + URLEncoder.encode( upkb, ForesterConstants.UTF8 );
+ }
+ catch ( final UnsupportedEncodingException e ) {
+ showErrorMessage( tp, e.toString() );
+ e.printStackTrace();
+ }
+ }
+ if ( ForesterUtil.isEmpty( uri_str ) ) {
+ final String v = ForesterUtil.extractGenbankAccessor( 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 );
+ }
+ }
+ catch ( final UnsupportedEncodingException e ) {
+ showErrorMessage( tp, e.toString() );
+ e.printStackTrace();
+ }
+ }
+ }
+ if ( ForesterUtil.isEmpty( uri_str ) ) {
+ final String v = ForesterUtil.extractRefSeqAccessorAccessor( 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 );
+ }
+ }
+ catch ( final UnsupportedEncodingException e ) {
+ showErrorMessage( tp, e.toString() );
+ e.printStackTrace();
+ }
+ }
+ }
+ if ( ForesterUtil.isEmpty( uri_str ) ) {
+ final String v = ForesterUtil.extractGInumber( node );
+ if ( !ForesterUtil.isEmpty( v ) ) {
+ try {
+ uri_str = ForesterUtil.NCBI_GI + URLEncoder.encode( v, ForesterConstants.UTF8 );
+ }
+ catch ( final UnsupportedEncodingException e ) {
+ showErrorMessage( tp, e.toString() );
+ e.printStackTrace();
+ }
+ }
+ }
+ return uri_str;
+ }
+
public static MaskFormatter createMaskFormatter( final String s ) {
MaskFormatter formatter = null;
try {
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" );
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" );
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() ) );
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 ) ) ) {
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 ) {
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;
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;
}
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 } );