From ae0f884be559f2f706945b379d110e9c60642364 Mon Sep 17 00:00:00 2001 From: jprocter Date: Wed, 17 Aug 2005 16:31:27 +0000 Subject: [PATCH] Client threads for discovered web services. --- src/jalview/ws/Discoverer.java | 2 +- src/jalview/ws/JPredClient.java | 28 +- src/jalview/ws/MsaWSClient.java | 771 +++++++++++++++++++------------------- src/jalview/ws/MsaWServices.java | 67 ---- src/jalview/ws/WSClient.java | 32 +- 5 files changed, 446 insertions(+), 454 deletions(-) delete mode 100755 src/jalview/ws/MsaWServices.java diff --git a/src/jalview/ws/Discoverer.java b/src/jalview/ws/Discoverer.java index bc2f613..40d29e7 100755 --- a/src/jalview/ws/Discoverer.java +++ b/src/jalview/ws/Discoverer.java @@ -98,7 +98,7 @@ public class Discoverer try { - reallyDiscoverServices = jalview.bin.Cache.getDefault("DISCOVER_SERVICES", false); + reallyDiscoverServices = jalview.bin.Cache.getDefault("DISCOVERY_START", false); if (reallyDiscoverServices) { RootServiceURL = new java.net.URL( diff --git a/src/jalview/ws/JPredClient.java b/src/jalview/ws/JPredClient.java index e6f3899..c7508df 100755 --- a/src/jalview/ws/JPredClient.java +++ b/src/jalview/ws/JPredClient.java @@ -33,10 +33,27 @@ public class JPredClient ext.vamsas.JPredWS server; String altitle = ""; java.util.Hashtable SequenceInfo = null; + public JPredClient(ext.vamsas.ServiceHandle sh, String title, SequenceI seq) { + wsInfo = setWebService(sh); + startJPredClient(title, seq); + } + public JPredClient(ext.vamsas.ServiceHandle sh, String title, SequenceI[] msa) { + wsInfo = setWebService(sh); + startJPredClient(title, msa); + } + + public JPredClient(String title, SequenceI[] msf) { + startJPredClient(title, msf); + } - public JPredClient(String title, SequenceI[] msf) + public JPredClient(String title, SequenceI seq) { + startJPredClient(title, seq); + } + + private void startJPredClient(String title, SequenceI[] msf) { - wsInfo = setWebService(); + if (wsInfo==null) + wsInfo = setWebService(); SequenceI seq = msf[0]; altitle = "JNet prediction on " + seq.getName() + @@ -58,9 +75,10 @@ public class JPredClient jthread.start(); } - public JPredClient(String title, SequenceI seq) + public void startJPredClient(String title, SequenceI seq) { - wsInfo = setWebService(); + if (wsInfo==null) + wsInfo = setWebService(); wsInfo.setProgressText("Job details for prediction on sequence :\n>" + seq.getName() + "\n" + AlignSeq.extractGaps("-. ", seq.getSequence()) + @@ -284,6 +302,8 @@ public class JPredClient } } + + private void addFloatAnnotations(Alignment al, int[] gapmap, Vector values, String Symname, String Visname, float min, diff --git a/src/jalview/ws/MsaWSClient.java b/src/jalview/ws/MsaWSClient.java index 0d5c22e..7f754e0 100755 --- a/src/jalview/ws/MsaWSClient.java +++ b/src/jalview/ws/MsaWSClient.java @@ -1,21 +1,21 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.ws; import ext.vamsas.*; @@ -30,439 +30,448 @@ import java.util.*; import javax.swing.*; - /** * DOCUMENT ME! * * @author $author$ * @version $Revision$ */ -public class MsaWSClient extends WSClient +public class MsaWSClient + extends WSClient { - /** - * server is a WSDL2Java generated stub for an archetypal MsaWSI service. - */ - ext.vamsas.MuscleWS server; - - /** - * Creates a new MsaWSClient object. - * - * @param MsaWSName DOCUMENT ME! - * @param altitle DOCUMENT ME! - * @param msa DOCUMENT ME! - * @param submitGaps DOCUMENT ME! - * @param preserveOrder DOCUMENT ME! - */ - public MsaWSClient(String MsaWSName, String altitle, SequenceI[] msa, - boolean submitGaps, boolean preserveOrder) + /** + * server is a WSDL2Java generated stub for an archetypal MsaWSI service. + */ + ext.vamsas.MuscleWS server; + + + /** + * Creates a new MsaWSClient object that uses a service + * given by an externally retrieved ServiceHandle + * + * @param sh service handle of type AbstractName(MsaWS) + * @param altitle DOCUMENT ME! + * @param msa DOCUMENT ME! + * @param submitGaps DOCUMENT ME! + * @param preserveOrder DOCUMENT ME! + */ + + public MsaWSClient(ext.vamsas.ServiceHandle sh, String altitle, SequenceI[] msa, + boolean submitGaps, boolean preserveOrder) + { + + if (!sh.getAbstractName().equals("MsaWS")) { - if (setWebService(MsaWSName) == false) - { - JOptionPane.showMessageDialog(Desktop.desktop, - "The Multiple Sequence Alignment Service named " + MsaWSName + - " is unknown", "Internal Jalview Error", - JOptionPane.WARNING_MESSAGE); + JOptionPane.showMessageDialog(Desktop.desktop, + "The Service called \n" + sh.getName() + + "\nis not a \nMultiple Sequence Alignment Service !", + "Internal Jalview Error", + JOptionPane.WARNING_MESSAGE); - return; - } + return; + } - wsInfo = new jalview.gui.WebserviceInfo(WebServiceJobTitle, - WebServiceReference); + if ((wsInfo = this.setWebService(sh))==null) + { + JOptionPane.showMessageDialog(Desktop.desktop, + "The Multiple Sequence Alignment Service named " + + sh.getName() + + " is unknown", "Internal Jalview Error", + JOptionPane.WARNING_MESSAGE); - if (!locateWebService()) - { - return; - } + return; + } + startMsaWSClient(altitle, msa, submitGaps, preserveOrder); + + } - wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment") + - " of " + altitle + "\nJob details\n"); - MsaWSThread musclethread = new MsaWSThread(WebServiceName + - " alignment of " + altitle, msa, submitGaps, preserveOrder); - wsInfo.setthisService(musclethread); - musclethread.start(); + private void startMsaWSClient(String altitle, SequenceI[] msa, + boolean submitGaps, boolean preserveOrder) + { + if (!locateWebService()) + { + return; } - // JBPNote Nasty object-global state setting methods shouldn't be allowed - private boolean setWebService(String MsaWSName) + wsInfo.setProgressText( ( (submitGaps) ? "Re-alignment" : "Alignment") + + " of " + altitle + "\nJob details\n"); + + MsaWSThread musclethread = new MsaWSThread(WebServiceName + + " alignment of " + altitle, msa, + submitGaps, preserveOrder); + wsInfo.setthisService(musclethread); + musclethread.start(); + } + + /** + * Initializes the server field with a valid service implementation. + * + * @return true if service was located. + */ + private boolean locateWebService() + { + // TODO: MuscleWS transmuted to generic MsaWS client + MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default + + try { - if (MsaWServices.info.containsKey(MsaWSName)) - { - WebServiceName = MsaWSName; + this.server = (MuscleWS) loc.getMuscleWS(new java.net.URL(WsURL)); + ( (MuscleWSSoapBindingStub)this.server).setTimeout(60000); // One minute timeout + } + catch (Exception ex) + { + wsInfo.setProgressText("Serious! " + WebServiceName + + " Service location failed\nfor URL :" + WsURL + + "\n" + + ex.getMessage()); + wsInfo.setStatus(wsInfo.ERROR); + ex.printStackTrace(); + + return false; + } - String[] wsinfo = (String[]) MsaWServices.info.get(MsaWSName); - WsURL = wsinfo[0]; - WebServiceJobTitle = wsinfo[1]; - WebServiceReference = wsinfo[2]; + loc.getEngine().setOption("axis", "1"); + + return true; + } + + protected class MsaWSThread + extends Thread implements WSClientI + { + String ServiceName = WebServiceName; + String OutputHeader; + vamsas.objects.simple.MsaResult result = null; + vamsas.objects.simple.SequenceSet seqs = new vamsas.objects.simple. + SequenceSet(); + Hashtable SeqNames = null; + boolean submitGaps = false; // and always store and recover sequence order + boolean preserveOrder = true; // and always store and recover sequence order + String jobId; + String alTitle; // name which will be used to form new alignment window. + int allowedServerExceptions = 3; // thread dies if too many exceptions. + boolean jobComplete = false; + + MsaWSThread(String title, SequenceI[] msa, boolean subgaps, + boolean presorder) + { + alTitle = title; + submitGaps = subgaps; + preserveOrder = presorder; + + OutputHeader = wsInfo.getProgressText(); + SeqNames = new Hashtable(); + + vamsas.objects.simple.Sequence[] seqarray = new vamsas.objects.simple. + Sequence[msa.length]; + + for (int i = 0; i < msa.length; i++) + { + String newname = jalview.analysis.SeqsetUtils.unique_name(i); + + // uniquify as we go + // TODO: JBPNote: this is a ubiquitous transformation - set of jalview seq objects to vamsas sequences with name preservation + SeqNames.put(newname, + jalview.analysis.SeqsetUtils.SeqCharacterHash(msa[i])); + seqarray[i] = new vamsas.objects.simple.Sequence(); + seqarray[i].setId(newname); + seqarray[i].setSeq( (submitGaps) ? msa[i].getSequence() + : AlignSeq.extractGaps( + jalview.util.Comparison.GapChars, + msa[i].getSequence())); + } + + this.seqs = new vamsas.objects.simple.SequenceSet(); + this.seqs.setSeqs(seqarray); + } - return true; - } - else - { - return false; - } + public boolean isCancellable() + { + return true; } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - private boolean locateWebService() + public void cancelJob() { - // TODO: MuscleWS transmuted to generic MsaWS client - MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default + if ( (jobId != null) && !jobId.equals("") && !jobComplete) + { + String cancelledMessage = ""; try { - this.server = (MuscleWS) loc.getMuscleWS(new java.net.URL(WsURL)); - ((MuscleWSSoapBindingStub) this.server).setTimeout(60000); // One minute timeout + vamsas.objects.simple.WsJobId cancelledJob = server.cancel(jobId); + + if (cancelledJob.getStatus() == 2) + { + // CANCELLED_JOB + cancelledMessage = "Job cancelled."; + wsInfo.setStatus(WebserviceInfo.STATE_CANCELLED_OK); + jobComplete = true; + jobsRunning--; + result = null; + } + else if (cancelledJob.getStatus() == 3) + { + // VALID UNSTOPPABLE JOB + cancelledMessage += + "Server cannot cancel this job. just close the window.\n"; + } + + if (cancelledJob.getJobId() != null) + { + cancelledMessage += ("[" + cancelledJob.getJobId() + + "]"); + } + + cancelledMessage += "\n"; } - catch (Exception ex) + catch (Exception exc) { - wsInfo.setProgressText("Serious! " + WebServiceName + - " Service location failed\nfor URL :" + WsURL + "\n" + - ex.getMessage()); - wsInfo.setStatus(wsInfo.ERROR); - ex.printStackTrace(); - - return false; + cancelledMessage += + ("\nProblems cancelling the job : Exception received...\n" + + exc + "\n"); + exc.printStackTrace(); } - loc.getEngine().setOption("axis", "1"); - - return true; - } - - protected class MsaWSThread extends Thread implements WSClientI - { - String ServiceName = WebServiceName; - String OutputHeader; - vamsas.objects.simple.MsaResult result = null; - vamsas.objects.simple.SequenceSet seqs = new vamsas.objects.simple.SequenceSet(); - Hashtable SeqNames = null; - boolean submitGaps = false; // and always store and recover sequence order - boolean preserveOrder = true; // and always store and recover sequence order - String jobId; - String alTitle; // name which will be used to form new alignment window. - int allowedServerExceptions = 3; // thread dies if too many exceptions. - boolean jobComplete = false; - - MsaWSThread(String title, SequenceI[] msa, boolean subgaps, - boolean presorder) + wsInfo.setProgressText(OutputHeader + cancelledMessage + "\n"); + } + else + { + if (!jobComplete) { - alTitle = title; - submitGaps = subgaps; - preserveOrder = presorder; - - OutputHeader = wsInfo.getProgressText(); - SeqNames = new Hashtable(); - - vamsas.objects.simple.Sequence[] seqarray = new vamsas.objects.simple.Sequence[msa.length]; - - for (int i = 0; i < msa.length; i++) - { - String newname = jalview.analysis.SeqsetUtils.unique_name(i); - - // uniquify as we go - // TODO: JBPNote: this is a ubiquitous transformation - set of jalview seq objects to vamsas sequences with name preservation - SeqNames.put(newname, - jalview.analysis.SeqsetUtils.SeqCharacterHash(msa[i])); - seqarray[i] = new vamsas.objects.simple.Sequence(); - seqarray[i].setId(newname); - seqarray[i].setSeq((submitGaps) ? msa[i].getSequence() - : AlignSeq.extractGaps( - jalview.util.Comparison.GapChars, msa[i].getSequence())); - } - - this.seqs = new vamsas.objects.simple.SequenceSet(); - this.seqs.setSeqs(seqarray); + wsInfo.setProgressText(OutputHeader + + "Server cannot cancel this job because it has not been submitted properly. just close the window.\n"); } + } + } - public boolean isCancellable() - { - return true; - } + public void run() + { + StartJob(); - public void cancelJob() + while (!jobComplete && (allowedServerExceptions > 0)) + { + try { - if ((jobId != null) && !jobId.equals("") && !jobComplete) + if ( (result = server.getResult(jobId)) == null) + { + throw (new Exception( + "Timed out when communicating with server\nTry again later.\n")); + } + jalview.bin.Jalview.log.debug("Result state " + result.getState() + + "(ServerError=" + result.isServerError() + + ")"); + if (result.isRunning()) + { + wsInfo.setStatus(WebserviceInfo.STATE_RUNNING); + } + else if (result.isQueued()) + { + wsInfo.setStatus(WebserviceInfo.STATE_QUEUING); + } + + if (result.isFinished()) + { + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK); + parseResult(); + jobComplete = true; + jobsRunning--; + } + else + { + if (result.getStatus() != null) { - String cancelledMessage = ""; - - try - { - vamsas.objects.simple.WsJobId cancelledJob = server.cancel(jobId); - - if (cancelledJob.getStatus() == 2) - { - // CANCELLED_JOB - cancelledMessage = "Job cancelled."; - wsInfo.setStatus(WebserviceInfo.STATE_CANCELLED_OK); - jobComplete = true; - jobsRunning--; - result = null; - } - else if (cancelledJob.getStatus() == 3) - { - // VALID UNSTOPPABLE JOB - cancelledMessage += "Server cannot cancel this job. just close the window.\n"; - } - - if (cancelledJob.getJobId() != null) - { - cancelledMessage += ("[" + cancelledJob.getJobId() + - "]"); - } - - cancelledMessage += "\n"; - } - catch (Exception exc) - { - cancelledMessage += ("\nProblems cancelling the job : Exception received...\n" + - exc + "\n"); - exc.printStackTrace(); - } - - wsInfo.setProgressText(OutputHeader + cancelledMessage + "\n"); + wsInfo.setProgressText(OutputHeader + "\n" + + result.getStatus()); } - else + if (result.isServerError()) { - if (!jobComplete) - { - wsInfo.setProgressText(OutputHeader + - "Server cannot cancel this job because it has not been submitted properly. just close the window.\n"); - } - } - } + jobComplete = true; + jobsRunning--; - public void run() - { - StartJob(); - - while (!jobComplete && (allowedServerExceptions > 0)) - { - try - { - if ((result = server.getResult(jobId)) == null) - { - throw (new Exception( - "Timed out when communicating with server\nTry again later.\n")); - } - - if (result.isRunning()) - { - wsInfo.setStatus(WebserviceInfo.STATE_RUNNING); - } - else if (result.isQueued()) - { - wsInfo.setStatus(WebserviceInfo.STATE_QUEUING); - } - - if (result.isFinished()) - { - parseResult(); - jobComplete = true; - jobsRunning--; - } - else - { - if (result.getStatus() != null) - { - wsInfo.setProgressText(OutputHeader + "\n" + - result.getStatus()); - } - - if (!(result.isJobFailed() || result.isServerError())) - { - Thread.sleep(5000); - - // System.out.println("I'm alive "+seqid+" "+jobid); - } - else - { - break; - } - } - } - catch (Exception ex) - { - allowedServerExceptions--; - wsInfo.appendProgressText("\n" + ServiceName + - " Server exception!\n" + ex.getMessage()); - System.err.println(ServiceName + " Server exception: " + - ex.getMessage()); - - // ex.printStackTrace(); JBPNote Debug - try - { - if (allowedServerExceptions > 0) - { - Thread.sleep(5000); - } - } - catch (InterruptedException ex1) - { - } - } + break; } - - if (allowedServerExceptions == 0) + if (! (result.isJobFailed() || result.isServerError() || + result.isBroken() || result.isFailed())) { - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); + Thread.sleep(5000); + + // System.out.println("I'm alive "+seqid+" "+jobid); } else { - if (!((result != null) && - (result.isJobFailed() || result.isServerError()))) - { - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK); - } - else - { - if (result.isFailed()) - { - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR); - } - - if (result.isServerError()) - { - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); - } - } + jobComplete = true; + jobsRunning--; + break; } + } } - - void StartJob() + catch (Exception ex) { - try - { - vamsas.objects.simple.WsJobId jobsubmit = server.align(seqs); - - if ((jobsubmit != null) && (jobsubmit.getStatus() == 1)) - { - jobId = jobsubmit.getJobId(); - System.out.println(WsURL + " Job Id '" + jobId + "'"); - } - else - { - if (jobsubmit == null) - { - throw new Exception("Server at " + WsURL + - " returned null object, it probably cannot be contacted. Try again later ?"); - } - - throw new Exception(jobsubmit.getJobId()); - } - } - catch (Exception e) + allowedServerExceptions--; + wsInfo.appendProgressText("\n" + ServiceName + + " Server exception!\n" + ex.getMessage()); + System.err.println(ServiceName + " Server exception: " + + ex.getMessage()); + + // ex.printStackTrace(); JBPNote Debug + try + { + if (allowedServerExceptions > 0) { - // TODO: JBPNote catch timeout or other fault types explicitly - // For unexpected errors - System.err.println(WebServiceName + - "Client: Failed to submit the sequences for alignment (probably a server side problem)\n" + - "When contacting Server:" + WsURL + "\n" + e.toString() + - "\n"); - this.allowedServerExceptions = 0; - wsInfo.setStatus(wsInfo.STATE_STOPPED_SERVERERROR); - wsInfo.appendProgressText( - "Failed to submit sequences for alignment.\n" + - "It is most likely that there is a problem with the server.\n" + - "Just close the window\n"); - - // e.printStackTrace(); // TODO: JBPNote DEBUG + Thread.sleep(5000); } + } + catch (InterruptedException ex1) + { + } } - - private void addFloatAnnotations(Alignment al, int[] gapmap, - Vector values, String Symname, String Visname, float min, - float max, int winLength) + } + + if (allowedServerExceptions == 0) + { + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); + } + else + { + if (result != null) { - Annotation[] annotations = new Annotation[al.getWidth()]; + if ( !(result.isJobFailed() || result.isServerError())) + { + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK); + } + + if (result.isBroken() || result.isFailed()) + { + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR); + } + + if (result.isServerError()) + { + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); + } + } + } + } - for (int j = 0; j < values.size(); j++) - { - float value = Float.parseFloat(values.get(j).toString()); - annotations[gapmap[j]] = new Annotation("", value + "", ' ', - value); - } + void StartJob() + { + try + { + vamsas.objects.simple.WsJobId jobsubmit = server.align(seqs); - al.addAnnotation(new AlignmentAnnotation(Symname, Visname, - annotations, min, max, winLength)); + if ( (jobsubmit != null) && (jobsubmit.getStatus() == 1)) + { + jobId = jobsubmit.getJobId(); + System.out.println(WsURL + " Job Id '" + jobId + "'"); } - - private jalview.datamodel.Sequence[] getVamsasAlignment( - vamsas.objects.simple.Alignment valign) + else { - vamsas.objects.simple.Sequence[] seqs = valign.getSeqs().getSeqs(); - jalview.datamodel.Sequence[] msa = new jalview.datamodel.Sequence[seqs.length]; + if (jobsubmit == null) + { + throw new Exception("Server at " + WsURL + + " returned null object, it probably cannot be contacted. Try again later ?"); + } - for (int i = 0, j = seqs.length; i < j; i++) - msa[i] = new jalview.datamodel.Sequence(seqs[i].getId(), - seqs[i].getSeq()); - - return msa; + throw new Exception(jobsubmit.getJobId()); } + } + catch (Exception e) + { + // TODO: JBPNote catch timeout or other fault types explicitly + // For unexpected errors + System.err.println(WebServiceName + + "Client: Failed to submit the sequences for alignment (probably a server side problem)\n" + + "When contacting Server:" + WsURL + "\n" + + e.toString() + + "\n"); + this.allowedServerExceptions = 0; + wsInfo.setStatus(wsInfo.STATE_STOPPED_SERVERERROR); + wsInfo.appendProgressText( + "Failed to submit sequences for alignment.\n" + + "It is most likely that there is a problem with the server.\n" + + "Just close the window\n"); + + // e.printStackTrace(); // TODO: JBPNote DEBUG + } + } - void parseResult() - { - SequenceI[] seqs = null; + private jalview.datamodel.Sequence[] getVamsasAlignment( + vamsas.objects.simple.Alignment valign) + { + vamsas.objects.simple.Sequence[] seqs = valign.getSeqs().getSeqs(); + jalview.datamodel.Sequence[] msa = new jalview.datamodel.Sequence[seqs. + length]; - try - { - // OutputHeader = output.getText(); - if (result.isFailed()) - { - OutputHeader += "Job failed.\n"; - } + for (int i = 0, j = seqs.length; i < j; i++) + { + msa[i] = new jalview.datamodel.Sequence(seqs[i].getId(), + seqs[i].getSeq()); + } + + return msa; + } + + void parseResult() + { + SequenceI[] seqs = null; + + try + { + // OutputHeader = output.getText(); + if (result.isFailed()) + { + OutputHeader += "Job failed.\n"; + } - if (result.getStatus() != null) - { - OutputHeader += ("\n" + result.getStatus()); - } + if (result.getStatus() != null) + { + OutputHeader += ("\n" + result.getStatus()); + } - if (result.getMsa() != null) - { - OutputHeader += "\nAlignment Object Method Notes\n"; + if (result.getMsa() != null) + { + OutputHeader += "\nAlignment Object Method Notes\n"; - String[] lines = result.getMsa().getMethod(); + String[] lines = result.getMsa().getMethod(); - for (int line = 0; line < lines.length; line++) - OutputHeader += (lines[line] + "\n"); + for (int line = 0; line < lines.length; line++) + { + OutputHeader += (lines[line] + "\n"); + } - // JBPNote The returned files from a webservice could be hidden behind icons in the monitor window that, when clicked, pop up their corresponding data - seqs = getVamsasAlignment(result.getMsa()); - } + // JBPNote The returned files from a webservice could be hidden behind icons in the monitor window that, when clicked, pop up their corresponding data + seqs = getVamsasAlignment(result.getMsa()); + } - wsInfo.setProgressText(OutputHeader); + wsInfo.setProgressText(OutputHeader); - if (seqs != null) - { - AlignmentOrder msaorder = new AlignmentOrder(seqs); + if (seqs != null) + { + AlignmentOrder msaorder = new AlignmentOrder(seqs); - if (preserveOrder) - { - jalview.analysis.AlignmentSorter.recoverOrder(seqs); - } + if (preserveOrder) + { + jalview.analysis.AlignmentSorter.recoverOrder(seqs); + } - jalview.analysis.SeqsetUtils.deuniquify(SeqNames, seqs); + jalview.analysis.SeqsetUtils.deuniquify(SeqNames, seqs); - Alignment al = new Alignment(seqs); + Alignment al = new Alignment(seqs); - // TODO: JBPNote Should also rename the query sequence sometime... - AlignFrame af = new AlignFrame(al); - af.addSortByOrderMenuItem(ServiceName + " Ordering", - msaorder); + // TODO: JBPNote Should also rename the query sequence sometime... + AlignFrame af = new AlignFrame(al); + af.addSortByOrderMenuItem(ServiceName + " Ordering", + msaorder); - Desktop.addInternalFrame(af, alTitle, - AlignFrame.NEW_WINDOW_WIDTH, - AlignFrame.NEW_WINDOW_HEIGHT); - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } + Desktop.addInternalFrame(af, alTitle, + AlignFrame.NEW_WINDOW_WIDTH, + AlignFrame.NEW_WINDOW_HEIGHT); } + } + catch (Exception ex) + { + ex.printStackTrace(); + } } + } } diff --git a/src/jalview/ws/MsaWServices.java b/src/jalview/ws/MsaWServices.java deleted file mode 100755 index 75ddf16..0000000 --- a/src/jalview/ws/MsaWServices.java +++ /dev/null @@ -1,67 +0,0 @@ -/* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ -package jalview.ws; - -import java.util.Hashtable; - - -/** - *

Title: MsaWServices

- * - *

Description: Registry of MsaWSI style services

- * - *

Copyright: Copyright (c) 2004

- * - *

Company: Dundee University

- * - * @author not attributable - * @version 1.0 - */ -/** - * TODO: MsaWServices will be set from properties and be dynamically discovered. - */ -public class MsaWServices -{ - /** DOCUMENT ME!! */ - public static Hashtable info; - - static - { - info = new Hashtable(); - info.put("ClustalWS", - new String[] - { - "http://www.compbio.dundee.ac.uk/JalviewWS/services/ClustalWS", - "ClustalW Alignment job", - - "\"Thompson, J.D., Higgins, D.G. and Gibson, T.J. (1994) CLUSTAL W: improving the sensitivity of progressive multiple" + - " sequence alignment through sequence weighting, position specific gap penalties and weight matrix choice." + - " Nucleic Acids Research, 22 4673-4680" - }); - info.put("MuscleWS", - new String[] - { - "http://www.compbio.dundee.ac.uk/JalviewWS/services/MuscleWS", - "Muscle Alignment job", - - "Edgar, Robert C. (2004), MUSCLE: multiple sequence alignment " + - "with high accuracy and high throughput, Nucleic Acids Research 32(5), 1792-97." - }); - } -} diff --git a/src/jalview/ws/WSClient.java b/src/jalview/ws/WSClient.java index 0ffb060..02b513c 100755 --- a/src/jalview/ws/WSClient.java +++ b/src/jalview/ws/WSClient.java @@ -19,6 +19,7 @@ package jalview.ws; import jalview.gui.*; +import ext.vamsas.ServiceHandle; public class WSClient { @@ -33,8 +34,37 @@ public class WSClient protected String WsURL; protected WebserviceInfo wsInfo; int jobsRunning = 0; - + /** + * mappings between abstract interface names and menu entries + */ + protected java.util.Hashtable ServiceActions; + { + ServiceActions = new java.util.Hashtable(); + ServiceActions.put("MsaWS", "Multiple Sequence Alignment"); + ServiceActions.put("SecStrPred", "Secondary Structure Prediction"); + }; public WSClient() { } + + protected WebserviceInfo setWebService(ServiceHandle sh) + { + WebServiceName = sh.getName(); + if (ServiceActions.containsKey(sh.getAbstractName())) + { + WebServiceJobTitle = sh.getName(); // TODO: control sh.Name specification properly + // add this for short names. +(String) ServiceActions.get(sh.getAbstractName()); + } + else + { + WebServiceJobTitle = sh.getAbstractName()+" using "+sh.getName(); + + } + WebServiceReference = sh.getDescription(); + WsURL = sh.getEndpointURL(); + WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle, + WebServiceReference); + + return wsInfo; + } } -- 1.7.10.2