2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.archaeopteryx.tools;
28 import java.io.IOException;
30 import java.net.URISyntaxException;
31 import java.util.Arrays;
32 import java.util.Enumeration;
33 import java.util.Hashtable;
34 import java.util.Vector;
36 import javax.swing.JApplet;
38 import org.forester.archaeopteryx.AptxUtil;
39 import org.forester.archaeopteryx.TreePanel;
40 import org.forester.phylogeny.PhylogenyNode;
41 import org.forester.phylogeny.data.Accession;
42 import org.forester.util.ForesterUtil;
43 import org.forester.util.SequenceAccessionTools;
45 public final class Blast {
47 final public static void openNcbiBlastWeb( final String query,
48 final boolean is_nucleic_acids,
51 //http://www.ncbi.nlm.nih.gov/blast/Blast.cgi?CMD=Web&PAGE=Proteins&DATABASE=swissprot&QUERY=gi|163848401
52 final StringBuilder uri_str = new StringBuilder();
53 uri_str.append( "http://www.ncbi.nlm.nih.gov/blast/Blast.cgi?CMD=Web&DATABASE=nr&PAGE=" );
54 if ( is_nucleic_acids ) {
55 uri_str.append( "Nucleotide" );
58 uri_str.append( "Proteins" );
60 uri_str.append( "&QUERY=" );
61 uri_str.append( query );
63 AptxUtil.launchWebBrowser( new URI( uri_str.toString() ), applet != null, applet, "_aptx_blast" );
65 catch ( final IOException e ) {
66 AptxUtil.showErrorMessage( p, e.toString() );
69 catch ( final URISyntaxException e ) {
70 AptxUtil.showErrorMessage( p, e.toString() );
75 final public static String obtainQueryForBlast( final PhylogenyNode node ) {
77 if ( node.getNodeData().isHasSequence() ) {
78 if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
79 query = node.getNodeData().getSequence().getMolecularSequence();
81 if ( ForesterUtil.isEmpty( query ) && ( node.getNodeData().getSequence().getAccession() != null )
82 && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getValue() ) ) {
83 final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getNodeData().getSequence()
84 .getAccession().getValue() );
86 query = id.getValue();
89 if ( ForesterUtil.isEmpty( query ) && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getName() ) ) {
90 final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getNodeData().getSequence()
93 query = id.getValue();
96 if ( ForesterUtil.isEmpty( query ) && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getSymbol() ) ) {
97 final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getNodeData().getSequence()
100 query = id.getValue();
103 if ( ForesterUtil.isEmpty( query )
104 && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getGeneName() ) ) {
105 final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getNodeData().getSequence()
108 query = id.getValue();
112 if ( ForesterUtil.isEmpty( query ) && !ForesterUtil.isEmpty( node.getName() ) ) {
113 final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getName() );
115 query = id.getValue();
121 final public static boolean isContainsQueryForBlast( final PhylogenyNode node ) {
122 return !ForesterUtil.isEmpty( obtainQueryForBlast( node ) );