X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FTreePanel.java;h=38afbce942c16853aa662c5156c9cf25005747e5;hb=558788e2eb321d781f6cd9d4ceee91ed5c98661b;hp=c100ec59e921c6e1b74c2221576f10bd834bf9be;hpb=884d428fdefc13f8da7cdfdb2fb48046e589d8fa;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index c100ec5..38afbce 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -77,11 +77,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.SortedMap; import java.util.SortedSet; -import java.util.TreeMap; import javax.swing.BorderFactory; import javax.swing.JApplet; @@ -117,7 +114,7 @@ import org.forester.phylogeny.data.BranchColor; import org.forester.phylogeny.data.Confidence; import org.forester.phylogeny.data.DomainArchitecture; import org.forester.phylogeny.data.Event; -import org.forester.phylogeny.data.NodeData.NODE_DATA; +import org.forester.phylogeny.data.NodeDataField; import org.forester.phylogeny.data.NodeVisualData; import org.forester.phylogeny.data.NodeVisualData.NodeFill; import org.forester.phylogeny.data.NodeVisualData.NodeShape; @@ -179,7 +176,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee private static final BasicStroke STROKE_2 = new BasicStroke( 2f ); private static final double TWO_PI = 2 * Math.PI; private final static int WIGGLE = 2; - private static final String SHOW_ONLY_THIS_CONF_TYPE = "posterior probability"; //TODO remove me + private static final String SHOW_ONLY_THIS_CONF_TYPE = null; //TODO remove me HashMap _nodeid_dist_to_leaf = new HashMap(); final private Arc2D _arc = new Arc2D.Double(); private AffineTransform _at; @@ -944,7 +941,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee repaint(); } - final void decreaseDomainStructureEvalueThreshold() { + final void decreaseDomainStructureEvalueThresholdExp() { if ( _domain_structure_e_value_thr_exp > -20 ) { _domain_structure_e_value_thr_exp -= 1; } @@ -991,7 +988,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee return _current_external_nodes_data_buffer_change_counter; } - final int getDomainStructureEvalueThreshold() { + final int getDomainStructureEvalueThresholdExp() { return _domain_structure_e_value_thr_exp; } @@ -1079,7 +1076,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee return _y_distance; } - final void increaseDomainStructureEvalueThreshold() { + final void increaseDomainStructureEvalueThresholdExp() { if ( _domain_structure_e_value_thr_exp < 3 ) { _domain_structure_e_value_thr_exp += 1; } @@ -3408,7 +3405,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else { _node_popup_menu_items[ i ].setEnabled( false ); } - // + } + else if ( title.startsWith( Configuration.clickto_options[ Configuration.get_ext_desc_data ][ 0 ] ) ) { + _node_popup_menu_items[ i ] + .setText( Configuration.clickto_options[ Configuration.get_ext_desc_data ][ 0 ] + ": " + + getOptions().getExtDescNodeDataToReturn().toString() ); } else if ( title.equals( Configuration.clickto_options[ Configuration.open_tax_web ][ 0 ] ) ) { _node_popup_menu_items[ i ].setEnabled( isCanOpenTaxWeb( node ) ); @@ -3578,33 +3579,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } private final String obtainTitleForExtDescNodeData() { - switch ( getOptions().getExtDescNodeDataToReturn() ) { - case NODE_NAME: - return "Node Names"; - case GENE_NAME: - return "Gene Names"; - case SEQUENCE_NAME: - return "Sequence Names"; - case SEQUENCE_SYMBOL: - return "Sequence Symbols"; - case SEQUENCE_MOL_SEQ: - return "Molecular Sequences"; - case SEQUENCE_MOL_SEQ_FASTA: - return "Molecular Sequences (Fasta)"; - case SEQUENCE_ACC: - return "Sequence Accessors"; - case TAXONOMY_SCIENTIFIC_NAME: - return "Scientific Names"; - case TAXONOMY_CODE: - return "Taxonomy Codes"; - case TAXONOMY_COMM0N_NAME: - return "Taxonomy Common Names"; - case UNKNOWN: - return "User Selected Data"; - default: - throw new IllegalArgumentException( "unknown data element: " - + getOptions().getExtDescNodeDataToReturn() ); - } + return getOptions().getExtDescNodeDataToReturn().toString(); } final private void openPdbWeb( final PhylogenyNode node ) { @@ -4815,6 +4790,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } paintNodeBox( node.getXcoord(), node.getYcoord(), node, g, to_pdf, to_graphics_file ); } + if ( getControlPanel().isShowMolSequences() && ( node.getNodeData().isHasSequence() ) + && ( node.getNodeData().getSequence().isMolecularSequenceAligned() ) + && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) { + paintMolecularSequences( g, node, to_pdf ); + } if ( dynamically_hide && !is_in_found_nodes && ( ( node.isExternal() && ( ( _external_node_index % dynamic_hiding_factor ) != 1 ) ) || ( !node @@ -4917,33 +4897,37 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } } - if ( getControlPanel().isShowMolSequences() && ( node.getNodeData().isHasSequence() ) - && ( node.getNodeData().getSequence().isMolecularSequenceAligned() ) - && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) { - final RenderableMsaSequence rs = RenderableMsaSequence.createInstance( node.getNodeData().getSequence() - .getMolecularSequence(), node.getNodeData().getSequence().getType(), getConfiguration() ); - if ( rs != null ) { - final int default_height = 7; - float y = getYdistance(); - if ( getControlPanel().isDynamicallyHideData() ) { - y = getTreeFontSet().getFontMetricsLarge().getHeight(); - } - final int h = y < default_height ? ForesterUtil.roundToInt( y ) : default_height; - rs.setRenderingHeight( h > 1 ? h : 2 ); - if ( getControlPanel().isDrawPhylogram() ) { - rs.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + _length_of_longest_text ), - node.getYcoord() - ( h / 2.0f ), - g, - this, - to_pdf ); - } - else { - rs.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text, - node.getYcoord() - ( h / 2.0f ), - g, - this, - to_pdf ); - } + + //if ( getControlPanel().isShowMolSequences() && ( node.getNodeData().isHasSequence() ) + // && ( node.getNodeData().getSequence().isMolecularSequenceAligned() ) + // && ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) ) { + // paintMolecularSequences( g, node, to_pdf ); + //} + } + + private void paintMolecularSequences( final Graphics2D g, final PhylogenyNode node, final boolean to_pdf ) { + final RenderableMsaSequence rs = RenderableMsaSequence.createInstance( node.getNodeData().getSequence() + .getMolecularSequence(), node.getNodeData().getSequence().getType(), getConfiguration() ); + if ( rs != null ) { + final int default_height = 8; + float y = getYdistance(); + + final int h = ( y / 2) < default_height ? ForesterUtil.roundToInt( y * 2 ) : default_height; + rs.setRenderingHeight( h > 1 ? h : 1 ); + + if ( getControlPanel().isDrawPhylogram() ) { + rs.render( ( float ) ( ( getMaxDistanceToRoot() * getXcorrectionFactor() ) + _length_of_longest_text ), + node.getYcoord() - ( h / 2.0f ), + g, + this, + to_pdf ); + } + else { + rs.render( getPhylogeny().getFirstExternalNode().getXcoord() + _length_of_longest_text, + node.getYcoord() - ( h / 2.0f ), + g, + this, + to_pdf ); } } } @@ -5495,9 +5479,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee private void showExtDescNodeData( final PhylogenyNode node ) { final List data = new ArrayList(); - final SortedMap string_int_map = new TreeMap(); - - final List nodes = node.getAllExternalDescendants(); if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) { for( final PhylogenyNode n : getFoundNodesAsListOfPhylogenyNodes() ) { @@ -5531,12 +5512,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee data.add( n.getNodeData().getSequence().getSymbol() ); } break; - case SEQUENCE_MOL_SEQ: - if ( n.getNodeData().isHasSequence() - && !ForesterUtil.isEmpty( n.getNodeData().getSequence().getMolecularSequence() ) ) { - data.add( n.getNodeData().getSequence().getMolecularSequence() ); - } - break; case SEQUENCE_MOL_SEQ_FASTA: final StringBuilder sb = new StringBuilder(); if ( n.getNodeData().isHasSequence() @@ -5602,44 +5577,58 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee data.add( n.getNodeData().getTaxonomy().getScientificName() ); } break; - case TAXONOMY_COMM0N_NAME: - if ( n.getNodeData().isHasTaxonomy() - && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getCommonName() ) ) { - data.add( n.getNodeData().getTaxonomy().getCommonName() ); - } - break; case TAXONOMY_CODE: if ( n.getNodeData().isHasTaxonomy() && !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) { data.add( n.getNodeData().getTaxonomy().getTaxonomyCode() ); } break; - case DOMAINS: + case DOMAINS_ALL: + case DOMAINS_COLLAPSED_PER_PROTEIN: if ( n.getNodeData().isHasSequence() - && n.getNodeData().getSequence().getDomainArchitecture() != null ) { + && ( n.getNodeData().getSequence().getDomainArchitecture() != null ) ) { final DomainArchitecture da = n.getNodeData().getSequence().getDomainArchitecture(); + final Set s = new HashSet(); for( int i = 0; i < da.getDomains().size(); ++i ) { final ProteinDomain d = da.getDomain( i ); - if ( d.getConfidence() < 1 ) { - String dn = d.getName(); - if ( !string_int_map.containsKey( dn ) ) { - string_int_map.put( dn, 1 ); - } - else { - string_int_map.put( dn, string_int_map.get( dn ) + 1 ); + if ( d.getConfidence() <= Math.pow( 10, getDomainStructureEvalueThresholdExp() ) ) { + final String name = d.getName(); + if ( !( s.contains( name ) ) ) { + data.add( name ); + if ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN ) { + s.add( name ); + } } - } - } } - break; - case GO_ANNOTATIONS: + break; + case SEQ_ANNOTATIONS: + if ( n.getNodeData().isHasSequence() ) { + if ( n.getNodeData().isHasSequence() + && ( n.getNodeData().getSequence().getAnnotations() != null ) ) { + final SortedSet a = n.getNodeData().getSequence().getAnnotations(); + for( int i = 0; i < a.size(); ++i ) { + data.add( n.getNodeData().getSequence().getAnnotation( i ).toString() ); + } + } + } + break; + case GO_TERM_IDS: if ( n.getNodeData().isHasSequence() ) { - //TODO do something clever + if ( n.getNodeData().isHasSequence() + && ( n.getNodeData().getSequence().getAnnotations() != null ) ) { + final SortedSet a = n.getNodeData().getSequence().getAnnotations(); + for( int i = 0; i < a.size(); ++i ) { + final Annotation ann = n.getNodeData().getSequence().getAnnotation( i ); + final String ref = ann.getRef(); + if ( ref.toUpperCase().startsWith( "GO:" ) ) { + data.add( ref ); + } + } + } } - break; - + break; case UNKNOWN: TreePanelUtil.showExtDescNodeDataUserSelectedHelper( getControlPanel(), n, data ); break; @@ -5648,19 +5637,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee + getOptions().getExtDescNodeDataToReturn() ); } } // for loop - /////////////////////////////////////////////////////// - //TODO remove me - if ( string_int_map != null ) { - for( final Object key : string_int_map.keySet() ) { - System.out.print( key.toString() ); - System.out.print( ": " ); - System.out.print( string_int_map.get( key ).toString() ); - System.out.println(); - } - } - /////////////////////////////////////////////////////// final StringBuilder sb = new StringBuilder(); - final int size = TreePanelUtil.makeSB( data, getOptions(), sb ); + final int size = TreePanelUtil.nodeDataIntoStringBuffer( data, getOptions(), sb ); if ( ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE ) || ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.BUFFER_ONLY ) ) { if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE ) { @@ -5683,7 +5661,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee setCurrentExternalNodesDataBuffer( sb ); String title; if ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() ) { - title = ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data" + title = ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.UNKNOWN ? "Data" : obtainTitleForExtDescNodeData() ) + " for " + data.size() @@ -5691,7 +5669,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee + size; } else { - title = ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data" + title = ( getOptions().getExtDescNodeDataToReturn() == NodeDataField.UNKNOWN ? "Data" : obtainTitleForExtDescNodeData() ) + " for " + data.size()