GenEvo 1 Genetic Switch

GenEvo 1 Genetic Switch preview image

1 collaborator

My_photo_2 Sugat Dabholkar (Author)

Tags

(This model has yet to be categorized with any tags)
Part of project 'GenEvo Curriculum'
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0-BETA1 • Viewed 424 times • Downloaded 27 times • Run 0 times
Download the 'GenEvo 1 Genetic Switch' modelDownload this modelEmbed this model

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


Info tab cannot be displayed because of an encoding error

Comments and Questions

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

Click to Run Model

globals [
  ; Simulation constants
  cell-width                 ; the width of the cell
  cell-height                ; the height of the cell
  cell-color                 ; the color of the cell
  cell-wall                  ; a patch set that contains the patches on the cell wall
  cell-patches               ; a patch set that contains the patches inside the cell
  promoter                   ; a patch set that contains the patches that represent the promoter
  operator                   ; a patch set that contains the patches that represent the operator
  terminator                 ; a patch set that contains the patches that represent the terminator
  lacZ-production-num        ; number of lacZ proteins produced per transcription event
  lacZ-production-cost       ; cost incurred by the cell to produce one molecule of lacZ protein
  lacY-production-num        ; number of lacZ proteins produced per transcription event
  lacY-production-cost       ; cost incurred by the cell to produce one molecule of lacZ protein
  initial-energy             ; initial energy of the cell
  lactose-upper-limit        ; a variable to set the lactose quantity in the external environment

  ; Global (cellular) properties
  energy                     ; keeps track of the energy of the cell
  division-number            ; a counter to keep track of number of cell division events
  inhibited?                 ; boolean for whether or not the operator is inhibited
]

breed [ lacIs lacI ]         ; the lacI repressor protein (purple proteins)
breed [ lacZs lacZ ]         ; the lacZ beta-galactosidase enzyme (light red proteins)
breed [ lacYs lacY ]         ; the lacY lactose permease enzyme (light red rectangles)
breed [ RNAPs RNAP ]         ; RNA Polymerase (brown proteins) that binds to the DNA and synthesizes mRNA
breed [ lactoses lactose ]   ; lactose molecules (grey)

lacIs-own [
  partner                ; if it's a lacI complex, then partner is a lactose molecule
  bound-to-operator?     ; a boolean to track if a lacI is bound to DNA as an inhibitor of transcription
]

RNAPs-own [
  on-DNA?     ; a boolean to track if a RNAP is transcribing the DNA
]

lactoses-own [
  partner     ; a partner is a lacI molecule with which an ONPG forms a complex
  inside?     ; a boolean to track if a lactose molecule is inside the cell
]

to setup
  clear-all

  ; Set all of our constant global variables
  set cell-width 44
  set cell-height 16
  set initial-energy 1000
  set lactose-upper-limit 1500
  set lacZ-production-num 5
  set lacZ-production-cost 10
  set lacY-production-num 5
  set lacY-production-cost 10

  ; Initialize all of our global property variables
  set energy initial-energy
  set division-number 0
  set inhibited? false

  draw-cell

  ; add the necessary proteins to the cell
  create-lacIs lacI-number [
    set bound-to-operator? false
    set partner nobody
    set-shape
    gen-xy-inside-inside
  ]
  create-RNAPs RNAP-number [
    set on-DNA? false
    set-shape
    gen-xy-inside-inside
  ]

  if not LevelSpace? [
    if lactose? [ update-lactose lactose-upper-limit ] ; add lactose if ON
  ]
  reset-ticks
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;  Runtime Procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go
  go-lacI
  go-lacY
  go-lacZ
  go-lactose
  go-RNAP

  ; if glucose? is ON, we get a steady stream of energy
  if glucose? [ set energy energy + 10 ]
  ; but it takes energy to maintain all of the proteins so consume some energy
  set energy (energy - (count RNAPs + count lacIs + count lacZs) / 100 )

  ; If we're in LevelSpace, then let the population model control division and lactose distribution.
  if not LevelSpace? [
    if lactose? [ update-lactose lactose-upper-limit ]

    ; if we've doubled our energy, then divide
    if (energy > 2 * initial-energy) [ divide-cell ]

    ; if we're out of energy, die
    if (energy < 0) [ user-message "The cell has run out of energy. It's dead!" stop ]
  ]
  tick
end 

; controls the random movement of all turtles. If you're headed towards the cell wall, just turn until you're not

to move ; turtle procedure
  rt random-float 360
  while [ (member? patch-ahead 1 cell-wall) or (member? patch-ahead 2 cell-wall) ] [ rt random-float 360 ]
  forward 1
end 

; procedure for movement and molecular interactions of lacI proteins

to go-lacI
  ; a lacI bound with the operator might dissociate from the operator
  ask lacIs with [ bound-to-operator? ] [
    if (random-float 1 < lacI-bond-leakage) [
      dissociate-from-operator
    ]
  ]

  ; lacIs with partners might dissociate from their partners
  ask lacIs with [ partner != nobody ] [
     if (random-float 1 < lacI-lactose-separation-chance) [
      ask partner [
        set partner nobody
        move-to myself
        set-shape
        forward 1
      ]
      set partner nobody
      forward -1
    ]
  ]

  ; lacIs without partners either bind with the operator
  ask lacIs with [ partner = nobody ] [
    ifelse (not inhibited?) and ((member? patch-here operator) or (member? patch-ahead 1 operator)) [
      set bound-to-operator? true
      set inhibited? true
      set heading 0
      setxy -12 1
    ] [ ; or maybe bind with a lactose
      if (count lactoses-here with [ partner = nobody ] > 0  and (random-float 1 < lacI-lactose-binding-chance)) [
        set partner one-of lactoses-here with [ partner = nobody ]
        set-shape
        ask partner [
          set partner myself
          set-shape
        ]
        dissociate-from-operator ; if necessary, dissociate from the operator
      ]
    ]
  ]

  ask lacIs with [ not bound-to-operator? ] [ move ]
end 

; procedure for lacIs to dissociate from the operator

to dissociate-from-operator ; lacI procedure
  if (bound-to-operator?) [
    set bound-to-operator? false
    set inhibited? false
    forward 3
  ]
end 

; procedure for movement and interactions of lacY proteins

to go-lacY
  ask lacYs [
    ; if lacY hits the cellwall, it gets installed on the cell wall
    ifelse (member? patch-ahead 2 cell-wall) [
      ask patch-ahead 2 [ set pcolor (red + 2) ]
      die
    ]
    ; otherwise we just move normally
    [ move ]
  ]
  ; each tick, the installed lacYs have a chance of degrading
  ask patches with [pcolor = (red + 2)] [
    if (random-float 1 < lacY-degradation-chance) [ set pcolor cell-color ]
  ]
end 

; procedure for movement and interactions of lacZ proteins

to go-lacZ
  ; lacZs near lactose can digest that lactose and produce energy
  ask lacZs with [ any? lactoses in-radius 1 with [ partner = nobody ] ] [
    ask lactoses in-radius 1 with [ partner = nobody ] [
      set energy energy + 10
      die
    ]
  ]
  ask lacZs [
    move
    if (random-float 1 < lacZ-degradation-chance) [ die ] ; there's a chance lacZ degrades
  ]
end 

; procedure for movement and interactions of lactose molecules

to go-lactose
  ; any lactoses near an installed lacY get pumped into the cell
  ask lactoses with [ ([ pcolor ] of patch-ahead 2 = (red + 2)) and not inside? ] [
    move-to patch-ahead 2 set heading towards patch 0 0 ; make sure the lactose gets inside the cell
    fd 3
    set inside? true
  ]

  ask lactoses [ move ]
end 


; procedure for movement and molecular interactions of RNAPs

to go-RNAP
  ; In the presence of glucose, the probability of trancription is less.
  let transcription-probability ifelse-value (glucose?) [ 0.1 ] [ 1 ]

  ; If any RNAPs are close to the promoter and the operator is not inhibited
  if (not inhibited?) [
    ask RNAPs with [ (member? patch-here promoter) or (member? patch-ahead 1 promoter) or (member? patch-ahead 2 promoter) ] [
      if random-float 1 < transcription-probability [
         ; then start moving along the DNA to model transcription
         setxy xcor 1
         set heading 90
         set on-dna? true
      ]
    ]
  ]

  ; If any RNAPs are in the process of transcribing (on-dna?) move them along
  ask RNAPs with [ on-dna? ] [
    forward 1
    ; when you reach the terminator, synthesize the proteins
    if (member? patch-here terminator) [
      synthesize-proteins
      set on-dna? false
      gen-xy-inside-inside
    ]
  ]

  ; Any other RNAPs just move around the cell
  ask RNAPs with [ not on-dna? ] [
    move
    ; Because our DNA is fixed within the cell,  RNAPs at both ends of the
    ; of the cell are moved to a random position inside the cell
    if (xcor > (cell-width - 3) or xcor < (- cell-width + 3)) [ gen-xy-inside-inside ]
  ]
end 

; procedure to synthesize proteins upon dna transcription

to synthesize-proteins
  hatch-lacYs lacY-production-num [
    gen-xy-inside-inside
    set-shape
  ]
  hatch-lacZs lacZ-production-num [
    gen-xy-inside-inside
    set-shape
  ]
  set energy energy - (lacY-production-cost * lacY-production-num) - (lacZ-production-cost * lacZ-production-num)
end 

; procedure to simulate cell division; each type of turtle (except RNAPs and lacIs) population is halved

to divide-cell
  ask n-of (count lacIs with [ partner != nobody ] / 2) lacIs with [ partner != nobody ] [
    ask partner [ die ]
    set partner nobody
    set-shape
  ]
  ask n-of (count lactoses with [ inside? and partner = nobody ] / 2) lactoses with [ inside? and partner = nobody ] [ die ]
  ask n-of (count lacYs / 2) lacYs [ die ]
  ask n-of (count patches with [ pcolor = (red + 2) ] / 2) patches with [ pcolor = (red + 2) ] [ set pcolor cell-color ]
  ask n-of (count lacZs / 2) lacZs [ die ]

  set energy energy / 2
  set division-number division-number + 1
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;  Helper Procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; procedure that sets patches for the cell, the cell-wall, and the
; regions of the DNA; although it looks complicated, really we're just
; addressing a bunch of patch-sets

to draw-cell
  set cell-wall ( patch-set
    ; the vertical part of the cell wall
    (patches with [
      (pycor = cell-height or pycor = (- cell-height))
       and
      (pxcor > (-(cell-width + 1)) and pxcor < (cell-width + 1))
    ])
    ; the horizontal part of the cell wall
    (patches with [
       (pxcor = cell-width or pxcor = (- cell-width))
        and
       (pycor > (-(cell-height + 1)) and pycor < (cell-height + 1))
     ])
  )
  set-cell-color brown

  ; patches inside the cell-wall are set white.
  set cell-patches patches with [
    (pycor > (- cell-height) and pycor < cell-height)
     and
    (pxcor > (- cell-width)  and pxcor < cell-width)
  ]
  ask cell-patches [ set pcolor white ]

  ; the operon patches are blue
  let operon patches with [ (pycor > -1 and pycor < 2) and (pxcor > -10 and pxcor < 17) ]
  ask operon [ set pcolor blue ]

  ; promoter is green
  set promoter patches with [ (pycor > -1 and pycor < 2) and (pxcor > -22 and pxcor < -14) ]
  ask promoter [ set pcolor green ]

  ; operator is orange
  set operator patches with [
   ((pycor = 0) and (pxcor > -15 and pxcor < -9))
    or
   (( pycor = 1) and (( pxcor = -10) or ( pxcor = -12) or ( pxcor = -14)))
  ]
  ask operator [ set pcolor orange ]

  ; the terminator patches are gray
  set terminator patches with [
    ((pycor > -1) and (pycor < 2))
     and
    ((pxcor > 16 and pxcor < 19))
  ]
  ask terminator [ set pcolor gray ]
end 

; procedure that assigns a specific shape to an agent based on breed

to set-shape ; turtle procedure
  if breed = lacIs [
    set size 6
    ifelse partner = nobody [
      set shape "lacI"
    ][ ; if you have a partner, you're a lacI-lactose-complex
      set shape "lacI-lactose-complex"
      set size 6
    ]
  ]
  if breed = RNAPs [
    set size 5
    set shape "RNAP"
    set color brown
  ]
  if breed = lactoses [
    ifelse partner = nobody [
      set size 2
      set shape "pentagon"
      set hidden? false
    ][ ; if you have a partner, you're invisible!
      set hidden? true
     ]
  ]
  if breed = lacYs [
    set shape "pump"
    set color (red + 2)
    set size 3
  ]
  if breed = lacZs [
    set shape "protein"
    set color (red + 2)
    set size 4
  ]
end 

; to keep the lactose amount constant if the lactose? switch is on

to update-lactose [ upper-limit ]
    let num-lactose-outside count lactoses with [ not inside? ]
    ifelse num-lactose-outside > upper-limit [
      ask n-of (num-lactose-outside - upper-limit) lactoses with [ not inside? ] [ die ]
    ][
      create-lactoses (upper-limit - num-lactose-outside) [
        gen-xy-inside-outside
        set inside? false
        set partner nobody
        set-shape
      ]
    ]
end 

; procedure to place a molecule inside the cell

to gen-xy-inside-inside ; turtle procedure
  setxy random-xcor random-ycor
  while [ not member? patch-here cell-patches] [
    setxy random-xcor random-ycor
  ]
end 

; procedure to place a molecule outside the cell

to gen-xy-inside-outside ; turtle procedure
  setxy random-xcor random-ycor
  while [(member? patch-here cell-wall) or (member? patch-here cell-patches)] [
    setxy random-xcor random-ycor
  ]
end 

; procedure to set the color of the cell wall. (this is a separate procedure because
; in LevelSpace, the cell wall color needs to be assigned)

to set-cell-color [ the-color ]
  set cell-color the-color
  ask cell-wall [ set pcolor the-color ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;  LevelSpace Procedures ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; procedure to setup the cell according to parameters passed in from the population model

to set-initial-variables [ the-list ]

  ; 'the-list' is the following list of numbers (or counts) and booleans
  ; [ cell-color initial-energy energy initial-lacYs initial-lacYs-inserted initial-lacZs
  ;    initial-lacI-lactose-complexes initial-lactose-inside initial-lactose-outside
  ;    glucose?-setting lactose?-setting ]

  ; we use NetLogo's `item` primitive to directly select elements of the list
  set LevelSpace?      true
  set-cell-color       item 0 the-list
  set initial-energy   item 1 the-list
  set energy           initial-energy
  set lactose?         item 8 the-list
  set glucose?         item 9 the-list

  ; create the necessary turtles
  ask n-of (item 3 the-list) cell-wall [ set pcolor red + 2 ]
  create-lacYs (item 2 the-list) [ gen-xy-inside-inside ]
  create-lacZs (item 4 the-list) [ gen-xy-inside-inside ]
  create-lactoses (item 6 the-list) [
    set inside? true
    set partner nobody
    gen-xy-inside-inside
  ]
  ask n-of (item 5 the-list) lacIs [
    hatch-lactoses 1 [
      set inside? true
      set partner myself
      ask partner [ set partner myself ]
    ]
  ]
  ask turtles [ set-shape ]
end 

; procedure to extract list of variables to use in the population model when using LevelSpace

to-report send-variables-list
  report (list (energy) (count lacYs) (count (patches with [pcolor = red + 2])) (count lacZs)
      (count (lacIs with [ partner != nobody ])) (count (lactoses with [ (inside?) and (partner = nobody) ])) (count (lactoses with [ not inside? ])))
end 


; Copyright 2016 Uri Wilensky.
; See Info tab for full copyright and license.

There is only one version of this model, created about 8 years ago by Sugat Dabholkar.

Attached files

File Type Description Last updated
GenEvo 1 Genetic Switch.png preview Preview for 'GenEvo 1 Genetic Switch' about 8 years ago, by Sugat Dabholkar Download

This model does not have any ancestors.

This model does not have any descendants.