refactored
[jalview.git] / forester / java / src / org / forester / archaeopteryx / MainFrameApplication.java
index a6e2569..eea852c 100644 (file)
@@ -6,7 +6,7 @@
 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
 // Copyright (C) 2003-2007 Ethalinda K.S. Cannon
 // All rights reserved
-// 
+//
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
@@ -16,7 +16,7 @@
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 // Lesser General Public License for more details.
-// 
+//
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
@@ -62,6 +62,13 @@ import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
 import org.forester.archaeopteryx.Util.GraphicsExportType;
+import org.forester.archaeopteryx.tools.AncestralTaxonomyInferrer;
+import org.forester.archaeopteryx.tools.GoAnnotation;
+import org.forester.archaeopteryx.tools.PhyloInferenceDialog;
+import org.forester.archaeopteryx.tools.PhylogeneticInferenceOptions;
+import org.forester.archaeopteryx.tools.PhylogeneticInferrer;
+import org.forester.archaeopteryx.tools.TaxonomyDataObtainer;
+import org.forester.archaeopteryx.tools.UniProtSequenceObtainer;
 import org.forester.archaeopteryx.webservices.PhylogeniesWebserviceClient;
 import org.forester.archaeopteryx.webservices.WebservicesManager;
 import org.forester.io.parsers.FastaParser;
@@ -94,9 +101,9 @@ import org.forester.util.BasicTable;
 import org.forester.util.BasicTableParser;
 import org.forester.util.DescriptiveStatistics;
 import org.forester.util.ForesterUtil;
-import org.forester.util.WindowsUtils;
 import org.forester.util.ForesterUtil.PhylogenyNodeField;
 import org.forester.util.ForesterUtil.TAXONOMY_EXTRACTION;
