From: cmzmasek@gmail.com Date: Mon, 23 Jun 2014 21:25:19 +0000 (+0000) Subject: in progress X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=cf02f1374fd1b3624d62e2809470cdde2319ed52;p=jalview.git in progress --- diff --git a/forester/java/src/org/forester/archaeopteryx/Configuration.java b/forester/java/src/org/forester/archaeopteryx/Configuration.java index 1914d76..5ae230f 100644 --- a/forester/java/src/org/forester/archaeopteryx/Configuration.java +++ b/forester/java/src/org/forester/archaeopteryx/Configuration.java @@ -90,17 +90,18 @@ public final class Configuration { // ------------------ final static String display_options[][] = { { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" }, - { "Seq Annotations", "nodisplay", "no" }, { "Confidence Values", "display", "?" }, + { "Seq Annotations", "display", "no" }, { "Confidence Values", "display", "?" }, { "Node Events", "display", "?" }, { "Colorize by Taxonomy", "display", "no" }, + { "Colorize by Sequence", "display", "no" }, { "Visual Styles/Branch Colors", "display", "no" }, { "Branch Widths", "display", "no" }, - { "Protein Domains", "nodisplay", "no" }, { "Binary Characters", "nodisplay", "no" }, + { "Protein Domains", "display", "no" }, { "Binary Characters", "nodisplay", "no" }, { "Binary Char Counts", "nodisplay", "no" }, { "Seq Name", "display", "yes" }, { "Seq Accession", "display", "no" }, { "Show Internal Data", "display", "yes" }, { "Dyna Hide", "display", "yes" }, { "Taxonomy Scientific", "display", "yes" }, - { "Taxonomy Common", "display", "no" }, { "Colorize by Annotation", "nodisplay", "no" }, + { "Taxonomy Common", "display", "no" }, { "Colorize by Annotation", "display", "no" }, { "Seq Symbol", "display", "yes" }, { "Rollover", "display", "yes" }, { "Relation Confidence", "nodisplay", "no" }, { "Vector Data", "nodisplay", "no" }, - { "Taxonomy Images", "display", "no" }, { "Properties", "nodisplay", "no" }, + { "Taxonomy Images", "display", "no" }, { "Properties", "display", "no" }, { "Gene Name", "display", "yes" } }; final static int display_as_phylogram = 0; final static int show_node_names = 1; @@ -109,37 +110,32 @@ public final class Configuration { final static int write_confidence_values = 4; final static int write_events = 5; final static int color_according_to_species = 6; - final static int use_style = 7; - final static int width_branches = 8; - final static int show_domain_architectures = 9; - final static int show_binary_characters = 10; - final static int show_binary_character_counts = 11; - final static int show_seq_names = 12; - final static int show_sequence_acc = 13; - final static int display_internal_data = 14; - final static int dynamically_hide_data = 15; - final static int show_taxonomy_scientific_names = 16; - final static int show_taxonomy_common_names = 17; - final static int color_according_to_annotation = 18; - final static int show_seq_symbols = 19; - final static int node_data_popup = 20; - final static int show_relation_confidence = 21; - final static int show_vector_data = 22; - final static int show_taxonomy_images = 23; - final static int show_properties = 24; - final static int show_gene_names = 25; + final static int color_according_to_sequence = 7; + final static int use_style = 8; + final static int width_branches = 9; + final static int show_domain_architectures = 10; + final static int show_binary_characters = 11; + final static int show_binary_character_counts = 12; + final static int show_seq_names = 13; + final static int show_sequence_acc = 14; + final static int display_internal_data = 15; + final static int dynamically_hide_data = 16; + final static int show_taxonomy_scientific_names = 17; + final static int show_taxonomy_common_names = 18; + final static int color_according_to_annotation = 19; + final static int show_seq_symbols = 20; + final static int node_data_popup = 21; + final static int show_relation_confidence = 22; + final static int show_vector_data = 23; + final static int show_taxonomy_images = 24; + final static int show_properties = 25; + final static int show_gene_names = 26; static final String VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA = "validate_against_phyloxml_xsd_schema"; - // ---------------- - // Function colors - // ---------------- + private static Hashtable _sequence_colors; + + private static Hashtable _annotation_colors; - // ---------------- - // Domain colors - // ---------------- private static Hashtable _domain_colors; - // ---------------- - // Species colors - // ---------------- private static Hashtable _species_colors; private static String DEFAULT_FONT_FAMILY = ""; private static final int DEPRECATED = -2; @@ -567,15 +563,7 @@ public final class Configuration { public void setShowScale( final boolean show_scale ) { _show_scale = show_scale; } - - public void setTaxonomyColorize( final boolean b ) { - display_options[ color_according_to_species ][ 2 ] = b ? "yes" : "no"; - } - - public void setUseBranchesWidths( final boolean b ) { - display_options[ width_branches ][ 2 ] = b ? "yes" : "no"; - } - + boolean displaySequenceRelations() { return _display_sequence_relations; } @@ -734,6 +722,13 @@ public final class Configuration { } return _species_colors; } + + Hashtable getSequenceColors() { + if ( _sequence_colors == null ) { + _sequence_colors = new Hashtable(); + } + return _sequence_colors; + } final TAXONOMY_EXTRACTION getTaxonomyExtraction() { return _taxonomy_extraction; @@ -1522,6 +1517,9 @@ public final class Configuration { else if ( key.equals( "color_according_to_species" ) ) { key_index = Configuration.color_according_to_species; } + else if ( key.equals( "color_according_to_sequence" ) ) { + key_index = Configuration.color_according_to_sequence; + } else if ( key.equals( "show_node_names" ) ) { key_index = Configuration.show_node_names; } @@ -1625,6 +1623,10 @@ public final class Configuration { getSpeciesColors().put( ( ( String ) st.nextElement() ).replace( '_', ' ' ), Color.decode( ( String ) st.nextElement() ) ); } + else if ( key.equals( "sequence_color" ) ) { + getSequenceColors().put( ( ( String ) st.nextElement() ).replace( '_', ' ' ), + Color.decode( ( String ) st.nextElement() ) ); + } else if ( key.equals( "domain_color" ) ) { getDomainColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) ); } diff --git a/forester/java/src/org/forester/archaeopteryx/Constants.java b/forester/java/src/org/forester/archaeopteryx/Constants.java index 6172d3e..1f8e21e 100644 --- a/forester/java/src/org/forester/archaeopteryx/Constants.java +++ b/forester/java/src/org/forester/archaeopteryx/Constants.java @@ -42,8 +42,8 @@ public final class Constants { public final static boolean __SYNTH_LF = false; // TODO remove me public final static boolean ALLOW_DDBJ_BLAST = false; public final static String PRG_NAME = "Archaeopteryx"; - final static String VERSION = "0.9891 beta"; - final static String PRG_DATE = "140605"; + final static String VERSION = "0.9892 beta"; + final static String PRG_DATE = "140623"; final static String DEFAULT_CONFIGURATION_FILE_NAME = "_aptx_configuration_file"; final static String[] DEFAULT_FONT_CHOICES = { "Arial", "Helvetica", "Verdana", "Tahoma", "Dialog", "Lucida Sans", "SansSerif", "Sans-serif", "Sans" }; diff --git a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java index a398560..509e24d 100644 --- a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java @@ -91,6 +91,7 @@ final class ControlPanel extends JPanel implements ActionListener { private List _click_to_names; private int _collapse_cb_item; private JCheckBox _color_acc_species; + private JCheckBox _color_acc_sequence; private JCheckBox _color_according_to_annotation; private boolean _color_branches; private JCheckBox _use_visual_styles_cb; @@ -156,6 +157,7 @@ final class ControlPanel extends JPanel implements ActionListener { private JButton _show_whole; private int _sort_descendents_item; private Map _species_colors; + private Map _sequence_colors; private int _subtree_cb_item; private int _swap_cb_item; private JButton _uncollapse_all; @@ -189,6 +191,19 @@ final class ControlPanel extends JPanel implements ActionListener { @Override public void actionPerformed( final ActionEvent e ) { try { + if ( e.getSource() == _color_acc_sequence ) { + if ( _color_acc_species != null ) { + _color_acc_species.setSelected( false ); + } + } + else if ( e.getSource() == _color_acc_species ) { + if ( _color_acc_sequence != null ) { + _color_acc_sequence.setSelected( false ); + } + + } + + final TreePanel tp = getMainPanel().getCurrentTreePanel(); if ( tp == null ) { return; @@ -291,6 +306,10 @@ final class ControlPanel extends JPanel implements ActionListener { search1(); displayedPhylogenyMightHaveChanged( true ); } + + + + else { displayedPhylogenyMightHaveChanged( true ); } @@ -310,6 +329,10 @@ final class ControlPanel extends JPanel implements ActionListener { public JCheckBox getColorAccSpeciesCb() { return _color_acc_species; } + + public JCheckBox getColorAccSequenceCb() { + return _color_acc_sequence; + } public JCheckBox getUseVisualStylesCb() { return _use_visual_styles_cb; @@ -532,10 +555,17 @@ final class ControlPanel extends JPanel implements ActionListener { case Configuration.color_according_to_species: _color_acc_species = new JCheckBox( title ); _color_acc_species - .setToolTipText( "To colorize taxonomy and sequence labels as a function of taxonomy" ); + .setToolTipText( "To colorize node labels as a function of taxonomy" ); addJCheckBox( _color_acc_species, ch_panel ); add( ch_panel ); break; + case Configuration.color_according_to_sequence: + _color_acc_sequence = new JCheckBox( title ); + _color_acc_sequence + .setToolTipText( "To colorize node labels as a function of sequence name" ); + addJCheckBox( _color_acc_sequence, ch_panel ); + add( ch_panel ); + break; case Configuration.color_according_to_annotation: _color_according_to_annotation = new JCheckBox( title ); _color_according_to_annotation @@ -790,6 +820,10 @@ final class ControlPanel extends JPanel implements ActionListener { Map getSpeciesColors() { return _species_colors; } + + Map getSequenceColors() { + return _sequence_colors; + } boolean isAntialiasScreenText() { return true; @@ -802,6 +836,10 @@ final class ControlPanel extends JPanel implements ActionListener { boolean isColorAccordingToTaxonomy() { return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() ); } + + boolean isColorAccordingToSequence() { + return ( ( _color_acc_sequence != null ) && _color_acc_sequence.isSelected() ); + } boolean isUseVisualStyles() { return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) || ( ( getUseVisualStylesCb() == null ) && _color_branches ) ); @@ -978,6 +1016,11 @@ final class ControlPanel extends JPanel implements ActionListener { _color_acc_species.setSelected( state ); } break; + case Configuration.color_according_to_sequence: + if ( _color_acc_sequence != null ) { + _color_acc_sequence.setSelected( state ); + } + break; case Configuration.color_according_to_annotation: if ( _color_according_to_annotation != null ) { _color_according_to_annotation.setSelected( state ); @@ -1230,6 +1273,10 @@ final class ControlPanel extends JPanel implements ActionListener { void setSpeciesColors( final Map species_colors ) { _species_colors = species_colors; } + + void setSequenceColors( final Map sequence_colors ) { + _sequence_colors = sequence_colors; + } /* GUILHEM_END */ /* @@ -1422,6 +1469,9 @@ final class ControlPanel extends JPanel implements ActionListener { if ( _color_acc_species != null ) { _color_acc_species.setSelected( false ); } + if ( _color_acc_sequence != null ) { + _color_acc_sequence.setSelected( false ); + } _mainpanel.getCurrentTreePanel().repaint(); } @@ -1721,6 +1771,7 @@ final class ControlPanel extends JPanel implements ActionListener { private void init() { _draw_phylogram = new ArrayList(); setSpeciesColors( new HashMap() ); + setSequenceColors( new HashMap() ); setAnnotationColors( new HashMap() ); } @@ -2095,6 +2146,18 @@ final class ControlPanel extends JPanel implements ActionListener { setCheckbox( Configuration.display_internal_data, _configuration.doCheckOption( Configuration.display_internal_data ) ); } + + + if ( _configuration.doDisplayOption( Configuration.color_according_to_sequence ) ) { + addCheckbox( Configuration.color_according_to_sequence, + _configuration.getDisplayTitle( Configuration.color_according_to_sequence ) ); + setCheckbox( Configuration.color_according_to_sequence, + _configuration.doCheckOption( Configuration.color_according_to_sequence ) ); + } + + + + if ( _configuration.doDisplayOption( Configuration.color_according_to_species ) ) { addCheckbox( Configuration.color_according_to_species, _configuration.getDisplayTitle( Configuration.color_according_to_species ) ); diff --git a/forester/java/src/org/forester/archaeopteryx/MainPanel.java b/forester/java/src/org/forester/archaeopteryx/MainPanel.java index 24fc5f7..6551f1b 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/MainPanel.java @@ -409,6 +409,7 @@ public class MainPanel extends JPanel implements ComponentListener { void setupTreeGraphic( final Configuration config_settings, final ControlPanel control ) { control.setSpeciesColors( config_settings.getSpeciesColors() ); + control.setSequenceColors( config_settings.getSequenceColors() ); control.setAnnotationColors( config_settings.getAnnotationColors() ); RenderableDomainArchitecture.setColorMap( config_settings.getDomainColors() ); } diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index b8905f2..019eaea 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -715,6 +715,20 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee return c; } } + + final Color calculateSequenceBasedColor( final Sequence seq ) { + if ( ForesterUtil.isEmpty( seq.getName() ) ) { + return getTreeColorSet().getSequenceColor(); + } + Color c = null; + final String seq_name = seq.getName(); + c = getControlPanel().getSequenceColors().get( seq_name ); + if ( c == null ) { + c = TreePanelUtil.calculateColorFromString( seq_name, false ); + getControlPanel().getSequenceColors().put( seq_name, c ); + } + return c; + } void checkForVectorProperties( final Phylogeny phy ) { final DescriptiveStatistics stats = new BasicDescriptiveStatistics(); @@ -841,6 +855,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee if ( _control_panel.getColorAccSpeciesCb() != null ) { _control_panel.getColorAccSpeciesCb().setSelected( false ); } + _options.setColorLabelsSameAsParentBranch( true ); _control_panel.repaint(); } @@ -986,12 +1001,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee return _statistics_for_vector_data; } - /** - * Find a color for this species name. - * - * @param species - * @return the species color - */ + final Color getTaxonomyBasedColor( final PhylogenyNode node ) { if ( node.getNodeData().isHasTaxonomy() ) { return calculateTaxonomyBasedColor( node.getNodeData().getTaxonomy() ); @@ -999,6 +1009,16 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee // return non-colorized color return getTreeColorSet().getTaxonomyColor(); } + + + final Color getSequenceBasedColor( final PhylogenyNode node ) { + if ( node.getNodeData().isHasSequence() ) { + return calculateSequenceBasedColor( node.getNodeData().getSequence() ); + } + // return non-colorized color + return getTreeColorSet().getSequenceColor(); + } + /** * @return pointer to colorset for tree drawing @@ -3924,6 +3944,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else if ( is_in_found_nodes ) { c = getColorForFoundNode( node ); } + else if ( getControlPanel().isColorAccordingToSequence() ) { + c = getSequenceBasedColor( node ); + } else if ( getControlPanel().isColorAccordingToTaxonomy() ) { c = getTaxonomyBasedColor( node ); } @@ -5161,6 +5184,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee && ( node.getNodeData().getNodeVisualData().getFontColor() != null ) ) { g.setColor( node.getNodeData().getNodeVisualData().getFontColor() ); } + else if ( getControlPanel().isColorAccordingToSequence() ) { + g.setColor( getSequenceBasedColor( node ) ); + } else if ( getControlPanel().isColorAccordingToTaxonomy() ) { g.setColor( getTaxonomyBasedColor( node ) ); } @@ -5689,9 +5715,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else if ( isInFoundNodes0( node ) && isInFoundNodes1( node ) ) { _rollover_popup.setForeground( getTreeColorSet().getFoundColor0and1() ); } - else if ( getControlPanel().isColorAccordingToTaxonomy() ) { - _rollover_popup.setForeground( getTaxonomyBasedColor( node ) ); - } else { _rollover_popup.setForeground( getTreeColorSet().getSequenceColor() ); }