0

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.

1

1 Answer 1

1

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']
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.