+import org.forester.util.WindowsUtils;
 
 class DefaultFilter extends FileFilter {
 
@@ -235,6 +242,7 @@ public final class MainFrameApplication extends MainFrame {
             else {
                 UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
             }
+            //UIManager.setLookAndFeel( "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" );
         }
         catch ( final UnsupportedLookAndFeelException e ) {
             Util.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
@@ -470,6 +478,9 @@ public final class MainFrameApplication extends MainFrame {
                 }
                 obtainDetailedTaxonomicInformation();
             }
+            else if ( o == _obtain_uniprot_seq_information_jmi ) {
+                obtainUniProtSequenceInformation();
+            }
             else if ( o == _read_values_jmi ) {
                 if ( isSubtreeDisplayed() ) {
                     return;
@@ -828,6 +839,10 @@ public final class MainFrameApplication extends MainFrame {
         customizeJMenuItem( _obtain_detailed_taxonomic_information_jmi );
         _obtain_detailed_taxonomic_information_jmi
                 .setToolTipText( "To add additional taxonomic information (from UniProt Taxonomy)" );
+        _tools_menu
+                .add( _obtain_uniprot_seq_information_jmi = new JMenuItem( "Obtain Sequence Information (from UniProt)" ) );
+        customizeJMenuItem( _obtain_uniprot_seq_information_jmi );
+        _obtain_uniprot_seq_information_jmi.setToolTipText( "To add additional sequence information (from UniProt)" );
         _tools_menu.addSeparator();
         if ( !Constants.__RELEASE ) {
             _tools_menu.add( _function_analysis = new JMenuItem( "Add UniProtKB Annotations" ) );
@@ -1098,8 +1113,9 @@ public final class MainFrameApplication extends MainFrame {
         if ( ( _mainpanel.getCurrentPhylogeny() == null ) || ( _mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
             return;
         }
-        final MainPanelEdit a = new MainPanelEdit( this, _mainpanel.getCurrentTreePanel(), _mainpanel
-                .getCurrentPhylogeny() );
+        final GoAnnotation a = new GoAnnotation( this,
+                                                 _mainpanel.getCurrentTreePanel(),
+                                                 _mainpanel.getCurrentPhylogeny() );
         new Thread( a ).start();
     }
 
@@ -1115,8 +1131,9 @@ public final class MainFrameApplication extends MainFrame {
             return;
         }
         final Phylogeny phy = _mainpanel.getCurrentPhylogeny().copy();
-        final AncestralTaxonomyInferrer inferrer = new AncestralTaxonomyInferrer( this, _mainpanel
-                .getCurrentTreePanel(), phy );
+        final AncestralTaxonomyInferrer inferrer = new AncestralTaxonomyInferrer( this,
+                                                                                  _mainpanel.getCurrentTreePanel(),
+                                                                                  phy );
         new Thread( inferrer ).start();
     }
 
@@ -1130,8 +1147,7 @@ public final class MainFrameApplication extends MainFrame {
                 if ( getMsa() != null ) {
                     final PhylogeneticInferrer inferrer = new PhylogeneticInferrer( getMsa(),
                                                                                     getPhylogeneticInferenceOptions()
-                                                                                            .copy(),
-                                                                                    this );
+                                                                                            .copy(), this );
                     new Thread( inferrer ).start();
                 }
                 else {
@@ -1145,8 +1161,7 @@ public final class MainFrameApplication extends MainFrame {
                 if ( getSeqs() != null ) {
                     final PhylogeneticInferrer inferrer = new PhylogeneticInferrer( getSeqs(),
                                                                                     getPhylogeneticInferenceOptions()
-                                                                                            .copy(),
-                                                                                    this );
+                                                                                            .copy(), this );
                     new Thread( inferrer ).start();
                 }
                 else {
@@ -1281,7 +1296,7 @@ public final class MainFrameApplication extends MainFrame {
     }
 
     @Override
-    MainPanel getMainPanel() {
+    public MainPanel getMainPanel() {
         return _mainpanel;
     }
 
@@ -1374,13 +1389,26 @@ public final class MainFrameApplication extends MainFrame {
         if ( getCurrentTreePanel() != null ) {
             final Phylogeny phy = getCurrentTreePanel().getPhylogeny();
             if ( ( phy != null ) && !phy.isEmpty() ) {
-                final TaxonomyDataObtainer t = new TaxonomyDataObtainer( this, _mainpanel.getCurrentTreePanel(), phy
-                        .copy() );
+                final TaxonomyDataObtainer t = new TaxonomyDataObtainer( this,
+                                                                         _mainpanel.getCurrentTreePanel(),
+                                                                         phy.copy() );
                 new Thread( t ).start();
             }
         }
     }
 
+    private void obtainUniProtSequenceInformation() {
+        if ( getCurrentTreePanel() != null ) {
+            final Phylogeny phy = getCurrentTreePanel().getPhylogeny();
+            if ( ( phy != null ) && !phy.isEmpty() ) {
+                final UniProtSequenceObtainer u = new UniProtSequenceObtainer( this,
+                                                                               _mainpanel.getCurrentTreePanel(),
+                                                                               phy.copy() );
+                new Thread( u ).start();
+            }
+        }
+    }
+
     private void print() {
         if ( ( getCurrentTreePanel() == null ) || ( getCurrentTreePanel().getPhylogeny() == null )
                 || getCurrentTreePanel().getPhylogeny().isEmpty() ) {
@@ -1710,7 +1738,7 @@ public final class MainFrameApplication extends MainFrame {
         System.gc();
     }
 
-    void readSeqsFromFile() {
+    public void readSeqsFromFile() {
         // Set an initial directory if none set yet
         final File my_dir = getCurrentDir();
         _seqs_filechooser.setMultiSelectionEnabled( false );
@@ -1817,7 +1845,7 @@ public final class MainFrameApplication extends MainFrame {
         }
     }
 
-    void readMsaFromFile() {
+    public void readMsaFromFile() {
         // Set an initial directory if none set yet
         final File my_dir = getCurrentDir();
         _msa_filechooser.setMultiSelectionEnabled( false );
@@ -1991,8 +2019,11 @@ public final class MainFrameApplication extends MainFrame {
                         ForesterUtil.transferInternalNodeNamesToConfidence( phy );
                     }
                 }
-                Util.addPhylogeniesToTabs( phys, new File( url.getFile() ).getName(), new File( url.getFile() )
-                        .toString(), getConfiguration(), getMainPanel() );
+                Util.addPhylogeniesToTabs( phys,
+                                           new File( url.getFile() ).getName(),
+                                           new File( url.getFile() ).toString(),
+                                           getConfiguration(),
+                                           getMainPanel() );
                 _mainpanel.getControlPanel().showWhole();
             }
         }
@@ -2343,6 +2374,7 @@ public final class MainFrameApplication extends MainFrame {
                 }
             }
             if ( !exception ) {
+                getMainPanel().setTitleOfSelectedTab( file.getName() );
                 getMainPanel().getCurrentTreePanel().setTreeFile( file );
                 getMainPanel().getCurrentTreePanel().setEdited( false );
             }
@@ -2476,7 +2508,7 @@ public final class MainFrameApplication extends MainFrame {
         return _phylogenetic_inference_options;
     }
 
-    Msa getMsa() {
+    public Msa getMsa() {
         return _msa;
     }
 
@@ -2488,11 +2520,11 @@ public final class MainFrameApplication extends MainFrame {
         _msa_file = msa_file;
     }
 
-    File getMsaFile() {
+    public File getMsaFile() {
         return _msa_file;
     }
 
-    List<Sequence> getSeqs() {
+    public List<Sequence> getSeqs() {
         return _seqs;
     }
 
@@ -2504,7 +2536,7 @@ public final class MainFrameApplication extends MainFrame {
         _seqs_file = seqs_file;
     }
 
-    File getSeqsFile() {
+    public File getSeqsFile() {
         return _seqs_file;
     }
 } // MainFrameApplication.
@@ -2574,8 +2606,7 @@ class TolFilter extends FileFilter {
     public boolean accept( final File f ) {
         final String file_name = f.getName().trim().toLowerCase();
         return ( file_name.endsWith( ".tol" ) || file_name.endsWith( ".tolxml" ) || file_name.endsWith( ".zip" ) || f
-                .isDirectory() )
-                && ( !file_name.endsWith( ".xml.zip" ) );
+                .isDirectory() ) && ( !file_name.endsWith( ".xml.zip" ) );
     }
 
     @Override