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: https://sites.google.com/site/cmzmasek/home/software/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 Phylogeny _phy;
42 private final MainFrameApplication _mf;
43 private final TreePanel _treepanel;
44 public final static boolean DEBUG = false;
46 public SequenceDataRetriver( final MainFrameApplication mf, final TreePanel treepanel, final Phylogeny phy ) {
49 _treepanel = treepanel;
57 private void execute() {
58 start( _mf, "sequence data" );
59 SortedSet<String> not_found = null;
61 not_found = SequenceDbWsTools.obtainSeqInformation( _phy,
64 SequenceDbWsTools.DEFAULT_LINES_TO_RETURN );
66 catch ( final UnknownHostException e ) {
67 JOptionPane.showMessageDialog( _mf,
68 e.getLocalizedMessage(),
69 "Network error during sequence data gathering",
70 JOptionPane.ERROR_MESSAGE );
73 catch ( final IOException e ) {
75 JOptionPane.showMessageDialog( _mf,
77 "Failed to obtain sequence data",
78 JOptionPane.ERROR_MESSAGE );
84 _treepanel.setTree( _phy );
86 _treepanel.setEdited( true );
87 if ( ( not_found != null ) && ( not_found.size() > 0 ) ) {
88 int max = not_found.size();
94 final StringBuffer sb = new StringBuffer();
95 if ( not_found.size() == 1 ) {
96 sb.append( "For the following node no data was found:\n" );
99 sb.append( "For the following nodes no data was found (total: " + not_found.size() + "):\n" );
102 for( final String string : not_found ) {
114 JOptionPane.showMessageDialog( _mf,
116 "Sequence Tool Completed",
117 JOptionPane.WARNING_MESSAGE );
119 catch ( final Exception e ) {
120 // Not important if this fails, do nothing.
125 JOptionPane.showMessageDialog( _mf,
126 "Sequence tool successfully completed",
127 "Sequence Tool Completed",
128 JOptionPane.INFORMATION_MESSAGE );
130 catch ( final Exception e ) {
131 // Not important if this fails, do nothing.