final static int swap = 4;
final static int color_subtree = 5;
final static int open_seq_web = 6;
- final static int open_tax_web = 7;
- final static int blast = 8;
- final static int cut_subtree = 9;
- final static int copy_subtree = 10;
- final static int paste_subtree = 11;
- final static int delete_subtree_or_node = 12;
- final static int add_new_node = 13;
- final static int edit_node_data = 14;
- final static int sort_descendents = 15;
- final static int get_ext_desc_data = 16;
- final static int select_nodes = 17;
+ final static int open_pdb_web = 7;
+ final static int open_tax_web = 8;
+ final static int blast = 9;
+ final static int cut_subtree = 10;
+ final static int copy_subtree = 11;
+ final static int paste_subtree = 12;
+ final static int delete_subtree_or_node = 13;
+ final static int add_new_node = 14;
+ final static int edit_node_data = 15;
+ final static int sort_descendents = 16;
+ final static int get_ext_desc_data = 17;
+ final static int select_nodes = 18;
// ---------------------------
// Display options for trees
// ---------------------------
final static String clickto_options[][] = {
{ "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
{ "Sub/Super Tree", "display" }, { "Swap Descendants", "display" },
- { "Colorize Subtree/Node(s)", "display" }, { "Open Sequence DB", "display" },
+ { "Colorize Subtree/Node(s)", "display" }, { "Open Sequence DB", "display" }, { "Open PDB", "display" },
{ "Open Taxonomy DB", "display" }, { "Blast", "display" }, { "Cut Subtree", "display" },
{ "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" },
{ "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Sort Descendants", "display" },
else if ( name.equals( "open_seq_web" ) ) {
index = Configuration.open_seq_web;
}
+ else if ( name.equals( "open_pdb_web" ) ) {
+ index = Configuration.open_pdb_web;
+ }
else if ( name.equals( "open_tax_web" ) ) {
index = Configuration.open_tax_web;
}
private int _edit_node_data_item;
private int _select_nodes_item;
private int _get_ext_desc_data;
+ private int _open_pdb_item;
private int _blast_item;
// zooming and quick tree manipulation buttons:
private JButton _zoom_in_x;
else if ( action == _get_ext_desc_data ) {
setActionWhenNodeClicked( NodeClickAction.GET_EXT_DESC_DATA );
}
+ else if ( action == _open_pdb_item ) {
+ setActionWhenNodeClicked( NodeClickAction.OPEN_PDB_WEB );
+ }
else {
throw new RuntimeException( "unknown action: " + action );
}
}
cb_index++;
}
+ if ( _configuration.doDisplayClickToOption( Configuration.open_pdb_web ) ) {
+ _open_pdb_item = cb_index;
+ addClickToOption( Configuration.open_pdb_web, _configuration.getClickToTitle( Configuration.open_pdb_web ) );
+ if ( default_option == Configuration.open_pdb_web ) {
+ selected_index = cb_index;
+ }
+ cb_index++;
+ }
if ( _configuration.doDisplayClickToOption( Configuration.open_tax_web ) ) {
_open_tax_web_item = cb_index;
addClickToOption( Configuration.open_tax_web, _configuration.getClickToTitle( Configuration.open_tax_web ) );
SELECT_NODES,
SORT_DESCENDENTS,
GET_EXT_DESC_DATA,
- BLAST;
+ BLAST,
+ OPEN_PDB_WEB;
}
}
case OPEN_TAX_WEB:
openTaxWeb( node );
break;
+ case OPEN_PDB_WEB:
+ openPdbWeb( node );
+ break;
case CUT_SUBTREE:
cutSubtree( node );
break;
return null;
}
+ final private List<Accession> getPdbAccs( final PhylogenyNode node ) {
+ final List<Accession> pdb_ids = new ArrayList<Accession>();
+ if ( node.getNodeData().isHasSequence() ) {
+ final Sequence seq = node.getNodeData().getSequence();
+ if ( !ForesterUtil.isEmpty( seq.getCrossReferences() ) ) {
+ final SortedSet<Accession> cross_refs = seq.getCrossReferences();
+ for( final Accession acc : cross_refs ) {
+ if ( acc.getSource().equalsIgnoreCase( "pdb" ) ) {
+ pdb_ids.add( acc );
+ }
+ }
+ }
+ }
+ return pdb_ids;
+ }
+
final private boolean isCanOpenTaxWeb( final PhylogenyNode node ) {
if ( node.getNodeData().isHasTaxonomy()
&& ( ( !ForesterUtil.isEmpty( node.getNodeData().getTaxonomy().getScientificName() ) )
_node_popup_menu_items[ i ].setEnabled( false );
}
}
+ else if ( title.equals( Configuration.clickto_options[ Configuration.open_pdb_web ][ 0 ] ) ) {
+ final List<Accession> accs = getPdbAccs( node );
+ _node_popup_menu_items[ i ] = new JMenuItem( title );
+ if ( !ForesterUtil.isEmpty( accs ) ) {
+ if ( accs.size() == 1 ) {
+ _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " ["
+ + TreePanelUtil.pdbAccToString( accs, 0 ) + "]" );
+ _node_popup_menu_items[ i ].setEnabled( true );
+ }
+ else if ( accs.size() == 2 ) {
+ _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " ["
+ + TreePanelUtil.pdbAccToString( accs, 0 ) + ", "
+ + TreePanelUtil.pdbAccToString( accs, 1 ) + "]" );
+ _node_popup_menu_items[ i ].setEnabled( true );
+ }
+ else if ( accs.size() == 3 ) {
+ _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " ["
+ + TreePanelUtil.pdbAccToString( accs, 0 ) + ", "
+ + TreePanelUtil.pdbAccToString( accs, 1 ) + ", "
+ + TreePanelUtil.pdbAccToString( accs, 2 ) + "]" );
+ _node_popup_menu_items[ i ].setEnabled( true );
+ }
+ else {
+ _node_popup_menu_items[ i ].setText( _node_popup_menu_items[ i ].getText() + " ["
+ + TreePanelUtil.pdbAccToString( accs, 0 ) + ", "
+ + TreePanelUtil.pdbAccToString( accs, 1 ) + ", "
+ + TreePanelUtil.pdbAccToString( accs, 2 ) + ", + " + ( accs.size() - 3 ) + " more]" );
+ _node_popup_menu_items[ i ].setEnabled( true );
+ }
+ }
+ else {
+ _node_popup_menu_items[ i ].setEnabled( false );
+ }
+ //
+ }
else if ( title.equals( Configuration.clickto_options[ Configuration.open_tax_web ][ 0 ] ) ) {
_node_popup_menu_items[ i ].setEnabled( isCanOpenTaxWeb( node ) );
}
}
}
+ final private void openPdbWeb( final PhylogenyNode node ) {
+ final List<Accession> pdb_ids = getPdbAccs( node );
+ if ( ForesterUtil.isEmpty( pdb_ids ) ) {
+ cannotOpenBrowserWarningMessage( "PDB" );
+ return;
+ }
+ final List<String> uri_strs = TreePanelUtil.createUrisForPdbWeb( node, pdb_ids, getConfiguration(), this );
+ if ( !ForesterUtil.isEmpty( uri_strs ) ) {
+ for( final String uri_str : uri_strs ) {
+ try {
+ AptxUtil.launchWebBrowser( new URI( uri_str ),
+ isApplet(),
+ isApplet() ? obtainApplet() : null,
+ "_aptx_seq" );
+ }
+ catch ( final IOException e ) {
+ AptxUtil.showErrorMessage( this, e.toString() );
+ e.printStackTrace();
+ }
+ catch ( final URISyntaxException e ) {
+ AptxUtil.showErrorMessage( this, e.toString() );
+ e.printStackTrace();
+ }
+ }
+ }
+ else {
+ cannotOpenBrowserWarningMessage( "PDB" );
+ }
+ }
+
final private void openTaxWeb( final PhylogenyNode node ) {
if ( !isCanOpenTaxWeb( node ) ) {
cannotOpenBrowserWarningMessage( "taxonomic" );
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;
public class TreePanelUtil {
- static int makeSB( final List<String> data, final Options optz, final StringBuilder sb ) {
- final SortedMap<String, Integer> map = new TreeMap<String, Integer>();
- 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<String, Integer> 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 ) {
return uri_str;
}
+ public static List<String> createUrisForPdbWeb( final PhylogenyNode node,
+ final List<Accession> pdb_accs,
+ final Configuration configuration,
+ final TreePanel treePanel ) {
+ final List<String> uris = new ArrayList<String>();
+ 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.
.getSynonyms().isEmpty() );
}
+ static int makeSB( final List<String> data, final Options optz, final StringBuilder sb ) {
+ final SortedMap<String, Integer> map = new TreeMap<String, Integer>();
+ 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<String, Integer> 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;
return c;
}
+ final static String pdbAccToString( final List<Accession> 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 );
public static final String NCBI_NUCCORE = "http://www.ncbi.nlm.nih.gov/nuccore/";
public final static String UNIPROT_KB = "http://www.uniprot.org/uniprot/";
public static final String NCBI_GI = "http://www.ncbi.nlm.nih.gov/protein/gi:";
+ public static final String PDB = "http://www.pdb.org/pdb/explore/explore.do?pdbId=";
static {
final DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setDecimalSeparator( '.' );