-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmendels_first_law.py
More file actions
38 lines (19 loc) · 1.23 KB
/
mendels_first_law.py
File metadata and controls
38 lines (19 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
##############################################
##############################################
#No nee for input file. Run with the command: "python mendels_first_law.py" and follow the prompts
##############################################
##############################################
from decimal import *
getcontext().prec = 5
import math
homd = input('n homozygous dominant: ')
het = input('n heterozygous: ')
homr = input('n homozygous recessive: ')
N = homd + het + homr
n_combinations = Decimal(math.factorial(N)/(2*(math.factorial(N-2))))
n_het_matings = Decimal(math.factorial(het)/(2*(math.factorial(het-2))))
n_het_homr_matings = Decimal((math.factorial(het+homr)/(2*(math.factorial(het+homr-2)))) - (math.factorial(het)/(2*(math.factorial(het-2)))) - (math.factorial(homr)/(2*(math.factorial(homr-2)))))
n_homd_homd_matings = Decimal(n_combinations - n_het_matings - n_het_homr_matings - ((math.factorial(homr)/(2*(math.factorial(homr-2))))))
out = Decimal((n_homd_homd_matings/n_combinations+(n_het_matings/n_combinations*3/4)+n_het_homr_matings/n_combinations*1/2))
print "probability that two randomly selected mating organisms will produce an individual possessing a dominant allele: " + str(out)
a = (9/15+(1/15*3/4)+4/15*1/2)