in progress
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Wed, 28 Sep 2011 23:47:57 +0000 (23:47 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Wed, 28 Sep 2011 23:47:57 +0000 (23:47 +0000)
forester/java/src/org/forester/archaeopteryx/ControlPanel.java
forester/java/src/org/forester/archaeopteryx/MainFrame.java
forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java
forester/java/src/org/forester/archaeopteryx/MainPanel.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java
forester/java/src/org/forester/archaeopteryx/Util.java
forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlUtil.java
forester/java/src/org/forester/phylogeny/data/Taxonomy.java

index b308854..5509327 100644 (file)
@@ -397,11 +397,6 @@ final class ControlPanel extends JPanel implements ActionListener {
                 addJCheckBox( _show_node_names, ch_panel );
                 add( ch_panel );
                 break;
-            case Configuration.show_tax_code:
-                _show_taxo_code = new JCheckBox( title );
-                addJCheckBox( _show_taxo_code, ch_panel );
-                add( ch_panel );
-                break;
             case Configuration.show_taxonomy_scientific_names:
                 _show_taxo_scientific_names = new JCheckBox( title );
                 addJCheckBox( _show_taxo_scientific_names, ch_panel );
@@ -412,6 +407,11 @@ final class ControlPanel extends JPanel implements ActionListener {
                 addJCheckBox( _show_taxo_common_names, ch_panel );
                 add( ch_panel );
                 break;
+            case Configuration.show_tax_code:
+                _show_taxo_code = new JCheckBox( title );
+                addJCheckBox( _show_taxo_code, ch_panel );
+                add( ch_panel );
+                break;
             case Configuration.show_taxonomy_images:
                 _show_taxo_images_cb = new JCheckBox( title );
                 addJCheckBox( _show_taxo_images_cb, ch_panel );
@@ -651,6 +651,10 @@ final class ControlPanel extends JPanel implements ActionListener {
         return _color_branches_cb;
     }
 
+    public JCheckBox getColorAccSpeciesCb() {
+        return _color_acc_species;
+    }
+
     Configuration getConfiguration() {
         return _configuration;
     }
@@ -996,11 +1000,6 @@ final class ControlPanel extends JPanel implements ActionListener {
                     _show_node_names.setSelected( state );
                 }
                 break;
-            case Configuration.show_tax_code:
-                if ( _show_taxo_code != null ) {
-                    _show_taxo_code.setSelected( state );
-                }
-                break;
             case Configuration.show_taxonomy_scientific_names:
                 if ( _show_taxo_scientific_names != null ) {
                     _show_taxo_scientific_names.setSelected( state );
@@ -1011,6 +1010,11 @@ final class ControlPanel extends JPanel implements ActionListener {
                     _show_taxo_common_names.setSelected( state );
                 }
                 break;
+            case Configuration.show_tax_code:
+                if ( _show_taxo_code != null ) {
+                    _show_taxo_code.setSelected( state );
+                }
+                break;
             case Configuration.show_taxonomy_images:
                 if ( _show_taxo_images_cb != null ) {
                     _show_taxo_images_cb.setSelected( state );
index 1c67316..98f2669 100644 (file)
@@ -645,14 +645,7 @@ public abstract class MainFrame extends JFrame implements ActionListener {
 
     void colorRank() {
         if ( _mainpanel.getCurrentTreePanel() != null ) {
-            final String[] ranks = Util.getAllRanks( _mainpanel.getCurrentTreePanel().getPhylogeny() );
-            if ( ranks.length < 1 ) {
-                JOptionPane.showMessageDialog( this,
-                                               "No rank information was found",
-                                               "No Rank Information",
-                                               JOptionPane.WARNING_MESSAGE );
-                return;
-            }
+            final String[] ranks = Util.getAllPossibleRanks();
             final String rank = ( String ) JOptionPane
                     .showInputDialog( this,
                                       "What rank should the colorization be based on",
index 42b6cb6..c524d9b 100644 (file)
@@ -174,20 +174,22 @@ class SequencesFileFilter extends FileFilter {
 
 public final class MainFrameApplication extends MainFrame {
 
-    private final static int                 FRAME_X_SIZE                    = 800;
-    private final static int                 FRAME_Y_SIZE                    = 800;
+    static final String                      INFER_ANCESTOR_TAXONOMIES             = "Infer Ancestor Taxonomies";
+    static final String                      OBTAIN_DETAILED_TAXONOMIC_INFORMATION = "Obtain Detailed Taxonomic Information";
+    private final static int                 FRAME_X_SIZE                          = 800;
+    private final static int                 FRAME_Y_SIZE                          = 800;
     // Filters for the file-open dialog (classes defined in this file)
-    private final static NHFilter            nhfilter                        = new NHFilter();
-    private final static NHXFilter           nhxfilter                       = new NHXFilter();
-    private final static XMLFilter           xmlfilter                       = new XMLFilter();
-    private final static TolFilter           tolfilter                       = new TolFilter();
-    private final static NexusFilter         nexusfilter                     = new NexusFilter();
-    private final static PdfFilter           pdffilter                       = new PdfFilter();
-    private final static GraphicsFileFilter  graphicsfilefilter              = new GraphicsFileFilter();
-    private final static MsaFileFilter       msafilter                       = new MsaFileFilter();
-    private final static SequencesFileFilter seqsfilter                      = new SequencesFileFilter();
-    private final static DefaultFilter       defaultfilter                   = new DefaultFilter();
-    private static final long                serialVersionUID                = -799735726778865234L;
+    private final static NHFilter            nhfilter                              = new NHFilter();
+    private final static NHXFilter           nhxfilter                             = new NHXFilter();
+    private final static XMLFilter           xmlfilter                             = new XMLFilter();
+    private final static TolFilter           tolfilter                             = new TolFilter();
+    private final static NexusFilter         nexusfilter                           = new NexusFilter();
+    private final static PdfFilter           pdffilter                             = new PdfFilter();
+    private final static GraphicsFileFilter  graphicsfilefilter                    = new GraphicsFileFilter();
+    private final static MsaFileFilter       msafilter                             = new MsaFileFilter();
+    private final static SequencesFileFilter seqsfilter                            = new SequencesFileFilter();
+    private final static DefaultFilter       defaultfilter                         = new DefaultFilter();
+    private static final long                serialVersionUID                      = -799735726778865234L;
     private final JFileChooser               _values_filechooser;
     private final JFileChooser               _open_filechooser;
     private final JFileChooser               _msa_filechooser;
@@ -217,17 +219,17 @@ public final class MainFrameApplication extends MainFrame {
     private File                             _current_dir;
     private ButtonGroup                      _radio_group_1;
     // Others:
-    double                                   _min_not_collapse               = Constants.MIN_NOT_COLLAPSE_DEFAULT;
+    double                                   _min_not_collapse                     = Constants.MIN_NOT_COLLAPSE_DEFAULT;
     // Phylogeny Inference menu
     private JMenu                            _inference_menu;
     private JMenuItem                        _inference_from_msa_item;
     private JMenuItem                        _inference_from_seqs_item;
     // Phylogeny Inference
-    private PhylogeneticInferenceOptions     _phylogenetic_inference_options = null;
-    private Msa                              _msa                            = null;
-    private File                             _msa_file                       = null;
-    private List<Sequence>                   _seqs                           = null;
-    private File                             _seqs_file                      = null;
+    private PhylogeneticInferenceOptions     _phylogenetic_inference_options       = null;
+    private Msa                              _msa                                  = null;
+    private File                             _msa_file                             = null;
+    private List<Sequence>                   _seqs                                 = null;
+    private File                             _seqs_file                            = null;
     // expression values menu:
     JMenuItem                                _read_values_jmi;
 
@@ -613,7 +615,7 @@ public final class MainFrameApplication extends MainFrame {
         customizeJMenuItem( _root_min_cost_l_item );
         customizeJMenuItem( _load_species_tree_item );
         _analysis_menu.addSeparator();
-        _analysis_menu.add( _lineage_inference = new JMenuItem( "Infer Ancestor Taxonomies" ) );
+        _analysis_menu.add( _lineage_inference = new JMenuItem( INFER_ANCESTOR_TAXONOMIES ) );
         customizeJMenuItem( _lineage_inference );
         _lineage_inference.setToolTipText( "Inference of ancestor taxonomies/lineages" );
         _jmenubar.add( _analysis_menu );
@@ -874,7 +876,7 @@ public final class MainFrameApplication extends MainFrame {
         customizeJMenuItem( _infer_common_sn_names_item );
         _tools_menu.addSeparator();
         _tools_menu
-                .add( _obtain_detailed_taxonomic_information_jmi = new JMenuItem( "Obtain Detailed Taxonomic Information" ) );
+                .add( _obtain_detailed_taxonomic_information_jmi = new JMenuItem( OBTAIN_DETAILED_TAXONOMIC_INFORMATION ) );
         customizeJMenuItem( _obtain_detailed_taxonomic_information_jmi );
         _obtain_detailed_taxonomic_information_jmi
                 .setToolTipText( "To add additional taxonomic information (from UniProt Taxonomy)" );
index 238fc6a..141488a 100644 (file)
@@ -36,8 +36,10 @@ import java.awt.event.ComponentEvent;
 import java.awt.event.ComponentListener;
 import java.awt.image.BufferedImage;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import javax.swing.JPanel;
@@ -66,6 +68,7 @@ public class MainPanel extends JPanel implements ComponentListener {
     private Phylogeny                        _cut_or_copied_tree;
     private Set<Integer>                     _copied_and_pasted_nodes;
     private Hashtable<String, BufferedImage> _image_map;
+    private static Map<String, String>       _lineage_to_rank_map;
 
     MainPanel() {
     }
@@ -409,4 +412,11 @@ public class MainPanel extends JPanel implements ComponentListener {
     synchronized Hashtable<String, BufferedImage> getImageMap() {
         return _image_map;
     }
+
+    public synchronized static Map<String, String> getLineageToRankMap() {
+        if ( _lineage_to_rank_map == null ) {
+            _lineage_to_rank_map = new HashMap<String, String>();
+        }
+        return _lineage_to_rank_map;
+    }
 }
index 684f90c..9d29d9d 100644 (file)
@@ -783,13 +783,43 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
         }
         setWaitCursor();
         Util.removeBranchColors( _phylogeny );
-        Util.colorPhylogenyAccordingToRanks( _phylogeny, rank, this );
-        _control_panel.setColorBranches( true );
-        if ( _control_panel.getColorBranchesCb() != null ) {
-            _control_panel.getColorBranchesCb().setSelected( true );
+        final int colorizations = Util.colorPhylogenyAccordingToRanks( _phylogeny, rank, this );
+        if ( colorizations > 0 ) {
+            _control_panel.setColorBranches( true );
+            if ( _control_panel.getColorBranchesCb() != null ) {
+                _control_panel.getColorBranchesCb().setSelected( true );
+            }
+            if ( _control_panel.getColorAccSpeciesCb() != null ) {
+                _control_panel.getColorAccSpeciesCb().setSelected( false );
+            }
+            _options.setColorLabelsSameAsParentBranch( true );
+            _control_panel.repaint();
         }
         setArrowCursor();
         repaint();
+        if ( colorizations > 0 ) {
+            String msg = "Taxonomy colorization via " + rank + " completed:\n";
+            if ( colorizations > 1 ) {
+                msg += "colorized " + colorizations + " subtrees";
+            }
+            else {
+                msg += "colorized one subtree";
+            }
+            JOptionPane.showMessageDialog( this,
+                                           msg,
+                                           "Taxonomy Colorization Completed (" + rank + ")",
+                                           JOptionPane.INFORMATION_MESSAGE );
+        }
+        else {
+            String msg = "Could not taxonomy colorize any subtree via " + rank + ".\n";
+            msg += "Possible solutions (given that suitable taxonomic information is present):\n";
+            msg += "select a different rank (e.g. phylum, genus, ...)\n";
+            msg += "  and/or\n";
+            msg += "execute:\n";
+            msg += "1. \"" + MainFrameApplication.OBTAIN_DETAILED_TAXONOMIC_INFORMATION + "\" (Tools)\n";
+            msg += "2. \"" + MainFrameApplication.INFER_ANCESTOR_TAXONOMIES + "\" (Analysis)";
+            JOptionPane.showMessageDialog( this, msg, "Taxonomy Colorization Failed", JOptionPane.WARNING_MESSAGE );
+        }
     }
 
     final private void copySubtree( final PhylogenyNode node ) {
index 59eb617..f9b7064 100644 (file)
@@ -61,6 +61,7 @@ import javax.swing.text.MaskFormatter;
 
 import org.forester.analysis.AncestralTaxonomyInference;
 import org.forester.io.parsers.PhylogenyParser;
+import org.forester.io.parsers.phyloxml.PhyloXmlUtil;
 import org.forester.io.parsers.tol.TolParser;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyMethods;
@@ -284,20 +285,15 @@ public final class Util {
                 if ( n.getBranchData().isHasConfidences() ) {
                     final double conf = PhylogenyMethods.getConfidenceValue( n );
                     final BranchColor c = new BranchColor( ForesterUtil.calcColor( conf, 0.0, max_conf, bg, br ) );
-                    n.getBranchData().setBranchColor( c );
-                    final List<PhylogenyNode> descs = PhylogenyMethods.getAllDescendants( n );
-                    for( final PhylogenyNode desc : descs ) {
-                        desc.getBranchData().setBranchColor( c );
-                    }
+                    colorizeSubtree( n, c );
                 }
             }
         }
     }
 
-    final static void colorPhylogenyAccordingToRanks( final Phylogeny tree,
-                                                      final String rank,
-                                                      final TreePanel tree_panel ) {
+    final static int colorPhylogenyAccordingToRanks( final Phylogeny tree, final String rank, final TreePanel tree_panel ) {
         final Map<String, Color> true_lineage_to_color_map = new HashMap<String, Color>();
+        int colorizations = 0;
         for( final PhylogenyNodeIterator it = tree.iteratorPostorder(); it.hasNext(); ) {
             final PhylogenyNode n = it.next();
             if ( n.getNodeData().isHasTaxonomy()
@@ -308,11 +304,8 @@ public final class Util {
                         && n.getNodeData().getTaxonomy().getRank().equalsIgnoreCase( rank ) ) {
                     final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( n.getNodeData()
                             .getTaxonomy() ) );
-                    n.getBranchData().setBranchColor( c );
-                    final List<PhylogenyNode> descs = PhylogenyMethods.getAllDescendants( n );
-                    for( final PhylogenyNode desc : descs ) {
-                        desc.getBranchData().setBranchColor( c );
-                    }
+                    colorizeSubtree( n, c );
+                    ++colorizations;
                     if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) ) {
                         true_lineage_to_color_map.put( n.getNodeData().getTaxonomy().getScientificName(), c.getValue() );
                     }
@@ -327,44 +320,59 @@ public final class Util {
                 if ( !true_lineage_to_color_map.isEmpty() ) {
                     for( final String lin : node.getNodeData().getTaxonomy().getLineage() ) {
                         if ( true_lineage_to_color_map.containsKey( lin ) ) {
-                            final BranchColor c = new BranchColor( true_lineage_to_color_map.get( lin ) );
-                            node.getBranchData().setBranchColor( c );
-                            final List<PhylogenyNode> descs = PhylogenyMethods.getAllDescendants( node );
-                            for( final PhylogenyNode desc : descs ) {
-                                desc.getBranchData().setBranchColor( c );
-                            }
+                            colorizeSubtree( node, new BranchColor( true_lineage_to_color_map.get( lin ) ) );
+                            ++colorizations;
                             success = true;
                             break;
                         }
                     }
                 }
-                //TODO refactor refactor refactor refactor refactor refactor 
                 if ( !success ) {
+                    final Map<String, String> lineage_to_rank_map = MainPanel.getLineageToRankMap();
                     for( final String lin : node.getNodeData().getTaxonomy().getLineage() ) {
                         final Taxonomy temp_tax = new Taxonomy();
                         temp_tax.setScientificName( lin );
-                        UniProtTaxonomy up = null;
-                        try {
-                            up = AncestralTaxonomyInference.obtainUniProtTaxonomy( temp_tax, null, null );
-                        }
-                        catch ( final Exception e ) {
-                            e.printStackTrace();
-                        }
-                        if ( ( up != null ) && !ForesterUtil.isEmpty( up.getRank() )
-                                && up.getRank().equalsIgnoreCase( rank ) ) {
+                        if ( lineage_to_rank_map.containsKey( lin )
+                                && !ForesterUtil.isEmpty( lineage_to_rank_map.get( lin ) )
+                                && lineage_to_rank_map.get( lin ).equalsIgnoreCase( rank ) ) {
                             final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( temp_tax ) );
-                            node.getBranchData().setBranchColor( c );
-                            final List<PhylogenyNode> descs = PhylogenyMethods.getAllDescendants( node );
-                            for( final PhylogenyNode desc : descs ) {
-                                desc.getBranchData().setBranchColor( c );
-                            }
+                            colorizeSubtree( node, c );
+                            ++colorizations;
                             true_lineage_to_color_map.put( lin, c.getValue() );
                             break;
                         }
+                        else {
+                            UniProtTaxonomy up = null;
+                            try {
+                                up = AncestralTaxonomyInference.obtainUniProtTaxonomy( temp_tax, null, null );
+                            }
+                            catch ( final Exception e ) {
+                                e.printStackTrace();
+                            }
+                            if ( ( up != null ) && !ForesterUtil.isEmpty( up.getRank() ) ) {
+                                lineage_to_rank_map.put( lin, up.getRank() );
+                                if ( up.getRank().equalsIgnoreCase( rank ) ) {
+                                    final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( temp_tax ) );
+                                    colorizeSubtree( node, c );
+                                    ++colorizations;
+                                    true_lineage_to_color_map.put( lin, c.getValue() );
+                                    break;
+                                }
+                            }
+                        }
                     }
                 }
             }
         }
+        return colorizations;
+    }
+
+    private static void colorizeSubtree( final PhylogenyNode node, final BranchColor c ) {
+        node.getBranchData().setBranchColor( c );
+        final List<PhylogenyNode> descs = PhylogenyMethods.getAllDescendants( node );
+        for( final PhylogenyNode desc : descs ) {
+            desc.getBranchData().setBranchColor( c );
+        }
     }
 
     final static String[] getAllRanks( final Phylogeny tree ) {
@@ -378,6 +386,17 @@ public final class Util {
         return ForesterUtil.stringSetToArray( ranks );
     }
 
+    public static String[] getAllPossibleRanks() {
+        final String[] str_array = new String[ PhyloXmlUtil.TAXONOMY_RANKS_LIST.size() - 2 ];
+        int i = 0;
+        for( final String e : PhyloXmlUtil.TAXONOMY_RANKS_LIST ) {
+            if ( !e.equals( PhyloXmlUtil.UNKNOWN ) && !e.equals( PhyloXmlUtil.OTHER ) ) {
+                str_array[ i++ ] = e;
+            }
+        }
+        return str_array;
+    }
+
     final static void colorPhylogenyAccordingToExternalTaxonomy( final Phylogeny tree, final TreePanel tree_panel ) {
         for( final PhylogenyNodeIterator it = tree.iteratorPreorder(); it.hasNext(); ) {
             it.next().getBranchData().setBranchColor( null );
index ec20b4d..9cd9bd9 100644 (file)
 
 package org.forester.io.parsers.phyloxml;
 
+import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 import java.util.regex.Pattern;
 
 public final class PhyloXmlUtil {
 
-    public final static Pattern     SEQUENCE_SYMBOL_PATTERN                    = Pattern.compile( "\\S{1,20}" );
-    public final static Pattern     TAXOMONY_CODE_PATTERN                      = Pattern.compile( "[a-zA-Z0-9_]{1,10}" );
-    public final static Pattern     LIT_REF_DOI_PATTERN                        = Pattern
-                                                                                       .compile( "[a-zA-Z0-9_\\.]+\\S+" );
-    public final static Set<String> SEQUENCE_TYPES                             = new HashSet<String>();
-    public final static Set<String> TAXONOMY_RANKS                             = new HashSet<String>();
-    public static final int         ROUNDING_DIGITS_FOR_PHYLOXML_DOUBLE_OUTPUT = 9;
-    public static final String      VECTOR_PROPERTY_REF                        = "vector:index=";
-    public static final String      VECTOR_PROPERTY_TYPE                       = "xsd:decimal";
-    public static final String      UNIPROT_TAX_PROVIDER                       = "uniprot";
+    public static final String       OTHER                                      = "other";
+    public static final String       UNKNOWN                                    = "unknown";
+    public final static Pattern      SEQUENCE_SYMBOL_PATTERN                    = Pattern.compile( "\\S{1,20}" );
+    public final static Pattern      TAXOMONY_CODE_PATTERN                      = Pattern
+                                                                                        .compile( "[a-zA-Z0-9_]{1,10}" );
+    public final static Pattern      LIT_REF_DOI_PATTERN                        = Pattern
+                                                                                        .compile( "[a-zA-Z0-9_\\.]+\\S+" );
+    public final static Set<String>  SEQUENCE_TYPES                             = new HashSet<String>();
+    public final static List<String> TAXONOMY_RANKS_LIST                        = new ArrayList<String>();
+    public final static Set<String>  TAXONOMY_RANKS_SET                         = new HashSet<String>();
+    public static final int          ROUNDING_DIGITS_FOR_PHYLOXML_DOUBLE_OUTPUT = 9;
+    public static final String       VECTOR_PROPERTY_REF                        = "vector:index=";
+    public static final String       VECTOR_PROPERTY_TYPE                       = "xsd:decimal";
+    public static final String       UNIPROT_TAX_PROVIDER                       = "uniprot";
     static {
         SEQUENCE_TYPES.add( "rna" );
         SEQUENCE_TYPES.add( "protein" );
         SEQUENCE_TYPES.add( "dna" );
-        TAXONOMY_RANKS.add( "domain" );
-        TAXONOMY_RANKS.add( "superkingdom" );
-        TAXONOMY_RANKS.add( "kingdom" );
-        TAXONOMY_RANKS.add( "subkingdom" );
-        TAXONOMY_RANKS.add( "branch" );
-        TAXONOMY_RANKS.add( "infrakingdom" );
-        TAXONOMY_RANKS.add( "superphylum" );
-        TAXONOMY_RANKS.add( "phylum" );
-        TAXONOMY_RANKS.add( "subphylum" );
-        TAXONOMY_RANKS.add( "infraphylum" );
-        TAXONOMY_RANKS.add( "microphylum" );
-        TAXONOMY_RANKS.add( "superdivision" );
-        TAXONOMY_RANKS.add( "division" );
-        TAXONOMY_RANKS.add( "subdivision" );
-        TAXONOMY_RANKS.add( "infradivision" );
-        TAXONOMY_RANKS.add( "superclass" );
-        TAXONOMY_RANKS.add( "class" );
-        TAXONOMY_RANKS.add( "subclass" );
-        TAXONOMY_RANKS.add( "infraclass" );
-        TAXONOMY_RANKS.add( "superlegion" );
-        TAXONOMY_RANKS.add( "legion" );
-        TAXONOMY_RANKS.add( "sublegion" );
-        TAXONOMY_RANKS.add( "infralegion" );
-        TAXONOMY_RANKS.add( "supercohort" );
-        TAXONOMY_RANKS.add( "cohort" );
-        TAXONOMY_RANKS.add( "subcohort" );
-        TAXONOMY_RANKS.add( "infracohort" );
-        TAXONOMY_RANKS.add( "superorder" );
-        TAXONOMY_RANKS.add( "order" );
-        TAXONOMY_RANKS.add( "suborder" );
-        TAXONOMY_RANKS.add( "superfamily" );
-        TAXONOMY_RANKS.add( "family" );
-        TAXONOMY_RANKS.add( "subfamily" );
-        TAXONOMY_RANKS.add( "supertribe" );
-        TAXONOMY_RANKS.add( "tribe" );
-        TAXONOMY_RANKS.add( "subtribe" );
-        TAXONOMY_RANKS.add( "infratribe" );
-        TAXONOMY_RANKS.add( "genus" );
-        TAXONOMY_RANKS.add( "subgenus" );
-        TAXONOMY_RANKS.add( "superspecies" );
-        TAXONOMY_RANKS.add( "species" );
-        TAXONOMY_RANKS.add( "subspecies" );
-        TAXONOMY_RANKS.add( "variety" );
-        TAXONOMY_RANKS.add( "subvariety" );
-        TAXONOMY_RANKS.add( "form" );
-        TAXONOMY_RANKS.add( "subform" );
-        TAXONOMY_RANKS.add( "cultivar" );
-        TAXONOMY_RANKS.add( "strain" );
-        TAXONOMY_RANKS.add( "unknown" );
-        TAXONOMY_RANKS.add( "other" );
+        TAXONOMY_RANKS_LIST.add( "domain" );
+        TAXONOMY_RANKS_LIST.add( "superkingdom" );
+        TAXONOMY_RANKS_LIST.add( "kingdom" );
+        TAXONOMY_RANKS_LIST.add( "subkingdom" );
+        TAXONOMY_RANKS_LIST.add( "branch" );
+        TAXONOMY_RANKS_LIST.add( "infrakingdom" );
+        TAXONOMY_RANKS_LIST.add( "superphylum" );
+        TAXONOMY_RANKS_LIST.add( "phylum" );
+        TAXONOMY_RANKS_LIST.add( "subphylum" );
+        TAXONOMY_RANKS_LIST.add( "infraphylum" );
+        TAXONOMY_RANKS_LIST.add( "microphylum" );
+        TAXONOMY_RANKS_LIST.add( "superdivision" );
+        TAXONOMY_RANKS_LIST.add( "division" );
+        TAXONOMY_RANKS_LIST.add( "subdivision" );
+        TAXONOMY_RANKS_LIST.add( "infradivision" );
+        TAXONOMY_RANKS_LIST.add( "superclass" );
+        TAXONOMY_RANKS_LIST.add( "class" );
+        TAXONOMY_RANKS_LIST.add( "subclass" );
+        TAXONOMY_RANKS_LIST.add( "infraclass" );
+        TAXONOMY_RANKS_LIST.add( "superlegion" );
+        TAXONOMY_RANKS_LIST.add( "legion" );
+        TAXONOMY_RANKS_LIST.add( "sublegion" );
+        TAXONOMY_RANKS_LIST.add( "infralegion" );
+        TAXONOMY_RANKS_LIST.add( "supercohort" );
+        TAXONOMY_RANKS_LIST.add( "cohort" );
+        TAXONOMY_RANKS_LIST.add( "subcohort" );
+        TAXONOMY_RANKS_LIST.add( "infracohort" );
+        TAXONOMY_RANKS_LIST.add( "superorder" );
+        TAXONOMY_RANKS_LIST.add( "order" );
+        TAXONOMY_RANKS_LIST.add( "suborder" );
+        TAXONOMY_RANKS_LIST.add( "superfamily" );
+        TAXONOMY_RANKS_LIST.add( "family" );
+        TAXONOMY_RANKS_LIST.add( "subfamily" );
+        TAXONOMY_RANKS_LIST.add( "supertribe" );
+        TAXONOMY_RANKS_LIST.add( "tribe" );
+        TAXONOMY_RANKS_LIST.add( "subtribe" );
+        TAXONOMY_RANKS_LIST.add( "infratribe" );
+        TAXONOMY_RANKS_LIST.add( "genus" );
+        TAXONOMY_RANKS_LIST.add( "subgenus" );
+        TAXONOMY_RANKS_LIST.add( "superspecies" );
+        TAXONOMY_RANKS_LIST.add( "species" );
+        TAXONOMY_RANKS_LIST.add( "subspecies" );
+        TAXONOMY_RANKS_LIST.add( "variety" );
+        TAXONOMY_RANKS_LIST.add( "subvariety" );
+        TAXONOMY_RANKS_LIST.add( "form" );
+        TAXONOMY_RANKS_LIST.add( "subform" );
+        TAXONOMY_RANKS_LIST.add( "cultivar" );
+        TAXONOMY_RANKS_LIST.add( "strain" );
+        TAXONOMY_RANKS_LIST.add( UNKNOWN );
+        TAXONOMY_RANKS_LIST.add( OTHER );
+        // same thing as set:
+        TAXONOMY_RANKS_SET.add( "domain" );
+        TAXONOMY_RANKS_SET.add( "superkingdom" );
+        TAXONOMY_RANKS_SET.add( "kingdom" );
+        TAXONOMY_RANKS_SET.add( "subkingdom" );
+        TAXONOMY_RANKS_SET.add( "branch" );
+        TAXONOMY_RANKS_SET.add( "infrakingdom" );
+        TAXONOMY_RANKS_SET.add( "superphylum" );
+        TAXONOMY_RANKS_SET.add( "phylum" );
+        TAXONOMY_RANKS_SET.add( "subphylum" );
+        TAXONOMY_RANKS_SET.add( "infraphylum" );
+        TAXONOMY_RANKS_SET.add( "microphylum" );
+        TAXONOMY_RANKS_SET.add( "superdivision" );
+        TAXONOMY_RANKS_SET.add( "division" );
+        TAXONOMY_RANKS_SET.add( "subdivision" );
+        TAXONOMY_RANKS_SET.add( "infradivision" );
+        TAXONOMY_RANKS_SET.add( "superclass" );
+        TAXONOMY_RANKS_SET.add( "class" );
+        TAXONOMY_RANKS_SET.add( "subclass" );
+        TAXONOMY_RANKS_SET.add( "infraclass" );
+        TAXONOMY_RANKS_SET.add( "superlegion" );
+        TAXONOMY_RANKS_SET.add( "legion" );
+        TAXONOMY_RANKS_SET.add( "sublegion" );
+        TAXONOMY_RANKS_SET.add( "infralegion" );
+        TAXONOMY_RANKS_SET.add( "supercohort" );
+        TAXONOMY_RANKS_SET.add( "cohort" );
+        TAXONOMY_RANKS_SET.add( "subcohort" );
+        TAXONOMY_RANKS_SET.add( "infracohort" );
+        TAXONOMY_RANKS_SET.add( "superorder" );
+        TAXONOMY_RANKS_SET.add( "order" );
+        TAXONOMY_RANKS_SET.add( "suborder" );
+        TAXONOMY_RANKS_SET.add( "superfamily" );
+        TAXONOMY_RANKS_SET.add( "family" );
+        TAXONOMY_RANKS_SET.add( "subfamily" );
+        TAXONOMY_RANKS_SET.add( "supertribe" );
+        TAXONOMY_RANKS_SET.add( "tribe" );
+        TAXONOMY_RANKS_SET.add( "subtribe" );
+        TAXONOMY_RANKS_SET.add( "infratribe" );
+        TAXONOMY_RANKS_SET.add( "genus" );
+        TAXONOMY_RANKS_SET.add( "subgenus" );
+        TAXONOMY_RANKS_SET.add( "superspecies" );
+        TAXONOMY_RANKS_SET.add( "species" );
+        TAXONOMY_RANKS_SET.add( "subspecies" );
+        TAXONOMY_RANKS_SET.add( "variety" );
+        TAXONOMY_RANKS_SET.add( "subvariety" );
+        TAXONOMY_RANKS_SET.add( "form" );
+        TAXONOMY_RANKS_SET.add( "subform" );
+        TAXONOMY_RANKS_SET.add( "cultivar" );
+        TAXONOMY_RANKS_SET.add( "strain" );
+        TAXONOMY_RANKS_SET.add( UNKNOWN );
+        TAXONOMY_RANKS_SET.add( OTHER );
     };
 }
index 40115c9..d403a8e 100644 (file)
@@ -289,7 +289,7 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable<Taxonom
     }
 
     public void setRank( final String rank ) {
-        if ( !ForesterUtil.isEmpty( rank ) && !PhyloXmlUtil.TAXONOMY_RANKS.contains( rank ) ) {
+        if ( !ForesterUtil.isEmpty( rank ) && !PhyloXmlUtil.TAXONOMY_RANKS_SET.contains( rank ) ) {
             throw new PhyloXmlDataFormatException( "illegal rank: [" + rank + "]" );
         }
         _rank = rank;