From: cmzmasek@gmail.com Date: Wed, 25 Sep 2013 02:23:01 +0000 (+0000) Subject: inprogress X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=78eb49e5b7c8d46b0c3a750400c9455e125d57ed;p=jalview.git inprogress --- diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index 3ad3935..32dd030 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -76,11 +76,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.List; -import java.util.Map.Entry; import java.util.Set; -import java.util.SortedMap; import java.util.SortedSet; -import java.util.TreeMap; import javax.swing.BorderFactory; import javax.swing.JApplet; @@ -2404,10 +2401,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee _color_chooser.setPreviewPanel( new JPanel() ); SubtreeColorizationActionListener al; if ( ( getFoundNodes() != null ) && !getFoundNodes().isEmpty() ) { - final List additional_nodes = new ArrayList(); - for( final Long id : getFoundNodes() ) { - additional_nodes.add( _phylogeny.getNode( id ) ); - } + final List additional_nodes = getFoundNodesAsListOfPhylogenyNodes(); al = new SubtreeColorizationActionListener( _color_chooser, node, additional_nodes ); } else { @@ -2418,6 +2412,14 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee dialog.setVisible( true ); } + private List getFoundNodesAsListOfPhylogenyNodes() { + final List additional_nodes = new ArrayList(); + for( final Long id : getFoundNodes() ) { + additional_nodes.add( _phylogeny.getNode( id ) ); + } + return additional_nodes; + } + final private void copySubtree( final PhylogenyNode node ) { if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED ) { errorMessageNoCutCopyPasteInUnrootedDisplay(); @@ -5070,7 +5072,15 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee private void showExtDescNodeData( final PhylogenyNode node ) { final List data = new ArrayList(); - for( final PhylogenyNode n : node.getAllExternalDescendants() ) { + final List nodes = node.getAllExternalDescendants(); + if ( ( getFoundNodes() != null ) && !getFoundNodes().isEmpty() ) { + for( final PhylogenyNode n : getFoundNodesAsListOfPhylogenyNodes() ) { + if ( !nodes.contains( n ) ) { + nodes.add( n ); + } + } + } + for( final PhylogenyNode n : nodes ) { switch ( getOptions().getExtDescNodeDataToReturn() ) { case NODE_NAME: if ( !ForesterUtil.isEmpty( n.getName() ) ) { @@ -5131,9 +5141,12 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee ann.append( "|" ); } } - String ann_str = ann.toString().trim(); - if ( ann_str.endsWith( "|" ) ) { - ann_str = ann_str.substring( 0, ann_str.length() - 1 ); + String ann_str; + if ( ann.charAt( ann.length() - 1 ) == '|' ) { + ann_str = ann.substring( 0, ann.length() - 1 ); + } + else { + ann_str = ann.toString(); } sb.append( SequenceWriter.toFasta( ann_str, n.getNodeData().getSequence() .getMolecularSequence(), 60 ) ); @@ -5173,7 +5186,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } // for loop final StringBuilder sb = new StringBuilder(); - final int size = makeSB( data, getOptions(), sb ); + final int size = TreePanelUtil.makeSB( 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 ) { @@ -5194,15 +5207,26 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } else { setCurrentExternalNodesDataBuffer( sb ); - final String title = ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data" - : obtainTitleForExtDescNodeData() ) - + " for " - + data.size() - + "/" - + node.getNumberOfExternalNodes() - + " external descendats of node " - + node - + ", unique entries: " + size; + String title; + if ( ( getFoundNodes() != null ) && !getFoundNodes().isEmpty() ) { + title = ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data" + : obtainTitleForExtDescNodeData() ) + + " for " + + data.size() + + " nodes, unique entries: " + + size; + } + else { + title = ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data" + : obtainTitleForExtDescNodeData() ) + + " for " + + data.size() + + "/" + + node.getNumberOfExternalNodes() + + " external descendats of node " + + node + + ", unique entries: " + size; + } final String s = sb.toString().trim(); if ( getMainPanel().getMainFrame() == null ) { // Must be "E" applet version. @@ -5216,46 +5240,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } - private int makeSB( final List data, final Options optz, final StringBuilder sb ) { - final SortedMap map = new TreeMap(); - if ( ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ ) - && ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ_FASTA ) ) { - for( final String d : data ) { - if ( !ForesterUtil.isEmpty( d ) ) { - if ( map.containsKey( d ) ) { - map.put( d, map.get( d ) + 1 ); - } - else { - map.put( d, 1 ); - } - } - } - } - int size = 0; - if ( ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ ) - && ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ_FASTA ) ) { - for( final Entry e : map.entrySet() ) { - final String v = e.getKey(); - final Object c = e.getValue(); - sb.append( v ); - sb.append( "\t" ); - sb.append( c ); - sb.append( ForesterUtil.LINE_SEPARATOR ); - } - size = map.size(); - } - else { - for( final String d : data ) { - if ( !ForesterUtil.isEmpty( d ) ) { - sb.append( d ); - sb.append( ForesterUtil.LINE_SEPARATOR ); - } - } - size = data.size(); - } - return size; - } - final private void showNodeDataPopup( final MouseEvent e, final PhylogenyNode node ) { try { if ( ( node.getName().length() > 0 ) diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java b/forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java index 082efa9..322199e 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java @@ -24,6 +24,7 @@ import org.forester.phylogeny.PhylogenyMethods; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.data.Annotation; import org.forester.phylogeny.data.BranchColor; +import org.forester.phylogeny.data.NodeData.NODE_DATA; import org.forester.phylogeny.data.Sequence; import org.forester.phylogeny.data.Taxonomy; import org.forester.phylogeny.iterators.PhylogenyNodeIterator; @@ -35,6 +36,46 @@ import org.forester.ws.seqdb.UniProtTaxonomy; public class TreePanelUtil { + static int makeSB( final List data, final Options optz, final StringBuilder sb ) { + final SortedMap map = new TreeMap(); + if ( ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ ) + && ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ_FASTA ) ) { + for( final String d : data ) { + if ( !ForesterUtil.isEmpty( d ) ) { + if ( map.containsKey( d ) ) { + map.put( d, map.get( d ) + 1 ); + } + else { + map.put( d, 1 ); + } + } + } + } + int size = 0; + if ( ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ ) + && ( optz.getExtDescNodeDataToReturn() != NODE_DATA.SEQUENCE_MOL_SEQ_FASTA ) ) { + for( final Entry e : map.entrySet() ) { + final String v = e.getKey(); + final Object c = e.getValue(); + sb.append( v ); + sb.append( "\t" ); + sb.append( c ); + sb.append( ForesterUtil.LINE_SEPARATOR ); + } + size = map.size(); + } + else { + for( final String d : data ) { + if ( !ForesterUtil.isEmpty( d ) ) { + sb.append( d ); + sb.append( ForesterUtil.LINE_SEPARATOR ); + } + } + size = data.size(); + } + return size; + } + public final static String createUriForSeqWeb( final PhylogenyNode node, final Configuration conf, final TreePanel tp ) {