X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignmentView.java;h=e6684705b23d43bc0c912d534563120b562924b0;hb=0bdaa0deb6ee514912d2ed730e19f618bc44cb69;hp=22232b3d7bcd4dc905ecca3b2bcde278aaefb138;hpb=716fb541ba9f841229db9dafab433115730cffd7;p=jalview.git diff --git a/src/jalview/datamodel/AlignmentView.java b/src/jalview/datamodel/AlignmentView.java index 22232b3..e668470 100644 --- a/src/jalview/datamodel/AlignmentView.java +++ b/src/jalview/datamodel/AlignmentView.java @@ -40,6 +40,7 @@ public class AlignmentView private SeqCigar[] sequences = null; private int[] contigs = null; private int width=0; + private int firstCol=0; public AlignmentView(CigarArray seqcigararray) { if (!seqcigararray.isSeqCigarArray()) @@ -49,6 +50,15 @@ public class AlignmentView sequences = seqcigararray.getSeqCigarArray(); width = seqcigararray.getWidth(); // visible width } + /** + * Create an alignmentView where the first column corresponds with the 'firstcol' column of some reference alignment + * @param sdata + * @param firstcol + */ + public AlignmentView(CigarArray sdata, int firstcol) { + this(sdata); + firstCol=firstcol; + } public void setSequences(SeqCigar[] sequences) { @@ -64,7 +74,10 @@ public class AlignmentView { return sequences; } - + /** + * @see CigarArray.getDeletedRegions + * @return int[] { vis_start, sym_start, length } + */ public int[] getContigs() { return contigs; @@ -382,5 +395,58 @@ public class AlignmentView return getAlignmentAndColumnSelection(gapCharacter); } } - + /** + * returns simple array of start end positions of visible range on alignment. + * vis_start and vis_end are inclusive - use SequenceI.getSubSequence(vis_start, vis_end+1) to recover visible sequence from underlying alignment. + * @return int[] { start_i, end_i } for 1 0) + { + int start = 0; + int nvis = 0; + int fwidth = width; + for (int contig = 0; contig < contigs.length; contig += 3) + { + if ( (contigs[contig + 1] - start) > 0) + { + nvis++; + } + fwidth += contigs[contig + 2]; // end up with full region width (including hidden regions) + start = contigs[contig + 1] + contigs[contig + 2]; + } + if (start < fwidth) + { + nvis++; + } + int viscontigs[] = new int[nvis*2]; + nvis=0; + start=0; + for (int contig=0; contig 0) + { + viscontigs[nvis] = start; + viscontigs[nvis+1]=contigs[contig+1]-1; // end is inclusive + nvis+=2; + } + start = contigs[contig + 1] + contigs[contig + 2]; + } + if (start