X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fjws2%2FJabawsAlignCalcWorker.java;h=c9c1ea82836a8807776963a82669750ad1cead10;hb=865a855a4ca87eadb3e5ff284ed32ed307d9c34b;hp=f0bac08a06c36fc953a2309592e6b92ae585ca40;hpb=d904a499f1863e96cd699e0c5f7f0f81710e8ad9;p=jalview.git diff --git a/src/jalview/ws/jws2/JabawsAlignCalcWorker.java b/src/jalview/ws/jws2/JabawsAlignCalcWorker.java index f0bac08..c9c1ea8 100644 --- a/src/jalview/ws/jws2/JabawsAlignCalcWorker.java +++ b/src/jalview/ws/jws2/JabawsAlignCalcWorker.java @@ -1,3 +1,21 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1) + * Copyright (C) 2014 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. + * + * 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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.ws.jws2; import jalview.analysis.AlignSeq; @@ -6,6 +24,7 @@ import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; +import jalview.datamodel.AnnotatedCollectionI; import jalview.datamodel.Annotation; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; @@ -77,7 +96,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker } /** - * reconfigure and restart the AAConsClient. This method will spawn a new + * reconfigure and restart the AAConClient. This method will spawn a new * thread that will wait until any current jobs are finished, modify the * parameters and restart the conservation calculation with the new values. * @@ -132,7 +151,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker return; } List seqs = getInputSequences(alignViewport - .getAlignment()); + .getAlignment(), bySequence ? alignViewport.getSelectionGroup() : null); if (seqs == null) { @@ -159,7 +178,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker } catch (WrongParameterException x) { throw new JobSubmissionException( - "Invalid paremeter set. Check Jalview implementation.", x); + "Invalid parameter set. Check Jalview implementation.", x); } } @@ -172,7 +191,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker { finished = true; } - if (calcMan.isPending(this) && this instanceof AAConsClient) + if (calcMan.isPending(this) && this instanceof AAConClient) { finished = true; // cancel this job and yield to the new job @@ -184,7 +203,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker } else { - System.err.println("FAILED TO CANCELL AACon job: " + rslt); + System.err.println("FAILED TO CANCEL AACon job: " + rslt); } } catch (Exception x) @@ -205,7 +224,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker try { stats = aaservice.pullExecStatistics(rslt, rpos); - } catch (Exception x) + } catch (Exception x) { if (x.getMessage().contains( @@ -222,10 +241,16 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker if (--serverErrorsLeft > 0) { retry = true; - try { + try + { Thread.sleep(200); - } catch (InterruptedException q) {}; - } else { + } catch (InterruptedException q) + { + } + ; + } + else + { throw x; } } @@ -250,7 +275,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker ; } } while (!finished); - if (serverErrorsLeft>0) + if (serverErrorsLeft > 0) { try { @@ -356,8 +381,10 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker boolean[] gapMap; int realw; + + int start,end; - public List getInputSequences(AlignmentI alignment) + public List getInputSequences(AlignmentI alignment, AnnotatedCollectionI inputSeqs) { if (alignment == null || alignment.getWidth() <= 0 || alignment.getSequences() == null @@ -367,6 +394,11 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker { return null; } + if (inputSeqs==null || inputSeqs.getWidth()<=0 || inputSeqs.getSequences()==null || inputSeqs.getSequences().size()<1) + { + inputSeqs = alignment; + } + List seqs = new ArrayList(); int minlen = 10; @@ -376,9 +408,12 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker seqNames = new HashMap(); } gapMap = new boolean[0]; - for (SequenceI sq : ((List) alignment.getSequences())) + start=inputSeqs.getStartRes(); + end=inputSeqs.getEndRes(); + + for (SequenceI sq : (List) inputSeqs.getSequences()) { - if (sq.getEnd() - sq.getStart() > minlen - 1) + if (sq.findPosition(end+1) -sq.findPosition(start+1) > minlen - 1) { String newname = SeqsetUtils.unique_name(seqs.size() + 1); // make new input sequence with or without gaps @@ -410,7 +445,7 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker { seqs.add(seq = new compbio.data.sequence.FastaSequence(newname, AlignSeq.extractGaps(jalview.util.Comparison.GapChars, - sq.getSequenceAsString()))); + sq.getSequenceAsString(start,end+1)))); } if (seq.getSequence().length() > ln) { @@ -429,8 +464,8 @@ public abstract class JabawsAlignCalcWorker extends AlignCalcWorker } } // try real hard to return something submittable - // TODO: some of AAcons measures need a minimum of two or three amino - // acids at each position, and aacons doesn't gracefully degrade. + // TODO: some of AAcon measures need a minimum of two or three amino + // acids at each position, and AAcon doesn't gracefully degrade. for (int p = 0; p < seqs.size(); p++) { FastaSequence sq = seqs.get(p);