2 // forester -- software libraries and applications
3 // for genomics and evolutionary biology research.
5 // Copyright (C) 2010 Christian M Zmasek
6 // Copyright (C) 2010 Sanford-Burnham Medical Research Institute
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: www.phylosoft.org/forester
26 package org.forester.archaeopteryx.tools;
28 import java.io.IOException;
29 import java.net.UnknownHostException;
30 import java.util.SortedSet;
32 import javax.swing.JOptionPane;
34 import org.forester.archaeopteryx.MainFrameApplication;
35 import org.forester.archaeopteryx.TreePanel;
36 import org.forester.phylogeny.Phylogeny;
37 import org.forester.ws.seqdb.SequenceDbWsTools;
39 public final class SequenceDataRetriver extends RunnableProcess {
41 private final static int DEFAULT_LINES_TO_RETURN = 50;
42 private final Phylogeny _phy;
43 private final MainFrameApplication _mf;
44 private final TreePanel _treepanel;
45 public final static boolean DEBUG = false;
47 public SequenceDataRetriver( final MainFrameApplication mf, final TreePanel treepanel, final Phylogeny phy ) {
50 _treepanel = treepanel;
58 private void execute() {
59 start( _mf, "sequence data" );
60 SortedSet<String> not_found = null;
62 not_found = SequenceDbWsTools.obtainSeqInformation( _phy, false, true, DEFAULT_LINES_TO_RETURN );
64 catch ( final UnknownHostException e ) {
65 JOptionPane.showMessageDialog( _mf,
66 e.getLocalizedMessage(),
67 "Network error during sequence data gathering",
68 JOptionPane.ERROR_MESSAGE );
71 catch ( final IOException e ) {
73 JOptionPane.showMessageDialog( _mf,
75 "Failed to obtain sequence data",
76 JOptionPane.ERROR_MESSAGE );
82 _treepanel.setTree( _phy );
84 _treepanel.setEdited( true );
85 if ( ( not_found != null ) && ( not_found.size() > 0 ) ) {
86 int max = not_found.size();
92 final StringBuffer sb = new StringBuffer();
93 if ( not_found.size() == 1 ) {
94 sb.append( "Data for the following sequence identifier was not found:\n" );
97 sb.append( "Data for the following sequence identifiers was not found (total: " + not_found.size()
101 for( final String string : not_found ) {
113 JOptionPane.showMessageDialog( _mf,
115 "Sequence Tool Completed",
116 JOptionPane.WARNING_MESSAGE );
118 catch ( final Exception e ) {
119 // Not important if this fails, do nothing.
124 JOptionPane.showMessageDialog( _mf,
125 "Sequence tool successfully completed",
126 "Sequence Tool Completed",
127 JOptionPane.INFORMATION_MESSAGE );
129 catch ( final Exception e ) {
130 // Not important if this fails, do nothing.