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();
212 * list of hidden column [start, end] ranges; the list is maintained in
213 * ascending start column order
215 Vector<int[]> hiddenColumns;
218 * Add a column to the selection
223 public void addElement(int col)
229 * clears column selection
237 * Removes value 'col' from the selection (not the col'th item)
240 * index of column to be removed
242 public void removeElement(int col)
244 selected.remove(col);
248 * removes a range of columns from the selection
251 * int - first column in range to be removed
255 public void removeElements(int start, int end)
258 for (int i = start; i < end; i++)
260 colInt = new Integer(i);
261 if (selected.contains(colInt))
263 selected.remove(colInt);
269 * Returns a list of selected columns. The list contains no duplicates but is
270 * not necessarily ordered. It also may include columns hidden from the
273 public List<Integer> getSelected()
275 return selected.getList();
279 * @return list of int arrays containing start and end column position for
280 * runs of selected columns ordered from right to left.
282 public List<int[]> getSelectedRanges()
284 return selected.getRanges();
290 * index to search for in column selection
292 * @return true if col is selected
294 public boolean contains(int col)
296 return (col > -1) ? selected.isSelected(col) : false;
300 * Answers true if no columns are selected, else false
302 public boolean isEmpty()
304 return selected == null || selected.isEmpty();
308 * rightmost selected column
310 * @return rightmost column in alignment that is selected
314 if (selected.isEmpty())
318 return selected.getMaxColumn();
322 * Leftmost column in selection
324 * @return column index of leftmost column in selection
328 if (selected.isEmpty())
332 return selected.getMinColumn();
336 * propagate shift in alignment columns to column selection
341 * shift in edit (+ve for removal, or -ve for inserts)
343 public List<int[]> compensateForEdit(int start, int change)
345 List<int[]> deletedHiddenColumns = null;
346 selected.compensateForEdits(start, change);
348 if (hiddenColumns != null)
350 deletedHiddenColumns = new ArrayList<int[]>();
351 int hSize = hiddenColumns.size();
352 for (int i = 0; i < hSize; i++)
354 int[] region = hiddenColumns.elementAt(i);
355 if (region[0] > start && start + change > region[1])
357 deletedHiddenColumns.add(region);
359 hiddenColumns.removeElementAt(i);
365 if (region[0] > start)
378 this.revealHiddenColumns(0);
381 return deletedHiddenColumns;
385 * propagate shift in alignment columns to column selection special version of
386 * compensateForEdit - allowing for edits within hidden regions
391 * shift in edit (+ve for removal, or -ve for inserts)
393 private void compensateForDelEdits(int start, int change)
396 selected.compensateForEdits(start, change);
398 if (hiddenColumns != null)
400 for (int i = 0; i < hiddenColumns.size(); i++)
402 int[] region = hiddenColumns.elementAt(i);
403 if (region[0] >= start)
407 if (region[1] >= start)
411 if (region[1] < region[0])
413 hiddenColumns.removeElementAt(i--);
429 * Adjust hidden column boundaries based on a series of column additions or
430 * deletions in visible regions.
435 public ShiftList compensateForEdits(ShiftList shiftrecord)
437 if (shiftrecord != null)
439 final List<int[]> shifts = shiftrecord.getShifts();
440 if (shifts != null && shifts.size() > 0)
443 for (int i = 0, j = shifts.size(); i < j; i++)
445 int[] sh = shifts.get(i);
446 // compensateForEdit(shifted+sh[0], sh[1]);
447 compensateForDelEdits(shifted + sh[0], sh[1]);
451 return shiftrecord.getInverse();
457 * removes intersection of position,length ranges in deletions from the
458 * start,end regions marked in intervals.
464 private boolean pruneIntervalVector(final List<int[]> shifts,
465 Vector<int[]> intervals)
467 boolean pruned = false;
468 int i = 0, j = intervals.size() - 1, s = 0, t = shifts.size() - 1;
469 int hr[] = intervals.elementAt(i);
470 int sr[] = shifts.get(s);
471 while (i <= j && s <= t)
473 boolean trailinghn = hr[1] >= sr[0];
478 hr = intervals.elementAt(++i);
486 int endshift = sr[0] + sr[1]; // deletion ranges - -ve means an insert
487 if (endshift < hr[0] || endshift < sr[0])
488 { // leadinghc disjoint or not a deletion
491 sr = shifts.get(++s);
499 boolean leadinghn = hr[0] >= sr[0];
500 boolean leadinghc = hr[0] < endshift;
501 boolean trailinghc = hr[1] < endshift;
505 { // deleted hidden region.
506 intervals.removeElementAt(i);
511 hr = intervals.elementAt(i);
517 hr[0] = endshift; // clip c terminal region
518 leadinghn = !leadinghn;
534 // sr contained in hr
537 sr = shifts.get(++s);
547 return pruned; // true if any interval was removed or modified by
552 * remove any hiddenColumns or selected columns and shift remaining based on a
553 * series of position, range deletions.
557 public void pruneDeletions(ShiftList deletions)
559 if (deletions != null)
561 final List<int[]> shifts = deletions.getShifts();
562 if (shifts != null && shifts.size() > 0)
564 // delete any intervals intersecting.
565 if (hiddenColumns != null)
567 pruneIntervalVector(shifts, hiddenColumns);
568 if (hiddenColumns != null && hiddenColumns.size() == 0)
570 hiddenColumns = null;
573 if (selected != null && selected.size() > 0)
575 selected.pruneColumnList(shifts);
576 if (selected != null && selected.size() == 0)
581 // and shift the rest.
582 this.compensateForEdits(deletions);
588 * This Method is used to return all the HiddenColumn regions
590 * @return empty list or List of hidden column intervals
592 public List<int[]> getHiddenColumns()
594 return hiddenColumns == null ? Collections.<int[]> emptyList()
599 * Return absolute column index for a visible column index
602 * int column index in alignment view
603 * @return alignment column index for column
605 public int adjustForHiddenColumns(int column)
608 if (hiddenColumns != null)
610 for (int i = 0; i < hiddenColumns.size(); i++)
612 int[] region = hiddenColumns.elementAt(i);
613 if (result >= region[0])
615 result += region[1] - region[0] + 1;
623 * Use this method to find out where a column will appear in the visible
624 * alignment when hidden columns exist. If the column is not visible, then the
625 * left-most visible column will always be returned.
627 * @param hiddenColumn
631 public int findColumnPosition(int hiddenColumn)
633 int result = hiddenColumn;
634 if (hiddenColumns != null)
640 region = hiddenColumns.elementAt(index++);
641 if (hiddenColumn > region[1])
643 result -= region[1] + 1 - region[0];
645 } while ((hiddenColumn > region[1]) && (index < hiddenColumns.size()));
646 if (hiddenColumn > region[0] && hiddenColumn < region[1])
648 return region[0] + hiddenColumn - result;
651 return result; // return the shifted position after removing hidden columns.
655 * Use this method to determine where the next hiddenRegion starts
657 * @param hiddenRegion
658 * index of hidden region (counts from 0)
659 * @return column number in visible view
661 public int findHiddenRegionPosition(int hiddenRegion)
664 if (hiddenColumns != null)
670 int[] region = hiddenColumns.elementAt(index);
671 if (hiddenRegion == 0)
676 gaps += region[1] + 1 - region[0];
677 result = region[1] + 1;
679 } while (index <= hiddenRegion);
688 * THis method returns the rightmost limit of a region of an alignment with
689 * hidden columns. In otherwords, the next hidden column.
694 public int getHiddenBoundaryRight(int alPos)
696 if (hiddenColumns != null)
701 int[] region = hiddenColumns.elementAt(index);
702 if (alPos < region[0])
708 } while (index < hiddenColumns.size());
716 * This method returns the leftmost limit of a region of an alignment with
717 * hidden columns. In otherwords, the previous hidden column.
722 public int getHiddenBoundaryLeft(int alPos)
724 if (hiddenColumns != null)
726 int index = hiddenColumns.size() - 1;
729 int[] region = hiddenColumns.elementAt(index);
730 if (alPos > region[1])
736 } while (index > -1);
743 public void hideSelectedColumns()
745 synchronized (selected)
747 for (int[] selregions : selected.getRanges())
749 hideColumns(selregions[0], selregions[1]);
757 * Adds the specified column range to the hidden columns
762 public void hideColumns(int start, int end)
764 if (hiddenColumns == null)
766 hiddenColumns = new Vector<int[]>();
770 * traverse existing hidden ranges and insert / amend / append as
773 for (int i = 0; i < hiddenColumns.size(); i++)
775 int[] region = hiddenColumns.elementAt(i);
777 if (end < region[0] - 1)
780 * insert discontiguous preceding range
782 hiddenColumns.insertElementAt(new int[] { start, end }, i);
786 if (end <= region[1])
789 * new range overlaps existing, or is contiguous preceding it - adjust
792 region[0] = Math.min(region[0], start);
796 if (start <= region[1] + 1)
799 * new range overlaps existing, or is contiguous following it - adjust
800 * start and end columns
802 region[0] = Math.min(region[0], start);
803 region[1] = Math.max(region[1], end);
809 * remaining case is that the new range follows everything else
811 hiddenColumns.addElement(new int[] { start, end });
815 * Hides the specified column and any adjacent selected columns
820 public void hideColumns(int col)
823 * deselect column (whether selected or not!)
828 * find adjacent selected columns
830 int min = col - 1, max = col + 1;
831 while (contains(min))
837 while (contains(max))
844 * min, max are now the closest unselected columns
853 hideColumns(min, max);
857 * Unhides, and adds to the selection list, all hidden columns
859 public void revealAllHiddenColumns()
861 if (hiddenColumns != null)
863 for (int i = 0; i < hiddenColumns.size(); i++)
865 int[] region = hiddenColumns.elementAt(i);
866 for (int j = region[0]; j < region[1] + 1; j++)
873 hiddenColumns = null;
877 * Reveals, and marks as selected, the hidden column range with the given
882 public void revealHiddenColumns(int start)
884 for (int i = 0; i < hiddenColumns.size(); i++)
886 int[] region = hiddenColumns.elementAt(i);
887 if (start == region[0])
889 for (int j = region[0]; j < region[1] + 1; j++)
894 hiddenColumns.removeElement(region);
898 if (hiddenColumns.size() == 0)
900 hiddenColumns = null;
904 public boolean isVisible(int column)
906 if (hiddenColumns != null)
908 for (int[] region : hiddenColumns)
910 if (column >= region[0] && column <= region[1])
925 public ColumnSelection(ColumnSelection copy)
929 if (copy.selected != null)
931 selected = new IntList();
932 for (int i = 0, j = copy.selected.size(); i < j; i++)
934 selected.add(copy.selected.elementAt(i));
937 if (copy.hiddenColumns != null)
939 hiddenColumns = new Vector<int[]>(copy.hiddenColumns.size());
940 for (int i = 0, j = copy.hiddenColumns.size(); i < j; i++)
943 rh = copy.hiddenColumns.elementAt(i);
946 cp = new int[rh.length];
947 System.arraycopy(rh, 0, cp, 0, rh.length);
948 hiddenColumns.addElement(cp);
958 public ColumnSelection()
962 public String[] getVisibleSequenceStrings(int start, int end,
965 int i, iSize = seqs.length;
966 String selection[] = new String[iSize];
967 if (hiddenColumns != null && hiddenColumns.size() > 0)
969 for (i = 0; i < iSize; i++)
971 StringBuffer visibleSeq = new StringBuffer();
972 List<int[]> regions = getHiddenColumns();
974 int blockStart = start, blockEnd = end;
976 int hideStart, hideEnd;
978 for (int j = 0; j < regions.size(); j++)
980 region = regions.get(j);
981 hideStart = region[0];
984 if (hideStart < start)
989 blockStart = Math.min(blockStart, hideEnd + 1);
990 blockEnd = Math.min(blockEnd, hideStart);
992 if (blockStart > blockEnd)
997 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
999 blockStart = hideEnd + 1;
1003 if (end > blockStart)
1005 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1008 selection[i] = visibleSeq.toString();
1013 for (i = 0; i < iSize; i++)
1015 selection[i] = seqs[i].getSequenceAsString(start, end);
1023 * return all visible segments between the given start and end boundaries
1026 * (first column inclusive from 0)
1028 * (last column - not inclusive)
1029 * @return int[] {i_start, i_end, ..} where intervals lie in
1030 * start<=i_start<=i_end<end
1032 public int[] getVisibleContigs(int start, int end)
1034 if (hiddenColumns != null && hiddenColumns.size() > 0)
1036 List<int[]> visiblecontigs = new ArrayList<int[]>();
1037 List<int[]> regions = getHiddenColumns();
1041 int hideStart, hideEnd;
1043 for (int j = 0; vstart < end && j < regions.size(); j++)
1045 region = regions.get(j);
1046 hideStart = region[0];
1047 hideEnd = region[1];
1049 if (hideEnd < vstart)
1053 if (hideStart > vstart)
1055 visiblecontigs.add(new int[] { vstart, hideStart - 1 });
1057 vstart = hideEnd + 1;
1062 visiblecontigs.add(new int[] { vstart, end - 1 });
1064 int[] vcontigs = new int[visiblecontigs.size() * 2];
1065 for (int i = 0, j = visiblecontigs.size(); i < j; i++)
1067 int[] vc = visiblecontigs.get(i);
1068 visiblecontigs.set(i, null);
1069 vcontigs[i * 2] = vc[0];
1070 vcontigs[i * 2 + 1] = vc[1];
1072 visiblecontigs.clear();
1077 return new int[] { start, end - 1 };
1082 * delete any columns in alignmentAnnotation that are hidden (including
1083 * sequence associated annotation).
1085 * @param alignmentAnnotation
1087 public void makeVisibleAnnotation(AlignmentAnnotation alignmentAnnotation)
1089 makeVisibleAnnotation(-1, -1, alignmentAnnotation);
1093 * delete any columns in alignmentAnnotation that are hidden (including
1094 * sequence associated annotation).
1097 * remove any annotation to the right of this column
1099 * remove any annotation to the left of this column
1100 * @param alignmentAnnotation
1101 * the annotation to operate on
1103 public void makeVisibleAnnotation(int start, int end,
1104 AlignmentAnnotation alignmentAnnotation)
1106 if (alignmentAnnotation.annotations == null)
1110 if (start == end && end == -1)
1113 end = alignmentAnnotation.annotations.length;
1115 if (hiddenColumns != null && hiddenColumns.size() > 0)
1117 // then mangle the alignmentAnnotation annotation array
1118 Vector<Annotation[]> annels = new Vector<Annotation[]>();
1119 Annotation[] els = null;
1120 List<int[]> regions = getHiddenColumns();
1121 int blockStart = start, blockEnd = end;
1123 int hideStart, hideEnd, w = 0;
1125 for (int j = 0; j < regions.size(); j++)
1127 region = regions.get(j);
1128 hideStart = region[0];
1129 hideEnd = region[1];
1131 if (hideStart < start)
1136 blockStart = Math.min(blockStart, hideEnd + 1);
1137 blockEnd = Math.min(blockEnd, hideStart);
1139 if (blockStart > blockEnd)
1144 annels.addElement(els = new Annotation[blockEnd - blockStart]);
1145 System.arraycopy(alignmentAnnotation.annotations, blockStart, els,
1148 blockStart = hideEnd + 1;
1152 if (end > blockStart)
1154 annels.addElement(els = new Annotation[end - blockStart + 1]);
1155 if ((els.length + blockStart) <= alignmentAnnotation.annotations.length)
1157 // copy just the visible segment of the annotation row
1158 System.arraycopy(alignmentAnnotation.annotations, blockStart,
1159 els, 0, els.length);
1163 // copy to the end of the annotation row
1164 System.arraycopy(alignmentAnnotation.annotations, blockStart,
1166 (alignmentAnnotation.annotations.length - blockStart));
1175 alignmentAnnotation.annotations = new Annotation[w];
1178 for (Annotation[] chnk : annels)
1180 System.arraycopy(chnk, 0, alignmentAnnotation.annotations, w,
1187 alignmentAnnotation.restrict(start, end);
1192 * Invert the column selection from first to end-1. leaves hiddenColumns
1193 * untouched (and unselected)
1198 public void invertColumnSelection(int first, int width)
1200 boolean hasHidden = hiddenColumns != null && hiddenColumns.size() > 0;
1201 for (int i = first; i < width; i++)
1209 if (!hasHidden || isVisible(i))
1218 * add in any unselected columns from the given column selection, excluding
1219 * any that are hidden.
1223 public void addElementsFrom(ColumnSelection colsel)
1225 if (colsel != null && !colsel.isEmpty())
1227 for (Integer col : colsel.getSelected())
1229 if (hiddenColumns != null && isVisible(col.intValue()))
1238 * set the selected columns the given column selection, excluding any columns
1243 public void setElementsFrom(ColumnSelection colsel)
1245 selected = new IntList();
1246 if (colsel.selected != null && colsel.selected.size() > 0)
1248 if (hiddenColumns != null && hiddenColumns.size() > 0)
1250 // only select visible columns in this columns selection
1251 addElementsFrom(colsel);
1255 // add everything regardless
1256 for (Integer col : colsel.getSelected())
1265 * Add gaps into the sequences aligned to profileseq under the given
1270 * - alignment to have gaps inserted into it
1272 * - alignment view where sequence corresponding to profileseq is
1274 * @return new Column selection for new alignment view, with insertions into
1275 * profileseq marked as hidden.
1277 public static ColumnSelection propagateInsertions(SequenceI profileseq,
1278 AlignmentI al, AlignmentView input)
1282 // return propagateInsertions(profileseq, al, )
1283 char gc = al.getGapCharacter();
1284 Object[] alandcolsel = input.getAlignmentAndColumnSelection(gc);
1285 ColumnSelection nview = (ColumnSelection) alandcolsel[1];
1286 SequenceI origseq = ((SequenceI[]) alandcolsel[0])[profsqpos];
1287 nview.propagateInsertions(profileseq, al, origseq);
1294 * - sequence in al which corresponds to origseq
1296 * - alignment which is to have gaps inserted into it
1298 * - sequence corresponding to profileseq which defines gap map for
1301 public void propagateInsertions(SequenceI profileseq, AlignmentI al,
1304 char gc = al.getGapCharacter();
1305 // recover mapping between sequence's non-gap positions and positions
1307 pruneDeletions(ShiftList.parseMap(origseq.gapMap()));
1308 int[] viscontigs = getVisibleContigs(0, profileseq.getLength());
1311 // input.pruneDeletions(ShiftList.parseMap(((SequenceI[])
1312 // alandcolsel[0])[0].gapMap()))
1313 // add profile to visible contigs
1314 for (int v = 0; v < viscontigs.length; v += 2)
1316 if (viscontigs[v] > spos)
1318 StringBuffer sb = new StringBuffer();
1319 for (int s = 0, ns = viscontigs[v] - spos; s < ns; s++)
1323 for (int s = 0, ns = al.getHeight(); s < ns; s++)
1325 SequenceI sqobj = al.getSequenceAt(s);
1326 if (sqobj != profileseq)
1328 String sq = al.getSequenceAt(s).getSequenceAsString();
1329 if (sq.length() <= spos + offset)
1332 int diff = spos + offset - sq.length() - 1;
1337 while ((diff = spos + offset - sq.length() - 1) > 0)
1340 // + ((diff >= sb.length()) ? sb.toString() : sb
1341 // .substring(0, diff));
1342 if (diff >= sb.length())
1344 sq += sb.toString();
1348 char[] buf = new char[diff];
1349 sb.getChars(0, diff, buf, 0);
1350 sq += buf.toString();
1354 sq += sb.toString();
1358 al.getSequenceAt(s).setSequence(
1359 sq.substring(0, spos + offset) + sb.toString()
1360 + sq.substring(spos + offset));
1364 // offset+=sb.length();
1366 spos = viscontigs[v + 1] + 1;
1368 if ((offset + spos) < profileseq.getLength())
1370 // pad the final region with gaps.
1371 StringBuffer sb = new StringBuffer();
1372 for (int s = 0, ns = profileseq.getLength() - spos - offset; s < ns; s++)
1376 for (int s = 0, ns = al.getHeight(); s < ns; s++)
1378 SequenceI sqobj = al.getSequenceAt(s);
1379 if (sqobj == profileseq)
1383 String sq = sqobj.getSequenceAsString();
1385 int diff = origseq.getLength() - sq.length();
1389 // + ((diff >= sb.length()) ? sb.toString() : sb
1390 // .substring(0, diff));
1391 if (diff >= sb.length())
1393 sq += sb.toString();
1397 char[] buf = new char[diff];
1398 sb.getChars(0, diff, buf, 0);
1399 sq += buf.toString();
1401 diff = origseq.getLength() - sq.length();
1409 * @return true if there are columns marked
1411 public boolean hasSelectedColumns()
1413 return (selected != null && selected.size() > 0);
1418 * @return true if there are columns hidden
1420 public boolean hasHiddenColumns()
1422 return hiddenColumns != null && hiddenColumns.size() > 0;
1427 * @return true if there are more than one set of columns hidden
1429 public boolean hasManyHiddenColumns()
1431 return hiddenColumns != null && hiddenColumns.size() > 1;
1435 * mark the columns corresponding to gap characters as hidden in the column
1440 public void hideInsertionsFor(SequenceI sr)
1442 List<int[]> inserts = sr.getInsertions();
1443 for (int[] r : inserts)
1445 hideColumns(r[0], r[1]);
1449 public boolean filterAnnotations(Annotation[] annotations,
1450 AnnotationFilterParameter filterParams)
1452 this.revealAllHiddenColumns();
1457 if (annotations[count] != null)
1460 boolean itemMatched = false;
1462 if (filterParams.getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD
1463 && annotations[count].value >= filterParams
1464 .getThresholdValue())
1468 if (filterParams.getThresholdType() == AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD
1469 && annotations[count].value <= filterParams
1470 .getThresholdValue())
1475 if (filterParams.isFilterAlphaHelix()
1476 && annotations[count].secondaryStructure == 'H')
1481 if (filterParams.isFilterBetaSheet()
1482 && annotations[count].secondaryStructure == 'E')
1487 if (filterParams.isFilterTurn()
1488 && annotations[count].secondaryStructure == 'S')
1493 String regexSearchString = filterParams.getRegexString();
1494 if (regexSearchString != null
1495 && !filterParams.getRegexSearchFields().isEmpty())
1497 List<SearchableAnnotationField> fields = filterParams
1498 .getRegexSearchFields();
1501 if (fields.contains(SearchableAnnotationField.DISPLAY_STRING)
1502 && annotations[count].displayCharacter
1503 .matches(regexSearchString))
1507 } catch (java.util.regex.PatternSyntaxException pse)
1509 if (annotations[count].displayCharacter
1510 .equals(regexSearchString))
1515 if (fields.contains(SearchableAnnotationField.DESCRIPTION)
1516 && annotations[count].description != null
1517 && annotations[count].description
1518 .matches(regexSearchString))
1526 this.addElement(count);
1530 } while (count < annotations.length);