import org.forester.ws.uniprot.SequenceDatabaseEntry;
import org.forester.ws.uniprot.UniProtWsTools;
-public final class SequenceDataRetriver implements Runnable {
+public final class SequenceDataRetriver extends RunnableProcess {
private final Phylogeny _phy;
private final MainFrameApplication _mf;
private final TreePanel _treepanel;
- private final static boolean DEBUG = true;
+ private final static boolean DEBUG = false;
private enum Db {
UNKNOWN, UNIPROT, EMBL;
}
private void execute() {
- _mf.getMainPanel().getCurrentTreePanel().setWaitCursor();
+ start( _mf, "sequence data" );
SortedSet<String> not_found = null;
try {
not_found = obtainSeqInformation( _phy );
}
catch ( final UnknownHostException e ) {
- _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
JOptionPane.showMessageDialog( _mf,
"Could not connect to \"" + getBaseUrl() + "\"",
"Network error during taxonomic information gathering",
return;
}
catch ( final IOException e ) {
- _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
e.printStackTrace();
JOptionPane.showMessageDialog( _mf,
e.toString(),
return;
}
finally {
- _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
+ end( _mf );
}
_treepanel.setTree( _phy );
_mf.showWhole();
max = 20;
}
final StringBuffer sb = new StringBuffer();
- sb.append( "Not all identifiers could be resolved.\n" );
if ( not_found.size() == 1 ) {
- sb.append( "The following identifier was not found:\n" );
+ sb.append( "Data for the following sequence identifier was not found:\n" );
}
else {
- sb.append( "The following identifiers were not found (total: " + not_found.size() + "):\n" );
+ sb.append( "Data for the following sequence identifiers was not found (total: " + not_found.size()
+ + "):\n" );
}
int i = 0;
for( final String string : not_found ) {
try {
JOptionPane.showMessageDialog( _mf,
sb.toString(),
- "UniProt Sequence Tool Completed",
+ "Sequence Tool Completed",
JOptionPane.WARNING_MESSAGE );
}
catch ( final Exception e ) {
// Ignore.
}
}
- else if ( db == Db.EMBL ) {
+ if ( ( db == Db.EMBL ) || ( ( db == Db.UNIPROT ) && ( db_entry == null ) ) ) {
if ( DEBUG ) {
System.out.println( "embl: " + query );
}
catch ( final FileNotFoundException e ) {
// Ignore.
}
+ if ( ( db == Db.UNIPROT ) && ( db_entry != null ) ) {
+ db = Db.EMBL;
+ }
}
- if ( db_entry != null ) {
+ if ( ( db_entry != null ) && !db_entry.isEmpty() ) {
if ( !ForesterUtil.isEmpty( db_entry.getAccession() ) ) {
- seq.setAccession( new Accession( db_entry.getAccession(), "uniprot" ) );
+ String type = null;
+ if ( db == Db.EMBL ) {
+ type = "embl";
+ }
+ else if ( db == Db.UNIPROT ) {
+ type = "uniprot";
+ }
+ seq.setAccession( new Accession( db_entry.getAccession(), type ) );
}
if ( !ForesterUtil.isEmpty( db_entry.getSequenceName() ) ) {
seq.setName( db_entry.getSequenceName() );