// 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.util;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
+import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.forester.archaeopteryx.Constants;
import org.forester.phylogeny.PhylogenyNode;
import org.forester.phylogeny.data.Distribution;
import org.forester.phylogeny.data.Sequence;
public static final NumberFormat FORMATTER_6;
public static final NumberFormat FORMATTER_06;
public static final NumberFormat FORMATTER_3;
+ public static final String NCBI_PROTEIN = "http://www.ncbi.nlm.nih.gov/protein/";
+ public static final String NCBI_NUCCORE = "http://www.ncbi.nlm.nih.gov/nuccore/";
+ public final static String UNIPROT_KB = "http://www.uniprot.org/uniprot/";
+ public static final String NCBI_GI = "http://www.ncbi.nlm.nih.gov/protein/gi:";
static {
final DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setDecimalSeparator( '.' );
return ary;
}
+ public static String[][] file22dArray( final File file ) throws IOException {
+ final List<String> list = new ArrayList<String>();
+ final BufferedReader in = new BufferedReader( new FileReader( file ) );
+ String str;
+ while ( ( str = in.readLine() ) != null ) {
+ str = str.trim();
+ if ( ( str.length() > 0 ) && !str.startsWith( "#" ) ) {
+ list.add( str );
+ }
+ }
+ in.close();
+ final String[][] ary = new String[ list.size() ][ 2 ];
+ final Pattern pa = Pattern.compile( "(\\S+)\\s+(\\S+)" );
+ int i = 0;
+ for( final String s : list ) {
+ final Matcher m = pa.matcher( s );
+ if ( m.matches() ) {
+ ary[ i ][ 0 ] = m.group( 1 );
+ ary[ i ][ 1 ] = m.group( 2 );
+ ++i;
+ }
+ else {
+ throw new IOException( "unexpcted format: " + s );
+ }
+ }
+ return ary;
+ }
+
final public static List<String> file2list( final File file ) throws IOException {
final List<String> list = new ArrayList<String>();
final BufferedReader in = new BufferedReader( new FileReader( file ) );
return isReadableFile( new File( s ) );
}
- public static boolean isWindowns() {
- return ForesterUtil.OS_NAME.toLowerCase().indexOf( "win" ) > -1;
+ public final static boolean isWindows() {
+ try {
+ return OS_NAME.toLowerCase().indexOf( "win" ) > -1;
+ }
+ catch ( final Exception e ) {
+ ForesterUtil.printWarningMessage( Constants.PRG_NAME, "minor error: " + e );
+ return false;
+ }
+ }
+
+ public final static boolean isMac() {
+ try {
+ return OS_NAME.toLowerCase().startsWith( "mac" );
+ }
+ catch ( final Exception e ) {
+ ForesterUtil.printWarningMessage( Constants.PRG_NAME, "minor error: " + e );
+ return false;
+ }
}
final public static String isWritableFile( final File f ) {
System.err.println();
System.exit( -1 );
}
-
+
final public static void unexpectedFatalError( final Error e ) {
System.err.println();
System.err.println( "unexpected error: should not have occured! Please contact program author(s)." );
System.out.print( "]" );
}
+ public final static void updateProgress( final int i, final DecimalFormat f ) {
+ System.out.print( "\r[" + f.format( i ) + "]" );
+ }
+
public final static String wordWrap( final String str, final int width ) {
final StringBuilder sb = new StringBuilder( str );
int start = 0;