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 int getMaxColumn()
175 return selected.length() - 1;
178 public int getMinColumn()
180 return selected.get(0) ? 0 : selected.nextSetBit(0);
184 IntList selected = new IntList();
186 * list of hidden column [start, end] ranges; the list is maintained in
187 * ascending start column order
189 Vector<int[]> hiddenColumns;
192 * Add a column to the selection
197 public void addElement(int col)
203 * clears column selection
211 * Removes value 'col' from the selection (not the col'th item)
214 * index of column to be removed
216 public void removeElement(int col)
218 selected.remove(col);
222 * removes a range of columns from the selection
225 * int - first column in range to be removed
229 public void removeElements(int start, int end)
232 for (int i = start; i < end; i++)
234 colInt = new Integer(i);
235 if (selected.contains(colInt))
237 selected.remove(colInt);
243 * Returns a list of selected columns. The list contains no duplicates but is
244 * not necessarily ordered. It also may include columns hidden from the
247 public List<Integer> getSelected()
249 return selected.getList();
255 * index to search for in column selection
257 * @return true if Integer(col) is in selection.
259 public boolean contains(int col)
261 return selected.contains(new Integer(col));
265 * Answers true if no columns are selected, else false
267 public boolean isEmpty()
269 return selected == null || selected.isEmpty();
273 * rightmost selected column
275 * @return rightmost column in alignment that is selected
279 if (selected.isEmpty())
283 return selected.getMaxColumn();
287 * Leftmost column in selection
289 * @return column index of leftmost column in selection
293 if (selected.isEmpty())
297 return selected.getMinColumn();
301 * propagate shift in alignment columns to column selection
306 * shift in edit (+ve for removal, or -ve for inserts)
308 public List<int[]> compensateForEdit(int start, int change)
310 List<int[]> deletedHiddenColumns = null;
311 selected.compensateForEdits(start, change);
313 if (hiddenColumns != null)
315 deletedHiddenColumns = new ArrayList<int[]>();
316 int hSize = hiddenColumns.size();
317 for (int i = 0; i < hSize; i++)
319 int[] region = hiddenColumns.elementAt(i);
320 if (region[0] > start && start + change > region[1])
322 deletedHiddenColumns.add(region);
324 hiddenColumns.removeElementAt(i);
330 if (region[0] > start)
343 this.revealHiddenColumns(0);
346 return deletedHiddenColumns;
350 * propagate shift in alignment columns to column selection special version of
351 * compensateForEdit - allowing for edits within hidden regions
356 * shift in edit (+ve for removal, or -ve for inserts)
358 private void compensateForDelEdits(int start, int change)
361 selected.compensateForEdits(start, change);
363 if (hiddenColumns != null)
365 for (int i = 0; i < hiddenColumns.size(); i++)
367 int[] region = hiddenColumns.elementAt(i);
368 if (region[0] >= start)
372 if (region[1] >= start)
376 if (region[1] < region[0])
378 hiddenColumns.removeElementAt(i--);
394 * Adjust hidden column boundaries based on a series of column additions or
395 * deletions in visible regions.
400 public ShiftList compensateForEdits(ShiftList shiftrecord)
402 if (shiftrecord != null)
404 final List<int[]> shifts = shiftrecord.getShifts();
405 if (shifts != null && shifts.size() > 0)
408 for (int i = 0, j = shifts.size(); i < j; i++)
410 int[] sh = shifts.get(i);
411 // compensateForEdit(shifted+sh[0], sh[1]);
412 compensateForDelEdits(shifted + sh[0], sh[1]);
416 return shiftrecord.getInverse();
422 * removes intersection of position,length ranges in deletions from the
423 * start,end regions marked in intervals.
429 private boolean pruneIntervalVector(final List<int[]> shifts,
430 Vector<int[]> intervals)
432 boolean pruned = false;
433 int i = 0, j = intervals.size() - 1, s = 0, t = shifts.size() - 1;
434 int hr[] = intervals.elementAt(i);
435 int sr[] = shifts.get(s);
436 while (i <= j && s <= t)
438 boolean trailinghn = hr[1] >= sr[0];
443 hr = intervals.elementAt(++i);
451 int endshift = sr[0] + sr[1]; // deletion ranges - -ve means an insert
452 if (endshift < hr[0] || endshift < sr[0])
453 { // leadinghc disjoint or not a deletion
456 sr = shifts.get(++s);
464 boolean leadinghn = hr[0] >= sr[0];
465 boolean leadinghc = hr[0] < endshift;
466 boolean trailinghc = hr[1] < endshift;
470 { // deleted hidden region.
471 intervals.removeElementAt(i);
476 hr = intervals.elementAt(i);
482 hr[0] = endshift; // clip c terminal region
483 leadinghn = !leadinghn;
499 // sr contained in hr
502 sr = shifts.get(++s);
512 return pruned; // true if any interval was removed or modified by
517 * remove any hiddenColumns or selected columns and shift remaining based on a
518 * series of position, range deletions.
522 public void pruneDeletions(ShiftList deletions)
524 if (deletions != null)
526 final List<int[]> shifts = deletions.getShifts();
527 if (shifts != null && shifts.size() > 0)
529 // delete any intervals intersecting.
530 if (hiddenColumns != null)
532 pruneIntervalVector(shifts, hiddenColumns);
533 if (hiddenColumns != null && hiddenColumns.size() == 0)
535 hiddenColumns = null;
538 if (selected != null && selected.size() > 0)
540 selected.pruneColumnList(shifts);
541 if (selected != null && selected.size() == 0)
546 // and shift the rest.
547 this.compensateForEdits(deletions);
553 * This Method is used to return all the HiddenColumn regions
555 * @return empty list or List of hidden column intervals
557 public List<int[]> getHiddenColumns()
559 return hiddenColumns == null ? Collections.<int[]> emptyList()
564 * Return absolute column index for a visible column index
567 * int column index in alignment view
568 * @return alignment column index for column
570 public int adjustForHiddenColumns(int column)
573 if (hiddenColumns != null)
575 for (int i = 0; i < hiddenColumns.size(); i++)
577 int[] region = hiddenColumns.elementAt(i);
578 if (result >= region[0])
580 result += region[1] - region[0] + 1;
588 * Use this method to find out where a column will appear in the visible
589 * alignment when hidden columns exist. If the column is not visible, then the
590 * left-most visible column will always be returned.
592 * @param hiddenColumn
596 public int findColumnPosition(int hiddenColumn)
598 int result = hiddenColumn;
599 if (hiddenColumns != null)
605 region = hiddenColumns.elementAt(index++);
606 if (hiddenColumn > region[1])
608 result -= region[1] + 1 - region[0];
610 } while ((hiddenColumn > region[1]) && (index < hiddenColumns.size()));
611 if (hiddenColumn > region[0] && hiddenColumn < region[1])
613 return region[0] + hiddenColumn - result;
616 return result; // return the shifted position after removing hidden columns.
620 * Use this method to determine where the next hiddenRegion starts
622 public int findHiddenRegionPosition(int hiddenRegion)
625 if (hiddenColumns != null)
631 int[] region = hiddenColumns.elementAt(index);
632 if (hiddenRegion == 0)
637 gaps += region[1] + 1 - region[0];
638 result = region[1] + 1;
640 } while (index < hiddenRegion + 1);
649 * THis method returns the rightmost limit of a region of an alignment with
650 * hidden columns. In otherwords, the next hidden column.
655 public int getHiddenBoundaryRight(int alPos)
657 if (hiddenColumns != null)
662 int[] region = hiddenColumns.elementAt(index);
663 if (alPos < region[0])
669 } while (index < hiddenColumns.size());
677 * This method returns the leftmost limit of a region of an alignment with
678 * hidden columns. In otherwords, the previous hidden column.
683 public int getHiddenBoundaryLeft(int alPos)
685 if (hiddenColumns != null)
687 int index = hiddenColumns.size() - 1;
690 int[] region = hiddenColumns.elementAt(index);
691 if (alPos > region[1])
697 } while (index > -1);
704 public void hideSelectedColumns()
706 while (!selected.isEmpty())
708 int column = selected.elementAt(0);
715 * Adds the specified column range to the hidden columns
720 public void hideColumns(int start, int end)
722 if (hiddenColumns == null)
724 hiddenColumns = new Vector<int[]>();
728 * traverse existing hidden ranges and insert / amend / append as
731 for (int i = 0; i < hiddenColumns.size(); i++)
733 int[] region = hiddenColumns.elementAt(i);
735 if (end < region[0] - 1)
738 * insert discontiguous preceding range
740 hiddenColumns.insertElementAt(new int[] { start, end }, i);
744 if (end <= region[1])
747 * new range overlaps existing, or is contiguous preceding it - adjust
750 region[0] = Math.min(region[0], start);
754 if (start <= region[1] + 1)
757 * new range overlaps existing, or is contiguous following it - adjust
758 * start and end columns
760 region[0] = Math.min(region[0], start);
761 region[1] = Math.max(region[1], end);
767 * remaining case is that the new range follows everything else
769 hiddenColumns.addElement(new int[] { start, end });
773 * Hides the specified column and any adjacent selected columns
778 public void hideColumns(int col)
781 * deselect column (whether selected or not!)
786 * find adjacent selected columns
788 int min = col - 1, max = col + 1;
789 while (contains(min))
795 while (contains(max))
802 * min, max are now the closest unselected columns
811 hideColumns(min, max);
815 * Unhides, and adds to the selection list, all hidden columns
817 public void revealAllHiddenColumns()
819 if (hiddenColumns != null)
821 for (int i = 0; i < hiddenColumns.size(); i++)
823 int[] region = hiddenColumns.elementAt(i);
824 for (int j = region[0]; j < region[1] + 1; j++)
831 hiddenColumns = null;
835 * Reveals, and marks as selected, the hidden column range with the given
840 public void revealHiddenColumns(int start)
842 for (int i = 0; i < hiddenColumns.size(); i++)
844 int[] region = hiddenColumns.elementAt(i);
845 if (start == region[0])
847 for (int j = region[0]; j < region[1] + 1; j++)
852 hiddenColumns.removeElement(region);
856 if (hiddenColumns.size() == 0)
858 hiddenColumns = null;
862 public boolean isVisible(int column)
864 if (hiddenColumns != null)
866 for (int[] region : hiddenColumns)
868 if (column >= region[0] && column <= region[1])
883 public ColumnSelection(ColumnSelection copy)
887 if (copy.selected != null)
889 selected = new IntList();
890 for (int i = 0, j = copy.selected.size(); i < j; i++)
892 selected.add(copy.selected.elementAt(i));
895 if (copy.hiddenColumns != null)
897 hiddenColumns = new Vector<int[]>(copy.hiddenColumns.size());
898 for (int i = 0, j = copy.hiddenColumns.size(); i < j; i++)
901 rh = copy.hiddenColumns.elementAt(i);
904 cp = new int[rh.length];
905 System.arraycopy(rh, 0, cp, 0, rh.length);
906 hiddenColumns.addElement(cp);
916 public ColumnSelection()
920 public String[] getVisibleSequenceStrings(int start, int end,
923 int i, iSize = seqs.length;
924 String selection[] = new String[iSize];
925 if (hiddenColumns != null && hiddenColumns.size() > 0)
927 for (i = 0; i < iSize; i++)
929 StringBuffer visibleSeq = new StringBuffer();
930 List<int[]> regions = getHiddenColumns();
932 int blockStart = start, blockEnd = end;
934 int hideStart, hideEnd;
936 for (int j = 0; j < regions.size(); j++)
938 region = regions.get(j);
939 hideStart = region[0];
942 if (hideStart < start)
947 blockStart = Math.min(blockStart, hideEnd + 1);
948 blockEnd = Math.min(blockEnd, hideStart);
950 if (blockStart > blockEnd)
955 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
957 blockStart = hideEnd + 1;
961 if (end > blockStart)
963 visibleSeq.append(seqs[i].getSequence(blockStart, end));
966 selection[i] = visibleSeq.toString();
971 for (i = 0; i < iSize; i++)
973 selection[i] = seqs[i].getSequenceAsString(start, end);
981 * return all visible segments between the given start and end boundaries
984 * (first column inclusive from 0)
986 * (last column - not inclusive)
987 * @return int[] {i_start, i_end, ..} where intervals lie in
988 * start<=i_start<=i_end<end
990 public int[] getVisibleContigs(int start, int end)
992 if (hiddenColumns != null && hiddenColumns.size() > 0)
994 List<int[]> visiblecontigs = new ArrayList<int[]>();
995 List<int[]> regions = getHiddenColumns();
999 int hideStart, hideEnd;
1001 for (int j = 0; vstart < end && j < regions.size(); j++)
1003 region = regions.get(j);
1004 hideStart = region[0];
1005 hideEnd = region[1];
1007 if (hideEnd < vstart)
1011 if (hideStart > vstart)
1013 visiblecontigs.add(new int[] { vstart, hideStart - 1 });
1015 vstart = hideEnd + 1;
1020 visiblecontigs.add(new int[] { vstart, end - 1 });
1022 int[] vcontigs = new int[visiblecontigs.size() * 2];
1023 for (int i = 0, j = visiblecontigs.size(); i < j; i++)
1025 int[] vc = visiblecontigs.get(i);
1026 visiblecontigs.set(i, null);
1027 vcontigs[i * 2] = vc[0];
1028 vcontigs[i * 2 + 1] = vc[1];
1030 visiblecontigs.clear();
1035 return new int[] { start, end - 1 };
1040 * delete any columns in alignmentAnnotation that are hidden (including
1041 * sequence associated annotation).
1043 * @param alignmentAnnotation
1045 public void makeVisibleAnnotation(AlignmentAnnotation alignmentAnnotation)
1047 makeVisibleAnnotation(-1, -1, alignmentAnnotation);
1051 * delete any columns in alignmentAnnotation that are hidden (including
1052 * sequence associated annotation).
1055 * remove any annotation to the right of this column
1057 * remove any annotation to the left of this column
1058 * @param alignmentAnnotation
1059 * the annotation to operate on
1061 public void makeVisibleAnnotation(int start, int end,
1062 AlignmentAnnotation alignmentAnnotation)
1064 if (alignmentAnnotation.annotations == null)
1068 if (start == end && end == -1)
1071 end = alignmentAnnotation.annotations.length;
1073 if (hiddenColumns != null && hiddenColumns.size() > 0)
1075 // then mangle the alignmentAnnotation annotation array
1076 Vector<Annotation[]> annels = new Vector<Annotation[]>();
1077 Annotation[] els = null;
1078 List<int[]> regions = getHiddenColumns();
1079 int blockStart = start, blockEnd = end;
1081 int hideStart, hideEnd, w = 0;
1083 for (int j = 0; j < regions.size(); j++)
1085 region = regions.get(j);
1086 hideStart = region[0];
1087 hideEnd = region[1];
1089 if (hideStart < start)
1094 blockStart = Math.min(blockStart, hideEnd + 1);
1095 blockEnd = Math.min(blockEnd, hideStart);
1097 if (blockStart > blockEnd)
1102 annels.addElement(els = new Annotation[blockEnd - blockStart]);
1103 System.arraycopy(alignmentAnnotation.annotations, blockStart, els,
1106 blockStart = hideEnd + 1;
1110 if (end > blockStart)
1112 annels.addElement(els = new Annotation[end - blockStart + 1]);
1113 if ((els.length + blockStart) <= alignmentAnnotation.annotations.length)
1115 // copy just the visible segment of the annotation row
1116 System.arraycopy(alignmentAnnotation.annotations, blockStart,
1117 els, 0, els.length);
1121 // copy to the end of the annotation row
1122 System.arraycopy(alignmentAnnotation.annotations, blockStart,
1124 (alignmentAnnotation.annotations.length - blockStart));
1133 alignmentAnnotation.annotations = new Annotation[w];
1136 for (Annotation[] chnk : annels)
1138 System.arraycopy(chnk, 0, alignmentAnnotation.annotations, w,
1145 alignmentAnnotation.restrict(start, end);
1150 * Invert the column selection from first to end-1. leaves hiddenColumns
1151 * untouched (and unselected)
1156 public void invertColumnSelection(int first, int width)
1158 boolean hasHidden = hiddenColumns != null && hiddenColumns.size() > 0;
1159 for (int i = first; i < width; i++)
1167 if (!hasHidden || isVisible(i))
1176 * add in any unselected columns from the given column selection, excluding
1177 * any that are hidden.
1181 public void addElementsFrom(ColumnSelection colsel)
1183 if (colsel != null && !colsel.isEmpty())
1185 for (Integer col : colsel.getSelected())
1187 if (hiddenColumns != null && isVisible(col.intValue()))
1196 * set the selected columns the given column selection, excluding any columns
1201 public void setElementsFrom(ColumnSelection colsel)
1203 selected = new IntList();
1204 if (colsel.selected != null && colsel.selected.size() > 0)
1206 if (hiddenColumns != null && hiddenColumns.size() > 0)
1208 // only select visible columns in this columns selection
1209 addElementsFrom(colsel);
1213 // add everything regardless
1214 for (Integer col : colsel.getSelected())
1223 * Add gaps into the sequences aligned to profileseq under the given
1228 * - alignment to have gaps inserted into it
1230 * - alignment view where sequence corresponding to profileseq is
1232 * @return new Column selection for new alignment view, with insertions into
1233 * profileseq marked as hidden.
1235 public static ColumnSelection propagateInsertions(SequenceI profileseq,
1236 AlignmentI al, AlignmentView input)
1240 // return propagateInsertions(profileseq, al, )
1241 char gc = al.getGapCharacter();
1242 Object[] alandcolsel = input.getAlignmentAndColumnSelection(gc);
1243 ColumnSelection nview = (ColumnSelection) alandcolsel[1];
1244 SequenceI origseq = ((SequenceI[]) alandcolsel[0])[profsqpos];
1245 nview.propagateInsertions(profileseq, al, origseq);
1252 * - sequence in al which corresponds to origseq
1254 * - alignment which is to have gaps inserted into it
1256 * - sequence corresponding to profileseq which defines gap map for
1259 public void propagateInsertions(SequenceI profileseq, AlignmentI al,
1262 char gc = al.getGapCharacter();
1263 // recover mapping between sequence's non-gap positions and positions
1265 pruneDeletions(ShiftList.parseMap(origseq.gapMap()));
1266 int[] viscontigs = getVisibleContigs(0, profileseq.getLength());
1269 // input.pruneDeletions(ShiftList.parseMap(((SequenceI[])
1270 // alandcolsel[0])[0].gapMap()))
1271 // add profile to visible contigs
1272 for (int v = 0; v < viscontigs.length; v += 2)
1274 if (viscontigs[v] > spos)
1276 StringBuffer sb = new StringBuffer();
1277 for (int s = 0, ns = viscontigs[v] - spos; s < ns; s++)
1281 for (int s = 0, ns = al.getHeight(); s < ns; s++)
1283 SequenceI sqobj = al.getSequenceAt(s);
1284 if (sqobj != profileseq)
1286 String sq = al.getSequenceAt(s).getSequenceAsString();
1287 if (sq.length() <= spos + offset)
1290 int diff = spos + offset - sq.length() - 1;
1295 while ((diff = spos + offset - sq.length() - 1) > 0)
1298 // + ((diff >= sb.length()) ? sb.toString() : sb
1299 // .substring(0, diff));
1300 if (diff >= sb.length())
1302 sq += sb.toString();
1306 char[] buf = new char[diff];
1307 sb.getChars(0, diff, buf, 0);
1308 sq += buf.toString();
1312 sq += sb.toString();
1316 al.getSequenceAt(s).setSequence(
1317 sq.substring(0, spos + offset) + sb.toString()
1318 + sq.substring(spos + offset));
1322 // offset+=sb.length();
1324 spos = viscontigs[v + 1] + 1;
1326 if ((offset + spos) < profileseq.getLength())
1328 // pad the final region with gaps.
1329 StringBuffer sb = new StringBuffer();
1330 for (int s = 0, ns = profileseq.getLength() - spos - offset; s < ns; s++)
1334 for (int s = 0, ns = al.getHeight(); s < ns; s++)
1336 SequenceI sqobj = al.getSequenceAt(s);
1337 if (sqobj == profileseq)
1341 String sq = sqobj.getSequenceAsString();
1343 int diff = origseq.getLength() - sq.length();
1347 // + ((diff >= sb.length()) ? sb.toString() : sb
1348 // .substring(0, diff));
1349 if (diff >= sb.length())
1351 sq += sb.toString();
1355 char[] buf = new char[diff];
1356 sb.getChars(0, diff, buf, 0);
1357 sq += buf.toString();
1359 diff = origseq.getLength() - sq.length();
1367 * @return true if there are columns marked
1369 public boolean hasSelectedColumns()
1371 return (selected != null && selected.size() > 0);
1376 * @return true if there are columns hidden
1378 public boolean hasHiddenColumns()
1380 return hiddenColumns != null && hiddenColumns.size() > 0;
1385 * @return true if there are more than one set of columns hidden
1387 public boolean hasManyHiddenColumns()
1389 return hiddenColumns != null && hiddenColumns.size() > 1;
1393 * mark the columns corresponding to gap characters as hidden in the column
1398 public void hideInsertionsFor(SequenceI sr)
1400 List<int[]> inserts = sr.getInsertions();
1401 for (int[] r : inserts)
1403 hideColumns(r[0], r[1]);
1407 public boolean filterAnnotations(Annotation[] annotations,
1408 AnnotationFilterParameter filterParams)
1410 this.revealAllHiddenColumns();
1415 if (annotations[count] != null)
1418 boolean itemMatched = false;
1420 if (filterParams.getThresholdType() == AnnotationFilterParameter.ThresholdType.ABOVE_THRESHOLD
1421 && annotations[count].value >= filterParams
1422 .getThresholdValue())
1426 if (filterParams.getThresholdType() == AnnotationFilterParameter.ThresholdType.BELOW_THRESHOLD
1427 && annotations[count].value <= filterParams
1428 .getThresholdValue())
1433 if (filterParams.isFilterAlphaHelix()
1434 && annotations[count].secondaryStructure == 'H')
1439 if (filterParams.isFilterBetaSheet()
1440 && annotations[count].secondaryStructure == 'E')
1445 if (filterParams.isFilterTurn()
1446 && annotations[count].secondaryStructure == 'S')
1451 String regexSearchString = filterParams.getRegexString();
1452 if (regexSearchString != null
1453 && !filterParams.getRegexSearchFields().isEmpty())
1455 List<SearchableAnnotationField> fields = filterParams
1456 .getRegexSearchFields();
1459 if (fields.contains(SearchableAnnotationField.DISPLAY_STRING)
1460 && annotations[count].displayCharacter
1461 .matches(regexSearchString))
1465 } catch (java.util.regex.PatternSyntaxException pse)
1467 if (annotations[count].displayCharacter
1468 .equals(regexSearchString))
1473 if (fields.contains(SearchableAnnotationField.DESCRIPTION)
1474 && annotations[count].description != null
1475 && annotations[count].description
1476 .matches(regexSearchString))
1484 this.addElement(count);
1488 } while (count < annotations.length);