GenEvo 1 Genetic Switch

GenEvo 1 Genetic Switch preview image

1 collaborator

My_photo_2 Sugat Dabholkar (Author)


(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 197 times • Downloaded 13 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.)


This model simulates a complex phenomenon in molecular biology: the “switching” (on and off) of genes depending on environmental conditions. Through molecular interactions between specific regulatory proteins and specific DNA sequences, each regulated gene is turn on or off in response to environmental stimuli.

Specifically, it is a model of the [lac-operon]( of a bacterium (E. coli.), which is responsible for the uptake and digestion of lactose, when lactose is the preferred energy source in the environment. It simulates the regulation of synthesis of the enzymes [permease (LacY)]( and [beta-galactosidase (LacZ)](


This genetic switch is in essence, a positive feedback loop. It is responsible for regulating the synthesis of proteins required to conduct the uptake and digestion of lactose.

In this model, there are in fact two sugars: glucose and lactose. Glucose is "preferred" as an energy source over lactose. When there is glucose and/or no lactose in the surrounding environment, the genetic switch is at an _off steady-state_. This is because the repressor protein [LacI]( prevents (mostly) the bacteria from producing the proteins, by binding to the">operator site of the DNA. In this steady state, relatively little permease (LacY) and beta-galactosidase (LacZ) are produced.

When lactose is introduced to the outside environment, the lactose molecules enter into the bacterial cell through permease proteins (LacYs). Some lactose molecules that enter the cell bind to LacIs, preventing LacIs from binding to the operator site of the DNA. This, in turn, causes more LacYs to be produced. The LacYs get inserted into the cell-wall, which causes more lactose to enter the cell, thus creating a positive feedback loop. The LacZs, meanwhile digest lactose molecules inside the cell to produce energy.

The effect of glucose (through [cAMP]( is only implicitly modelled. The rate at which LacZ and LacI are produced reduces significantly when glucose is present.

### Important Proteins

1. *RNAP* – These are RNA polymerases that synthesize mRNA from DNA. These are represented by brown blobs in the model. This model does not include mRNAs.

2. *LacI* – The purple-colored shapes in the model represent a repressor (LacI proteins). They bind to the operator region (see below) of the DNA and do not let RNAP to pass along the gene, thus stopping protein synthesis. When lactose binds to LacI, they form LacI-lactose complexes (shown by a purple shape with a grey dot attached to it). These complexes cannot bind to the operator region of the DNA.

3. *LacY* – These are shown in the model as light red rectangles. They are produced when an RNAP passes along the gene. When they hit the cell-wall, they get installed on the cell-wall (shown by light patches). Lactose (grey pentagons) from the outside environment is transported inside the cell through these light red patches.

4. *LacZ* – These are shown as light red colored proteins. They are present inside the cell. When they collide with a lactose molecule, the lactose molecule is digested and energy is produced.

### DNA Regions

There are four important DNA regions in this model:

1. *Promoter* – This region is indicated by the color green. As an RNAP binds to the promoter region and if the operator is free, it moves along DNA to start transcription.

2. *Operator* – This region is indicated by the color orange. The repressor protein, LacI, binds to this region and prevents RNAP from moving along the DNA.

3. *Operon* – This is indicated by the color blue. This is where lacY and lacZ genes are. This model includes only these two genes of the operon.

4. *Terminator* – This is indicated by the color grey. RNAP separates from the DNA when it reaches this region.

As RNAP moves along the gene, LacY and LacZ proteins are produced (five molecules per transcription). We do not show translation by ribosomes in this model.

### Energy of the cell

Producing and maintaining the protein machinery for a cell takes energy. So as a cell produces proteins and maintains those proteins (RNAPs, LacIs and LacZs), its energy decreases.

Energy of the cell increases when lactose inside the cell is digested.

### Cell division

When the energy of the cell doubles from its initial value, it splits into two daughter cells. Each of these cells has half of the energy of the original cell as well as half the number of each type of protein in the original cell.


### To setup

Each slider controls a certain aspect of this genetic regulation circuit. Refer to the Sliders Section for more information on the function of each variable.

Once all the sliders are set to the desired levels, the user should click SETUP to initialize the cell.

### To run

To observe the switching behavior of the genetic switch, set GLUCOSE? to ON and LACTOSE? to OFF. Let the simulation run for a few hundred ticks. Observe the changes in the energy of the cell as time progresses and cell divides. The energy drops to half when a cell divides.

To run the simulation faster, uncheck the 'view updates' box for several thousand ticks. Observe the LacZ production in the graph. It varies because of the stochastic nature of the molecular interactions in the cell. This variability even when the switch "is off" is why genetic switches are referred to as "leaky".

Set GLUCOSE? to OFF and LACTOSE? to ON to see the behavior of the genetic switch by observing change in the LacZ production.

While molecular interactions (micro) are best observed through running the simulation with 'view updates' checked, to observe cellular behavior (macro), 'view updates' should be unchecked and the simulation should be run for several thousand ticks.

### Buttons

The SETUP button initializes the model

The GO button runs the simulation until the cell dies

### Switches

LACTOSE? - If ON, lactose is added to the external medium (outside of the cell)

GLUCOSE? - If ON, glucose is added to the external medium. Glucose is implicitly modelled meaning that when GLUCOSE? is ON, energy of a cell increases at a constant rate (10 units/tick). In addition, since glucose is a "preferred energy source", the lac promoter is less active when GLUCOSE? is ON.

### Sliders

LACI-NUMBER - Sets the number of LacIs

RNAP-NUMBER - Sets the number of RNAPs

LACI-BOND-LEAKAGE - This is the chance a LacI molecule bonded to the operator detaches from the operator

LACI-LACTOSE-BINDING-CHANCE - Sets the chance that a lactose and a LacI come together to form a LacI-lactose complex

LACI-LACTOSE-SEPARATION-CHANCE - Sets the chance that a LacI-lactose complex separates

LACY-DEGRADATION-CHANCE - Sets the chance of degradation of a LacY that is installed on the cell-wall

LACZ-DEGRADATION-CHANCE - Sets the chance of degradation of a LacZ molecules in the cell

### Plots

Energy – Plots the amount of energy in the cell over time

lacZ Number – Plots the number of LacZ molecules inside a cell

Average Cell Division Time – Plots the average number of ticks between two cell division events. It can be used as a growth rate indicator.


Notice the three parts of the molecular mechanism involved in the control of the genetic switch:

1. Uptake of lactose from outside to inside through LacY

2. Repression by LacI in absence of lactose

3. Formation of LacI-lactose complex in presence of lactose and removal of repression

Notice the changes in energy of the cells when lactose is added (that is, when LACTOSE? is ON and when LACTOSE? is OFF).

Notice the energy changes when a cell divides.

Notice the changes in the Average Cell Division Time as time progresses.

Notice the effect of changes in the environmental conditions (ON/OFF of GLUCOSE? and LACTOSE? on the Average Cell Division Time and the LacZ Number.


Try to make the genetic switch more sensitive to the environmental conditions. It should be "on" only when lactose is present and "off" otherwise. You can do this be changing the slider parameters.

If the cell starts to uptake lactose and produce energy faster, does the Average Cell Division Time also decrease?


In real life, cells aren't flat! See if you can extend the model into three-dimensions with NetLogo 3D.


This model uses NetLogo's `with` primitive extensively. This is because, although the different proteins are represented by different `breeds`, the proteins also exist in various states.


* GenEvo Curricular Models

* GenDrift Sample Models


If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

* Dabholkar, S., Bain, C. and Wilensky, U. (2016). NetLogo GenEvo 1 Genetic Switch model. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

Please cite the NetLogo software as:

* Wilensky, U. (1999). NetLogo. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

To cite the GenEvo Systems Biology curriculum as a whole, please use:

* Dabholkar, S. & Wilensky, U. (2016). GenEvo Systems Biology curriculum. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.


Copyright 2016 Uri Wilensky.

![CC BY-NC-SA 3.0](

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at

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

  ; 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


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

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

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

to go

  ; 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 ]

; 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

; 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) [

  ; 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
        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 ]
        ask partner [
          set partner myself
        dissociate-from-operator ; if necessary, dissociate from the operator

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

; 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

; 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) ]
    ; 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 ]

; 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
  ask lacZs [
    if (random-float 1 < lacZ-degradation-chance) [ die ] ; there's a chance lacZ degrades

; 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 ]

; 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) [
      set on-dna? false

  ; Any other RNAPs just move around the cell
  ask RNAPs with [ not on-dna? ] [
    ; 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 ]

; procedure to synthesize proteins upon dna transcription

to synthesize-proteins
  hatch-lacYs lacY-production-num [
  hatch-lacZs lacZ-production-num [
  set energy energy - (lacY-production-cost * lacY-production-num) - (lacZ-production-cost * lacZ-production-num)

; 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
  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

;;;;;;;;;;;;;;;;;;;;;;;;;;  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))
      (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))
       (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)
    (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))
   (( 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))
    ((pxcor > 16 and pxcor < 19))
  ask terminator [ set pcolor gray ]

; 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

; 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) [
        set inside? false
        set partner nobody

; 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

; 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

; 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 ]

;;;;;;;;;;;;;;;;;;;;;;  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
  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 ]

; 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? ])))

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

There is only one version of this model, created about 2 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 2 years ago, by Sugat Dabholkar Download

This model does not have any ancestors.

This model does not have any descendants.