3 import org.apache.axis.client.*;
\r
4 import javax.xml.namespace.QName;
\r
6 import jalview.datamodel.*;
\r
7 import jalview.gui.*;
\r
8 import javax.swing.*;
\r
10 public class WSWUBlastClient
\r
12 CutAndPasteTransfer cap = new CutAndPasteTransfer(false);
\r
14 public WSWUBlastClient(AlignmentI al, ArrayList ids)
\r
16 JInternalFrame frame = new JInternalFrame();
\r
17 cap.formatForOutput();
\r
18 frame.setContentPane(cap);
\r
19 cap.setText("To display sequence features an exact Uniprot id with 100% sequence identity match must be entered."
\r
20 +"\nIn order to display these features, try changing the names of your sequences to the ids suggested below.");
\r
21 Desktop.addInternalFrame(frame, "BLASTing for unidentified sequences ", 800,300);
\r
23 for(int i=0; i<ids.size(); i++)
\r
25 SequenceI sequence = al.findName( ids.get(i).toString() );
\r
26 StringBuffer nonGapped = new StringBuffer();
\r
27 for (int n = 0; n < sequence.getSequence().length(); n++)
\r
29 if (!jalview.util.Comparison.isGap(sequence.getCharAt(n)))
\r
30 nonGapped.append(sequence.getCharAt(n));
\r
33 BlastThread thread = new BlastThread(ids.get(i).toString(), nonGapped.toString());
\r
39 class BlastThread extends Thread
\r
43 BlastThread(String id, String sequence)
\r
45 this.sequence = sequence;
\r
51 FindUniprotIDFromUnknownSequence(id, sequence);
\r
55 public void FindUniprotIDFromUnknownSequence (String id, String s)
\r
57 HashMap params = new HashMap();
\r
58 params.put("database", "uniprot");
\r
59 params.put("sensitivity","low");
\r
60 params.put("sort","totalscore");
\r
61 params.put("matrix","pam10");
\r
62 params.put("program","blastp");
\r
63 params.put("alignments","5");
\r
64 params.put("outformat","xml");
\r
65 byte[] sequence = s.getBytes();
\r
68 Call call = (Call) new Service().createCall();
\r
69 call.setTargetEndpointAddress (new java.net.URL("http://www.ebi.ac.uk/cgi-bin/webservices/WSWUBlast"));
\r
70 call.setOperationName(new QName("WSWUBlast", "doWUBlast"));
\r
72 String result = (String) call.invoke(new Object[] {params,sequence});
\r
73 parseResult(id, result);
\r
75 catch (Exception exp) {
\r
76 System.err.println ("ERROR:\n" + exp.toString());
\r
77 exp.printStackTrace();
\r
81 void parseResult(String id1, String res)
\r
83 StringTokenizer st = new StringTokenizer(res, "\n");
\r
87 StringBuffer buffer = new StringBuffer("\n\n"+id1+" :");
\r
89 while( st.hasMoreTokens() )
\r
91 data = st.nextToken();
\r
93 if(data.indexOf("database=\"uniprot\" id=")>-1)
\r
95 int index = data.indexOf("database=\"uniprot\" id=")+ 23;
\r
96 id2 = data.substring( index, data.indexOf("\"", index) );
\r
97 while( data.indexOf("</alignment>")==-1)
\r
99 data = st.nextToken();
\r
100 if(data.indexOf("<identity>")>-1)
\r
102 int value = Integer.parseInt( data.substring(data.indexOf("<identity>")+10, data.indexOf("</identity>")));
\r
103 if(value>=maxFound)
\r
106 buffer.append(" "+ id2 + " " + value+"%; ");
\r
116 cap.setText(cap.getText()+buffer.toString());
\r