cleanup
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Wed, 28 Mar 2012 03:03:08 +0000 (03:03 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Wed, 28 Mar 2012 03:03:08 +0000 (03:03 +0000)
forester/java/src/org/forester/archaeopteryx/AptxUtil.java
forester/java/src/org/forester/archaeopteryx/Configuration.java
forester/java/src/org/forester/archaeopteryx/Constants.java
forester/java/src/org/forester/archaeopteryx/ControlPanel.java
forester/java/src/org/forester/archaeopteryx/TreePanel.java
forester/java/src/org/forester/archaeopteryx/tools/Blast.java

index ba95034..cb3a2c6 100644 (file)
@@ -679,9 +679,9 @@ public final class AptxUtil {
     }
 
     final public static void launchWebBrowser( final URI uri,
-                                        final boolean is_applet,
-                                        final JApplet applet,
-                                        final String frame_name ) throws IOException {
+                                               final boolean is_applet,
+                                               final JApplet applet,
+                                               final String frame_name ) throws IOException {
         if ( is_applet ) {
             applet.getAppletContext().showDocument( uri.toURL(), frame_name );
         }
index 882e1b8..2b39eee 100644 (file)
@@ -166,9 +166,9 @@ public final class Configuration {
     final static String                     clickto_options[][]                                    = {
             { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
             { "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree", "display" },
-            { "Open Sequence Web", "display" }, { "Open Taxonomy Web", "display" }, { "Blast", "display" }, { "Cut Subtree", "display" },
-            { "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" },
-            { "Add New Node", "display" }, { "Edit Node Data", "display" }, 
+            { "Open Sequence Web", "display" }, { "Open Taxonomy Web", "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" }                                                     };
     // This option is selected in the dropdown
     int                                     default_clickto                                        = Configuration.display_node_data;
index c7f8414..9cf4f40 100644 (file)
@@ -40,7 +40,7 @@ public final class Constants {
     public final static boolean __RELEASE                                                     = false;                                                    // TODO remove me
     public final static boolean __SNAPSHOT_RELEASE                                            = true;                                                     // TODO remove me
     public final static boolean __SYNTH_LF                                                    = false;                                                    // TODO remove me
-    public final static boolean ALLOW_DDBJ_BLAST  = false;
+    public final static boolean ALLOW_DDBJ_BLAST                                              = false;
     public final static String  PRG_NAME                                                      = "Archaeopteryx";
     final static String         VERSION                                                       = "0.969 NM";
     final static String         PRG_DATE                                                      = "2012.03.05";
index ad88f3b..adb02a6 100644 (file)
@@ -1162,9 +1162,7 @@ final class ControlPanel extends JPanel implements ActionListener {
             setActionWhenNodeClicked( NodeClickAction.SORT_DESCENDENTS );
         }
         else if ( action == _blast_item ) {
-           
-                setActionWhenNodeClicked( NodeClickAction.BLAST );
-            
+            setActionWhenNodeClicked( NodeClickAction.BLAST );
         }
         else if ( action == _open_tax_web_item ) {
             setActionWhenNodeClicked( NodeClickAction.OPEN_TAX_WEB );
@@ -1376,7 +1374,6 @@ final class ControlPanel extends JPanel implements ActionListener {
             }
             cb_index++;
         }
-        
         if ( getOptions().isEditable() ) {
             if ( _configuration.doDisplayClickToOption( Configuration.cut_subtree ) ) {
                 _cut_subtree_item = cb_index;
@@ -1431,9 +1428,6 @@ final class ControlPanel extends JPanel implements ActionListener {
                 }
                 cb_index++;
             }
-           
-                
-            
         }
         // Set default selection and its action
         _click_to_combobox.setSelectedIndex( selected_index );
index 36afa04..06d4e2f 100644 (file)
@@ -346,7 +346,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     }
 
     final public void actionPerformed( final ActionEvent e ) {
-        
         boolean done = false;
         final JMenuItem node_popup_menu_item = ( JMenuItem ) e.getSource();
         for( int index = 0; ( index < _node_popup_menu_items.length ) && !done; index++ ) {
@@ -465,34 +464,27 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
             return;
         }
         if ( node.getNodeData().isHasSequence() ) {
-            String query  = Blast.obtainQueryForBlast( node );
+            final String query = Blast.obtainQueryForBlast( node );
             if ( !ForesterUtil.isEmpty( query ) ) {
-                
                 JApplet applet = null;
                 if ( isApplet() ) {
                     applet = obtainApplet();
                 }
                 Blast.NcbiBlastWeb( query, applet, this );
-                
-              
-                
-                
                 if ( Constants.ALLOW_DDBJ_BLAST ) {
-                try {
-                    System.out.println( "trying: " + query );
-                    final Blast s = new Blast();
-                    s.ddbjBlast( query );
-                }
-                catch ( final Exception e ) {
-                    e.printStackTrace();
-                }
+                    try {
+                        System.out.println( "trying: " + query );
+                        final Blast s = new Blast();
+                        s.ddbjBlast( query );
+                    }
+                    catch ( final Exception e ) {
+                        e.printStackTrace();
+                    }
                 }
             }
         }
     }
 
-   
-
     final void calcMaxDepth() {
         if ( _phylogeny != null ) {
             _circ_max_depth = PhylogenyMethods.calculateMaxDepth( _phylogeny );
@@ -1448,9 +1440,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
     final private boolean isCanBlast( final PhylogenyNode node ) {
         return ( node.getNodeData().isHasSequence() && ( ( ( node.getNodeData().getSequence().getAccession() != null ) && !ForesterUtil
                 .isEmpty( node.getNodeData().getSequence().getAccession().getValue() ) )
-                || !ForesterUtil.isEmpty( node.getNodeData().getSequence().getName() ) || !ForesterUtil.isEmpty( node
-                .getNodeData().getSequence().getSymbol() ) || !ForesterUtil.isEmpty( node
-                                                                                     .getNodeData().getSequence().getMolecularSequence() )) );
+                || !ForesterUtil.isEmpty( node.getNodeData().getSequence().getName() )
+                || !ForesterUtil.isEmpty( node.getNodeData().getSequence().getSymbol() ) || !ForesterUtil.isEmpty( node
+                .getNodeData().getSequence().getMolecularSequence() ) ) );
     }
 
     final boolean isCanCollapse() {
@@ -1749,7 +1741,6 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee
                 _node_popup_menu_items[ i ].setEnabled( isCanOpenTaxWeb( node ) );
             }
             else if ( title.equals( Configuration.clickto_options[ Configuration.blast ][ 0 ] ) ) {
-               
                 _node_popup_menu_items[ i ].setEnabled( isCanBlast( node ) );
             }
             else if ( title.equals( Configuration.clickto_options[ Configuration.delete_subtree_or_node ][ 0 ] ) ) {
index d3ea4cc..38519e4 100644 (file)
@@ -25,7 +25,6 @@
 
 package org.forester.archaeopteryx.tools;
 
-
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -46,23 +45,19 @@ import org.forester.ws.wabi.RestUtil;
 
 public class Blast {
 
-    final static Pattern identifier_pattern_1 = Pattern.compile ("^([A-Za-z]{2,5})[|=:]([0-9A-Za-z\\.]{4,40})\\s*$");
-    final static Pattern identifier_pattern_2 = Pattern.compile ("^([A-Za-z]{2,5})[|=:]([0-9A-Za-z\\.]{4,40})[|,; ].*$");
-    
+    final static Pattern identifier_pattern_1 = Pattern.compile( "^([A-Za-z]{2,5})[|=:]([0-9A-Za-z\\.]{4,40})\\s*$" );
+    final static Pattern identifier_pattern_2 = Pattern
+                                                      .compile( "^([A-Za-z]{2,5})[|=:]([0-9A-Za-z\\.]{4,40})[|,; ].*$" );
+
     public Blast() {
     }
 
-
-    public static void NcbiBlastWeb( String query, JApplet applet, TreePanel p ) {
-
-      //http://www.ncbi.nlm.nih.gov/blast/Blast.cgi?CMD=Web&PAGE=Proteins&DATABASE=swissprot&QUERY=gi|163848401
-        
-        
-        StringBuilder uri_str = new StringBuilder();
+    public static void NcbiBlastWeb( final String query, final JApplet applet, final TreePanel p ) {
+        //http://www.ncbi.nlm.nih.gov/blast/Blast.cgi?CMD=Web&PAGE=Proteins&DATABASE=swissprot&QUERY=gi|163848401
+        final StringBuilder uri_str = new StringBuilder();
         uri_str.append( "http://www.ncbi.nlm.nih.gov/blast/Blast.cgi?CMD=Web&DATABASE=nr&PAGE=Proteins&QUERY=" );
         uri_str.append( query );
         try {
-
             AptxUtil.launchWebBrowser( new URI( uri_str.toString() ), applet != null, applet, "_aptx_blast" );
         }
         catch ( final IOException e ) {
@@ -73,64 +68,57 @@ public class Blast {
             AptxUtil.showErrorMessage( p, e.toString() );
             e.printStackTrace();
         }
-
     }
+
     public static String obtainQueryForBlast( final PhylogenyNode node ) {
         String query = "";
         if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
             query = node.getNodeData().getSequence().getMolecularSequence();
         }
-        else if ( node.getNodeData().getSequence().getAccession() != null && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getValue() ) ) {
+        else if ( ( node.getNodeData().getSequence().getAccession() != null )
+                && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getValue() ) ) {
             if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() ) ) {
                 query = node.getNodeData().getSequence().getAccession().getSource() + "%7C";
             }
             query += node.getNodeData().getSequence().getAccession().getValue();
         }
         else if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getName() ) ) {
-            String name = node.getNodeData().getSequence().getName();
+            final String name = node.getNodeData().getSequence().getName();
             final Matcher matcher1 = identifier_pattern_1.matcher( name );
             final Matcher matcher2 = identifier_pattern_2.matcher( name );
             String group1 = "";
             String group2 = "";
-            
             if ( matcher1.matches() ) {
-                group1 =  matcher1.group( 1 );
-                group2 =  matcher1.group( 2 );
+                group1 = matcher1.group( 1 );
+                group2 = matcher1.group( 2 );
                 System.out.println( "1 1=" + group1 );
-
                 System.out.println( "1 2=" + group2 );
             }
             if ( matcher2.matches() ) {
-                group1 =  matcher2.group( 1 );
-                group2 =  matcher2.group( 2 );
+                group1 = matcher2.group( 1 );
+                group2 = matcher2.group( 2 );
                 System.out.println( "2 1=" + group1 );
-
                 System.out.println( "2 2=" + group2 );
             }
-            if (!ForesterUtil.isEmpty( group1 ) && !ForesterUtil.isEmpty( group2 )) {
-                query = group1  + "%7C" + group2;
+            if ( !ForesterUtil.isEmpty( group1 ) && !ForesterUtil.isEmpty( group2 ) ) {
+                query = group1 + "%7C" + group2;
             }
-
         }
-       
-        
         System.out.println( query );
-
         return query;
     }
 
-
     public void ddbjBlast( final String geneName ) {
         // Retrieve accession number list which has specified gene name from searchByXMLPath of ARSA. Please click here for details of ARSA.
         /*target: Sequence length is between 300bp and 1000bp.
         Feature key is CDS.
         Gene qualifire is same as specified gene name.*/
         String queryPath = "/ENTRY/DDBJ/division=='HUM' AND (/ENTRY/DDBJ/length>=300 AND "
-            + "/ENTRY/DDBJ/length<=1000) ";
+                + "/ENTRY/DDBJ/length<=1000) ";
         queryPath += "AND (/ENTRY/DDBJ/feature-table/feature{/f_key = 'CDS' AND ";
         queryPath += "/f_quals/qualifier{/q_name = 'gene' AND /q_value=='" + geneName + "'}})";
         String query = "service=ARSA&method=searchByXMLPath&queryPath=" + queryPath
-        + "&returnPath=/ENTRY/DDBJ/primary-accession&offset=1&count=100";
+                + "&returnPath=/ENTRY/DDBJ/primary-accession&offset=1&count=100";
         //Execute ARSA
         String arsaResult = null;
         try {
@@ -164,7 +152,7 @@ public class Blast {
         //Execute blastn by using searchParam of Blast with step2's sequence. Specified option is -e 0.0001 -m 8 -b 50 -v 50. It means "Extract top 50 hit which E-value is more than 0.0001.". The reference databases are specified as follows. ddbjpri(primates) ddbjrod(rodents) ddbjmam(mammals) ddbjvrt(vertebrates ) ddbjinv(invertebrates).
         //Execute blastn with step3's sequence
         query = "service=Blast&method=searchParam&program=blastn&database=ddbjpri ddbjrod ddbjmam ddbjvrt "
-            + "ddbjinv&query=" + dnaSeq + "&param=-m 8 -b 50 -v 50 -e 0.0001";
+                + "ddbjinv&query=" + dnaSeq + "&param=-m 8 -b 50 -v 50 -e 0.0001";
         String blastResult = null;
         try {
             blastResult = RestUtil.getResult( query );
@@ -190,7 +178,7 @@ public class Blast {
         for( int i = 0; i < parsedBlastResult.size(); i++ ) {
             final String[] parsed = parsedBlastResult.elementAt( i );
             query = "service=ARSA&method=searchByXMLPath&queryPath=/ENTRY/DDBJ/primary-accession=='" + parsed[ 0 ]
-                                                                                                               + "'&returnPath=/ENTRY/DDBJ/organism&offset=1&count=100";
+                    + "'&returnPath=/ENTRY/DDBJ/organism&offset=1&count=100";
             String organism = null;
             try {
                 organism = RestUtil.getResult( query );