From aafe9bfd2c035d1683c42d767ff0a6b9071fa081 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 14 Apr 2005 15:05:08 +0000 Subject: [PATCH] use webservice info --- src/jalview/io/JPredClient.java | 97 ++++++++++++--------------------------- 1 file changed, 29 insertions(+), 68 deletions(-) diff --git a/src/jalview/io/JPredClient.java b/src/jalview/io/JPredClient.java index c403730..3ebc1f0 100755 --- a/src/jalview/io/JPredClient.java +++ b/src/jalview/io/JPredClient.java @@ -14,103 +14,56 @@ import ext.vamsas.*; public class JPredClient { - - JInternalFrame outputFrame = new JInternalFrame(); - CutAndPasteTransfer output = new CutAndPasteTransfer(false); int jobsRunning = 0; ext.vamsas.JpredSoapBindingStub server; + WebserviceInfo wsInfo; public JPredClient(SequenceI[] msf) { - SequenceI seq = msf[0]; - output.formatForOutput(); - outputFrame.setContentPane(output); + wsInfo = new WebserviceInfo("JNet secondary structure prediction job", + "\"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\"."); - output.setText("Job details for MSA based prediction on sequence :\nName : " + SequenceI seq = msf[0]; + wsInfo.setProgressText("Job details for MSA based prediction on sequence :\nName : " + seq.getName() + "\nSequence : " + AlignSeq.extractGaps("-. ",seq.getSequence()) + "\n"); - Desktop.addInternalFrame(outputFrame, - "JNet secondary structure prediction job", 800, - 300); + JPredWSServiceLocator loc = new JPredWSServiceLocator(); // Default try { this.server = (JpredSoapBindingStub) loc.getjpred(); // JBPNote will be set from properties } catch (Exception ex) { - output.setText("Serious! JPred Service location failed\nfor URL :" + wsInfo.setProgressText("Serious! JPred Service location failed\nfor URL :" +loc.getjpredAddress()+"\n"+ex.getMessage()); } JPredThread jthread = new JPredThread(msf); jthread.start(); - ImageTwirler thread = new ImageTwirler(); - thread.start(); } public JPredClient(SequenceI seq) { - output.formatForOutput(); - outputFrame.setContentPane(output); + wsInfo = new WebserviceInfo("JNet secondary structure prediction job", + "\"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\"."); - output.setText("Job details for prediction on sequence :\nName : " + + wsInfo.setProgressText("Job details for prediction on sequence :\nName : " + seq.getName() + "\nSequence : " + AlignSeq.extractGaps("-. ",seq.getSequence()) + "\n"); - Desktop.addInternalFrame(outputFrame, - "JNet secondary structure prediction job", 800, - 300); JPredWSServiceLocator loc = new JPredWSServiceLocator(); // Default try { this.server = (JpredSoapBindingStub) loc.getjpred(); // JBPNote will be set from properties } catch (Exception ex) { - output.setText("Serious! JPred Service location failed\nfor URL :" + wsInfo.setProgressText("Serious! JPred Service location failed\nfor URL :" +loc.getjpredAddress()+"\n"+ex.getMessage()); } JPredThread jthread = new JPredThread(seq); jthread.start(); - ImageTwirler thread = new ImageTwirler(); - thread.start(); } - class ImageTwirler - extends Thread - { - ImageIcon[] imageIcon; - int imageIndex = 0; - public ImageTwirler() - { - imageIcon = new ImageIcon[9]; - for (int i = 0; i < 9; i++) - { - java.net.URL url = getClass().getResource("/images/dna" + (i + 1) + - ".gif"); - if (url != null) - imageIcon[i] = new ImageIcon(url); - } - } - - public void run() - { - while (jobsRunning > 0) - { - try - { - Thread.sleep(100); - imageIndex++; - imageIndex %= 9; - outputFrame.setFrameIcon(imageIcon[imageIndex]); - outputFrame.setTitle("JNet Secondary Structure Prediction : " + - jobsRunning + " jobs running."); - - } - catch (Exception ex) - {} - - } - } - } class JPredThread extends Thread @@ -124,7 +77,7 @@ public class JPredClient int allowedServerExceptions = 3; // thread dies if too many exceptions. JPredThread(SequenceI seq) { - OutputHeader = output.getText(); + OutputHeader = wsInfo.getProgressText(); this.sequence = new ext.vamsas.Sequence(); this.sequence.setId(seq.getName()); this.sequence.setSeq(AlignSeq.extractGaps("-. ",seq.getSequence())); @@ -132,7 +85,7 @@ public class JPredClient JPredThread(SequenceI[] msf) { - OutputHeader = output.getText(); + OutputHeader = wsInfo.getProgressText(); this.sequence = new ext.vamsas.Sequence(); this.sequence.setId(msf[0].getName()); this.sequence.setSeq(AlignSeq.extractGaps("-. ",msf[0].getSequence())); @@ -147,13 +100,17 @@ public class JPredClient StartJob(); - while (!jobComplete - && (allowedServerExceptions > 0)) + while (!jobComplete && (allowedServerExceptions > 0)) { try { result = server.getresult(jobId); + if( result.isRunning() ) + wsInfo.setStatus(WebserviceInfo.STATE_RUNNING); + else if( result.isQueued() ) + wsInfo.setStatus(WebserviceInfo.STATE_QUEUING); + if (result.isFinished()) { parseResult(); @@ -162,21 +119,25 @@ public class JPredClient } else { - output.setText(OutputHeader + "\n" + result.getStatus()); + wsInfo.setProgressText(OutputHeader + "\n" + result.getStatus()); if (! (result.isJobFailed() || result.isServerError())) { Thread.sleep(5000); - // System.out.println("I'm alive "+seqid+" "+jobid); + // System.out.println("I'm alive "+seqid+" "+jobid); } } } catch (Exception ex) { allowedServerExceptions--; - String msg = output.getText(); - output.setText(msg + "\nJPredWS Server exception!\n" + ex.getMessage()); + wsInfo.appendProgressText("\nJPredWS Server exception!\n" + ex.getMessage()); } } + + if (! (result.isJobFailed() || result.isServerError())) + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK); + else + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR); } void StartJob() @@ -225,7 +186,7 @@ public class JPredClient if (result.getAligfile()!=null) { OutputHeader += "\n"+result.getAligfile(); } - output.setText(OutputHeader); + wsInfo.setProgressText(OutputHeader); try { // JPredFile prediction = new JPredFile("C:/JalviewX/files/jpred.txt", "File"); jalview.io.JPredFile prediction = new jalview.io.JPredFile(result.getPredfile(), "Paste"); -- 1.7.10.2