alt text

DOWNLOAD THE MODEL

http://stemccm.com/wp-content/uploads/2015/07/Hardy-Weinberg-Model.zip

WHAT IS IT?

This is a simple example of genetic information being handed down from parents to offspring. The model can also demonstrate Hardy Weighberg Equilibrium.

HOW IT WORKS

Fish are given alleles for color. Homozygous Recessive results in green fish while Heterozygous and Homozygous Dominant results in red fish. Fish are able to move, die, and breed.

HOW TO USE IT

Press setup and go!

THINGS TO NOTICE

Run the model out to a high number of ticks a number of times. Is the result always the same? Why or why not?

THINGS TO TRY

Is Hardy Weighberg Equalibrium preserved?
Try changing the population size to determine the minimum population level required to consistently maintain equilibrium.
To better facilitate this, try changing the wait time.

EXTENDING THE MODEL

Adding gender to the fish would make the model more accurate to real life.
Adding a preditor to put pressure on a certain genotype could be interesting.

NETLOGO FEATURES

turtles-own
of
ifelse
plot

CREDITS AND REFERENCES

Hardy Weinberg Model
Created by Richard Newton
CCM Classroom Computer Modeling (2014)

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

CODE

;; Hardy Weinberg Model
;; Richard Newton
;; CCM Classroom Computer Modeling (2014)
;; Please see info tab for liscensing information


turtles-own                                                                        ;; here we are giving each turtle some unique characteristics
 [                                                                                 ;;
   gene1                                                                           ;; gene1 will be the first allele for fish color (1 is dominant and 0 is recessive)
   gene2                                                                           ;; gene2 will be the second allele for fish color
   tempgene1                                                                       ;; tempgene1 and tempgene2 will store the genetic info of the parents until the baby is born,
   tempgene2                                                                       ;;  then the information will be passed on to the baby and it's color will be adjusted
   age                                                                             ;; age will hopefully limit population growth
 ]                                                                                 ;;

to setup                                                                           ;; this submodel will build the world + fish that have genotypes for color
  clear-all                                                                        ;;
  reset-ticks                                                                      ;;
  ask patches [set pcolor blue]                                                    ;;
  crt 100 [set size 2 set shape "fish" setxy random-xcor random-ycor]              ;;
  ask turtles [set gene1 random 2]                                                 ;; each fish flips a coin for the first allele, gene1 (random 2 will result in either a 0 or 1)
  ask turtles [set gene2 random 2]                                                 ;; each fish flips a coin for the second allele, gene2 (random 2 will result in either a 0 or 1)
  ask turtles [if gene1 + gene2 = 0 [set color green]]                             ;; if the sum of both alleles = 0, the the fish is homozygous recessive and green
  ask turtles [if gene1 + gene2 > 0 [set color red]]                               ;; if the sum of the alleles > 0, then the fish is either heterozygous or homozygous dominant and red
end

to go                                                                              ;; this submodel will have fish move, die, and breed
  tick                                                                             ;;
  wait .1                                                                          ;;
  ask turtles [forward 1 right random 30 left random 30 set age age + 1]           ;; fish move randomly and age (age increases by 1 each tick)
  ask turtles [if age > 80 or count turtles > 200 [die]]                           ;; fish die if they are over age 80 or there are more than 200 fish
                                                                                   ;;
  ask turtles with [age > 30]                                                      ;; this is the most complex part of the program. fish of age 30 or greater are asked..
   [                                                                               ;;
    if any? other turtles in-radius 1 with [age > 30]                              ;; if there is another fish that is 30 or older within a radius of 1..
    [                                                                              ;; 
      let partner min-one-of other turtles with [age > 30] [distance myself]       ;; the word "partner" now represents that fish they are going to breed with
                                                                                   ;;  
      ifelse random 2 = 0                                                          ;; the first fish flips a coin (0 or 1) 
         [set tempgene1 gene1]                                                     ;; if the result is 0, it sets tempgene1 equal to it's first gene (gene1)
         [set tempgene1 gene2]                                                     ;; otherwise, tempgene1 is set to it's second gene (gene2)
                                                                                   ;; 
      ifelse random 2 = 0                                                          ;; the second fish's information ("partner") is gathered here with another coin flip (0 or 1)
        [set tempgene2 [gene1] of partner]                                         ;; if the result is 0, it sets tempgene2 equal to it's first gene 
        [set tempgene2 [gene2] of partner]                                         ;; otherwise, tempgene2 is set to it's second gene (gene2)
                                                                                   ;;
      hatch 1                                                                      ;; finally, the baby is hatched
        [                                                                          ;; since it's a clone of the first fish, it has the same age, gene1, gene2, tempgene1, and tempgene2 as the parent
         set age 0                                                                 ;; age is set to 0
         set gene1 tempgene1                                                       ;; gene1 is the first parent's gene1 which we don't want this baby fish to have, so we replace it with tempgene1
         set gene2 tempgene2                                                       ;; gene2 is the first parent's gene2 which we don't want this baby fish to have, so we replace it with tempgene2
         if gene1 + gene2 = 0 [set color green]                                    ;; if the sum of both alleles = 0, the the fish is homozygous recessive and green
         if gene1 + gene2 > 0 [set color red]                                      ;; if the sum of the alleles > 0, then the fish is either heterozygous or homozygous dominant and red
        ]                                                                          ;;
    ]                                                                              ;;
   ]                                                                               ;;
end                                                                                ;;