X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FAlignmentUtils.java;h=6385fa75076c0ef2d32d715ae67781bcb8126f39;hb=refs%2Fheads%2FRelease_2_8_2_Branch;hp=2feeb919a3d7791c74584018f69e26b493371ec0;hpb=7ab5d6b0ba5fec1ea4a4239e79c476d841622485;p=jalview.git diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index 2feeb91..6385fa7 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -20,12 +20,13 @@ */ package jalview.analysis; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.SequenceI; + import java.util.ArrayList; import java.util.List; -import jalview.datamodel.SequenceI; -import jalview.datamodel.AlignmentI; - /** * grab bag of useful alignment manipulation operations Expect these to be * refactored elsewhere at some point. @@ -121,7 +122,41 @@ public class AlignmentUtils } AlignmentI newAl = new jalview.datamodel.Alignment( sq.toArray(new SequenceI[0])); + for (SequenceI s : sq) + { + if (s.getAnnotation() != null) + { + for (AlignmentAnnotation aa : s.getAnnotation()) + { + newAl.addAnnotation(aa); + } + } + } newAl.setDataset(core.getDataset()); return newAl; } + + /** + * Returns the index (zero-based position) of a sequence in an alignment, or + * -1 if not found. + * + * @param al + * @param seq + * @return + */ + public static int getSequenceIndex(AlignmentI al, SequenceI seq) + { + int result = -1; + int pos = 0; + for (SequenceI alSeq : al.getSequences()) + { + if (alSeq == seq) + { + result = pos; + break; + } + pos++; + } + return result; + } }