Skip to content

Instantly share code, notes, and snippets.

@Winterflower
Created June 24, 2014 13:13
Show Gist options
  • Save Winterflower/6468220450cc7ab9466d to your computer and use it in GitHub Desktop.
Save Winterflower/6468220450cc7ab9466d to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
def kmer(sequence,k):
length=len(sequence)
#if the kmer size if greater than the lenght of the sequene
if k>=length:
print "You specified a kmer size, which if greater or equal to the length of the sequence"
return
stepsize=k-1
i=0
kmers=[]
while i+stepsize<length:
kmers.append(sequence[i:i+k])
i+=1
print kmers
kmer("ABCDGFGFGFGFGFGG",90)
#OUTPUT ALL OF THE POSSIBLE KMERS FROM A PREDEFINED ALPHABET
def all_kmers(alphabet,k):
nodenumber=len(alphabet)
kmerTree=[]
return kmerTree
def kmer_subtree(rootnode, length):
return [rootnode,[]*length]
maintree=kmer_subtree('/',4)
print maintree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment