-
-
Save canimus/356c38798a2ac4790bf66e7c86e94d40 to your computer and use it in GitHub Desktop.
dna manipulation functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functional import seq # PyFunctional | |
from itertools import product | |
def all_kmers(k): | |
'''return list of all dna carthesien products of length k''' | |
all = list(product('ACGT', repeat=k)) | |
return seq(all).map(lambda x: ''.join(x)).to_list() | |
def kmer_per_segment(dna_segment, k): | |
'''return all the dna substrings of length k of the different dna strings in dna list''' | |
return [dna_segment[i:i+k] for i in range(len(dna_segment)-(k-1))] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment