| Class | Line # | Actions | |||
|---|---|---|---|---|---|
| JabawsMsaInterfaceAlignCalcWorker | 30 | 1 | 1 |
| 1 | /* | |
| 2 | * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) | |
| 3 | * Copyright (C) $$Year-Rel$$ The Jalview Authors | |
| 4 | * | |
| 5 | * This file is part of Jalview. | |
| 6 | * | |
| 7 | * Jalview is free software: you can redistribute it and/or | |
| 8 | * modify it under the terms of the GNU General Public License | |
| 9 | * as published by the Free Software Foundation, either version 3 | |
| 10 | * of the License, or (at your option) any later version. | |
| 11 | * | |
| 12 | * Jalview is distributed in the hope that it will be useful, but | |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty | |
| 14 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR | |
| 15 | * PURPOSE. See the GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * along with Jalview. If not, see <http://www.gnu.org/licenses/>. | |
| 19 | * The Jalview Authors are detailed in the 'AUTHORS' file. | |
| 20 | */ | |
| 21 | package jalview.ws.jws2.jabaws2; | |
| 22 | ||
| 23 | import jalview.gui.AlignFrame; | |
| 24 | import jalview.ws.jws2.SeqAnnotationServiceCalcWorker; | |
| 25 | import jalview.ws.params.ArgumentI; | |
| 26 | import jalview.ws.params.WsParamSetI; | |
| 27 | ||
| 28 | import java.util.List; | |
| 29 | ||
| 30 | public abstract class JabawsMsaInterfaceAlignCalcWorker | |
| 31 | extends SeqAnnotationServiceCalcWorker | |
| 32 | { | |
| 33 | ||
| 34 | 0 | public JabawsMsaInterfaceAlignCalcWorker(Jws2Instance service, |
| 35 | AlignFrame alignFrame, WsParamSetI preset, | |
| 36 | List<ArgumentI> paramset) | |
| 37 | { | |
| 38 | 0 | super(service, alignFrame, preset, paramset); |
| 39 | // TODO Auto-generated constructor stub | |
| 40 | } | |
| 41 | ||
| 42 | // TODO: REFACTOR if needed ! | |
| 43 | // may be able to get away with overriding run() only, but maybe not. | |
| 44 | /*** | |
| 45 | * @SuppressWarnings("unchecked") protected MsaWS msaservice; | |
| 46 | * | |
| 47 | * protected Alignment msascoreset; | |
| 48 | * | |
| 49 | * public JabawsMsaInterfaceAlignCalcWorker(AlignViewportI alignViewport, | |
| 50 | * AlignmentViewPanel alignPanel) { super(alignViewport, alignPanel); } | |
| 51 | * | |
| 52 | * public JabawsMsaInterfaceAlignCalcWorker(Jws2Instance service, AlignFrame | |
| 53 | * alignFrame, WsParamSetI preset, List<ArgumentI> paramset) { | |
| 54 | * this(alignFrame.getCurrentView(), alignFrame.alignPanel); this.guiProgress | |
| 55 | * = alignFrame; this.preset = preset; this.arguments = paramset; this.service | |
| 56 | * = service; msaservice = (MsaWS) service.service; | |
| 57 | * | |
| 58 | * } | |
| 59 | * | |
| 60 | * @Override ChunkHolder pullExecStatistics(String rslt, long rpos) { return | |
| 61 | * msaservice.pullExecStatistics(rslt, rpos); } | |
| 62 | * | |
| 63 | * @Override boolean collectAnnotationResultsFor(String rslt) throws | |
| 64 | * ResultNotAvailableException { msascoreset = | |
| 65 | * msaservice.getResult(rslt); if (msascoreset != null) { return | |
| 66 | * true; } return false; } | |
| 67 | * | |
| 68 | * @Override boolean cancelJob(String rslt) throws Exception { return | |
| 69 | * msaservice.cancelJob(rslt); } | |
| 70 | * | |
| 71 | * @Override protected JobStatus getJobStatus(String rslt) throws Exception { | |
| 72 | * return msaservice.getJobStatus(rslt); } | |
| 73 | * | |
| 74 | * @Override boolean hasService() { return msaservice != null; } | |
| 75 | * | |
| 76 | * @Override protected boolean isInteractiveUpdate() { return false; // this | |
| 77 | * instanceof AAConClient; } | |
| 78 | * | |
| 79 | * @Override protected String submitToService( | |
| 80 | * List<compbio.data.sequence.FastaSequence> seqs) throws | |
| 81 | * JobSubmissionException { String rslt; if (preset == null && | |
| 82 | * arguments == null) { rslt = msaservice.align(seqs); } else { try | |
| 83 | * { rslt = msaservice.customAlign(seqs, getJabaArguments()); } | |
| 84 | * catch (WrongParameterException x) { throw new | |
| 85 | * JobSubmissionException(MessageManager.getString( | |
| 86 | * "exception.jobsubmission_invalid_params_set"), x); } } return | |
| 87 | * rslt; } | |
| 88 | * | |
| 89 | * protected void createAnnotationRowsForScores( | |
| 90 | * List<AlignmentAnnotation> ourAnnot, String calcId, int alWidth, | |
| 91 | * Score scr) { // simple annotation row AlignmentAnnotation | |
| 92 | * annotation = alignViewport.getAlignment() | |
| 93 | * .findOrCreateAnnotation(scr.getMethod(), calcId, true, null, | |
| 94 | * null); if (alWidth == gapMap.length) // scr.getScores().size()) { | |
| 95 | * constructAnnotationFromScore(annotation, 0, alWidth, scr); | |
| 96 | * ourAnnot.add(annotation); } } | |
| 97 | * | |
| 98 | * protected AlignmentAnnotation createAnnotationRowsForScores( | |
| 99 | * List<AlignmentAnnotation> ourAnnot, String typeName, String | |
| 100 | * calcId, SequenceI dseq, int base, Score scr) { | |
| 101 | * System.out.println("Creating annotation on dseq:" + | |
| 102 | * dseq.getStart() + " base is " + base + " and length=" + | |
| 103 | * dseq.getLength() + " == " + scr.getScores().size()); // | |
| 104 | * AlignmentAnnotation annotation = new AlignmentAnnotation( // | |
| 105 | * scr.getMethod(), typeName, new Annotation[] // {}, 0, -1, | |
| 106 | * AlignmentAnnotation.LINE_GRAPH); // annotation.setCalcId(calcId); | |
| 107 | * AlignmentAnnotation annotation = alignViewport.getAlignment() | |
| 108 | * .findOrCreateAnnotation(typeName, calcId, false, dseq, null); | |
| 109 | * constructAnnotationFromScore(annotation, 0, dseq.getLength(), | |
| 110 | * scr); annotation.createSequenceMapping(dseq, base, false); | |
| 111 | * annotation.adjustForAlignment(); | |
| 112 | * dseq.addAlignmentAnnotation(annotation); | |
| 113 | * ourAnnot.add(annotation); return annotation; } | |
| 114 | * | |
| 115 | * private void constructAnnotationFromScore(AlignmentAnnotation | |
| 116 | * annotation, int base, int alWidth, Score scr) { Annotation[] elm | |
| 117 | * = new Annotation[alWidth]; Iterator<Float> vals = | |
| 118 | * scr.getScores().iterator(); float m = 0f, x = 0f; for (int i = 0; | |
| 119 | * vals.hasNext(); i++) { float val = vals.next().floatValue(); if | |
| 120 | * (i == 0) { m = val; x = val; } else { if (m > val) { m = val; } ; | |
| 121 | * if (x < val) { x = val; } } // if we're at a gapped column then | |
| 122 | * skip to next ungapped position if (gapMap != null && | |
| 123 | * gapMap.length > 0) { while (!gapMap[i]) { elm[i++] = new | |
| 124 | * Annotation("", "", ' ', Float.NaN); } } elm[i] = new | |
| 125 | * Annotation("", "" + val, ' ', val); } | |
| 126 | * | |
| 127 | * annotation.annotations = elm; annotation.belowAlignment = true; | |
| 128 | * if (x < 0) { x = 0; } x += (x - m) * 0.1; annotation.graphMax = | |
| 129 | * x; annotation.graphMin = m; annotation.validateRangeAndDisplay(); | |
| 130 | * } | |
| 131 | ***/ | |
| 132 | } |