-
Independent AllelesBioinformatics/Rosalind 2019. 6. 8. 15:04
http://rosalind.info/problems/lia/
from itertools import combinations from functools import reduce from math import factorial with open('rosalind_lia.txt') as f: data= list(map(lambda x: int(x), f.read().strip().split(' '))) def combi(n, r): return int(factorial(n) / factorial(r) / factorial(n - r)) AaBb_prob= 0.25 total = 2 ** data[0] # result = reduce(lambda a, b: a+b, map(lambda x: len(list(combinations(range(total), x))) * AaBb_prob ** x * (1 - AaBb_prob) ** (total - x), range(data[1], total+1))) result = reduce(lambda a, b: a+b, map(lambda x: combi(total, x) * AaBb_prob ** x * (1 - AaBb_prob) ** (total - x), range(data[1], total+1))) print(result)
0th generation에서 매 세대마다 2배씩 population이 증가할때 n-th generation일때 대립 쌍이 hetero인 genotype이 k개 이상일 확률을 구하는 문제이다. 별거없고 자식이 AaBb일 확률이 0.25니까 그냥 k개 이상이 나올 확률들을 다 더해주면 된다.
'Bioinformatics > Rosalind' 카테고리의 다른 글
Completing a Tree (0) 2019.06.17 Genome Assembly as Shortest Superstring (0) 2019.06.13 Locating Restriction Sites (0) 2019.03.04 RNA Splicing (0) 2019.03.03 Calculating Protein Mass (0) 2019.03.02 댓글