From: James Procter Date: Sat, 13 May 2023 15:49:19 +0000 (+0100) Subject: JAL-2349 JAL-3855 helper method to make it easy to transfer a single ‘reference annot... X-Git-Tag: Release_2_11_3_0~14^2~3^2^2~34 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4d5f77436c8d77a776ca7c042611f36238c97057;p=jalview.git JAL-2349 JAL-3855 helper method to make it easy to transfer a single ‘reference annotation’ to an alignment sequence --- diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index 0906872..403991a 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -1503,7 +1503,7 @@ public class AlignmentUtils /** * Adds annotations to the top of the alignment annotations, in the same order - * as their related sequences. + * as their related sequences. If you already have an annotation and want to add it to a sequence in an alignment use {@code addReferenceAnnotationTo} * * @param annotations * the annotations to add @@ -1520,6 +1520,20 @@ public class AlignmentUtils { for (AlignmentAnnotation ann : annotations.get(seq)) { + addReferenceAnnotationTo(alignment, seq,ann,selectionGroup); + } + } + } + /** + * Make a copy of a reference annotation {@code ann} and add it to an alignment sequence {@code seq} in {@code alignment}, optionally limited to the extent of {@code selectionGroup} + * @param alignment + * @param seq + * @param ann + * @param selectionGroup - may be null + * @return annotation added to {@code seq and {@code alignment} + */ + public static AlignmentAnnotation addReferenceAnnotationTo(final AlignmentI alignment, final SequenceI seq,final AlignmentAnnotation ann,final SequenceGroup selectionGroup) + { AlignmentAnnotation copyAnn = new AlignmentAnnotation(ann); int startRes = 0; int endRes = ann.annotations.length; @@ -1549,9 +1563,8 @@ public class AlignmentUtils // add to the alignment and set visible alignment.addAnnotation(copyAnn); copyAnn.visible = true; - } - } - + + return copyAnn; } /**