X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fjws2%2Fjabaws2%2FJabawsAnnotationInstance.java;h=a52b515a40e3c3d89bd022f7cb54d7349ee07868;hb=a1df6edfaf77aefab83a34bfd1331bc679a86142;hp=e7f30224b2bd40b8c00b039af0bd0f68fc376e88;hpb=b55dff11e4b566dcaa3a219c463f09afb65cf92d;p=jalview.git diff --git a/src/jalview/ws/jws2/jabaws2/JabawsAnnotationInstance.java b/src/jalview/ws/jws2/jabaws2/JabawsAnnotationInstance.java index e7f3022..a52b515 100644 --- a/src/jalview/ws/jws2/jabaws2/JabawsAnnotationInstance.java +++ b/src/jalview/ws/jws2/jabaws2/JabawsAnnotationInstance.java @@ -1,22 +1,24 @@ package jalview.ws.jws2.jabaws2; -import jalview.api.AlignViewportI; +import jalview.api.FeatureColourI; +import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; import jalview.datamodel.SequenceI; +import jalview.datamodel.features.FeatureMatcherSetI; import jalview.util.MessageManager; import jalview.ws.api.JobId; import jalview.ws.api.SequenceAnnotationServiceI; -import jalview.ws.gui.AnnotationWsJob; import jalview.ws.jws2.JabaParamStore; import jalview.ws.jws2.JabaPreset; -import jalview.ws.jws2.SeqAnnotationServiceCalcWorker; import jalview.ws.params.ArgumentI; import jalview.ws.params.WsParamSetI; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Map; import compbio.data.msa.SequenceAnnotation; import compbio.data.sequence.FastaSequence; @@ -106,37 +108,47 @@ public abstract class JabawsAnnotationInstance return new JobId(our.getServiceType(), our.getName(), rslt); } + @Override - public List getAlignmentAnnotation( - AnnotationWsJob running, - SeqAnnotationServiceCalcWorker abstractJabaCalcWorker) throws Throwable + public + List getAnnotationResult(JobId job, + List seqs, Map featureColours, + Map featureFilters) throws Throwable { if (scoremanager == null) { // TODO: raise annotation unavailable exception ? - scoremanager = service.getAnnotation(running.getJobId()); + scoremanager = service.getAnnotation(job.getJobId()); } if (scoremanager == null) { return List.of(); } - - return annotationFromScoreManager(running, - abstractJabaCalcWorker.getAlignViewport(), - abstractJabaCalcWorker.getGapMap()); + /** + * dummy alignment to perform annotation on + */ + AlignmentI newal = new Alignment(seqs.toArray(new SequenceI[0])); + List ourAnnot = annotationFromScoreManager(newal, + featureColours, featureFilters); + return ourAnnot; } /** * service specific annotation creation method * - * @param running - * @param alignViewport - * @param gapMap + * @param seqs + * - sequences to be annotated with results + * @param featureColours + * - - updated with any colours imported during result processing + * @param featureFilters + * - updated with any filters imported during result processing + * * @return */ abstract List annotationFromScoreManager( - AnnotationWsJob running, - AlignViewportI alignViewport, boolean[] gapMap); + AlignmentI seqs, Map featureColours, + Map featureFilters); + /** * create and complete an annotation row from a JABAWS score object @@ -149,16 +161,16 @@ public abstract class JabawsAnnotationInstance * @param scr */ - protected void createAnnotationRowsForScores(AlignViewportI alignViewport, + protected void createAnnotationRowsForScores(AlignmentI al_result, boolean[] gapMap, List ourAnnot, String calcId, int alWidth, Score scr) { // simple annotation row - AlignmentAnnotation annotation = alignViewport.getAlignment() + AlignmentAnnotation annotation = al_result .findOrCreateAnnotation(scr.getMethod(), calcId, true, null, null); - if (alWidth == gapMap.length) // scr.getScores().size()) + if (gapMap == null || alWidth == gapMap.length) // scr.getScores().size()) { constructAnnotationFromScore(gapMap, annotation, 0, alWidth, scr); @@ -180,7 +192,7 @@ public abstract class JabawsAnnotationInstance * @return */ protected AlignmentAnnotation createAnnotationRowsForScores( - AlignViewportI alignViewport, boolean[] gapMap, + AlignmentI alignment, boolean[] gapMap, List ourAnnot, String typeName, String calcId, SequenceI dseq, int base, Score scr) { @@ -191,7 +203,7 @@ public abstract class JabawsAnnotationInstance // scr.getMethod(), typeName, new Annotation[] // {}, 0, -1, AlignmentAnnotation.LINE_GRAPH); // annotation.setCalcId(calcId); - AlignmentAnnotation annotation = alignViewport.getAlignment() + AlignmentAnnotation annotation = alignment .findOrCreateAnnotation(typeName, calcId, false, dseq, null); constructAnnotationFromScore(gapMap, annotation, 0, dseq.getLength(), scr); @@ -203,44 +215,6 @@ public abstract class JabawsAnnotationInstance } /** - * replace an existing sequence associated annotation with another, creating - * association as necessary - * - * @param newAnnot - * - annotation row used to create an instance on the dataset - * sequence. - * @param typeName - * - label used to match existing row - * @param calcId - * - calcId for existing row - * @param aSeq - * - alignment sequence with reference to destination dataet sequence - */ - protected void replaceAnnotationOnAlignmentWith( - AlignmentAnnotation newAnnot, String typeName, String calcId, - SequenceI aSeq) - { - SequenceI dsseq = aSeq.getDatasetSequence(); - while (dsseq.getDatasetSequence() != null) - { - dsseq = dsseq.getDatasetSequence(); - } - // look for same annotation on dataset and lift this one over - List dsan = dsseq.getAlignmentAnnotations(calcId, - typeName); - if (dsan != null && dsan.size() > 0) - { - for (AlignmentAnnotation dssan : dsan) - { - dsseq.removeAlignmentAnnotation(dssan); - } - } - AlignmentAnnotation dssan = new AlignmentAnnotation(newAnnot); - dsseq.addAlignmentAnnotation(dssan); - dssan.adjustForAlignment(); - } - - /** * create column annotation elements from Jabaws score object * * @param gapMap