mardi 29 septembre 2015

randomly seek a small sequence of a particular length in a larger sequnce in python

I want to randomly seek a subsequence of length 4 from a larger sequence.

I tried the following code:

import system
import random

    X = 'ATGCATGCTAGCTAGTAAACGTACGTACGTACGATGCTAATATAGAGGGGCTTCGTACCCCTGA'
    Y = [random.choice(X) for i in range(4)]
    print(Y)

But it selects 4 distinct elements from X and not a sequence of length 4 in continuity.




Aucun commentaire:

Enregistrer un commentaire