您的位置 首页 kreess

孟德爾分離定律建模

孟德爾(Gregor Johann Mendel)阿基米德會思考如何用這粒豌豆做支點來翹起地球;英國人希望次日醒來能順著它的莖爬上天空;而遊戲玩傢們則會把豌豆種在傢門口阻擋

孟德爾(Gregor Johann Mendel)

阿基米德會思考如何用這粒豌豆做支點來翹起地球;英國人希望次日醒來能順著它的莖爬上天空;而遊戲玩傢們則會把豌豆種在傢門口阻擋一大波僵屍的進攻……

大約150多年前,有一名修道士卻將它玩出瞭風格,玩出瞭水平,一不小心就奠定瞭現代生物學的三大基石之一。

孟德爾(Gregor Johann Mendel)

他就是“現代遺傳學之父”——格雷戈爾·約翰·孟德爾。

孟德爾在揭示瞭由一對遺傳因子(或一對等位基因)控制的一對相對性狀雜交的遺傳規律——分離規律之後,這位才思敏捷的科學工作者,又接連進行瞭兩對、三對甚至更多對相對性狀雜交的遺傳試驗,進而又發現瞭第二條重要的遺傳學規律,即自由組合規律,也有人稱它為獨立分配規律。這裡我們僅介紹所進行的兩對相對性狀的雜交試驗。(通過假說演繹法論證)

算法:

模擬孟德爾分離定理

#原創公眾號pythonEducation
#law of segregation 孟德爾分離定理

import math,random,pylab

#試驗次數
n=1000

#三類實驗對象
#顯性遺傳因子
dominant_hereditary_factor='D'
#隱性遺傳因子
recessive_hereditary_factor='d'
#遺傳因子列表
list_hereditary_factor=[dominant_hereditary_factor,recessive_hereditary_factor]

#純種高莖
high_pure=[dominant_hereditary_factor,dominant_hereditary_factor]
#純種矮莖
low_pure=[recessive_hereditary_factor,recessive_hereditary_factor]
#雜種高莖
cross_high=[dominant_hereditary_factor,recessive_hereditary_factor]

#配子時,隨機選出一個遺傳因子

def Random_hereditary_factor(list_hereditary_factor):
#真隨機數
r=random.SystemRandom()
#隨機抽出一個遺傳因子
random_hereditary_factor=r.choice(list_hereditary_factor)
return random_hereditary_factor

#配子過程
def Son(list1,list2):
son=[]
#純高莖中抽取一個遺傳因子
factor1=Random_hereditary_factor(list1)
son.append(factor1)
#純矮莖中抽取一個遺傳因子
factor2=Random_hereditary_factor(list2)
son.append(factor2)
return son

#配子性狀判斷,例如是高還是矮
def Character_analysis(list1,list2):
son=Son(list1,list2)
#print 'son:',son
#如果線性遺傳因子在配子中,返回顯性性狀
if dominant_hereditary_factor in son:
character="dominant_character"
#否則返回隱性性狀
else:
character="recessive_character"
return character

#實驗n次,觀察高莖與矮莖數量比
def Count_test(n,list1,list2):
count_dominant=0
count_recessive=0
for i in range(n):
analysis1=Character_analysis(list1,list2)
if analysis1=="dominant_character":
count_dominant+=1
if analysis1=="recessive_character":
count_recessive+=1

ration=count_recessive*1.0/count_dominant
return ration

def Print(n,ratio_pureHigh_pureLow,ratio_crossHigh_crossHigh,ratio_crossHigh_pureLow):
print 'n:',n
print 'ratio_pureHigh_pureLow:',ratio_pureHigh_pureLow
print 'ratio_crossHigh_crossHigh:',ratio_crossHigh_crossHigh
print 'ratio_crossHigh_pureLow:',ratio_crossHigh_pureLow

#繪圖前準備,得到多次實驗的比例系數集合
def List_ratio(n,list1,list2):
list_ration=[]
for i in range(n):
ration=Count_test(n,list1,list2)
list_ration.append(ration)

return list_ration

#實驗1:純種高莖與純種矮莖的數量比
#list_ratio1=List_ratio(n,high_pure,low_pure)
#實驗2:雜種高莖與雜種高莖的數量比
#list_ratio2=List_ratio(n,cross_high,cross_high)
#實驗3:雜種高莖和純種矮莖的數量比
#list_ratio3=List_ratio(n,cross_high,low_pure)

#實驗1:純種高莖與純種矮莖的數量比
ratio_pureHigh_pureLow=Count_test(n,high_pure,low_pure)

#實驗2:雜種高莖與雜種高莖的數量比
#ratio_crossHigh_crossHigh=Count_test(n,cross_high,cross_high)

#實驗3:雜種高莖和純種矮莖的數量比
#ratio_crossHigh_pureLow=Count_test(n,cross_high,low_pure)

#Print(n,ratio_pureHigh_pureLow,ratio_crossHigh_crossHigh,ratio_crossHigh_pureLow)

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

返回顶部