Bacterial competition with toxin producer

No preview image

3 collaborators

Default-person Cameron Crandall (Author)
Steve Krone (Author)
Anna Rodriguez (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.0.5 • Viewed 501 times • Downloaded 35 times • Run 0 times
Download the 'Bacterial competition with toxin producer' modelDownload this modelEmbed this model

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


## WHAT IS IT?

A spatial model of competition between two bacterial species (green and red), with green cells producing a toxin that kills red cells.

## Color Coding

Color Coding:

Turtles: Magenta- normal toxin molecule that can diffuse and attach to red cells

Blue- toxin molecule that has attached to (red) cell and can no longer move

Patches: Shades of Green and Red- bacterial cells, lighter shades represent more cells at a location

Yellow- unoccupied patch; Brown- unoccupied after previously being occupied (shows clearing of red cells by toxin)

## HOW BACTERIA WORK

Each patch begins with some allocation of nutrient and can be occupied by up to 3 cells. Reproduction occurs at a specified rate, which depends on cell type, as long as the cell has acquired sufficient energy by consuming nutrient. A unit of nutrient that is consumed confers a specified amount of energy. Each reproduction event costs the reproducing cell energy. A cell that does not have sufficient energy to reproduce will attempt to consume nutrient from its `nutrient neighborhood' (patches that are within a Moore neighborhood with radius three). This is an efficient method for simulating the effects of nutrient diffusion without excessive computational cost. The offspring cell is placed at the patch of the parent or at one of the 8 neighboring patches, with pre-specified probabilities, as long as there is space available and the other species is not present at that patch. Reproduction is suppressed whenever all these local patches are at their carrying capacity. A red cell that is killed by toxin releases a specified amount of nutrient to that patch.

## HOW TOXINS WORK

Toxin molecules (turtles) are produced by green cells at each tick, as long as they have sufficient energy. Toxin molecules diffuse and can attach to red cells. Toxins kill red cells if enough attach; they do not attach to or harm green cells. A toxin molecule will degrade after a specified time.

## THINGS TO TRY

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

## EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

## NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

## RELATED MODELS

(models in the NetLogo Models Library and elsewhere which are of related interest)

## CREDITS AND REFERENCES

(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)

Comments and Questions

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

Click to Run Model

globals [red-nearby green-nearby red-toxin-area green-toxin-area toxin-area setup-size target feeding-radius radius nearby ]
breed [toxins toxin] ;; creates a breed of turtles called "toxins" pluaral and "toxin" singular
toxins-own [age] ;; toxin specific variable used to calculate how old the molecule is
patches-own [ cells energy dormant time nutrient] ; variables for the patches

; Color Coding:
;toxins: Magenta- normal toxin that can move and attach 
;       Blue- toxins that have attached to cell and can no longer move
;Patches: Shades of Green and Red- normal bacterial cells, lighter shades represent more cells at a location, 
;         Yellow- Unoccupied patch, Brown- unoccupied after previously being occupied (shows clearing of red cells by toxin)
;      
;
;
;

to setup
  clear-all
  reset-ticks
  set red-nearby circle-neighborhood red-radius
  set green-nearby circle-neighborhood green-radius
  
  set setup-size circle-neighborhood colony-initial-size
  set feeding-radius circle-neighborhood 3
  
  if mode = "1 colony" ; 1 colony mode sets up a single green colony in the middle
  [
    ask patches [set pcolor 48] 
    ask patch (0) (0)
    [
      ask patches at-points setup-size [
        set pcolor 57
        set energy 0
        set cells 3
      ]
    ]
  ]
  if mode = "random positions" ; this mode spreads a specified number of green and red cells across the grid
  [
    ask patches 
    [
      set pcolor 48
      set cells 0
      set nutrient nutrient-amount
    ] 
    while [count patches with [pcolor = 55] < number-of-green] [ask patch random-xcor random-ycor 
      [
        if pcolor = 48  
        [
          set pcolor 55
          set cells 1
          set nutrient nutrient-amount
        ]
      ]
    ]
    while [count patches with [pcolor = 15] < number-of-red] [ask patch random-xcor random-ycor [
      if pcolor = 48  
      [
        set pcolor 15
        set cells 1
        
        set nutrient nutrient-amount]
    ]
    ]
    
    
  ]
  if mode = "2 colonies" ; this mode makes a green colony and a red colony a specific distance apart
  [
    ask patches [set pcolor 48] 
    ask patch ((distance-apart / 2)) (0)
    [
      ask patches at-points setup-size 
      [
        set pcolor 57
        set energy 0
        set cells 3
      ]
    ]
    ask patch ((distance-apart / -2)) (0)
    [
      ask patches at-points setup-size 
      [
        set pcolor 17
        set energy 0
        set cells 3
        
      ]
    ]
  ]
end 

to go
  
  if growth? [
    ask patches with [ (pcolor = 55) or (pcolor = 56) or (pcolor = 57)]  
    [
      eating-green grow-green 
      if toxin? [   make-toxin] 
      set time time + 1 
    ]
    ask patches with [(pcolor = 15) or (pcolor = 16) or (pcolor = 17)]  
    [
       eating-red grow-red  
      set time time + 1
    ]
  ]
  ask turtles ;; asks the turtles to run their commands
  [
    
    if mode = "2 colonies" ;; this command delays the phage from doing anything until after 200 ticks. This give the bacteria time to grow first
    [
     if ticks = 200
     [
      
      
       if color = orange
       [
        set color blue 
       ] 
      
     ] 
    ]
  ]
  ask toxins ; asks the toxins to run their commands
  [
   toxin-move toxin-attach grow-up
  ]
  
 
  ifelse show-toxin? ; this will show all the toxins if the switch is turned on
  [
    ask toxins
    [
      show-turtle 
    ]
  ]
  [
   ask toxins
   [
    hide-turtle 
   ] 
  ]
  
  tick
end 

to grow-green
  ;; if a cell has energy it can grow, cells with more open spaces near them ( yellow patches) will have a higher chance of reproducing. 
  ;; probability is (number of yellow in von-neuman neighborhood / total number of patches in vonneumann neigbborhood) * 90% + 10%
  ;; added a 10% base probability to all cells to make colonies more symmetrical
  ;; the grow command works by asking a patch if its energy is less than 1. It is it will "roll a dice" with a higher chance of success based on the number of yellow patches nearby. 
  ;;If the roll is succesfull the patch will ask itself if it has less than the maximum number of patches (2) if it does it will roll another dice. If that number is less than 5 it will place
  ;; the new cell on itself and increase the number of cells on that patch. If the roll is greater than 5 it will put the newly formed cell in a neighboring patch.
  ;; the cell will ask one-of neighbors with cells < 3 (if it can't find a cell with cells < 3 it will return "nobody" and stop the reproduction event) after finding a cell with cells < 3 that's the right color
  ;; it will add a new cell to that location and change cells number and color accordingly.
 if time > reproduction-time-green ;; this is how you change the growth rate !!!!! start with competitor being faster
 [ 
  if energy >= reproduction-energy-green
    [
      
        ifelse cells < 3
        [
          ifelse add-to-parent-site > random 100
          [
            set cells cells + 1
            set energy energy - 1
            if cells = 2 
            [
              set pcolor 56
            ]
            if cells = 3
            [
              set pcolor 57
            ]
          ]
          [ set target one-of neighbors with [cells < 3]
            
            if target != nobody
            [ 
              ask target
              [
                if ( pcolor = 55) or ( pcolor = 56) or ( pcolor = 57) or ( pcolor = black) or ( pcolor = 48) or (pcolor = brown)
                [
                  if cells = 0 
                  [ 
                    
                    set energy 0
                    set cells 1
                    set pcolor green
                    set time 0
                    ask myself [set energy energy - 1]
                    stop
                  ]
                  if cells = 1
                  [
                    set cells cells + 1
                    set pcolor 56
                    ask myself [set energy energy - 1]
                    stop
                  ]
                  if cells = 2
                  [
                    set cells cells + 1
                    set pcolor 57
                    ask myself [set energy energy - 1]
                    stop
                  ]
                ]
              ]
            ]
          ]
        ]
        [
          set target one-of neighbors with [cells < 3]
          
          if target != nobody 
          [
            ask target
            [
              if (pcolor = 55) or (pcolor = 56) or (pcolor = 57) or (pcolor = black) or (pcolor = 48) or (pcolor = brown)
              [
                if cells = 0 
                [ 
                  set energy 0
                  set cells 1
                  set time 0
                  set pcolor green
                  ask myself [set energy energy - 1]
                  stop
                ]
                if cells = 1
                [
                  set cells cells + 1
                  set pcolor 56
                  ask myself [set energy energy - 1]]
                stop
                if cells = 2
                [
                  set cells cells + 1
                  set pcolor 57
                  ask myself [set energy energy - 1]
                  stop
                ]
              ]
            ]
          ]
        ]
        set time 0
      ]
    ]
end 

to grow-red
  ;; same as green command but with colors switched
  if time > reproduction-time-red
  [ 
    if energy >= reproduction-energy-red
    [
     
        ifelse cells < 3
        [
          ifelse add-to-parent-site > random 100
          [
            set cells cells + 1
            set energy energy - 1
            if cells = 2 
            [
              set pcolor 16
            ]
            if cells = 3
            [
              set pcolor 17
            ]
          ]
          [ set target one-of neighbors with [cells < 3]
            
            if target != nobody
            [ 
              ask target
              [
                if ( pcolor = 15) or ( pcolor = 16) or ( pcolor = 17) or ( pcolor = black) or ( pcolor = 48) or (pcolor = brown)
                [
                  if cells = 0 
                  [ 
                    
                    set energy 0
                    set cells 1
                    set pcolor red
                    set time 0
                    ask myself [set energy energy - 1]
                    stop
                  ]
                  if cells = 1
                  [
                    set cells cells + 1
                    set pcolor 16
                    ask myself [set energy energy - 1]
                    stop
                  ]
                  if cells = 2
                  [
                    set cells cells + 1
                    set pcolor 17
                    ask myself [set energy energy - 1]
                    stop
                  ]
                ]
              ]
            ]
          ]
        ]
        [
          set target one-of neighbors with [cells < 3]
          
          if target != nobody 
          [
            ask target
            [
              if (pcolor = 15) or (pcolor = 16) or (pcolor = 17) or (pcolor = black) or (pcolor = 48) or (pcolor = brown)
              [
                if cells = 0 
                [ 
                  set energy 0
                  set cells 1
                  set time 0
                  set pcolor red
                  ask myself [set energy energy - 1]
                  stop
                ]
                if cells = 1
                [
                  set cells cells + 1
                  set pcolor 16
                  ask myself [set energy energy - 1]]
                stop
                if cells = 2
                [
                  set cells cells + 1
                  set pcolor 17
                  ask myself [set energy energy - 1]
                  stop
                ]
              ]
            ]
          ]
        ]
        set time 0
      ]
    ]
end 

;; this is the reporter used to take a radius number (n) and create a list of all the cells in the neighborhood of the radius n and can store the list as a variable (ex. "red-nearby")

to-report circle-neighborhood [n]
  let result [list pxcor pycor] of patches with [(abs pxcor) ^ 2 + (abs pycor) ^ 2 <= n ^ 2]
  report result 
end 

to eating-green
  ;;a cell can eat at any site with nutrient  and it will consume a set amount of energy.
  ;; this command works by looking for a patch to eat in a set radius.
  ;;based on the neighborhood used by the bacteria (ex: red-nearby). As soon as the patch finds a suitable patch to eat it will move on.
 
  
   if energy < green-hunger
    [
      
      ask one-of patches at-points feeding-radius
      [
        if nutrient > 0
        [
          set nutrient nutrient - 1
          ask myself 
          [
            set energy energy + 1 
          ] 
        ] 
      ] 
    ]
end 

to eating-red
 ;; this is the same as eating-green but works for the red bacteria
  
  if energy < red-hunger
  [
      
      ask one-of patches at-points feeding-radius
      [
        if nutrient > 0
        [
          set nutrient nutrient - 1
          ask myself 
          [
            set energy energy + 1 
          ] 
        ] 
      ] 
    ]
end 

to make-toxin ;; a command for a patch to create and release toxin particles
 if energy > 0 [
   
    sprout-toxins toxin-production
    [
      set color magenta
      set size .5
      set age 0
    ] ]
end 

to toxin-move  ; command to let the toxins move, only magenta toxins can move
  if color = magenta
  [
     right random 360 forward toxin-speed
  ]
end 

to toxin-attach ; toxin can attach and turn pink, once the number of toxin attached is equal to the lethal-amount the cell dies and clears all attached toxin molecules
  if (pcolor = 15) or (pcolor = 16) or (pcolor = 17)  
  [
    if random 100 < probability-of-toxin-attachment
    [
      
      set color blue
      ask patch-here
        [
          if count toxins-here with [color = blue] = lethal-amount
            [
              set pcolor pcolor - 1 
            
              set cells cells - 1 
              set nutrient nutrient + corpse-energy
              
                if cells = 0 [ set pcolor brown ]
              ask toxins-here
              [
                if color = blue
                [
                  die 
                ] 
              ]
            ] 
        ]
    ]
  ]
end 

to grow-up ; toxins grow older each tick once they reach degradation-time they die
  
  ifelse age = degradation-time
  [
   die 
  ]
  [
  set age age + 1
  ]
end 

There is only one version of this model, created about 9 years ago by Cameron Crandall.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.