import ext.vamsas.*;\r
\r
\r
-public class JPredClient\r
+public class JPredClient extends WSClient\r
{\r
- int jobsRunning = 0;\r
- ext.vamsas.JpredSoapBindingStub server;\r
- WebserviceInfo wsInfo;\r
-\r
- public JPredClient(SequenceI[] msf)\r
+ ext.vamsas.JPredWS server;\r
+ String altitle = "";\r
+ java.util.Hashtable SequenceInfo = null;\r
+ private void setWebService() {\r
+ WebServiceName = "JNetWS";\r
+ WebServiceJobTitle = "JNet secondary structure prediction";\r
+ WebServiceReference="\"Cuff J. A and Barton G.J (1999) Application of enhanced "\r
+ + "multiple sequence alignment profiles to improve protein secondary structure prediction, "\r
+ + "Proteins 40:502-511\".";\r
+ WsURL="http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred";\r
+ }\r
+ public JPredClient(String title, SequenceI[] msf)\r
{\r
- wsInfo = new WebserviceInfo("JNet secondary structure prediction job",\r
- "\"Cuff J. A and Barton G.J (1999) Application of enhanced multiple sequence alignment profiles to improve protein secondary structure prediction, Proteins 40:502-511\".");\r
-\r
+ setWebService();\r
+ wsInfo = new WebserviceInfo(WebServiceJobTitle, WebServiceReference);\r
SequenceI seq = msf[0];\r
- wsInfo.setProgressText("Job details for MSA based prediction on sequence :\nName : "\r
- + seq.getName() + "\nSequence : "\r
+ altitle = "JNet prediction on "+seq.getName()+" using alignment from "+title;\r
+\r
+ wsInfo.setProgressText("Job details for MSA based prediction ("+title+") on sequence :\n>"\r
+ + seq.getName() + "\n"\r
+ AlignSeq.extractGaps("-. ",seq.getSequence()) + "\n");\r
\r
+ SequenceInfo = jalview.analysis.SeqsetUtils.SeqCharacterHash(seq);\r
\r
JPredWSServiceLocator loc = new JPredWSServiceLocator(); // Default\r
+ // JBPNote url will be set from properties\r
try {\r
- this.server = (JpredSoapBindingStub) loc.getjpred(); // JBPNote will be set from properties\r
+ this.server = loc.getjpred(new java.net.URL(WsURL));\r
}\r
catch (Exception ex) {\r
- wsInfo.setProgressText("Serious! JPred Service location failed\nfor URL :"\r
- +loc.getjpredAddress()+"\n"+ex.getMessage());\r
+ JOptionPane.showMessageDialog(Desktop.desktop, "The Secondary Structure Prediction Service named "\r
+ +WebServiceName+" at "+WsURL+" couldn't be located.",\r
+ "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);\r
+ wsInfo.setProgressText("Serious! "+WebServiceName+" Service location failed\nfor URL :"\r
+ +WsURL+"\n"+ex.getMessage());\r
}\r
\r
JPredThread jthread = new JPredThread(msf);\r
jthread.start();\r
}\r
\r
- public JPredClient(SequenceI seq)\r
+ public JPredClient(String title, SequenceI seq)\r
{\r
- wsInfo = new WebserviceInfo("JNet secondary structure prediction job",\r
- "\"Cuff J. A and Barton G.J (1999) Application of enhanced multiple sequence alignment profiles to improve protein secondary structure prediction, Proteins 40:502-511\".");\r
-\r
-\r
- wsInfo.setProgressText("Job details for prediction on sequence :\nName : "\r
- + seq.getName() + "\nSequence : " + AlignSeq.extractGaps("-. ",seq.getSequence()) + "\n");\r
+ setWebService();\r
+ wsInfo = new WebserviceInfo(WebServiceJobTitle, WebServiceReference);\r
+ wsInfo.setProgressText("Job details for prediction on sequence :\n>"\r
+ + seq.getName() + "\n" + AlignSeq.extractGaps("-. ",seq.getSequence()) + "\n");\r
+ altitle = "JNet prediction for sequence "+seq.getName()+" from "+title;\r
+ SequenceInfo = jalview.analysis.SeqsetUtils.SeqCharacterHash(seq);\r
\r
JPredWSServiceLocator loc = new JPredWSServiceLocator(); // Default\r
try {\r
- this.server = (JpredSoapBindingStub) loc.getjpred(); // JBPNote will be set from properties\r
+ this.server = loc.getjpred(new java.net.URL(WsURL)); // JBPNote will be set from properties\r
+ ((JpredSoapBindingStub) this.server).setTimeout(60000); // one minute stub\r
}\r
catch (Exception ex) {\r
- wsInfo.setProgressText("Serious! JPred Service location failed\nfor URL :"\r
- +loc.getjpredAddress()+"\n"+ex.getMessage());\r
+ JOptionPane.showMessageDialog(Desktop.desktop, "The Secondary Structure Prediction Service named "\r
+ +WebServiceName+" at "+WsURL+" couldn't be located.",\r
+ "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);\r
+ wsInfo.setProgressText("Serious! "+WebServiceName+" Service location failed\nfor URL :"\r
+ +WsURL+"\n"+ex.getMessage());\r
+ wsInfo.setStatus(wsInfo.STATE_STOPPED_SERVERERROR);\r
}\r
\r
JPredThread jthread = new JPredThread(seq);\r
this.sequence = new ext.vamsas.Sequence();\r
this.sequence.setId(msf[0].getName());\r
this.sequence.setSeq(AlignSeq.extractGaps("-. ",msf[0].getSequence()));\r
- jalview.io.MSFfile mwrite = new jalview.io.MSFfile();\r
+ jalview.io.PileUpfile mwrite = new jalview.io.PileUpfile();\r
this.msa = new ext.vamsas.Msfalignment();\r
msa.setMsf(mwrite.print(msf));\r
}\r
{\r
try\r
{\r
- result = server.getresult(jobId);\r
+ if ((result = server.getresult(jobId))==null)\r
+ throw(new Exception("Timed out when communicating with server\nTry again later.\n"));\r
\r
if( result.isRunning() )\r
wsInfo.setStatus(WebserviceInfo.STATE_RUNNING);\r
wsInfo.setProgressText(OutputHeader + "\n" + result.getStatus());\r
if (! (result.isJobFailed() || result.isServerError()))\r
{\r
- Thread.sleep(5000);\r
+ try\r
+ {\r
+ Thread.sleep(5000);\r
+ }\r
+ catch (InterruptedException ex1)\r
+ {\r
+ }\r
// System.out.println("I'm alive "+seqid+" "+jobid);\r
} else {\r
wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR);\r
{\r
allowedServerExceptions--;\r
wsInfo.appendProgressText("\nJPredWS Server exception!\n" + ex.getMessage());\r
+ try\r
+ {\r
+ if (allowedServerExceptions>0)\r
+ Thread.sleep(5000);\r
+ }\r
+ catch (InterruptedException ex1)\r
+ {\r
+ }\r
}\r
}\r
\r
} else {\r
jobId = server.predict(sequence);\r
}\r
- System.out.println(jobId);\r
+ if (jobId!=null) {\r
+ if (jobId.startsWith("Broken")) {\r
+ throw new Exception("Submission " + jobId);\r
+ } else {\r
+ System.out.println(WsURL+" Job Id '"+jobId+"'");\r
+ }\r
+ } else {\r
+ throw new Exception("Server timed out - try again later\n");\r
+\r
+ }\r
}\r
catch (Exception e)\r
{\r
- System.out.println("JPredWS Client: Failed to submit the prediction\n" +\r
- e.toString() + "\n");\r
- e.printStackTrace();\r
+ wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);\r
+ allowedServerExceptions=0;\r
+ jobComplete=false;\r
+ wsInfo.appendProgressText("Failed to submit the prediction: "+e.toString()+"\nJust close the window\n");\r
+ System.err.println("JPredWS Client: Failed to submit the prediction\n" +\r
+ e.toString() + "\n");\r
+ // e.printStackTrace(); TODO: JBPNote DEBUG\r
}\r
}\r
\r
FirstSeq = prediction.getQuerySeqPosition();\r
}\r
\r
+ if (!jalview.analysis.SeqsetUtils.SeqCharacterUnhash(al.getSequenceAt(FirstSeq), SequenceInfo))\r
+ throw (new Exception("Couldn't recover sequence properties for JNet Query sequence!"));\r
+\r
AlignmentAnnotation annot;\r
Annotation [] annotations = null;\r
int i = 0;\r
\r
\r
int[] gapmap = al.getSequenceAt(FirstSeq).gapMap();\r
+\r
if (gapmap.length!=width) {\r
- throw (new Exception("Jpred Client Error\nNumber of residues in supposed query sequence :\n"\r
+ throw (new Exception("Jnet Client Error\nNumber of residues in supposed query sequence :\n"\r
+al.getSequenceAt(FirstSeq).getName()+"\n"\r
+al.getSequenceAt(FirstSeq).getSequence()\r
+"\nDiffer from number of prediction sites in \n"+result.getPredfile()+"\n"));\r
\r
\r
Desktop.addInternalFrame(af,\r
- "JNet Prediction for sequence ",\r
+ altitle,\r
AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT);\r
}catch(Exception ex){ex.printStackTrace();}\r
\r