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<i<n visible regions.
+ */
+ public int[] getVisibleContigs() {
+ if (contigs != null && contigs.length > 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<contigs.length; contig+=3) {
+ if ( (contigs[contig + 1] - start) > 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<fwidth) {
+ viscontigs[nvis] = start;
+ viscontigs[nvis+1]=fwidth; // end is inclusive
+ nvis+=2;
+ }
+ return viscontigs;
+ } else {
+ return new int[] { 0, width};
+ }
+ }
}