I am trying to randomly select a specific number of sequences from a dictionary of lists and then append these sequences to a new list, but I keep receiving an empty list. My code:
final_List = []
num = [["ENST", "10", "5"], ["ENGT", "8", "2"], ["ENHT", "5", "1"]]
a = {"ENST" : ['acac', 'tgtgtgt', 'hahah'], "ENHT": ['aaaa', 'tttt', 'gig',
'cccc'], 'ENGT' : ['ddd', 'eeee', 'ffff', 'hhhh', 'pppp']}
for line in num:
for k, v in a.items():
if line[0] == k:
for i in int(line[1] -1):
final_List.append([k, random.choice(0, len(v))])
I am comparing line[0] with k, and if they are the same, I want to pull random sequences from v. The number of sequences I want is the number at line[1]. The final_List would look like:
final_List = [["ENST", "acac"], ["ENST", tgtgtgt"]...10 lists with header "ENST"
["ENGT", "ddd"], .....8 lists with header "ENGT"
["ENHT","aaaa"], ..... 5 lists with header "ENHT"
Aucun commentaire:
Enregistrer un commentaire