As preparation for the upcoming bioinformatics course, I am doing some tasks from rosalind.info. I am currently stuck in the assignment of Mendel’s First Law .
I think that I could overcome myself through this, but somehow my thinking should be too confused. My approach would be this:
Build a probability tree that has three levels. There are two creatures that mate, creature A and creature B. First level: what is the likelihood of being selected as a creature. Homozygous dominant (k), heterozygous (m) or homozygous recessive (n). It seems that, for example, for a homozygous dominant, since there is a total number (k + m + n) of creatures, and k of them are homozygous dominants, the probability is k / (k + m + n).
Then in this tree under each of them there will come a probability of the creature B, which is k / m / n, given that we know which creature A was chosen. For example, if a creature was chosen heterozygous (m), then the likelihood that creature B would also be heterozygous would be (m-1) / (k + m + n-1), because now fewer heterozygous creatures remain.
This will give two levels of probability and will include a lot of code to get this far, since I would literally build a tree structure and manually write the code for this part for each branch.

Now, choosing creatures A and B, each of them has two chromosomes. One of these chromosomes can be randomly selected. Thus, for chromosome 1 or 2, you can choose the same for B. Thus, there are 4 different options: choose 1 from A, 1 from B. Choose 2 from A, 1 from B. Choose 1 from A, 2 from B Pick 2 of A, 2 of B. The probability of each of them will be 1/4. So finally, this tree will have these leaf probabilities.
Then from there, somehow, by magic, I would put together all these probabilities to see how likely it is that two organisms will produce a creature with a dominant allele.
I doubt that this task was designed to solve several hours. What am I thinking too much about?
Update:
I decided this in the funniest way of brute force. They simply launched thousands of simulated mating and found out the part that ended up with the dominant allele until there was enough accuracy to transmit the task.
import random k = 26 m = 18 n = 25 trials = 0 dominants = 0 while True: s = ['AA'] * k + ['Aa'] * m + ['aa'] * n first = random.choice(s) s.remove(first) second = random.choice(s) has_dominant_allele = 'A' in [random.choice(first), random.choice(second)] trials += 1 if has_dominant_allele: dominants += 1 print "%.5f" % (dominants / float(trials))