X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSequenceFetcher.java;h=67a3eff124f9310402e0fe977a430b09dd4cac5e;hb=03e082a4dba4e1ba9b6929ca3d3f8055f9224fc1;hp=99ba120519f31adea264c0cbdcdd91b91cceadb1;hpb=d1309c5058238503ad5bb7c52657e04bc201410c;p=jalview.git diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 99ba120..67a3eff 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -44,6 +44,7 @@ public class SequenceFetcher database.addItem("EMBL"); database.addItem("EMBLCDS"); database.addItem("PDB"); + database.addItem("PFAM"); try { @@ -64,8 +65,7 @@ public class SequenceFetcher private String getFrameTitle() { - return ( (alignFrame == null) ? "New " : "Additional ") + - "Sequence Fetcher (WSDBfetch@EBI)"; + return ( (alignFrame == null) ? "New " : "Additional ") + "Sequence Fetcher"; } private void jbInit() @@ -87,12 +87,12 @@ public class SequenceFetcher ok_actionPerformed(e); } }); - cancel.setText("Cancel"); - cancel.addActionListener(new ActionListener() + close.setText("Close"); + close.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - cancel_actionPerformed(e); + close_actionPerformed(e); } }); textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); @@ -104,7 +104,7 @@ public class SequenceFetcher } }); jPanel1.add(ok); - jPanel1.add(cancel); + jPanel1.add(close); this.add(jLabel1, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0 , GridBagConstraints.WEST, GridBagConstraints.NONE, @@ -126,11 +126,11 @@ public class SequenceFetcher JComboBox database = new JComboBox(); JLabel jLabel1 = new JLabel(); JButton ok = new JButton(); - JButton cancel = new JButton(); + JButton close = new JButton(); JPanel jPanel1 = new JPanel(); JTextField textfield = new JTextField(); GridBagLayout gridBagLayout1 = new GridBagLayout(); - public void cancel_actionPerformed(ActionEvent e) + public void close_actionPerformed(ActionEvent e) { try { @@ -142,11 +142,10 @@ public class SequenceFetcher public void ok_actionPerformed(ActionEvent e) { - frame.setTitle("Sequence Fetcher (WSDBfetch@EBI) - Fetching Sequence..."); database.setEnabled(false); textfield.setEnabled(false); ok.setEnabled(false); - cancel.setEnabled(false); + close.setEnabled(false); Thread worker = new Thread(this); worker.start(); @@ -157,8 +156,7 @@ public class SequenceFetcher database.setEnabled(true); textfield.setEnabled(true); ok.setEnabled(true); - cancel.setEnabled(true); - frame.setTitle(getFrameTitle()); + close.setEnabled(true); } public void run() @@ -196,7 +194,7 @@ public class SequenceFetcher for (int i = 0; i < reply.length; i++) result.append(reply[i] + "\n"); - parseResult(result.toString()); + parseResult(result.toString(), null); } } else if (database.getSelectedItem().equals("PDB")) @@ -212,15 +210,29 @@ public class SequenceFetcher if (result.length()>0) - parseResult(result.toString()); + parseResult(result.toString(), null); + } + else if( database.getSelectedItem().equals("PFAM")) + { + try{ + result.append(new FastaFile( + "http://www.sanger.ac.uk/cgi-bin/Pfam/getalignment.pl?format=fal&acc=" + + textfield.getText().toUpperCase(), "URL").print() + ); + + if(result.length()>0) + parseResult( result.toString(), textfield.getText().toUpperCase() ); + + }catch(java.io.IOException ex) + { result = null; } } if (result == null || result.length() == 0) showErrorMessage("Error retrieving " + textfield.getText() + " from " + database.getSelectedItem()); - else - textfield.setText(""); + resetDialog(); + return; } void getUniprotFile(String id) @@ -237,7 +249,7 @@ public class SequenceFetcher while (en.hasMoreElements()) { UniprotEntry entry = (UniprotEntry) en.nextElement(); - StringBuffer name = new StringBuffer(">Uniprot/Swiss-Prot"); + StringBuffer name = new StringBuffer(">UniProt/Swiss-Prot"); Enumeration en2 = entry.getAccession().elements(); while (en2.hasMoreElements()) { @@ -260,7 +272,7 @@ public class SequenceFetcher } //Then read in the features and apply them to the dataset - SequenceI[] sequence = parseResult(result.toString()); + SequenceI[] sequence = parseResult(result.toString(), null); for (int i = 0; i < entries.size(); i++) { UniprotEntry entry = (UniprotEntry) entries.elementAt(i); @@ -276,8 +288,15 @@ public class SequenceFetcher } sequence[i].getDatasetSequence().setPDBId(onlyPdbEntries); - sequence[i].getDatasetSequence().setSequenceFeatures(entry.getFeature()); - + if (entry.getFeature() != null) + { + e = entry.getFeature().elements(); + while (e.hasMoreElements()) + { + sequence[i].getDatasetSequence().addSequenceFeature( ( + SequenceFeature) e.nextElement()); + } + } } } } @@ -324,23 +343,28 @@ public class SequenceFetcher return result; } - SequenceI[] parseResult(String result) + SequenceI[] parseResult(String result, String title) { - String format = IdentifyFile.Identify(result, "Paste"); + String format = new IdentifyFile().Identify(result, "Paste"); SequenceI[] sequences = null; if (FormatAdapter.formats.contains(format)) { - sequences = new FormatAdapter().readFile(result.toString(), "Paste", - format); + sequences = null; + try{ sequences = new FormatAdapter().readFile(result.toString(), "Paste", + format);} + catch(Exception ex){} + if (sequences != null && sequences.length > 0) { if (alignFrame == null) { AlignFrame af = new AlignFrame(new Alignment(sequences)); af.currentFileFormat = format; + if(title==null) + title = "Retrieved from " + database.getSelectedItem(); Desktop.addInternalFrame(af, - "Retrieved from " + database.getSelectedItem(), + title, AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT); af.statusBar.setText("Successfully pasted alignment file"); @@ -358,7 +382,7 @@ public class SequenceFetcher alignFrame.viewport.alignment.addSequence(sequences[i]); //////////////////////////// - //Datset needs extension; + //Dataset needs extension; ///////////////////////////// Sequence ds = new Sequence(sequences[i].getName(), AlignSeq.extractGaps("-. ", @@ -433,9 +457,11 @@ public class SequenceFetcher void showErrorMessage(String error) { + resetDialog(); JOptionPane.showInternalMessageDialog(Desktop.desktop, error, "Error Retrieving Data", JOptionPane.WARNING_MESSAGE); + return; } }