Good evening! Given the dictionary with the probabilities of finding each letter in the first and second place:
profile = {'A': [0.5, 0.1], 'C': [0.3, 0.2], 'G': [0.2, 0.4], 'T': [0.0, 0.3]} I need, based on their probabilities, to randomly choose a dimer ('AA', 'AC', etc.)
I can get randomly selected non-integer number:
random.uniform(0, 1) Then for the first letter of a dimer, I can write the following:
0 to 0.5 —-> 'A', 0.5 to 0.8 —-> 'C', 0.8 to 1 —-> 'G', Considering that I cannot use the 'ACTG' keys directly, because the keys may have other names, I need to write a function that selects a random dimer based on the probabilities of each letter on each of the two places. Any ideas? I have been sitting on this task for quite a long time.