Rewrite to use sort/merge instead of collecting everything in a dict
Rewrite to use sort/merge instead of collecting everything in a dict

Add MergeSorter class to implement a unix sort style sort/merge algorithm.
This allows partial data to be stored in a temporary file if the number
of items gets too big.  The point where this happens can be set using
a command-line option.  The class includes an iterator that brings all
of the stored data back in order at the end of the process.

Re-write index to use the class above.  Instead of trying to store all of
the data in a dict, it gathers a set of kmer hits which it converts to
binary strings.  The strings hold the kmer_id, record number and position
in big-endian format.  This means a sort using the standard string comparison
function will get them into the desired order, i.e. first by kmer_id, then
record, then position.  Hits on the negative strand are dealt with by
setting the top bit of the record number.  When the number of hits
reaches the limit, the set so far is written out using the MergeSorter
class.  When it reaches the end of the input data, it adds any remaining
hits into the MergeSorter and then uses its iterator to get them back
in order.  It's then trivial to construct the database updates needed
to fill out the sqlite3 database.  In tests this gives exactly the
same result as the previous method in spite of the very different algorithm.

The new version runs at a similar speed to the old one for small inputs,
but is significantly faster for large ones.  E.g. on human chr.21 with a
kmer length of 9, the old one took about 19 minutes while the new one
took about 8.

daviesrob/qu-mfeindex,daviesrob/qu-mfeindex