+ private List<Match> matches = new ArrayList<Match>();
+
+ public class Match
+ {
+ SequenceI sequence;
+
+ /**
+ * Start position of match in sequence (base 1)
+ */
+ int start;
+
+ /**
+ * End position (inclusive) (base 1)
+ */
+ int end;
+
+ /**
+ * Constructor
+ *
+ * @param seq
+ * a sequence
+ * @param start
+ * start position of matched range (base 1)
+ * @param end
+ * end of matched range (inclusive, base 1)
+ */
+ public Match(SequenceI seq, int start, int end)
+ {
+ sequence = seq;
+ this.start = start;
+ this.end = end;
+ }
+
+ public SequenceI getSequence()
+ {
+ return sequence;
+ }
+
+ public int getStart()
+ {
+ return start;
+ }
+
+ public int getEnd()
+ {
+ return end;
+ }
+
+ /**
+ * Returns the string of characters in the matched region.
+ */
+ @Override
+ public String toString()
+ {
+ char[] chars = sequence.getSequence();
+ // convert start/end to base 0 (with bounds check)
+ final int from = Math.max(start - 1, 0);
+ final int to = Math.min(end, chars.length + 1);
+ return String.valueOf(Arrays.copyOfRange(chars, from, to));
+ }
+ }