2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel;
23 import jalview.util.ShiftList;
24 import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
25 import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField;
27 import java.util.ArrayList;
28 import java.util.BitSet;
29 import java.util.Collections;
30 import java.util.List;
31 import java.util.Vector;
34 * NOTE: Columns are zero based.
36 public class ColumnSelection
41 * list of selected columns (ordered by selection order, not column order)
43 private List<Integer> order = new ArrayList<Integer>();
46 * bitfield for column selection - allows quick lookup
48 private BitSet selected = new BitSet();
51 * adds a new column i to the selection - only if i is not already selected
55 public void add(int i)
59 order.add(Integer.valueOf(i));
70 public void remove(int col)
73 Integer colInt = new Integer(col);
75 if (selected.get(col))
77 // if this ever changes to List.remove(), ensure Integer not int
79 // as List.remove(int i) removes the i'th item which is wrong
85 public boolean contains(Integer colInt)
87 return selected.get(colInt);
90 public boolean isEmpty()
92 return order.isEmpty();
95 public List<Integer> getList()
106 * gets the column that was selected first, second or i'th
111 public int elementAt(int i)
116 protected boolean pruneColumnList(final List<int[]> shifts)
118 int s = 0, t = shifts.size();
119 int[] sr = shifts.get(s++);
120 boolean pruned = false;
121 int i = 0, j = order.size();
122 while (i < j && s <= t)
124 int c = order.get(i++).intValue();
127 if (sr[1] + sr[0] >= c)
128 { // sr[1] -ve means inseriton.
147 * shift every selected column at or above start by change
150 * - leftmost column to be shifted
154 public void compensateForEdits(int start, int change)
156 BitSet mask = new BitSet();
157 for (int i = 0; i < order.size(); i++)
159 int temp = order.get(i);
163 // clear shifted bits and update List of selected columns
164 selected.clear(temp);
165 mask.set(temp - change);
166 order.set(i, new Integer(temp - change));
169 // lastly update the bitfield all at once
173 public boolean isSelected(int column)
175 return selected.get(column);
178 public int getMaxColumn()
180 return selected.length() - 1;
183 public int getMinColumn()
185 return selected.get(0) ? 0 : selected.nextSetBit(0);
189 * @return a series of selection intervals along the range
191 public List<int[]> getRanges()
193 List<int[]> rlist = new ArrayList<int[]>();
194 if (selected.isEmpty())
198 int next = selected.nextSetBit(0), clear = -1;
201 clear = selected.nextClearBit(next);
202 rlist.add(new int[] { next, clear - 1 });
203 next = selected.nextSetBit(clear);
209 IntList selected = new IntList();
211 * list of hidden column [start, end] ranges; the list is maintained in
212 * ascending start column order
214 Vector<int[]> hiddenColumns;
217 * Add a column to the selection
222 public void addElement(int col)
228 * clears column selection
236 * Removes value 'col' from the selection (not the col'th item)
239 * index of column to be removed
241 public void removeElement(int col)
243 selected.remove(col);
247 * removes a range of columns from the selection
250 * int - first column in range to be removed
254 public void removeElements(int start, int end)
257 for (int i = start; i < end; i++)
259 colInt = new Integer(i);
260 if (selected.contains(colInt))
262 selected.remove(colInt);
268 * Returns a list of selected columns. The list contains no duplicates but is
269 * not necessarily ordered. It also may include columns hidden from the
272 public List<Integer> getSelected()
274 return selected.getList();
278 * @return list of int arrays containing start and end column position for
279 * runs of selected columns ordered from right to left.
281 public List<int[]> getSelectedRanges()
283 return selected.getRanges();
289 * index to search for in column selection
291 * @return true if col is selected
293 public boolean contains(int col)
295 return (col > -1) ? selected.isSelected(col) : false;
299 * Answers true if no columns are selected, else false
301 public boolean isEmpty()
303 return selected == null || selected.isEmpty();
307 * rightmost selected column
309 * @return rightmost column in alignment that is selected
313 if (selected.isEmpty())
317 return selected.getMaxColumn();
321 * Leftmost column in selection
323 * @return column index of leftmost column in selection
327 if (selected.isEmpty())
331 return selected.getMinColumn();
335 * propagate shift in alignment columns to column selection
340 * shift in edit (+ve for removal, or -ve for inserts)
342 public List<int[]> compensateForEdit(int start, int change)
344 List<int[]> deletedHiddenColumns = null;
345 selected.compensateForEdits(start, change);
347 if (hiddenColumns != null)
349 deletedHiddenColumns = new ArrayList<int[]>();
350 int hSize = hiddenColumns.size();
351 for (int i = 0; i < hSize; i++)
353 int[] region = hiddenColumns.elementAt(i);
354 if (region[0] > start && start + change > region[1])
356 deletedHiddenColumns.add(region);
358 hiddenColumns.removeElementAt(i);
364 if (region[0] > start)
377 this.revealHiddenColumns(0);
380 return deletedHiddenColumns;
384 * propagate shift in alignment columns to column selection special version of
385 * compensateForEdit - allowing for edits within hidden regions
390 * shift in edit (+ve for removal, or -ve for inserts)
392 private void compensateForDelEdits(int start, int change)
395 selected.compensateForEdits(start, change);
397 if (hiddenColumns != null)
399 for (int i = 0; i < hiddenColumns.size(); i++)
401 int[] region = hiddenColumns.elementAt(i);
402 if (region[0] >= start)
406 if (region[1] >= start)
410 if (region[1] < region[0])
412 hiddenColumns.removeElementAt(i--);
428 * Adjust hidden column boundaries based on a series of column additions or
429 * deletions in visible regions.
434 public ShiftList compensateForEdits(ShiftList shiftrecord)
436 if (shiftrecord != null)
438 final List<int[]> shifts = shiftrecord.getShifts();
439 if (shifts != null && shifts.size() > 0)
442 for (int i = 0, j = shifts.size(); i < j; i++)
444 int[] sh = shifts.get(i);
445 // compensateForEdit(shifted+sh[0], sh[1]);
446 compensateForDelEdits(shifted + sh[0], sh[1]);
450 return shiftrecord.getInverse();
456 * removes intersection of position,length ranges in deletions from the
457 * start,end regions marked in intervals.
463 private boolean pruneIntervalVector(final List<int[]> shifts,
464 Vector<int[]> intervals)
466 boolean pruned = false;
467 int i = 0, j = intervals.size() - 1, s = 0, t = shifts.size() - 1;
468 int hr[] = intervals.elementAt(i);
469 int sr[] = shifts.get(s);
470 while (i <= j && s <= t)
472 boolean trailinghn = hr[1] >= sr[0];
477 hr = intervals.elementAt(++i);
485 int endshift = sr[0] + sr[1]; // deletion ranges - -ve means an insert
486 if (endshift < hr[0] || endshift < sr[0])
487 { // leadinghc disjoint or not a deletion
490 sr = shifts.get(++s);
498 boolean leadinghn = hr[0] >= sr[0];
499 boolean leadinghc = hr[0] < endshift;
500 boolean trailinghc = hr[1] < endshift;
504 { // deleted hidden region.
505 intervals.removeElementAt(i);
510 hr = intervals.elementAt(i);
516 hr[0] = endshift; // clip c terminal region
517 leadinghn = !leadinghn;
533 // sr contained in hr
536 sr = shifts.get(++s);
546 return pruned; // true if any interval was removed or modified by
551 * remove any hiddenColumns or selected columns and shift remaining based on a
552 * series of position, range deletions.
556 public void pruneDeletions(ShiftList deletions)
558 if (deletions != null)
560 final List<int[]> shifts = deletions.getShifts();
561 if (shifts != null && shifts.size() > 0)
563 // delete any intervals intersecting.
564 if (hiddenColumns != null)
566 pruneIntervalVector(shifts, hiddenColumns);
567 if (hiddenColumns != null && hiddenColumns.size() == 0)
569 hiddenColumns = null;
572 if (selected != null && selected.size() > 0)
574 selected.pruneColumnList(shifts);
575 if (selected != null && selected.size() == 0)
580 // and shift the rest.
581 this.compensateForEdits(deletions);
587 * This Method is used to return all the HiddenColumn regions
589 * @return empty list or List of hidden column intervals
591 public List<int[]> getHiddenColumns()
593 return hiddenColumns == null ? Collections.<int[]> emptyList()
598 * Return absolute column index for a visible column index
601 * int column index in alignment view
602 * @return alignment column index for column
604 public int adjustForHiddenColumns(int column)
607 if (hiddenColumns != null)
609 for (int i = 0; i < hiddenColumns.size(); i++)
611 int[] region = hiddenColumns.elementAt(i);
612 if (result >= region[0])
614 result += region[1] - region[0] + 1;
622 * Use this method to find out where a column will appear in the visible
623 * alignment when hidden columns exist. If the column is not visible, then the
624 * left-most visible column will always be returned.
626 * @param hiddenColumn
630 public int findColumnPosition(int hiddenColumn)
632 int result = hiddenColumn;
633 if (hiddenColumns != null)
639 region = hiddenColumns.elementAt(index++);
640 if (hiddenColumn > region[1])
642 result -= region[1] + 1 - region[0];
644 } while ((hiddenColumn > region[1]) && (index < hiddenColumns.size()));
645 if (hiddenColumn > region[0] && hiddenColumn < region[1])
647 return region[0] + hiddenColumn - result;
650 return result; // return the shifted position after removing hidden columns.
654 * Use this method to determine where the next hiddenRegion starts
656 * @param hiddenRegion
657 * index of hidden region (counts from 0)
658 * @return column number in visible view
660 public int findHiddenRegionPosition(int hiddenRegion)
663 if (hiddenColumns != null)
669 int[] region = hiddenColumns.elementAt(index);
670 if (hiddenRegion == 0)
675 gaps += region[1] + 1 - region[0];
676 result = region[1] + 1;
678 } while (index <= hiddenRegion);
687 * THis method returns the rightmost limit of a region of an alignment with
688 * hidden columns. In otherwords, the next hidden column.
693 public int getHiddenBoundaryRight(int alPos)
695 if (hiddenColumns != null)
700 int[] region = hiddenColumns.elementAt(index);
701 if (alPos < region[0])
707 } while (index < hiddenColumns.size());
715 * This method returns the leftmost limit of a region of an alignment with
716 * hidden columns. In otherwords, the previous hidden column.
721 public int getHiddenBoundaryLeft(int alPos)
723 if (hiddenColumns != null)
725 int index = hiddenColumns.size() - 1;
728 int[] region = hiddenColumns.elementAt(index);
729 if (alPos > region[1])
735 } while (index > -1);
742 public void hideSelectedColumns()
744 synchronized (selected) {
745 for (int[] selregions:selected.getRanges())
747 hideColumns(selregions[0], selregions[1]);
755 * Adds the specified column range to the hidden columns
760 public void hideColumns(int start, int end)
762 if (hiddenColumns == null)
764 hiddenColumns = new Vector<int[]>();
768 * traverse existing hidden ranges and insert / amend / append as
771 for (int i = 0; i < hiddenColumns.size(); i++)
773 int[] region = hiddenColumns.elementAt(i);
775 if (end < region[0] - 1)
778 * insert discontiguous preceding range
780 hiddenColumns.insertElementAt(new int[] { start, end }, i);
784 if (end <= region[1])
787 * new range overlaps existing, or is contiguous preceding it - adjust
790 region[0] = Math.min(region[0], start);
794 if (start <= region[1] + 1)
797 * new range overlaps existing, or is contiguous following it - adjust
798 * start and end columns
800 region[0] = Math.min(region[0], start);
801 region[1] = Math.max(region[1], end);
807 * remaining case is that the new range follows everything else
809 hiddenColumns.addElement(new int[] { start, end });
813 * Hides the specified column and any adjacent selected columns
818 public void hideColumns(int col)
821 * deselect column (whether selected or not!)
826 * find adjacent selected columns
828 int min = col - 1, max = col + 1;
829 while (contains(min))
835 while (contains(max))
842 * min, max are now the closest unselected columns
851 hideColumns(min, max);
855 * Unhides, and adds to the selection list, all hidden columns
857 public void revealAllHiddenColumns()
859 if (hiddenColumns != null)
861 for (int i = 0; i < hiddenColumns.size(); i++)
863 int[] region = hiddenColumns.elementAt(i);
864 for (int j = region[0]; j < region[1] + 1; j++)
871 hiddenColumns = null;
875 * Reveals, and marks as selected, the hidden column range with the given
880 public void revealHiddenColumns(int start)
882 for (int i = 0; i < hiddenColumns.size(); i++)
884 int[] region = hiddenColumns.elementAt(i);
885 if (start == region[0])
887 for (int j = region[0]; j < region[1] + 1; j++)
892 hiddenColumns.removeElement(region);
896 if (hiddenColumns.size() == 0)
898 hiddenColumns = null;
902 public boolean isVisible(int column)
904 if (hiddenColumns != null)
906 for (int[] region : hiddenColumns)
908 if (column >= region[0] && column <= region[1])
923 public ColumnSelection(ColumnSelection copy)
927 if (copy.selected != null)
929 selected = new IntList();
930 for (int i = 0, j = copy.selected.size(); i < j; i++)
932 selected.add(copy.selected.elementAt(i));
935 if (copy.hiddenColumns != null)
937 hiddenColumns = new Vector<int[]>(copy.hiddenColumns.size());
938 for (int i = 0, j = copy.hiddenColumns.size(); i < j; i++)
941 rh = copy.hiddenColumns.elementAt(i);
944 cp = new int[rh.length];
945 System.arraycopy(rh, 0, cp, 0, rh.length);
946 hiddenColumns.addElement(cp);
956 public ColumnSelection()
960 public String[] getVisibleSequenceStrings(int start, int end,
963 int i, iSize = seqs.length;
964 String selection[] = new String[iSize];
965 if (hiddenColumns != null && hiddenColumns.size() > 0)
967 for (i = 0; i < iSize; i++)
969 StringBuffer visibleSeq = new StringBuffer();
970 List<int[]> regions = getHiddenColumns();
972 int blockStart = start, blockEnd = end;
974 int hideStart, hideEnd;
976 for (int j = 0; j < regions.size(); j++)
978 region = regions.get(j);
979 hideStart = region[0];
982 if (hideStart < start)
987 blockStart = Math.min(blockStart, hideEnd + 1);
988 blockEnd = Math.min(blockEnd, hideStart);
990 if (blockStart > blockEnd)
995 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
997 blockStart = hideEnd + 1;
1001 if (end > blockStart)
1003 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1006 selection[i] = visibleSeq.toString();
1011 for (i = 0; i < iSize; i++)
1013 selection[i] = seqs[i].getSequenceAsString(start, end);
1021 * return all visible segments between the given start and end boundaries
1024 * (first column inclusive from 0)
1026 * (last column - not inclusive)
1027 * @return int[] {i_start, i_end, ..} where intervals lie in
1028 * start<=i_start<=i_end<end
1030 public int[] getVisibleContigs(int start, int end)
1032 if (hiddenColumns != null && hiddenColumns.size() > 0)
1034 List<int[]> visiblecontigs = new ArrayList<int[]>();
1035 List<int[]> regions = getHiddenColumns();
1039 int hideStart, hideEnd;
1041 for (int j = 0; vstart < end && j < regions.size(); j++)
1043 region = regions.get(j);
1044 hideStart = region[0];
1045 hideEnd = region[1];
1047 if (hideEnd < vstart)
1051 if (hideStart > vstart)
1053 visiblecontigs.add(new int[] { vstart, hideStart - 1 });
1055 vstart = hideEnd + 1;
1060 visiblecontigs.add(new int[] { vstart, end - 1 });
1062 int[] vcontigs = new int[visiblecontigs.size() * 2];
1063 for (int i = 0, j = visiblecontigs.size(); i < j; i++)
1065 int[] vc = visiblecontigs.get(i);
1066 visiblecontigs.set(i, null);
1067 vcontigs[i * 2] = vc[0];
1068 vcontigs[i * 2 + 1] = vc[1];
1070 visiblecontigs.clear();
1075 return new int[] { start, end - 1 };
1080 * delete any columns in alignmentAnnotation that are hidden (including
1081 * sequence associated annotation).
1083 * @param alignmentAnnotation
1085 public void makeVisibleAnnotation(AlignmentAnnotation alignmentAnnotation)
1087 makeVisibleAnnotation(-1, -1, alignmentAnnotation);
1091 * delete any columns in alignmentAnnotation that are hidden (including
1092 * sequence associated annotation).
1095 * remove any annotation to the right of this column
1097 * remove any annotation to the left of this column
1098 * @param alignmentAnnotation
1099 * the annotation to operate on
1101 public void makeVisibleAnnotation(int start, int end,
1102 AlignmentAnnotation alignmentAnnotation)
1104 if (alignmentAnnotation.annotations == null)
1108 if (start == end && end == -1)
1111 end = alignmentAnnotation.annotations.length;
1113 if (hiddenColumns != null && hiddenColumns.size() > 0)
1115 // then mangle the alignmentAnnotation annotation array
1116 Vector<Annotation[]> annels = new Vector<Annotation[]>();
1117 Annotation[] els = null;
1118 List<int[]> regions = getHiddenColumns();
1119 int blockStart = start, blockEnd = end;
1121 int hideStart, hideEnd, w = 0;
1123 for (int j = 0; j < regions.size(); j++)
1125 region = regions.get(j);
1126 hideStart = region[0];
1127 hideEnd = region[1];
1129 if (hideStart < start)
1134 blockStart = Math.min(blockStart, hideEnd + 1);
1135 blockEnd = Math.min(blockEnd, hideStart);
1137 if (blockStart > blockEnd)
1142 annels.addElement(els = new Annotation[blockEnd - blockStart]);
1143 System.arraycopy(alignmentAnnotation.annotations, blockStart, els,
1146 blockStart = hideEnd + 1;
1150 if (end > blockStart)
1152 annels.addElement(els = new Annotation[end - blockStart + 1]);
1153 if ((els.length + blockStart) <= alignmentAnnotation.annotations.length)
1155 // copy just the visible segment of the annotation row
1156 System.arraycopy(alignmentAnnotation.annotations, blockStart,
1157 els, 0, els.length);
1161 // copy to the end of the annotation row
1162 System.arraycopy(alignmentAnnotation.annotations, blockStart,
1164 (alignmentAnnotation.annotations.length - blockStart));
1173 alignmentAnnotation.annotations = new Annotation[w];
1176 for (Annotation[] chnk : annels)
1178 System.arraycopy(chnk, 0, alignmentAnnotation.annotations, w,
1185 alignmentAnnotation.restrict(start, end);
1190 * Invert the column selection from first to end-1. leaves hiddenColumns
1191 * untouched (and unselected)
1196 public void invertColumnSelection(int first, int width)
1198 boolean hasHidden = hiddenColumns != null && hiddenColumns.size() > 0;
1199 for (int i = first; i < width; i++)
1207 if (!hasHidden || isVisible(i))
1216 * add in any unselected columns from the given column selection, excluding
1217 * any that are hidden.
1221 public void addElementsFrom(ColumnSelection colsel)
1223 if (colsel != null && !colsel.isEmpty())
1225 for (Integer col : colsel.getSelected())
1227 if (hiddenColumns != null && isVisible(col.intValue()))
1236 * set the selected columns the given column selection, excluding any columns
1241 public void setElementsFrom(ColumnSelection colsel)
1243 selected = new IntList();
1244 if (colsel.selected != null && colsel.selected.size() > 0)
1246 if (hiddenColumns != null && hiddenColumns.size() > 0)
1248 // only select visible columns in this columns selection
1249 addElementsFrom(colsel);
1253 // add everything regardless
1254 for (Integer col : colsel.getSelected())
1263 * Add gaps into the sequences aligned to profileseq under the given
1268 * - alignment to have gaps inserted into it
1270 * - alignment view where sequence corresponding to profileseq is
1272 * @return new Column selection for new alignment view, with insertions into
1273 * profileseq marked as hidden.
1275 public static ColumnSelection propagateInsertions(SequenceI profileseq,
1276 AlignmentI al, AlignmentView input)
1280 // return propagateInsertions(profileseq, al, )
1281 char gc = al.getGapCharacter();
1282 Object[] alandcolsel = input.getAlignmentAndColumnSelection(gc);
1283 ColumnSelection nview = (ColumnSelection) alandcolsel[1];
1284 SequenceI origseq = ((SequenceI[]) alandcolsel[0])[profsqpos];
1285 nview.propagateInsertions(profileseq, al, origseq);
1292 * - sequence in al which corresponds to origseq
1294 * - alignment which is to have gaps inserted into it
1296 * - sequence corresponding to profileseq which defines gap map for
1299 public void propagateInsertions(SequenceI profileseq, AlignmentI al,
1302 char gc = al.getGapCharacter();
1303 // recover mapping between sequence's non-gap positions and positions
1305 pruneDeletions(ShiftList.parseMap(origseq.gapMap()));
1306 int[] viscontigs = getVisibleContigs(0, profileseq.getLength());
1309 // input.pruneDeletions(ShiftList.parseMap(((SequenceI[])
1310 // alandcolsel[0])[0].gapMap()))
1311 // add profile to visible contigs
1312 for (int v = 0; v < viscontigs.length; v += 2)
1314 if (viscontigs[v] > spos)
1316 StringBuffer sb = new StringBuffer();
1317 for (int s = 0, ns = viscontigs[v] - spos; s < ns; s++)
1321 for (int s = 0, ns = al.getHeight(); s < ns; s++)
1323 SequenceI sqobj = al.getSequenceAt(s);
1324 if (sqobj != profileseq)
1326 String sq = al.getSequenceAt(s).getSequenceAsString();
1327 if (sq.length() <= spos + offset)
1330 int diff = spos + offset - sq.length() - 1;
1335 while ((diff = spos + offset - sq.length() - 1) > 0)
1338 // + ((diff >= sb.length()) ? sb.toString() : sb
1339 // .substring(0, diff));
1340 if (diff >= sb.length())
1342 sq += sb.toString();
1346 char[] buf = new char[diff];
1347 sb.getChars(0, diff, buf, 0);
1348 sq += buf.toString();
1352 sq += sb.toString();
1356 al.getSequenceAt(s).setSequence(
1357 sq.substring(0, spos + offset) + sb.toString()
1358 + sq.substring(spos + offset));
1362 // offset+=sb.length();
1364 spos = viscontigs[v + 1] + 1;
1366 if ((offset + spos) < profileseq.getLength())
1368 // pad the final region with gaps.
1369 StringBuffer sb = new StringBuffer();
1370 for (int s = 0, ns = profileseq.getLength() - spos - offset; s < ns; s++)
1374 for (int s = 0, ns = al.getHeight(); s < ns; s++)
1376 SequenceI sqobj = al.getSequenceAt(s);
1377 if (sqobj == profileseq)
1381 String sq = sqobj.getSequenceAsString();
1383 int diff = origseq.getLength() - sq.length();
1387 // + ((diff >= sb.length()) ? sb.toString() : sb
1388 // .substring(0, diff));
1389 if (diff >= sb.length())
1391 sq += sb.toString();
1395 char[] buf = new char[diff];
1396 sb.getChars(0, diff, buf, 0);
1397 sq += buf.toString();
1399 diff = origseq.getLength() - sq.length();
1407 * @return true if there are columns marked
1409 public boolean hasSelectedColumns()
1411 return (selected != null && selected.size() > 0);
1416 * @return true if there are columns hidden
1418 public boolean hasHiddenColumns()
1420 return hiddenColumns != null && hiddenColumns.size() > 0;
1425 * @return true if there are more than one set of columns hidden
1427 public boolean hasManyHiddenColumns()
1429 return hiddenColumns != null && hiddenColumns.size() > 1;
1433 * mark the columns corresponding to gap characters as hidden in the column
1438 public void hideInsertionsFor(SequenceI sr)
1440 List<int[]> inserts = sr.getInsertions();
1441 for (int[] r : inserts)
1443 hideColumns(r[0], r[1]);
1447 public boolean filterAnnotations(Annotation[] annotations,
1448 AnnotationFilterParameter filterParams)
1450 this.revealAllHiddenColumns();
1455 if (annotations[count] != null)
1458 boolean itemMatched = false;
1460 if (filterParams.getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD
1461 && annotations[count].value >= filterParams
1462 .getThresholdValue())
1466 if (filterParams.getThresholdType() == AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD
1467 && annotations[count].value <= filterParams
1468 .getThresholdValue())
1473 if (filterParams.isFilterAlphaHelix()
1474 && annotations[count].secondaryStructure == 'H')
1479 if (filterParams.isFilterBetaSheet()
1480 && annotations[count].secondaryStructure == 'E')
1485 if (filterParams.isFilterTurn()
1486 && annotations[count].secondaryStructure == 'S')
1491 String regexSearchString = filterParams.getRegexString();
1492 if (regexSearchString != null
1493 && !filterParams.getRegexSearchFields().isEmpty())
1495 List<SearchableAnnotationField> fields = filterParams
1496 .getRegexSearchFields();
1499 if (fields.contains(SearchableAnnotationField.DISPLAY_STRING)
1500 && annotations[count].displayCharacter
1501 .matches(regexSearchString))
1505 } catch (java.util.regex.PatternSyntaxException pse)
1507 if (annotations[count].displayCharacter
1508 .equals(regexSearchString))
1513 if (fields.contains(SearchableAnnotationField.DESCRIPTION)
1514 && annotations[count].description != null
1515 && annotations[count].description
1516 .matches(regexSearchString))
1524 this.addElement(count);
1528 } while (count < annotations.length);