alberthrocks

Gene Probability Python Code

Mar 20th, 2011
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. import random
  2.  
  3. genotype = [0,0]
  4. homoDom=0;
  5. heteroDom=0;
  6. homoRec=0;
  7. dom=0;
  8. rec=0;
  9. bigtable=[]
  10. print "Genotype\t| Genotype name\t\t| Phenotype"
  11. print "====================================================="
  12. for x in range(0,100):
  13.     genotype[0]=int(random.randrange(0,100)/50)
  14.     genotype[1]=int(random.randrange(0,100)/50)
  15.     if genotype[0] == 1:
  16.             if genotype[1] == 1:
  17.                 print "RR \t\t| homozygous dominant\t| normal skin"
  18.                 bigtable.append(["RR", "homozygous dominant", "normal skin"])
  19.                 homoDom+=1
  20.             else:
  21.                 print "Rr \t\t| heterozygous dominant\t| normal skin"
  22.                 bigtable.append(["Rr", "heterozygous dominant", "normal skin"])
  23.                 heteroDom+=1
  24.     else:
  25.         if genotype[1] == 1:
  26.             print "rR\t\t| heterozygous dominant\t| normal skin"
  27.             bigtable.append(["rR", "heterozygous dominant", "normal skin"])
  28.             heteroDom+=1
  29.         else:
  30.             print "rr\t\t| homozygous recessive\t| albino"
  31.             bigtable.append(["rr", "homozygous recessive", "normal skin"])
  32.             homoRec+=1
  33. print "Statistics:"
  34. print "RR: "+str(homoDom)+"/100 Rr or rR: "+str(heteroDom)+"/100 rr: "+str(homoRec)+"/100."
  35. rec=homoRec
  36. dom=homoDom+heteroDom
  37. print str(dom)+"/100 were dominant. "+str(rec)+"/100 were recessive."
  38. blabla=raw_input("Press ENTER to continue... ")
Advertisement
Add Comment
Please, Sign In to add comment