2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 import jalview.analysis.*;
26 import jalview.datamodel.*;
28 import uk.ac.ebi.www.*;
36 public class WSWUBlastClient
40 CutAndPasteTransfer output = new CutAndPasteTransfer();
43 Vector suggestedIds = new Vector();
45 * Creates a new WSWUBlastClient object.
47 * @param al DOCUMENT ME!
48 * @param ids DOCUMENT ME!
50 public WSWUBlastClient(AlignmentPanel ap, AlignmentI al, ArrayList ids)
55 "To display sequence features an exact Uniprot id with 100% sequence identity match must be entered."
56 + "\nIn order to display these features, try changing the names of your sequences to the ids suggested below."
57 + "\n\nRunning WSWUBlast at EBI."
58 + "\nPlease quote Pillai S., Silventoinen V., Kallio K., Senger M., Sobhany S., Tate J., Velankar S., Golovin A., Henrick K., Rice P., Stoehr P., Lopez R."
60 "\nSOAP-based services provided by the European Bioinformatics Institute."
61 + "\nNucleic Acids Res. 33(1):W25-W28 (2005));");
63 Desktop.addInternalFrame(output,
64 "BLASTing for unidentified sequences ", 800, 300);
66 for (int i = 0; i < ids.size(); i++)
68 Sequence sequence = (Sequence) ids.get(i);
69 System.out.println(sequence.getName());
71 BlastThread thread = new BlastThread(sequence);
76 ImageTwirler thread = new ImageTwirler();
83 * @param id1 DOCUMENT ME!
84 * @param res DOCUMENT ME!
86 void parseResult(Sequence seq, String res)
88 StringTokenizer st = new StringTokenizer(res, "\n");
92 StringBuffer buffer = new StringBuffer("\n\n" + seq.getName() + " :");
94 while (st.hasMoreTokens())
96 data = st.nextToken();
98 if (data.indexOf(">UNIPROT") > -1)
100 int index = data.indexOf(">UNIPROT") + 9;
101 id2 = data.substring(index, data.indexOf(" ", index));
103 boolean identitiesFound = false;
104 while (!identitiesFound)
106 data = st.nextToken();
108 if (data.indexOf("Identities") > -1)
110 identitiesFound = true;
112 int value = Integer.parseInt(data.substring(data.indexOf(
116 if (value >= maxFound)
119 buffer.append(" " + id2 + " " + value + "%; ");
120 suggestedIds.addElement(new Object[]
128 output.appendText(buffer.toString());
133 // This must be outside the run() body as java 1.5
134 // will not return any value from the OptionPane to the expired thread.
135 int reply = JOptionPane.showConfirmDialog(
136 Desktop.desktop, "Automatically update suggested ids?",
137 "Auto replace sequence ids", JOptionPane.YES_NO_OPTION);
139 if (reply == JOptionPane.YES_OPTION)
141 Enumeration keys = suggestedIds.elements();
142 while (keys.hasMoreElements())
144 Object[] object = (Object[]) keys.nextElement();
146 Sequence oldseq = (Sequence) object[0];
148 oldseq.setName(object[1].toString());
150 // Oldseq is actually in the dataset, we must find the
151 // Visible seq and change its name also.
152 for (int i = 0; i < al.getHeight(); i++)
154 if (al.getSequenceAt(i).getDatasetSequence() == oldseq)
156 al.getSequenceAt(i).setName(oldseq.getName());
161 DBRefEntry[] entries = oldseq.getDBRef();
164 oldseq.addDBRef(new jalview.datamodel.
165 DBRefEntry(jalview.datamodel.DBRefSource.UNIPROT,
167 entries[0].getAccessionId()));
171 ap.paintAlignment(true);
178 ImageIcon[] imageIcon;
181 public ImageTwirler()
183 imageIcon = new ImageIcon[9];
185 for (int i = 0; i < 9; i++)
187 java.net.URL url = getClass().getResource("/images/dna" +
192 imageIcon[i] = new ImageIcon(url);
199 while (jobsRunning > 0)
206 output.setFrameIcon(imageIcon[imageIndex]);
207 output.setTitle("BLASTing for unidentified sequences - " +
208 jobsRunning + " jobs running.");
215 if (jobsRunning == 0)
227 boolean jobComplete = false;
229 BlastThread(Sequence sequence)
231 System.out.println("blasting for: " + sequence.getName());
232 this.sequence = sequence;
243 WSWUBlastService service = new WSWUBlastServiceLocator();
244 WSWUBlast wublast = service.getWSWUBlast();
245 WSFile[] results = wublast.getResults(jobid);
249 String result = new String(wublast.poll(jobid, "tooloutput"));
250 parseResult(sequence, result);
257 System.out.println("WSWuBlastClient: I'm alive " +
258 sequence.getName() + " " + jobid); // log.debug
269 InputParams params = new InputParams();
271 params.setProgram("blastp");
272 params.setDatabase("uniprot");
273 params.setMatrix("pam10");
276 params.setSensitivity("low");
277 params.setSort("totalscore");
278 params.setOutformat("txt");
279 params.setAsync(true);
283 Data inputs[] = new Data[1];
284 Data input = new Data();
285 input.setType("sequence");
286 input.setContent(AlignSeq.extractGaps("-. ",
287 sequence.getSequenceAsString()));
290 WSWUBlastService service = new WSWUBlastServiceLocator();
291 WSWUBlast wublast = service.getWSWUBlast();
292 jobid = wublast.runWUBlast(params, inputs);
294 catch (Exception exp)
298 System.err.println("WSWUBlastClient error:\n" + exp.toString());
299 exp.printStackTrace();