X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FMainFrame.java;h=ec2e600888139d4c60330fdb578930e497390a65;hb=04275071ecc44e04eaf6006397eae0b86514cc75;hp=ae4f8b452ec5ed21a25d692ccbff8d05fee6a39f;hpb=ebabb46561f996b5fcd59bd202defd7b189ea5b6;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrame.java b/forester/java/src/org/forester/archaeopteryx/MainFrame.java index ae4f8b4..ec2e600 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrame.java @@ -20,7 +20,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // // Contact: phylosoft @ gmail . com -// WWW: www.phylosoft.org/forester +// WWW: https://sites.google.com/site/cmzmasek/home/software/forester package org.forester.archaeopteryx; @@ -58,9 +58,10 @@ import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE; import org.forester.archaeopteryx.tools.InferenceManager; import org.forester.archaeopteryx.tools.ProcessPool; import org.forester.archaeopteryx.tools.ProcessRunning; +import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyNode; -import org.forester.phylogeny.PhylogenyNodeI.NH_CONVERSION_SUPPORT_VALUE_STYLE; +import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE; import org.forester.phylogeny.data.Annotation; import org.forester.phylogeny.data.NodeVisualization.NodeFill; import org.forester.phylogeny.data.NodeVisualization.NodeShape; @@ -100,7 +101,8 @@ public abstract class MainFrame extends JFrame implements ActionListener { static final String SCREEN_ANTIALIAS_LABEL = "Antialias"; static final String COLOR_LABELS_LABEL = "Colorize Labels Same as Parent Branch"; static final String BG_GRAD_LABEL = "Background Color Gradient"; - static final String DISPLAY_NODE_BOXES_LABEL = "Show Node Shapes"; + static final String DISPLAY_NODE_BOXES_LABEL_EXT = "Show External Node Shapes"; + static final String DISPLAY_NODE_BOXES_LABEL_INT = "Show Internal Node Shapes"; static final String SHOW_OVERVIEW_LABEL = "Show Overview"; static final String FONT_SIZE_MENU_LABEL = "Font Size"; static final String NONUNIFORM_CLADOGRAMS_LABEL = "External Node Sum Dependent Cladograms"; @@ -135,12 +137,11 @@ public abstract class MainFrame extends JFrame implements ActionListener { JMenuItem _taxcolor_item; JMenuItem _confcolor_item; JMenuItem _color_rank_jmi; - JMenuItem _infer_common_sn_names_item; JMenuItem _collapse_species_specific_subtrees; JMenuItem _collapse_below_threshold; //TODO implememt me JMenuItem _obtain_detailed_taxonomic_information_jmi; JMenuItem _obtain_detailed_taxonomic_information_deleting_jmi; - JMenuItem _obtain_uniprot_seq_information_jmi; + JMenuItem _obtain_seq_information_jmi; JMenuItem _move_node_names_to_tax_sn_jmi; JMenuItem _move_node_names_to_seq_names_jmi; JMenuItem _extract_tax_code_from_node_names_jmi; @@ -170,7 +171,8 @@ public abstract class MainFrame extends JFrame implements ActionListener { JCheckBoxMenuItem _color_labels_same_as_parent_branch; JMenuItem _overview_placment_mi; JMenuItem _choose_minimal_confidence_mi; - JCheckBoxMenuItem _show_default_node_shapes_cbmi; + JCheckBoxMenuItem _show_default_node_shapes_internal_cbmi; + JCheckBoxMenuItem _show_default_node_shapes_external_cbmi; JMenuItem _cycle_node_shape_mi; JMenuItem _cycle_node_fill_mi; JMenuItem _choose_node_size_mi; @@ -186,7 +188,9 @@ public abstract class MainFrame extends JFrame implements ActionListener { JMenuItem _choose_pdf_width_mi; // _ parsing JCheckBoxMenuItem _internal_number_are_confidence_for_nh_parsing_cbmi; - JCheckBoxMenuItem _extract_pfam_style_tax_codes_cbmi; + JRadioButtonMenuItem _extract_taxonomy_no_rbmi; + JRadioButtonMenuItem _extract_taxonomy_yes_rbmi; + JRadioButtonMenuItem _extract_taxonomy_pfam_rbmi; JCheckBoxMenuItem _replace_underscores_cbmi; JCheckBoxMenuItem _use_brackets_for_conf_in_nh_export_cbmi; JCheckBoxMenuItem _use_internal_names_for_conf_in_nh_export_cbmi; @@ -206,7 +210,6 @@ public abstract class MainFrame extends JFrame implements ActionListener { JCheckBoxMenuItem _circular_type_cbmi; // view as text menu: JMenuItem _view_as_NH_item; - JMenuItem _view_as_NHX_item; JMenuItem _view_as_XML_item; JMenuItem _view_as_nexus_item; JMenuItem _display_basic_information_item; @@ -263,14 +266,6 @@ public abstract class MainFrame extends JFrame implements ActionListener { else if ( o == _color_rank_jmi ) { colorRank(); } - else if ( o == _infer_common_sn_names_item ) { - if ( isSubtreeDisplayed() ) { - return; - } - if ( getCurrentTreePanel() != null ) { - getCurrentTreePanel().inferCommonPartOfScientificNames(); - } - } else if ( o == _collapse_species_specific_subtrees ) { if ( isSubtreeDisplayed() ) { return; @@ -303,9 +298,6 @@ public abstract class MainFrame extends JFrame implements ActionListener { else if ( o == _view_as_NH_item ) { viewAsNH(); } - else if ( o == _view_as_NHX_item ) { - viewAsNHX(); - } else if ( o == _view_as_XML_item ) { viewAsXML(); } @@ -376,7 +368,10 @@ public abstract class MainFrame extends JFrame implements ActionListener { else if ( o == _color_labels_same_as_parent_branch ) { updateOptions( getOptions() ); } - else if ( o == _show_default_node_shapes_cbmi ) { + else if ( o == _show_default_node_shapes_internal_cbmi ) { + updateOptions( getOptions() ); + } + else if ( o == _show_default_node_shapes_external_cbmi ) { updateOptions( getOptions() ); } else if ( o == _taxonomy_colorize_node_shapes_cbmi ) { @@ -495,6 +490,26 @@ public abstract class MainFrame extends JFrame implements ActionListener { return _configuration; } + /** + * This method returns the current external node data which + * has been selected by the user by clicking the "Return ..." + * menu item. This method is expected to be called from Javascript or + * something like it. + * + * @return current external node data as String + */ + public String getCurrentExternalNodesDataBuffer() { + return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString(); + } + + public int getCurrentExternalNodesDataBufferChangeCounter() { + return getCurrentTreePanel().getCurrentExternalNodesDataBufferChangeCounter(); + } + + public int getCurrentExternalNodesDataBufferLength() { + return getCurrentTreePanel().getCurrentExternalNodesDataBufferAsString().length(); + } + public InferenceManager getInferenceManager() { return _inference_manager; } @@ -616,11 +631,9 @@ public abstract class MainFrame extends JFrame implements ActionListener { _view_jmenu.addSeparator(); _view_jmenu.add( _view_as_XML_item = new JMenuItem( "View as phyloXML" ) ); _view_jmenu.add( _view_as_NH_item = new JMenuItem( "View as Newick" ) ); - _view_jmenu.add( _view_as_NHX_item = new JMenuItem( "View as NHX" ) ); _view_jmenu.add( _view_as_nexus_item = new JMenuItem( "View as Nexus" ) ); customizeJMenuItem( _display_basic_information_item ); customizeJMenuItem( _view_as_NH_item ); - customizeJMenuItem( _view_as_NHX_item ); customizeJMenuItem( _view_as_XML_item ); customizeJMenuItem( _view_as_nexus_item ); _jmenubar.add( _view_jmenu ); @@ -875,7 +888,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { sb.append( "Website: " + Constants.PHYLOXML_WEB_SITE + "\n" ); sb.append( "Version: " + ForesterConstants.PHYLO_XML_VERSION + "\n" ); sb.append( "\n" ); - sb.append( "For more information: http://www.phylosoft.org/archaeopteryx/\n" ); + sb.append( "For more information: https://sites.google.com/site/cmzmasek/home/software/archaeopteryx\n" ); sb.append( "Email: " + Constants.AUTHOR_EMAIL + "\n\n" ); TextFrame.instantiate( sb.toString(), "Help", _textframes ); } @@ -1053,8 +1066,10 @@ public abstract class MainFrame extends JFrame implements ActionListener { && _abbreviate_scientific_names.isSelected() ); options.setColorLabelsSameAsParentBranch( ( _color_labels_same_as_parent_branch != null ) && _color_labels_same_as_parent_branch.isSelected() ); - options.setShowDefaultNodeShapes( ( _show_default_node_shapes_cbmi != null ) - && _show_default_node_shapes_cbmi.isSelected() ); + options.setShowDefaultNodeShapesInternal( ( _show_default_node_shapes_internal_cbmi != null ) + && _show_default_node_shapes_internal_cbmi.isSelected() ); + options.setShowDefaultNodeShapesExternal( ( _show_default_node_shapes_external_cbmi != null ) + && _show_default_node_shapes_external_cbmi.isSelected() ); options.setTaxonomyColorizeNodeShapes( ( _taxonomy_colorize_node_shapes_cbmi != null ) && _taxonomy_colorize_node_shapes_cbmi.isSelected() ); if ( ( _non_lined_up_cladograms_rbmi != null ) && ( _non_lined_up_cladograms_rbmi.isSelected() ) ) { @@ -1105,8 +1120,15 @@ public abstract class MainFrame extends JFrame implements ActionListener { && _print_black_and_white_cbmi.isSelected() ); options.setInternalNumberAreConfidenceForNhParsing( ( _internal_number_are_confidence_for_nh_parsing_cbmi != null ) && _internal_number_are_confidence_for_nh_parsing_cbmi.isSelected() ); - options.setExtractPfamTaxonomyCodesInNhParsing( ( _extract_pfam_style_tax_codes_cbmi != null ) - && _extract_pfam_style_tax_codes_cbmi.isSelected() ); + if ( ( _extract_taxonomy_yes_rbmi != null ) && _extract_taxonomy_yes_rbmi.isSelected() ) { + options.setTaxonomyExtractio( TAXONOMY_EXTRACTION.YES ); + } + else if ( ( _extract_taxonomy_pfam_rbmi != null ) && _extract_taxonomy_pfam_rbmi.isSelected() ) { + options.setTaxonomyExtractio( TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY ); + } + else if ( ( _extract_taxonomy_no_rbmi != null ) && _extract_taxonomy_no_rbmi.isSelected() ) { + options.setTaxonomyExtractio( TAXONOMY_EXTRACTION.NO ); + } options.setReplaceUnderscoresInNhParsing( ( _replace_underscores_cbmi != null ) && _replace_underscores_cbmi.isSelected() ); options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null ) @@ -1177,16 +1199,6 @@ public abstract class MainFrame extends JFrame implements ActionListener { } } - void viewAsNHX() { - if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) { - String title = "NHX"; - if ( !ForesterUtil.isEmpty( _mainpanel.getCurrentPhylogeny().getName() ) ) { - title = _mainpanel.getCurrentPhylogeny().getName() + " " + title; - } - showTextFrame( _mainpanel.getCurrentPhylogeny().toNewHampshireX(), title ); - } - } - void viewAsXML() { if ( ( _mainpanel.getCurrentPhylogeny() != null ) && !_mainpanel.getCurrentPhylogeny().isEmpty() ) { String title = "phyloXML"; @@ -1210,35 +1222,43 @@ public abstract class MainFrame extends JFrame implements ActionListener { } final Phylogeny phy = getMainPanel().getCurrentPhylogeny(); if ( ( phy != null ) && !phy.isEmpty() ) { - final JTextField xField = new JTextField( 10 ); - final JTextField yField = new JTextField( 20 ); - xField.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? "" + final JTextField ref_field = new JTextField( 10 ); + final JTextField desc_filed = new JTextField( 20 ); + ref_field.setText( ForesterUtil.isEmpty( getPreviousNodeAnnotationReference() ) ? "" : getPreviousNodeAnnotationReference() ); - final JPanel myPanel = new JPanel(); - myPanel.add( new JLabel( "Reference " ) ); - myPanel.add( xField ); - myPanel.add( Box.createHorizontalStrut( 15 ) ); - myPanel.add( new JLabel( "Description " ) ); - myPanel.add( yField ); + final JPanel my_panel = new JPanel(); + my_panel.add( new JLabel( "Reference " ) ); + my_panel.add( ref_field ); + my_panel.add( Box.createHorizontalStrut( 15 ) ); + my_panel.add( new JLabel( "Description " ) ); + my_panel.add( desc_filed ); final int result = JOptionPane.showConfirmDialog( null, - myPanel, + my_panel, "Enter the sequence annotation(s) for the " + nodes.size() + " selected nodes", JOptionPane.OK_CANCEL_OPTION ); if ( result == JOptionPane.OK_OPTION ) { - String ref = xField.getText(); - String desc = yField.getText(); - if ( ref != null ) { + String ref = ref_field.getText(); + String desc = desc_filed.getText(); + if ( !ForesterUtil.isEmpty( ref ) ) { ref = ref.trim(); ref = ref.replaceAll( "\\s+", " " ); + if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.indexOf( ':' ) > ref.length() - 2 ) + || ( ref.length() < 3 ) ) { + JOptionPane.showMessageDialog( this, + "Reference needs to be in the form of \"GO:1234567\"", + "Illegal Format for Annotation Reference", + JOptionPane.ERROR_MESSAGE ); + return; + } + } + if ( ref != null ) { + setPreviousNodeAnnotationReference( ref ); } if ( desc != null ) { desc = desc.trim(); desc = desc.replaceAll( "\\s+", " " ); } - if ( ref != null ) { - setPreviousNodeAnnotationReference( ref ); - } if ( !ForesterUtil.isEmpty( ref ) || !ForesterUtil.isEmpty( desc ) ) { for( final Integer id : nodes ) { final PhylogenyNode n = phy.getNode( id ); @@ -1251,19 +1271,12 @@ public abstract class MainFrame extends JFrame implements ActionListener { n.getNodeData().getSequence().addAnnotation( ann ); } } + getMainPanel().getControlPanel().showAnnotations(); } } } } - private String getPreviousNodeAnnotationReference() { - return _previous_node_annotation_ref; - } - - private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) { - _previous_node_annotation_ref = previous_node_annotation_ref; - } - private void chooseFont() { final FontChooser fc = new FontChooser(); fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() ); @@ -1328,18 +1341,26 @@ public abstract class MainFrame extends JFrame implements ActionListener { repaint(); } + private String getPreviousNodeAnnotationReference() { + return _previous_node_annotation_ref; + } + private void removeBranchColors() { if ( getMainPanel().getCurrentPhylogeny() != null ) { AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() ); } } + private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) { + _previous_node_annotation_ref = previous_node_annotation_ref; + } + /** * Display the about box. */ static void about() { final StringBuffer about = new StringBuffer( "Archaeopteryx\nVersion " + Constants.VERSION + "\n" ); - about.append( "Copyright (C) 2007-2012 Christian M. Zmasek\n" ); + about.append( "Copyright (C) 2013 Christian M. Zmasek\n" ); about.append( "All Rights Reserved\n" ); about.append( "License: GNU Lesser General Public License (LGPL)\n" ); about.append( "Last modified: " + Constants.PRG_DATE + "\n" );