X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FTreePanelUtil.java;h=eb9a3b1201d8d3bcbbfc5ef874e27c99559fba81;hb=558788e2eb321d781f6cd9d4ceee91ed5c98661b;hp=5b5537ca7bbbdfc4444d1eb2f631fe1b9a071dbb;hpb=256204975bca8c5e5c00a9728caff30c52bd65cc;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java b/forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java index 5b5537c..eb9a3b1 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java @@ -6,6 +6,7 @@ import java.awt.Component; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -25,7 +26,7 @@ import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.data.Accession; 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.NodeDataField; import org.forester.phylogeny.data.Sequence; import org.forester.phylogeny.data.Taxonomy; import org.forester.phylogeny.iterators.PhylogenyNodeIterator; @@ -33,6 +34,7 @@ import org.forester.phylogeny.iterators.PreorderTreeIterator; import org.forester.util.ForesterConstants; import org.forester.util.ForesterUtil; import org.forester.util.SequenceAccessionTools; +import org.forester.util.StringInt; import org.forester.ws.seqdb.UniProtTaxonomy; public class TreePanelUtil { @@ -120,7 +122,7 @@ public class TreePanelUtil { * all external nodes of node. * If at least one the external nodes has no taxonomy, * null is returned. - * + * */ public static Set obtainDistinctTaxonomies( final PhylogenyNode node ) { final List descs = node.getAllExternalDescendants(); @@ -176,12 +178,12 @@ public class TreePanelUtil { TreePanelUtil .showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getTaxonomy().getCommonName(), sb ); } - if ( ( cp.isShowSeqNames() || cp.isShowSeqSymbols() || cp.isShowSequenceAcc() ) - && node.getNodeData().isHasSequence() - && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) { - TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence() - .getMolecularSequence(), sb ); - } +// if ( ( cp.isShowSeqNames() || cp.isShowSeqSymbols() || cp.isShowSequenceAcc() ) +// && node.getNodeData().isHasSequence() +// && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) { +// TreePanelUtil.showExtDescNodeDataUserSelectedHelperHelper( node.getNodeData().getSequence() +// .getMolecularSequence(), sb ); +// } final String s = sb.toString().trim(); if ( !ForesterUtil.isEmpty( s ) ) { data.add( s ); @@ -199,44 +201,6 @@ public class TreePanelUtil { JOptionPane.showMessageDialog( parent, msg, title, JOptionPane.INFORMATION_MESSAGE ); } - final static Color calculateColorFromString( final String str, final boolean is_taxonomy ) { - final String my_str = str.toUpperCase(); - char first = my_str.charAt( 0 ); - char second = ' '; - char third = ' '; - if ( my_str.length() > 1 ) { - if ( is_taxonomy ) { - second = my_str.charAt( 1 ); - } - else { - second = my_str.charAt( my_str.length() - 1 ); - } - if ( is_taxonomy ) { - if ( my_str.length() > 2 ) { - if ( my_str.indexOf( " " ) > 0 ) { - third = my_str.charAt( my_str.indexOf( " " ) + 1 ); - } - else { - third = my_str.charAt( 2 ); - } - } - } - else if ( my_str.length() > 2 ) { - third = my_str.charAt( ( my_str.length() - 1 ) / 2 ); - } - } - first = TreePanelUtil.normalizeCharForRGB( first ); - second = TreePanelUtil.normalizeCharForRGB( second ); - third = TreePanelUtil.normalizeCharForRGB( third ); - if ( ( first > 235 ) && ( second > 235 ) && ( third > 235 ) ) { - first = 0; - } - else if ( ( first < 60 ) && ( second < 60 ) && ( third < 60 ) ) { - second = 255; - } - return new Color( first, second, third ); - } - final static void collapseSpeciesSpecificSubtrees( final Phylogeny phy ) { boolean inferred = false; for( final PhylogenyNodeIterator it = phy.iteratorPreorder(); it.hasNext(); ) { @@ -334,7 +298,7 @@ public class TreePanelUtil { if ( n.getNodeData().isHasTaxonomy() && ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getScientificName() ) || !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getCommonName() ) || !ForesterUtil - .isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) ) { + .isEmpty( n.getNodeData().getTaxonomy().getTaxonomyCode() ) ) ) { if ( !ForesterUtil.isEmpty( n.getNodeData().getTaxonomy().getRank() ) && n.getNodeData().getTaxonomy().getRank().equalsIgnoreCase( rank ) ) { final BranchColor c = new BranchColor( tree_panel.calculateTaxonomyBasedColor( n.getNodeData() @@ -435,7 +399,7 @@ public class TreePanelUtil { if ( sb.charAt( sb.length() - 1 ) == ' ' ) { sb.deleteCharAt( sb.length() - 1 ); } - if ( i < ans.size() - 1 ) { + if ( i < ( ans.size() - 1 ) ) { sb.append( ", " ); } } @@ -475,10 +439,11 @@ public class TreePanelUtil { .getSynonyms().isEmpty() ); } - static int makeSB( final List data, final Options optz, final StringBuilder sb ) { + static final int nodeDataIntoStringBuffer( 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 ) ) { + int size = 0; + if ( ( optz.getExtDescNodeDataToReturn() != NodeDataField.SEQUENCE_MOL_SEQ_FASTA ) + && ( optz.getExtDescNodeDataToReturn() != NodeDataField.GO_TERM_IDS ) ) { for( final String d : data ) { if ( !ForesterUtil.isEmpty( d ) ) { if ( map.containsKey( d ) ) { @@ -489,17 +454,30 @@ public class TreePanelUtil { } } } - } - 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 ); + if ( ( optz.getExtDescNodeDataToReturn() == NodeDataField.DOMAINS_ALL ) + || ( optz.getExtDescNodeDataToReturn() == NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN ) + || ( optz.getExtDescNodeDataToReturn() == NodeDataField.SEQ_ANNOTATIONS ) ) { + final ArrayList sis = new ArrayList(); + for( final Entry e : map.entrySet() ) { + sis.add( new StringInt( e.getKey(), e.getValue() ) ); + } + Collections.sort( sis, new StringInt.DescendingIntComparator() ); + for( final StringInt si : sis ) { + sb.append( si.getString() ); + sb.append( "\t" ); + sb.append( si.getInt() ); + sb.append( ForesterUtil.LINE_SEPARATOR ); + } + } + else { + 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(); } @@ -515,14 +493,6 @@ public class TreePanelUtil { return size; } - final static char normalizeCharForRGB( char c ) { - c -= 65; - c *= 10.2; - c = c > 255 ? 255 : c; - c = c < 0 ? 0 : c; - return c; - } - final static String pdbAccToString( final List accs, final int i ) { if ( ForesterUtil.isEmpty( accs.get( i ).getComment() ) ) { return accs.get( i ).getValue();