X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignmentView.java;h=8b86a8252cc135b922726e4a9c945c30e8efa6ec;hb=dd74fc4938723fe5ec48d4e5fdcfbe58ac42a48d;hp=2cc0e9f25817fed8190b5217d30e61f473d384e5;hpb=89a0b775abfaa90242a171ca8133784a424a3d7b;p=jalview.git diff --git a/src/jalview/datamodel/AlignmentView.java b/src/jalview/datamodel/AlignmentView.java index 2cc0e9f..8b86a82 100644 --- a/src/jalview/datamodel/AlignmentView.java +++ b/src/jalview/datamodel/AlignmentView.java @@ -1,3 +1,21 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.datamodel; @@ -22,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()) @@ -31,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) { @@ -46,7 +74,10 @@ public class AlignmentView { return sequences; } - + /** + * @see CigarArray.getDeletedRegions + * @return int[] { vis_start, sym_start, length } + */ public int[] getContigs() { return contigs; @@ -71,7 +102,19 @@ public class AlignmentView { String[] seqs=new String[sequences.length]; for (int n=0; n= oseq.getStart()) { alignment[s].setEnd(oseq.getEnd()); @@ -260,8 +303,8 @@ public class AlignmentView } else { - alignment[s].setSequence(alignment[s].getSequence() + - hseq.getSequence()); + alignment[s].setSequence(alignment[s].getSequenceAsString() + + hseq.getSequenceAsString()); if (hseq.getEnd() >= hseq.getStart()) { alignment[s].setEnd(hseq.getEnd()); @@ -289,8 +332,8 @@ public class AlignmentView } else { - alignment[s].setSequence(alignment[s].getSequence() + - mseq[s].getSequence()); + alignment[s].setSequence(alignment[s].getSequenceAsString() + + mseq[s].getSequenceAsString()); if (mseq[s].getEnd() >= mseq[s].getStart()) { alignment[s].setEnd(mseq[s].getEnd()); @@ -323,8 +366,8 @@ public class AlignmentView } else { - alignment[s].setSequence(alignment[s].getSequence() + - oseq.getSequence()); + alignment[s].setSequence(alignment[s].getSequenceAsString() + + oseq.getSequenceAsString()); if (oseq.getEnd() >= oseq.getStart()) { alignment[s].setEnd(oseq.getEnd()); @@ -352,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