2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
\r
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
\r
5 * This file is part of Jalview.
\r
7 * Jalview is free software: you can redistribute it and/or
\r
8 * modify it under the terms of the GNU General Public License
\r
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
\r
11 * Jalview is distributed in the hope that it will be useful, but
\r
12 * WITHOUT ANY WARRANTY; without even the implied warranty
\r
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
14 * PURPOSE. See the GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
\r
18 package jalview.datamodel;
\r
22 import jalview.util.*;
\r
25 * NOTE: Columns are zero based.
\r
27 public class ColumnSelection
\r
29 Vector selected = new Vector();
\r
31 // Vector of int [] {startCol, endCol}
\r
32 Vector hiddenColumns;
\r
35 * Add a column to the selection
\r
40 public void addElement(int col)
\r
42 Integer column = new Integer(col);
\r
43 if (!selected.contains(column))
\r
45 selected.addElement(column);
\r
50 * clears column selection
\r
54 selected.removeAllElements();
\r
58 * removes col from selection
\r
61 * index of column to be removed
\r
63 public void removeElement(int col)
\r
65 Integer colInt = new Integer(col);
\r
67 if (selected.contains(colInt))
\r
69 selected.removeElement(colInt);
\r
74 * removes a range of columns from the selection
\r
77 * int - first column in range to be removed
\r
81 public void removeElements(int start, int end)
\r
84 for (int i = start; i < end; i++)
\r
86 colInt = new Integer(i);
\r
87 if (selected.contains(colInt))
\r
89 selected.removeElement(colInt);
\r
96 * @return Vector containing selected columns as Integers
\r
98 public Vector getSelected()
\r
106 * index to search for in column selection
\r
108 * @return true if Integer(col) is in selection.
\r
110 public boolean contains(int col)
\r
112 return selected.contains(new Integer(col));
\r
116 * Column number at position i in selection
\r
119 * index into selected columns
\r
121 * @return column number in alignment
\r
123 public int columnAt(int i)
\r
125 return ((Integer) selected.elementAt(i)).intValue();
\r
131 * @return DOCUMENT ME!
\r
135 return selected.size();
\r
139 * rightmost selected column
\r
141 * @return rightmost column in alignment that is selected
\r
143 public int getMax()
\r
147 for (int i = 0; i < selected.size(); i++)
\r
149 if (columnAt(i) > max)
\r
159 * Leftmost column in selection
\r
161 * @return column index of leftmost column in selection
\r
163 public int getMin()
\r
165 int min = 1000000000;
\r
167 for (int i = 0; i < selected.size(); i++)
\r
169 if (columnAt(i) < min)
\r
179 * propagate shift in alignment columns to column selection
\r
182 * beginning of edit
\r
184 * shift in edit (+ve for removal, or -ve for inserts)
\r
186 public Vector compensateForEdit(int start, int change)
\r
188 Vector deletedHiddenColumns = null;
\r
189 for (int i = 0; i < size(); i++)
\r
191 int temp = columnAt(i);
\r
195 selected.setElementAt(new Integer(temp - change), i);
\r
199 if (hiddenColumns != null)
\r
201 deletedHiddenColumns = new Vector();
\r
202 int hSize = hiddenColumns.size();
\r
203 for (int i = 0; i < hSize; i++)
\r
205 int[] region = (int[]) hiddenColumns.elementAt(i);
\r
206 if (region[0] > start && start + change > region[1])
\r
208 deletedHiddenColumns.addElement(hiddenColumns.elementAt(i));
\r
210 hiddenColumns.removeElementAt(i);
\r
216 if (region[0] > start)
\r
218 region[0] -= change;
\r
219 region[1] -= change;
\r
229 this.revealHiddenColumns(0);
\r
232 return deletedHiddenColumns;
\r
236 * propagate shift in alignment columns to column selection special version of
\r
237 * compensateForEdit - allowing for edits within hidden regions
\r
240 * beginning of edit
\r
242 * shift in edit (+ve for removal, or -ve for inserts)
\r
244 private void compensateForDelEdits(int start, int change)
\r
246 for (int i = 0; i < size(); i++)
\r
248 int temp = columnAt(i);
\r
252 selected.setElementAt(new Integer(temp - change), i);
\r
256 if (hiddenColumns != null)
\r
258 for (int i = 0; i < hiddenColumns.size(); i++)
\r
260 int[] region = (int[]) hiddenColumns.elementAt(i);
\r
261 if (region[0] >= start)
\r
263 region[0] -= change;
\r
265 if (region[1] >= start)
\r
267 region[1] -= change;
\r
269 if (region[1] < region[0])
\r
271 hiddenColumns.removeElementAt(i--);
\r
287 * Adjust hidden column boundaries based on a series of column additions or
\r
288 * deletions in visible regions.
\r
290 * @param shiftrecord
\r
293 public ShiftList compensateForEdits(ShiftList shiftrecord)
\r
295 if (shiftrecord != null)
\r
297 Vector shifts = shiftrecord.shifts;
\r
298 if (shifts != null && shifts.size() > 0)
\r
301 for (int i = 0, j = shifts.size(); i < j; i++)
\r
303 int[] sh = (int[]) shifts.elementAt(i);
\r
304 // compensateForEdit(shifted+sh[0], sh[1]);
\r
305 compensateForDelEdits(shifted + sh[0], sh[1]);
\r
309 return shiftrecord.getInverse();
\r
315 * removes intersection of position,length ranges in deletions from the
\r
316 * start,end regions marked in intervals.
\r
322 private boolean pruneIntervalVector(Vector deletions, Vector intervals)
\r
324 boolean pruned = false;
\r
325 int i = 0, j = intervals.size() - 1, s = 0, t = deletions.size() - 1;
\r
326 int hr[] = (int[]) intervals.elementAt(i);
\r
327 int sr[] = (int[]) deletions.elementAt(s);
\r
328 while (i <= j && s <= t)
\r
330 boolean trailinghn = hr[1] >= sr[0];
\r
335 hr = (int[]) intervals.elementAt(++i);
\r
343 int endshift = sr[0] + sr[1]; // deletion ranges - -ve means an insert
\r
344 if (endshift < hr[0] || endshift < sr[0])
\r
345 { // leadinghc disjoint or not a deletion
\r
348 sr = (int[]) deletions.elementAt(++s);
\r
356 boolean leadinghn = hr[0] >= sr[0];
\r
357 boolean leadinghc = hr[0] < endshift;
\r
358 boolean trailinghc = hr[1] < endshift;
\r
362 { // deleted hidden region.
\r
363 intervals.removeElementAt(i);
\r
368 hr = (int[]) intervals.elementAt(i);
\r
374 hr[0] = endshift; // clip c terminal region
\r
375 leadinghn = !leadinghn;
\r
391 // sr contained in hr
\r
394 sr = (int[]) deletions.elementAt(++s);
\r
404 return pruned; // true if any interval was removed or modified by
\r
408 private boolean pruneColumnList(Vector deletion, Vector list)
\r
410 int s = 0, t = deletion.size();
\r
411 int[] sr = (int[]) list.elementAt(s++);
\r
412 boolean pruned = false;
\r
413 int i = 0, j = list.size();
\r
414 while (i < j && s <= t)
\r
416 int c = ((Integer) list.elementAt(i++)).intValue();
\r
419 if (sr[1] + sr[0] >= c)
\r
420 { // sr[1] -ve means inseriton.
\r
421 list.removeElementAt(--i);
\r
428 sr = (int[]) deletion.elementAt(s);
\r
438 * remove any hiddenColumns or selected columns and shift remaining based on a
\r
439 * series of position, range deletions.
\r
443 public void pruneDeletions(ShiftList deletions)
\r
445 if (deletions != null)
\r
447 Vector shifts = deletions.shifts;
\r
448 if (shifts != null && shifts.size() > 0)
\r
450 // delete any intervals intersecting.
\r
451 if (hiddenColumns != null)
\r
453 pruneIntervalVector(shifts, hiddenColumns);
\r
454 if (hiddenColumns != null && hiddenColumns.size() == 0)
\r
456 hiddenColumns = null;
\r
459 if (selected != null && selected.size() > 0)
\r
461 pruneColumnList(shifts, selected);
\r
462 if (selected != null && selected.size() == 0)
\r
467 // and shift the rest.
\r
468 this.compensateForEdits(deletions);
\r
474 * This Method is used to return all the HiddenColumn regions less than the
\r
481 public Vector getHiddenColumns()
\r
483 return hiddenColumns;
\r
487 * Return absolute column index for a visible column index
\r
490 * int column index in alignment view
\r
491 * @return alignment column index for column
\r
493 public int adjustForHiddenColumns(int column)
\r
495 int result = column;
\r
496 if (hiddenColumns != null)
\r
498 for (int i = 0; i < hiddenColumns.size(); i++)
\r
500 int[] region = (int[]) hiddenColumns.elementAt(i);
\r
501 if (result >= region[0])
\r
503 result += region[1] - region[0] + 1;
\r
511 * Use this method to find out where a column will appear in the visible
\r
512 * alignment when hidden columns exist. If the column is not visible, then the
\r
513 * left-most visible column will always be returned.
\r
515 * @param hiddenColumn
\r
519 public int findColumnPosition(int hiddenColumn)
\r
521 int result = hiddenColumn;
\r
522 if (hiddenColumns != null)
\r
528 region = (int[]) hiddenColumns.elementAt(index++);
\r
529 if (hiddenColumn > region[1])
\r
531 result -= region[1] + 1 - region[0];
\r
533 } while ((hiddenColumn > region[1]) && (index < hiddenColumns.size()));
\r
534 if (hiddenColumn > region[0] && hiddenColumn < region[1])
\r
536 return region[0] + hiddenColumn - result;
\r
539 return result; // return the shifted position after removing hidden columns.
\r
543 * Use this method to determine where the next hiddenRegion starts
\r
545 public int findHiddenRegionPosition(int hiddenRegion)
\r
548 if (hiddenColumns != null)
\r
554 int[] region = (int[]) hiddenColumns.elementAt(index);
\r
555 if (hiddenRegion == 0)
\r
560 gaps += region[1] + 1 - region[0];
\r
561 result = region[1] + 1;
\r
563 } while (index < hiddenRegion + 1);
\r
572 * THis method returns the rightmost limit of a region of an alignment with
\r
573 * hidden columns. In otherwords, the next hidden column.
\r
578 public int getHiddenBoundaryRight(int alPos)
\r
580 if (hiddenColumns != null)
\r
585 int[] region = (int[]) hiddenColumns.elementAt(index);
\r
586 if (alPos < region[0])
\r
592 } while (index < hiddenColumns.size());
\r
600 * This method returns the leftmost limit of a region of an alignment with
\r
601 * hidden columns. In otherwords, the previous hidden column.
\r
606 public int getHiddenBoundaryLeft(int alPos)
\r
608 if (hiddenColumns != null)
\r
610 int index = hiddenColumns.size() - 1;
\r
613 int[] region = (int[]) hiddenColumns.elementAt(index);
\r
614 if (alPos > region[1])
\r
620 } while (index > -1);
\r
627 public void hideSelectedColumns()
\r
631 int column = ((Integer) getSelected().firstElement()).intValue();
\r
632 hideColumns(column);
\r
637 public void hideColumns(int start, int end)
\r
639 if (hiddenColumns == null)
\r
641 hiddenColumns = new Vector();
\r
644 boolean added = false;
\r
645 boolean overlap = false;
\r
647 for (int i = 0; i < hiddenColumns.size(); i++)
\r
649 int[] region = (int[]) hiddenColumns.elementAt(i);
\r
650 if (start <= region[1] && end >= region[0])
\r
652 hiddenColumns.removeElementAt(i);
\r
656 else if (end < region[0] && start < region[0])
\r
658 hiddenColumns.insertElementAt(new int[]
\r
659 { start, end }, i);
\r
667 hideColumns(start, end);
\r
671 hiddenColumns.addElement(new int[]
\r
678 * This method will find a range of selected columns around the column
\r
684 public void hideColumns(int col)
\r
686 // First find out range of columns to hide
\r
687 int min = col, max = col + 1;
\r
688 while (contains(min))
\r
690 removeElement(min);
\r
694 while (contains(max))
\r
696 removeElement(max);
\r
707 hideColumns(min, max);
\r
710 public void revealAllHiddenColumns()
\r
712 if (hiddenColumns != null)
\r
714 for (int i = 0; i < hiddenColumns.size(); i++)
\r
716 int[] region = (int[]) hiddenColumns.elementAt(i);
\r
717 for (int j = region[0]; j < region[1] + 1; j++)
\r
724 hiddenColumns = null;
\r
727 public void revealHiddenColumns(int res)
\r
729 for (int i = 0; i < hiddenColumns.size(); i++)
\r
731 int[] region = (int[]) hiddenColumns.elementAt(i);
\r
732 if (res == region[0])
\r
734 for (int j = region[0]; j < region[1] + 1; j++)
\r
739 hiddenColumns.removeElement(region);
\r
743 if (hiddenColumns.size() == 0)
\r
745 hiddenColumns = null;
\r
749 public boolean isVisible(int column)
\r
751 if (hiddenColumns != null)
\r
752 for (int i = 0; i < hiddenColumns.size(); i++)
\r
754 int[] region = (int[]) hiddenColumns.elementAt(i);
\r
755 if (column >= region[0] && column <= region[1])
\r
769 public ColumnSelection(ColumnSelection copy)
\r
773 if (copy.selected != null)
\r
775 selected = new Vector();
\r
776 for (int i = 0, j = copy.selected.size(); i < j; i++)
\r
778 selected.addElement(copy.selected.elementAt(i));
\r
781 if (copy.hiddenColumns != null)
\r
783 hiddenColumns = new Vector(copy.hiddenColumns.size());
\r
784 for (int i = 0, j = copy.hiddenColumns.size(); i < j; i++)
\r
787 rh = (int[]) copy.hiddenColumns.elementAt(i);
\r
790 cp = new int[rh.length];
\r
791 System.arraycopy(rh, 0, cp, 0, rh.length);
\r
792 hiddenColumns.addElement(cp);
\r
802 public ColumnSelection()
\r
806 public String[] getVisibleSequenceStrings(int start, int end,
\r
809 int i, iSize = seqs.length;
\r
810 String selection[] = new String[iSize];
\r
811 if (hiddenColumns != null && hiddenColumns.size() > 0)
\r
813 for (i = 0; i < iSize; i++)
\r
815 StringBuffer visibleSeq = new StringBuffer();
\r
816 Vector regions = getHiddenColumns();
\r
818 int blockStart = start, blockEnd = end;
\r
820 int hideStart, hideEnd;
\r
822 for (int j = 0; j < regions.size(); j++)
\r
824 region = (int[]) regions.elementAt(j);
\r
825 hideStart = region[0];
\r
826 hideEnd = region[1];
\r
828 if (hideStart < start)
\r
833 blockStart = Math.min(blockStart, hideEnd + 1);
\r
834 blockEnd = Math.min(blockEnd, hideStart);
\r
836 if (blockStart > blockEnd)
\r
841 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
\r
843 blockStart = hideEnd + 1;
\r
847 if (end > blockStart)
\r
849 visibleSeq.append(seqs[i].getSequence(blockStart, end));
\r
852 selection[i] = visibleSeq.toString();
\r
857 for (i = 0; i < iSize; i++)
\r
859 selection[i] = seqs[i].getSequenceAsString(start, end);
\r
867 * return all visible segments between the given start and end boundaries
\r
870 * (first column inclusive from 0)
\r
872 * (last column - not inclusive)
\r
873 * @return int[] {i_start, i_end, ..} where intervals lie in
\r
874 * start<=i_start<=i_end<end
\r
876 public int[] getVisibleContigs(int start, int end)
\r
878 if (hiddenColumns != null && hiddenColumns.size() > 0)
\r
880 Vector visiblecontigs = new Vector();
\r
881 Vector regions = getHiddenColumns();
\r
883 int vstart = start;
\r
885 int hideStart, hideEnd;
\r
887 for (int j = 0; vstart < end && j < regions.size(); j++)
\r
889 region = (int[]) regions.elementAt(j);
\r
890 hideStart = region[0];
\r
891 hideEnd = region[1];
\r
893 if (hideEnd < vstart)
\r
897 if (hideStart > vstart)
\r
899 visiblecontigs.addElement(new int[]
\r
900 { vstart, hideStart - 1 });
\r
902 vstart = hideEnd + 1;
\r
907 visiblecontigs.addElement(new int[]
\r
908 { vstart, end - 1 });
\r
910 int[] vcontigs = new int[visiblecontigs.size() * 2];
\r
911 for (int i = 0, j = visiblecontigs.size(); i < j; i++)
\r
913 int[] vc = (int[]) visiblecontigs.elementAt(i);
\r
914 visiblecontigs.setElementAt(null, i);
\r
915 vcontigs[i * 2] = vc[0];
\r
916 vcontigs[i * 2 + 1] = vc[1];
\r
918 visiblecontigs.removeAllElements();
\r
924 { start, end - 1 };
\r
929 * delete any columns in alignmentAnnotation that are hidden (including
\r
930 * sequence associated annotation).
\r
932 * @param alignmentAnnotation
\r
934 public void makeVisibleAnnotation(AlignmentAnnotation alignmentAnnotation)
\r
936 makeVisibleAnnotation(-1, -1, alignmentAnnotation);
\r
940 * delete any columns in alignmentAnnotation that are hidden (including
\r
941 * sequence associated annotation).
\r
944 * remove any annotation to the right of this column
\r
946 * remove any annotation to the left of this column
\r
947 * @param alignmentAnnotation
\r
948 * the annotation to operate on
\r
950 public void makeVisibleAnnotation(int start, int end,
\r
951 AlignmentAnnotation alignmentAnnotation)
\r
953 if (alignmentAnnotation.annotations == null)
\r
957 if (start == end && end == -1)
\r
960 end = alignmentAnnotation.annotations.length;
\r
962 if (hiddenColumns != null && hiddenColumns.size() > 0)
\r
964 // then mangle the alignmentAnnotation annotation array
\r
965 Vector annels = new Vector();
\r
966 Annotation[] els = null;
\r
967 Vector regions = getHiddenColumns();
\r
968 int blockStart = start, blockEnd = end;
\r
970 int hideStart, hideEnd, w = 0;
\r
972 for (int j = 0; j < regions.size(); j++)
\r
974 region = (int[]) regions.elementAt(j);
\r
975 hideStart = region[0];
\r
976 hideEnd = region[1];
\r
978 if (hideStart < start)
\r
983 blockStart = Math.min(blockStart, hideEnd + 1);
\r
984 blockEnd = Math.min(blockEnd, hideStart);
\r
986 if (blockStart > blockEnd)
\r
991 annels.addElement(els = new Annotation[blockEnd - blockStart]);
\r
992 System.arraycopy(alignmentAnnotation.annotations, blockStart, els,
\r
995 blockStart = hideEnd + 1;
\r
999 if (end > blockStart)
\r
1001 annels.addElement(els = new Annotation[end - blockStart + 1]);
\r
1002 if ((els.length + blockStart) <= alignmentAnnotation.annotations.length)
\r
1004 // copy just the visible segment of the annotation row
\r
1005 System.arraycopy(alignmentAnnotation.annotations, blockStart,
\r
1006 els, 0, els.length);
\r
1010 // copy to the end of the annotation row
\r
1011 System.arraycopy(alignmentAnnotation.annotations, blockStart,
\r
1013 (alignmentAnnotation.annotations.length - blockStart));
\r
1019 Enumeration e = annels.elements();
\r
1020 alignmentAnnotation.annotations = new Annotation[w];
\r
1022 while (e.hasMoreElements())
\r
1024 Annotation[] chnk = (Annotation[]) e.nextElement();
\r
1025 System.arraycopy(chnk, 0, alignmentAnnotation.annotations, w,
\r
1032 alignmentAnnotation.restrict(start, end);
\r
1037 * Invert the column selection from first to end-1. leaves hiddenColumns
\r
1038 * untouched (and unselected)
\r
1043 public void invertColumnSelection(int first, int width)
\r
1045 boolean hasHidden = hiddenColumns != null && hiddenColumns.size() > 0;
\r
1046 for (int i = first; i < width; i++)
\r
1054 if (!hasHidden || isVisible(i))
\r
1063 * add in any unselected columns from the given column selection, excluding
\r
1064 * any that are hidden.
\r
1068 public void addElementsFrom(ColumnSelection colsel)
\r
1070 if (colsel != null && colsel.size() > 0)
\r
1072 Enumeration e = colsel.getSelected().elements();
\r
1073 while (e.hasMoreElements())
\r
1075 Object eo = e.nextElement();
\r
1076 if (hiddenColumns != null && isVisible(((Integer) eo).intValue()))
\r
1078 if (!selected.contains(eo))
\r
1080 selected.addElement(eo);
\r
1088 * set the selected columns the given column selection, excluding any columns
\r
1089 * that are hidden.
\r
1093 public void setElementsFrom(ColumnSelection colsel)
\r
1095 selected = new Vector();
\r
1096 if (colsel.selected != null && colsel.selected.size() > 0)
\r
1098 if (hiddenColumns != null && hiddenColumns.size() > 0)
\r
1100 // only select visible columns in this columns selection
\r
1101 selected = new Vector();
\r
1102 addElementsFrom(colsel);
\r
1106 // add everything regardless
\r
1107 Enumeration en = colsel.selected.elements();
\r
1108 while (en.hasMoreElements())
\r
1110 selected.addElement(en.nextElement());
\r
1117 * Add gaps into the sequences aligned to profileseq under the given
\r
1120 * @param profileseq
\r
1121 * @param al - alignment to have gaps inserted into it
\r
1122 * @param input - alignment view where sequence corresponding to profileseq is first entry
\r
1123 * @return new Column selection for new alignment view, with insertions into profileseq marked as hidden.
\r
1125 public static ColumnSelection propagateInsertions(SequenceI profileseq,
\r
1126 Alignment al, AlignmentView input)
\r
1130 // return propagateInsertions(profileseq, al, )
\r
1131 char gc = al.getGapCharacter();
\r
1132 Object[] alandcolsel = input.getAlignmentAndColumnSelection(gc);
\r
1133 ColumnSelection nview = (ColumnSelection) alandcolsel[1];
\r
1134 SequenceI origseq = ((SequenceI[]) alandcolsel[0])[profsqpos];
\r
1135 nview.propagateInsertions(profileseq,
\r
1141 * @param profileseq - sequence in al which corresponds to origseq
\r
1142 * @param al - alignment which is to have gaps inserted into it
\r
1143 * @param origseq - sequence corresponding to profileseq which defines gap map for modifying al
\r
1145 public void propagateInsertions(SequenceI profileseq, AlignmentI al, SequenceI origseq)
\r
1147 char gc = al.getGapCharacter();
\r
1148 // recover mapping between sequence's non-gap positions and positions
\r
1149 // mapping to view.
\r
1150 pruneDeletions(ShiftList
\r
1153 int[] viscontigs = getVisibleContigs(0, profileseq.getLength());
\r
1156 // input.pruneDeletions(ShiftList.parseMap(((SequenceI[])
\r
1157 // alandcolsel[0])[0].gapMap()))
\r
1158 // add profile to visible contigs
\r
1159 for (int v = 0; v < viscontigs.length; v += 2)
\r
1161 if (viscontigs[v] > spos)
\r
1163 StringBuffer sb = new StringBuffer();
\r
1164 for (int s = 0, ns = viscontigs[v] - spos; s < ns; s++)
\r
1168 for (int s = 0, ns = al.getHeight(); s < ns; s++)
\r
1170 SequenceI sqobj = al.getSequenceAt(s);
\r
1171 if (sqobj != profileseq)
\r
1173 String sq = al.getSequenceAt(s).getSequenceAsString();
\r
1174 if (sq.length() <= spos + offset)
\r
1177 int diff = spos + offset - sq.length() - 1;
\r
1182 while ((diff = spos + offset - sq.length() - 1) > 0)
\r
1185 // + ((diff >= sb.length()) ? sb.toString() : sb
\r
1186 // .substring(0, diff));
\r
1187 if (diff>=sb.length()) {
\r
1188 sq+=sb.toString();
\r
1190 char[] buf = new char[diff];
\r
1191 sb.getChars(0, diff, buf, 0);
\r
1192 sq+=buf.toString();
\r
1196 sq += sb.toString();
\r
1200 al.getSequenceAt(s).setSequence(
\r
1201 sq.substring(0, spos + offset) + sb.toString()
\r
1202 + sq.substring(spos + offset));
\r
1206 // offset+=sb.length();
\r
1208 spos = viscontigs[v + 1] + 1;
\r
1210 if ((offset + spos) < profileseq.getLength())
\r
1212 // pad the final region with gaps.
\r
1213 StringBuffer sb = new StringBuffer();
\r
1214 for (int s = 0, ns = profileseq.getLength() - spos - offset; s < ns; s++)
\r
1218 for (int s = 0, ns = al.getHeight(); s < ns; s++)
\r
1220 SequenceI sqobj = al.getSequenceAt(s);
\r
1221 if (sqobj==profileseq)
\r
1225 String sq = sqobj.getSequenceAsString();
\r
1227 int diff = origseq.getLength() - sq.length();
\r
1231 // + ((diff >= sb.length()) ? sb.toString() : sb
\r
1232 // .substring(0, diff));
\r
1233 if (diff>=sb.length()) {
\r
1234 sq+=sb.toString();
\r
1236 char[] buf = new char[diff];
\r
1237 sb.getChars(0, diff, buf, 0);
\r
1238 sq+=buf.toString();
\r
1240 diff = origseq.getLength() - sq.length();
\r