import jalview.analysis.*;\r
import jalview.datamodel.*;\r
import jalview.gui.*;\r
+import jalview.io.FormatAdapter;\r
\r
public class JPredClient\r
extends WSClient\r
{\r
- ext.vamsas.JPredWS server;\r
+ ext.vamsas.Jpred server;\r
String altitle = "";\r
java.util.Hashtable SequenceInfo = null;\r
public JPredClient(ext.vamsas.ServiceHandle sh, String title, SequenceI seq) {\r
wsInfo = setWebService();\r
\r
SequenceI seq = msf[0];\r
+\r
altitle = "JNet prediction on " + seq.getName() +\r
" using alignment from " + title;\r
\r
title + ") on sequence :\n>" + seq.getName() + "\n" +\r
AlignSeq.extractGaps("-. ", seq.getSequence()) +\r
"\n");\r
+ SequenceI aln[] = new SequenceI[msf.length];\r
+ for (int i=0,j=msf.length; i<j;i++) {\r
+ aln[i] = new jalview.datamodel.Sequence(msf[i]);\r
+ }\r
\r
- SequenceInfo = jalview.analysis.SeqsetUtils.SeqCharacterHash(seq);\r
+ SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln, true);\r
\r
if (!locateWebService())\r
{\r
return;\r
}\r
\r
- JPredThread jthread = new JPredThread(msf);\r
+ JPredThread jthread = new JPredThread(aln);\r
jthread.start();\r
}\r
\r
\r
private boolean locateWebService()\r
{\r
- JPredWSServiceLocator loc = new JPredWSServiceLocator(); // Default\r
+ ext.vamsas.JpredServiceLocator loc = new JpredServiceLocator(); // Default\r
\r
try\r
{\r
" Service location failed\nfor URL :" + WsURL +\r
"\n" +\r
ex.getMessage());\r
- wsInfo.setStatus(wsInfo.STATE_STOPPED_SERVERERROR);\r
+ wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);\r
\r
return false;\r
}\r
extends Thread\r
{\r
String OutputHeader;\r
- ext.vamsas.JpredResult result;\r
- ext.vamsas.Sequence sequence;\r
- ext.vamsas.Msfalignment msa;\r
+ vamsas.objects.simple.JpredResult result;\r
+ vamsas.objects.simple.Sequence sequence;\r
+ vamsas.objects.simple.Msfalignment msa;\r
String jobId;\r
boolean jobComplete = false;\r
int allowedServerExceptions = 3; // thread dies if too many exceptions.\r
JPredThread(SequenceI seq)\r
{\r
OutputHeader = wsInfo.getProgressText();\r
- this.sequence = new ext.vamsas.Sequence();\r
+ this.sequence = new vamsas.objects.simple.Sequence();\r
this.sequence.setId(seq.getName());\r
this.sequence.setSeq(AlignSeq.extractGaps("-. ", seq.getSequence()));\r
}\r
JPredThread(SequenceI[] msf)\r
{\r
OutputHeader = wsInfo.getProgressText();\r
- this.sequence = new ext.vamsas.Sequence();\r
+ this.sequence = new vamsas.objects.simple.Sequence();\r
this.sequence.setId(msf[0].getName());\r
this.sequence.setSeq(AlignSeq.extractGaps("-. ",\r
msf[0].getSequence()));\r
\r
- jalview.io.PileUpfile mwrite = new jalview.io.PileUpfile();\r
- this.msa = new ext.vamsas.Msfalignment();\r
- msa.setMsf(mwrite.print(msf));\r
+ this.msa = new vamsas.objects.simple.Msfalignment();\r
+ jalview.io.PileUpfile pileup = new jalview.io.PileUpfile();\r
+ msa.setMsf(pileup.print(msf));\r
}\r
\r
public void run()\r
throw (new Exception(\r
"Timed out when communicating with server\nTry again later.\n"));\r
}\r
-\r
+ if (result.getState()==0)\r
+ jalview.bin.Cache.log.debug("Finished "+jobId);\r
if (result.isRunning())\r
{\r
wsInfo.setStatus(WebserviceInfo.STATE_RUNNING);\r
}\r
- else if (result.isQueued())\r
+ if (result.isQueued())\r
{\r
wsInfo.setStatus(WebserviceInfo.STATE_QUEUING);\r
}\r
\r
+ wsInfo.setProgressText(OutputHeader + "\n" +\r
+ result.getStatus());\r
+\r
if (result.isFinished())\r
{\r
+\r
parseResult();\r
jobComplete = true;\r
jobsRunning--;\r
- }\r
- else\r
- {\r
- wsInfo.setProgressText(OutputHeader + "\n" +\r
- result.getStatus());\r
-\r
+ } else {\r
+ // catch exceptions\r
if (! (result.isJobFailed() || result.isServerError()))\r
{\r
try\r
else\r
{\r
wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR);\r
+ jobsRunning--;\r
+ jobComplete = true;\r
}\r
}\r
}\r
{\r
}\r
}\r
+ catch (OutOfMemoryError er)\r
+ {\r
+ jobComplete = true;\r
+ wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR);\r
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+ "Out of memory handling result!!"\r
+ +\r
+ "\nSee help files for increasing Java Virtual Machine memory."\r
+ , "Out of memory",\r
+ JOptionPane.WARNING_MESSAGE);\r
+ System.out.println("JPredClient: "+er);\r
+ System.gc();\r
+ }\r
}\r
-\r
- if (! (result.isJobFailed() || result.isServerError()))\r
- {\r
- wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK);\r
- }\r
- else\r
- {\r
- wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR);\r
- }\r
+ if (result!=null)\r
+ if (! (result.isJobFailed() || result.isServerError()))\r
+ {\r
+ wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK);\r
+ }\r
+ else\r
+ {\r
+ wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR);\r
+ }\r
}\r
\r
void StartJob()\r
}\r
catch (Exception e)\r
{\r
- wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);\r
- allowedServerExceptions = 0;\r
- jobComplete = false;\r
-\r
- wsInfo.appendProgressText("Failed to submit the prediction.\n"\r
- +\r
- "It is most likely that there is a problem with the server.\n"\r
- + "Just close the window\n");\r
- System.err.println(\r
- "JPredWS Client: Failed to submit the prediction (Probably a server error - see below)\n" +\r
- e.toString() + "\n");\r
-\r
- // e.printStackTrace(); TODO: JBPNote DEBUG\r
+ if (e.getMessage().indexOf("Exception")>-1) {\r
+ wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);\r
+ wsInfo.setProgressText(\r
+ "Failed to submit the prediction. (Just close the window)\n"\r
+ +\r
+ "It is most likely that there is a problem with the server.\n");\r
+ System.err.println(\r
+ "JPredWS Client: Failed to submit the prediction. Quite possibly because of a server error - see below)\n" +\r
+ e.getMessage() + "\n");\r
+\r
+ jalview.bin.Cache.log.warn("Server Exception",e);\r
+ } else {\r
+ wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR);\r
+ // JBPNote - this could be a popup informing the user of the problem.\r
+ wsInfo.setProgressText("Failed to submit the prediction:\n"\r
+ +e.getMessage()+\r
+ wsInfo.getProgressText());\r
+\r
+ jalview.bin.Cache.log.debug("Failed Submission",e);\r
+\r
+ }\r
+ allowedServerExceptions = -1;\r
+ jobComplete = true;\r
+\r
}\r
}\r
\r
\r
\r
- private void addFloatAnnotations(Alignment al, int[] gapmap,\r
+ /* private void addFloatAnnotations(Alignment al, int[] gapmap,\r
Vector values, String Symname,\r
String Visname, float min,\r
float max, int winLength)\r
\r
al.addAnnotation(new AlignmentAnnotation(Symname, Visname,\r
annotations, min, max, winLength));\r
- }\r
+ }*/\r
\r
void parseResult()\r
{\r
OutputHeader += ("\n" + result.getAligfile());\r
}\r
\r
- wsInfo.setProgressText(OutputHeader);\r
+ wsInfo.setProgressText(OutputHeader+"Parsing...");\r
\r
try\r
{\r
+ jalview.bin.Cache.log.debug("Parsing output from JNet job.");\r
// JPredFile prediction = new JPredFile("C:/JalviewX/files/jpred.txt", "File");\r
jalview.io.JPredFile prediction = new jalview.io.JPredFile(result.\r
getPredfile(),\r
"Paste");\r
SequenceI[] preds = prediction.getSeqsAsArray();\r
+ jalview.bin.Cache.log.debug("Got prediction profile.");\r
Alignment al;\r
int FirstSeq; // the position of the query sequence in Alignment al\r
boolean noMsa = true; // set if no MSA has been returned by JPred\r
\r
if ( (this.msa != null) && (result.getAligfile() != null))\r
{\r
+ jalview.bin.Cache.log.debug("Getting associated alignment.");\r
// we ignore the returned alignment if we only predicted on a single sequence\r
String format = jalview.io.IdentifyFile.Identify(result.getAligfile(),\r
"Paste");\r
\r
if (jalview.io.FormatAdapter.formats.contains(format))\r
{\r
- al = new Alignment(jalview.io.FormatAdapter.readFile(\r
+ al = new Alignment(new FormatAdapter().readFile(\r
result.getAligfile(), "Paste", format));\r
+ SequenceI sqs[] = new SequenceI[al.getHeight()];\r
+ for (int i=0, j=al.getHeight(); i<j; i++) {\r
+ sqs[i] = al.getSequenceAt(i);\r
+ }\r
+ if (!jalview.analysis.SeqsetUtils.deuniquify(\r
+ (Hashtable) SequenceInfo,sqs))\r
+ {\r
+ throw (new Exception(\r
+ "Couldn't recover sequence properties for alignment."));\r
+ }\r
+\r
noMsa = false;\r
FirstSeq = 0;\r
}\r
{\r
al = new Alignment(preds);\r
FirstSeq = prediction.getQuerySeqPosition();\r
+ if (!jalview.analysis.SeqsetUtils.SeqCharacterUnhash(\r
+ al.getSequenceAt(FirstSeq), SequenceInfo))\r
+ {\r
+ throw (new Exception(\r
+ "Couldn't recover sequence properties for JNet Query sequence!"));\r
+ }\r
}\r
\r
- if (!jalview.analysis.SeqsetUtils.SeqCharacterUnhash(\r
- al.getSequenceAt(FirstSeq), SequenceInfo))\r
- {\r
- throw (new Exception(\r
- "Couldn't recover sequence properties for JNet Query sequence!"));\r
- }\r
\r
AlignmentAnnotation annot;\r
Annotation[] annotations = null;\r
{\r
annot = new AlignmentAnnotation(preds[i].getName(),\r
"JNet Output", annotations, 0f,\r
- 10f, 1);\r
+ 10f,\r
+ AlignmentAnnotation.BAR_GRAPH);\r
}\r
else\r
{\r
i++;\r
}\r
\r
- Hashtable scores = prediction.getScores();\r
+ //Hashtable scores = prediction.getScores();\r
\r
/* addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPH"),\r
"JnetpropH", "Jnet Helix Propensity", 0f,1f,1);\r
addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPC"),\r
"JnetpropC", "Jnet Coil Propensity", 0f,1f,1);\r
*/\r
+\r
+ wsInfo.setProgressText(OutputHeader);\r
+ jalview.bin.Cache.log.debug("Finished parsing output.");\r
AlignFrame af = new AlignFrame(al);\r
\r
Desktop.addInternalFrame(af, altitle,\r
}\r
catch (Exception ex)\r
{\r
- ex.printStackTrace();\r
+ jalview.bin.Cache.log.warn("Exception whilst parsing JNet style secondary structure prediction.",ex);\r
}\r
}\r
}\r