I have a 34-mer string like
ATGGGGTTTCCC...CTG
I want to get all possible 6-mer substrings in this string. Can you suggest a good way to do this.
I have a 34-mer string like
ATGGGGTTTCCC...CTG
I want to get all possible 6-mer substrings in this string. Can you suggest a good way to do this.
Assuming they have to be contiguous, you can use slicing in a list comprehension
>>> s = 'AGTAATGGCGATTGAGGGTCCACTGTCCTGGTAC'
>>> [s[i:i+6] for i in range(len(s)-5)]
['AGTAAT', 'GTAATG', 'TAATGG', 'AATGGC', 'ATGGCG', 'TGGCGA', 'GGCGAT', 'GCGATT', 'CGATTG', 'GATTGA', 'ATTGAG', 'TTGAGG', 'TGAGGG', 'GAGGGT', 'AGGGTC', 'GGGTCC', 'GGTCCA', 'GTCCAC', 'TCCACT', 'CCACTG', 'CACTGT', 'ACTGTC', 'CTGTCC', 'TGTCCT', 'GTCCTG', 'TCCTGG', 'CCTGGT', 'CTGGTA', 'TGGTAC']