// 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.tools;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
+import javax.swing.JApplet;
+
+import org.forester.archaeopteryx.AptxUtil;
+import org.forester.archaeopteryx.TreePanel;
+import org.forester.phylogeny.PhylogenyNode;
+import org.forester.phylogeny.data.Accession;
+import org.forester.util.ForesterUtil;
+import org.forester.util.SequenceAccessionTools;
import org.forester.ws.wabi.RestUtil;
-public class Blast {
+public final class Blast {
+
+ final public static void openNcbiBlastWeb( final String query,
+ final boolean is_nucleic_acids,
+ 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=" );
+ if ( is_nucleic_acids ) {
+ uri_str.append( "Nucleotide" );
+ }
+ else {
+ uri_str.append( "Proteins" );
+ }
+ uri_str.append( "&QUERY=" );
+ uri_str.append( query );
+ try {
+ AptxUtil.launchWebBrowser( new URI( uri_str.toString() ), applet != null, applet, "_aptx_blast" );
+ }
+ catch ( final IOException e ) {
+ AptxUtil.showErrorMessage( p, e.toString() );
+ e.printStackTrace();
+ }
+ catch ( final URISyntaxException e ) {
+ AptxUtil.showErrorMessage( p, e.toString() );
+ e.printStackTrace();
+ }
+ }
+
+ final public static String obtainQueryForBlast( final PhylogenyNode node ) {
+ String query = "";
+ if ( node.getNodeData().isHasSequence() ) {
+ if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
+ query = node.getNodeData().getSequence().getMolecularSequence();
+ }
+ if ( ForesterUtil.isEmpty( query ) && ( node.getNodeData().getSequence().getAccession() != null )
+ && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getValue() ) ) {
+ final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getNodeData().getSequence()
+ .getAccession().getValue() );
+ if ( id != null ) {
+ query = id.getValue();
+ }
+ }
+ if ( ForesterUtil.isEmpty( query ) && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getName() ) ) {
+ final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getNodeData().getSequence()
+ .getName() );
+ if ( id != null ) {
+ query = id.getValue();
+ }
+ }
+ if ( ForesterUtil.isEmpty( query ) && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getSymbol() ) ) {
+ final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getNodeData().getSequence()
+ .getSymbol() );
+ if ( id != null ) {
+ query = id.getValue();
+ }
+ }
+ if ( ForesterUtil.isEmpty( query )
+ && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getGeneName() ) ) {
+ final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getNodeData().getSequence()
+ .getGeneName() );
+ if ( id != null ) {
+ query = id.getValue();
+ }
+ }
+ }
+ if ( ForesterUtil.isEmpty( query ) && !ForesterUtil.isEmpty( node.getName() ) ) {
+ final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getName() );
+ if ( id != null ) {
+ query = id.getValue();
+ }
+ }
+ return query;
+ }
- public Blast() {
+ final public static boolean isContainsQueryForBlast( final PhylogenyNode node ) {
+ return !ForesterUtil.isEmpty( obtainQueryForBlast( node ) );
}
- public void go( final String geneName ) {
+ final 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.