dimanche 5 novembre 2017

generate random RNA transcripts with ending condition

I am trying to write a program that generates random RNA transcripts: all 4 RNA nucleotides are of equal probability, each sequence begins with a start codon, ends only when a stop codon is introduced.

import random

def random_rna():
    rna = 'AUG'
    stop_codon = ['UAG','UAA','UGA']
    while rna[-3:] not in stop_codon:
            rna += (random.choice('AUCG'))*3
    return rna

random_rna()

it does not generate a sequence and python is not presenting any errors...




Aucun commentaire:

Enregistrer un commentaire