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(result.getOutput(), "Paste");
\r
158 SequenceI[] preds = prediction.getSeqsAsArray();
\r
160 // Rename the query sequence
\r
161 while (i<preds.length && !preds[i].getName().equals("QUERY")) {
\r
164 if (i<preds.length) {
\r
165 preds[i].setName(sequence.getId());
\r
167 AlignFrame af = new AlignFrame(new Alignment(preds));
\r
168 /* JBPNote - need to set correct style of display for the secstrpred alignment object.
\r
169 af.clustalColour.setSelected(true);
\r
170 af.clustalColour_actionPerformed(null);
\r
172 Desktop.addInternalFrame(af, "JNet Prediction for sequence "+sequence.getId(),
\r
175 catch (Exception e) {
\r
176 output.setText(output.getText()+"\nError! File did not parse correctly\n"+e.getMessage()+"\n");
\r
177 e.printStackTrace();
\r