X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSequenceFetcher.java;h=fc8f042fcdce14a099f219c02b3101b12d5f107a;hb=e651bfd6da43bae19e157d6fdf1efbb484acda76;hp=65145cc79898274c8380f59876852e24490d868d;hpb=7854b5718c659c3768b738f0211bf27e604cf3ff;p=jalview.git diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 65145cc..fc8f042 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() @@ -191,10 +189,13 @@ public class SequenceFetcher ) + ":" + textfield.getText(), "fasta", "raw"); - for (int i = 0; i < reply.length; i++) - result.append(reply[i] + "\n"); + if(reply!=null) + { + 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")) { @@ -209,21 +210,36 @@ 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) { EBIFetchClient ebi = new EBIFetchClient(); File file = ebi.fetchDataAsFile("uniprot:" + id, "xml", null); + // File file = new File("H:/jalview/classes/fer1.xml"); SequenceFeatureFetcher sff = new SequenceFeatureFetcher(); Vector entries = sff.getUniprotEntries(file); @@ -234,7 +250,8 @@ 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()) { @@ -248,8 +265,10 @@ public class SequenceFetcher name.append(en2.nextElement()); } - if (entry.getProteinName() != null) - name.append(" " + entry.getProteinName().elementAt(0)); + if (entry.getProtein() != null) + { + name.append(" " + entry.getProtein().getName().elementAt(0)); + } result.append(name + "\n" + entry.getUniprotSequence().getContent() + "\n"); @@ -257,7 +276,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); @@ -273,8 +292,16 @@ 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()) + { + SequenceFeature sf = (SequenceFeature) e.nextElement(); + sf.setFeatureGroup("Uniprot"); + sequence[i].getDatasetSequence().addSequenceFeature( sf ); + } + } } } } @@ -321,23 +348,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"); @@ -355,7 +387,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("-. ", @@ -396,6 +428,11 @@ public class SequenceFetcher + "=" + sequences[i].getStart() + "-" + sequences[i].getEnd()); sequences[i].getDatasetSequence().addPDBId(entry); + + // We make a DBRefEtntry because we have obtained the PDB file from a verifiable source + // JBPNote - PDB DBRefEntry should also carry the chain and mapping information + DBRefEntry dbentry = new DBRefEntry("PDB","0",pdbid); + sequences[i].getDatasetSequence().addDBRef(dbentry); } else { @@ -425,9 +462,11 @@ public class SequenceFetcher void showErrorMessage(String error) { + resetDialog(); JOptionPane.showInternalMessageDialog(Desktop.desktop, error, "Error Retrieving Data", JOptionPane.WARNING_MESSAGE); + return; } }