From: jprocter Date: Tue, 5 Sep 2006 13:36:07 +0000 (+0000) Subject: getVisibleContigs() returns start and end positions of visible regions of an alignmen... X-Git-Tag: Release_2_1_1~16 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7f2a5060015acbd1f5c1d45f8483329492876f87;p=jalview.git getVisibleContigs() returns start and end positions of visible regions of an alignmentView. --- diff --git a/src/jalview/datamodel/AlignmentView.java b/src/jalview/datamodel/AlignmentView.java index 6d94ff1..a76e90e 100644 --- a/src/jalview/datamodel/AlignmentView.java +++ b/src/jalview/datamodel/AlignmentView.java @@ -385,5 +385,50 @@ 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