A friend writing in APL found a much better solution by rearranging the data and sorting.
A C T C G G positions 1 to M C T C G G A positions 2 to M+1 T C G G A T positions 3 to M+2 C G G A T T positions 4 to M+3 G G A T T C positions 5 to M+4 G A T T C T positions 6 to M+5 . . . T G G A C C G G A C C C . . .
Ran surprizingly quickly, thesis saved.