Move updated kmer_cms code from notebook to file