X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fjws1%2FSeqSearchWSThread.java;h=edc9ae89b4f588eaf879d241351336d14f28244d;hb=136c0793b90b72b928c4d77dc109dd5c644e00d3;hp=259a0b9786adc8726fd2da1e6a6f7a415eb52a34;hpb=add30afdc46a14e61ccf55881fa91b9ca9abfe80;p=jalview.git diff --git a/src/jalview/ws/jws1/SeqSearchWSThread.java b/src/jalview/ws/jws1/SeqSearchWSThread.java index 259a0b9..edc9ae8 100644 --- a/src/jalview/ws/jws1/SeqSearchWSThread.java +++ b/src/jalview/ws/jws1/SeqSearchWSThread.java @@ -1,55 +1,49 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * * Jalview 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 3 of the License, or (at your option) any later version. - * + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * * Jalview 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 Jalview. If not, see . + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.ws.jws1; -import java.util.*; - -import jalview.analysis.*; -import jalview.bin.*; -import jalview.datamodel.*; -import jalview.gui.*; +import jalview.analysis.AlignSeq; +import jalview.api.FeatureColourI; +import jalview.bin.Cache; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.AlignmentView; +import jalview.datamodel.SequenceI; +import jalview.gui.AlignFrame; +import jalview.gui.Desktop; +import jalview.gui.WebserviceInfo; import jalview.io.NewickFile; +import jalview.util.MessageManager; import jalview.ws.AWsJob; import jalview.ws.JobStateSummary; import jalview.ws.WSClientI; + +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; +import java.util.Vector; + import vamsas.objects.simple.MsaResult; import vamsas.objects.simple.SeqSearchResult; -/** - *

- * Title: - *

- * - *

- * Description: - *

- * - *

- * Copyright: Copyright (c) 2004 - *

- * - *

- * Company: Dundee University - *

- * - * @author not attributable - * @version 1.0 - */ class SeqSearchWSThread extends JWS1Thread implements WSClientI { String dbs = null; @@ -78,7 +72,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI subjobComplete = true; result = new MsaResult(); result.setFinished(true); - result.setStatus("Job never ran - input returned to user."); + result.setStatus(MessageManager.getString("label.job_never_ran")); } } @@ -102,7 +96,8 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI if (minlen < 0) { throw new Error( - "Implementation error: minlen must be zero or more."); + MessageManager + .getString("error.implementation_error_minlen_must_be_greater_zero")); } for (int i = 0; i < seqs.length; i++) { @@ -124,8 +119,8 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI // for // any // subjob - SeqNames.put(newname, jalview.analysis.SeqsetUtils - .SeqCharacterHash(seqs[i])); + SeqNames.put(newname, + jalview.analysis.SeqsetUtils.SeqCharacterHash(seqs[i])); if (valid && seqs[i].getEnd() - seqs[i].getStart() > minlen - 1) { seqarray[n] = new vamsas.objects.simple.Sequence(); @@ -140,11 +135,10 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI if (seqs[i].getEnd() >= seqs[i].getStart()) { empty = (submitGaps) ? seqs[i].getSequenceAsString() : AlignSeq - .extractGaps(jalview.util.Comparison.GapChars, seqs[i] - .getSequenceAsString()); + .extractGaps(jalview.util.Comparison.GapChars, + seqs[i].getSequenceAsString()); } - emptySeqs.add(new String[] - { newname, empty }); + emptySeqs.add(new String[] { newname, empty }); } } if (submitGaps) @@ -160,6 +154,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI * * @return true if getAlignment will return a valid alignment result. */ + @Override public boolean hasResults() { if (subjobComplete @@ -178,7 +173,8 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI * * @return null or { Alignment(+features and annotation), NewickFile)} */ - public Object[] getAlignment(Alignment dataset, Hashtable featureColours) + public Object[] getAlignment(AlignmentI dataset, + Map featureColours) { if (result != null && result.isFinished()) @@ -213,7 +209,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI if (inFile != null && inFile.length() > 0) { new jalview.io.AnnotationFile().readAnnotationFile(al, inFile, - jalview.io.AppletFormatAdapter.PASTE); + jalview.io.DataSourceType.PASTE); } } catch (Exception e) { @@ -229,7 +225,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI if (inFile != null && inFile.length() > 0) { jalview.io.FeaturesFile ff = new jalview.io.FeaturesFile( - inFile, jalview.io.AppletFormatAdapter.PASTE); + inFile, jalview.io.DataSourceType.PASTE); ff.parse(al, featureColours, false); } } catch (Exception e) @@ -246,7 +242,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI if (inFile != null && inFile.length() > 0) { nf = new jalview.io.NewickFile(inFile, - jalview.io.AppletFormatAdapter.PASTE); + jalview.io.DataSourceType.PASTE); if (!nf.isValid()) { nf.close(); @@ -276,8 +272,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI * trigger a 'fetchDBids' to annotate sequences with database ids... */ - return new Object[] - { al, nf }; + return new Object[] { al, nf }; } return null; } @@ -296,6 +291,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI * * @return boolean true if job can be submitted. */ + @Override public boolean hasValidInput() { if (seqs.getSeqs() != null) @@ -308,7 +304,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI String alTitle; // name which will be used to form new alignment window. - Alignment dataset; // dataset to which the new alignment will be + AlignmentI dataset; // dataset to which the new alignment will be // associated. @@ -350,7 +346,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI SeqSearchWSThread(ext.vamsas.SeqSearchI server, String wsUrl, WebserviceInfo wsinfo, jalview.gui.AlignFrame alFrame, String wsname, String title, AlignmentView _msa, String db, - Alignment seqset) + AlignmentI seqset) { this(server, wsUrl, wsinfo, alFrame, _msa, wsname, db); OutputHeader = wsInfo.getProgressText(); @@ -374,20 +370,21 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI } if (njobs > 0) { - wsinfo - .setProgressName("region " + jobs[j].getJobnum(), - jobs[j].getJobnum()); + wsinfo.setProgressName("region " + jobs[j].getJobnum(), + jobs[j].getJobnum()); } wsinfo.setProgressText(jobs[j].getJobnum(), OutputHeader); } } } + @Override public boolean isCancellable() { return true; } + @Override public void cancelJob() { if (!jobComplete && jobs != null) @@ -430,7 +427,8 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI cancelledMessage += ("\nProblems cancelling the job : Exception received...\n" + exc + "\n"); Cache.log.warn( - "Exception whilst cancelling " + jobs[job].getJobId(), exc); + "Exception whilst cancelling " + jobs[job].getJobId(), + exc); } wsInfo.setProgressText(jobs[job].getJobnum(), OutputHeader + cancelledMessage + "\n"); @@ -447,25 +445,27 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI { if (!jobComplete) { - wsInfo - .setProgressText(OutputHeader - + "Server cannot cancel this job because it has not been submitted properly. just close the window.\n"); + wsInfo.setProgressText(OutputHeader + + "Server cannot cancel this job because it has not been submitted properly. just close the window.\n"); } } } + @Override public void pollJob(AWsJob job) throws Exception { - ((SeqSearchWSJob) job).result = server - .getResult(((SeqSearchWSJob) job).getJobId()); + ((SeqSearchWSJob) job).result = server.getResult(((SeqSearchWSJob) job) + .getJobId()); } + @Override public void StartJob(AWsJob job) { if (!(job instanceof SeqSearchWSJob)) { - throw new Error("StartJob(MsaWSJob) called on a WSJobInstance " - + job.getClass()); + throw new Error(MessageManager.formatMessage( + "error.implementation_error_msawbjob_called", + new String[] { job.getClass().toString() })); } SeqSearchWSJob j = (SeqSearchWSJob) job; if (j.isSubmitted()) @@ -483,13 +483,14 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI j.setSubmitted(true); j.result = new MsaResult(); j.result.setFinished(true); - j.result.setStatus("Empty Alignment Job"); + j.result.setStatus(MessageManager + .getString("label.empty_alignment_job")); ((MsaResult) j.result).setMsa(null); } try { - vamsas.objects.simple.WsJobId jobsubmit = server.search(j.seqs - .getSeqs()[0], dbArg); + vamsas.objects.simple.WsJobId jobsubmit = server.search( + j.seqs.getSeqs()[0], dbArg); if ((jobsubmit != null) && (jobsubmit.getStatus() == 1)) { @@ -502,10 +503,9 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI { if (jobsubmit == null) { - throw new Exception( - "Server at " - + WsUrl - + " returned null object, it probably cannot be contacted. Try again later ?"); + throw new Exception(MessageManager.formatMessage( + "exception.web_service_returned_null_try_later", + new String[] { WsUrl })); } throw new Exception(jobsubmit.getJobId()); @@ -521,13 +521,10 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI + e.toString() + "\n"); j.setAllowedServerExceptions(0); wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); - wsInfo.setStatus(j.getJobnum(), WebserviceInfo.STATE_STOPPED_SERVERERROR); - wsInfo - .appendProgressText( - j.getJobnum(), - "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"); + wsInfo.setStatus(j.getJobnum(), + WebserviceInfo.STATE_STOPPED_SERVERERROR); + wsInfo.appendProgressText(j.getJobnum(), MessageManager + .getString("info.failed_to_submit_sequences_for_alignment")); // e.printStackTrace(); // TODO: JBPNote DEBUG } @@ -541,13 +538,14 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI for (int i = 0, j = seqs.length; i < j; i++) { - msa[i] = new jalview.datamodel.Sequence(seqs[i].getId(), seqs[i] - .getSeq()); + msa[i] = new jalview.datamodel.Sequence(seqs[i].getId(), + seqs[i].getSeq()); } return msa; } + @Override public void parseResult() { int results = 0; // number of result sets received @@ -561,16 +559,17 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI && jobs[j].hasResults()) { results++; - vamsas.objects.simple.Alignment valign = ((SeqSearchResult) ((SeqSearchWSJob)jobs[j]).result) + vamsas.objects.simple.Alignment valign = ((SeqSearchResult) ((SeqSearchWSJob) jobs[j]).result) .getAlignment(); if (valign != null) { - wsInfo.appendProgressText(jobs[j].getJobnum(), - "\nAlignment Object Method Notes\n"); + wsInfo.appendProgressText(jobs[j].getJobnum(), MessageManager + .getString("info.alignment_object_method_notes")); String[] lines = valign.getMethod(); for (int line = 0; line < lines.length; line++) { - wsInfo.appendProgressText(jobs[j].getJobnum(), lines[line] + "\n"); + wsInfo.appendProgressText(jobs[j].getJobnum(), lines[line] + + "\n"); } // JBPNote The returned files from a webservice could be // hidden behind icons in the monitor window that, @@ -590,6 +589,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI wsInfo.showResultsNewFrame .addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(java.awt.event.ActionEvent evt) { displayResults(true); @@ -598,6 +598,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI wsInfo.mergeResults .addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(java.awt.event.ActionEvent evt) { displayResults(false); @@ -623,7 +624,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI // NewickFile nf[] = new NewickFile[jobs.length]; for (int j = 0; j < jobs.length; j++) { - Hashtable featureColours = new Hashtable(); + Map featureColours = new HashMap(); Alignment al = null; NewickFile nf = null; if (jobs[j].hasResults()) @@ -665,7 +666,8 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); if (nf != null) { - af.ShowNewickTree(nf, "Tree from " + this.alTitle); + af.showNewickTree(nf, MessageManager.formatMessage( + "label.tree_from", new String[] { this.alTitle })); } // initialise with same renderer settings as in parent alignframe. af.getFeatureRenderer().transferSettings(this.featureSettings); @@ -674,6 +676,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI } } + @Override public boolean canMergeResults() { return false;