X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Futil%2FForesterUtil.java;h=eb1ea8df1f65a535042d5b8d53315025fdae15ef;hb=a1114eb8610e592961a40e5c3d46d647c02b5108;hp=08c3b9e85088488bf2c7be534843ad1e0d1b3abb;hpb=03e51d179caedf757b09e2872f9500318bd85a53;p=jalview.git diff --git a/forester/java/src/org/forester/util/ForesterUtil.java b/forester/java/src/org/forester/util/ForesterUtil.java index 08c3b9e..eb1ea8d 100644 --- a/forester/java/src/org/forester/util/ForesterUtil.java +++ b/forester/java/src/org/forester/util/ForesterUtil.java @@ -21,7 +21,7 @@ // 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; @@ -50,7 +50,6 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Date; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -59,8 +58,19 @@ import java.util.SortedMap; 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; +import org.forester.phylogeny.data.Taxonomy; +import org.forester.protein.BasicProtein; +import org.forester.protein.Domain; +import org.forester.protein.Protein; +import org.forester.surfacing.SurfacingUtil; + public final class ForesterUtil { public final static String FILE_SEPARATOR = System.getProperty( "file.separator" ); @@ -77,6 +87,10 @@ public final class ForesterUtil { 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( '.' ); @@ -90,29 +104,86 @@ public final class ForesterUtil { private ForesterUtil() { } + public static int calculateOverlap( final Domain domain, final List covered_positions ) { + int overlap_count = 0; + for( int i = domain.getFrom(); i <= domain.getTo(); ++i ) { + if ( ( i < covered_positions.size() ) && ( covered_positions.get( i ) == true ) ) { + ++overlap_count; + } + } + return overlap_count; + } + final public static void appendSeparatorIfNotEmpty( final StringBuffer sb, final char separator ) { if ( sb.length() > 0 ) { sb.append( separator ); } } - public static boolean isWindowns() { - return ForesterUtil.OS_NAME.toLowerCase().indexOf( "win" ) > -1; - } - - final public static String getForesterLibraryInformation() { - return "forester " + ForesterConstants.FORESTER_VERSION + " (" + ForesterConstants.FORESTER_DATE + ")"; + /** + * + * Example regarding engulfment: ------------0.1 ----------0.2 --0.3 => + * domain with 0.3 is ignored + * + * -----------0.1 ----------0.2 --0.3 => domain with 0.3 is ignored + * + * + * ------------0.1 ----------0.3 --0.2 => domains with 0.3 and 0.2 are _not_ + * ignored + * + * @param max_allowed_overlap + * maximal allowed overlap (inclusive) to be still considered not + * overlapping (zero or negative value to allow any overlap) + * @param remove_engulfed_domains + * to remove domains which are completely engulfed by coverage of + * domains with better support + * @param protein + * @return + */ + public static Protein removeOverlappingDomains( final int max_allowed_overlap, + final boolean remove_engulfed_domains, + final Protein protein ) { + final Protein pruned_protein = new BasicProtein( protein.getProteinId().getId(), protein.getSpecies() + .getSpeciesId(), protein.getLength() ); + final List sorted = SurfacingUtil.sortDomainsWithAscendingConfidenceValues( protein ); + final List covered_positions = new ArrayList(); + for( final Domain domain : sorted ) { + if ( ( ( max_allowed_overlap < 0 ) || ( ForesterUtil.calculateOverlap( domain, covered_positions ) <= max_allowed_overlap ) ) + && ( !remove_engulfed_domains || !isEngulfed( domain, covered_positions ) ) ) { + final int covered_positions_size = covered_positions.size(); + for( int i = covered_positions_size; i < domain.getFrom(); ++i ) { + covered_positions.add( false ); + } + final int new_covered_positions_size = covered_positions.size(); + for( int i = domain.getFrom(); i <= domain.getTo(); ++i ) { + if ( i < new_covered_positions_size ) { + covered_positions.set( i, true ); + } + else { + covered_positions.add( true ); + } + } + pruned_protein.addProteinDomain( domain ); + } + } + return pruned_protein; } - public static boolean seqIsLikelyToBeAa( final String s ) { - final String seq = s.toLowerCase(); - if ( ( seq.indexOf( 'r' ) > -1 ) || ( seq.indexOf( 'd' ) > -1 ) || ( seq.indexOf( 'e' ) > -1 ) - || ( seq.indexOf( 'q' ) > -1 ) || ( seq.indexOf( 'h' ) > -1 ) || ( seq.indexOf( 'k' ) > -1 ) - || ( seq.indexOf( 'w' ) > -1 ) || ( seq.indexOf( 's' ) > -1 ) || ( seq.indexOf( 'm' ) > -1 ) - || ( seq.indexOf( 'p' ) > -1 ) || ( seq.indexOf( 'v' ) > -1 ) ) { - return true; + /** + * Returns true is Domain domain falls in an uninterrupted stretch of + * covered positions. + * + * @param domain + * @param covered_positions + * @return + */ + public static boolean isEngulfed( final Domain domain, final List covered_positions ) { + for( int i = domain.getFrom(); i <= domain.getTo(); ++i ) { + if ( ( i >= covered_positions.size() ) || ( covered_positions.get( i ) != true ) ) { + return false; + } } - return false; + return true; } /** @@ -205,39 +276,6 @@ public final class ForesterUtil { } } - /** - * Helper method for calcColor methods. - * - * @param smallercolor_component_x - * color component the smaller color - * @param largercolor_component_x - * color component the larger color - * @param x - * factor - * @return an int representing a color component - */ - final private static int calculateColorComponent( final double smallercolor_component_x, - final double largercolor_component_x, - final double x ) { - return ( int ) ( smallercolor_component_x + ( ( x * ( largercolor_component_x - smallercolor_component_x ) ) / 255.0 ) ); - } - - /** - * Helper method for calcColor methods. - * - * - * @param value - * the value - * @param larger - * the largest value - * @param smaller - * the smallest value - * @return a normalized value between larger and smaller - */ - final private static double calculateColorFactor( final double value, final double larger, final double smaller ) { - return ( 255.0 * ( value - smaller ) ) / ( larger - smaller ); - } - final public static String collapseWhiteSpace( final String s ) { return s.replaceAll( "[\\s]+", " " ); } @@ -308,6 +346,10 @@ public final class ForesterUtil { return new BufferedWriter( new FileWriter( file ) ); } + final public static BufferedWriter createBufferedWriter( final String name ) throws IOException { + return new BufferedWriter( new FileWriter( createFileForWriting( name ) ) ); + } + final public static EasyWriter createEasyWriter( final File file ) throws IOException { return new EasyWriter( createBufferedWriter( file ) ); } @@ -316,10 +358,6 @@ public final class ForesterUtil { return createEasyWriter( createFileForWriting( name ) ); } - final public static BufferedWriter createBufferedWriter( final String name ) throws IOException { - return new BufferedWriter( new FileWriter( createFileForWriting( name ) ) ); - } - final public static File createFileForWriting( final String name ) throws IOException { final File file = new File( name ); if ( file.exists() ) { @@ -328,6 +366,37 @@ public final class ForesterUtil { return file; } + final public static void ensurePresenceOfDate( final PhylogenyNode node ) { + if ( !node.getNodeData().isHasDate() ) { + node.getNodeData().setDate( new org.forester.phylogeny.data.Date() ); + } + } + + final public static void ensurePresenceOfDistribution( final PhylogenyNode node ) { + if ( !node.getNodeData().isHasDistribution() ) { + node.getNodeData().setDistribution( new Distribution( "" ) ); + } + } + + public static void ensurePresenceOfSequence( final PhylogenyNode node ) { + if ( !node.getNodeData().isHasSequence() ) { + node.getNodeData().setSequence( new Sequence() ); + } + } + + public static void ensurePresenceOfTaxonomy( final PhylogenyNode node ) { + if ( !node.getNodeData().isHasTaxonomy() ) { + node.getNodeData().setTaxonomy( new Taxonomy() ); + } + } + + public static void fatalError( final String message ) { + System.err.println(); + System.err.println( "error: " + message ); + System.err.println(); + System.exit( -1 ); + } + public static void fatalError( final String prg_name, final String message ) { System.err.println(); System.err.println( "[" + prg_name + "] > " + message ); @@ -335,6 +404,26 @@ public final class ForesterUtil { System.exit( -1 ); } + public static void fatalErrorIfFileNotReadable( final File file ) { + final String error = isReadableFile( file ); + if ( !isEmpty( error ) ) { + System.err.println(); + System.err.println( "error: " + error ); + System.err.println(); + System.exit( -1 ); + } + } + + public static void fatalErrorIfFileNotReadable( final String prg_name, final File file ) { + final String error = isReadableFile( file ); + if ( !isEmpty( error ) ) { + System.err.println(); + System.err.println( "[" + prg_name + "] > " + error ); + System.err.println(); + System.exit( -1 ); + } + } + public static String[] file2array( final File file ) throws IOException { final List list = file2list( file ); final String[] ary = new String[ list.size() ]; @@ -345,6 +434,34 @@ public final class ForesterUtil { return ary; } + public static String[][] file22dArray( final File file ) throws IOException { + final List list = new ArrayList(); + 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 file2list( final File file ) throws IOException { final List list = new ArrayList(); final BufferedReader in = new BufferedReader( new FileReader( file ) ); @@ -432,6 +549,10 @@ public final class ForesterUtil { return line; } + final public static String getForesterLibraryInformation() { + return "forester " + ForesterConstants.FORESTER_VERSION + " (" + ForesterConstants.FORESTER_DATE + ")"; + } + final public static String getLineSeparator() { return ForesterUtil.LINE_SEPARATOR; } @@ -548,6 +669,26 @@ public final class ForesterUtil { return isReadableFile( new File( s ) ); } + 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 ) { if ( f.isDirectory() ) { return "[" + f + "] is a directory"; @@ -573,7 +714,7 @@ public final class ForesterUtil { return i; } - final public static SortedMap listToSortedCountsMap( final List list ) { + final public static SortedMap listToSortedCountsMap( final List list ) { final SortedMap map = new TreeMap(); for( final Object key : list ) { if ( !map.containsKey( key ) ) { @@ -613,10 +754,9 @@ public final class ForesterUtil { } } - final public static StringBuffer mapToStringBuffer( final Map map, final String key_value_separator ) { + final public static StringBuffer mapToStringBuffer( final Map map, final String key_value_separator ) { final StringBuffer sb = new StringBuffer(); - for( final Iterator iter = map.keySet().iterator(); iter.hasNext(); ) { - final Object key = iter.next(); + for( final Object key : map.keySet() ) { sb.append( key.toString() ); sb.append( key_value_separator ); sb.append( map.get( key ).toString() ); @@ -732,7 +872,7 @@ public final class ForesterUtil { } final public static void printErrorMessage( final String prg_name, final String message ) { - System.out.println( "[" + prg_name + "] > error: " + message ); + System.err.println( "[" + prg_name + "] > error: " + message ); } final public static void printProgramInformation( final String prg_name, final String prg_version, final String date ) { @@ -746,6 +886,14 @@ public final class ForesterUtil { } final public static void printProgramInformation( final String prg_name, + final String prg_version, + final String date, + final String email, + final String www ) { + printProgramInformation( prg_name, null, prg_version, date, email, www, null ); + } + + final public static void printProgramInformation( final String prg_name, final String desc, final String prg_version, final String date, @@ -776,14 +924,6 @@ public final class ForesterUtil { System.out.println(); } - final public static void printProgramInformation( final String prg_name, - final String prg_version, - final String date, - final String email, - final String www ) { - printProgramInformation( prg_name, null, prg_version, date, email, www, null ); - } - final public static void printWarningMessage( final String prg_name, final String message ) { System.out.println( "[" + prg_name + "] > warning: " + message ); } @@ -861,9 +1001,15 @@ public final class ForesterUtil { } } - final private static String[] splitString( final String str ) { - final String regex = "[\\s;,]+"; - return str.split( regex ); + public static boolean seqIsLikelyToBeAa( final String s ) { + final String seq = s.toLowerCase(); + if ( ( seq.indexOf( 'r' ) > -1 ) || ( seq.indexOf( 'd' ) > -1 ) || ( seq.indexOf( 'e' ) > -1 ) + || ( seq.indexOf( 'q' ) > -1 ) || ( seq.indexOf( 'h' ) > -1 ) || ( seq.indexOf( 'k' ) > -1 ) + || ( seq.indexOf( 'w' ) > -1 ) || ( seq.indexOf( 's' ) > -1 ) || ( seq.indexOf( 'm' ) > -1 ) + || ( seq.indexOf( 'p' ) > -1 ) || ( seq.indexOf( 'v' ) > -1 ) ) { + return true; + } + return false; } final public static String stringArrayToString( final String[] a ) { @@ -913,10 +1059,34 @@ public final class ForesterUtil { return str_array; } + final public static void unexpectedFatalError( final Exception e ) { + System.err.println(); + System.err.println( "unexpected exception: should not have occured! Please contact program author(s)." ); + e.printStackTrace( System.err ); + 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)." ); + e.printStackTrace( System.err ); + System.err.println(); + System.exit( -1 ); + } + + final public static void unexpectedFatalError( final String message ) { + System.err.println(); + System.err.println( "unexpected error: should not have occured! Please contact program author(s)." ); + System.err.println( message ); + System.err.println(); + System.exit( -1 ); + } + final public static void unexpectedFatalError( final String prg_name, final Exception e ) { System.err.println(); System.err.println( "[" + prg_name - + "] > unexpected error (Should not have occured! Please contact program author(s).)" ); + + "] > unexpected error; should not have occured! Please contact program author(s)." ); e.printStackTrace( System.err ); System.err.println(); System.exit( -1 ); @@ -925,7 +1095,7 @@ public final class ForesterUtil { final public static void unexpectedFatalError( final String prg_name, final String message ) { System.err.println(); System.err.println( "[" + prg_name - + "] > unexpected error. Should not have occured! Please contact program author(s)." ); + + "] > unexpected error: should not have occured! Please contact program author(s)." ); System.err.println( message ); System.err.println(); System.exit( -1 ); @@ -934,13 +1104,30 @@ public final class ForesterUtil { final public static void unexpectedFatalError( final String prg_name, final String message, final Exception e ) { System.err.println(); System.err.println( "[" + prg_name - + "] > unexpected error. Should not have occured! Please contact program author(s)." ); + + "] > unexpected error: should not have occured! Please contact program author(s)." ); System.err.println( message ); e.printStackTrace( System.err ); System.err.println(); System.exit( -1 ); } + public final static void updateProgress( final double progress_percentage ) { + final int width = 50; + System.out.print( "\r[" ); + int i = 0; + for( ; i <= ForesterUtil.roundToInt( progress_percentage * width ); i++ ) { + System.out.print( "." ); + } + for( ; i < width; i++ ) { + System.out.print( " " ); + } + 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; @@ -969,4 +1156,208 @@ public final class ForesterUtil { } return sb.toString(); } + + /** + * Helper method for calcColor methods. + * + * @param smallercolor_component_x + * color component the smaller color + * @param largercolor_component_x + * color component the larger color + * @param x + * factor + * @return an int representing a color component + */ + final private static int calculateColorComponent( final double smallercolor_component_x, + final double largercolor_component_x, + final double x ) { + return ( int ) ( smallercolor_component_x + ( ( x * ( largercolor_component_x - smallercolor_component_x ) ) / 255.0 ) ); + } + + /** + * Helper method for calcColor methods. + * + * + * @param value + * the value + * @param larger + * the largest value + * @param smaller + * the smallest value + * @return a normalized value between larger and smaller + */ + final private static double calculateColorFactor( final double value, final double larger, final double smaller ) { + return ( 255.0 * ( value - smaller ) ) / ( larger - smaller ); + } + + final private static String[] splitString( final String str ) { + final String regex = "[\\s;,]+"; + return str.split( regex ); + } + + public final static void outOfMemoryError( final OutOfMemoryError e ) { + System.err.println(); + System.err.println( "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option" ); + System.err.println(); + e.printStackTrace( System.err ); + System.err.println(); + System.exit( -1 ); + } + + public final static Color obtainColorDependingOnTaxonomyGroup( final String tax_group ) { + if ( !ForesterUtil.isEmpty( tax_group ) ) { + if ( tax_group.equals( "deuterostomia" ) ) { + return TaxonomyColors.DEUTEROSTOMIA_COLOR; + } + else if ( tax_group.equals( "protostomia" ) ) { + return TaxonomyColors.PROTOSTOMIA_COLOR; + } + else if ( tax_group.equals( "cnidaria" ) ) { + return TaxonomyColors.CNIDARIA_COLOR; + } + else if ( tax_group.equals( "placozoa" ) ) { + return TaxonomyColors.PLACOZOA_COLOR; + } + else if ( tax_group.equals( "ctenophora" ) ) { + return TaxonomyColors.CTENOPHORA_COLOR; + } + else if ( tax_group.equals( "porifera" ) ) { + return TaxonomyColors.PORIFERA_COLOR; + } + else if ( tax_group.equals( "choanoflagellida" ) ) { + return TaxonomyColors.CHOANOFLAGELLIDA; + } + else if ( tax_group.equals( "ichthyophonida & filasterea" ) ) { + return TaxonomyColors.ICHTHYOSPOREA_AND_FILASTEREA; + } + else if ( tax_group.equals( "dikarya" ) ) { + return TaxonomyColors.DIKARYA_COLOR; + } + else if ( tax_group.equalsIgnoreCase( "fungi" ) || tax_group.equalsIgnoreCase( "other fungi" ) ) { + return TaxonomyColors.OTHER_FUNGI_COLOR; + } + else if ( tax_group.equals( "nucleariidae and fonticula" ) ) { + return TaxonomyColors.NUCLEARIIDAE_AND_FONTICULA_GROUP_COLOR; + } + else if ( tax_group.equals( "amoebozoa" ) ) { + return TaxonomyColors.AMOEBOZOA_COLOR; + } + else if ( tax_group.equals( "embryophyta" ) ) { + return TaxonomyColors.EMBRYOPHYTA_COLOR; + } + else if ( tax_group.equals( "chlorophyta" ) ) { + return TaxonomyColors.CHLOROPHYTA_COLOR; + } + else if ( tax_group.equals( "rhodophyta" ) ) { + return TaxonomyColors.RHODOPHYTA_COLOR; + } + else if ( tax_group.equals( "hacrobia" ) ) { + return TaxonomyColors.HACROBIA_COLOR; + } + else if ( tax_group.equals( "glaucocystophyceae" ) ) { + return TaxonomyColors.GLAUCOPHYTA_COLOR; + } + else if ( tax_group.equals( "stramenopiles" ) ) { + return TaxonomyColors.STRAMENOPILES_COLOR; + } + else if ( tax_group.equals( "alveolata" ) ) { + return TaxonomyColors.ALVEOLATA_COLOR; + } + else if ( tax_group.equals( "rhizaria" ) ) { + return TaxonomyColors.RHIZARIA_COLOR; + } + else if ( tax_group.equals( "excavata" ) ) { + return TaxonomyColors.EXCAVATA_COLOR; + } + else if ( tax_group.equals( "apusozoa" ) ) { + return TaxonomyColors.APUSOZOA_COLOR; + } + else if ( tax_group.equals( "archaea" ) ) { + return TaxonomyColors.ARCHAEA_COLOR; + } + else if ( tax_group.equals( "bacteria" ) ) { + return TaxonomyColors.BACTERIA_COLOR; + } + } + return null; + } + + public final static String obtainNormalizedTaxonomyGroup( final String tax ) { + if ( tax.equalsIgnoreCase( "deuterostomia" ) ) { + return "deuterostomia"; + } + else if ( tax.equalsIgnoreCase( "protostomia" ) ) { + return "protostomia"; + } + else if ( tax.equalsIgnoreCase( "cnidaria" ) ) { + return "cnidaria"; + } + else if ( tax.toLowerCase().startsWith( "trichoplax" ) || tax.equalsIgnoreCase( "placozoa" ) ) { + return "placozoa"; + } + else if ( tax.toLowerCase().startsWith( "mnemiopsis" ) || tax.equalsIgnoreCase( "ctenophora" ) ) { + return "ctenophora"; + } + else if ( tax.toLowerCase().startsWith( "amphimedon" ) || tax.equalsIgnoreCase( "porifera" ) ) { + return "porifera"; + } + else if ( tax.equalsIgnoreCase( "codonosigidae" ) || tax.equalsIgnoreCase( "choanoflagellida" ) ) { + return "choanoflagellida"; + } + else if ( tax.toLowerCase().startsWith( "ichthyophonida & filasterea" ) + || tax.toLowerCase().startsWith( "ichthyophonida and filasterea" ) + || tax.toLowerCase().startsWith( "ichthyosporea & filasterea" ) + || tax.toLowerCase().startsWith( "ichthyosporea and filasterea" ) ) { + return "ichthyophonida & filasterea"; + } + else if ( tax.equalsIgnoreCase( "dikarya" ) ) { + return "dikarya"; + } + else if ( tax.equalsIgnoreCase( "other fungi" ) ) { + return "other fungi"; + } + else if ( tax.toLowerCase().startsWith( "nucleariidae and fonticula" ) ) { + return "nucleariidae and fonticula group"; + } + else if ( tax.equalsIgnoreCase( "amoebozoa" ) ) { + return "amoebozoa"; + } + else if ( tax.equalsIgnoreCase( "embryophyta" ) ) { + return "embryophyta"; + } + else if ( tax.equalsIgnoreCase( "chlorophyta" ) ) { + return "chlorophyta"; + } + else if ( tax.equalsIgnoreCase( "rhodophyta" ) ) { + return "rhodophyta"; + } + else if ( tax.toLowerCase().startsWith( "hacrobia" ) ) { + return "hacrobia"; + } + else if ( tax.equalsIgnoreCase( "glaucocystophyceae" ) || tax.equalsIgnoreCase( "glaucophyta" ) ) { + return "glaucocystophyceae"; + } + else if ( tax.equalsIgnoreCase( "stramenopiles" ) ) { + return "stramenopiles"; + } + else if ( tax.equalsIgnoreCase( "alveolata" ) ) { + return "alveolata"; + } + else if ( tax.equalsIgnoreCase( "rhizaria" ) ) { + return "rhizaria"; + } + else if ( tax.equalsIgnoreCase( "excavata" ) ) { + return "excavata"; + } + else if ( tax.equalsIgnoreCase( "apusozoa" ) ) { + return "apusozoa"; + } + else if ( tax.equalsIgnoreCase( "archaea" ) ) { + return "archaea"; + } + else if ( tax.equalsIgnoreCase( "bacteria" ) ) { + return "bacteria"; + } + return null; + } }