X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FTreePanelUtil.java;h=5b5537ca7bbbdfc4444d1eb2f631fe1b9a071dbb;hb=83086d32cf5b8c98a5c8d045187e07e4fa9bb752;hp=7c1cbafadc14b35a58b192442eeaab2b98c4a5a4;hpb=f8ecfc1d254f7f413ee5c47fbb012b609f7f4fd1;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java b/forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java index 7c1cbaf..5b5537c 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanelUtil.java @@ -22,6 +22,7 @@ import org.forester.analysis.TaxonomyDataManager; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyMethods; 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; @@ -31,56 +32,16 @@ import org.forester.phylogeny.iterators.PhylogenyNodeIterator; import org.forester.phylogeny.iterators.PreorderTreeIterator; import org.forester.util.ForesterConstants; import org.forester.util.ForesterUtil; -import org.forester.util.SequenceIdParser; +import org.forester.util.SequenceAccessionTools; 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 ) { String uri_str = null; - final String upkb = ForesterUtil.extractUniProtKbProteinSeqIdentifier( node ); + final String upkb = SequenceAccessionTools.obtainUniProtAccessorFromDataFields( node ); if ( !ForesterUtil.isEmpty( upkb ) ) { try { uri_str = ForesterUtil.UNIPROT_KB + URLEncoder.encode( upkb, ForesterConstants.UTF8 ); @@ -91,10 +52,10 @@ public class TreePanelUtil { } } if ( ForesterUtil.isEmpty( uri_str ) ) { - final String v = ForesterUtil.extractGenbankAccessor( node ); + final String v = SequenceAccessionTools.obtainGenbankAccessorFromDataFields( node ); if ( !ForesterUtil.isEmpty( v ) ) { try { - if ( SequenceIdParser.isProtein( v ) ) { + if ( SequenceAccessionTools.isProteinDbQuery( v ) ) { uri_str = ForesterUtil.NCBI_PROTEIN + URLEncoder.encode( v, ForesterConstants.UTF8 ); } else { @@ -108,10 +69,10 @@ public class TreePanelUtil { } } if ( ForesterUtil.isEmpty( uri_str ) ) { - final String v = ForesterUtil.extractRefSeqAccessorAccessor( node ); + final String v = SequenceAccessionTools.obtainRefSeqAccessorFromDataFields( node ); if ( !ForesterUtil.isEmpty( v ) ) { try { - if ( SequenceIdParser.isProtein( v ) ) { + if ( SequenceAccessionTools.isProteinDbQuery( v ) ) { uri_str = ForesterUtil.NCBI_PROTEIN + URLEncoder.encode( v, ForesterConstants.UTF8 ); } else { @@ -125,7 +86,7 @@ public class TreePanelUtil { } } if ( ForesterUtil.isEmpty( uri_str ) ) { - final String v = ForesterUtil.extractGInumber( node ); + final String v = SequenceAccessionTools.obtainGiNumberFromDataFields( node ); if ( !ForesterUtil.isEmpty( v ) ) { try { uri_str = ForesterUtil.NCBI_GI + URLEncoder.encode( v, ForesterConstants.UTF8 ); @@ -139,6 +100,21 @@ public class TreePanelUtil { return uri_str; } + public static List createUrisForPdbWeb( final PhylogenyNode node, + final List pdb_accs, + final Configuration configuration, + final TreePanel treePanel ) { + final List uris = new ArrayList(); + if ( !ForesterUtil.isEmpty( pdb_accs ) ) { + for( final Accession pdb_acc : pdb_accs ) { + if ( !ForesterUtil.isEmpty( pdb_acc.getValue() ) ) { + uris.add( ForesterUtil.PDB + pdb_acc.getValue() ); + } + } + } + return uris; + } + /** * Returns the set of distinct taxonomies of * all external nodes of node. @@ -499,6 +475,46 @@ public class TreePanelUtil { .getSynonyms().isEmpty() ); } + 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; + } + final static char normalizeCharForRGB( char c ) { c -= 65; c *= 10.2; @@ -507,6 +523,13 @@ public class TreePanelUtil { return c; } + final static String pdbAccToString( final List accs, final int i ) { + if ( ForesterUtil.isEmpty( accs.get( i ).getComment() ) ) { + return accs.get( i ).getValue(); + } + return accs.get( i ).getValue() + " (" + accs.get( i ).getComment().toLowerCase() + ")"; + } + final static Phylogeny subTree( final PhylogenyNode new_root, final Phylogeny source_phy ) { final Phylogeny new_phy = new Phylogeny(); new_phy.setRooted( true );