From: gmungoc Date: Fri, 8 Nov 2019 09:35:44 +0000 (+0000) Subject: JAL-3081 new method to get alignment sequence order lookup X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=383bcec2f07e63081a697118554154100d599079;p=jalview.git JAL-3081 new method to get alignment sequence order lookup --- 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(); + }