From a1df6edfaf77aefab83a34bfd1331bc679a86142 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 26 Sep 2019 16:28:41 +0100 Subject: [PATCH] JAL-3070 JAL-3066 JAL-3067 refactor annotation web service so client is passed sequences as input, and an alignment object containing result sequences to be annotated. --- src/jalview/ws/api/SequenceAnnotationServiceI.java | 29 ++- .../ws/jws2/SeqAnnotationServiceCalcWorker.java | 208 ++++++++++++++++++-- src/jalview/ws/jws2/jabaws2/AAConClient.java | 22 ++- src/jalview/ws/jws2/jabaws2/AADisorderClient.java | 89 +++++---- .../ws/jws2/jabaws2/JabawsAnnotationInstance.java | 92 ++++----- src/jalview/ws/jws2/jabaws2/RNAalifoldClient.java | 27 +-- 6 files changed, 319 insertions(+), 148 deletions(-) diff --git a/src/jalview/ws/api/SequenceAnnotationServiceI.java b/src/jalview/ws/api/SequenceAnnotationServiceI.java index a224bac..9ca2d31 100644 --- a/src/jalview/ws/api/SequenceAnnotationServiceI.java +++ b/src/jalview/ws/api/SequenceAnnotationServiceI.java @@ -1,13 +1,14 @@ package jalview.ws.api; +import jalview.api.FeatureColourI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.SequenceI; -import jalview.ws.gui.AnnotationWsJob; -import jalview.ws.jws2.SeqAnnotationServiceCalcWorker; +import jalview.datamodel.features.FeatureMatcherSetI; import jalview.ws.params.ArgumentI; import jalview.ws.params.WsParamSetI; import java.util.List; +import java.util.Map; public interface SequenceAnnotationServiceI extends JalviewWebServiceI { @@ -27,14 +28,24 @@ public interface SequenceAnnotationServiceI extends JalviewWebServiceI List paramset) throws Throwable; /** - * todo: move to SequenceAnnotationResult + * materialise annotation and features for sequences input to the service * - * @param running - * @param abstractJabaCalcWorker - * @return + * @param job + * @param seqs + * - features and alignment annotation added to these will be + * imported to the dataset for the alignment + * @param featureColours + * - container for feature colours - any defined will be merged with + * viewport + * @param featureFilters + * - container for filters - any defined will be merged with viewport + * @return sequence and alignment annotation rows that should be made + * visible/updated on alignment + * @throws Throwable */ - List getAlignmentAnnotation(AnnotationWsJob running, - SeqAnnotationServiceCalcWorker abstractJabaCalcWorker) throws Throwable; - + List getAnnotationResult(JobId job, + List seqs, Map featureColours, + Map featureFilters) throws Throwable; + } diff --git a/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java b/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java index 7d22f25..6279ccd 100644 --- a/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java +++ b/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java @@ -21,20 +21,28 @@ package jalview.ws.jws2; import jalview.analysis.AlignSeq; +import jalview.analysis.AlignmentAnnotationUtils; import jalview.analysis.SeqsetUtils; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; +import jalview.api.FeatureColourI; import jalview.bin.Cache; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AnnotatedCollectionI; +import jalview.datamodel.Annotation; +import jalview.datamodel.ContiguousI; +import jalview.datamodel.Mapping; import jalview.datamodel.SequenceI; +import jalview.datamodel.features.FeatureMatcherSetI; import jalview.gui.AlignFrame; import jalview.gui.Desktop; import jalview.gui.IProgressIndicator; import jalview.gui.IProgressIndicatorHandler; import jalview.gui.JvOptionPane; +import jalview.schemes.FeatureSettingsAdapter; import jalview.schemes.ResidueProperties; +import jalview.util.MapList; import jalview.util.MessageManager; import jalview.workers.AlignCalcWorker; import jalview.ws.api.CancellableI; @@ -191,6 +199,7 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker bySequence = !service.isAlignmentAnalysis(); filterNonStandardResidues = service.isFilterSymbols(); min_valid_seqs = service.getMinimumInputSequences(); + submitGaps = service.isAlignmentAnalysis(); if (service.isInteractiveUpdate()) { @@ -385,10 +394,23 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker running.setFeatureRenderer( ((jalview.gui.AlignmentPanel) ap).cloneFeatureRenderer()); Cache.log.debug("retrieving job results."); + final Map featureColours = new HashMap<>(); + final Map featureFilters = new HashMap<>(); List returnedAnnot = annotService - .getAlignmentAnnotation(running, this); + .getAnnotationResult(running.getJobHandle(), seqs, + featureColours, featureFilters); + Cache.log.debug("Obtained " + (returnedAnnot == null ? "no rows" : ("" + returnedAnnot.size()))); + Cache.log.debug("There were " + featureColours.size() + + " feature colours and " + featureFilters.size() + + " filters defined."); + + // TODO + // copy over each annotation row reurned and also defined on each + // sequence, excluding regions not annotated due to gapMap/column + // visibility + running.setAnnotation(returnedAnnot); if (running.hasResults()) @@ -398,19 +420,42 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker updateResultAnnotation(true); if (running.isTransferSequenceFeatures()) { + // TODO + // look at each sequence and lift over any features, excluding regions + // not annotated due to gapMap/column visibility + jalview.bin.Cache.log.debug( "Updating feature display settings and transferring features from Job " + rslt + " at " + service.getUri()); - ((jalview.gui.AlignmentPanel) ap) - .updateFeatureRendererFrom(running.getFeatureRenderer()); + // TODO: consider merge rather than apply here + alignViewport.applyFeaturesStyle(new FeatureSettingsAdapter() + { + @Override + public FeatureColourI getFeatureColour(String type) + { + return featureColours.get(type); + } + + @Override + public FeatureMatcherSetI getFeatureFilters(String type) + { + return featureFilters.get(type); + } + + @Override + public boolean isFeatureDisplayed(String type) + { + return featureColours.containsKey(type); + } + + }); // TODO: JAL-1150 - create sequence feature settings API for defining // styles and enabling/disabling feature overlay on alignment panel if (alignFrame.alignPanel == ap) { - // only do this if the alignFrame is currently showing this view. - Desktop.getAlignFrameFor(alignViewport) - .setShowSeqFeatures(true); + alignViewport.setShowSequenceFeatures(true); + alignFrame.setMenusForViewport(); } } ap.adjustAnnotationHeight(); @@ -677,8 +722,137 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker if ((immediate || !calcMan.isWorking(this)) && running != null && running.hasResults()) { - List ourAnnot = running.getAnnotation(); - updateOurAnnots(ourAnnot); + List ourAnnot = running.getAnnotation(), + newAnnots = new ArrayList<>(); + // + // update graphGroup for all annotation + // + /** + * find a graphGroup greater than any existing ones this could be a method + * provided by alignment Alignment.getNewGraphGroup() - returns next + * unused graph group + */ + int graphGroup = 1; + if (alignViewport.getAlignment().getAlignmentAnnotation() != null) + { + for (AlignmentAnnotation ala : alignViewport.getAlignment() + .getAlignmentAnnotation()) + { + if (ala.graphGroup > graphGroup) + { + graphGroup = ala.graphGroup; + } + } + } + /** + * update graphGroup in the annotation rows returned from service + */ + // TODO: look at sequence annotation rows and update graph groups in the + // case of reference annotation. + for (AlignmentAnnotation ala : ourAnnot) + { + if (ala.graphGroup > 0) + { + ala.graphGroup += graphGroup; + } + SequenceI aseq = null; + + /** + * transfer sequence refs and adjust gapmap + */ + if (ala.sequenceRef != null) + { + SequenceI seq = running.getSeqNames() + .get(ala.sequenceRef.getName()); + aseq = seq; + while (seq.getDatasetSequence() != null) + { + seq = seq.getDatasetSequence(); + } + } + Annotation[] resAnnot = ala.annotations, + gappedAnnot = new Annotation[Math.max( + alignViewport.getAlignment().getWidth(), + gapMap.length)]; + for (int p = 0, ap = start; ap < gappedAnnot.length; ap++) + { + if (gapMap != null && gapMap.length > ap && !gapMap[ap]) + { + gappedAnnot[ap] = new Annotation("", "", ' ', Float.NaN); + } + else if (p < resAnnot.length) + { + gappedAnnot[ap] = resAnnot[p++]; + } + } + ala.sequenceRef = aseq; + ala.annotations = gappedAnnot; + AlignmentAnnotation newAnnot = getAlignViewport().getAlignment() + .updateFromOrCopyAnnotation(ala); + if (aseq != null) + { + + aseq.addAlignmentAnnotation(newAnnot); + newAnnot.adjustForAlignment(); + + AlignmentAnnotationUtils.replaceAnnotationOnAlignmentWith( + newAnnot, newAnnot.label, newAnnot.getCalcId()); + } + newAnnots.add(newAnnot); + + } + for (SequenceI sq : running.getSeqs()) + { + if (!sq.getFeatures().hasFeatures() + && (sq.getDBRefs() == null || sq.getDBRefs().length == 0)) + { + continue; + } + running.setTransferSequenceFeatures(true); + SequenceI seq = running.getSeqNames().get(sq.getName()); + SequenceI dseq; + ContiguousI seqRange = seq.findPositions(start, end); + + while ((dseq = seq).getDatasetSequence() != null) + { + seq = seq.getDatasetSequence(); + } + List sourceRange = new ArrayList(); + if (gapMap != null && gapMap.length >= end) + { + int lastcol = start, col = start; + do + { + if (col == end || !gapMap[col]) + { + if (lastcol <= (col - 1)) + { + seqRange = seq.findPositions(lastcol, col); + sourceRange.add(seqRange); + } + lastcol = col + 1; + } + } while (++col <= end); + } + else + { + sourceRange.add(seq.findPositions(start, end)); + } + int i = 0; + int source_startend[] = new int[sourceRange.size() * 2]; + + for (ContiguousI range : sourceRange) + { + source_startend[i++] = range.getBegin(); + source_startend[i++] = range.getEnd(); + } + Mapping mp = new Mapping( + new MapList(source_startend, new int[] + { seq.getStart(), seq.getEnd() }, 1, 1)); + dseq.transferAnnotation(sq, mp); + + } + updateOurAnnots(newAnnots); } } @@ -738,15 +912,17 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker } } our.clear(); - // validate rows and update Alignmment state - for (AlignmentAnnotation an : ourAnnots) - { - alignViewport.getAlignment().validateAnnotation(an); - } - // TODO: may need a menu refresh after this - // af.setMenusForViewport(); - ap.adjustAnnotationHeight(); } + + // validate rows and update Alignmment state + for (AlignmentAnnotation an : ourAnnots) + { + alignViewport.getAlignment().validateAnnotation(an); + } + // TODO: may need a menu refresh after this + // af.setMenusForViewport(); + ap.adjustAnnotationHeight(); + } public SequenceAnnotationServiceI getService() diff --git a/src/jalview/ws/jws2/jabaws2/AAConClient.java b/src/jalview/ws/jws2/jabaws2/AAConClient.java index f0a4b67..18b6ce1 100644 --- a/src/jalview/ws/jws2/jabaws2/AAConClient.java +++ b/src/jalview/ws/jws2/jabaws2/AAConClient.java @@ -20,10 +20,11 @@ */ package jalview.ws.jws2.jabaws2; -import jalview.api.AlignViewportI; +import jalview.api.FeatureColourI; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.features.FeatureMatcherSetI; import jalview.util.MessageManager; -import jalview.ws.gui.AnnotationWsJob; import jalview.ws.uimodel.AlignAnalysisUIText; import java.util.ArrayList; @@ -64,13 +65,17 @@ public class AAConClient extends JabawsAnnotationInstance } @Override - List annotationFromScoreManager( - AnnotationWsJob running, AlignViewportI alignViewport, - boolean[] gapMap) + List annotationFromScoreManager(AlignmentI seqs, + Map featureColours, + Map featureFilters) { + return aacons_annotation(seqs.getWidth(), seqs, null); + } + private List aacons_annotation(int alWidth, + AlignmentI alignViewport, boolean[] gapMap) + { Map> scoremap = scoremanager.asMap(); - int alWidth = alignViewport.getAlignment().getWidth(); ArrayList ourAnnot = new ArrayList<>(); for (String score : scoremap.keySet()) { @@ -91,8 +96,9 @@ public class AAConClient extends JabawsAnnotationInstance } else { - createAnnotationRowsForScores(alignViewport, gapMap, ourAnnot, - getCalcId(), alWidth, scr); + createAnnotationRowsForScores(alignViewport, null, ourAnnot, + getCalcId(), + scr.getScores().size(), scr); } } } diff --git a/src/jalview/ws/jws2/jabaws2/AADisorderClient.java b/src/jalview/ws/jws2/jabaws2/AADisorderClient.java index 6e65cce..a221aa0 100644 --- a/src/jalview/ws/jws2/jabaws2/AADisorderClient.java +++ b/src/jalview/ws/jws2/jabaws2/AADisorderClient.java @@ -20,16 +20,17 @@ */ package jalview.ws.jws2.jabaws2; -import jalview.api.AlignViewportI; +import jalview.analysis.AlignmentAnnotationUtils; import jalview.api.FeatureColourI; import jalview.bin.Cache; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; import jalview.datamodel.GraphLine; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; +import jalview.datamodel.features.FeatureMatcherSetI; import jalview.schemes.FeatureColour; import jalview.util.ColorUtils; -import jalview.ws.gui.AnnotationWsJob; import java.awt.Color; import java.util.ArrayList; @@ -61,41 +62,26 @@ public class AADisorderClient extends JabawsAnnotationInstance } @Override - List annotationFromScoreManager( - AnnotationWsJob running, AlignViewportI alignViewport, - boolean[] gapMap) + List annotationFromScoreManager(AlignmentI seqs, + Map featureColours, + Map featureFilters) { Map featureTypeMap = featureMap.get(our.getName()); Map> annotTypeMap = annotMap .get(our.getName()); boolean dispFeatures = false; - Map fc = new Hashtable<>(); + Map fc = new Hashtable<>(), + fex = new Hashtable(); List ourAnnot = new ArrayList<>(); - /** - * grouping for any annotation rows created - */ - int graphGroup = 1; - if (alignViewport.getAlignment().getAlignmentAnnotation() != null) - { - for (AlignmentAnnotation ala : alignViewport.getAlignment() - .getAlignmentAnnotation()) - { - if (ala.graphGroup > graphGroup) - { - graphGroup = ala.graphGroup; - } - } - } + int graphGroup = 1, lastAnnot = 0; - // TODO: downgrade code below so we don't annotate sequences directly - Map seqNames = running.getSeqNames(); - int start = running.getStartPos(); - for (String seqId : seqNames.keySet()) + for (SequenceI seq : seqs.getSequences()) { + String seqId = seq.getName(); boolean sameGroup = false; - SequenceI dseq, aseq, seq = seqNames.get(seqId); - int base = seq.findPosition(start) - 1; + SequenceI dseq, aseq; + int base = seq.findPosition(0) - 1; aseq = seq; while ((dseq = seq).getDatasetSequence() != null) { @@ -109,10 +95,10 @@ public class AADisorderClient extends JabawsAnnotationInstance { Cache.log.info("Couldn't recover disorder prediction for sequence " + seq.getName() + "(Prediction name was " + seqId + ")" - + "\nSee http://issues.jalview.org/browse/JAL-1319 for one possible reason why disorder predictions might fail."); + + "\nSee http://issues.jalview.org/browse/JAL-1319 for one possible reason why disorder predictions might fail.", + q); } float last = Float.NaN, val = Float.NaN; - int lastAnnot = ourAnnot.size(); if (scores != null && scores.scores != null) { for (Score scr : scores.scores) @@ -124,7 +110,7 @@ public class AADisorderClient extends JabawsAnnotationInstance // make features on sequence for (Range rn : scr.getRanges()) { - + // TODO: Create virtual feature settings SequenceFeature sf; String[] type = featureTypeMap.get(scr.getMethod()); if (type == null) @@ -146,12 +132,16 @@ public class AADisorderClient extends JabawsAnnotationInstance base + rn.to, methodName); } dseq.addSequenceFeature(sf); - if (last != val && !Float.isNaN(last)) + // mark feature as requiring a graduated colourscheme if has + // variable scores + if (!Float.isNaN(last) && !Float.isNaN(val) && last != val) { fc.put(sf.getType(), sf); + } else + { + fex.put(sf.getType(), sf); } last = val; - running.setTransferSequenceFeatures(true); dispFeatures = true; } } @@ -163,7 +153,7 @@ public class AADisorderClient extends JabawsAnnotationInstance } String typename, calcName; AlignmentAnnotation annot = createAnnotationRowsForScores( - alignViewport, gapMap, ourAnnot, + seqs, null, ourAnnot, typename = our.getName() + " (" + scr.getMethod() + ")", calcName = our.getNameURI() + "/" + scr.getMethod(), aseq, base + 1, scr); @@ -218,8 +208,8 @@ public class AADisorderClient extends JabawsAnnotationInstance } annot._linecolour = col; // finally, update any dataset annotation - replaceAnnotationOnAlignmentWith(annot, typename, calcName, - aseq); + AlignmentAnnotationUtils.replaceAnnotationOnAlignmentWith(annot, + typename, calcName); } } } @@ -232,20 +222,29 @@ public class AADisorderClient extends JabawsAnnotationInstance { if (dispFeatures) { - jalview.api.FeatureRenderer fr = running.getFeatureRenderer(); - for (String ft : fc.keySet()) + // TODO: virtual feature settings + // feature colours need to merged with current viewport's colours + // simple feature colours promoted to colour-by-score ranges using + // currently assigned or created feature colour + for (String ft : fex.keySet()) { - FeatureColourI gc = fr.getFeatureStyle(ft); - if (gc.isSimpleColour()) + Color col = ColorUtils.createColourFromName(ft); + // set graduated color as fading to white for minimum, and + // autoscaling to values on alignment + + FeatureColourI ggc; + if (fc.get(ft) != null) { - // set graduated color as fading to white for minimum, and - // autoscaling to values on alignment - FeatureColourI ggc = new FeatureColour(gc.getColour(), - Color.white, gc.getColour(), Color.white, - Float.MIN_VALUE, Float.MAX_VALUE); + ggc = new FeatureColour(col, Color.white, col, + + Color.white, Float.MIN_VALUE, Float.MAX_VALUE); ggc.setAutoScaled(true); - fr.setColour(ft, ggc); } + else + { + ggc = new FeatureColour(col); + } + featureColours.put(ft, ggc); } } 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 diff --git a/src/jalview/ws/jws2/jabaws2/RNAalifoldClient.java b/src/jalview/ws/jws2/jabaws2/RNAalifoldClient.java index cde7707..1b07fe6 100644 --- a/src/jalview/ws/jws2/jabaws2/RNAalifoldClient.java +++ b/src/jalview/ws/jws2/jabaws2/RNAalifoldClient.java @@ -20,17 +20,19 @@ */ package jalview.ws.jws2.jabaws2; -import jalview.api.AlignViewportI; +import jalview.api.FeatureColourI; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; +import jalview.datamodel.features.FeatureMatcherSetI; import jalview.util.MessageManager; -import jalview.ws.gui.AnnotationWsJob; import jalview.ws.uimodel.AlignAnalysisUIText; import java.text.MessageFormat; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.TreeSet; import java.util.regex.Pattern; @@ -85,9 +87,9 @@ public class RNAalifoldClient extends JabawsAnnotationInstance } @Override - List annotationFromScoreManager( - AnnotationWsJob running, AlignViewportI alignViewport, - boolean[] gapMap) + List annotationFromScoreManager(AlignmentI seqs, + Map featureColours, + Map featureFilters) { List ourAnnot = new ArrayList<>(); @@ -103,18 +105,21 @@ public class RNAalifoldClient extends JabawsAnnotationInstance .equals(AlifoldResult.contactProbabilities.toString())); // add annotation for the consensus sequence alignment - createAnnotationRowforScoreHolder(alignViewport, gapMap, ourAnnot, + createAnnotationRowforScoreHolder(seqs, null, + ourAnnot, getCalcId(), structs.get(0), null, null); // Add annotations for the mfe Structure - createAnnotationRowforScoreHolder(alignViewport, gapMap, ourAnnot, + createAnnotationRowforScoreHolder(seqs, null, + ourAnnot, getCalcId(), structs.get(1), data.get(1), null); // decide whether to add base pair contact probability histogram int count = 2; if (bpScores) { - createAnnotationRowforScoreHolder(alignViewport, gapMap, ourAnnot, + createAnnotationRowforScoreHolder(seqs, null, + ourAnnot, getCalcId(), structs.get(2), data.get(0), data.get(2)); count++; } @@ -130,7 +135,7 @@ public class RNAalifoldClient extends JabawsAnnotationInstance .equals(AlifoldResult.ensembleValues.toString())) { - createAnnotationRowforScoreHolder(alignViewport, gapMap, ourAnnot, + createAnnotationRowforScoreHolder(seqs, null, ourAnnot, getCalcId(), structs.get(i), data.get(i), null); } } @@ -138,7 +143,7 @@ public class RNAalifoldClient extends JabawsAnnotationInstance } private static void createAnnotationRowforScoreHolder( - AlignViewportI alignViewport, boolean[] gapMap, + AlignmentI alignment, boolean[] gapMap, List ourAnnot, String calcId, String struct, TreeSet data, TreeSet descriptionData) { @@ -165,7 +170,7 @@ public class RNAalifoldClient extends JabawsAnnotationInstance String typename = typenameAndDescription[0]; String description = typenameAndDescription[1]; - AlignmentAnnotation annotation = alignViewport.getAlignment() + AlignmentAnnotation annotation = alignment .findOrCreateAnnotation(typename, calcId, false, null, null); constructAnnotationFromScoreHolder(gapMap, annotation, struct, data); -- 1.7.10.2