}
/**
- * Returns the string of characters in the matched region.
+ * Returns the string of characters in the matched region, prefixed by the
+ * start position, e.g. "12CGT" or "208K"
*/
@Override
public String toString()
{
+ final int from = Math.max(start - 1, 0);
+ String startPosition = String.valueOf(from);
+ return startPosition + getCharacters();
+ }
+
+ /**
+ * Returns the string of characters in the matched region.
+ */
+ public String getCharacters()
+ {
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));
- return String.valueOf(from)
- + String.valueOf(Arrays.copyOfRange(chars, from, to));
+ return String.valueOf(Arrays.copyOfRange(chars, from, to));
}
public void setSequence(SequenceI seq)
}
/**
- * Return the results as a string of characters. Meant for use when the
- * context ensures that all matches are to regions of the same sequence
- * (otherwise the result is meaningless).
+ * Return the results as a string of characters (bases) prefixed by start
+ * position(s). Meant for use when the context ensures that all matches are to
+ * regions of the same sequence (otherwise the result is meaningless).
*
* @return
*/
}
/**
+ * Return the results as a string of characters (bases). Meant for use when
+ * the context ensures that all matches are to regions of the same sequence
+ * (otherwise the result is meaningless).
+ *
+ * @return
+ */
+ public String getCharacters()
+ {
+ StringBuilder result = new StringBuilder(256);
+ for (Match m : matches)
+ {
+ result.append(m.getCharacters());
+ }
+ return result.toString();
+ }
+
+ /**
* Hashcode is has derived from the list of matches. This ensures that when
* two SearchResults objects satisfy the test for equals(), then they have the
* same hashcode.