/** * Get the suffix array value at a given sequence. * * @param index Index at which to retrieve the suffix array vaule. * @return The suffix array value at that entry. */ public long get(long index) { int iterations = 0; while (index % sequenceInterval != 0) { // The inverseSA0 ('$') doesn't have a usable ASCII representation; it must be treated as a // special case. if (index == inverseSA0) index = 0; else { byte base = bwt.getBase(index); index = bwt.counts(base) + bwt.occurrences(base, index); } iterations++; } return (sequence[(int) (index / sequenceInterval)] + iterations) % length(); }
/** * Retrieves the length of the sequence array. * * @return Length of the suffix array. */ public long length() { if (bwt != null) return bwt.length() + 1; else return sequence.length; }