!!!---hivsim.nlogo

来自「NETLOGO」· NLOGO 代码 · 共 1,716 行 · 第 1/5 页

NLOGO
1,716
字号
          set rep_rate 0.05 
        ]
        if(breed = bCell) 
        [ 
          set halfL life_B 
          set color white 
        ]
        if(breed = plasma) 
        [ 
          set halfL life_Plasma 
          set color green 
        ]
        if(breed = memB) 
        [ 
          set halfL life_MemB 
          set color white
        ]
        if(breed = thCell) 
        [ 
          set halfL life_Th 
          set color blue 
        ]
        if(breed = memTh) 
        [ 
          set halfL life_MemTh 
          set color blue 
        ]
        if(breed = effTh) 
        [ 
          set halfL life_EffTh 
          set color green 
        ]
        if(breed = epCell) 
        [ 
          set halfL 1000 
          set color green 
        ]
        if(breed = tcCell) 
        [ 
          set halfL life_Tc 
          set color blue 
        ]
        if(breed = memTc) 
        [ 
          set halfL life_MemTc 
          set color blue 
        ]
        if(breed = effTc) 
        [ 
          set halfL life_EffTc 
          set color green 
        ]
        if(breed = ab) 
        [ 
          set halfL life_Ab 
          set color yellow
        ]
        if(breed = cyto) 
        [ 
          set halfL life_Cyto 
          set color brown
        ]
        if(breed = apc) 
        [ 
          set halfL life_Apc 
          set vRNA []
          set color grey
        ]
end</p><p>to create-cells
        create-custom-bCell numB
        [
                initialize-turtle-vars
                disperse
        ]
        create-custom-epCell numEp
        [
                initialize-turtle-vars
                disperse
        ]
        create-custom-hiv numHiv
        [
                initialize-turtle-vars
                disperse
        ]
        create-custom-thCell numTh
        [
                initialize-turtle-vars
                disperse
        ]
        create-custom-apc numApc
        [
                initialize-turtle-vars
                disperse
        ]
        create-custom-tcCell numTc
        [
                initialize-turtle-vars
                disperse
        ]
end</p><p>;; the interactions of entities, as described in the supplemental materials
to do-interact
        locals [this other ]
        set this self
        if ((breed = bCell or breed = memB) and (state = "resting"))
        [
                set other random-one-of hiv in-radius .2 with [ not neutralized? ]
                if((other != nobody) and (success receptor (epitope-of other)))
                [
                        set state "activated" ;; the B cell is still in resting state but is presenting an HLA2/peptide complex. 
                                            ;; Subsequent binding with a Th cell will result in its activation
                        set HLA2/pep (peptide-of other)
                        ask other [ die ]
                ]
        ]
        if((breed = bCell or breed = memB) and not stimulated?)
        [
                if((count cyto-here) >= bystander_thr) ;; bystander activation of B cells and memory B cells
                [
                  set state "activated"
                        set stimulated? true
                ]
        ]
        if((breed = bCell or breed = memB) and not stimulated? and (state = "activated"))
        [
                set other random-one-of turtles in-radius .2 with [ ((breed = thCell) or (breed = memTh)) ]
                if(other != nobody  and (success HLA2/pep (receptor-of other)))
                [
                        set stimulated? true
                        set stimulated?-of other true ;; B cells are also APCs and can thus stimulate Th cells
                ]
        ]
        if(((breed = thCell) or (breed = memTh)) and not stimulated?)
        [
                set other random-one-of turtles in-radius .2 with [ ((breed = apc)) and (state = "activated") ]
                if((other != nobody)  and (success receptor (HLA2/pep-of other)))
                [
                        set state "activated"
                        set stimulated? true
                        set stimulated?-of other true ;; this has no effect on apcs. However, stimulated B cells are able to divide
                ]
        ]
        if(((breed = tcCell) or (breed = memTc)) and not stimulated?)
        [
                set other random-one-of apc in-radius .2 with [ stimulated? ]
                if((other != nobody) and (success receptor (HLA1/pep-of other)))
                [
                        set state "activated"
                        set stimulated? true
                ]
        ]
        if(((breed = tcCell) or (breed = memTc)) and not stimulated?)
        [
                if((count cyto-here) >= bystander_thr)
                [
                  set state "activated"
                        set stimulated? true
                ]
        ]
        if(breed = apc) ;; apcs (particularly folicular dendritic cells) may serve as viral reservoirs
        [
                set other random-one-of hiv in-radius .2 with [ not neutralized? ]
                if((other != nobody) and prob p_nonspec)
                [
                        set state "activated"
                        set HLA1/pep (peptide-of other) ;; an activated apc presents viral peptides on both HLA1 and HLA2
                        set HLA2/pep (peptide-of other)
                        set vRNA lput (peptide-of other) vRNA
                        ask other [ die ]                       
                ]
        ]
end</p><p>;; the half-life of each entity is used to determine the probability that it will die during a given time step. Because the gradual 
;; depletion of Th cells, a hallmark of hiv pathogenesis, is thought to arise not only from direct hiv-mediated killing of infected 
;; Th cells but also from indirect killing (or bystander effect) of Th cells. We assume 
;; that this indirect killing of Th cells is a function of the number of both activated and infected cells in the vicinity of a 
;; Th cell and on the value of the AICD parameter.
to do-apoptosis
        locals [ diff tau ]
        if((breed = thCell) or (breed = memTh) or (breed = effTh)) [ set halfL max (list 0 (halfL - (aicd <em> ((count turtles-here with [ infected? ]) + (count hiv-here))))) ] 
        set tau halfL
        set diff ((ln 2) </em> tau)
        if(prob exp (0 - diff)) [ die ]
