Hardy-Weinberg Equilibrium

Hardy-Weinberg Equilibrium preview image

1 collaborator

Screen_shot_2018-02-02_at_12.53.50_pm lin xiang (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.2.0 • Viewed 87 times • Downloaded 18 times • Run 0 times
Download the 'Hardy-Weinberg Equilibrium' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT

This model simulates four conditions that intervene Hardy-Weinberg Equilibrium. Students may observe the model outcomes to infer these conditions.

CREDITS AND REFERENCES

This module is made by Dr. Lin Xiang at the University of Kentucky.If you mention this model in a publication, we ask that you include the citations below.

Xiang, L. (2016). Hardy-Weinberg Equilibrium. Department of STEM Education, University of Kentucky, Lexington, KY.

CC BY-NC-SA 4.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/4.0/.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [num-survival attribute1 attribute2 x y]
turtles-own [genotype]

breed [gametes gamete]
breed [individuals individual]

to-report number-big-a
  report length (word 0 [genotype] of turtles) - length (remove "A" (word 0 [genotype] of turtles))      ;report total number of "A"
end 

to-report number-small-a
report length (word 0 [genotype] of turtles) - length (remove "a" (word 0 [genotype] of turtles))      ;report total number of "a"
end 

to-report freq-big-a
  report number-big-a / (number-big-a + number-small-a)   ;report allele frequency of "A"
end 

to-report freq-small-a
  report number-small-a / (number-big-a + number-small-a)  ;report allele frequency of "a"
end 

to-report fa2
  report count individuals with [genotype = "AA"] ;report numbe of the homozygous dominant
end 

to-report f2a
  report count individuals with [genotype = "aa"]  ;report numbe of the homozygous recessive
end 

to-report faa
  report (count individuals with [genotype = "Aa"] + count individuals with [genotype = "aA"])  ;report numbe of the heterzygous
end 

to trait               ;define gamete trait
  ifelse genotype = "A" [set color 57][set color 26]
  set size 0.5
end 

to big-a              ;assign "A" allele
  set genotype "A"
end 

to sml-a               ;assign "A" allele
  set genotype "a"
end 
; -----------------------------------------

to setup

  set-default-shape gametes "circle"
  set-default-shape individuals "beetle"

  ca

setup-patches
setup-gametes
fertilization
reset-ticks
output
end 

to setup-gametes    ;generate gemetes based on population size and allele ratio, and randomly distribute the gametes
   create-gametes population-size * (A/a-ratio / 100) * 2 [

    big-a
    trait
    setxy random-xcor random-ycor
  ]

  create-gametes population-size * ((100 - A/a-ratio) / 100) * 2 [

    sml-a
    trait
    setxy random-xcor random-ycor
  ]
end 

to setup-patches
  ask patches [set pcolor Environment-color]
end 



;====================================

to go
  tick
  setup-patches
  ask turtles [move]
  process
 if number-big-a = 0 or number-small-a = 0 [stop]
 output
end 

to move
 rt random 45 lt random 45 fd 1
end 

to process
   if Conditions = "Condition 2" [
     gametogenesis
    fertilization
   ]

   if Conditions = "Condition 1" [
     gametogenesis-1
     fertilization
   ]
   if Conditions = "Condition 3" [
     gametogenesis
     fertilization
     survival
   ]

   if Conditions = "Condition 4" [
     gametogenesis-2
    fertilization
   ]
end 

to fertilization
  ask gametes [let target one-of other gametes           ;one gamete randomly fuses with another gamete
    if target != nobody [
      hatch-individuals 1 [
        set genotype (word genotype [genotype] of target)   ;determine the genotype
        if genotype = "AA" [set color 21 + random-float 2]     ;determine the phynotype
        if genotype = "Aa" or genotype = "aA" [set color 23 + random-float 2]
        if genotype = "aa" [set color 25 + random-float 2]
        set size 3
      ]
      ask target [die]  ;the two gametes disappear after forming the zygote
      ]
     die
     ]
end 

to gametogenesis                  ;Each individual produces two gametes. The homozygous produces the same kind of gametes. The heterzygous produces one "A" and one "a"
  ask individuals with [genotype = "AA"] [
    hatch-gametes 2 [ big-a trait setxy random-xcor random-ycor move ]
    die]

  ask individuals with [genotype = "aa"] [
   hatch-gametes 2 [ sml-a trait setxy random-xcor random-ycor move ]
    die]

  ask individuals with [genotype = "Aa"] [
    hatch-gametes 1 [ big-a trait setxy random-xcor random-ycor move]
    hatch-gametes 1 [ sml-a trait setxy random-xcor random-ycor move]
    die]

  ask individuals with [genotype = "aA"] [
    hatch-gametes 1 [ big-a trait setxy random-xcor random-ycor move]
    hatch-gametes 1 [ sml-a trait setxy random-xcor random-ycor move]
    die]
end 

to gametogenesis-1       ;Each individual produces two gametes.
                         ;The homozygous produces the same kind of gametes.
                         ;The heterzygous produces gamete twice. Each time it has 50% chance to produce "A" or "a"one "A" and one "a"
  ask individuals with [genotype = "AA"] [
    hatch-gametes 2 [ big-a trait move ]
    die]

  ask individuals with [genotype = "aa"] [
   hatch-gametes 2 [ sml-a trait move ]
    die]

  ask individuals with [genotype = "Aa"] [
    hatch-gametes 1 [ ifelse random 2 = 0 [big-a][sml-a] trait move]
    hatch-gametes 1 [ ifelse random 2 = 0 [big-a][sml-a] trait move]

    die]

  ask individuals with [genotype = "aA"] [
    hatch-gametes 1 [ ifelse random 2 = 0 [big-a][sml-a] trait move]
    hatch-gametes 1 [ ifelse random 2 = 0 [big-a][sml-a] trait move]
    die]
end 

to gametogenesis-2     ;Each individual produces two gametes.
                         ;The homozygous produces the same kind of gametes. A mutant gamete is produced at a chance of 1.
                         ;The heterzygous produces gamete twice. Each time it has 50% chance to produce "A" or "a"one "A" and one "a"

  ask individuals with [genotype = "AA"] [
    hatch-gametes 2 [ ifelse random 100 = 0 [sml-a][big-a] trait move ]
    die]

  ask individuals with [genotype = "aa"] [
   hatch-gametes 2 [ ifelse random 100 = 0 [big-a][sml-a] trait move ]
    die]

  ask individuals with [genotype = "Aa"] [
    hatch-gametes 1 [ big-a trait move]
    hatch-gametes 1 [ sml-a trait move]
    die]

  ask individuals with [genotype = "aA"] [
    hatch-gametes 1 [ big-a trait move]
    hatch-gametes 1 [ sml-a trait move]
    die]
end 

to survival         ;differential survival
   ask individuals [if random-float 500 < abs (color - Environment-color) ^ 3 [die]]

  ;count sivivial rate and scale up the population
   if count individuals < population-size [
     set num-survival count individuals
    create-individuals round (population-size * (count individuals with [genotype = "AA"] / num-survival) - (num-survival * (count individuals with [genotype = "AA"] / num-survival)))
    [set genotype "AA" set color 21 + random-float 2 set size 4 setxy random-xcor random-ycor]
    create-individuals round (population-size * (count individuals with [genotype = "aa"] / num-survival) - (num-survival * (count individuals with [genotype = "aa"] / num-survival)))
    [set genotype "aa" set color 25 + random-float 2 set size 4 setxy random-xcor random-ycor]
    create-individuals round (population-size * (count individuals with [genotype = "Aa"] / num-survival) - (num-survival * (count individuals with [genotype = "Aa"] / num-survival)))
    [set genotype "Aa" set color 23 + random-float 2 set size 4 setxy random-xcor random-ycor]
    create-individuals round (population-size * (count individuals with [genotype = "aA"] / num-survival) - (num-survival * (count individuals with [genotype = "aA"] / num-survival)))
    [set genotype "aA" set color 23 + random-float 2 set size 4 setxy random-xcor random-ycor]
  ]
end 

to output
  ifelse ticks < 10 [output-type word 0 ticks][output-type ticks]
  repeat 9 [output-type " "]
  output-write fa2
  repeat 3 [output-type " "]
  output-write faa
  repeat 3 [output-type " "]
  output-type f2a
  repeat 11 [output-type " "]
  output-type number-big-a
  repeat 10 [output-type " "]
  output-print number-small-a

  ;]
end 

to watch-a-beetle
  if mouse-inside? [
    if mouse-down? [
      set x mouse-xcor set y  mouse-ycor
      let picked-beetle one-of individuals with [distancexy x y < 1]
      if picked-beetle != nobody
        [watch picked-beetle
         set attribute1 [color] of picked-beetle
        set attribute2 [genotype] of picked-beetle]
  ]]
end 

There are 2 versions of this model.

Uploaded by When Description Download
lin xiang almost 3 years ago fix plot Download this version
lin xiang almost 3 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Hardy-Weinberg Equilibrium.png preview Preview for 'Hardy-Weinberg Equilibrium' almost 3 years ago, by lin xiang Download

This model does not have any ancestors.

This model does not have any descendants.