GenEvo 4 Competition

GenEvo 4 Competition 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 422 times • Downloaded 28 times • Run 0 times
Download the 'GenEvo 4 Competition' 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

extensions [ ls cf ]

globals [
  ; These are constant variables used to specify simulation restrictions
  global-lactose-limit         ; variable to specify lactose quantity
  initial-energy               ; variable to specify initial energy of bacterial cells
  old-models-list                  ; list of ls:models to identify newly created model
]

breed [ ecolis ecoli ]

ecolis-own [
  my-model              ; cell model (LevelSpace child model) associated with an E. coli cell
  my-model-path         ; path to locate the file to be used for creating a cell model (LevelSpace child model)

  ; these variables are used to store the corresponding statistics from the cell models
  energy                ; energy of the cell
  lactose-inside        ; lactose quantity inside a cell
  lactose-outside       ; lactose quantity in the outside environment
  lacZ-inside           ; lacZ proteins inside a cell
  lacY-inside           ; lacY proteins inside a cell
  lacY-inserted         ; lacY proteins inserted into the cell-wall
  lacI-lactose-complex  ; lacI-lactose-complex molecules inside a cell
]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;; SETUP PROCEDURES ;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup
  clear-all
  ls:reset
  ; set the constant values
  set initial-energy 1000
  set global-lactose-limit (initial-number-of-cells * 5000)
  generate-cells ; create the cells
  if lactose? [ distribute-lactose ] ; distribute lactose if the option is selected
  reset-ticks
end 

; procedure to generate E. coli cells. If choose-models is OFF, default cell model is created for all the cells.

to generate-cells
  let color-list [ gray red brown yellow green cyan violet magenta ]

  let i 0
  create-ecolis initial-number-of-cells [
    set color (item i color-list)
    setxy random-xcor random-ycor
    set shape "ecoli"

    ifelse choose-models? [
      user-message "Select a Genetic Switch model to use..."
      set my-model-path user-file
    ][
      set my-model-path "GenEvo 1 Genetic Switch.nlogo"
    ]

    create-my-model
    while [ test-if-switch my-model ] [
      user-message "The model must be a Genetic Switch model! Please select a Genetic Switch model again."
      ls:close my-model
      set my-model-path user-file
      create-my-model
    ]
    set i i + 1
  ]
end 

to create-my-model ; turtle procedure
  ; If my-model-path is False, it means the user didn't select a file.
  ; In that case, we kill the E. coli so we this doesn't mess anything up.
  ifelse my-model-path != False [
    ls:create-interactive-models 1 my-model-path
    set my-model max ls:models
    ls:hide my-model

    ls:let initial-variables-list generate-initial-variables-list
    ls:ask my-model [
      setup
      set-initial-variables initial-variables-list
    ]
  ]
  [ die ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;; RUNTIME PROCEDURES ;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go
  distribute-lactose
  ask ecolis [
    rt random-float 360
    fd 1
    run-your-model
    maybe-reproduce
    if energy < 0 [
      ls:close my-model
      die
    ]
  ]
  if not any? ecolis [ stop ]
  tick
end 

; Updates the enviornmental conditions and then runs each cell model

to run-your-model ; turtle procedure
   ls:let lactose-outside-per-cell ifelse-value lactose? [ floor ( global-lactose-limit / length ls:models ) ] [ 0 ]
   ls:let parent-glucose? glucose?
   ls:let parent-lactose? lactose?

   ls:ask my-model [
     set glucose? parent-glucose?
     set lactose? parent-lactose?
     go
   ]
end 

; when lactose? is OFF, this procedure is used to update the lactose quantity in the environment in the population model

to distribute-lactose
  ifelse lactose? [
    ls:let lactose-per-model (global-lactose-limit / length ls:models)
    ask patches [ set pcolor 2 ]
    ask ecolis [ ls:ask my-model [ update-lactose lactose-per-model ] ]
  ][
    ; see how much lactose is outside all of the cells
    let total-lactose-outside sum [ count lactoses with [ not inside? ] ] ls:of ls:models

    cf:when ; color the patches based on the global lactose amount
    cf:case [ total-lactose-outside < (global-lactose-limit / 2) ] [ ask patches [ set pcolor 1 ]]
    cf:case [ total-lactose-outside = 0 ] [ ask patches [ set pcolor 0 ] ]
    cf:else [ ask patches [ set pcolor 2 ] ]

    ls:let lactose-per-model (total-lactose-outside / length ls:models)
    ask ecolis [ ls:ask my-model [ update-lactose lactose-per-model ] ]
  ]
end 

; procedure for E. coli cells to reproduce. A new cell is added in the population model and a new individual cell model is created.

to maybe-reproduce
  ; if there's enough energy, reproduce
  if ( [ energy ] ls:of my-model > 2 * initial-energy ) [
    ls:ask my-model [ divide-cell ]
    extract-cell-model-variables
    hatch 1 [
      rt random-float 360 fd 1 ; move it forward so they don't overlap
      create-my-model  ; Now create and setup the cell model that will simulate this new daughter cell
    ]
  ]
end 

; procedure to concatenate all the necessary initial variables for a daughter cell model into a single list

to-report generate-initial-variables-list ; turtle procedure
  report (list color initial-energy lacY-inside lacY-inserted lacZ-inside lacI-lactose-complex lactose-inside lactose-outside lactose? glucose?)
end 

; Extract all the necessary variables from the cell model

to extract-cell-model-variables ; turtle procedure

  let list-of-variables ([ send-variables-list ] ls:of my-model) ; grab the list

  ; now save the elements in our 'ecolis-own' variables
  set energy item 0 list-of-variables
  set lacY-inside item 1 list-of-variables
  set lacY-inserted item 2 list-of-variables
  set lacZ-inside item 3 list-of-variables
  set lacI-lactose-complex item 4 list-of-variables
  set lactose-inside item 5 list-of-variables
  set lactose-outside item 6 list-of-variables
end 

; procedure to view the cell model (LevelSpace child model) associated with each cell

to inspect-cells
  if mouse-inside? and mouse-down? [
    ask ecolis with-min [ distancexy mouse-xcor mouse-ycor ] [
      ls:show my-model
    ]
  ]
end 

; procedure to test whether or not a model is a Genetic Switch model

to-report test-if-switch [ a-model-number ]
  let return-value False
  carefully [
    ls:ask a-model-number [ set LevelSpace? True ]
  ][
     set return-value True
   ]
  report return-value
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 4 Competition.png preview Preview for 'GenEvo 4 Competition' about 8 years ago, by Sugat Dabholkar Download

This model does not have any ancestors.

This model does not have any descendants.