python - easy method for spliting substrings of a given length from a string -


i have 34-mer string like

atggggtttccc...ctg 

i want possible 6-mer substrings in string. can suggest way this.

assuming have contiguous, can use slicing in list comprehension

>>> s = 'agtaatggcgattgagggtccactgtcctggtac' >>> [s[i:i+6] 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'] 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -