Heterozygosity Simulation

No preview image

1 collaborator

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 41 times • Downloaded 8 times • Run 0 times
Download the 'Heterozygosity Simulation' modelDownload this modelEmbed this model

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


Comments and Questions

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

Click to Run Model

turtles-own [
  allele1
  allele2

  allele3
  allele4

  allele5
  allele6

  allele7
  allele8

  allele9
  allele10

  heterozygous-loci
  heterozygosity
  offspring-number
  is-juvenile
  survival

]

to setup
  clear-all
  ask patches [set pcolor white]
  create-turtles initial-turtles [
    setxy random-xcor random-ycor
    set color black
   ifelse who < initial-turtles * initial-homozygous-AA  ;;UNSURE HOW TO RANDOMIZE;;
      [set allele1 "A1"
       set allele2 "A1"]
    [ifelse who < initial-turtles * (initial-homozygous-AA + initial-heterozygous-Aa)
          [ifelse random-float 1.0 < 0.5
           [set allele1 "A1"
           set allele2 "A2"]
           [set allele1 "A2"
          set allele2 "A1"]]
      [set allele1 "A2"
        set allele2 "A2"]]

     ifelse who < initial-turtles * initial-homozygous-BB  ;;UNSURE HOW TO RANDOMIZE;;
      [set allele3 "B1"
       set allele4 "B1"]
    [ifelse who < initial-turtles * (initial-homozygous-BB + initial-heterozygous-Bb)
          [ifelse random-float 1.0 < 0.5
           [set allele3 "B1"
           set allele4 "B2"]
           [set allele3 "B2"
          set allele4 "B1"]]
      [set allele3 "B2"
        set allele4 "B2"]]

     ifelse who < initial-turtles * initial-homozygous-CC  ;;UNSURE HOW TO RANDOMIZE;;
      [set allele5 "C1"
       set allele6 "C1"]
    [ifelse who < initial-turtles * (initial-homozygous-CC + initial-heterozygous-Cc)
          [ifelse random-float 1.0 < 0.5
           [set allele5 "C1"
           set allele6 "C2"]
           [set allele5 "C2"
          set allele6 "C1"]]
      [set allele5 "C2"
        set allele6 "C2"]]

     ifelse who < initial-turtles * initial-homozygous-DD  ;;UNSURE HOW TO RANDOMIZE;;
      [set allele7 "D1"
       set allele8 "D1"]
    [ifelse who < initial-turtles * (initial-homozygous-DD + initial-heterozygous-Dd)
          [ifelse random-float 1.0 < 0.5
           [set allele7 "D1"
           set allele8 "D2"]
           [set allele7 "D2"
          set allele8 "D1"]]
      [set allele7 "D2"
        set allele8 "D2"]]

    ifelse who < initial-turtles * initial-homozygous-EE  ;;UNSURE HOW TO RANDOMIZE;;
      [set allele9 "E1"
       set allele10 "E1"]
    [ifelse who < initial-turtles * (initial-homozygous-DD + initial-heterozygous-Dd)
          [ifelse random-float 1.0 < 0.5
           [set allele9 "E1"
           set allele10 "E2"]
           [set allele9 "E2"
          set allele10 "E1"]]
      [set allele9 "E2"
        set allele10 "E2"]]

    set is-juvenile false
  ]

  calculate-heterozygosity
  produce-offspring-number

  reset-ticks
end 

to go
  reproduce-and-die
  age-juveniles
  calculate-heterozygosity
  produce-offspring-number
  tick
end 

to calculate-heterozygosity
  ask turtles [
    set heterozygous-loci 5
    if allele1 = allele2 [set heterozygous-loci heterozygous-loci - 1]
    if allele3 = allele4 [set heterozygous-loci heterozygous-loci - 1]
    if allele5 = allele6 [set heterozygous-loci heterozygous-loci - 1]
    if allele7 = allele8 [set heterozygous-loci heterozygous-loci - 1]
    if allele9 = allele10 [set heterozygous-loci heterozygous-loci - 1]

    set heterozygosity heterozygous-loci / 5
  ]
end 

to produce-offspring-number
  ask turtles [
    set offspring-number random-poisson (heterozygosity + 1) ;;RETURN TO THIS;;
  ]
end 

to reproduce-and-die
  ask turtles [
    if is-juvenile = false [
    while [offspring-number > 0] [
    let mate one-of turtles with [offspring-number > 0 and who != [who] of myself]

    if mate = nobody [stop]

    let mate-allele-locus1 one-of [list allele1 allele2] of mate
    let my-allele-locus1 one-of (list allele1 allele2)

    let mate-allele-locus2 one-of [list allele3 allele4] of mate
    let my-allele-locus2 one-of (list allele3 allele4)

    let mate-allele-locus3 one-of [list allele5 allele6] of mate
    let my-allele-locus3 one-of (list allele5 allele6)

    let mate-allele-locus4 one-of [list allele7 allele8] of mate
    let my-allele-locus4 one-of (list allele7 allele8)

    let mate-allele-locus5 one-of [list allele9 allele10] of mate
    let my-allele-locus5 one-of (list allele9 allele10)

    hatch 1 [
       set allele1 my-allele-locus1
       set allele2 mate-allele-locus1

       set allele3 my-allele-locus2
       set allele4 my-allele-locus2

       set allele5 my-allele-locus3
       set allele6 my-allele-locus3

       set allele7 my-allele-locus4
       set allele8 my-allele-locus4

       set allele9 my-allele-locus5
       set allele10 my-allele-locus5

       set is-juvenile true

       wander
    ]

     set offspring-number offspring-number - 1
     ask mate [set offspring-number offspring-number - 1]
  ]
     die
 ]
]
end 

to age-juveniles
  ask turtles [
    if is-juvenile = true [
      set survival e ^ (- lethal-equivalent) * (1 - heterozygosity) ;;MAY REMOVE LETHAL-EQUIVALENT;;
      ifelse random-float 1.0 < survival
      [die]
      [set is-juvenile false]
    ]
  ]
end 

to wander
  rt random-float 30 - random-float 30
  fd 1
end 
















There is only one version of this model, created over 2 years ago by Kathryn Groenewald.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.