From 4d5f77436c8d77a776ca7c042611f36238c97057 Mon Sep 17 00:00:00 2001 From: James Procter Date: Sat, 13 May 2023 16:49:19 +0100 Subject: [PATCH] =?utf8?q?JAL-2349=20JAL-3855=20helper=20method=20to=20make=20?= =?utf8?q?it=20easy=20to=20transfer=20a=20single=20=E2=80=98reference=20anno?= =?utf8?q?tation=E2=80=99=20to=20an=20alignment=20sequence?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/analysis/AlignmentUtils.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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; } /** -- 1.7.10.2