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
11 import jalview.analysis.AlignSeq;
\r
12 import ext.vamsas.*;
\r
14 public class JPredClient
\r
17 JInternalFrame outputFrame = new JInternalFrame();
\r
18 CutAndPasteTransfer output = new CutAndPasteTransfer(false);
\r
19 int jobsRunning = 0;
\r
20 ext.vamsas.JpredSoapBindingStub server;
\r
22 public JPredClient(SequenceI seq)
\r
24 output.formatForOutput();
\r
25 outputFrame.setContentPane(output);
\r
27 output.setText("Job details for prediction on sequence :\nName : "
\r
28 + seq.getName() + "\nSequence : " + seq.getSequence() + "\n");
\r
29 Desktop.addInternalFrame(outputFrame,
\r
30 "JNet secondary structure prediction job", 800,
\r
33 JPredWSServiceLocator loc = new JPredWSServiceLocator(); // Default
\r
35 this.server = (JpredSoapBindingStub) loc.getjpred(); // JBPNote will be set from properties
\r
37 catch (Exception ex) {
\r
38 output.setText("Serious! JPred Service location failed\nfor URL :"
\r
39 +loc.getjpredAddress()+"\n"+ex.getMessage());
\r
42 JPredThread jthread = new JPredThread(seq);
\r
44 ImageTwirler thread = new ImageTwirler();
\r
51 ImageIcon[] imageIcon;
\r
53 public ImageTwirler()
\r
55 imageIcon = new ImageIcon[9];
\r
56 for (int i = 0; i < 9; i++)
\r
58 java.net.URL url = getClass().getResource("/images/dna" + (i + 1) +
\r
61 imageIcon[i] = new ImageIcon(url);
\r
67 while (jobsRunning > 0)
\r
74 outputFrame.setFrameIcon(imageIcon[imageIndex]);
\r
75 outputFrame.setTitle("JNet Secondary Structure Prediction : " +
\r
76 jobsRunning + " jobs running.");
\r
79 catch (Exception ex)
\r
89 String OutputHeader;
\r
90 ext.vamsas.Secstructpred result;
\r
91 ext.vamsas.Sequence sequence;
\r
93 boolean jobComplete = false;
\r
94 int allowedServerExceptions = 3; // thread dies if too many exceptions.
\r
95 JPredThread(SequenceI seq)
\r
97 OutputHeader = output.getText();
\r
98 this.sequence = new ext.vamsas.Sequence();
\r
99 this.sequence.setId(seq.getName());
\r
100 this.sequence.setSeq(AlignSeq.extractGaps("-. ",seq.getSequence()));
\r
108 while (!jobComplete
\r
109 && (allowedServerExceptions > 0))
\r
113 result = server.getpredict(jobId);
\r
115 if (result.getOutput().indexOf("Job") != 0)
\r
118 jobComplete = true;
\r
123 output.setText(OutputHeader + "\n" + result.getOutput());
\r
125 Thread.sleep(5000);
\r
126 // System.out.println("I'm alive "+seqid+" "+jobid);
\r
129 catch (Exception ex)
\r
131 allowedServerExceptions--;
\r
132 String msg = output.getText();
\r
133 output.setText(msg + "\nJPredWS Server exception!\n" + ex.getMessage());
\r
142 jobId = server.predict(sequence);
\r
143 System.out.println(jobId);
\r
145 catch (Exception e)
\r
147 System.out.println("JPredWS Client: Failed to submit the prediction\n" +
\r
148 e.toString() + "\n");
\r
149 e.printStackTrace();
\r
155 output.setText(OutputHeader + result.getOutput());
\r
157 // JPredFile prediction = new JPredFile("C:/JalviewX/files/jpred.txt", "File");
\r
158 JPredFile prediction=new JPredFile(result.getOutput(), "Paste");
\r
159 SequenceI[] preds = prediction.getSeqsAsArray();
\r
160 Alignment al = new Alignment(preds);
\r
162 AlignmentAnnotation annot;
\r
163 Annotation [] annotations = null;
\r
165 // Rename the query sequence
\r
166 while (i < preds.length)
\r
168 String id = preds[i].getName().toUpperCase();
\r
169 if(id.startsWith("LUPAS") || id.startsWith("JNET"))
\r
171 annotations = new Annotation[al.getWidth()];
\r
173 if(id.equals("JNETPRED")
\r
174 || id.equals("JNETPSSM")
\r
175 || id.equals("JNETFREQ")
\r
176 || id.equals("JNETHMM")
\r
177 || id.equals("JNETALIGN"))
\r
179 for (int j = 0; j < al.getWidth(); j++)
\r
180 annotations[j] = new Annotation("", "", preds[i].getCharAt(j), 0);
\r
182 else if(id.equals("JNETCONF"))
\r
184 for (int j = 0; j < al.getWidth(); j++)
\r
186 float value = Float.parseFloat(preds[i].getCharAt(j)+"");
\r
187 annotations[j] = new Annotation(preds[i].getCharAt(j)+"", "",preds[i].getCharAt(j),value);
\r
192 for (int j = 0; j < al.getWidth(); j++)
\r
193 annotations[j] = new Annotation(preds[i].getCharAt(j)+"", "", ' ', 0);
\r
196 if(id.equals("JNETCONF"))
\r
197 annot = new AlignmentAnnotation(preds[i].getName(),
\r
199 annotations,0f,10f,1);
\r
201 else annot = new AlignmentAnnotation(preds[i].getName(),
\r
204 al.addAnnotation(annot);
\r
205 al.deleteSequence(preds[i]);
\r
210 Hashtable scores = prediction.Scores;
\r
212 Vector values = (Vector)scores.get("JNETPROPH");
\r
213 annotations = new Annotation[al.getWidth()];
\r
214 for (int j = 0; j < al.getWidth(); j++)
\r
216 float value = Float.parseFloat(values.get(j).toString());
\r
217 annotations[j] = new Annotation("", value+"",' ',value);
\r
219 annot = new AlignmentAnnotation("Jnetproph", "Jpred Output", annotations, 0f,1f,1);
\r
220 al.addAnnotation(annot);
\r
222 values = (Vector)scores.get("JNETPROPB");
\r
223 annotations = new Annotation[al.getWidth()];
\r
224 for (int j = 0; j < al.getWidth(); j++)
\r
226 float value = Float.parseFloat(values.get(j).toString());
\r
227 annotations[j] = new Annotation("", value+"",' ',value);
\r
229 annot = new AlignmentAnnotation("JnetpropB", "Jpred Output", annotations, 0f,1f,1);
\r
230 al.addAnnotation(annot);
\r
232 values = (Vector)scores.get("JNETPROPC");
\r
233 annotations = new Annotation[al.getWidth()];
\r
234 for (int j = 0; j < al.getWidth(); j++)
\r
236 float value = Float.parseFloat(values.get(j).toString());
\r
237 annotations[j] = new Annotation("", value+"",' ',value);
\r
239 annot = new AlignmentAnnotation("JnetpropC", "Jpred Output", annotations, 0f,1f,1);
\r
240 al.addAnnotation(annot);
\r
244 AlignFrame af = new AlignFrame(al);
\r
247 /* JBPNote - need to set correct style of display for the secstrpred alignment object.
\r
248 af.clustalColour.setSelected(true);
\r
249 af.clustalColour_actionPerformed(null);
\r
251 Desktop.addInternalFrame(af,
\r
252 "JNet Prediction for sequence ",
\r
254 }catch(Exception ex){ex.printStackTrace();}
\r