end</p><p>;; the dissociation of an apc from a bound virion. This is thought to contribute to the pepertuation of viremia in chronically 
;; infected patients.
to do-dissociation
  locals [ this ]
  set this self
  if(prob pdissociation and not empty? vRNA)
  [
    foreach vRNA
    [
      hatch 1
      [
        set breed hiv
        initialize-turtle-vars
        set epitope ?
        set peptide ?
      ]
    ]
    set vRNA [ ]
    set state "resting"
    set stimulated? false
  ]
end</p><p>;; the neutralization of a virion by an antibody. Note that to keep the number of turtles relatively low and, consequently, improve the 
;; speed of the simulation, all neutralized virions and the antibodies involved are immediately removed from the simulation.
to do-ab-neutralization
        locals [ other this ]
        set this self
        set other random-one-of hiv in-radius .2 with [ not neutralized? and (success epitope (paratope-of this)) ]
        if((other != nobody) and (prob neutRate))
        [ 
                set neutralized (neutralized + 1)
                ask other [ die ]
                die
        ]
end</p><p>;; viral infection of target cells. The probability of infection is determined by the infectivity parameter or the lethality variable
to do-infection
        locals [ this other ]
        set this self
        set other random-one-of turtles in-radius .2 with [ (breed = thCell) or (breed = memth) or (breed = effTh) ] ;; hiv preferentially infect th cells
        if(other = nobody) [ set other random-one-of turtles in-radius .2 with [ (breed != hiv) and (breed != cyto) and (breed != ab) and (breed != ara)] ]
        if(other != nobody)
        [
          if(prob lethality)
          [
              set infected?-of other true
                    set HLA1/pep-of other peptide
                    set inf_rep_rate-of other rep_rate ;; the replication rate for inactivated virions, in vivo, is set to 0
                    set inf_lethality-of other lethality
                    set inf_lethal_load-of other lethal_load
                    die
                ]
        ]
end</p><p>;; plasma cells secrete numAbs antibodies during each time step
to do-ab-secretion
        locals [ this ]
        set this self   
        hatch numAbs
        [
                set breed ab
                initialize-turtle-vars
                set paratope (receptor-of this)
        ]
end</p><p>;; effector Th cells secrete numCyto cytokines during each time step
to do-cyto-production
        locals [ this ]
        set this self
        hatch numCyto
        [
                set breed cyto
                initialize-turtle-vars
        ]
end</p><p>;; the killing of infected cells by Tc cells. The probability that a Tc cell will kill an infected cell on initial contact is given 
;; by the ctlRate parameter
to do-ctl
        locals [ other ]
        set other random-one-of turtles in-radius .2 with [ infected? ]
        if((other != nobody) and (success receptor (HLA1/pep-of other)) and (prob ctlRate)) [ ask other [ die ] set killed (killed + 1)]
end</p><p>;; activated B, memory B, Th, memory Th, Tc, and memory Tc cells divide over two time steps to produce 4 cells - 2 effectors cells and
;; 2 memory cells
to do-cell-division
        locals [ this ]
        set this self
        ifelse(numDivs >= 2)
        [
                if((breed = bCell) or (breed = memB))
                [
                        hatch 2
                        [
                                set breed memB
                                initialize-turtle-vars
                                ifelse(prob mutB) [ set receptor random maxspec ] [ set receptor (receptor-of self) ]
                        ]
                        hatch 2
                        [
                                set breed plasma
                                initialize-turtle-vars
                                set receptor (receptor-of this)
                        ]
                        die
                ]
                if((breed = thCell) or (breed = memTh))
                [
                        hatch 2
                        [
                                set breed memTh
                                initialize-turtle-vars
                                set receptor (receptor-of this)
                        ]
                        hatch 2
                        [
                                set breed effTh
                                initialize-turtle-vars
                                set receptor (receptor-of this)
                        ]
                        die
                ]
                if((breed = tcCell) or (breed = memTc))
                [
                        hatch 2
                        [
                                set breed memTc
                                initialize-turtle-vars
                                set receptor (receptor-of this)
                        ]
                        hatch 2
                        [
                                set breed effTc
                                initialize-turtle-vars
                                set receptor (receptor-of this)
                        ]
                        die
                ]
        ]
        [
                set numDivs (numDivs + 1)
        ]
end</p><p>;; productively infected cells (as opposed to infected but dormant/anergic cells)       continue to produce new virions until
;; either a) they are killed during CTL or (b) their viral load exceeds the lethal load of the infecting virus. In the latter
;; case, the infected cells undergo lysis, releasing new virions into the simulation.
to do-viral-production
        locals [ this ]
        set this self
        set vLoad floor(exp(inf_rep_rate * sinceInf))
        ifelse( vLoad > inf_lethal_load)
        [
                hatch vLoad
                [
                        set breed hiv
                        initialize-turtle-vars
                        ifelse(prob mutV) 
                        [ 
                          set peptide random maxspec 
                          set epitope random maxspec 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?