среда, 16 ноября 2016 г.

Mendel's First Love (ROSALIND IPRB)

Given: Three positive integers k, m, and n, representing a population containing k+m+n organisms: k individuals are homozygous dominant for a factor, m are heterozygous, and n are homozygous recessive.
Return: The probability that two randomly selected mating organisms will produce an individual possessing a dominant allele (and thus displaying the dominant phenotype). Assume that any two organisms can mate.

import sys

def main():
 if len(sys.argv) > 1:
  k = int(sys.argv[1])
  m = int(sys.argv[2])
  n = int(sys.argv[3])
  T = k + m + n
  Z = T*(T - 1)
  print round(1-(n*(n-1) + 0.25*m*(m-1) + m*n)/Z, 5)
 else:
  print 'Enter k, m, n.'

if __name__ == '__main__':
 main()

Комментариев нет:

Отправить комментарий