From d5ae51f80441c008a5e23741b40ab095720ff618 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Mon, 14 Nov 2005 12:00:25 +0000 Subject: [PATCH] Catch exceptions --- src/jalview/gui/SequenceFetcher.java | 69 ++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 74312e2..4fa215f 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -128,35 +128,43 @@ public class SequenceFetcher public void run() { StringBuffer result = new StringBuffer(); - if (database.getSelectedItem().equals("Uniprot") - || database.getSelectedItem().equals("EMBL") - || database.getSelectedItem().equals("EMBLCDS")) - { - EBIFetchClient dbFetch = new EBIFetchClient(); - String[] reply = dbFetch.fetchData( - database.getSelectedItem().toString().toLowerCase( - ) + ":" + textfield.getText(), - "fasta", "raw"); - - for (int i = 0; i < reply.length; i++) - result.append(reply[i]+"\n"); - } - else if (database.getSelectedItem().equals("PDB")) - { - EBIFetchClient ebi = new EBIFetchClient(); - String[] reply = ebi.fetchData("pdb:" + textfield.getText(), "pdb", - "raw"); - PDBfile pdbfile = new PDBfile(reply); - for (int i = 0; i < pdbfile.chains.size(); i++) + if (database.getSelectedItem().equals("Uniprot") + || database.getSelectedItem().equals("EMBL") + || database.getSelectedItem().equals("EMBLCDS")) { - result.append("\n>" + - ( (PDBChain) pdbfile.chains.elementAt(i)).sequence.getName() + - "\n" - + - ( (PDBChain) pdbfile.chains.elementAt(i)).sequence. - getSequence()); + EBIFetchClient dbFetch = new EBIFetchClient(); + String[] reply = dbFetch.fetchData( + database.getSelectedItem().toString().toLowerCase( + ) + ":" + textfield.getText(), + "fasta", "raw"); + + for (int i = 0; i < reply.length; i++) + result.append(reply[i] + "\n"); + } + else if (database.getSelectedItem().equals("PDB")) + { + EBIFetchClient ebi = new EBIFetchClient(); + String[] reply = ebi.fetchData("pdb:" + textfield.getText(), "pdb", + "raw"); + try{ + PDBfile pdbfile = new PDBfile(reply); + for (int i = 0; i < pdbfile.chains.size(); i++) + { + result.append("\n>" + + ( (PDBChain) pdbfile.chains.elementAt(i)).sequence. + getName() + + "\n" + + + ( (PDBChain) pdbfile.chains.elementAt(i)).sequence. + getSequence()); + } + }catch(Exception ex)// Problem parsing PDB file + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, + "Error retrieving "+textfield.getText()+" from "+database.getSelectedItem(), + "Error Retrieving Data", JOptionPane.WARNING_MESSAGE); + } } - } if (result.length() > 0) { @@ -166,7 +174,7 @@ public class SequenceFetcher if (FormatAdapter.formats.contains(format)) { sequences = new FormatAdapter().readFile(result.toString(), "Paste", format); - if (sequences != null) + if (sequences != null && sequences.length>0) { if(alignFrame==null) { @@ -219,6 +227,11 @@ public class SequenceFetcher } } + else + JOptionPane.showInternalMessageDialog(Desktop.desktop, + "Error retrieving "+textfield.getText()+" from "+database.getSelectedItem(), + "Error Retrieving Data", JOptionPane.WARNING_MESSAGE); + } } -- 1.7.10.2