From 383bcec2f07e63081a697118554154100d599079 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 8 Nov 2019 09:35:44 +0000 Subject: [PATCH] JAL-3081 new method to get alignment sequence order lookup --- src/jalview/datamodel/Alignment.java | 20 ++++++++++++++++++++ src/jalview/datamodel/AlignmentI.java | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index ac00fa2..5739b7c 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -32,6 +32,7 @@ import java.util.Arrays; import java.util.BitSet; import java.util.Collections; import java.util.Enumeration; +import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; @@ -2024,4 +2025,23 @@ public class Alignment implements AlignmentI } } + /** + * Returns a map from sequence to position (0, 1,...) in the alignment + */ + @Override + public Map getSequencePositions() + { + Map map = new HashMap<>(); + + synchronized (sequences) + { + int i = sequences.size(); + for (int j = 0; j < i; j++) + { + map.put(sequences.get(j), Integer.valueOf(j)); + } + } + return map; + } + } diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 93a2456..34457fc 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -624,4 +624,12 @@ public interface AlignmentI extends AnnotatedCollectionI public HiddenColumns propagateInsertions(SequenceI profileseq, AlignmentView input); + /** + * Returns a map whose key is a sequence in the alignment, and value the + * position (0, 1, 2...) of the sequence + * + * @return + */ + Map getSequencePositions(); + } -- 1.7.10.2