lundi 6 novembre 2017

Calculate average transcript length of random RNA sequences that have a fixed gc content

trying to calculate average transcript length of random RNA sequences that have a fixed gc content ( 10%, 20%, 30%, …, 90%)

def bias_rna(gc_content):
    rna = 'AUG'
    stop_codon = ['UAG','UAA','UGA']
    while rna[-3:] not in stop_codon:
        for _ in range(3):
            rna += random.choice(('A'+'U')*(100-(gc_content))+('C'+'G')*(gc_content))
    return rna


for numb in [range(10,91,10)]:
    rna2_list = []
    for _ in range(1001):
        rna2_list.append(bias_rna(numb))
    rna2_len = []
    for s in rna2_list:
        rna2_len.append(len(s))
    print ('Average random rna length with  cg: %.2f' % (sum(rna_len)/(len(rna_len))))

however, the program doesn't work.. suggestions?




Aucun commentaire:

Enregistrer un commentaire