X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSeqCigar.java;h=9cc7b4a35ff054f5a6a3a48728216f0eaa197105;hb=1c251a57c7b2fb70dabceb480d0170363357558f;hp=b4e0d71b6db75a7789228d74ad392a17a1c390b7;hpb=838e4f91d4a53dd315640dbc9ff6ef7a815ee576;p=jalview.git diff --git a/src/jalview/datamodel/SeqCigar.java b/src/jalview/datamodel/SeqCigar.java index b4e0d71..9cc7b4a 100644 --- a/src/jalview/datamodel/SeqCigar.java +++ b/src/jalview/datamodel/SeqCigar.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b1) - * Copyright (C) 2015 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -68,10 +68,49 @@ public class SeqCigar extends CigarSimple } /** + * + * @param column + * @return position in sequence for column (or -1 if no match state exists) + */ + public int findPosition(int column) + { + int w = 0, ew, p = refseq.findPosition(start); + if (column < 0) + { + return -1; + } + if (range != null) + { + for (int i = 0; i < length; i++) + { + if (operation[i] == M || operation[i] == D) + { + p += range[i]; + } + if (operation[i] == M || operation[i] == I) + { + ew = w + range[i]; + if (column < ew) + { + if (operation[i] == I) + { + return -1; + } + return p - (ew - column); + } + w = ew; + } + } + } + return -1; + } + + /** * Returns sequence as a string with cigar operations applied to it * * @return String */ + @Override public String getSequenceString(char GapChar) { return (length == 0) ? "" : (String) getSequenceAndDeletions( @@ -455,18 +494,18 @@ public class SeqCigar extends CigarSimple /** * create an alignment from the given array of cigar sequences and gap * character, and marking the given segments as visible in the given - * columselection. + * hiddenColumns. * * @param alseqs * @param gapCharacter - * @param colsel - * - columnSelection where hidden regions are marked + * @param hidden + * - hiddenColumns where hidden regions are marked * @param segments * - visible regions of alignment * @return SequenceI[] */ public static SequenceI[] createAlignmentSequences(SeqCigar[] alseqs, - char gapCharacter, ColumnSelection colsel, int[] segments) + char gapCharacter, HiddenColumns hidden, int[] segments) { SequenceI[] seqs = new SequenceI[alseqs.length]; StringBuffer[] g_seqs = new StringBuffer[alseqs.length]; @@ -538,7 +577,7 @@ public class SeqCigar extends CigarSimple if (segments == null) { // add a hidden column for this deletion - colsel.hideColumns(inspos, inspos + insert.length - 1); + hidden.hideColumns(inspos, inspos + insert.length - 1); } } } @@ -559,7 +598,7 @@ public class SeqCigar extends CigarSimple { // int start=shifts.shift(segments[i]-1)+1; // int end=shifts.shift(segments[i]+segments[i+1]-1)-1; - colsel.hideColumns(segments[i + 1], segments[i + 1] + hidden.hideColumns(segments[i + 1], segments[i + 1] + segments[i + 2] - 1); } }