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;
32 import org.forester.archaeopteryx.AptxUtil;
33 import org.forester.archaeopteryx.TreePanel;
34 import org.forester.phylogeny.PhylogenyNode;
35 import org.forester.phylogeny.data.Accession;
36 import org.forester.util.ForesterUtil;
37 import org.forester.util.SequenceAccessionTools;
39 public final class Blast {
41 final public static void openNcbiBlastWeb( final String query,
42 final boolean is_nucleic_acids,
45 //http://www.ncbi.nlm.nih.gov/blast/Blast.cgi?CMD=Web&PAGE=Proteins&DATABASE=swissprot&QUERY=gi|163848401
46 final StringBuilder uri_str = new StringBuilder();
47 uri_str.append( "http://www.ncbi.nlm.nih.gov/blast/Blast.cgi?CMD=Web&DATABASE=nr&PAGE=" );
48 if ( is_nucleic_acids ) {
49 uri_str.append( "Nucleotide" );
52 uri_str.append( "Proteins" );
54 uri_str.append( "&QUERY=" );
55 uri_str.append( query );
57 AptxUtil.launchWebBrowser( new URI( uri_str.toString() ), "_aptx_blast" );
59 catch ( final IOException e ) {
60 AptxUtil.showErrorMessage( p, e.toString() );
63 catch ( final URISyntaxException e ) {
64 AptxUtil.showErrorMessage( p, e.toString() );
69 final public static String obtainQueryForBlast( final PhylogenyNode node ) {
71 if ( node.getNodeData().isHasSequence() ) {
72 if ( !ForesterUtil.isEmpty( node.getNodeData().getSequence().getMolecularSequence() ) ) {
73 query = node.getNodeData().getSequence().getMolecularSequence();
75 if ( ForesterUtil.isEmpty( query ) && ( node.getNodeData().getSequence().getAccession() != null )
76 && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getValue() ) ) {
77 final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getNodeData().getSequence()
78 .getAccession().getValue() );
80 query = id.getValue();
83 if ( ForesterUtil.isEmpty( query ) && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getName() ) ) {
84 final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getNodeData().getSequence()
87 query = id.getValue();
90 if ( ForesterUtil.isEmpty( query ) && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getSymbol() ) ) {
91 final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getNodeData().getSequence()
94 query = id.getValue();
97 if ( ForesterUtil.isEmpty( query )
98 && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getGeneName() ) ) {
99 final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getNodeData().getSequence()
102 query = id.getValue();
106 if ( ForesterUtil.isEmpty( query ) && !ForesterUtil.isEmpty( node.getName() ) ) {
107 final Accession id = SequenceAccessionTools.parseAccessorFromString( node.getName() );
109 query = id.getValue();
115 final public static boolean isContainsQueryForBlast( final PhylogenyNode node ) {
116 return !ForesterUtil.isEmpty( obtainQueryForBlast( node ) );