From 5476c24fda6e12aea2470d55ef15da301d0a2623 Mon Sep 17 00:00:00 2001 From: Allison Li Date: Mon, 23 Oct 2023 14:13:58 -0700 Subject: [PATCH 001/185] adding new cell states to enum + add tests for enum interface --- src/arcade/patch/util/PatchEnums.java | 21 +++++++ test/arcade/patch/util/PatchEnumsTest.java | 67 ++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/src/arcade/patch/util/PatchEnums.java b/src/arcade/patch/util/PatchEnums.java index ea5e95f88..5249f5def 100644 --- a/src/arcade/patch/util/PatchEnums.java +++ b/src/arcade/patch/util/PatchEnums.java @@ -90,6 +90,24 @@ public enum State implements CellState { /** Code for necrotic cells. */ NECROTIC, + + /** Code for stimulatory cells. */ + STIMULATORY, + + /** Code for cytotoxic cells. */ + CYTOTOXIC, + + /** Code for paused cells. */ + PAUSED, + + /** Code for exhausted cells. */ + EXHAUSTED, + + /** Code for anergic cells. */ + ANERGIC, + + /** Code for starved cells. */ + STARVED, /** Code for senescent cells. */ SENESCENT; @@ -112,6 +130,9 @@ public enum Domain implements ProcessDomain { /** Code for metabolism domain. */ METABOLISM, + + /** Code for inflammation domain. */ + INFLAMMATION, /** Code for signaling domain. */ SIGNALING; diff --git a/test/arcade/patch/util/PatchEnumsTest.java b/test/arcade/patch/util/PatchEnumsTest.java index 4564a8d6a..067bc8830 100644 --- a/test/arcade/patch/util/PatchEnumsTest.java +++ b/test/arcade/patch/util/PatchEnumsTest.java @@ -7,6 +7,10 @@ import static org.junit.Assert.*; import static org.mockito.Mockito.*; import static arcade.patch.util.PatchEnums.Flag; +import static arcade.patch.util.PatchEnums.Domain; +import static arcade.patch.util.PatchEnums.Ordering; +import static arcade.patch.util.PatchEnums.State; +import static arcade.patch.util.PatchEnums.Category; public class PatchEnumsTest { @Test(expected = UnsupportedOperationException.class) @@ -34,4 +38,67 @@ public void Flag_random_returnsFlag() { EnumSet enumSetRandom = EnumSet.copyOf(enumRandom); assertEquals(enumSet, enumSetRandom); } + + @Test + public void Domain_random_returnsDomain() { + // Create set of all values. + EnumSet enumSet = EnumSet.allOf(Domain.class); + enumSet.remove(Domain.UNDEFINED); + + // Create set of all random values. + ArrayList enumRandom = new ArrayList<>(); + + int n = Domain.values().length - 1; + for (int i = 0; i < n; i++) { + MersenneTwisterFast rng = mock(MersenneTwisterFast.class); + doReturn(i).when(rng).nextInt(n); + enumRandom.add(Domain.random(rng)); + } + + // Compare resulting sets. + EnumSet enumSetRandom = EnumSet.copyOf(enumRandom); + assertEquals(enumSet, enumSetRandom); + } + + @Test + public void State_random_returnsState() { + // Create set of all values. + EnumSet enumSet = EnumSet.allOf(State.class); + enumSet.remove(State.UNDEFINED); + + // Create set of all random values. + ArrayList enumRandom = new ArrayList<>(); + + int n = State.values().length - 1; + for (int i = 0; i < n; i++) { + MersenneTwisterFast rng = mock(MersenneTwisterFast.class); + doReturn(i).when(rng).nextInt(n); + enumRandom.add(State.random(rng)); + } + + // Compare resulting sets. + EnumSet enumSetRandom = EnumSet.copyOf(enumRandom); + assertEquals(enumSet, enumSetRandom); + } + + @Test + public void Category_random_returnsCategory() { + // Create set of all values. + EnumSet enumSet = EnumSet.allOf(Category.class); + enumSet.remove(Category.UNDEFINED); + + // Create set of all random values. + ArrayList enumRandom = new ArrayList<>(); + + int n = Category.values().length - 1; + for (int i = 0; i < n; i++) { + MersenneTwisterFast rng = mock(MersenneTwisterFast.class); + doReturn(i).when(rng).nextInt(n); + enumRandom.add(Category.random(rng)); + } + + // Compare resulting sets. + EnumSet enumSetRandom = EnumSet.copyOf(enumRandom); + assertEquals(enumSet, enumSetRandom); + } } From 7ddfb2cf2af105d825913574b653ff3bc2f07e19 Mon Sep 17 00:00:00 2001 From: Allison Li Date: Mon, 23 Oct 2023 15:18:08 -0700 Subject: [PATCH 002/185] move step() down to TissueCell --- src/arcade/patch/agent/cell/PatchCell.java | 61 ++----------------- .../patch/agent/cell/PatchCellTissue.java | 58 ++++++++++++++++++ test/arcade/patch/util/PatchEnumsTest.java | 23 +++++++ 3 files changed, 86 insertions(+), 56 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 9cf3da4da..213655c38 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -3,7 +3,6 @@ import java.util.HashMap; import java.util.Map; import sim.engine.Schedule; -import sim.engine.SimState; import sim.engine.Stoppable; import sim.util.Bag; import ec.util.MersenneTwisterFast; @@ -85,7 +84,7 @@ public abstract class PatchCell implements Cell { int age; /** Cell energy [fmol ATP]. */ - private double energy; + double energy; /** Number of divisions. */ int divisions; @@ -103,19 +102,19 @@ public abstract class PatchCell implements Cell { final double criticalHeight; /** Cell state change flag. */ - private Flag flag; + Flag flag; /** Variation in cell agent parameters. */ private final double heterogeneity; /** Fraction of necrotic cells that become apoptotic. */ - private final double necroticFraction; + final double necroticFraction; /** Fraction of senescent cells that become apoptotic. */ - private final double senescentFraction; + final double senescentFraction; /** Maximum energy deficit before necrosis. */ - private final double energyThreshold; + final double energyThreshold; /** Cell state module. */ protected Module module; @@ -309,56 +308,6 @@ public void schedule(Schedule schedule) { stopper = schedule.scheduleRepeating(this, Ordering.CELLS.ordinal(), 1); } - @Override - public void step(SimState simstate) { - Simulation sim = (Simulation) simstate; - - // Increase age of cell. - age++; - - // TODO: check for death due to age - - // Step metabolism process. - processes.get(Domain.METABOLISM).step(simstate.random, sim); - - // Check energy status. If cell has less energy than threshold, it will - // necrose. If overall energy is negative, then cell enters quiescence. - if (state != State.APOPTOTIC && energy < 0) { - if (energy < energyThreshold) { - if (simstate.random.nextDouble() > necroticFraction) { - setState(State.APOPTOTIC); - } else { - setState(State.NECROTIC); - } - } else if (state != State.QUIESCENT && state != State.SENESCENT) { - setState(State.QUIESCENT); - } - } - - // Step signaling network process. - processes.get(Domain.SIGNALING).step(simstate.random, sim); - - // Change state from undefined. - if (state == State.UNDEFINED) { - if (flag == Flag.MIGRATORY) { - setState(State.MIGRATORY); - } else if (divisions == 0) { - if (simstate.random.nextDouble() > senescentFraction) { - setState(State.APOPTOTIC); - } else { - setState(State.SENESCENT); - } - } else { - setState(State.PROLIFERATIVE); - } - } - - // Step the module for the cell state. - if (module != null) { - module.step(simstate.random, sim); - } - } - @Override public CellContainer convert() { return new PatchCellContainer(id, parent, pop, age, divisions, state, diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index 5caaae3eb..1b349c535 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -5,6 +5,11 @@ import arcade.core.env.location.Location; import arcade.core.util.MiniBox; +import sim.engine.SimState; +import arcade.core.sim.Simulation; +import static arcade.patch.util.PatchEnums.Domain; +import static arcade.patch.util.PatchEnums.Flag; +import static arcade.patch.util.PatchEnums.State; /** * Extension of {@link PatchCell} for healthy tissue cells. */ @@ -40,4 +45,57 @@ public PatchCell make(int newID, CellState newState, Location newLocation, return new PatchCellTissue(newID, id, pop, newState, age, divisions, newLocation, parameters, volume, height, criticalVolume, criticalHeight); } + + /* consider making PatchCell parameters protected instead of private */ + /* make step() method that overrides main that is moved over from PatchCell */ + + @Override + public void step(SimState simstate) { + Simulation sim = (Simulation) simstate; + + // Increase age of cell. + super.age++; + + // TODO: check for death due to age + + // Step metabolism process. + super.processes.get(Domain.METABOLISM).step(simstate.random, sim); + + // Check energy status. If cell has less energy than threshold, it will + // necrose. If overall energy is negative, then cell enters quiescence. + if (state != State.APOPTOTIC && energy < 0) { + if (super.energy < super.energyThreshold) { + if (simstate.random.nextDouble() > super.necroticFraction) { + super.setState(State.APOPTOTIC); + } else { + super.setState(State.NECROTIC); + } + } else if (state != State.QUIESCENT && state != State.SENESCENT) { + super.setState(State.QUIESCENT); + } + } + + // Step signaling network process. + super.processes.get(Domain.SIGNALING).step(simstate.random, sim); + + // Change state from undefined. + if (super.state == State.UNDEFINED) { + if (super.flag == Flag.MIGRATORY) { + super.setState(State.MIGRATORY); + } else if (super.divisions == 0) { + if (simstate.random.nextDouble() > super.senescentFraction) { + super.setState(State.APOPTOTIC); + } else { + super.setState(State.SENESCENT); + } + } else { + super.setState(State.PROLIFERATIVE); + } + } + + // Step the module for the cell state. + if (super.module != null) { + super.module.step(simstate.random, sim); + } + } } diff --git a/test/arcade/patch/util/PatchEnumsTest.java b/test/arcade/patch/util/PatchEnumsTest.java index 067bc8830..22286eaf7 100644 --- a/test/arcade/patch/util/PatchEnumsTest.java +++ b/test/arcade/patch/util/PatchEnumsTest.java @@ -1,8 +1,15 @@ package arcade.patch.util; import java.util.ArrayList; +import java.util.Arrays; import java.util.EnumSet; import org.junit.Test; + +import arcade.patch.util.PatchEnums.Category; +import arcade.patch.util.PatchEnums.Domain; +import arcade.patch.util.PatchEnums.Flag; +import arcade.patch.util.PatchEnums.Ordering; +import arcade.patch.util.PatchEnums.State; import ec.util.MersenneTwisterFast; import static org.junit.Assert.*; import static org.mockito.Mockito.*; @@ -101,4 +108,20 @@ public void Category_random_returnsCategory() { EnumSet enumSetRandom = EnumSet.copyOf(enumRandom); assertEquals(enumSet, enumSetRandom); } + + @Test + public void Ordering_in_expected_order() { + // Create list of all values. + ArrayList enumList = new ArrayList(Arrays.asList(Ordering.values())); + + int n = -1; + int verify = -2; + // Grabbing order of items in enum + for (Ordering x: enumList){ + verify = x.ordinal(); + n++; + // Verify order of enum + assertEquals(n, verify); + } + } } From 925ab280fb7c3d2e649bd6c589d838ac6a479711 Mon Sep 17 00:00:00 2001 From: Allison Li Date: Mon, 23 Oct 2023 15:29:38 -0700 Subject: [PATCH 003/185] move state fractions down from PatchCell to TissueCell --- src/arcade/patch/agent/cell/PatchCell.java | 7 ----- .../patch/agent/cell/PatchCellTissue.java | 31 ++++++++++++++++--- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 213655c38..27f0886f4 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -107,11 +107,6 @@ public abstract class PatchCell implements Cell { /** Variation in cell agent parameters. */ private final double heterogeneity; - /** Fraction of necrotic cells that become apoptotic. */ - final double necroticFraction; - - /** Fraction of senescent cells that become apoptotic. */ - final double senescentFraction; /** Maximum energy deficit before necrosis. */ final double energyThreshold; @@ -173,8 +168,6 @@ public PatchCell(int id, int parent, int pop, CellState state, int age, int divi // Set loaded parameters. heterogeneity = parameters.getDouble("HETEROGENEITY"); - necroticFraction = parameters.getDouble("NECROTIC_FRACTION"); - senescentFraction = parameters.getDouble("SENESCENT_FRACTION"); energyThreshold = -parameters.getDouble("ENERGY_THRESHOLD"); // TODO: implement heterogeneity diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index 1b349c535..7af1431c3 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -4,7 +4,9 @@ import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.util.MiniBox; - +import arcade.patch.util.PatchEnums.Domain; +import arcade.patch.util.PatchEnums.Flag; +import arcade.patch.util.PatchEnums.State; import sim.engine.SimState; import arcade.core.sim.Simulation; import static arcade.patch.util.PatchEnums.Domain; @@ -14,9 +16,26 @@ * Extension of {@link PatchCell} for healthy tissue cells. */ + + public class PatchCellTissue extends PatchCell { + /** Fraction of necrotic cells that become apoptotic. */ + private final double necroticFraction; + + /** Fraction of senescent cells that become apoptotic. */ + private final double senescentFraction; + + /** * Creates a tissue {@code PatchCell} agent. + * *

+ * Loaded parameters include: + *

    + *
  • {@code NECROTIC_FRACTION} = fraction of necrotic cells that + * become apoptotic
  • + *
  • {@code SENESCENT_FRACTION} = fraction of senescent cells that + * become apoptotic
  • + *
* * @param id the cell ID * @param parent the parent ID @@ -36,6 +55,10 @@ public PatchCellTissue(int id, int parent, int pop, CellState state, int age, in double criticalVolume, double criticalHeight) { super(id, parent, pop, state, age, divisions, location, parameters, volume, height, criticalVolume, criticalHeight); + + // Set loaded parameters. + necroticFraction = parameters.getDouble("NECROTIC_FRACTION"); + senescentFraction = parameters.getDouble("SENESCENT_FRACTION"); } @Override @@ -48,7 +71,7 @@ public PatchCell make(int newID, CellState newState, Location newLocation, /* consider making PatchCell parameters protected instead of private */ /* make step() method that overrides main that is moved over from PatchCell */ - + @Override public void step(SimState simstate) { Simulation sim = (Simulation) simstate; @@ -65,7 +88,7 @@ public void step(SimState simstate) { // necrose. If overall energy is negative, then cell enters quiescence. if (state != State.APOPTOTIC && energy < 0) { if (super.energy < super.energyThreshold) { - if (simstate.random.nextDouble() > super.necroticFraction) { + if (simstate.random.nextDouble() > necroticFraction) { super.setState(State.APOPTOTIC); } else { super.setState(State.NECROTIC); @@ -83,7 +106,7 @@ public void step(SimState simstate) { if (super.flag == Flag.MIGRATORY) { super.setState(State.MIGRATORY); } else if (super.divisions == 0) { - if (simstate.random.nextDouble() > super.senescentFraction) { + if (simstate.random.nextDouble() > senescentFraction) { super.setState(State.APOPTOTIC); } else { super.setState(State.SENESCENT); From fac3611359e53837cdcea7653facce72f6998038 Mon Sep 17 00:00:00 2001 From: Allison Li Date: Tue, 24 Oct 2023 16:27:46 -0700 Subject: [PATCH 004/185] IN PROGRESS adding CART cell class --- src/arcade/patch/agent/cell/PatchCell.java | 2 + .../patch/agent/cell/PatchCellCART.java | 233 ++++++++++++++++++ .../patch/agent/cell/PatchCellCancer.java | 12 + .../patch/agent/cell/PatchCellTissue.java | 10 + 4 files changed, 257 insertions(+) create mode 100644 src/arcade/patch/agent/cell/PatchCellCART.java diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 27f0886f4..91e6e924f 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -290,6 +290,8 @@ public Process makeProcess(ProcessDomain domain, String version) { return PatchProcessMetabolism.make(this, version); case SIGNALING: return PatchProcessSignaling.make(this, version); + /*case INFLAMMATION: + return PatchProcessInflammation.make(this,version);*/ case UNDEFINED: default: return null; diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java new file mode 100644 index 000000000..fc6634d50 --- /dev/null +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -0,0 +1,233 @@ +package arcade.patch.agent.cell; + +import ec.util.MersenneTwisterFast; +import arcade.core.agent.cell.CellState; +import arcade.core.env.location.Location; +import arcade.core.util.MiniBox; +import arcade.patch.util.PatchEnums.Domain; +import arcade.patch.util.PatchEnums.Flag; +import arcade.patch.util.PatchEnums.State; +import sim.engine.SimState; +import arcade.core.sim.Simulation; +import static arcade.patch.util.PatchEnums.Domain; +import static arcade.patch.util.PatchEnums.Flag; +import static arcade.patch.util.PatchEnums.State; + +/** + * Implementation of {@link Cell} for generic CART cell. + * + *

+ * {@code PatchCellCART} agents exist in one of thirteen states: neutral, apoptotic, + * migratory, proliferative, senescent, cytotoxic (CD8), stimulatory (CD4), + * exhausted, anergic, starved, or paused. + * The neutral state is an transition state for "undecided" cells, and does not + * have any biological analog. + *

+ * + * {@code PatchCellCART} agents have two required {@link Process} domains: + * metabolism and inflammation. Metabolism controls changes in cell energy and + * volume. Inflammation controls effector functions. + *

+ * + * General order of rules for the {@code PatchCellCART} step: + *

    + *
  • update age
  • + *
  • check lifespan (possible change to apoptotic)
  • + *
  • step metabolism module
  • + *
  • check energy status (possible change to starved, apoptotic)
  • + *
  • step inflammation module
  • + *
  • check if neutral or paused (change to proliferative, migratory, senescent, + * cytotoxic, stimulatory, exhausted, anergic)
  • + *
+ * + *

+ * Cells that become senescent, exhausted, anergic, or proliferative have a change to become apoptotic + * instead {@code SENESCENT_FRACTION}, ({@code EXHAUSTED_FRACTION}, ({@code ANERGIC_FRACTION}, and ({@code PROLIFERATIVE_FRACTION}, + * respectively). + *

+ * + * Cell parameters are tracked using a map between the parameter name and value. + * Daughter cell parameter values are drawn from a distribution centered on the + * parent cell parameter with the specified amount of heterogeneity + * ({@code HETEROGENEITY}). + */ + +public class PatchCellCART extends PatchCell { + + /** Fraction of exhausted cells that become apoptotic. */ + private final double exhaustedFraction; + + /** Fraction of senescent cells that become apoptotic. */ + private final double senescentFraction; + + /** Fraction of anergic cells that become apoptotic. */ + private final double anergicFraction; + + /** Fraction of proliferative cells that become apoptotic. */ + private final double proliferativeFraction; + + /** Cell surface antigen count */ + protected int carAntigens; + + /** Cell surface PDL1 count */ + protected final int selfTargets; + + /** lack of documentation so these parameters are TBD */ + protected int selfReceptors; + protected int selfReceptorsStart; + protected int boundAntigensCount; + protected int boundSelfCount; + + /** lack of documentation so these loaded parameters are TBD */ + protected final double searchAbility; + protected final double carAffinity; + protected final double carAlpha; + protected final double carBeta; + protected final double selfReceptorAffinity; + protected final double selfAlpha; + protected final double selfBeta; + protected final double contactFraction; + protected final int maxAntigenBinding; + protected final int cars; + + + + //lastActiveTicker initiated and set to 0 if cell state switches to cytotoxic or stimulatory -> just have it in subclasses for CD4, CD8 + + /** + * Creates a tissue {@code PatchCellCART} agent. + * *

+ * Loaded parameters include: + *

    + *
  • {@code EXHAUSTED_FRACTION} = fraction of exhausted cells that + * become apoptotic
  • + *
  • {@code SENESCENT_FRACTION} = fraction of senescent cells that + * become apoptotic
  • + *
  • {@code ANERGIC_FRACTION} = fraction of anergic cells that + * become apoptotic
  • + *
  • {@code PROLIFERATIVE_FRACTION} = fraction of proliferative cells that + * become apoptotic
  • + *
  • {@code CAR_ANTIGENS} = Cell surface antigen count
  • + *
  • {@code SELF_TARGETS} = Cell surface PDL1 count
  • + * + *
  • {@code SEARCH_ABILITY} = TBD
  • + *
  • {@code CAR_AFFINITY} = TBD
  • + *
  • {@code CAR_ALPHA} = TBD
  • + *
  • {@code CAR_BETA} = TBD
  • + *
  • {@code SELF_RECEPTOR_AFFINITY} = TBD
  • + *
  • {@code SELF_ALPHA} = TBD
  • + *
  • {@code SELF_BETA} = TBD
  • + *
  • {@code CONTACT_FRACTION} = TBD
  • + *
  • {@code MAX_ANTIGEN_BINDING} = TBD
  • + *
  • {@code CARS} = TBD
  • + *
  • {@code SELF_RECEPTORS} = TBD
  • + *
  • {@code SELF_RECEPTORS_START} = TBD
  • + *
+ * < THERE IS A LACK OF DOCUMENTATION FOR THE REST OF THE LOADED PARAMS SO THEY ARE TBD> + * + * @param id the cell ID + * @param parent the parent ID + * @param pop the cell population index + * @param state the cell state + * @param age the cell age + * @param divisions the number of cell divisions + * @param location the {@link Location} of the cell + * @param parameters the dictionary of parameters + * @param volume the cell volume + * @param height the cell height + * @param criticalVolume the critical cell volume + * @param criticalHeight the critical cell height + */ + public PatchCellCART(int id, int parent, int pop, CellState state, int age, int divisions, + Location location, MiniBox parameters, double volume, double height, + double criticalVolume, double criticalHeight) { + super(id, parent, pop, state, age, divisions, location, parameters, + volume, height, criticalVolume, criticalHeight); + + //initialized non-loaded parameters + boundAntigensCount = 0; + boundSelfCount = 0; + + // Set loaded parameters. + exhaustedFraction = parameters.getDouble( "EXHAUSTED_FRACTION"); + senescentFraction = parameters.getDouble("SENESCENT_FRACTION"); + anergicFraction = parameters.getDouble("ANERGIC_FRACTION"); + proliferativeFraction = parameters.getDouble("PROLIFERATIVE_FRACTION"); + carAntigens = parameters.getInt("CAR_ANTIGENS"); + selfTargets = parameters.getInt("SELF_TARGETS"); + selfReceptors = parameters.getInt("SELF_RECEPTORS"); + selfReceptorsStart = parameters.getInt("SELF_RECEPTORS_START"); + searchAbility = parameters.getDouble("SEARCH_ABILITY"); + carAffinity = parameters.getDouble("CAR_AFFINITY"); + carAlpha = parameters.getDouble("CAR_ALPHA"); + carBeta = parameters.getDouble("CAR_BETA"); + selfReceptorAffinity = parameters.getDouble("SELF_RECEPTOR_AFFINITY"); + selfAlpha = parameters.getDouble("SELF_ALPHA"); + selfBeta = parameters.getDouble("SELF_BETA"); + contactFraction = parameters.getDouble("CONTACT_FRACTION"); + maxAntigenBinding = parameters.getInt("MAX_ANTIGEN_BINDING"); + cars = parameters.getInt("CARS"); + } + + @Override + public PatchCell make(int newID, CellState newState, Location newLocation, + MersenneTwisterFast random) { + divisions--; + return new PatchCellCART(newID, id, pop, newState, age, divisions, newLocation, + parameters, volume, height, criticalVolume, criticalHeight); + } + + /* need to implement bindTarget equivalent here*/ + + @Override + public void step(SimState simstate) { + Simulation sim = (Simulation) simstate; + + // Increase age of cell. + super.age++; + + // TODO: check for death due to age + + // Step metabolism process. + super.processes.get(Domain.METABOLISM).step(simstate.random, sim); + + // Check energy status. If cell has less energy than threshold, it will + // apoptose. If overall energy is negative, then cell enters quiescence. + if (state != State.APOPTOTIC && energy < 0) { + if (super.energy < super.energyThreshold) { + super.setState(State.APOPTOTIC); + } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED && state != State.STARVED && state != State.PROLIFERATIVE) { + super.setState(State.STARVED); + } + } else { + //or whatever the neutral state is lol + super.setState(State.UNDEFINED); + } + + // Step inflammation process. + //super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); + + //every state with fraction will need to check against distribution in proceeding inflammation steps + + // Change state from undefined. + if (super.state == State.UNDEFINED) { + if (super.flag == Flag.MIGRATORY) { + super.setState(State.MIGRATORY); + } else if (super.divisions == 0) { + if (simstate.random.nextDouble() > senescentFraction) { + super.setState(State.APOPTOTIC); + } else { + super.setState(State.SENESCENT); + } + } else { + super.setState(State.PROLIFERATIVE); + } + } + + // Step the module for the cell state. + if (super.module != null) { + super.module.step(simstate.random, sim); + } + } + +} diff --git a/src/arcade/patch/agent/cell/PatchCellCancer.java b/src/arcade/patch/agent/cell/PatchCellCancer.java index 22d872d1f..f257c350c 100644 --- a/src/arcade/patch/agent/cell/PatchCellCancer.java +++ b/src/arcade/patch/agent/cell/PatchCellCancer.java @@ -6,6 +6,8 @@ import arcade.core.env.location.Location; import arcade.core.sim.Simulation; import arcade.core.util.MiniBox; +import arcade.patch.util.PatchEnums.State; + import static arcade.patch.util.PatchEnums.State; /** @@ -22,6 +24,12 @@ public class PatchCellCancer extends PatchCellTissue { /** * Creates a tissue {@code PatchCell} agent. * + *

+ * Loaded parameters include: + *

    + *
  • {@code CAR_ANTIGENS_CANCER} = Cancer cell specific surface antigen count
  • + *
+ * * @param id the cell ID * @param parent the parent ID * @param pop the cell population index @@ -40,6 +48,10 @@ public PatchCellCancer(int id, int parent, int pop, CellState state, int age, in double criticalVolume, double criticalHeight) { super(id, parent, pop, state, age, divisions, location, parameters, volume, height, criticalVolume, criticalHeight); + + // Set loaded parameters. + //cancer cells can have tumor specific antigens that are not present on healthy tissue cells + super.carAntigens = parameters.getInt("CAR_ANTIGENS_CANCER"); } /** diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index 7af1431c3..d4505f5b7 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -25,6 +25,12 @@ public class PatchCellTissue extends PatchCell { /** Fraction of senescent cells that become apoptotic. */ private final double senescentFraction; + /** Cell surface antigen count */ + protected int carAntigens; + + /** Cell surface PDL1 count */ + protected final int selfTargets; + /** * Creates a tissue {@code PatchCell} agent. @@ -35,6 +41,8 @@ public class PatchCellTissue extends PatchCell { * become apoptotic *
  • {@code SENESCENT_FRACTION} = fraction of senescent cells that * become apoptotic
  • + *
  • {@code CAR_ANTIGENS} = Cell surface antigen count
  • + *
  • {@code SELF_TARGETS} = Cell surface PDL1 count
  • * * * @param id the cell ID @@ -59,6 +67,8 @@ public PatchCellTissue(int id, int parent, int pop, CellState state, int age, in // Set loaded parameters. necroticFraction = parameters.getDouble("NECROTIC_FRACTION"); senescentFraction = parameters.getDouble("SENESCENT_FRACTION"); + carAntigens = parameters.getInt("CAR_ANTIGENS"); + selfTargets = parameters.getInt("SELF_TARGETS"); } @Override From bbe57e049e4ddfb303062d496c71404d4eae62da Mon Sep 17 00:00:00 2001 From: Allison Li Date: Wed, 25 Oct 2023 10:48:10 -0700 Subject: [PATCH 005/185] making patchCARTCell an abstract class --- .../patch/agent/cell/PatchCellCART.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index fc6634d50..ead235800 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -52,7 +52,7 @@ * ({@code HETEROGENEITY}). */ -public class PatchCellCART extends PatchCell { +public abstract class PatchCellCART extends PatchCell { /** Fraction of exhausted cells that become apoptotic. */ private final double exhaustedFraction; @@ -89,10 +89,7 @@ public class PatchCellCART extends PatchCell { protected final double contactFraction; protected final int maxAntigenBinding; protected final int cars; - - - - //lastActiveTicker initiated and set to 0 if cell state switches to cytotoxic or stimulatory -> just have it in subclasses for CD4, CD8 + protected int lastActiveTicker; /** * Creates a tissue {@code PatchCellCART} agent. @@ -147,6 +144,7 @@ public PatchCellCART(int id, int parent, int pop, CellState state, int age, int //initialized non-loaded parameters boundAntigensCount = 0; boundSelfCount = 0; + lastActiveTicker = 0; // Set loaded parameters. exhaustedFraction = parameters.getDouble( "EXHAUSTED_FRACTION"); @@ -169,16 +167,11 @@ public PatchCellCART(int id, int parent, int pop, CellState state, int age, int cars = parameters.getInt("CARS"); } - @Override - public PatchCell make(int newID, CellState newState, Location newLocation, - MersenneTwisterFast random) { - divisions--; - return new PatchCellCART(newID, id, pop, newState, age, divisions, newLocation, - parameters, volume, height, criticalVolume, criticalHeight); - } - /* need to implement bindTarget equivalent here*/ + //this potentially needs to move to CD4, CD8 + //all car t cells have either CD4 or CD8 receptors + @Override public void step(SimState simstate) { Simulation sim = (Simulation) simstate; @@ -200,7 +193,6 @@ public void step(SimState simstate) { super.setState(State.STARVED); } } else { - //or whatever the neutral state is lol super.setState(State.UNDEFINED); } From 773175b2e6f7ce0cdba378adcf153218f27b5595 Mon Sep 17 00:00:00 2001 From: Allison Li Date: Wed, 25 Oct 2023 19:32:08 -0700 Subject: [PATCH 006/185] implementing CART class, CARTCD4 class, added antigen binding to enums and enum tests --- .../patch/agent/cell/PatchCellCART.java | 106 ++++++------ .../patch/agent/cell/PatchCellCARTCD4.java | 162 ++++++++++++++++++ .../patch/agent/cell/PatchCellTissue.java | 6 +- src/arcade/patch/util/PatchEnums.java | 28 +++ test/arcade/patch/util/PatchEnumsTest.java | 22 +++ 5 files changed, 264 insertions(+), 60 deletions(-) create mode 100644 src/arcade/patch/agent/cell/PatchCellCARTCD4.java diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index ead235800..91b83b57a 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -1,9 +1,13 @@ package arcade.patch.agent.cell; +import sim.util.Bag; import ec.util.MersenneTwisterFast; +import javafx.stage.PopupWindow.AnchorLocation; +import arcade.core.agent.cell.Cell; import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.util.MiniBox; +import arcade.patch.util.PatchEnums.AntigenFlag; import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.Flag; import arcade.patch.util.PatchEnums.State; @@ -12,6 +16,7 @@ import static arcade.patch.util.PatchEnums.Domain; import static arcade.patch.util.PatchEnums.Flag; import static arcade.patch.util.PatchEnums.State; +import static arcade.patch.util.PatchEnums.AntigenFlag; /** * Implementation of {@link Cell} for generic CART cell. @@ -55,16 +60,16 @@ public abstract class PatchCellCART extends PatchCell { /** Fraction of exhausted cells that become apoptotic. */ - private final double exhaustedFraction; + protected final double exhaustedFraction; /** Fraction of senescent cells that become apoptotic. */ - private final double senescentFraction; + protected final double senescentFraction; /** Fraction of anergic cells that become apoptotic. */ - private final double anergicFraction; + protected final double anergicFraction; /** Fraction of proliferative cells that become apoptotic. */ - private final double proliferativeFraction; + protected final double proliferativeFraction; /** Cell surface antigen count */ protected int carAntigens; @@ -72,6 +77,12 @@ public abstract class PatchCellCART extends PatchCell { /** Cell surface PDL1 count */ protected final int selfTargets; + /** Cell binding flag */ + protected AntigenFlag binding; + + /** Cell activation flag */ + protected boolean activated; + /** lack of documentation so these parameters are TBD */ protected int selfReceptors; protected int selfReceptorsStart; @@ -145,6 +156,8 @@ public PatchCellCART(int id, int parent, int pop, CellState state, int age, int boundAntigensCount = 0; boundSelfCount = 0; lastActiveTicker = 0; + binding = AntigenFlag.UNDEFINED; + activated = true; // Set loaded parameters. exhaustedFraction = parameters.getDouble( "EXHAUSTED_FRACTION"); @@ -168,58 +181,41 @@ public PatchCellCART(int id, int parent, int pop, CellState state, int age, int } /* need to implement bindTarget equivalent here*/ + /** + * Determines if CAR T cell agent is bound to neighbor through receptor-target binding. + *

    + * Searches the number of allowed neighbors in series, calculates bound probability to antigen + * and self receptors, compares values to random variable. Sets flags accordingly + * and returns a target cell if one was bound by antigen or self receptor. + * + * @param state the MASON simulation state + * @param loc the location of the CAR T-cell + * @return target cell if bound one, null otherwise + */ + + public void bindTarget(Simulation sim, Location loc) { + double KDCAR = carAffinity * (loc.getVolume() * 1e-15 * 6.022E23); + double KDSelf = selfReceptorAffinity * (loc.getVolume() * 1e-15 * 6.022E23); - //this potentially needs to move to CD4, CD8 - //all car t cells have either CD4 or CD8 receptors - - @Override - public void step(SimState simstate) { - Simulation sim = (Simulation) simstate; - - // Increase age of cell. - super.age++; - - // TODO: check for death due to age - - // Step metabolism process. - super.processes.get(Domain.METABOLISM).step(simstate.random, sim); - - // Check energy status. If cell has less energy than threshold, it will - // apoptose. If overall energy is negative, then cell enters quiescence. - if (state != State.APOPTOTIC && energy < 0) { - if (super.energy < super.energyThreshold) { - super.setState(State.APOPTOTIC); - } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED && state != State.STARVED && state != State.PROLIFERATIVE) { - super.setState(State.STARVED); - } - } else { - super.setState(State.UNDEFINED); - } - - // Step inflammation process. - //super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); - - //every state with fraction will need to check against distribution in proceeding inflammation steps - - // Change state from undefined. - if (super.state == State.UNDEFINED) { - if (super.flag == Flag.MIGRATORY) { - super.setState(State.MIGRATORY); - } else if (super.divisions == 0) { - if (simstate.random.nextDouble() > senescentFraction) { - super.setState(State.APOPTOTIC); - } else { - super.setState(State.SENESCENT); - } - } else { - super.setState(State.PROLIFERATIVE); - } - } - - // Step the module for the cell state. - if (super.module != null) { - super.module.step(simstate.random, sim); - } + // Create a bag with all agents in neighboring and current locations inside. + // Remove self from bag. + + //get all agents from this location + //Bag allAgents = new Bag(sim.getGrid().getObjectsAtLocation(loc)); + + //get all agents from neighboring locations + /* for (Location neighborLocation : loc.getNeighbors()) { + Bag bag = new Bag(grid.getObjectsAtLocation(neighborLocation)) + allAgents = allAgents.union(bag); + } */ } + //this method may be unnecessary... + /** + * Sets the cell binding flag. + * + * @param antigenFlag the target cell antigen binding state + */ + public void setAntigenFlag(AntigenFlag flag) { this.binding = flag; } + } diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java new file mode 100644 index 000000000..3fffb5175 --- /dev/null +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -0,0 +1,162 @@ +package arcade.patch.agent.cell; + +import arcade.core.agent.cell.CellState; +import arcade.core.env.location.Location; +import arcade.core.sim.Simulation; +import arcade.core.util.MiniBox; +import arcade.patch.util.PatchEnums.AntigenFlag; +import arcade.patch.util.PatchEnums.Domain; +import arcade.patch.util.PatchEnums.Flag; +import arcade.patch.util.PatchEnums.State; +import ec.util.MersenneTwisterFast; +import sim.engine.SimState; + +public class PatchCellCARTCD4 extends PatchCellCART{ + + /** Fraction of stimulatory cells that become apoptotic. */ + private final double stimulatoryFraction; + + /** + * Creates a tissue {@code PatchCellCARTCD4} agent. + * *

    + * Loaded parameters include: + *

      + *
    • {@code STIMULATORY_FRACTION} = fraction of stimulatory cells that + * become apoptotic
    • + *
    + * + * @param id the cell ID + * @param parent the parent ID + * @param pop the cell population index + * @param state the cell state + * @param age the cell age + * @param divisions the number of cell divisions + * @param location the {@link Location} of the cell + * @param parameters the dictionary of parameters + * @param volume the cell volume + * @param height the cell height + * @param criticalVolume the critical cell volume + * @param criticalHeight the critical cell height + */ + + public PatchCellCARTCD4(int id, int parent, int pop, CellState state, int age, int divisions, + Location location, MiniBox parameters, double volume, double height, + double criticalVolume, double criticalHeight) { + + super(id, parent, pop, state, age, divisions, location, parameters, + volume, height, criticalVolume, criticalHeight); + + // Set loaded parameters. + stimulatoryFraction = parameters.getDouble( "STIMULATORY_FRACTION"); + } + + + @Override + public PatchCellCARTCD4 make(int newID, CellState newState, Location newLocation, + MersenneTwisterFast random) { + + divisions--; + return new PatchCellCARTCD4(newID, id, pop, newState, age, divisions, newLocation, + parameters, volume, height, criticalVolume, criticalHeight); + } + + @Override + public void step(SimState simstate) { + Simulation sim = (Simulation) simstate; + + // Increase age of cell. + super.age++; + + // TODO: check for death due to age + + + // Increase time since last active ticker + super.lastActiveTicker++; + if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { + if (super.boundAntigensCount != 0) super.boundAntigensCount--; + } + if (super.lastActiveTicker/1440 >- 7) super.activated = false; + + // Step metabolism process. + super.processes.get(Domain.METABOLISM).step(simstate.random, sim); + + // Check energy status. If cell has less energy than threshold, it will + // apoptose. If overall energy is negative, then cell enters quiescence. + if (state != State.APOPTOTIC && energy < 0) { + if (super.energy < super.energyThreshold) { + super.setState(State.APOPTOTIC); + } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED && state != State.STARVED && state != State.PROLIFERATIVE) { + super.setState(State.STARVED); + } + } else { + super.setState(State.UNDEFINED); + } + + // Step inflammation process. + + //super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); + + // Change state from undefined. + if (super.state == State.UNDEFINED || super.state == State.PAUSED) { + if (divisions == 0) { + if (simstate.random.nextDouble() > super.senescentFraction) { + super.setState(State.APOPTOTIC); + } else { + super.setState(State.SENESCENT); + } + } + } else { + + // bindTarget(super.state, location) + + //If cell is bound to both antigen and self it will become anergic. + if (binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { + if (simstate.random.nextDouble() > super.anergicFraction) { + super.setState(State.APOPTOTIC); + } else { + super.setState(State.ANERGIC); + } + } else if (binding == AntigenFlag.BOUND_ANTIGEN) { + // If cell is only bound to target antigen, the cell + // can potentially become properly activated. + + // Check overstimulation. If cell has bound to + // target antigens too many times, becomes exhausted. + if (boundAntigensCount > maxAntigenBinding) { + if (simstate.random.nextDouble() > super.exhaustedFraction) { + super.setState(State.APOPTOTIC); + } else { + super.setState(State.EXHAUSTED); + } + } else { + //if CD4 cell is properly activated, it can stimulate + if (simstate.random.nextDouble() > stimulatoryFraction) { + super.setState(State.APOPTOTIC); + } else { + super.setState(State.STIMULATORY); + } + } + } else if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) { + //If self binding, unbind + super.setAntigenFlag(AntigenFlag.UNBINDED); + } else { + // Check activation status. If cell has been activated before, + // it will proliferate. If not, it will migrate. + if (activated) { + super.setState(State.PROLIFERATIVE); + } else { + if (simstate.random.nextDouble() > super.proliferativeFraction) { + super.setState(State.MIGRATORY); + } else { + super.setState(State.PROLIFERATIVE); + } + } + } + } + + // Step the module for the cell state. + if (super.module != null) { + super.module.step(simstate.random, sim); + } + } +} diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index d4505f5b7..4764a6e5e 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -4,9 +4,6 @@ import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.util.MiniBox; -import arcade.patch.util.PatchEnums.Domain; -import arcade.patch.util.PatchEnums.Flag; -import arcade.patch.util.PatchEnums.State; import sim.engine.SimState; import arcade.core.sim.Simulation; import static arcade.patch.util.PatchEnums.Domain; @@ -80,8 +77,7 @@ public PatchCell make(int newID, CellState newState, Location newLocation, } /* consider making PatchCell parameters protected instead of private */ - /* make step() method that overrides main that is moved over from PatchCell */ - + @Override public void step(SimState simstate) { Simulation sim = (Simulation) simstate; diff --git a/src/arcade/patch/util/PatchEnums.java b/src/arcade/patch/util/PatchEnums.java index 5249f5def..d6ed64064 100644 --- a/src/arcade/patch/util/PatchEnums.java +++ b/src/arcade/patch/util/PatchEnums.java @@ -169,6 +169,34 @@ public static Flag random(MersenneTwisterFast rng) { return values()[rng.nextInt(values().length - 1) + 1]; } } + + /** Antigen binding for CART simulations. */ + public enum AntigenFlag { + /** Code for undefined flag. */ + UNDEFINED, + + /** Code for cell bound to antigen. */ + BOUND_ANTIGEN, + + /** Code for cell bound to self. */ + BOUND_CELL_RECEPTOR, + + /** Code for cell bound to self and antigen. */ + BOUND_ANTIGEN_CELL_RECEPTOR, + + /** Code for cell bound to nothing. */ + UNBINDED; + + /** + * Randomly selects a {@code AntigenFlag}. + * + * @param rng the random number generator + * @return a random {@code AntigenFlag} + */ + public static AntigenFlag random(MersenneTwisterFast rng) { + return values()[rng.nextInt(values().length - 1) + 1]; + } + } /** Operation category codes for patch simulations. */ public enum Category implements OperationCategory { diff --git a/test/arcade/patch/util/PatchEnumsTest.java b/test/arcade/patch/util/PatchEnumsTest.java index 22286eaf7..3aea266e7 100644 --- a/test/arcade/patch/util/PatchEnumsTest.java +++ b/test/arcade/patch/util/PatchEnumsTest.java @@ -18,6 +18,7 @@ import static arcade.patch.util.PatchEnums.Ordering; import static arcade.patch.util.PatchEnums.State; import static arcade.patch.util.PatchEnums.Category; +import static arcade.patch.util.PatchEnums.AntigenFlag; public class PatchEnumsTest { @Test(expected = UnsupportedOperationException.class) @@ -109,6 +110,27 @@ public void Category_random_returnsCategory() { assertEquals(enumSet, enumSetRandom); } + @Test + public void AntigenFlag_random_returnsAntigenFlag() { + // Create set of all values. + EnumSet enumSet = EnumSet.allOf(AntigenFlag.class); + enumSet.remove(AntigenFlag.UNDEFINED); + + // Create set of all random values. + ArrayList enumRandom = new ArrayList<>(); + + int n = AntigenFlag.values().length - 1; + for (int i = 0; i < n; i++) { + MersenneTwisterFast rng = mock(MersenneTwisterFast.class); + doReturn(i).when(rng).nextInt(n); + enumRandom.add(AntigenFlag.random(rng)); + } + + // Compare resulting sets. + EnumSet enumSetRandom = EnumSet.copyOf(enumRandom); + assertEquals(enumSet, enumSetRandom); + } + @Test public void Ordering_in_expected_order() { // Create list of all values. From b588f7856f9f3b4f70fced41258b8d619cf1e548 Mon Sep 17 00:00:00 2001 From: Allison Li Date: Thu, 26 Oct 2023 20:46:13 -0700 Subject: [PATCH 007/185] implemented bindTarget function --- .../patch/agent/cell/PatchCellCART.java | 94 +++++++++++++++---- .../patch/agent/cell/PatchCellCARTCD4.java | 5 +- .../patch/agent/cell/PatchCellTissue.java | 8 +- test/arcade/patch/util/PatchEnumsTest.java | 5 - 4 files changed, 83 insertions(+), 29 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 91b83b57a..bd143116e 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -7,15 +7,11 @@ import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.util.MiniBox; -import arcade.patch.util.PatchEnums.AntigenFlag; -import arcade.patch.util.PatchEnums.Domain; -import arcade.patch.util.PatchEnums.Flag; -import arcade.patch.util.PatchEnums.State; -import sim.engine.SimState; +import arcade.patch.env.grid.PatchGrid; +import arcade.patch.env.location.PatchLocation; import arcade.core.sim.Simulation; -import static arcade.patch.util.PatchEnums.Domain; -import static arcade.patch.util.PatchEnums.Flag; import static arcade.patch.util.PatchEnums.State; + import static arcade.patch.util.PatchEnums.AntigenFlag; /** @@ -190,27 +186,89 @@ public PatchCellCART(int id, int parent, int pop, CellState state, int age, int * * @param state the MASON simulation state * @param loc the location of the CAR T-cell - * @return target cell if bound one, null otherwise + * @param random random seed */ - public void bindTarget(Simulation sim, Location loc) { + public void bindTarget(Simulation sim, PatchLocation loc, MersenneTwisterFast random) { double KDCAR = carAffinity * (loc.getVolume() * 1e-15 * 6.022E23); double KDSelf = selfReceptorAffinity * (loc.getVolume() * 1e-15 * 6.022E23); - - // Create a bag with all agents in neighboring and current locations inside. - // Remove self from bag. + PatchGrid grid = (PatchGrid) sim.getGrid(); //get all agents from this location - //Bag allAgents = new Bag(sim.getGrid().getObjectsAtLocation(loc)); + Bag allAgents = new Bag(grid.getObjectsAtLocation(loc)); //get all agents from neighboring locations - /* for (Location neighborLocation : loc.getNeighbors()) { - Bag bag = new Bag(grid.getObjectsAtLocation(neighborLocation)) - allAgents = allAgents.union(bag); - } */ + for (Location neighborLocation : loc.getNeighbors()) { + Bag bag = new Bag(grid.getObjectsAtLocation(neighborLocation)); + for (Object b : bag) { + //add all agents from neighboring locations + if (!allAgents.contains(b)) allAgents.add(b); + } + } + + //remove self + allAgents.remove(this); + + //shuffle bag + allAgents.shuffle(random); + + //get number of neighbors + int neighbors = allAgents.size(); + + // Bind target with some probability if a nearby cell has targets to bind. + int maxSearch = 0; + if (neighbors == 0) { + binding = AntigenFlag.UNBINDED; + } else { + if (neighbors < searchAbility) { + maxSearch = neighbors; + } else { + maxSearch = (int) searchAbility; + } + } + + // Within maximum search vicinity, search for neighboring cells to bind to + for (int i = 0; i < maxSearch; i++) { + Cell cell = (Cell) allAgents.get(i); + if (!(cell instanceof PatchCellCART) && cell.getState() != State.APOPTOTIC && cell.getState() != State.NECROTIC) { + PatchCellTissue tissueCell = (PatchCellTissue) cell; + double CARAntigens = tissueCell.carAntigens; + double selfTargets = tissueCell.selfTargets; + + double hillCAR = (CARAntigens*contactFraction/ (KDCAR*carBeta + CARAntigens*contactFraction))*(cars/50000)*carAlpha; + double hillSelf = (selfTargets*contactFraction / (KDSelf*selfBeta + selfTargets*contactFraction))*(selfReceptors/selfReceptorsStart)*selfAlpha; + + double logCAR = 2*(1/(1 + Math.exp(-1*hillCAR))) - 1; + double logSelf = 2*(1/(1 + Math.exp(-1*hillSelf))) - 1; + + double randomAntigen = random.nextDouble(); + double randomSelf = random.nextDouble(); + + if (logCAR >= randomAntigen && logSelf < randomSelf ) { + // cell binds to antigen receptor + binding = AntigenFlag.BOUND_ANTIGEN; + boundAntigensCount++; + selfReceptors += (int)((double)selfReceptorsStart * (0.95 + random.nextDouble()/10)); + } else if ( logCAR >= randomAntigen && logSelf >= randomSelf ) { + // cell binds to antigen receptor and self + binding = AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR; + boundAntigensCount++; + boundSelfCount++; + selfReceptors += (int)((double)selfReceptorsStart * (0.95 + random.nextDouble()/10)); + } else if ( logCAR < randomAntigen && logSelf >= randomSelf ) { + // cell binds to self + binding = AntigenFlag.BOUND_CELL_RECEPTOR; + boundSelfCount++; + } else { + // cell doesn't bind to anything + binding = AntigenFlag.UNBINDED; + } + } + } } - //this method may be unnecessary... + //this method may be unnecessary if only subclasses can set antigen flag + /** * Sets the cell binding flag. * diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 3fffb5175..27bcd368f 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -93,7 +93,6 @@ public void step(SimState simstate) { } // Step inflammation process. - //super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); // Change state from undefined. @@ -106,8 +105,8 @@ public void step(SimState simstate) { } } } else { - - // bindTarget(super.state, location) + // Cell attempts to bind to a target + super.bindTarget(sim, location, new MersenneTwisterFast(simstate.seed())); //If cell is bound to both antigen and self it will become anergic. if (binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index 4764a6e5e..26aaa6145 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -22,11 +22,13 @@ public class PatchCellTissue extends PatchCell { /** Fraction of senescent cells that become apoptotic. */ private final double senescentFraction; + //these two variables are public bc I don't want to implement setter/getter methods for sims that do not use CART cells. + /** Cell surface antigen count */ - protected int carAntigens; + int carAntigens; /** Cell surface PDL1 count */ - protected final int selfTargets; + int selfTargets; /** @@ -77,7 +79,7 @@ public PatchCell make(int newID, CellState newState, Location newLocation, } /* consider making PatchCell parameters protected instead of private */ - + @Override public void step(SimState simstate) { Simulation sim = (Simulation) simstate; diff --git a/test/arcade/patch/util/PatchEnumsTest.java b/test/arcade/patch/util/PatchEnumsTest.java index 3aea266e7..118d2b0e9 100644 --- a/test/arcade/patch/util/PatchEnumsTest.java +++ b/test/arcade/patch/util/PatchEnumsTest.java @@ -5,11 +5,6 @@ import java.util.EnumSet; import org.junit.Test; -import arcade.patch.util.PatchEnums.Category; -import arcade.patch.util.PatchEnums.Domain; -import arcade.patch.util.PatchEnums.Flag; -import arcade.patch.util.PatchEnums.Ordering; -import arcade.patch.util.PatchEnums.State; import ec.util.MersenneTwisterFast; import static org.junit.Assert.*; import static org.mockito.Mockito.*; From 6d1dd0a7e2b0be406fa03182aafaf68b4e2cf537 Mon Sep 17 00:00:00 2001 From: Allison Li Date: Fri, 27 Oct 2023 12:20:11 -0700 Subject: [PATCH 008/185] adding PatchCellCARTCD8 subclass --- .../patch/agent/cell/PatchCellCARTCD4.java | 1 - .../patch/agent/cell/PatchCellCARTCD8.java | 161 ++++++++++++++++++ 2 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 src/arcade/patch/agent/cell/PatchCellCARTCD8.java diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 27bcd368f..309ce3ebf 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -6,7 +6,6 @@ import arcade.core.util.MiniBox; import arcade.patch.util.PatchEnums.AntigenFlag; import arcade.patch.util.PatchEnums.Domain; -import arcade.patch.util.PatchEnums.Flag; import arcade.patch.util.PatchEnums.State; import ec.util.MersenneTwisterFast; import sim.engine.SimState; diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java new file mode 100644 index 000000000..43d85f83e --- /dev/null +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -0,0 +1,161 @@ +package arcade.patch.agent.cell; + +import arcade.core.agent.cell.CellState; +import arcade.core.env.location.Location; +import arcade.core.sim.Simulation; +import arcade.core.util.MiniBox; +import arcade.patch.util.PatchEnums.AntigenFlag; +import arcade.patch.util.PatchEnums.Domain; +import arcade.patch.util.PatchEnums.State; +import ec.util.MersenneTwisterFast; +import sim.engine.SimState; + +public class PatchCellCARTCD8 extends PatchCellCART { + + /** Fraction of cytotoxic cells that become apoptotic. */ + private final double cytotoxicFraction; + + /** + * Creates a tissue {@code PatchCellCARTCD8} agent. + * *

    + * Loaded parameters include: + *

      + *
    • {@code CYTOTOXIC_FRACTION} = fraction of cytotoxic cells that + * become apoptotic
    • + *
    + * + * @param id the cell ID + * @param parent the parent ID + * @param pop the cell population index + * @param state the cell state + * @param age the cell age + * @param divisions the number of cell divisions + * @param location the {@link Location} of the cell + * @param parameters the dictionary of parameters + * @param volume the cell volume + * @param height the cell height + * @param criticalVolume the critical cell volume + * @param criticalHeight the critical cell height + */ + + public PatchCellCARTCD8(int id, int parent, int pop, CellState state, int age, int divisions, + Location location, MiniBox parameters, double volume, double height, + double criticalVolume, double criticalHeight) { + + super(id, parent, pop, state, age, divisions, location, parameters, + volume, height, criticalVolume, criticalHeight); + + // Set loaded parameters. + cytotoxicFraction = parameters.getDouble( "CYTOTOXIC_FRACTION"); + + + } + + @Override + public PatchCellCARTCD8 make(int newID, CellState newState, Location newLocation, + MersenneTwisterFast random) { + + divisions--; + return new PatchCellCARTCD8(newID, id, pop, newState, age, divisions, newLocation, + parameters, volume, height, criticalVolume, criticalHeight); + } + + @Override + public void step(SimState simstate) { + Simulation sim = (Simulation) simstate; + + // Increase age of cell. + super.age++; + + // TODO: check for death due to age + + + // Increase time since last active ticker + super.lastActiveTicker++; + if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { + if (super.boundAntigensCount != 0) super.boundAntigensCount--; + } + if (super.lastActiveTicker/1440 >- 7) super.activated = false; + + // Step metabolism process. + super.processes.get(Domain.METABOLISM).step(simstate.random, sim); + + // Check energy status. If cell has less energy than threshold, it will + // apoptose. If overall energy is negative, then cell enters quiescence. + if (state != State.APOPTOTIC && energy < 0) { + if (super.energy < super.energyThreshold) { + super.setState(State.APOPTOTIC); + } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED && state != State.STARVED && state != State.PROLIFERATIVE) { + super.setState(State.STARVED); + } + } else { + super.setState(State.UNDEFINED); + } + + // Step inflammation process. + //super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); + + // Change state from undefined. + if (super.state == State.UNDEFINED || super.state == State.PAUSED) { + if (divisions == 0) { + if (simstate.random.nextDouble() > super.senescentFraction) { + super.setState(State.APOPTOTIC); + } else { + super.setState(State.SENESCENT); + } + } + } else { + // Cell attempts to bind to a target + super.bindTarget(sim, location, new MersenneTwisterFast(simstate.seed())); + + //If cell is bound to both antigen and self it will become anergic. + if (binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { + if (simstate.random.nextDouble() > super.anergicFraction) { + super.setState(State.APOPTOTIC); + } else { + super.setState(State.ANERGIC); + } + } else if (binding == AntigenFlag.BOUND_ANTIGEN) { + // If cell is only bound to target antigen, the cell + // can potentially become properly activated. + + // Check overstimulation. If cell has bound to + // target antigens too many times, becomes exhausted. + if (boundAntigensCount > maxAntigenBinding) { + if (simstate.random.nextDouble() > super.exhaustedFraction) { + super.setState(State.APOPTOTIC); + } else { + super.setState(State.EXHAUSTED); + } + } else { + //if CD4 cell is properly activated, it can stimulate + if (simstate.random.nextDouble() > cytotoxicFraction) { + super.setState(State.APOPTOTIC); + } else { + super.setState(State.CYTOTOXIC); + } + } + } else if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) { + //If self binding, unbind + super.setAntigenFlag(AntigenFlag.UNBINDED); + } else { + // Check activation status. If cell has been activated before, + // it will proliferate. If not, it will migrate. + if (activated) { + super.setState(State.PROLIFERATIVE); + } else { + if (simstate.random.nextDouble() > super.proliferativeFraction) { + super.setState(State.MIGRATORY); + } else { + super.setState(State.PROLIFERATIVE); + } + } + } + } + + // Step the module for the cell state. + if (super.module != null) { + super.module.step(simstate.random, sim); + } + } +} From ba7c3bf4cf5643ac23db3d368594bc1d39adafce Mon Sep 17 00:00:00 2001 From: Allison Li Date: Mon, 30 Oct 2023 10:31:27 -0700 Subject: [PATCH 009/185] adding comments --- src/arcade/patch/agent/cell/PatchCellCART.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index bd143116e..295c73cd1 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -268,6 +268,7 @@ public void bindTarget(Simulation sim, PatchLocation loc, MersenneTwisterFast ra } //this method may be unnecessary if only subclasses can set antigen flag + //can non-T cells set the antigen binding properties of CART cell? /** * Sets the cell binding flag. From bf6e61a2b17ecf16e4a5b25541d70be4d298dff8 Mon Sep 17 00:00:00 2001 From: Allison Li Date: Thu, 2 Nov 2023 10:48:39 -0700 Subject: [PATCH 010/185] added some comments --- src/arcade/patch/agent/cell/PatchCellCART.java | 2 ++ src/arcade/patch/agent/cell/PatchCellTissue.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 295c73cd1..7fe14275a 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -206,6 +206,8 @@ public void bindTarget(Simulation sim, PatchLocation loc, MersenneTwisterFast ra } } + + //remove self allAgents.remove(this); diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index 26aaa6145..77c8e509e 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -66,6 +66,10 @@ public PatchCellTissue(int id, int parent, int pop, CellState state, int age, in // Set loaded parameters. necroticFraction = parameters.getDouble("NECROTIC_FRACTION"); senescentFraction = parameters.getDouble("SENESCENT_FRACTION"); + + //In component, check if TCells present + //check if these values null + //double check if getInt fails at runtime for null values carAntigens = parameters.getInt("CAR_ANTIGENS"); selfTargets = parameters.getInt("SELF_TARGETS"); } From 6724768d0ba8535ca6558dacce1175f4747b4709 Mon Sep 17 00:00:00 2001 From: Allison Li Date: Fri, 3 Nov 2023 12:26:41 -0700 Subject: [PATCH 011/185] adding new tests --- src/arcade/patch/agent/cell/PatchCell.java | 4 +++- src/arcade/patch/agent/cell/PatchCellCART.java | 4 ++-- src/arcade/patch/agent/cell/PatchCellCARTCD4.java | 2 +- src/arcade/patch/agent/cell/PatchCellCARTCD8.java | 2 +- src/arcade/patch/agent/cell/PatchCellTissue.java | 4 +--- src/arcade/patch/util/PatchEnums.java | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 91e6e924f..42423a7c9 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -175,12 +175,14 @@ public PatchCell(int id, int parent, int pop, CellState state, int age, int divi // Add cell processes. processes = new HashMap<>(); MiniBox processBox = parameters.filter("(PROCESS)"); - for (String processKey : processBox.getKeys()) { + if (processBox != null) { + for (String processKey : processBox.getKeys()) { ProcessDomain domain = Domain.valueOf(processKey); String version = processBox.get(processKey); Process process = makeProcess(domain, version); processes.put(domain, process); } + } } @Override diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 7fe14275a..f4c638e09 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -220,7 +220,7 @@ public void bindTarget(Simulation sim, PatchLocation loc, MersenneTwisterFast ra // Bind target with some probability if a nearby cell has targets to bind. int maxSearch = 0; if (neighbors == 0) { - binding = AntigenFlag.UNBINDED; + binding = AntigenFlag.UNBOUND; } else { if (neighbors < searchAbility) { maxSearch = neighbors; @@ -263,7 +263,7 @@ public void bindTarget(Simulation sim, PatchLocation loc, MersenneTwisterFast ra boundSelfCount++; } else { // cell doesn't bind to anything - binding = AntigenFlag.UNBINDED; + binding = AntigenFlag.UNBOUND; } } } diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 309ce3ebf..54f6be88c 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -136,7 +136,7 @@ public void step(SimState simstate) { } } else if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) { //If self binding, unbind - super.setAntigenFlag(AntigenFlag.UNBINDED); + super.setAntigenFlag(AntigenFlag.UNBOUND); } else { // Check activation status. If cell has been activated before, // it will proliferate. If not, it will migrate. diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index 43d85f83e..1a71c949a 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -137,7 +137,7 @@ public void step(SimState simstate) { } } else if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) { //If self binding, unbind - super.setAntigenFlag(AntigenFlag.UNBINDED); + super.setAntigenFlag(AntigenFlag.UNBOUND); } else { // Check activation status. If cell has been activated before, // it will proliferate. If not, it will migrate. diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index 77c8e509e..a0b30b4e3 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -67,9 +67,7 @@ public PatchCellTissue(int id, int parent, int pop, CellState state, int age, in necroticFraction = parameters.getDouble("NECROTIC_FRACTION"); senescentFraction = parameters.getDouble("SENESCENT_FRACTION"); - //In component, check if TCells present - //check if these values null - //double check if getInt fails at runtime for null values + //These default to 0 if not present in input carAntigens = parameters.getInt("CAR_ANTIGENS"); selfTargets = parameters.getInt("SELF_TARGETS"); } diff --git a/src/arcade/patch/util/PatchEnums.java b/src/arcade/patch/util/PatchEnums.java index d6ed64064..1af4c9037 100644 --- a/src/arcade/patch/util/PatchEnums.java +++ b/src/arcade/patch/util/PatchEnums.java @@ -185,7 +185,7 @@ public enum AntigenFlag { BOUND_ANTIGEN_CELL_RECEPTOR, /** Code for cell bound to nothing. */ - UNBINDED; + UNBOUND; /** * Randomly selects a {@code AntigenFlag}. From 6e7c4916e5a0b7a42e08225cf9ff38be4846dc71 Mon Sep 17 00:00:00 2001 From: Allison Li Date: Fri, 3 Nov 2023 13:37:43 -0700 Subject: [PATCH 012/185] temp add of inflammation module, in help of casting issues --- src/arcade/patch/agent/cell/PatchCellCART.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index f4c638e09..1be78d876 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -278,5 +278,11 @@ public void bindTarget(Simulation sim, PatchLocation loc, MersenneTwisterFast ra * @param antigenFlag the target cell antigen binding state */ public void setAntigenFlag(AntigenFlag flag) { this.binding = flag; } + + + /** + * Returns activation status + */ + public boolean getActivationStatus(){ return this.activated;} } From 6576ea8d21929bbe5642c633a684c9bc01f08f20 Mon Sep 17 00:00:00 2001 From: Allison Li Date: Wed, 17 Jan 2024 20:01:08 -0800 Subject: [PATCH 013/185] added kill process --- .../patch/agent/module/PatchModuleKill.java | 122 ++++++++ .../process/PatchProcessInflammation.java | 273 +++++++++++++++++ .../process/PatchProcessInflammationCD4.java | 100 ++++++ .../process/PatchProcessInflammationCD8.java | 86 ++++++ src/arcade/patch/sim/PatchSimulation.java | 6 + .../patch/agent/cell/PatchCARTCellTest.java | 290 ++++++++++++++++++ .../patch/agent/cell/PatchCellTest.java | 239 +++++++++++++++ 7 files changed, 1116 insertions(+) create mode 100644 src/arcade/patch/agent/module/PatchModuleKill.java create mode 100644 src/arcade/patch/agent/process/PatchProcessInflammation.java create mode 100644 src/arcade/patch/agent/process/PatchProcessInflammationCD4.java create mode 100644 src/arcade/patch/agent/process/PatchProcessInflammationCD8.java create mode 100644 test/arcade/patch/agent/cell/PatchCARTCellTest.java create mode 100644 test/arcade/patch/agent/cell/PatchCellTest.java diff --git a/src/arcade/patch/agent/module/PatchModuleKill.java b/src/arcade/patch/agent/module/PatchModuleKill.java new file mode 100644 index 000000000..b51fad024 --- /dev/null +++ b/src/arcade/patch/agent/module/PatchModuleKill.java @@ -0,0 +1,122 @@ +package arcade.patch.agent.module; + +import arcade.core.agent.process.ProcessDomain; +import arcade.core.sim.Simulation; +import arcade.patch.sim.PatchSimulation; +import arcade.core.util.MiniBox; +import arcade.patch.agent.cell.PatchCell; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.patch.agent.cell.PatchCellTissue; +import arcade.patch.agent.process.PatchProcess; +import arcade.patch.agent.process.PatchProcessInflammation; +import arcade.patch.util.PatchEnums.AntigenFlag; +import arcade.patch.util.PatchEnums.Domain; +import arcade.patch.util.PatchEnums.State; +import ec.util.MersenneTwisterFast; +import sim.engine.SimState; + +// collaprse reset with kill + +public class PatchModuleKill extends PatchModule { + /** The {@link PatchCell} the module is associated with. */ + + //immune cell itself + PatchCellCART cellImmune; + + /** Target cell cytotoxic CAR T-cell is bound to */ + PatchCell target; + + /** CAR T-cell inflammation module */ + PatchProcessInflammation inflammation; + + /** Amount of granzyme inside CAR T-cell */ + double granzyme; + + /** + * Creates a proliferation {@link PatchModule} for the given cell. + *

    + * Loaded parameters include: + *

      + *
    • {@code SYNTHESIS_DURATION} = time required for DNA synthesis
    • + *
    + * + * @param cell the {@link PatchCell} the module is associated with + */ + public PatchModuleKill(PatchCell inputCell, PatchCell target) { + super(inputCell); + //I have to override this.cell bc patchmodule can only take patch cells + this.cellImmune = (PatchCellCART) inputCell; + this.target = target; + this.inflammation = (PatchProcessInflammation) cell.getProcess(Domain.INFLAMMATION); + this.granzyme = inflammation.getInternal("granzyme"); + } + + @Override + public void step(MersenneTwisterFast random, Simulation sim) { + PatchSimulation growthSim = (PatchSimulation) sim; + + // If current CAR T-cell is stopped, stop helper. + if (cellImmune.isStopped()) { return; } + + // If bound target cell is stopped, stop helper. + + //All cells need isStopped method + if (target.isStopped()) { stop(); return; } + + if (granzyme >= 1) { + // Kill bound target cell. + PatchCellTissue tissueCell = (PatchCellTissue) target; + + //setState? + tissueCell.setState(State.APOPTOTIC); + + //what is this + growthSim.lysedCells.add(recordLysis(sim, target)); + + // Use up some granzyme in the process. + granzyme--; + inflammation.setInternal("granzyme", granzyme); + reset(cellImmune); + } + } + + /** + * Stops the helper from if can't kill target. + * + * @param sim the simulation instance + */ + private void stop() { + // Unbind from target. + if (cellImmune.binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { + cellImmune.setAntigenFlag(AntigenFlag.BOUND_CELL_RECEPTOR); + } else { + cellImmune.setAntigenFlag(AntigenFlag.UNBOUND); + } + // Stop helper and set cell type to neutral. + cell.setState(State.QUIESCENT); + } + + /** + * Steps the helper for killing target cell. + *

    + * The String is formatted as: + *

    +	 *     [time of death, [location], [ code, pop, type, position, volume, age, [ list, of, cycle, lengths, ... ] ] ]
    +	 * 
    + */ + private String recordLysis(PatchSimulation sim, PatchCell cell) { + //what is the toJSON equivalent in 3.0? + + //TODO: get toJSON version of the stuff + return "[" + sim.getSchedule().getTime() + "," + cell.getLocation() + "," + cell + "]"; + } + + //for now this is unscheduled... + private void reset(PatchCellCART cell) { + if (cell.getState() == State.CYTOTOXIC || cell.getState() == State.STIMULATORY) { + // Return to neutral state and reset flags to make a new state decision. + cell.setAntigenFlag(AntigenFlag.UNDEFINED); + cell.setState(State.QUIESCENT); + } + } +} diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java new file mode 100644 index 000000000..0810acf4d --- /dev/null +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -0,0 +1,273 @@ +package arcade.patch.agent.process; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import arcade.core.env.location.Location; +import arcade.core.util.MiniBox; +import arcade.core.sim.Simulation; +import arcade.util.Solver.Equations; +import ec.util.MersenneTwisterFast; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.patch.env.lattice.PatchLattice; +import arcade.util.Solver; +/** + * Implementation of {@link arcade.patch.agent.process.Process} for inflammation type modules + * in which IL-2 is taken up and cytotoxic/stimulatory functions are modified. + *

    + * The {@code Inflammation} module represents an 8-component signaling network. + */ + +public abstract class PatchProcessInflammation extends PatchProcess{ + + /** Number of components in signaling network */ + protected static final int NUM_COMPONENTS = 8; + + /** ID for IL-2, bound total */ + protected static final int IL2_INT_TOTAL = 0; + + /** ID for IL-2, external */ + protected static final int IL2_EXT = 1; + + /** ID for IL-2 receptors, total between both two and three chain complex */ + protected static final int IL2R_TOTAL = 2; + + /** ID for two-chain IL-2 receptor complex */ + protected static final int IL2Rbg = 3; + + /** ID for three-chain IL-2 receptor complex */ + protected static final int IL2Rbga = 4; + + /** ID for IL-2-two-chain IL-2 receptor complex */ + protected static final int IL2_IL2Rbg = 5; + + /** ID for IL-2-three-chain IL-2 receptor complex */ + protected static final int IL2_IL2Rbga = 6; + + /** ID for granzyme, internal */ + protected static final int GRANZYME = 7; + + /** Number of steps per second to take in ODE */ + private static final double STEP_DIVIDER = 3.0; + + /** Rate of conversion of IL-2R two-chian complex to IL-2R three chian complex [/sec/step divider] */ + private static final double K_CONVERT = 1e-3/STEP_DIVIDER; + + /** Rate of recycling of recptor complexes back to IL-2 receptor two chain complex [/sec/step divider] */ + private static final double K_REC = 1e-5/STEP_DIVIDER; + + /** Rate of IL-2 binding to two-chain IL-2 recpetor complex [um^3/molecules IL-2/min] */ + private double IL2_BINDING_ON_RATE_MIN = 3.8193E-2; + + /** Rate of IL-2 binding to three-chain IL-2 recpetor complex [um^3/molecules IL-2/min] */ + private double IL2_BINDING_ON_RATE_MAX = 3.155; + + /** Rate of unbinding of IL-2 from two- or three- chain IL-2 receptor complex [/min] */ + private double IL2_BINDING_OFF_RATE = 0.015; + + /** Step size for module (in seconds) */ + static final double STEP_SIZE = 1.0/STEP_DIVIDER; + + /** Location of cell */ + protected Location loc; + + /** Cell the module is associated with */ + protected PatchCellCART c; + + /** Cell population index */ + protected int pop; + + /** List of internal names */ + protected List names; + + /** List of amounts of each species */ + protected double[] amts; + + /** External IL-2 [molecules] */ + protected double extIL2; + + /** Shell around cell volume fraction */ + protected double f; + + /** Volume of cell [um3] */ + protected double volume; + + /** Flag marking if cell is activated via antigen-induced activation */ + protected boolean active; + + /** Time since cell first bound IL-2 */ + protected int IL2Ticker; + + /** Time since cell became activated via antigen-induced activation */ + protected int activeTicker; + + /** List of amounts of IL-2 bound to cell at previous time points */ + protected double[] boundArray; + + /** Distance outward from surface a cell can sense */ + protected final double SHELL_THICKNESS; + + /** Total 2-complex receptors */ + protected final double IL2_RECEPTORS; + + + /** + * Creates an {@code Inflammation} module for the given {@link arcade.patch.agent.PatchCell.PatchCellCART}. + *

    + * Module parameters are specific for the cell population. + * The module starts with no IL-2 bound and no three-chain receptors. + * Daughter cells split amounts of bound IL-2 and three-chain receptors upon dividing. + * + * @param c the {@link arcade.patch.agent.PatchCell.PatchCellCART} the module is associated with + * @param sim the simulation instance + */ + public PatchProcessInflammation(PatchCellCART c) { + super(c); + // Initialize module. + this.loc = c.getLocation(); + this.c = c; + this.pop = c.getPop(); + this.volume = c.getVolume(); + this.IL2Ticker = 0; + this.activeTicker = 0; + + // Set parameters. + MiniBox parameters = cell.getParameters(); + this.SHELL_THICKNESS = parameters.getDouble("SHELL_THICKNESS"); + this.IL2_RECEPTORS = parameters.getDouble("IL2_RECEPTORS"); + this.IL2_BINDING_ON_RATE_MIN = parameters.getDouble("IL2_BINDING_ON_RATE_MIN"); + this.IL2_BINDING_ON_RATE_MAX = parameters.getDouble("IL2_BINDING_ON_RATE_MAX"); + this.IL2_BINDING_OFF_RATE = parameters.getDouble("IL2_BINDING_OFF_RATE"); + + // Set external concentrations. + //updateExternal(sim); + extIL2 = 0; + + // Initial amounts of each species, all in molecules/cell. + amts = new double[NUM_COMPONENTS]; + amts[IL2_INT_TOTAL] = 0; + amts[IL2R_TOTAL] = IL2_RECEPTORS; + amts[IL2Rbg] = IL2_RECEPTORS; + amts[IL2Rbga] = 0; + amts[IL2_IL2Rbg] = 0; + amts[IL2_IL2Rbga] = 0; + + // Molecule names. + names = new ArrayList(); + names.add(IL2_INT_TOTAL, "IL-2"); + names.add(IL2_EXT, "external_IL-2"); + names.add(IL2R_TOTAL, "IL2R_total"); + names.add(IL2Rbg, "IL2R_two_chain_complex"); + names.add(IL2Rbga, "IL2R_three_chain_complex"); + names.add(IL2_IL2Rbg, "IL-2_IL2R_two_chain_complex"); + names.add(IL2_IL2Rbga, "IL-2_IL2R_three_chain_complex"); + + // Initialize prior IL2 array. + this.boundArray = new double[180]; + } + + /** + * System of ODEs for network + */ + Equations dydt = (Equations & Serializable) (t, y) -> { + double[] dydt = new double[NUM_COMPONENTS]; + + double kon_2 = IL2_BINDING_ON_RATE_MIN/loc.getVolume()/60/STEP_DIVIDER; + double kon_3 = IL2_BINDING_ON_RATE_MAX/loc.getVolume()/60/STEP_DIVIDER; + double koff = IL2_BINDING_OFF_RATE/60/STEP_DIVIDER; + + dydt[IL2_EXT] = koff*y[IL2_IL2Rbg] + koff*y[IL2_IL2Rbga] - kon_2*y[IL2Rbg]*y[IL2_EXT] - kon_3*y[IL2Rbga]*y[IL2_EXT]; + dydt[IL2Rbg] = koff*y[IL2_IL2Rbg] - kon_2*y[IL2Rbg]*y[IL2_EXT] - K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2Rbg] + K_REC*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga] + y[IL2Rbga]); + dydt[IL2Rbga] = koff*y[IL2_IL2Rbga] - kon_3*y[IL2Rbga]*y[IL2_EXT] + K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2Rbg] - K_REC*y[IL2Rbga]; + dydt[IL2_IL2Rbg] = kon_2*y[IL2Rbg]*y[IL2_EXT] - koff*y[IL2_IL2Rbg] - K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2_IL2Rbg] - K_REC*y[IL2_IL2Rbg]; + dydt[IL2_IL2Rbga] = kon_3*y[IL2Rbga]*y[IL2_EXT] - koff*y[IL2_IL2Rbga] + K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2_IL2Rbg] - K_REC*y[IL2_IL2Rbga]; + dydt[IL2_INT_TOTAL] = kon_2*y[IL2Rbg]*y[IL2_EXT] - koff*y[IL2_IL2Rbg] - K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2_IL2Rbg] - K_REC*y[IL2_IL2Rbg] + kon_3*y[IL2Rbga]*y[IL2_EXT] - koff*y[IL2_IL2Rbga] + K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2_IL2Rbg] - K_REC*y[IL2_IL2Rbga]; + dydt[IL2R_TOTAL] = koff*y[IL2_IL2Rbg] - kon_2*y[IL2Rbg]*y[IL2_EXT] - K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2Rbg] + K_REC*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga] + y[IL2Rbga]) + koff*y[IL2_IL2Rbga] - kon_3*y[IL2Rbga]*y[IL2_EXT] + K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2Rbg] - K_REC*y[IL2Rbga]; + + return dydt; + }; + + /** + * Gets the internal amounts of requested key. + * + * @param key the requested substance + */ + public double getInternal(String key) {return amts[names.indexOf(key)]; } + + /** + * Steps the inflammation module. + * + * @param sim the simulation instance + */ + // abstract void stepInflammationModule(Simulation sim); + + public void setInternal(String key, double val) { + amts[names.indexOf(key)] = val; + } + + + /** + * Gets the external amounts of IL-2. + *

    + * Multiply by location volume and divide by 1E12 to convert from cm3 + * to um3 to get in molecules. + * + * @param sim the simulation instance + */ + private void updateExternal(Simulation sim) { + // Convert to molecules. + PatchLattice il2 = (PatchLattice) sim.getLattice("IL-2"); + extIL2 = il2.getAverageValue(loc)*loc.getVolume() / 1E12; + } + + // METHOD: stepModule. + public void stepProcess(MersenneTwisterFast random, Simulation sim) { + // Calculate shell volume 2 um outside of cell. + double radCell = Math.cbrt((3.0/4.0)*(1.0/Math.PI)*volume); + double radShell = radCell + SHELL_THICKNESS; + double volShell = volume*(((radShell*radShell*radShell)/(radCell*radCell*radCell)) - 1.0); + // this f might be the actual fraction instead of split + f = volShell/loc.getVolume(); + updateExternal(sim); + + // Check active status. + active = c.getActivationStatus(); + if (active) { activeTicker++; } + else { activeTicker = 0; } + + // Calculate external IL-2 used in inflammation module. + // Local IL-2 total available to cell is fraction of total available + // where that fraction is the relative volume fraction the cell occupies + // in the location. + amts[IL2_EXT] = extIL2*f; // [molecules] + + // Solve system of equations. + amts = Solver.rungeKutta(dydt, 0, amts, 60, STEP_SIZE); + + // Modify internal inflammation response. + step(random, sim); + + // Update bound array. + boundArray[IL2Ticker % boundArray.length] = amts[IL2_INT_TOTAL]; + IL2Ticker++; + } + + /** + * Creates a {@code PatchProcessInflammation} for given version. + * + * @param cell the {@link arcade.patch.agent.PatchCell.PatchCellCART} the process is associated with + * @param version the process version + * @return the process instance + */ + public static PatchProcess make(PatchCellCART cell, String version) { + switch (version.toUpperCase()) { + case "CD4": + return new PatchProcessInflammationCD4(cell); + case "CD8": + return new PatchProcessInflammationCD8(cell); + default: + return null; + } + } +} diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java new file mode 100644 index 000000000..bccf00e12 --- /dev/null +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java @@ -0,0 +1,100 @@ +package arcade.patch.agent.process; + +import arcade.core.agent.process.Process; +import arcade.core.util.MiniBox; +import arcade.core.sim.Simulation; +import ec.util.MersenneTwisterFast; +import arcade.patch.agent.cell.PatchCellCART; +/** + * Extension of {@link arcade.patch.agent.process} for CD4 CAR T-cells + *

    + * {@code InflammationCD4} determines IL-2 amounts produced for stimulatory effector + * functions as a antigen-induced activation state. + */ +public class PatchProcessInflammationCD4 extends PatchProcessInflammation { + + /** Rate of IL-2 production due to antigen-induced activation */ + private final double IL2_PROD_RATE_ACTIVE; + + /** Rate of IL-2 production due to IL-2 feedback */ + private final double IL2_PROD_RATE_IL2; + + /** Delay in IL-2 synthesis after antigen-induced activation */ + private final int IL2_SYNTHESIS_DELAY; + + /** Total rate of IL-2 production */ + private double IL2ProdRate; + + /** Total IL-2 produced in step */ + private double IL2Produced; + + /** Amount of IL-2 bound in past being used for current IL-2 production calculation */ + private double priorIL2prod; + + /** + * Creates a CD4 {@link arcade.agent.module.Inflammation} module. + *

    + * IL-2 production rate parameters set. + * + * @param c the {@link arcade.agent.cell.CARTCell} the module is associated with + * @param sim the simulation instance + */ + public PatchProcessInflammationCD4(PatchCellCART c) { + super(c); + + // Set parameters. + MiniBox parameters = cell.getParameters(); + this.IL2_PROD_RATE_IL2 = parameters.getDouble( "IL2_PROD_RATE_IL2"); + this.IL2_PROD_RATE_ACTIVE = parameters.getDouble("IL2_PROD_RATE_ACTIVE"); + this.IL2_SYNTHESIS_DELAY = parameters.getInt("IL2_SYNTHESIS_DELAY"); + IL2ProdRate = 0; + } + + + @Override + public void step(MersenneTwisterFast random, Simulation sim) { + + // Determine IL-2 production rate as a function of IL-2 bound. + int prodIndex = (IL2Ticker % boundArray.length) - IL2_SYNTHESIS_DELAY; + if (prodIndex < 0) { prodIndex += boundArray.length; } + priorIL2prod = boundArray[prodIndex]; + IL2ProdRate = IL2_PROD_RATE_IL2 * (priorIL2prod/IL2_RECEPTORS); + + // Add IL-2 production rate dependent on antigen-induced + // cell activation if cell is activated. + if (active && activeTicker >= IL2_SYNTHESIS_DELAY) { IL2ProdRate += IL2_PROD_RATE_ACTIVE; } + + // Produce IL-2 to environment. + IL2Produced = IL2ProdRate; // [molecules], rate is already per minute + + // Update environment. + // Take current IL2 external concentration and add the amount produced, + // then convert units back to molecules/cm^3. + double IL2Env = ((extIL2 - (extIL2*f - amts[IL2_EXT])) + IL2Produced)*1E12/loc.getVolume(); + sim.getLattice("IL-2").setValue(loc, IL2Env); + } + + @Override + public void update(Process mod) { + PatchProcessInflammationCD4 inflammation = (PatchProcessInflammationCD4) mod; + double split = this.cell.getVolume() / this.volume; + + // Update daughter cell inflammation as a fraction of parent. + this.amts[IL2Rbga] = inflammation.amts[IL2Rbga]*split; + this.amts[IL2_IL2Rbg] = inflammation.amts[IL2_IL2Rbg]*split; + this.amts[IL2_IL2Rbga] = inflammation.amts[IL2_IL2Rbga]*split; + this.amts[IL2Rbg] = IL2_RECEPTORS - this.amts[IL2Rbga] - this.amts[IL2_IL2Rbg] - this.amts[IL2_IL2Rbga]; + this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2Rbg] + this.amts[IL2_IL2Rbga]; + this.amts[IL2R_TOTAL] = this.amts[IL2Rbg] + this.amts[IL2Rbga]; + this.boundArray = (inflammation.boundArray).clone(); + + // Update parent cell with remaining fraction. + inflammation.amts[IL2Rbga] *= (1 - split); + inflammation.amts[IL2_IL2Rbg] *= (1 - split); + inflammation.amts[IL2_IL2Rbga] *= (1 - split); + inflammation.amts[IL2Rbg] = IL2_RECEPTORS - inflammation.amts[IL2Rbga] - inflammation.amts[IL2_IL2Rbg] - inflammation.amts[IL2_IL2Rbga]; + inflammation.amts[IL2_INT_TOTAL] = inflammation.amts[IL2_IL2Rbg] + inflammation.amts[IL2_IL2Rbga]; + inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2Rbg] + inflammation.amts[IL2Rbga]; + inflammation.volume *= (1 - split); + } +} diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java new file mode 100644 index 000000000..c5f334c38 --- /dev/null +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -0,0 +1,86 @@ +package arcade.patch.agent.process; + +import arcade.core.agent.process.Process; +import arcade.core.util.MiniBox; +import ec.util.MersenneTwisterFast; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.core.sim.Simulation; + +public class PatchProcessInflammationCD8 extends PatchProcessInflammation { + /** Moles of granzyme produced per moles IL-2 [mol granzyme/mol IL-2] */ + private static final double GRANZ_PER_IL2 = 0.005; + + /** Delay in IL-2 synthesis after antigen-induced activation */ + private final int GRANZ_SYNTHESIS_DELAY; + + /** Amount of IL-2 bound in past being used for current granzyme production calculation */ + private double priorIL2granz; + + /** + * Creates a CD8 {@link arcade.agent.module.Inflammation} module. + *

    + * Initial amount of internal granzyme is set. + * Granzyme production parameters set. + * + * @param c the {@link arcade.agent.cell.CARTCell} the module is associated with + * @param sim the simulation instance + */ + public PatchProcessInflammationCD8(PatchCellCART c) { + super(c); + + // Set parameters. + MiniBox parameters = cell.getParameters(); + this.GRANZ_SYNTHESIS_DELAY = parameters.getInt("GRANZ_SYNTHESIS_DELAY"); + this.priorIL2granz = 0; + + // Initialize internal, external, and uptake concentration arrays. + amts[GRANZYME] = 1; // [molecules] + + // Molecule names. + names.add(GRANZYME, "granzyme"); + } + + public void step(MersenneTwisterFast random, Simulation sim) { + + // Determine amount of granzyme production based on if cell is activated + // as a function of IL-2 production. + int granzIndex = (IL2Ticker % boundArray.length) - GRANZ_SYNTHESIS_DELAY; + if (granzIndex < 0) { granzIndex += boundArray.length; } + priorIL2granz = boundArray[granzIndex]; + + if (active && activeTicker > GRANZ_SYNTHESIS_DELAY) { + amts[GRANZYME] += GRANZ_PER_IL2*(priorIL2granz/IL2_RECEPTORS); + } + + // Update environment. + // Convert units back from molecules to molecules/cm^3. + double IL2Env = (extIL2 - (extIL2*f - amts[IL2_EXT]))*1E12/loc.getVolume(); + sim.getLattice("IL-2").setValue(loc, IL2Env); + } + + @Override + public void update(Process mod) { + PatchProcessInflammationCD8 inflammation = (PatchProcessInflammationCD8) mod; + double split = this.cell.getVolume() / this.volume; + + // Update daughter cell inflammation as a fraction of parent. + this.amts[IL2Rbga] = inflammation.amts[IL2Rbga]*split; + this.amts[IL2_IL2Rbg] = inflammation.amts[IL2_IL2Rbg]*split; + this.amts[IL2_IL2Rbga] = inflammation.amts[IL2_IL2Rbga]*f; + this.amts[IL2Rbg] = IL2_RECEPTORS - this.amts[IL2Rbga] - this.amts[IL2_IL2Rbg] - this.amts[IL2_IL2Rbga]; + this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2Rbg] + this.amts[IL2_IL2Rbga]; + this.amts[IL2R_TOTAL] = this.amts[IL2Rbg] + this.amts[IL2Rbga]; + this.amts[GRANZYME] = inflammation.amts[GRANZYME]*split; + this.boundArray = (inflammation.boundArray).clone(); + + // Update parent cell with remaining fraction. + inflammation.amts[IL2Rbga] *= (1 - split); + inflammation.amts[IL2_IL2Rbg] *= (1 - split); + inflammation.amts[IL2_IL2Rbga] *= (1 - split); + inflammation.amts[IL2Rbg] = IL2_RECEPTORS - inflammation.amts[IL2Rbga] - inflammation.amts[IL2_IL2Rbg] - inflammation.amts[IL2_IL2Rbga]; + inflammation.amts[IL2_INT_TOTAL] = inflammation.amts[IL2_IL2Rbg] + inflammation.amts[IL2_IL2Rbga]; + inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2Rbg] + inflammation.amts[IL2Rbga]; + inflammation.amts[GRANZYME] *= (1 - split); + inflammation.volume *= (1 - split); + } +} diff --git a/src/arcade/patch/sim/PatchSimulation.java b/src/arcade/patch/sim/PatchSimulation.java index 9b6505ad3..13e16f952 100644 --- a/src/arcade/patch/sim/PatchSimulation.java +++ b/src/arcade/patch/sim/PatchSimulation.java @@ -57,6 +57,9 @@ public abstract class PatchSimulation extends SimState implements Simulation { /** Lattice factory instance for the simulation. */ public final PatchLatticeFactory latticeFactory; + + /** list of series cells lysed */ + public ArrayList lysedCells; /** * Simulation instance for a {@link Series} for given random seed. @@ -141,6 +144,9 @@ public void start() { setupAgents(); setupEnvironment(); + // Create lysed cell list + this.lysedCells = new ArrayList(); + scheduleActions(); scheduleComponents(); diff --git a/test/arcade/patch/agent/cell/PatchCARTCellTest.java b/test/arcade/patch/agent/cell/PatchCARTCellTest.java new file mode 100644 index 000000000..561c53ef8 --- /dev/null +++ b/test/arcade/patch/agent/cell/PatchCARTCellTest.java @@ -0,0 +1,290 @@ +package arcade.patch.agent.cell; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.stubbing.Answer; + +import static arcade.core.ARCADETestUtilities.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyDouble; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.Arrays; + +import arcade.core.util.MiniBox; +import arcade.patch.agent.module.PatchModule; +import arcade.patch.env.location.PatchLocation; +import arcade.patch.util.PatchEnums.Flag; +import arcade.patch.util.PatchEnums.AntigenFlag; +import arcade.patch.util.PatchEnums.Domain; +import arcade.patch.util.PatchEnums.State; +import ec.util.MersenneTwisterFast; +import sim.util.Bag; +import arcade.patch.env.grid.PatchGrid; +import arcade.core.agent.cell.Cell; +import arcade.core.env.location.Location; +import arcade.core.sim.Simulation; + +public class PatchCARTCellTest { + + private static final double EPSILON = 1E-8; + + private static final MersenneTwisterFast RANDOM = new MersenneTwisterFast(randomSeed()); + + static int cellID = randomIntBetween(1, 10); + + static int cellParent = randomIntBetween(1, 10); + + static int cellPop = randomIntBetween(1, 10); + + static int cellAge = randomIntBetween(1, 1000); + + static int cellDivisions = randomIntBetween(1, 100); + + static double cellVolume = randomDoubleBetween(10, 100); + + static double cellHeight = randomDoubleBetween(10, 100); + + static double cellCriticalVolume = randomDoubleBetween(10, 100); + + static double cellCriticalHeight = randomDoubleBetween(10, 100); + + + static State cellState = State.QUIESCENT; + + static PatchCellCART cellDefaultCD4; + static PatchCellCART cellDefaultCD8; + static PatchCell cellDefault; + + static MiniBox parametersMock; + static PatchLocation locationMock; + static PatchGrid gridMock; + static Simulation simMock; + static MersenneTwisterFast random; + + + @BeforeClass + public static void setupMocks() { + parametersMock = mock(MiniBox.class); + locationMock = mock(PatchLocation.class); + gridMock = mock(PatchGrid.class); + simMock = mock(Simulation.class); + random = new MersenneTwisterFast(); + + //make both a default CD4 cell and a CD8 cell + cellDefaultCD4 = new PatchCellCARTCD4(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + + cellDefaultCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + cellDefault = new PatchCellTissue(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + } + + //test bindTarget() + + // Test if bind targets grab all agents in this location, and all neighbors of this location + @Test + public void bind_target_grabs_all_neighbors() { + //adding all dummy neighbors for this cell + Bag sampleBag = new Bag(); + Bag dummyBag = new Bag(); + for (int i = 0; i <=5; i++) { + sampleBag.add(cellDefaultCD8.make(cellID+i+1,cellState, locationMock, random)); + dummyBag.add(cellDefaultCD8.make(cellID+i+6,cellState, locationMock, random)); + } + //setting up mocks + when(simMock.getGrid()).thenReturn(gridMock); + when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); + PatchLocation dummyNeighbor = mock(PatchLocation.class); + when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList(dummyNeighbor))); + when(gridMock.getObjectsAtLocation(dummyNeighbor)).thenReturn(dummyBag); + //number of neighbors should be the size of the bags we just established + int neighbors = sampleBag.size() * 2; + //set searchAbility to neighbors + 1 so it will always be more than neighbors + when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(neighbors+1.0); + //make new cell + PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + sampleCellCD8.bindTarget(simMock, locationMock, random); + //check that searchAbility is now neighbors if there are less neighbors than search ability + assertEquals(sampleCellCD8.searchAbility, neighbors, EPSILON); + } + + //Test that it is removing itself from potential neighbors + @Test + public void bind_target_removes_self_from_neighbors(){ + //adding all dummy neighbors for this cell + Bag sampleBag = new Bag(); + for (int i = 0; i <=5; i++) { + sampleBag.add(cellDefaultCD8.make(cellID+i+1,cellState, locationMock, random)); + } + //number of neighbors should be the size of the bags we just established + // +1 because we will be adding it in later + int neighbors = sampleBag.size() + 1; + //set searchAbility to neighbors to verify that it eventually removes self + when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(neighbors * 1.0); + //make new cell + PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + //adding self to neighbors + sampleBag.add(sampleCellCD8); + //setting up mocks + when(simMock.getGrid()).thenReturn(gridMock); + when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); + when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList())); + + sampleCellCD8.bindTarget(simMock, locationMock, random); + //check that searchAbility is now neighbors if there are less neighbors than search ability + assertEquals(sampleCellCD8.searchAbility, neighbors-1, EPSILON); + } + + //Test that it is not binding to other T cells + @Test + public void bind_target_removes_avoid_tcells(){ + //adding all dummy tcell neighbors for this cell + Bag sampleBag = new Bag(); + for (int i = 0; i <=5; i++) { + sampleBag.add(cellDefaultCD8.make(cellID+i+1,cellState, locationMock, random)); + } + //set searchAbility to some number that accomodates all neighbors + when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(sampleBag.size() + 1.0); + //make new cell + PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + //setting up mocks + when(simMock.getGrid()).thenReturn(gridMock); + when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); + when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList())); + + sampleCellCD8.bindTarget(simMock, locationMock, random); + + //check that the cell is not binding to anything + assertEquals(sampleCellCD8.getAntigenFlag(), AntigenFlag.UNDEFINED); + } + + //Test that it is not binding to apoptotic cells + @Test + public void bind_target_removes_avoid_apoptotic_cells(){ + //adding all dummy apoptotic neighbors for this cell + Bag sampleBag = new Bag(); + for (int i = 0; i <=5; i++) { + Cell dummyCell = cellDefault.make(cellID+i+1,cellState, locationMock, random); + dummyCell.setState(State.APOPTOTIC); + sampleBag.add(dummyCell); + } + //set searchAbility to some number that accomodates all neighbors + when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(sampleBag.size() + 1.0); + //make new cell + PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + //setting up mocks + when(simMock.getGrid()).thenReturn(gridMock); + when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); + when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList())); + + sampleCellCD8.bindTarget(simMock, locationMock, random); + + //check that the cell is not binding to anything + assertEquals(sampleCellCD8.getAntigenFlag(), AntigenFlag.UNDEFINED); + } + + //Test that it is not binding to necrotic cells + @Test + public void bind_target_removes_avoid_necrotic_cells(){ + //adding all dummy necrotic neighbors for this cell + Bag sampleBag = new Bag(); + for (int i = 0; i <=5; i++) { + Cell dummyCell = cellDefault.make(cellID+i+1,cellState, locationMock, random); + dummyCell.setState(State.NECROTIC); + sampleBag.add(dummyCell); + } + //set searchAbility to some number that accomodates all neighbors + when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(sampleBag.size() + 1.0); + //make new cell + PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + //setting up mocks + when(simMock.getGrid()).thenReturn(gridMock); + when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); + when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList())); + + sampleCellCD8.bindTarget(simMock, locationMock, random); + + //check that the cell is not binding to anything + assertEquals(sampleCellCD8.getAntigenFlag(), AntigenFlag.UNDEFINED); + } + + //Test that maxSearch is calculated correctly when neighbors > searchAbility + @Test + public void maxSearch_returns_neighbors_when_less() { + //set searchAbility to some number + when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(2.0); + //make new cell + PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + //make allAgents greater than searchAbility + Bag sampleBag = new Bag(); + for (int i = 0; i <=5; i++) { + sampleBag.add(cellDefaultCD8.make(cellID+i+1,cellState, locationMock, random)); + } + when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); + when(simMock.getGrid()).thenReturn(gridMock); + when(locationMock.getNeighbors()).thenReturn(new ArrayList()); + sampleCellCD8.bindTarget(simMock, locationMock, random); + //check that searchAbility stays the same + assertEquals(sampleCellCD8.searchAbility, 2, EPSILON); + } + + //Test that maxSearch is calculated correctly when neighbors < searchAbility + @Test + public void maxSearch_returns_neighbors_when_more() { + //set searchAbility to some number + when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(6.0); + //make new cell + PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + //make allAgents less than searchAbility + Bag sampleBag = new Bag(); + for (int i = 0; i <=5; i++) { + sampleBag.add(cellDefaultCD8.make(cellID+i+1,cellState, locationMock, random)); + } + when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); + when(simMock.getGrid()).thenReturn(gridMock); + when(locationMock.getNeighbors()).thenReturn(new ArrayList()); + sampleCellCD8.bindTarget(simMock, locationMock, random); + //check that searchAbility stays the same + assertEquals(sampleCellCD8.searchAbility, sampleBag.size(), EPSILON); + } + + //Is it worth testing these cases?????? + + //logCAR >= randomAntigen && logSelf < randomSelf + //set random antigen and random self that fits conditions + //verify flag set + //verify antigen count incremented + //verify self receptors calculated correctly + + //logCAR >= randomAntigen && logSelf >= randomSelf + //set random antigen and random self that fits conditions + //verify flag set + //verify antigen count incremented + //verify self receptors calculated correctly + + //logCAR < randomAntigen && logSelf >= randomSelf + //set random antigen and random self that fits conditions + //verify flag set + //verify antigen count incremented + //verify self receptors calculated correctly + + //logCAR < randomAntigen && logSelf < randomSelf + //set random antigen and random self that fits conditions + //verify flag set to unbound + +} diff --git a/test/arcade/patch/agent/cell/PatchCellTest.java b/test/arcade/patch/agent/cell/PatchCellTest.java new file mode 100644 index 000000000..2b0f91a32 --- /dev/null +++ b/test/arcade/patch/agent/cell/PatchCellTest.java @@ -0,0 +1,239 @@ +package arcade.patch.agent.cell; + +import org.junit.BeforeClass; +import org.junit.Test; + +import static arcade.core.ARCADETestUtilities.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.mockito.Mockito.mock; + +import arcade.core.util.MiniBox; +import arcade.patch.env.location.PatchLocation; +import arcade.patch.util.PatchEnums.Flag; +import arcade.patch.util.PatchEnums.Domain; +import arcade.patch.util.PatchEnums.State; +import ec.util.MersenneTwisterFast; +import sim.util.Bag; + +public class PatchCellTest { + private static final double EPSILON = 1E-8; + + private static final MersenneTwisterFast RANDOM = new MersenneTwisterFast(randomSeed()); + + static int cellID = randomIntBetween(1, 10); + + static int cellParent = randomIntBetween(1, 10); + + static int cellPop = randomIntBetween(1, 10); + + static int cellAge = randomIntBetween(1, 1000); + + static int cellDivisions = randomIntBetween(1, 100); + + static double cellVolume = randomDoubleBetween(10, 100); + + static double cellHeight = randomDoubleBetween(10, 100); + + static double cellCriticalVolume = randomDoubleBetween(10, 100); + + static double cellCriticalHeight = randomDoubleBetween(10, 100); + + static State cellState = State.QUIESCENT; + + static PatchCellTissue cellDefault; + + static MiniBox parametersMock; + static PatchLocation locationMock; + + @BeforeClass + public static void setupMocks() { + parametersMock = mock(MiniBox.class); + locationMock = mock(PatchLocation.class); + + cellDefault = new PatchCellTissue(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + } + + @Test + public void getID_defaultConstructor_returnsValue() { + assertEquals(cellID, cellDefault.getID()); + } + + @Test + public void getParent_defaultConstructor_returnsValue() { + assertEquals(cellParent, cellDefault.getParent()); + } + + @Test + public void getParent_valueAssigned_returnsValue() { + int parent = randomIntBetween(0, 100); + PatchCellTissue cell = new PatchCellTissue(cellID, parent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + assertEquals(parent, cell.getParent()); + } + + @Test + public void getPop_defaultConstructor_returnsValue() { + assertEquals(cellPop, cellDefault.getPop()); + } + + @Test + public void getPop_valueAssigned_returnsValue() { + int pop = randomIntBetween(0, 100); + PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, pop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + assertEquals(pop, cell.getPop()); + } + + @Test + public void getState_defaultConstructor_returnsValue() { + assertEquals(cellState, cellDefault.getState()); + } + + @Test + public void getState_valueAssigned_returnsValue() { + State state = State.random(RANDOM); + PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, cellPop, state, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + assertEquals(state, cell.getState()); + } + + @Test + public void getAge_defaultConstructor_returnsValue() { + assertEquals(cellAge, cellDefault.getAge()); + } + + @Test + public void getAge_valueAssigned_returnsValue() { + int age = randomIntBetween(0, 100); + PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, cellPop, cellState, age, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + assertEquals(age, cell.getAge()); + } + + @Test + public void getDivisions_defaultConstructor_returnsValue() { + assertEquals(cellDivisions, cellDefault.getDivisions()); + } + + @Test + public void getDivisions_valueAssigned_returnsValue() { + int divisions = randomIntBetween(0, 100); + PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, cellPop, cellState, cellAge, divisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + assertEquals(divisions, cell.getDivisions()); + } + + @Test + public void getLocation_defaultConstructor_returnsObject() { + assertSame(locationMock, cellDefault.getLocation()); + } + + @Test + public void getModule_defaultConstructor_returnsNull() { + assertEquals(cellDefault.getModule(), null); + } + + @Test + public void getProcess_defaultConstructor_returnsNull() { + assertNull(cellDefault.getProcess(Domain.UNDEFINED)); + } + + @Test + public void getParameters_defaultConstructor_returnsObject() { + assertSame(parametersMock, cellDefault.getParameters()); + } + + @Test + public void getVolume_defaultConstructor_returnsValue() { + assertEquals(cellVolume, cellDefault.getVolume(),EPSILON); + } + + @Test + public void getHeight_defaultConstructor_returnsValue() { + assertEquals(cellHeight, cellDefault.getHeight(),EPSILON); + } + + @Test + public void getCriticalVolume_defaultConstructor_returnsValue() { + assertEquals(cellCriticalVolume, cellDefault.getCriticalVolume(),EPSILON); + } + + @Test + public void getCriticalHeight_defaultConstructor_returnsValue() { + assertEquals(cellCriticalHeight, cellDefault.getCriticalHeight(),EPSILON); + } + + @Test + public void getEnergy_defaultConstructor_returnsValue() { + assertEquals(0, cellDefault.getEnergy(),EPSILON); + } + + @Test + public void setEnergy_returnsValue() { + double energy = randomDoubleBetween(0, 100); + PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, cellPop, cellState,cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + cell.setEnergy(energy); + assertEquals(energy, cell.getEnergy(),EPSILON); + } + + @Test + public void setFlag_valueAssigned_returnsValue() { + Flag flag = Flag.random(RANDOM); + PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + cell.setFlag(flag); + assertEquals(flag, cell.flag); + } + + @Test + public void convert_createsContainer() { + PatchLocation location = mock(PatchLocation.class); + MiniBox parameters = mock(MiniBox.class); + + int id = randomIntBetween(1, 10); + int parent = randomIntBetween(1, 10); + int pop = randomIntBetween(1, 10); + int age = randomIntBetween(1, 100); + int divisions = randomIntBetween(1, 100); + State state = State.PROLIFERATIVE; + double criticalVolume = randomDoubleBetween(10, 100); + double criticalHeight = randomDoubleBetween(10, 100); + double volume = randomDoubleBetween(10, 100); + double height = randomDoubleBetween(10, 100); + + PatchCellTissue cell = new PatchCellTissue(id, parent, pop, state, age, divisions, + location, parameters, volume, height, criticalVolume, criticalHeight); + + PatchCellContainer container = (PatchCellContainer) cell.convert(); + + assertEquals(id, container.id); + assertEquals(parent, container.parent); + assertEquals(pop, container.pop); + assertEquals(age, container.age); + assertEquals(divisions, container.divisions); + assertEquals(state, container.state); + assertEquals(criticalVolume, container.criticalVolume, EPSILON); + assertEquals(criticalHeight, container.criticalHeight, EPSILON); + } + + @Test + public void calculate_total_volume_returnsValue() { + Bag cells = new Bag(); + double runningSum = 0; + for (int i = 0; i < randomIntBetween(1,10); i++) { + double v = randomDoubleBetween(10, 100); + PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + locationMock, parametersMock, v, cellHeight, cellCriticalVolume, cellCriticalHeight); + cells.add(cell); + runningSum+=v; + } + assertEquals(runningSum, PatchCell.calculateTotalVolume(cells), EPSILON); + } + + //once implemented, make sure location methods and step is working + +} From ec2cdae6dc6cf3bf6ac119480afd8cec3730feab Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Thu, 27 Jun 2024 23:42:39 +0000 Subject: [PATCH 014/185] initial CART agent refactoring file push --- src/arcade/patch/agent/cell/PatchCell.java | 16 +++++++++++++--- src/arcade/patch/agent/cell/PatchCellCART.java | 15 +++++++++------ .../patch/agent/cell/PatchCellCARTCD4.java | 5 ++++- .../patch/agent/cell/PatchCellContainer.java | 6 ++++++ 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 42423a7c9..98accf0df 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -18,6 +18,7 @@ import arcade.patch.agent.module.PatchModuleApoptosis; import arcade.patch.agent.module.PatchModuleMigration; import arcade.patch.agent.module.PatchModuleProliferation; +import arcade.patch.agent.process.PatchProcessInflammation; import arcade.patch.agent.process.PatchProcessMetabolism; import arcade.patch.agent.process.PatchProcessSignaling; import arcade.patch.env.grid.PatchGrid; @@ -119,6 +120,9 @@ public abstract class PatchCell implements Cell { /** Cell parameters. */ final MiniBox parameters; + + /** If cell is stopped in the simulation */ + private boolean isStopped; /** * Creates a {@code PatchCell} agent. @@ -163,6 +167,7 @@ public PatchCell(int id, int parent, int pop, CellState state, int age, int divi this.criticalHeight = criticalHeight; this.flag = Flag.UNDEFINED; this.parameters = parameters; + this.isStopped = false; setState(state); @@ -256,7 +261,12 @@ public PatchCell(int id, int parent, int pop, CellState state, int age, int divi public void setEnergy(double energy) { this.energy = energy; } @Override - public void stop() { stopper.stop(); } + public void stop() { + stopper.stop(); + isStopped = true; + } + + public boolean isStopped(){ return isStopped;} @Override public void setState(CellState state) { @@ -292,8 +302,8 @@ public Process makeProcess(ProcessDomain domain, String version) { return PatchProcessMetabolism.make(this, version); case SIGNALING: return PatchProcessSignaling.make(this, version); - /*case INFLAMMATION: - return PatchProcessInflammation.make(this,version);*/ + case INFLAMMATION: + return PatchProcessInflammation.make(this,version); case UNDEFINED: default: return null; diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 1be78d876..ee8e6163f 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -2,7 +2,7 @@ import sim.util.Bag; import ec.util.MersenneTwisterFast; -import javafx.stage.PopupWindow.AnchorLocation; +//import javafx.stage.PopupWindow.AnchorLocation; import arcade.core.agent.cell.Cell; import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; @@ -74,7 +74,7 @@ public abstract class PatchCellCART extends PatchCell { protected final int selfTargets; /** Cell binding flag */ - protected AntigenFlag binding; + public AntigenFlag binding; /** Cell activation flag */ protected boolean activated; @@ -163,7 +163,7 @@ public PatchCellCART(int id, int parent, int pop, CellState state, int age, int carAntigens = parameters.getInt("CAR_ANTIGENS"); selfTargets = parameters.getInt("SELF_TARGETS"); selfReceptors = parameters.getInt("SELF_RECEPTORS"); - selfReceptorsStart = parameters.getInt("SELF_RECEPTORS_START"); + selfReceptorsStart = selfReceptors; searchAbility = parameters.getDouble("SEARCH_ABILITY"); carAffinity = parameters.getDouble("CAR_AFFINITY"); carAlpha = parameters.getDouble("CAR_ALPHA"); @@ -269,9 +269,6 @@ public void bindTarget(Simulation sim, PatchLocation loc, MersenneTwisterFast ra } } - //this method may be unnecessary if only subclasses can set antigen flag - //can non-T cells set the antigen binding properties of CART cell? - /** * Sets the cell binding flag. * @@ -279,6 +276,12 @@ public void bindTarget(Simulation sim, PatchLocation loc, MersenneTwisterFast ra */ public void setAntigenFlag(AntigenFlag flag) { this.binding = flag; } + /** + * Returns the cell binding flag. + * + * @return the cell antigen binding state + */ + public AntigenFlag getAntigenFlag() { return this.binding; } /** * Returns activation status diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 54f6be88c..121862506 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -1,6 +1,9 @@ package arcade.patch.agent.cell; +import java.util.Set; + import arcade.core.agent.cell.CellState; +import arcade.core.agent.process.ProcessDomain; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; import arcade.core.util.MiniBox; @@ -92,7 +95,7 @@ public void step(SimState simstate) { } // Step inflammation process. - //super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); + super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); // Change state from undefined. if (super.state == State.UNDEFINED || super.state == State.PAUSED) { diff --git a/src/arcade/patch/agent/cell/PatchCellContainer.java b/src/arcade/patch/agent/cell/PatchCellContainer.java index e88854b75..c62d58a33 100644 --- a/src/arcade/patch/agent/cell/PatchCellContainer.java +++ b/src/arcade/patch/agent/cell/PatchCellContainer.java @@ -105,6 +105,12 @@ private Cell convert(PatchCellFactory factory, Location location) { case "cancer_stem": return new PatchCellCancerStem(id, parent, pop, state, age, divisions, location, parameters, volume, height, criticalVolume, criticalHeight); + case "cart_cd4": + return new PatchCellCARTCD4(id, parent, pop, state, age, divisions, location, + parameters, volume, height, criticalVolume, criticalHeight); + case "cart_cd8": + return new PatchCellCARTCD8(id, parent, pop, state, age, divisions, location, + parameters, volume, height, criticalVolume, criticalHeight); } } } From 06ffa1f14de8dca3b509aff7501f63f533d13671 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Thu, 27 Jun 2024 23:43:32 +0000 Subject: [PATCH 015/185] initial Inflammation module refactorization file push --- .../agent/process/PatchProcessInflammation.java | 11 ++++++----- .../agent/process/PatchProcessInflammationCD4.java | 12 +++++++++--- .../agent/process/PatchProcessInflammationCD8.java | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index 0810acf4d..76837f03d 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -7,11 +7,12 @@ import arcade.core.env.location.Location; import arcade.core.util.MiniBox; import arcade.core.sim.Simulation; -import arcade.util.Solver.Equations; +import arcade.core.util.Solver.Equations; import ec.util.MersenneTwisterFast; +import arcade.patch.agent.cell.PatchCell; import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.env.lattice.PatchLattice; -import arcade.util.Solver; +import arcade.core.util.Solver; /** * Implementation of {@link arcade.patch.agent.process.Process} for inflammation type modules * in which IL-2 is taken up and cytotoxic/stimulatory functions are modified. @@ -260,12 +261,12 @@ public void stepProcess(MersenneTwisterFast random, Simulation sim) { * @param version the process version * @return the process instance */ - public static PatchProcess make(PatchCellCART cell, String version) { + public static PatchProcess make(PatchCell cell, String version) { switch (version.toUpperCase()) { case "CD4": - return new PatchProcessInflammationCD4(cell); + return new PatchProcessInflammationCD4((PatchCellCART) cell); case "CD8": - return new PatchProcessInflammationCD8(cell); + return new PatchProcessInflammationCD8((PatchCellCART) cell); default: return null; } diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java index bccf00e12..3308e5577 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java @@ -1,5 +1,8 @@ package arcade.patch.agent.process; +import java.util.ArrayList; +import java.util.Set; + import arcade.core.agent.process.Process; import arcade.core.util.MiniBox; import arcade.core.sim.Simulation; @@ -43,10 +46,13 @@ public PatchProcessInflammationCD4(PatchCellCART c) { super(c); // Set parameters. + + //TODO: parameters are not grabbing here MiniBox parameters = cell.getParameters(); - this.IL2_PROD_RATE_IL2 = parameters.getDouble( "IL2_PROD_RATE_IL2"); - this.IL2_PROD_RATE_ACTIVE = parameters.getDouble("IL2_PROD_RATE_ACTIVE"); - this.IL2_SYNTHESIS_DELAY = parameters.getInt("IL2_SYNTHESIS_DELAY"); + ArrayList keys = parameters.getKeys(); + this.IL2_PROD_RATE_IL2 = parameters.getDouble( "inflammation/IL2_PROD_RATE_IL2"); + this.IL2_PROD_RATE_ACTIVE = parameters.getDouble("inflammation/IL2_PROD_RATE_ACTIVE"); + this.IL2_SYNTHESIS_DELAY = parameters.getInt("inflammation/IL2_SYNTHESIS_DELAY"); IL2ProdRate = 0; } diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index c5f334c38..fe52b2141 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -30,7 +30,7 @@ public PatchProcessInflammationCD8(PatchCellCART c) { // Set parameters. MiniBox parameters = cell.getParameters(); - this.GRANZ_SYNTHESIS_DELAY = parameters.getInt("GRANZ_SYNTHESIS_DELAY"); + this.GRANZ_SYNTHESIS_DELAY = parameters.getInt("inflammation/GRANZ_SYNTHESIS_DELAY"); this.priorIL2granz = 0; // Initialize internal, external, and uptake concentration arrays. From 0552a45ac2117062a0db776cc8dff6de5a90c542 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Thu, 27 Jun 2024 23:44:17 +0000 Subject: [PATCH 016/185] including CART agent tags for default CART agent and module parameter values --- src/arcade/patch/parameter.patch.xml | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index 48b1d4556..24180f8ca 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -22,6 +22,27 @@ + + + + + + + + + + + + + + + + + + + + + @@ -54,6 +75,28 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -80,6 +123,13 @@ + + + + + + + From 3b7a882a566f6684805932bc852337539889f068 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Thu, 27 Jun 2024 23:45:33 +0000 Subject: [PATCH 017/185] adding IL2 layers into env --- src/arcade/patch/sim/PatchSeries.java | 3 ++- src/arcade/patch/sim/PatchSimulationHex.java | 3 +++ src/arcade/patch/sim/PatchSimulationRect.java | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/arcade/patch/sim/PatchSeries.java b/src/arcade/patch/sim/PatchSeries.java index 7711e59bf..3283349f1 100644 --- a/src/arcade/patch/sim/PatchSeries.java +++ b/src/arcade/patch/sim/PatchSeries.java @@ -87,7 +87,7 @@ protected void initialize(HashMap> setupLists, Box parame MiniBox actionDefaults = parameters.getIdValForTag("ACTION"); ArrayList actionsBox = setupLists.get("actions"); updateActions(actionsBox, actionDefaults); - + // Add components. MiniBox componentDefaults = parameters.getIdValForTag("COMPONENT"); ArrayList componentsBox = setupLists.get("components"); @@ -97,6 +97,7 @@ protected void initialize(HashMap> setupLists, Box parame MiniBox patchDefaults = parameters.getIdValForTag("PATCH"); ArrayList patchBox = setupLists.get("patch"); updatePatch(patchBox, patchDefaults); + } /** diff --git a/src/arcade/patch/sim/PatchSimulationHex.java b/src/arcade/patch/sim/PatchSimulationHex.java index 8aed4da5d..93676a501 100644 --- a/src/arcade/patch/sim/PatchSimulationHex.java +++ b/src/arcade/patch/sim/PatchSimulationHex.java @@ -7,6 +7,7 @@ import arcade.patch.agent.action.PatchActionConvert; import arcade.patch.agent.action.PatchActionInsert; import arcade.patch.agent.action.PatchActionRemove; +import arcade.patch.agent.action.PatchActionTreat; import arcade.patch.agent.cell.PatchCellFactory; import arcade.patch.env.component.PatchComponentCycle; import arcade.patch.env.component.PatchComponentDegrade; @@ -61,6 +62,8 @@ public Action makeAction(String actionClass, MiniBox parameters) { return new PatchActionRemove(series, parameters); case "convert": return new PatchActionConvert(series, parameters); + case "treat": + return new PatchActionTreat(series, parameters); default: return null; } diff --git a/src/arcade/patch/sim/PatchSimulationRect.java b/src/arcade/patch/sim/PatchSimulationRect.java index ea614f01b..506189126 100644 --- a/src/arcade/patch/sim/PatchSimulationRect.java +++ b/src/arcade/patch/sim/PatchSimulationRect.java @@ -7,6 +7,7 @@ import arcade.patch.agent.action.PatchActionConvert; import arcade.patch.agent.action.PatchActionInsert; import arcade.patch.agent.action.PatchActionRemove; +import arcade.patch.agent.action.PatchActionTreat; import arcade.patch.agent.cell.PatchCellFactory; import arcade.patch.env.component.PatchComponentCycle; import arcade.patch.env.component.PatchComponentDegrade; @@ -61,6 +62,8 @@ public Action makeAction(String actionClass, MiniBox parameters) { return new PatchActionRemove(series, parameters); case "convert": return new PatchActionConvert(series, parameters); + case "treat": + return new PatchActionTreat(series, parameters); default: return null; } From 450f66bbf0261656038f45213fad4c05425c2aae Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Thu, 27 Jun 2024 23:46:03 +0000 Subject: [PATCH 018/185] adding in treat action from CARCADE helper options --- .../patch/agent/action/PatchActionTreat.java | 364 ++++++++++++++++++ 1 file changed, 364 insertions(+) create mode 100644 src/arcade/patch/agent/action/PatchActionTreat.java diff --git a/src/arcade/patch/agent/action/PatchActionTreat.java b/src/arcade/patch/agent/action/PatchActionTreat.java new file mode 100644 index 000000000..d5f9555e6 --- /dev/null +++ b/src/arcade/patch/agent/action/PatchActionTreat.java @@ -0,0 +1,364 @@ +package arcade.patch.agent.action; +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Set; + +import sim.engine.Schedule; +import sim.engine.SimState; +import sim.util.Bag; +import arcade.core.agent.action.Action; +import arcade.core.agent.cell.Cell; +import arcade.core.agent.cell.CellContainer; +import arcade.core.env.component.Component; +import arcade.core.env.grid.Grid; +import arcade.core.env.lattice.Lattice; +import arcade.core.env.location.Location; +import arcade.core.env.location.LocationContainer; +import arcade.core.sim.Series; +import arcade.core.sim.Simulation; +import arcade.core.util.MiniBox; +import arcade.core.util.Utilities; +import arcade.patch.env.grid.PatchGrid; +import arcade.patch.env.location.Coordinate; +import arcade.patch.env.location.CoordinateUVWZ; +import arcade.patch.env.location.CoordinateXYZ; +import arcade.patch.env.location.PatchLocation; +import arcade.patch.env.location.PatchLocationContainer; +import arcade.patch.sim.PatchSeries; +import arcade.patch.sim.PatchSimulation; +import arcade.patch.env.component.PatchComponentSitesSource; +import arcade.patch.env.component.PatchComponentSitesPattern; +import arcade.patch.agent.cell.PatchCell; +import arcade.patch.agent.cell.PatchCellContainer; +import arcade.patch.env.component.PatchComponentSites; +import arcade.patch.env.component.PatchComponentSitesGraph; +import arcade.patch.env.component.PatchComponentSitesGraph.SiteEdge; +import arcade.patch.env.component.PatchComponentSitesGraphTri; +import arcade.patch.env.component.PatchComponentSitesGraphRect; +import arcade.core.util.Graph; +import arcade.patch.util.PatchEnums.Ordering; + +/** + * Implementation of {@link Action} for removing cell agents. + *

    + * The action is stepped once after {@code TIME_DELAY}. + * The {@code TreatAction} will add CAR T-cell agents of specified dose + * and ratio next to source points or vasculature. + */ + +public class PatchActionTreat implements Action { + /** Serialization version identifier */ + private static final long serialVersionUID = 0; + + /** Delay before calling the helper (in minutes) */ + private final int delay; + + /** Total number of CAR T-cells to treat with */ + private final int dose; + + /** List of populations being treated with */ + //private final ArrayList treatPops; + + /** List of freaction of each population to treat with. CD4 to CD8 ratio */ + private final double treatFrac; + + /** Grid radius that cells are inserted into. */ + private final int insertRadius; + + /** Grid depth that cells are inserted into. */ + private final int insertDepth; + + /** Maximum damage value at which T-cells can spawn next to in source or pattern source */ + private double max_damage; + + /** Minimum radius value at which T- cells can spawn next to in graph source*/ + + private double min_damage_radius; + + /** Number of agent positions per lattice site */ + private int latPositions; + + /** Coordinate system used for simulation */ + private String coord; + + /** List of populations. */ + private final ArrayList populations; + + /** + * Creates an {@code Action} to add agents after a delay. + * + * @param series the simulation series + * @param parameters the component parameters dictionary + */ + + public PatchActionTreat(Series series, MiniBox parameters) { + // Set loaded parameters. + this.delay = parameters.getInt("TIME_DELAY"); + this.dose = parameters.getInt("DOSE"); + this.treatFrac = parameters.getDouble("RATIO"); + this.max_damage = parameters.getDouble("MAX_DAMAGE_SEED"); + this.min_damage_radius = parameters.getDouble("MIN_RADIUS_SEED"); + + this.coord = ((PatchSeries) series).patch.get("GEOMETRY").equalsIgnoreCase("HEX") ? "Hex" : "Rect"; + if (coord == "Hex") { latPositions = 9; } + if (coord == "Rect") { latPositions = 16;} + + + + //Im assuming to just use the default here + this.insertRadius = ((PatchSeries) series).radius; + this.insertDepth = ((PatchSeries) series).height; + + // Initialize population register. + populations = new ArrayList<>(); + } + + @Override + public void schedule(Schedule schedule) { + schedule.scheduleOnce(delay, Ordering.ACTIONS.ordinal(), this); + } + + @Override + public void register(Simulation sim, String population) { + populations.add(sim.getSeries().populations.get(population)); + } + + /** + * Steps the helper to insert cells of the treatment population(s). + * + * @param state the MASON simulation state + */ + public void step(SimState simstate) { + + PatchSimulation sim = (PatchSimulation) simstate; + String type = "null"; + PatchGrid grid = (PatchGrid) sim.getGrid(); + PatchComponentSites comp = (PatchComponentSites) sim.getComponent("SITES"); + + ArrayList locs = sim.getLocations(); + + + + ArrayList siteLocs0 = new ArrayList(); + ArrayList siteLocs1 = new ArrayList(); + ArrayList siteLocs2 = new ArrayList(); + ArrayList siteLocs3 = new ArrayList(); + ArrayList siteLocs = new ArrayList(); + + // Determine type of sites component implemented. + if (comp instanceof PatchComponentSitesSource) { type = "source"; } + else if (comp instanceof PatchComponentSitesPattern) { type = "pattern"; } + else if (comp instanceof PatchComponentSitesGraph) { type = "graph"; } + + // Find sites without specified level of damage based on component type. + switch (type) { + case "source": case "pattern": + double[][][] damage; + boolean[][][] sitesLat; + + if (type == "source") { + damage = ((PatchComponentSitesSource)comp).getDamage(); + sitesLat = ((PatchComponentSitesSource)comp).getSources(); + } else { + damage = ((PatchComponentSitesPattern)comp).getDamage(); + sitesLat = ((PatchComponentSitesPattern)comp).getPatterns(); + } + + // Iterate through list of locations and remove locations not next to a site. + for (LocationContainer l:locs) { + PatchLocationContainer contain = (PatchLocationContainer) l; + //TODO: Can this just be random? Does each location necessarily need to be tied to a cell??? + //PatchLocation loc = (PatchLocation) contain.convert(sim.locationFactory, sim.cellFactory.createCellForPopulation(sim.getID(), populations.get(0).getInt("CODE"))); + PatchLocation loc = (PatchLocation) contain.convert(sim.locationFactory, sim.cellFactory.createCellForPopulation(0, populations.get(0).getInt("CODE"))); + //Something is crashing here + CoordinateXYZ coord = (CoordinateXYZ) loc.getSubcoordinate(); + int z = coord.z; + // Check of lattice location is a site (1 or 2) + // and if damage is not too severe to pass through vasculature + if ( sitesLat[z][coord.x][coord.y] && damage[z][coord.x][coord.y] <= this.max_damage) { + addCellsIntoList(grid, loc, siteLocs0, siteLocs1, siteLocs2, siteLocs3); + } + } + break; + + case "graph": + Graph G = ((PatchComponentSitesGraph)comp).getGraph(); + Bag allEdges = new Bag(G.getAllEdges()); + PatchComponentSitesGraph graphSites = (PatchComponentSitesGraph) comp; + + for (Object edgeObj : allEdges) { + SiteEdge edge = (SiteEdge)edgeObj; + Bag allEdgeLocs = new Bag(); + if (coord == "Hex") { + allEdgeLocs.add(((PatchComponentSitesGraphTri) graphSites).getSpan(edge.getFrom(), edge.getTo())); + } else { + allEdgeLocs.add(((PatchComponentSitesGraphRect) graphSites).getSpan(edge.getFrom(), edge.getTo())); + } + + for (Object locObj : allEdgeLocs) { + Location loc = (Location)locObj; + //check if locaiton within margine + if (locs.contains(loc)) { + //check if radius is larger than minimum + if (edge.getRadius() >= min_damage_radius) { + addCellsIntoList(grid, loc, siteLocs0, siteLocs1, siteLocs2, siteLocs3); + } + } + } + } + break; + } + + // Sort location list in order of most to least tumor cells inside it. + Utilities.shuffleList(siteLocs3, sim.random); + Utilities.shuffleList(siteLocs2, sim.random); + Utilities.shuffleList(siteLocs1, sim.random); + Utilities.shuffleList(siteLocs0, sim.random); + siteLocs.addAll(siteLocs3); + siteLocs.addAll(siteLocs2); + siteLocs.addAll(siteLocs1); + siteLocs.addAll(siteLocs0); + insert(siteLocs, sim, grid); + } + + private void addCellsIntoList(PatchGrid grid, LocationContainer l, PatchLocationContainer contain, PatchSimulation sim, ArrayList siteLocs0, ArrayList siteLocs1, ArrayList siteLocs2, ArrayList siteLocs3){ + //TODO: Check w/ Jason about this... + //location container ID and cell container ID the same? if they at the same place? + Location loc = contain.convert(sim.locationFactory, sim.getCells().get(l.getID())); + Bag bag = new Bag(grid.getObjectsAtLocation(loc)); + int numAgents = bag.numObjs; + + if (numAgents == 0) { + for (int p = 0; p < latPositions; p++) { siteLocs0.add(loc); } + } + else if (numAgents == 1) { + for (int p = 0; p < latPositions; p++) { siteLocs1.add(loc); } + } + else if (numAgents == 2) { + for (int p = 0; p < latPositions; p++) { siteLocs2.add(loc); } + } + else { for (int p = 0; p < latPositions; p++) { siteLocs3.add(loc); } } + // Remove break statement if more than one per hex can appear + // with break statement, each location can only be added to list once + // without it, places with more vasc sites get added more times to list + //break; +} + +private void addCellsIntoList(PatchGrid grid, Location loc, ArrayList siteLocs0, ArrayList siteLocs1, ArrayList siteLocs2, ArrayList siteLocs3){ + //TODO: Check w/ Jason about this... + //location container ID and cell container ID the same? if they at the same place? + Bag bag = new Bag(grid.getObjectsAtLocation(loc)); + int numAgents = bag.numObjs; + + if (numAgents == 0) { + for (int p = 0; p < latPositions; p++) { siteLocs0.add(loc); } + } + else if (numAgents == 1) { + for (int p = 0; p < latPositions; p++) { siteLocs1.add(loc); } + } + else if (numAgents == 2) { + for (int p = 0; p < latPositions; p++) { siteLocs2.add(loc); } + } + else { for (int p = 0; p < latPositions; p++) { siteLocs3.add(loc); } } + // Remove break statement if more than one per hex can appear + // with break statement, each location can only be added to list once + // without it, places with more vasc sites get added more times to list + //break; +} + +private void insert(ArrayList coordinates, PatchSimulation sim, PatchGrid grid ){ + //shuffle coordinates before cell insertion + Utilities.shuffleList(coordinates, sim.random); + + int cd4Code = 0; + int cd8Code = 0; + + //I need to grab the code using another method...maybe + for (MiniBox population : populations) { + String className = population.get("CLASS"); + if (className.equals("cart_cd4")) { + cd4Code = population.getInt("CODE"); + } + if (className.equals("cart_cd8")) { + cd8Code = population.getInt("CODE"); + } + } + + for (int i = 0; i < dose; i++) { + + int id = sim.getID(); + + int pop = cd4Code; + + if (sim.random.nextDouble() > treatFrac){ + pop = cd8Code; + } + + PatchLocation loc = ((PatchLocation) coordinates.remove(0)); + Coordinate coord = loc.getCoordinate(); + + //find available locaiton space + while (!coordinates.isEmpty() && !checkLocationSpace(sim, loc, grid)) { + loc = (PatchLocation) coordinates.remove(0); + } + + if (coordinates.isEmpty()) { + break; + } + + PatchLocationContainer locationContainer = new PatchLocationContainer(id, coord); + PatchCellContainer cellContainer = sim.cellFactory.createCellForPopulation(id, pop); + Location location = locationContainer.convert(sim.locationFactory, cellContainer); + PatchCell cell = (PatchCell) cellContainer.convert(sim.cellFactory, location); + + grid.addObject(cell, location); + cell.schedule(sim.getSchedule()); + } +} + +protected boolean checkLocationSpace(Simulation sim, Location loc, PatchGrid grid) { + boolean available; + int locMax = ((PatchLocation) loc).getMaximum(); + double locVolume = ((PatchLocation) loc).getVolume(); + double locArea = ((PatchLocation) loc).getArea(); + + // Iterate through each neighbor location and check if cell is able + // to move into it based on if it does not increase volume above hex + // volume and that each agent exists at tolerable height. + Bag bag = new Bag(grid.getObjectsAtLocation(loc)); + int n = bag.numObjs; // number of agents in location + + if (n == 0) { available = true; } // no cells in location + else if (n >= locMax) { available = false; } // location already full + else { + available = true; + //TODO: how do i access a constant like T cell vol average + double totalVol = PatchCell.calculateTotalVolume(bag); + //double totalVol = Cell.calcTotalVolume(bag) + sim.getSeries().getParam(treatPops[0], "T_CELL_VOL_AVG"); + double currentHeight = totalVol/locArea; + + // Check if total volume of cells with addition does not exceed + // volume of the hexagonal location. + if (totalVol > locVolume) { available = false; } + + // Check if all tissue cells can exist at a tolerable height. + for (Object cellObj : bag) { + PatchCell cell = (PatchCell)cellObj; + MiniBox cellParams = cell.getParameters(); + String className = cellParams.get("CLASS"); + if(className.equals("cart_cd4") || className.equals("cart_cd8")){ + totalVol = PatchCell.calculateTotalVolume(bag) + cell.getParameters().getDouble("T_CELL_VOL_AVG"); + currentHeight = totalVol/locArea; + } + if (className.equals("tissue") || className.equals("cancer") || className.equals("cancer_stem")) { + if (currentHeight > cell.getCriticalHeight()) { available = false; } + } + } + + } + + return available; +} + +} \ No newline at end of file From 566a23a9394547d8ba4bd04556baff6ea7ce51d7 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Wed, 23 Oct 2024 22:47:57 +0000 Subject: [PATCH 019/185] adding treat module --- .../patch/agent/action/PatchActionTreat.java | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/src/arcade/patch/agent/action/PatchActionTreat.java b/src/arcade/patch/agent/action/PatchActionTreat.java index d5f9555e6..4aba99dc8 100644 --- a/src/arcade/patch/agent/action/PatchActionTreat.java +++ b/src/arcade/patch/agent/action/PatchActionTreat.java @@ -84,7 +84,10 @@ public class PatchActionTreat implements Action { /** List of populations. */ private final ArrayList populations; - + + /** parameters */ + MiniBox parameters; + /** * Creates an {@code Action} to add agents after a delay. * @@ -99,6 +102,7 @@ public PatchActionTreat(Series series, MiniBox parameters) { this.treatFrac = parameters.getDouble("RATIO"); this.max_damage = parameters.getDouble("MAX_DAMAGE_SEED"); this.min_damage_radius = parameters.getDouble("MIN_RADIUS_SEED"); + this.parameters = parameters; this.coord = ((PatchSeries) series).patch.get("GEOMETRY").equalsIgnoreCase("HEX") ? "Hex" : "Rect"; if (coord == "Hex") { latPositions = 9; } @@ -171,11 +175,8 @@ public void step(SimState simstate) { //TODO: Can this just be random? Does each location necessarily need to be tied to a cell??? //PatchLocation loc = (PatchLocation) contain.convert(sim.locationFactory, sim.cellFactory.createCellForPopulation(sim.getID(), populations.get(0).getInt("CODE"))); PatchLocation loc = (PatchLocation) contain.convert(sim.locationFactory, sim.cellFactory.createCellForPopulation(0, populations.get(0).getInt("CODE"))); - //Something is crashing here CoordinateXYZ coord = (CoordinateXYZ) loc.getSubcoordinate(); int z = coord.z; - // Check of lattice location is a site (1 or 2) - // and if damage is not too severe to pass through vasculature if ( sitesLat[z][coord.x][coord.y] && damage[z][coord.x][coord.y] <= this.max_damage) { addCellsIntoList(grid, loc, siteLocs0, siteLocs1, siteLocs2, siteLocs3); } @@ -198,9 +199,7 @@ public void step(SimState simstate) { for (Object locObj : allEdgeLocs) { Location loc = (Location)locObj; - //check if locaiton within margine if (locs.contains(loc)) { - //check if radius is larger than minimum if (edge.getRadius() >= min_damage_radius) { addCellsIntoList(grid, loc, siteLocs0, siteLocs1, siteLocs2, siteLocs3); } @@ -209,8 +208,7 @@ public void step(SimState simstate) { } break; } - - // Sort location list in order of most to least tumor cells inside it. + Utilities.shuffleList(siteLocs3, sim.random); Utilities.shuffleList(siteLocs2, sim.random); Utilities.shuffleList(siteLocs1, sim.random); @@ -219,7 +217,8 @@ public void step(SimState simstate) { siteLocs.addAll(siteLocs2); siteLocs.addAll(siteLocs1); siteLocs.addAll(siteLocs0); - insert(siteLocs, sim, grid); + //insert(siteLocs, sim, grid); + insert(siteLocs, simstate); } private void addCellsIntoList(PatchGrid grid, LocationContainer l, PatchLocationContainer contain, PatchSimulation sim, ArrayList siteLocs0, ArrayList siteLocs1, ArrayList siteLocs2, ArrayList siteLocs3){ @@ -267,14 +266,14 @@ else if (numAgents == 2) { //break; } -private void insert(ArrayList coordinates, PatchSimulation sim, PatchGrid grid ){ - //shuffle coordinates before cell insertion +private void insert(ArrayList coordinates, SimState simstate ){ + PatchSimulation sim = (PatchSimulation) simstate; + PatchGrid grid = (PatchGrid) sim.getGrid(); Utilities.shuffleList(coordinates, sim.random); int cd4Code = 0; int cd8Code = 0; - //I need to grab the code using another method...maybe for (MiniBox population : populations) { String className = population.get("CLASS"); if (className.equals("cart_cd4")) { @@ -311,7 +310,6 @@ private void insert(ArrayList coordinates, PatchSimulation sim, PatchG PatchCellContainer cellContainer = sim.cellFactory.createCellForPopulation(id, pop); Location location = locationContainer.convert(sim.locationFactory, cellContainer); PatchCell cell = (PatchCell) cellContainer.convert(sim.cellFactory, location); - grid.addObject(cell, location); cell.schedule(sim.getSchedule()); } @@ -323,9 +321,7 @@ protected boolean checkLocationSpace(Simulation sim, Location loc, PatchGrid gri double locVolume = ((PatchLocation) loc).getVolume(); double locArea = ((PatchLocation) loc).getArea(); - // Iterate through each neighbor location and check if cell is able - // to move into it based on if it does not increase volume above hex - // volume and that each agent exists at tolerable height. + Bag bag = new Bag(grid.getObjectsAtLocation(loc)); int n = bag.numObjs; // number of agents in location @@ -333,22 +329,18 @@ protected boolean checkLocationSpace(Simulation sim, Location loc, PatchGrid gri else if (n >= locMax) { available = false; } // location already full else { available = true; - //TODO: how do i access a constant like T cell vol average double totalVol = PatchCell.calculateTotalVolume(bag); - //double totalVol = Cell.calcTotalVolume(bag) + sim.getSeries().getParam(treatPops[0], "T_CELL_VOL_AVG"); double currentHeight = totalVol/locArea; - // Check if total volume of cells with addition does not exceed - // volume of the hexagonal location. if (totalVol > locVolume) { available = false; } - // Check if all tissue cells can exist at a tolerable height. for (Object cellObj : bag) { PatchCell cell = (PatchCell)cellObj; MiniBox cellParams = cell.getParameters(); String className = cellParams.get("CLASS"); if(className.equals("cart_cd4") || className.equals("cart_cd8")){ - totalVol = PatchCell.calculateTotalVolume(bag) + cell.getParameters().getDouble("T_CELL_VOL_AVG"); + //totalVol = PatchCell.calculateTotalVolume(bag) + cell.getParameters().getDouble("T_CELL_VOL_AVG"); + totalVol = PatchCell.calculateTotalVolume(bag) + parameters.getDouble("T_CELL_VOL_AVG"); currentHeight = totalVol/locArea; } if (className.equals("tissue") || className.equals("cancer") || className.equals("cancer_stem")) { From 4aba068b62c831a32eb4d053c092b0441a53c637 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Wed, 23 Oct 2024 22:48:58 +0000 Subject: [PATCH 020/185] adding CART cell killing and reseting rule edits --- .../patch/agent/cell/PatchCellCART.java | 81 +++++++------ .../patch/agent/cell/PatchCellCARTCD4.java | 104 +++++++++-------- .../patch/agent/cell/PatchCellCARTCD8.java | 107 ++++++++++-------- 3 files changed, 160 insertions(+), 132 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index ee8e6163f..4e43a0994 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -9,6 +9,8 @@ import arcade.core.util.MiniBox; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; +import arcade.patch.util.PatchEnums.AntigenFlag; +import arcade.patch.util.PatchEnums.State; import arcade.core.sim.Simulation; import static arcade.patch.util.PatchEnums.State; @@ -156,7 +158,7 @@ public PatchCellCART(int id, int parent, int pop, CellState state, int age, int activated = true; // Set loaded parameters. - exhaustedFraction = parameters.getDouble( "EXHAUSTED_FRACTION"); + exhaustedFraction = parameters.getDouble( "EXHAU_FRAC"); senescentFraction = parameters.getDouble("SENESCENT_FRACTION"); anergicFraction = parameters.getDouble("ANERGIC_FRACTION"); proliferativeFraction = parameters.getDouble("PROLIFERATIVE_FRACTION"); @@ -171,7 +173,7 @@ public PatchCellCART(int id, int parent, int pop, CellState state, int age, int selfReceptorAffinity = parameters.getDouble("SELF_RECEPTOR_AFFINITY"); selfAlpha = parameters.getDouble("SELF_ALPHA"); selfBeta = parameters.getDouble("SELF_BETA"); - contactFraction = parameters.getDouble("CONTACT_FRACTION"); + contactFraction = parameters.getDouble("CONTACT_FRAC"); maxAntigenBinding = parameters.getInt("MAX_ANTIGEN_BINDING"); cars = parameters.getInt("CARS"); } @@ -189,7 +191,7 @@ public PatchCellCART(int id, int parent, int pop, CellState state, int age, int * @param random random seed */ - public void bindTarget(Simulation sim, PatchLocation loc, MersenneTwisterFast random) { + public PatchCellTissue bindTarget(Simulation sim, PatchLocation loc, MersenneTwisterFast random) { double KDCAR = carAffinity * (loc.getVolume() * 1e-15 * 6.022E23); double KDSelf = selfReceptorAffinity * (loc.getVolume() * 1e-15 * 6.022E23); PatchGrid grid = (PatchGrid) sim.getGrid(); @@ -206,8 +208,6 @@ public void bindTarget(Simulation sim, PatchLocation loc, MersenneTwisterFast ra } } - - //remove self allAgents.remove(this); @@ -221,52 +221,59 @@ public void bindTarget(Simulation sim, PatchLocation loc, MersenneTwisterFast ra int maxSearch = 0; if (neighbors == 0) { binding = AntigenFlag.UNBOUND; + return null; } else { if (neighbors < searchAbility) { maxSearch = neighbors; } else { maxSearch = (int) searchAbility; } - } + - // Within maximum search vicinity, search for neighboring cells to bind to - for (int i = 0; i < maxSearch; i++) { - Cell cell = (Cell) allAgents.get(i); - if (!(cell instanceof PatchCellCART) && cell.getState() != State.APOPTOTIC && cell.getState() != State.NECROTIC) { - PatchCellTissue tissueCell = (PatchCellTissue) cell; - double CARAntigens = tissueCell.carAntigens; - double selfTargets = tissueCell.selfTargets; + // Within maximum search vicinity, search for neighboring cells to bind to + for (int i = 0; i < maxSearch; i++) { + Cell cell = (Cell) allAgents.get(i); + if (!(cell instanceof PatchCellCART) && cell.getState() != State.APOPTOTIC && cell.getState() != State.NECROTIC) { + PatchCellTissue tissueCell = (PatchCellTissue) cell; + double CARAntigens = tissueCell.carAntigens; + double selfTargets = tissueCell.selfTargets; - double hillCAR = (CARAntigens*contactFraction/ (KDCAR*carBeta + CARAntigens*contactFraction))*(cars/50000)*carAlpha; - double hillSelf = (selfTargets*contactFraction / (KDSelf*selfBeta + selfTargets*contactFraction))*(selfReceptors/selfReceptorsStart)*selfAlpha; + double hillCAR = (CARAntigens*contactFraction/ (KDCAR*carBeta + CARAntigens*contactFraction))*(cars/50000)*carAlpha; + double hillSelf = (selfTargets*contactFraction / (KDSelf*selfBeta + selfTargets*contactFraction))*(selfReceptors/selfReceptorsStart)*selfAlpha; - double logCAR = 2*(1/(1 + Math.exp(-1*hillCAR))) - 1; - double logSelf = 2*(1/(1 + Math.exp(-1*hillSelf))) - 1; + double logCAR = 2*(1/(1 + Math.exp(-1*hillCAR))) - 1; + double logSelf = 2*(1/(1 + Math.exp(-1*hillSelf))) - 1; - double randomAntigen = random.nextDouble(); - double randomSelf = random.nextDouble(); + double randomAntigen = random.nextDouble(); + double randomSelf = random.nextDouble(); - if (logCAR >= randomAntigen && logSelf < randomSelf ) { - // cell binds to antigen receptor - binding = AntigenFlag.BOUND_ANTIGEN; - boundAntigensCount++; - selfReceptors += (int)((double)selfReceptorsStart * (0.95 + random.nextDouble()/10)); - } else if ( logCAR >= randomAntigen && logSelf >= randomSelf ) { - // cell binds to antigen receptor and self - binding = AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR; - boundAntigensCount++; - boundSelfCount++; - selfReceptors += (int)((double)selfReceptorsStart * (0.95 + random.nextDouble()/10)); - } else if ( logCAR < randomAntigen && logSelf >= randomSelf ) { - // cell binds to self - binding = AntigenFlag.BOUND_CELL_RECEPTOR; - boundSelfCount++; - } else { - // cell doesn't bind to anything - binding = AntigenFlag.UNBOUND; + if (logCAR >= randomAntigen && logSelf < randomSelf ) { + // cell binds to antigen receptor + binding = AntigenFlag.BOUND_ANTIGEN; + boundAntigensCount++; + selfReceptors += (int)((double)selfReceptorsStart * (0.95 + random.nextDouble()/10)); + return tissueCell; + } else if ( logCAR >= randomAntigen && logSelf >= randomSelf ) { + // cell binds to antigen receptor and self + binding = AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR; + boundAntigensCount++; + boundSelfCount++; + selfReceptors += (int)((double)selfReceptorsStart * (0.95 + random.nextDouble()/10)); + return tissueCell; + } else if ( logCAR < randomAntigen && logSelf >= randomSelf ) { + // cell binds to self + binding = AntigenFlag.BOUND_CELL_RECEPTOR; + boundSelfCount++; + return tissueCell; + } else { + // cell doesn't bind to anything + binding = AntigenFlag.UNBOUND; + } } } + binding = AntigenFlag.UNBOUND; } + return null; } /** diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 121862506..3a45310df 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -7,6 +7,8 @@ import arcade.core.env.location.Location; import arcade.core.sim.Simulation; import arcade.core.util.MiniBox; +import arcade.patch.agent.action.PatchActionReset; +import arcade.patch.sim.PatchSimulation; import arcade.patch.util.PatchEnums.AntigenFlag; import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.State; @@ -15,9 +17,6 @@ public class PatchCellCARTCD4 extends PatchCellCART{ - /** Fraction of stimulatory cells that become apoptotic. */ - private final double stimulatoryFraction; - /** * Creates a tissue {@code PatchCellCARTCD4} agent. * *

    @@ -48,8 +47,6 @@ public PatchCellCARTCD4(int id, int parent, int pop, CellState state, int age, i super(id, parent, pop, state, age, divisions, location, parameters, volume, height, criticalVolume, criticalHeight); - // Set loaded parameters. - stimulatoryFraction = parameters.getDouble( "STIMULATORY_FRACTION"); } @@ -77,7 +74,7 @@ public void step(SimState simstate) { if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { if (super.boundAntigensCount != 0) super.boundAntigensCount--; } - if (super.lastActiveTicker/1440 >- 7) super.activated = false; + if (super.lastActiveTicker/1440 >= 7) super.activated = false; // Step metabolism process. super.processes.get(Domain.METABOLISM).step(simstate.random, sim); @@ -87,10 +84,14 @@ public void step(SimState simstate) { if (state != State.APOPTOTIC && energy < 0) { if (super.energy < super.energyThreshold) { super.setState(State.APOPTOTIC); - } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED && state != State.STARVED && state != State.PROLIFERATIVE) { + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; + } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED && state != State.STARVED ) { super.setState(State.STARVED); + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; } - } else { + } else if (state == State.STARVED && energy >= 0) { super.setState(State.UNDEFINED); } @@ -98,58 +99,71 @@ public void step(SimState simstate) { super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); // Change state from undefined. - if (super.state == State.UNDEFINED || super.state == State.PAUSED) { + if (super.state == State.UNDEFINED|| super.state == State.PAUSED || super.state == State.QUIESCENT) { if (divisions == 0) { if (simstate.random.nextDouble() > super.senescentFraction) { super.setState(State.APOPTOTIC); } else { super.setState(State.SENESCENT); } - } - } else { - // Cell attempts to bind to a target - super.bindTarget(sim, location, new MersenneTwisterFast(simstate.seed())); - - //If cell is bound to both antigen and self it will become anergic. - if (binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { - if (simstate.random.nextDouble() > super.anergicFraction) { - super.setState(State.APOPTOTIC); - } else { - super.setState(State.ANERGIC); - } - } else if (binding == AntigenFlag.BOUND_ANTIGEN) { - // If cell is only bound to target antigen, the cell - // can potentially become properly activated. + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; + } else { + // Cell attempts to bind to a target + PatchCellTissue target = super.bindTarget(sim, location, new MersenneTwisterFast(simstate.seed())); - // Check overstimulation. If cell has bound to - // target antigens too many times, becomes exhausted. - if (boundAntigensCount > maxAntigenBinding) { - if (simstate.random.nextDouble() > super.exhaustedFraction) { + //If cell is bound to both antigen and self it will become anergic. + if (binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { + if (simstate.random.nextDouble() > super.anergicFraction) { super.setState(State.APOPTOTIC); } else { - super.setState(State.EXHAUSTED); + super.setState(State.ANERGIC); } - } else { - //if CD4 cell is properly activated, it can stimulate - if (simstate.random.nextDouble() > stimulatoryFraction) { - super.setState(State.APOPTOTIC); + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; + } else if (binding == AntigenFlag.BOUND_ANTIGEN) { + // If cell is only bound to target antigen, the cell + // can potentially become properly activated. + + // Check overstimulation. If cell has bound to + // target antigens too many times, becomes exhausted. + if (boundAntigensCount > maxAntigenBinding) { + if (simstate.random.nextDouble() > super.exhaustedFraction) { + super.setState(State.APOPTOTIC); + } else { + super.setState(State.EXHAUSTED); + } + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; } else { + //if CD4 cell is properly activated, it can stimulate super.setState(State.STIMULATORY); + //reset the cell + this.lastActiveTicker = 0; + this.activated = true; + if (target.isStopped()) { + target.binding = (AntigenFlag.UNBOUND); + } + target.setState(State.QUIESCENT); + this.binding = AntigenFlag.UNBOUND; + //need to reset + PatchActionReset reset = new PatchActionReset(this, simstate.random, ((PatchSimulation) simstate).getSeries(), parameters); + reset.schedule(sim.getSchedule()); + } - } - } else if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) { - //If self binding, unbind - super.setAntigenFlag(AntigenFlag.UNBOUND); - } else { - // Check activation status. If cell has been activated before, - // it will proliferate. If not, it will migrate. - if (activated) { - super.setState(State.PROLIFERATIVE); } else { - if (simstate.random.nextDouble() > super.proliferativeFraction) { - super.setState(State.MIGRATORY); - } else { + //If self binding, unbind + if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) super.setAntigenFlag(AntigenFlag.UNBOUND); + // Check activation status. If cell has been activated before, + // it will proliferate. If not, it will migrate. + if (activated) { super.setState(State.PROLIFERATIVE); + } else { + if (simstate.random.nextDouble() > super.proliferativeFraction) { + super.setState(State.MIGRATORY); + } else { + super.setState(State.PROLIFERATIVE); + } } } } diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index 1a71c949a..780e95052 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -4,6 +4,9 @@ import arcade.core.env.location.Location; import arcade.core.sim.Simulation; import arcade.core.util.MiniBox; +import arcade.patch.agent.action.PatchActionKill; +import arcade.patch.agent.action.PatchActionReset; +import arcade.patch.sim.PatchSimulation; import arcade.patch.util.PatchEnums.AntigenFlag; import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.State; @@ -11,10 +14,6 @@ import sim.engine.SimState; public class PatchCellCARTCD8 extends PatchCellCART { - - /** Fraction of cytotoxic cells that become apoptotic. */ - private final double cytotoxicFraction; - /** * Creates a tissue {@code PatchCellCARTCD8} agent. * *

    @@ -44,11 +43,6 @@ public PatchCellCARTCD8(int id, int parent, int pop, CellState state, int age, i super(id, parent, pop, state, age, divisions, location, parameters, volume, height, criticalVolume, criticalHeight); - - // Set loaded parameters. - cytotoxicFraction = parameters.getDouble( "CYTOTOXIC_FRACTION"); - - } @Override @@ -75,7 +69,7 @@ public void step(SimState simstate) { if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { if (super.boundAntigensCount != 0) super.boundAntigensCount--; } - if (super.lastActiveTicker/1440 >- 7) super.activated = false; + if (super.lastActiveTicker/1440 > 7) super.activated = false; // Step metabolism process. super.processes.get(Domain.METABOLISM).step(simstate.random, sim); @@ -85,69 +79,82 @@ public void step(SimState simstate) { if (state != State.APOPTOTIC && energy < 0) { if (super.energy < super.energyThreshold) { super.setState(State.APOPTOTIC); - } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED && state != State.STARVED && state != State.PROLIFERATIVE) { + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; + } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED && state != State.STARVED ) { super.setState(State.STARVED); + super.setAntigenFlag(AntigenFlag.UNBOUND); } - } else { + } else if (state == State.STARVED && energy >= 0) { super.setState(State.UNDEFINED); } // Step inflammation process. - //super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); + super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); // Change state from undefined. - if (super.state == State.UNDEFINED || super.state == State.PAUSED) { + if (super.state == State.UNDEFINED|| super.state == State.PAUSED || super.state == State.QUIESCENT) { if (divisions == 0) { if (simstate.random.nextDouble() > super.senescentFraction) { super.setState(State.APOPTOTIC); } else { super.setState(State.SENESCENT); } - } - } else { - // Cell attempts to bind to a target - super.bindTarget(sim, location, new MersenneTwisterFast(simstate.seed())); - - //If cell is bound to both antigen and self it will become anergic. - if (binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { - if (simstate.random.nextDouble() > super.anergicFraction) { - super.setState(State.APOPTOTIC); - } else { - super.setState(State.ANERGIC); - } - } else if (binding == AntigenFlag.BOUND_ANTIGEN) { - // If cell is only bound to target antigen, the cell - // can potentially become properly activated. + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; + } else { + // Cell attempts to bind to a target + PatchCellTissue target = super.bindTarget(sim, location, simstate.random); - // Check overstimulation. If cell has bound to - // target antigens too many times, becomes exhausted. - if (boundAntigensCount > maxAntigenBinding) { - if (simstate.random.nextDouble() > super.exhaustedFraction) { + //If cell is bound to both antigen and self it will become anergic. + if (binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { + if (simstate.random.nextDouble() > super.anergicFraction) { super.setState(State.APOPTOTIC); } else { - super.setState(State.EXHAUSTED); + super.setState(State.ANERGIC); } - } else { - //if CD4 cell is properly activated, it can stimulate - if (simstate.random.nextDouble() > cytotoxicFraction) { - super.setState(State.APOPTOTIC); + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; + } else if (binding == AntigenFlag.BOUND_ANTIGEN) { + // If cell is only bound to target antigen, the cell + // can potentially become properly activated. + + // Check overstimulation. If cell has bound to + // target antigens too many times, becomes exhausted. + if (boundAntigensCount > maxAntigenBinding) { + if (simstate.random.nextDouble() > super.exhaustedFraction) { + super.setState(State.APOPTOTIC); + } else { + super.setState(State.EXHAUSTED); + } + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; } else { + //if CD4 cell is properly activated, it can stimulate + this.lastActiveTicker = 0; + this.activated = true; super.setState(State.CYTOTOXIC); + //need to call kill + PatchActionKill kill = new PatchActionKill(this, target, simstate.random,((PatchSimulation) simstate).getSeries(), parameters); + kill.schedule(sim.getSchedule()); + //need to reset + PatchActionReset reset = new PatchActionReset(this, simstate.random, ((PatchSimulation) simstate).getSeries(), parameters); + reset.schedule(sim.getSchedule()); + } - } - } else if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) { - //If self binding, unbind - super.setAntigenFlag(AntigenFlag.UNBOUND); - } else { - // Check activation status. If cell has been activated before, - // it will proliferate. If not, it will migrate. - if (activated) { - super.setState(State.PROLIFERATIVE); } else { - if (simstate.random.nextDouble() > super.proliferativeFraction) { - super.setState(State.MIGRATORY); - } else { + //If self binding, unbind + if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) super.setAntigenFlag(AntigenFlag.UNBOUND); + // Check activation status. If cell has been activated before, + // it will proliferate. If not, it will migrate. + if (activated) { super.setState(State.PROLIFERATIVE); + } else { + if (simstate.random.nextDouble() > super.proliferativeFraction) { + super.setState(State.MIGRATORY); + } else { + super.setState(State.PROLIFERATIVE); + } } } } From 12cd23c19ced40604e2ab2c95bc527f36bb07a87 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Wed, 23 Oct 2024 22:50:09 +0000 Subject: [PATCH 021/185] changing kill scheduling functionality --- .../patch/agent/module/PatchModuleKill.java | 122 ------------------ 1 file changed, 122 deletions(-) delete mode 100644 src/arcade/patch/agent/module/PatchModuleKill.java diff --git a/src/arcade/patch/agent/module/PatchModuleKill.java b/src/arcade/patch/agent/module/PatchModuleKill.java deleted file mode 100644 index b51fad024..000000000 --- a/src/arcade/patch/agent/module/PatchModuleKill.java +++ /dev/null @@ -1,122 +0,0 @@ -package arcade.patch.agent.module; - -import arcade.core.agent.process.ProcessDomain; -import arcade.core.sim.Simulation; -import arcade.patch.sim.PatchSimulation; -import arcade.core.util.MiniBox; -import arcade.patch.agent.cell.PatchCell; -import arcade.patch.agent.cell.PatchCellCART; -import arcade.patch.agent.cell.PatchCellTissue; -import arcade.patch.agent.process.PatchProcess; -import arcade.patch.agent.process.PatchProcessInflammation; -import arcade.patch.util.PatchEnums.AntigenFlag; -import arcade.patch.util.PatchEnums.Domain; -import arcade.patch.util.PatchEnums.State; -import ec.util.MersenneTwisterFast; -import sim.engine.SimState; - -// collaprse reset with kill - -public class PatchModuleKill extends PatchModule { - /** The {@link PatchCell} the module is associated with. */ - - //immune cell itself - PatchCellCART cellImmune; - - /** Target cell cytotoxic CAR T-cell is bound to */ - PatchCell target; - - /** CAR T-cell inflammation module */ - PatchProcessInflammation inflammation; - - /** Amount of granzyme inside CAR T-cell */ - double granzyme; - - /** - * Creates a proliferation {@link PatchModule} for the given cell. - *

    - * Loaded parameters include: - *

      - *
    • {@code SYNTHESIS_DURATION} = time required for DNA synthesis
    • - *
    - * - * @param cell the {@link PatchCell} the module is associated with - */ - public PatchModuleKill(PatchCell inputCell, PatchCell target) { - super(inputCell); - //I have to override this.cell bc patchmodule can only take patch cells - this.cellImmune = (PatchCellCART) inputCell; - this.target = target; - this.inflammation = (PatchProcessInflammation) cell.getProcess(Domain.INFLAMMATION); - this.granzyme = inflammation.getInternal("granzyme"); - } - - @Override - public void step(MersenneTwisterFast random, Simulation sim) { - PatchSimulation growthSim = (PatchSimulation) sim; - - // If current CAR T-cell is stopped, stop helper. - if (cellImmune.isStopped()) { return; } - - // If bound target cell is stopped, stop helper. - - //All cells need isStopped method - if (target.isStopped()) { stop(); return; } - - if (granzyme >= 1) { - // Kill bound target cell. - PatchCellTissue tissueCell = (PatchCellTissue) target; - - //setState? - tissueCell.setState(State.APOPTOTIC); - - //what is this - growthSim.lysedCells.add(recordLysis(sim, target)); - - // Use up some granzyme in the process. - granzyme--; - inflammation.setInternal("granzyme", granzyme); - reset(cellImmune); - } - } - - /** - * Stops the helper from if can't kill target. - * - * @param sim the simulation instance - */ - private void stop() { - // Unbind from target. - if (cellImmune.binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { - cellImmune.setAntigenFlag(AntigenFlag.BOUND_CELL_RECEPTOR); - } else { - cellImmune.setAntigenFlag(AntigenFlag.UNBOUND); - } - // Stop helper and set cell type to neutral. - cell.setState(State.QUIESCENT); - } - - /** - * Steps the helper for killing target cell. - *

    - * The String is formatted as: - *

    -	 *     [time of death, [location], [ code, pop, type, position, volume, age, [ list, of, cycle, lengths, ... ] ] ]
    -	 * 
    - */ - private String recordLysis(PatchSimulation sim, PatchCell cell) { - //what is the toJSON equivalent in 3.0? - - //TODO: get toJSON version of the stuff - return "[" + sim.getSchedule().getTime() + "," + cell.getLocation() + "," + cell + "]"; - } - - //for now this is unscheduled... - private void reset(PatchCellCART cell) { - if (cell.getState() == State.CYTOTOXIC || cell.getState() == State.STIMULATORY) { - // Return to neutral state and reset flags to make a new state decision. - cell.setAntigenFlag(AntigenFlag.UNDEFINED); - cell.setState(State.QUIESCENT); - } - } -} From eda1b22ba8250396290a48bf912a3bfff0a1b3e9 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Wed, 23 Oct 2024 22:50:44 +0000 Subject: [PATCH 022/185] changing reset action scheduling functionalities --- .../patch/agent/action/PatchActionReset.java | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/arcade/patch/agent/action/PatchActionReset.java diff --git a/src/arcade/patch/agent/action/PatchActionReset.java b/src/arcade/patch/agent/action/PatchActionReset.java new file mode 100644 index 000000000..1eddccdd0 --- /dev/null +++ b/src/arcade/patch/agent/action/PatchActionReset.java @@ -0,0 +1,82 @@ +package arcade.patch.agent.action; + +import arcade.core.agent.action.Action; +import arcade.core.agent.process.ProcessDomain; +import arcade.core.sim.Series; +import arcade.core.sim.Simulation; +import arcade.core.util.MiniBox; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.patch.agent.cell.PatchCellTissue; +import arcade.patch.agent.process.PatchProcessInflammation; +import arcade.patch.util.PatchEnums.AntigenFlag; +import arcade.patch.util.PatchEnums.Domain; +import arcade.patch.util.PatchEnums.Ordering; +import arcade.patch.util.PatchEnums.State; +import ec.util.MersenneTwisterFast; +import sim.engine.Schedule; +import sim.engine.SimState; + +/** + * Implementation of {@link Action} for killing tissue agents. + *

    + * {@code PatchActionKill} is stepped once after a CD8 CAR T-cell binds to a + * target tissue cell. + * The {@code PatchActionKill} determines if cell has enough granzyme to kill. + * If so, it kills cell and calls the reset to neutral helper to return to neutral state. + * If not, it waits until it has enough granzyme to kill cell. + */ + +public class PatchActionReset implements Action { + + + /** CAR T-cell inflammation module */ + PatchProcessInflammation inflammation; + + /** Amount of granzyme inside CAR T-cell */ + double granzyme; + + /** CAR T-cell that the module is linked to */ + PatchCellCART c; + + /** Time delay before calling the action [min]. */ + private final int timeDelay; + + /** + * Creates a {@code PatchActionKill} for the given + * {@link arcade.patch.agent.cell.PatchCellCART}. + * + * @param c the {@link arcade.patch.agent.cell.PatchCellCART} the helper is associated with + * @param target the {@link arcade.patch.agent.cell.PatchCellTissue} the CAR T-cell is bound to + */ + + public PatchActionReset(PatchCellCART c, MersenneTwisterFast random, Series series, MiniBox parameters) { + this.c = c; + double boundTime = parameters.getInt("BOUND_TIME"); + double boundRange = parameters.getInt("BOUND_RANGE"); + timeDelay = (int)(boundTime + Math.round((boundRange*(2*random.nextInt() - 1)))); + } + + @Override + public void schedule(Schedule schedule) { + schedule.scheduleOnce(schedule.getTime() + timeDelay, Ordering.ACTIONS.ordinal(), this); + } + + @Override + public void register(Simulation sim, String population) {} + + @Override + public void step(SimState state) { + Simulation sim = (Simulation)state; + + // If current CAR T-cell is stopped, stop helper. + if (c.isStopped()) {return; } + + if (c.getState() == State.CYTOTOXIC || c.getState() == State.STIMULATORY) { + c.binding = AntigenFlag.UNBOUND; + c.setState(State.QUIESCENT); + } + //this.schedule(sim.getSchedule()); + } + + +} From 85ee85b6411a6b5b37e774755ac19a1c632ee8bb Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Wed, 23 Oct 2024 22:51:22 +0000 Subject: [PATCH 023/185] editing CART metabolism stepping rules --- .../process/PatchProcessMetabolismCART.java | 238 ++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 src/arcade/patch/agent/process/PatchProcessMetabolismCART.java diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java new file mode 100644 index 000000000..c80e74c97 --- /dev/null +++ b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java @@ -0,0 +1,238 @@ +package arcade.patch.agent.process; + +import java.util.Arrays; + +import arcade.core.sim.Simulation; +import arcade.core.util.MiniBox; +import arcade.patch.agent.cell.PatchCell; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.patch.util.PatchEnums.Domain; +import ec.util.MersenneTwisterFast; + + +public class PatchProcessMetabolismCART extends PatchProcessMetabolismComplex { + + /** ID for pyruvate */ + public static final int PYRUVATE = 1; + + /** Flag indicating T-cell's antigen induced activation state. */ + private boolean active; + + /** Metabolic preference for glycolysis over oxidative phosphorylation */ + private final double metaPref; + + /** Minimal cell mass */ + private final double fracMass; + + /** Fraction of internal glucose/pyruvate converted to mass. */ + private final double conversionFraction; + + /** Preference for glucose over pyruvate for mass */ + private final double ratioGlucosePyruvate; + + /** Rate of lactate production */ + private final double lactateRate; + + /** Rate of autophagy */ + private final double autophagyRate; + + /** Rate of glucose uptake */ + private final double glucUptakeRate; + + /** Max incrase in metabolic preference for glycolysis over oxidative phosphorylation */ + private final double metabolicPreference_IL2; + + /** Increase in rate of glucose uptake due antigen-induced activation */ + private final double metabolicPreference_active; + + /** Max increase in rate of glucose uptake due to IL-2 bound to surface */ + private final double glucoseUptakeRate_IL2; + + /** Increase in rate of glucose uptake due to antigen-induced activation. */ + private final double glucoseUptakeRate_active; + + /** Increase in fraction of glucose used for cell mass due to antigen-induced activation. */ + private final double minimumMassFraction_active; + + /** Time delay for changes in metabolism. */ + private final int timeDelay; + + /** + * Creates a metabolism {@link PatchProcess} for the given cell. + *

    + * Process parameters are specific for the cell population. + * Loaded parameters include: + *

      + *
    • {@code METABOLIC_PREFERENCE} = preference for glycolysis over + * oxidative phosphorylation
    • + *
    • {@code CONVERSION_FRACTION} = fraction of internal glucose / + * pyruvate converted to mass
    • + *
    • {@code MINIMUM_MASS_FRACTION} = minimum viable cell mass + * fraction
    • + *
    • {@code RATIO_GLUCOSE_PYRUVATE} = preference for glucose over + * pyruvate for mass
    • + *
    • {@code LACTATE_RATE} = rate of lactate production
    • + *
    • {@code AUTOPHAGY_RATE} = rate of autophagy
    • + *
    • {@code GLUCOSE_UPTAKE_RATE} = rate of glucose uptake
    • + *
    + * The process starts with energy at zero and assumes a constant ratio + * between mass and volume (through density). + * + * @param cell the {@link PatchCell} the process is associated with + */ + public PatchProcessMetabolismCART(PatchCell cell) { + super(cell); + // Initial internal concentrations. + intAmts = new double[2]; + intAmts[GLUCOSE] = extAmts[GLUCOSE]; + intAmts[PYRUVATE] = extAmts[GLUCOSE] * PYRU_PER_GLUC; + + // Mapping for internal concentration access. + String[] intNames = new String[2]; + intNames[GLUCOSE] = "glucose"; + intNames[PYRUVATE] = "pyruvate"; + names = Arrays.asList(intNames); + + // Set loaded parameters. + // TODO: pull metabolic preference from distribution + MiniBox parameters = cell.getParameters(); + metaPref = parameters.getDouble("metabolism/METABOLIC_PREFERENCE"); + conversionFraction = parameters.getDouble("metabolism/CONVERSION_FRACTION"); + fracMass = parameters.getDouble("metabolism/MINIMUM_MASS_FRACTION"); + ratioGlucosePyruvate = parameters.getDouble("metabolism/RATIO_GLUCOSE_PYRUVATE"); + lactateRate = parameters.getDouble("metabolism/LACTATE_RATE"); + autophagyRate = parameters.getDouble("metabolism/AUTOPHAGY_RATE"); + glucUptakeRate = parameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE"); + + metabolicPreference_IL2 = parameters.getDouble("metabolism/META_PREF_IL2"); + metabolicPreference_active = parameters.getDouble("metabolism/META_PREF_ACTIVE"); + glucoseUptakeRate_IL2 = parameters.getDouble("metabolism/GLUC_UPTAKE_RATE_IL2"); + glucoseUptakeRate_active = parameters.getDouble("metabolism/GLUC_UPTAKE_RATE_ACTIVE"); + minimumMassFraction_active = parameters.getDouble("metabolism/FRAC_MASS_ACTIVE"); + timeDelay = (int) parameters.getDouble("metabolism/META_SWITCH_DELAY"); + } + + @Override + void stepProcess(MersenneTwisterFast random, Simulation sim) { + double glucInt = intAmts[GLUCOSE]; // [fmol] + double pyruInt = intAmts[PYRUVATE]; // [fmol] + double glucExt = extAmts[GLUCOSE]; // [fmol] + double oxyExt = extAmts[OXYGEN]; // [fmol] + + PatchProcessInflammation inflammation = (PatchProcessInflammation) cell.getProcess(Domain.INFLAMMATION); + double[] boundArray = inflammation.boundArray; // [molecules] + int IL2Ticker = inflammation.IL2Ticker; + double IL2ReceptorsTotal = inflammation.IL2_RECEPTORS; + + int metaIndex = (IL2Ticker % boundArray.length) - timeDelay; + if (metaIndex < 0) { metaIndex += boundArray.length; } + double priorIL2meta = boundArray[metaIndex]; + + // Calculate metabolic preference and glucose uptake rate + // as a function of base values plus impact of IL-2 bound to surface. + double metabolicPreference = metaPref + (metabolicPreference_IL2 * (priorIL2meta/IL2ReceptorsTotal)); + double glucoseUptakeRate = glucUptakeRate + (glucoseUptakeRate_IL2 * (priorIL2meta/IL2ReceptorsTotal)); + double minimumMassFraction = fracMass; + + // Check active status + active = ((PatchCellCART) cell).getActivationStatus(); + double activeTicker = inflammation.activeTicker; + + // Add metabolic preference and glucose uptake rate depdendent on + // antigen-induced cell activation if cell is activated. + if (active && activeTicker >= timeDelay) { + metabolicPreference += metabolicPreference_active; + glucoseUptakeRate += glucoseUptakeRate_active; + minimumMassFraction += minimumMassFraction_active; + } + + // Take up glucose from environment, relative to glucose gradient. + // If agent shares location with other agents, occupied area for + // calculating surface area is limited by the number of neighbors. + double area = location.getArea() * f; + double surfaceArea = area * 2 + (volume / area) * location.getPerimeter(f); + double glucGrad = (glucExt / location.getVolume()) - (glucInt / volume); + glucGrad *= glucGrad < 1E-10 ? 0 : 1; + double glucUptake = glucoseUptakeRate * surfaceArea * glucGrad; + glucInt += glucUptake; + + // Determine energy requirement given current type in terms of glucose. + // Additional energy needed for cell that is migrating or proliferating. + // Arrays indicate oxidative phosphorylation (0) and glycolysis (1). + double[] energyGen = { 0, 0 }; + double glucReq = metabolicPreference * energyReq / ENERGY_FROM_GLYC; + double pyruReq = (1 - metabolicPreference) * energyReq / ENERGY_FROM_OXPHOS; + + // Calculate oxygen required and take up from environment. + double oxyReq = pyruReq * OXY_PER_PYRU; + double oxyUptake = Math.min(oxyExt, oxyReq); + oxyUptake *= oxyUptake < 1E-10 ? 0 : 1; + + // Perform oxidative phosphorylation using internal pyruvate. + double oxyUptakeInPyru = oxyUptake / OXY_PER_PYRU; + if (pyruInt > oxyUptakeInPyru) { + energyGen[0] += oxyUptakeInPyru * ENERGY_FROM_OXPHOS; // add energy + pyruInt -= oxyUptakeInPyru; // use up internal pyruvate + } else { + energyGen[0] += pyruInt * ENERGY_FROM_OXPHOS; // add energy + oxyUptake = pyruInt * OXY_PER_PYRU; // return unused oxygen + pyruInt = 0.0; // use up internal pyruvate + } + + // Check if more glucose needs to be diverted to compensate for energy + // deficit (from not enough oxygen) and is available. + if (energy <= 0 && glucInt > 0) { + double glucNeeded = -(energy - energyCons + energyGen[0]) / ENERGY_FROM_GLYC; + glucReq = Math.max(glucReq, glucNeeded); + } + + // Perform glycolysis. Internal glucose is converted to internal pyruvate + // which is used in oxidative phosphorylation or to increase mass. + if (glucInt > glucReq) { + energyGen[1] += glucReq * ENERGY_FROM_GLYC; + pyruInt += glucReq * PYRU_PER_GLUC; // increase internal pyruvate + glucInt -= glucReq; // use up internal glucose + } else { + energyGen[1] += glucInt * ENERGY_FROM_GLYC; + pyruInt += glucInt * PYRU_PER_GLUC; // increase internal pyruvate + glucInt = 0.0; // use up all internal glucose + } + + // Update energy. + energy += energyGen[0]; + energy += energyGen[1]; + energy -= energyCons; + energy *= Math.abs(energy) < 1E-10 ? 0 : 1; + + // Increase mass if (i) dividing and less than double mass or (ii) + // below critical mass for maintenance. + if ((energy >= 0 && isProliferative && mass < 2 * critMass) + || (energy >= 0 && mass < 0.99 * critMass)) { + mass += conversionFraction * (ratioGlucosePyruvate * glucInt + + (1 - ratioGlucosePyruvate) * pyruInt / PYRU_PER_GLUC) / ratioGlucoseBiomass; + glucInt *= (1 - conversionFraction * ratioGlucosePyruvate); + pyruInt *= (1 - conversionFraction * (1 - ratioGlucosePyruvate)); + } + + // Decrease mass through autophagy if (i) negative energy indicating + // not enough nutrients or (ii) above critical mass for maintenance + if ((energy < 0 && mass > minimumMassFraction * critMass) + || (energy >= 0 && mass > 1.01 * critMass && !isProliferative)) { + mass -= autophagyRate; + glucInt += autophagyRate * ratioGlucoseBiomass; + } + + // Update volume based on changes in mass. + volume = mass / cellDensity; + + // Convert internal pyruvate to lactate (i.e. remove pyruvate). + pyruInt -= lactateRate * pyruInt; + + // Reset values. + intAmts[GLUCOSE] = glucInt; + upAmts[GLUCOSE] = glucUptake; + upAmts[OXYGEN] = oxyUptake; + intAmts[PYRUVATE] = pyruInt; + } + +} From 5db743942786784f9337aa9e2f8580027bcf235f Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Wed, 23 Oct 2024 22:52:10 +0000 Subject: [PATCH 024/185] changing inflammation rules --- .../process/PatchProcessInflammation.java | 21 ++++++++++++------- .../process/PatchProcessInflammationCD4.java | 2 +- .../process/PatchProcessInflammationCD8.java | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index 76837f03d..0ba7d67f1 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -135,11 +135,11 @@ public PatchProcessInflammation(PatchCellCART c) { // Set parameters. MiniBox parameters = cell.getParameters(); - this.SHELL_THICKNESS = parameters.getDouble("SHELL_THICKNESS"); - this.IL2_RECEPTORS = parameters.getDouble("IL2_RECEPTORS"); - this.IL2_BINDING_ON_RATE_MIN = parameters.getDouble("IL2_BINDING_ON_RATE_MIN"); - this.IL2_BINDING_ON_RATE_MAX = parameters.getDouble("IL2_BINDING_ON_RATE_MAX"); - this.IL2_BINDING_OFF_RATE = parameters.getDouble("IL2_BINDING_OFF_RATE"); + this.SHELL_THICKNESS = parameters.getDouble("inflammation/SHELL_THICKNESS"); + this.IL2_RECEPTORS = parameters.getDouble("inflammation/IL2_RECEPTORS"); + this.IL2_BINDING_ON_RATE_MIN = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MIN"); + this.IL2_BINDING_ON_RATE_MAX = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MAX"); + this.IL2_BINDING_OFF_RATE = parameters.getDouble("inflammation/IL2_BINDING_OFF_RATE"); // Set external concentrations. //updateExternal(sim); @@ -207,6 +207,13 @@ public void setInternal(String key, double val) { amts[names.indexOf(key)] = val; } + /** + * Steps the metabolism process. + * + * @param random the random number generator + * @param sim the simulation instance + */ + abstract void stepProcess(MersenneTwisterFast random, Simulation sim); /** * Gets the external amounts of IL-2. @@ -223,7 +230,7 @@ private void updateExternal(Simulation sim) { } // METHOD: stepModule. - public void stepProcess(MersenneTwisterFast random, Simulation sim) { + public void step(MersenneTwisterFast random, Simulation sim) { // Calculate shell volume 2 um outside of cell. double radCell = Math.cbrt((3.0/4.0)*(1.0/Math.PI)*volume); double radShell = radCell + SHELL_THICKNESS; @@ -247,7 +254,7 @@ public void stepProcess(MersenneTwisterFast random, Simulation sim) { amts = Solver.rungeKutta(dydt, 0, amts, 60, STEP_SIZE); // Modify internal inflammation response. - step(random, sim); + stepProcess(random, sim); // Update bound array. boundArray[IL2Ticker % boundArray.length] = amts[IL2_INT_TOTAL]; diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java index 3308e5577..e4fbcc793 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java @@ -58,7 +58,7 @@ public PatchProcessInflammationCD4(PatchCellCART c) { @Override - public void step(MersenneTwisterFast random, Simulation sim) { + public void stepProcess(MersenneTwisterFast random, Simulation sim) { // Determine IL-2 production rate as a function of IL-2 bound. int prodIndex = (IL2Ticker % boundArray.length) - IL2_SYNTHESIS_DELAY; diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index fe52b2141..d8914f219 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -40,7 +40,7 @@ public PatchProcessInflammationCD8(PatchCellCART c) { names.add(GRANZYME, "granzyme"); } - public void step(MersenneTwisterFast random, Simulation sim) { + public void stepProcess(MersenneTwisterFast random, Simulation sim) { // Determine amount of granzyme production based on if cell is activated // as a function of IL-2 production. From fd177cc495f62f4dee3b9b5e6604a65bf6bdc882 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Thu, 24 Oct 2024 20:59:38 +0000 Subject: [PATCH 025/185] adding antigen and target parameters in patch cells --- src/arcade/patch/agent/cell/PatchCellTissue.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index a0b30b4e3..b79c292a5 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -4,6 +4,10 @@ import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.util.MiniBox; +import arcade.patch.util.PatchEnums.AntigenFlag; +import arcade.patch.util.PatchEnums.Domain; +import arcade.patch.util.PatchEnums.Flag; +import arcade.patch.util.PatchEnums.State; import sim.engine.SimState; import arcade.core.sim.Simulation; import static arcade.patch.util.PatchEnums.Domain; @@ -30,6 +34,9 @@ public class PatchCellTissue extends PatchCell { /** Cell surface PDL1 count */ int selfTargets; + /** Cell binding flag */ + public AntigenFlag binding; + /** * Creates a tissue {@code PatchCell} agent. @@ -70,6 +77,7 @@ public PatchCellTissue(int id, int parent, int pop, CellState state, int age, in //These default to 0 if not present in input carAntigens = parameters.getInt("CAR_ANTIGENS"); selfTargets = parameters.getInt("SELF_TARGETS"); + this.binding = AntigenFlag.UNDEFINED; } @Override From b6b76cb72ce6123035316ec4e5ae6b1b74a8113c Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Thu, 24 Oct 2024 21:00:39 +0000 Subject: [PATCH 026/185] adding CAR-T specific parameters to parameter file --- src/arcade/patch/parameter.patch.xml | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index 24180f8ca..483bc3721 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -20,14 +20,16 @@ + + + - + - @@ -42,7 +44,8 @@ - + + @@ -72,18 +75,18 @@ + + + + + + + - - - - - - - @@ -124,8 +127,11 @@ + + + - + From 691a5406aa61c4f4c4436905264ad7a59237d073 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Wed, 13 Nov 2024 23:12:47 +0000 Subject: [PATCH 027/185] debugging CART metabolism --- .../patch/agent/cell/PatchCellCARTCD4.java | 7 --- .../module/PatchModuleProliferation.java | 17 +++++-- .../process/PatchProcessInflammation.java | 2 +- .../process/PatchProcessInflammationCD4.java | 12 ++--- .../process/PatchProcessInflammationCD8.java | 7 +-- .../agent/process/PatchProcessMetabolism.java | 4 ++ .../process/PatchProcessMetabolismCART.java | 48 +++++++++++++++++-- 7 files changed, 70 insertions(+), 27 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index b219dcc9a..aa342124b 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -1,9 +1,5 @@ package arcade.patch.agent.cell; - -import java.util.Set; - import arcade.core.agent.cell.CellState; -import arcade.core.agent.process.ProcessDomain; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; import arcade.core.util.MiniBox; @@ -52,10 +48,7 @@ public PatchCellCARTCD4(int id, int parent, int pop, CellState state, int age, i @Override public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFast random) { - divisions--; - // return new PatchCellCARTCD4(newID, id, pop, newState, age, divisions, newLocation, - // parameters, volume, height, criticalVolume, criticalHeight); return new PatchCellContainer( newID, id, diff --git a/src/arcade/patch/agent/module/PatchModuleProliferation.java b/src/arcade/patch/agent/module/PatchModuleProliferation.java index f76740799..63cd5cd74 100644 --- a/src/arcade/patch/agent/module/PatchModuleProliferation.java +++ b/src/arcade/patch/agent/module/PatchModuleProliferation.java @@ -6,6 +6,7 @@ import arcade.core.sim.Simulation; import arcade.core.util.MiniBox; import arcade.patch.agent.cell.PatchCell; +import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.agent.process.PatchProcess; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; @@ -53,7 +54,11 @@ public PatchModuleProliferation(PatchCell cell) { // Set loaded parameters. MiniBox parameters = cell.getParameters(); - synthesisDuration = parameters.getInt("proliferation/SYNTHESIS_DURATION"); + if (cell instanceof PatchCellCART) { + synthesisDuration = parameters.getInt("proliferation/T_CELL_SYNTHESIS_DURATION"); + } else { + synthesisDuration = parameters.getInt("proliferation/SYNTHESIS_DURATION"); + } } @Override @@ -103,9 +108,13 @@ public void step(MersenneTwisterFast random, Simulation sim) { // Update processes. PatchProcess metabolism = (PatchProcess) newCell.getProcess(Domain.METABOLISM); metabolism.update(cell.getProcess(Domain.METABOLISM)); - PatchProcess signaling = (PatchProcess) newCell.getProcess(Domain.SIGNALING); - signaling.update(cell.getProcess(Domain.SIGNALING)); - + if (cell instanceof PatchCellCART) { + PatchProcess inflammation = (PatchProcess) newCell.getProcess(Domain.INFLAMMATION); + inflammation.update(cell.getProcess(Domain.INFLAMMATION)); + } else { + PatchProcess signaling = (PatchProcess) newCell.getProcess(Domain.SIGNALING); + signaling.update(cell.getProcess(Domain.SIGNALING)); + } // TODO: Update environment generator sites. } else { ticker++; diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index 0ba7d67f1..c94018b56 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -171,7 +171,7 @@ public PatchProcessInflammation(PatchCellCART c) { /** * System of ODEs for network */ - Equations dydt = (Equations & Serializable) (t, y) -> { + Equations dydt = (Equations & Serializable) (t, y) -> { double[] dydt = new double[NUM_COMPONENTS]; double kon_2 = IL2_BINDING_ON_RATE_MIN/loc.getVolume()/60/STEP_DIVIDER; diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java index e4fbcc793..49455f483 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java @@ -1,8 +1,4 @@ package arcade.patch.agent.process; - -import java.util.ArrayList; -import java.util.Set; - import arcade.core.agent.process.Process; import arcade.core.util.MiniBox; import arcade.core.sim.Simulation; @@ -46,10 +42,7 @@ public PatchProcessInflammationCD4(PatchCellCART c) { super(c); // Set parameters. - - //TODO: parameters are not grabbing here MiniBox parameters = cell.getParameters(); - ArrayList keys = parameters.getKeys(); this.IL2_PROD_RATE_IL2 = parameters.getDouble( "inflammation/IL2_PROD_RATE_IL2"); this.IL2_PROD_RATE_ACTIVE = parameters.getDouble("inflammation/IL2_PROD_RATE_ACTIVE"); this.IL2_SYNTHESIS_DELAY = parameters.getInt("inflammation/IL2_SYNTHESIS_DELAY"); @@ -76,16 +69,17 @@ public void stepProcess(MersenneTwisterFast random, Simulation sim) { // Update environment. // Take current IL2 external concentration and add the amount produced, // then convert units back to molecules/cm^3. - double IL2Env = ((extIL2 - (extIL2*f - amts[IL2_EXT])) + IL2Produced)*1E12/loc.getVolume(); + double IL2Env = (((extIL2 - (extIL2*f - amts[IL2_EXT])) + IL2Produced)*1E12/loc.getVolume()); sim.getLattice("IL-2").setValue(loc, IL2Env); } @Override public void update(Process mod) { PatchProcessInflammationCD4 inflammation = (PatchProcessInflammationCD4) mod; - double split = this.cell.getVolume() / this.volume; + double split = (this.cell.getVolume() / this.volume); // Update daughter cell inflammation as a fraction of parent. + // this.volume = this.cell.getVolume(); this.amts[IL2Rbga] = inflammation.amts[IL2Rbga]*split; this.amts[IL2_IL2Rbg] = inflammation.amts[IL2_IL2Rbg]*split; this.amts[IL2_IL2Rbga] = inflammation.amts[IL2_IL2Rbga]*split; diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index d8914f219..2faa4db59 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -54,19 +54,20 @@ public void stepProcess(MersenneTwisterFast random, Simulation sim) { // Update environment. // Convert units back from molecules to molecules/cm^3. - double IL2Env = (extIL2 - (extIL2*f - amts[IL2_EXT]))*1E12/loc.getVolume(); + double IL2Env = ((extIL2 - (extIL2*f - amts[IL2_EXT]))*1E12/loc.getVolume()); sim.getLattice("IL-2").setValue(loc, IL2Env); } @Override public void update(Process mod) { PatchProcessInflammationCD8 inflammation = (PatchProcessInflammationCD8) mod; - double split = this.cell.getVolume() / this.volume; + double split = (this.cell.getVolume() / this.volume); // Update daughter cell inflammation as a fraction of parent. + // this.volume = this.cell.getVolume(); this.amts[IL2Rbga] = inflammation.amts[IL2Rbga]*split; this.amts[IL2_IL2Rbg] = inflammation.amts[IL2_IL2Rbg]*split; - this.amts[IL2_IL2Rbga] = inflammation.amts[IL2_IL2Rbga]*f; + this.amts[IL2_IL2Rbga] = inflammation.amts[IL2_IL2Rbga]*split; this.amts[IL2Rbg] = IL2_RECEPTORS - this.amts[IL2Rbga] - this.amts[IL2_IL2Rbg] - this.amts[IL2_IL2Rbga]; this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2Rbg] + this.amts[IL2_IL2Rbga]; this.amts[IL2R_TOTAL] = this.amts[IL2Rbg] + this.amts[IL2Rbga]; diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolism.java b/src/arcade/patch/agent/process/PatchProcessMetabolism.java index 0565664de..64a77fb70 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolism.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolism.java @@ -8,6 +8,7 @@ import arcade.patch.agent.cell.PatchCell; import arcade.patch.env.grid.PatchGrid; import static arcade.patch.util.PatchEnums.State; +import sim.engine.SimState; /** * Implementation of {@link Process} for cell metabolism. @@ -143,6 +144,9 @@ public abstract class PatchProcessMetabolism extends PatchProcess { // Initialize external and uptake concentration arrays; extAmts = new double[2]; upAmts = new double[2]; + + // Update extAmts with initial values + //updateExternal(cell.getSimulation()); } /** diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java index c80e74c97..3292bbb0b 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java @@ -1,7 +1,7 @@ package arcade.patch.agent.process; import java.util.Arrays; - +import arcade.core.agent.process.Process; import arcade.core.sim.Simulation; import arcade.core.util.MiniBox; import arcade.patch.agent.cell.PatchCell; @@ -9,8 +9,14 @@ import arcade.patch.util.PatchEnums.Domain; import ec.util.MersenneTwisterFast; +import sim.engine.SimState; + + + -public class PatchProcessMetabolismCART extends PatchProcessMetabolismComplex { + + +public class PatchProcessMetabolismCART extends PatchProcessMetabolism { /** ID for pyruvate */ public static final int PYRUVATE = 1; @@ -96,7 +102,7 @@ public PatchProcessMetabolismCART(PatchCell cell) { // Set loaded parameters. // TODO: pull metabolic preference from distribution MiniBox parameters = cell.getParameters(); - metaPref = parameters.getDouble("metabolism/METABOLIC_PREFERENCE"); + metaPref = parameters.getDouble("metabolism/METABOLIC_PREFERENCE"); conversionFraction = parameters.getDouble("metabolism/CONVERSION_FRACTION"); fracMass = parameters.getDouble("metabolism/MINIMUM_MASS_FRACTION"); ratioGlucosePyruvate = parameters.getDouble("metabolism/RATIO_GLUCOSE_PYRUVATE"); @@ -234,5 +240,41 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { upAmts[OXYGEN] = oxyUptake; intAmts[PYRUVATE] = pyruInt; } + + + @Override + public void update(Process process) { + PatchProcessMetabolismCART metabolism = (PatchProcessMetabolismCART) process; + double split = this.cell.getVolume() / this.volume; + + // Update daughter cell metabolism as fraction of parent. + this.energy = metabolism.energy*f; + this.intAmts[GLUCOSE] = metabolism.intAmts[GLUCOSE]*split; + this.intAmts[PYRUVATE] = metabolism.intAmts[PYRUVATE]*split; + + // Update parent cell with remaining fraction. + metabolism.energy *= (1 - split); + metabolism.intAmts[GLUCOSE] *= (1 - split); + metabolism.intAmts[PYRUVATE] *= (1 - split); + metabolism.volume *= (1 - split); + metabolism.mass *= (1 - split); + + // PatchProcessMetabolismCART metabolism = (PatchProcessMetabolismCART) process; + // double split = this.cell.getVolume() / this.volume; + + // // Update this process as split of given process. + // this.volume = this.cell.getVolume(); + // this.energy = this.cell.getEnergy(); + // this.mass = this.volume * cellDensity; + // this.intAmts[GLUCOSE] = metabolism.intAmts[GLUCOSE] * split; + // this.intAmts[PYRUVATE] = metabolism.intAmts[PYRUVATE] * split; + + // // Update given process with remaining split. + // metabolism.volume = metabolism.cell.getVolume(); + // metabolism.energy = metabolism.cell.getEnergy(); + // metabolism.mass = metabolism.volume * cellDensity; + // metabolism.intAmts[GLUCOSE] *= (1 - split); + // metabolism.intAmts[PYRUVATE] *= (1 - split); + } } From 2c686688c8a07bbf1683f0c8f732643c53b77ef6 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Fri, 15 Nov 2024 04:39:14 +0000 Subject: [PATCH 028/185] changing files after pulling in container changes from develop --- .../patch/agent/action/PatchActionReset.java | 7 +- .../patch/agent/action/PatchActionTreat.java | 36 ++---- src/arcade/patch/agent/cell/PatchCell.java | 14 ++- .../patch/agent/cell/PatchCellCART.java | 107 ++++++++++-------- .../patch/agent/cell/PatchCellCARTCD4.java | 16 +-- .../patch/agent/cell/PatchCellCARTCD8.java | 15 +-- .../patch/agent/cell/PatchCellCancer.java | 3 + .../patch/agent/cell/PatchCellContainer.java | 21 +--- .../patch/agent/cell/PatchCellTissue.java | 20 +++- .../module/PatchModuleProliferation.java | 2 +- .../process/PatchProcessInflammation.java | 4 +- .../process/PatchProcessInflammationCD4.java | 4 +- .../process/PatchProcessInflammationCD8.java | 4 +- .../agent/process/PatchProcessMetabolism.java | 3 - .../process/PatchProcessMetabolismCART.java | 11 +- 15 files changed, 128 insertions(+), 139 deletions(-) diff --git a/src/arcade/patch/agent/action/PatchActionReset.java b/src/arcade/patch/agent/action/PatchActionReset.java index ffb07a759..ede5d6624 100644 --- a/src/arcade/patch/agent/action/PatchActionReset.java +++ b/src/arcade/patch/agent/action/PatchActionReset.java @@ -1,15 +1,12 @@ package arcade.patch.agent.action; import arcade.core.agent.action.Action; -import arcade.core.agent.process.ProcessDomain; import arcade.core.sim.Series; import arcade.core.sim.Simulation; -import arcade.core.util.MiniBox; +import arcade.core.util.Parameters; import arcade.patch.agent.cell.PatchCellCART; -import arcade.patch.agent.cell.PatchCellTissue; import arcade.patch.agent.process.PatchProcessInflammation; import arcade.patch.util.PatchEnums.AntigenFlag; -import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.Ordering; import arcade.patch.util.PatchEnums.State; import ec.util.MersenneTwisterFast; @@ -49,7 +46,7 @@ public class PatchActionReset implements Action { * @param target the {@link arcade.patch.agent.cell.PatchCellTissue} the CAR T-cell is bound to */ - public PatchActionReset(PatchCellCART c, MersenneTwisterFast random, Series series, MiniBox parameters) { + public PatchActionReset(PatchCellCART c, MersenneTwisterFast random, Series series, Parameters parameters) { this.c = c; double boundTime = parameters.getInt("BOUND_TIME"); double boundRange = parameters.getInt("BOUND_RANGE"); diff --git a/src/arcade/patch/agent/action/PatchActionTreat.java b/src/arcade/patch/agent/action/PatchActionTreat.java index 43040a074..fbbefb69c 100644 --- a/src/arcade/patch/agent/action/PatchActionTreat.java +++ b/src/arcade/patch/agent/action/PatchActionTreat.java @@ -1,18 +1,9 @@ package arcade.patch.agent.action; -import java.lang.reflect.Constructor; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Set; - import sim.engine.Schedule; import sim.engine.SimState; import sim.util.Bag; import arcade.core.agent.action.Action; -import arcade.core.agent.cell.Cell; -import arcade.core.agent.cell.CellContainer; -import arcade.core.env.component.Component; -import arcade.core.env.grid.Grid; -import arcade.core.env.lattice.Lattice; import arcade.core.env.location.Location; import arcade.core.env.location.LocationContainer; import arcade.core.sim.Series; @@ -21,7 +12,6 @@ import arcade.core.util.Utilities; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.Coordinate; -import arcade.patch.env.location.CoordinateUVWZ; import arcade.patch.env.location.CoordinateXYZ; import arcade.patch.env.location.PatchLocation; import arcade.patch.env.location.PatchLocationContainer; @@ -30,7 +20,9 @@ import arcade.patch.env.component.PatchComponentSitesSource; import arcade.patch.env.component.PatchComponentSitesPattern; import arcade.patch.agent.cell.PatchCell; +import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.agent.cell.PatchCellContainer; +import arcade.patch.agent.cell.PatchCellTissue; import arcade.patch.env.component.PatchComponentSites; import arcade.patch.env.component.PatchComponentSitesGraph; import arcade.patch.env.component.PatchComponentSitesGraph.SiteEdge; @@ -63,12 +55,6 @@ public class PatchActionTreat implements Action { /** List of freaction of each population to treat with. CD4 to CD8 ratio */ private final double treatFrac; - /** Grid radius that cells are inserted into. */ - private final int insertRadius; - - /** Grid depth that cells are inserted into. */ - private final int insertDepth; - /** Maximum damage value at which T-cells can spawn next to in source or pattern source */ private double max_damage; @@ -108,12 +94,6 @@ public PatchActionTreat(Series series, MiniBox parameters) { if (coord == "Hex") { latPositions = 9; } if (coord == "Rect") { latPositions = 16;} - - - //Im assuming to just use the default here - this.insertRadius = ((PatchSeries) series).radius; - this.insertDepth = ((PatchSeries) series).height; - // Initialize population register. populations = new ArrayList<>(); } @@ -283,7 +263,7 @@ private void insert(ArrayList coordinates, SimState simstate ){ PatchLocationContainer locationContainer = new PatchLocationContainer(id, coord); PatchCellContainer cellContainer = sim.cellFactory.createCellForPopulation(id, pop); Location location = locationContainer.convert(sim.locationFactory, cellContainer); - PatchCell cell = (PatchCell) cellContainer.convert(sim.cellFactory, location); + PatchCell cell = (PatchCell) cellContainer.convert(sim.cellFactory, location, sim.random); grid.addObject(cell, location); cell.schedule(sim.getSchedule()); } @@ -310,14 +290,16 @@ protected boolean checkLocationSpace(Simulation sim, Location loc, PatchGrid gri for (Object cellObj : bag) { PatchCell cell = (PatchCell)cellObj; - MiniBox cellParams = cell.getParameters(); - String className = cellParams.get("CLASS"); - if(className.equals("cart_cd4") || className.equals("cart_cd8")){ + // MiniBox cellParams = cell.getParameters(); + // String className = cellParams.get("CLASS"); + // if(className.equals("cart_cd4") || className.equals("cart_cd8")){ + if (cell instanceof PatchCellCART){ //totalVol = PatchCell.calculateTotalVolume(bag) + cell.getParameters().getDouble("T_CELL_VOL_AVG"); totalVol = PatchCell.calculateTotalVolume(bag) + parameters.getDouble("T_CELL_VOL_AVG"); currentHeight = totalVol/locArea; } - if (className.equals("tissue") || className.equals("cancer") || className.equals("cancer_stem")) { + // if (className.equals("tissue") || className.equals("cancer") || className.equals("cancer_stem")) { + if (cell instanceof PatchCellTissue){ if (currentHeight > cell.getCriticalHeight()) { available = false; } } } diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index fb5490447..5a1ef202e 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -25,6 +25,11 @@ import arcade.patch.agent.process.PatchProcessSignaling; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; +import arcade.patch.util.PatchEnums.Domain; +import arcade.patch.util.PatchEnums.Flag; +import arcade.patch.util.PatchEnums.Ordering; +import arcade.patch.util.PatchEnums.State; + import static arcade.patch.util.PatchEnums.Domain; import static arcade.patch.util.PatchEnums.Flag; import static arcade.patch.util.PatchEnums.Ordering; @@ -104,6 +109,9 @@ public abstract class PatchCell implements Cell { /** Cell state change flag. */ Flag flag; + /** Variation in cell agent parameters. */ + private final double heterogeneity; + /** Fraction of necrotic cells that become apoptotic. */ final double necroticFraction; @@ -163,14 +171,14 @@ public PatchCell( this.isStopped = false; setState(container.state); - - // Set loaded parameters. - //heterogeneity = parameters.getDouble("HETEROGENEITY"); this.links = links; necroticFraction = parameters.getDouble("NECROTIC_FRACTION"); senescentFraction = parameters.getDouble("SENESCENT_FRACTION"); + heterogeneity = parameters.getDouble("HETEROGENEITY"); energyThreshold = -parameters.getDouble("ENERGY_THRESHOLD"); + // TODO: implement heterogeneity + // Add cell processes. processes = new HashMap<>(); MiniBox processBox = parameters.filter("(PROCESS)"); diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 4e43a0994..136062d87 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -6,7 +6,9 @@ import arcade.core.agent.cell.Cell; import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; +import arcade.core.util.GrabBag; import arcade.core.util.MiniBox; +import arcade.core.util.Parameters; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; import arcade.patch.util.PatchEnums.AntigenFlag; @@ -57,24 +59,18 @@ public abstract class PatchCellCART extends PatchCell { - /** Fraction of exhausted cells that become apoptotic. */ - protected final double exhaustedFraction; + // /** Fraction of exhausted cells that become apoptotic. */ + // protected final double exhaustedFraction; - /** Fraction of senescent cells that become apoptotic. */ - protected final double senescentFraction; + // /** Fraction of senescent cells that become apoptotic. */ + // protected final double senescentFraction; - /** Fraction of anergic cells that become apoptotic. */ - protected final double anergicFraction; + // /** Fraction of anergic cells that become apoptotic. */ + // protected final double anergicFraction; - /** Fraction of proliferative cells that become apoptotic. */ - protected final double proliferativeFraction; + // /** Fraction of proliferative cells that become apoptotic. */ + // protected final double proliferativeFraction; - /** Cell surface antigen count */ - protected int carAntigens; - - /** Cell surface PDL1 count */ - protected final int selfTargets; - /** Cell binding flag */ public AntigenFlag binding; @@ -100,6 +96,18 @@ public abstract class PatchCellCART extends PatchCell { protected final int cars; protected int lastActiveTicker; + /** Fraction of exhausted cells that become apoptotic. */ + protected final double exhaustedFraction; + + /** Fraction of senescent cells that become apoptotic. */ + protected final double senescentFraction; + + /** Fraction of anergic cells that become apoptotic. */ + protected final double anergicFraction; + + /** Fraction of proliferative cells that become apoptotic. */ + protected final double proliferativeFraction; + /** * Creates a tissue {@code PatchCellCART} agent. * *

    @@ -144,39 +152,46 @@ public abstract class PatchCellCART extends PatchCell { * @param criticalVolume the critical cell volume * @param criticalHeight the critical cell height */ - public PatchCellCART(int id, int parent, int pop, CellState state, int age, int divisions, - Location location, MiniBox parameters, double volume, double height, - double criticalVolume, double criticalHeight) { - super(id, parent, pop, state, age, divisions, location, parameters, - volume, height, criticalVolume, criticalHeight); - - //initialized non-loaded parameters - boundAntigensCount = 0; - boundSelfCount = 0; - lastActiveTicker = 0; - binding = AntigenFlag.UNDEFINED; - activated = true; + public PatchCellCART(PatchCellContainer container, Location location, Parameters parameters) { + this(container, location, parameters, null); + } - // Set loaded parameters. - exhaustedFraction = parameters.getDouble( "EXHAU_FRAC"); - senescentFraction = parameters.getDouble("SENESCENT_FRACTION"); - anergicFraction = parameters.getDouble("ANERGIC_FRACTION"); - proliferativeFraction = parameters.getDouble("PROLIFERATIVE_FRACTION"); - carAntigens = parameters.getInt("CAR_ANTIGENS"); - selfTargets = parameters.getInt("SELF_TARGETS"); - selfReceptors = parameters.getInt("SELF_RECEPTORS"); - selfReceptorsStart = selfReceptors; - searchAbility = parameters.getDouble("SEARCH_ABILITY"); - carAffinity = parameters.getDouble("CAR_AFFINITY"); - carAlpha = parameters.getDouble("CAR_ALPHA"); - carBeta = parameters.getDouble("CAR_BETA"); - selfReceptorAffinity = parameters.getDouble("SELF_RECEPTOR_AFFINITY"); - selfAlpha = parameters.getDouble("SELF_ALPHA"); - selfBeta = parameters.getDouble("SELF_BETA"); - contactFraction = parameters.getDouble("CONTACT_FRAC"); - maxAntigenBinding = parameters.getInt("MAX_ANTIGEN_BINDING"); - cars = parameters.getInt("CARS"); - } + /** + * Creates a tissue {@code PatchCell} agent with population links. + * + * @param container the cell container + * @param location the {@link Location} of the cell + * @param parameters the dictionary of parameters + * @param links the map of population links + */ + public PatchCellCART(PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { + super(container, location, parameters, links); + //initialized non-loaded parameters + boundAntigensCount = 0; + boundSelfCount = 0; + lastActiveTicker = 0; + binding = AntigenFlag.UNDEFINED; + activated = true; + + // Set loaded parameters. + exhaustedFraction = parameters.getDouble( "EXHAU_FRAC"); + senescentFraction = parameters.getDouble("SENESCENT_FRACTION"); + anergicFraction = parameters.getDouble("ANERGIC_FRACTION"); + proliferativeFraction = parameters.getDouble("PROLIFERATIVE_FRACTION"); + selfReceptors = parameters.getInt("SELF_RECEPTORS"); + selfReceptorsStart = selfReceptors; + searchAbility = parameters.getDouble("SEARCH_ABILITY"); + carAffinity = parameters.getDouble("CAR_AFFINITY"); + carAlpha = parameters.getDouble("CAR_ALPHA"); + carBeta = parameters.getDouble("CAR_BETA"); + selfReceptorAffinity = parameters.getDouble("SELF_RECEPTOR_AFFINITY"); + selfAlpha = parameters.getDouble("SELF_ALPHA"); + selfBeta = parameters.getDouble("SELF_BETA"); + contactFraction = parameters.getDouble("CONTACT_FRAC"); + maxAntigenBinding = parameters.getInt("MAX_ANTIGEN_BINDING"); + cars = parameters.getInt("CARS"); + } + /* need to implement bindTarget equivalent here*/ /** diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index aa342124b..87822614e 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -2,7 +2,8 @@ import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; -import arcade.core.util.MiniBox; +import arcade.core.util.GrabBag; +import arcade.core.util.Parameters; import arcade.patch.agent.action.PatchActionReset; import arcade.patch.sim.PatchSimulation; import arcade.patch.util.PatchEnums.AntigenFlag; @@ -36,15 +37,14 @@ public class PatchCellCARTCD4 extends PatchCellCART{ * @param criticalHeight the critical cell height */ - public PatchCellCARTCD4(int id, int parent, int pop, CellState state, int age, int divisions, - Location location, MiniBox parameters, double volume, double height, - double criticalVolume, double criticalHeight) { - - super(id, parent, pop, state, age, divisions, location, parameters, - volume, height, criticalVolume, criticalHeight); - + public PatchCellCARTCD4(PatchCellContainer container, Location location, Parameters parameters) { + this(container, location, parameters, null); } + public PatchCellCARTCD4(PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { + super(container, location, parameters, links); + } + @Override public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFast random) { diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index be4392911..f7e0a5fc6 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -3,7 +3,8 @@ import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; -import arcade.core.util.MiniBox; +import arcade.core.util.GrabBag; +import arcade.core.util.Parameters; import arcade.patch.agent.action.PatchActionKill; import arcade.patch.agent.action.PatchActionReset; import arcade.patch.sim.PatchSimulation; @@ -37,14 +38,14 @@ public class PatchCellCARTCD8 extends PatchCellCART { * @param criticalHeight the critical cell height */ - public PatchCellCARTCD8(int id, int parent, int pop, CellState state, int age, int divisions, - Location location, MiniBox parameters, double volume, double height, - double criticalVolume, double criticalHeight) { - - super(id, parent, pop, state, age, divisions, location, parameters, - volume, height, criticalVolume, criticalHeight); + public PatchCellCARTCD8(PatchCellContainer container, Location location, Parameters parameters) { + this(container, location, parameters, null); } + public PatchCellCARTCD8(PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { + super(container, location, parameters, links); + } + @Override public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFast random) { diff --git a/src/arcade/patch/agent/cell/PatchCellCancer.java b/src/arcade/patch/agent/cell/PatchCellCancer.java index 9ba152b95..ea4a15323 100644 --- a/src/arcade/patch/agent/cell/PatchCellCancer.java +++ b/src/arcade/patch/agent/cell/PatchCellCancer.java @@ -7,6 +7,8 @@ import arcade.core.sim.Simulation; import arcade.core.util.GrabBag; import arcade.core.util.Parameters; +import arcade.patch.util.PatchEnums.State; + import static arcade.patch.util.PatchEnums.State; /** @@ -42,6 +44,7 @@ public PatchCellCancer(PatchCellContainer container, Location location, Paramete public PatchCellCancer( PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { super(container, location, parameters, links); + super.carAntigens = parameters.getInt("CAR_ANTIGENS_CANCER"); } /** diff --git a/src/arcade/patch/agent/cell/PatchCellContainer.java b/src/arcade/patch/agent/cell/PatchCellContainer.java index 732ecc540..9e2242a9b 100644 --- a/src/arcade/patch/agent/cell/PatchCellContainer.java +++ b/src/arcade/patch/agent/cell/PatchCellContainer.java @@ -114,26 +114,11 @@ public Cell convert( case "cancer": return new PatchCellCancer(this, location, parameters, links); case "cancer_stem": - return new PatchCellCancerStem( - id, - parent, - pop, - state, - age, - divisions, - location, - parameters, - volume, - height, - criticalVolume, - criticalHeight); + return new PatchCellCancerStem(this, location, parameters, links); case "cart_cd4": - return new PatchCellCARTCD4(id, parent, pop, state, age, divisions, location, - parameters, volume, height, criticalVolume, criticalHeight); + return new PatchCellCARTCD4(this, location, parameters, links); case "cart_cd8": - return new PatchCellCARTCD8(id, parent, pop, state, age, divisions, location, - parameters, volume, height, criticalVolume, criticalHeight); - return new PatchCellCancerStem(this, location, parameters, links); + return new PatchCellCARTCD8(this, location, parameters, links); case "random": return new PatchCellRandom(this, location, parameters, links); } diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index f785af4a3..8a3e7ca7a 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -1,18 +1,24 @@ package arcade.patch.agent.cell; import ec.util.MersenneTwisterFast; +import sim.engine.SimState; import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; +import arcade.core.sim.Simulation; import arcade.core.util.GrabBag; import arcade.core.util.Parameters; +import arcade.patch.util.PatchEnums.AntigenFlag; +import arcade.patch.util.PatchEnums.Domain; +import arcade.patch.util.PatchEnums.Flag; +import arcade.patch.util.PatchEnums.State; /** Extension of {@link PatchCell} for healthy tissue cells. */ public class PatchCellTissue extends PatchCell { - /** Fraction of necrotic cells that become apoptotic. */ - private final double necroticFraction; + // /** Fraction of necrotic cells that become apoptotic. */ + // private final double necroticFraction; - /** Fraction of senescent cells that become apoptotic. */ - private final double senescentFraction; + // /** Fraction of senescent cells that become apoptotic. */ + // private final double senescentFraction; //these two variables are public bc I don't want to implement setter/getter methods for sims that do not use CART cells. @@ -45,9 +51,11 @@ public PatchCellTissue(PatchCellContainer container, Location location, Paramete * @param parameters the dictionary of parameters * @param links the map of population links */ - public PatchCellTissue( - PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { + public PatchCellTissue(PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { super(container, location, parameters, links); + carAntigens = parameters.getInt("CAR_ANTIGENS_HEALTHY"); + selfTargets = parameters.getInt("SELF_TARGETS"); + this.binding = AntigenFlag.UNDEFINED; } @Override diff --git a/src/arcade/patch/agent/module/PatchModuleProliferation.java b/src/arcade/patch/agent/module/PatchModuleProliferation.java index cb2845ad2..e50c45f34 100644 --- a/src/arcade/patch/agent/module/PatchModuleProliferation.java +++ b/src/arcade/patch/agent/module/PatchModuleProliferation.java @@ -53,7 +53,7 @@ public PatchModuleProliferation(PatchCell cell) { maxHeight = cell.getCriticalHeight(); // Set loaded parameters. - MiniBox parameters = cell.getParameters(); + Parameters parameters = cell.getParameters(); if (cell instanceof PatchCellCART) { synthesisDuration = parameters.getInt("proliferation/T_CELL_SYNTHESIS_DURATION"); } else { diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index c94018b56..b8c6e509a 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -5,7 +5,7 @@ import java.util.List; import arcade.core.env.location.Location; -import arcade.core.util.MiniBox; +import arcade.core.util.Parameters; import arcade.core.sim.Simulation; import arcade.core.util.Solver.Equations; import ec.util.MersenneTwisterFast; @@ -134,7 +134,7 @@ public PatchProcessInflammation(PatchCellCART c) { this.activeTicker = 0; // Set parameters. - MiniBox parameters = cell.getParameters(); + Parameters parameters = cell.getParameters(); this.SHELL_THICKNESS = parameters.getDouble("inflammation/SHELL_THICKNESS"); this.IL2_RECEPTORS = parameters.getDouble("inflammation/IL2_RECEPTORS"); this.IL2_BINDING_ON_RATE_MIN = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MIN"); diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java index 49455f483..ae4bfab85 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java @@ -1,6 +1,6 @@ package arcade.patch.agent.process; import arcade.core.agent.process.Process; -import arcade.core.util.MiniBox; +import arcade.core.util.Parameters; import arcade.core.sim.Simulation; import ec.util.MersenneTwisterFast; import arcade.patch.agent.cell.PatchCellCART; @@ -42,7 +42,7 @@ public PatchProcessInflammationCD4(PatchCellCART c) { super(c); // Set parameters. - MiniBox parameters = cell.getParameters(); + Parameters parameters = cell.getParameters(); this.IL2_PROD_RATE_IL2 = parameters.getDouble( "inflammation/IL2_PROD_RATE_IL2"); this.IL2_PROD_RATE_ACTIVE = parameters.getDouble("inflammation/IL2_PROD_RATE_ACTIVE"); this.IL2_SYNTHESIS_DELAY = parameters.getInt("inflammation/IL2_SYNTHESIS_DELAY"); diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index 2faa4db59..8838074aa 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -1,7 +1,7 @@ package arcade.patch.agent.process; import arcade.core.agent.process.Process; -import arcade.core.util.MiniBox; +import arcade.core.util.Parameters; import ec.util.MersenneTwisterFast; import arcade.patch.agent.cell.PatchCellCART; import arcade.core.sim.Simulation; @@ -29,7 +29,7 @@ public PatchProcessInflammationCD8(PatchCellCART c) { super(c); // Set parameters. - MiniBox parameters = cell.getParameters(); + Parameters parameters = cell.getParameters(); this.GRANZ_SYNTHESIS_DELAY = parameters.getInt("inflammation/GRANZ_SYNTHESIS_DELAY"); this.priorIL2granz = 0; diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolism.java b/src/arcade/patch/agent/process/PatchProcessMetabolism.java index 61f50b3ba..8eda1831d 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolism.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolism.java @@ -144,9 +144,6 @@ public abstract class PatchProcessMetabolism extends PatchProcess { // Initialize external and uptake concentration arrays; extAmts = new double[2]; upAmts = new double[2]; - - // Update extAmts with initial values - //updateExternal(cell.getSimulation()); } /** diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java index 3292bbb0b..f6a11aa52 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java @@ -3,19 +3,12 @@ import java.util.Arrays; import arcade.core.agent.process.Process; import arcade.core.sim.Simulation; -import arcade.core.util.MiniBox; +import arcade.core.util.Parameters; import arcade.patch.agent.cell.PatchCell; import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.util.PatchEnums.Domain; import ec.util.MersenneTwisterFast; -import sim.engine.SimState; - - - - - - public class PatchProcessMetabolismCART extends PatchProcessMetabolism { /** ID for pyruvate */ @@ -101,7 +94,7 @@ public PatchProcessMetabolismCART(PatchCell cell) { // Set loaded parameters. // TODO: pull metabolic preference from distribution - MiniBox parameters = cell.getParameters(); + Parameters parameters = cell.getParameters(); metaPref = parameters.getDouble("metabolism/METABOLIC_PREFERENCE"); conversionFraction = parameters.getDouble("metabolism/CONVERSION_FRACTION"); fracMass = parameters.getDouble("metabolism/MINIMUM_MASS_FRACTION"); From 3410c64daa07f4a3a8cb345dce52a3f70bbc00e8 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 15 Nov 2024 04:55:57 +0000 Subject: [PATCH 029/185] adding metabolism initial glucose concentration parameter for cart metabolism, changing grid capacity limit for t cells --- .../agent/process/PatchProcessMetabolismCART.java | 12 +++++++----- src/arcade/patch/env/grid/PatchGrid.java | 2 +- src/arcade/patch/parameter.patch.xml | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java index f6a11aa52..ef9bf92b9 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java @@ -73,6 +73,7 @@ public class PatchProcessMetabolismCART extends PatchProcessMetabolism { *

  • {@code LACTATE_RATE} = rate of lactate production
  • *
  • {@code AUTOPHAGY_RATE} = rate of autophagy
  • *
  • {@code GLUCOSE_UPTAKE_RATE} = rate of glucose uptake
  • + *
  • {@code INITIAL_GLUCOSE_CONCENTRATION} = initial cell internal glucose concentration * * The process starts with energy at zero and assumes a constant ratio * between mass and volume (through density). @@ -81,11 +82,6 @@ public class PatchProcessMetabolismCART extends PatchProcessMetabolism { */ public PatchProcessMetabolismCART(PatchCell cell) { super(cell); - // Initial internal concentrations. - intAmts = new double[2]; - intAmts[GLUCOSE] = extAmts[GLUCOSE]; - intAmts[PYRUVATE] = extAmts[GLUCOSE] * PYRU_PER_GLUC; - // Mapping for internal concentration access. String[] intNames = new String[2]; intNames[GLUCOSE] = "glucose"; @@ -109,6 +105,12 @@ public PatchProcessMetabolismCART(PatchCell cell) { glucoseUptakeRate_active = parameters.getDouble("metabolism/GLUC_UPTAKE_RATE_ACTIVE"); minimumMassFraction_active = parameters.getDouble("metabolism/FRAC_MASS_ACTIVE"); timeDelay = (int) parameters.getDouble("metabolism/META_SWITCH_DELAY"); + + // Initial internal concentrations. + intAmts = new double[2]; + intAmts[GLUCOSE] = + parameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION") * volume; + intAmts[PYRUVATE] = intAmts[GLUCOSE] * PYRU_PER_GLUC; } @Override diff --git a/src/arcade/patch/env/grid/PatchGrid.java b/src/arcade/patch/env/grid/PatchGrid.java index 599171f5a..34be56bd7 100644 --- a/src/arcade/patch/env/grid/PatchGrid.java +++ b/src/arcade/patch/env/grid/PatchGrid.java @@ -15,7 +15,7 @@ */ public class PatchGrid implements Grid { /** Initial bag capacity. */ - private static final int INITIAL_CAPACITY = 6; + private static final int INITIAL_CAPACITY = 54; /** Map of ID to object. */ final HashMap objects; diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index 40e1f728c..62e2ffce7 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -47,6 +47,7 @@ + @@ -79,7 +80,7 @@ - + From 3a42203178f3f63dd82ba4912c52c66d3ce64389 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 15 Nov 2024 21:51:28 +0000 Subject: [PATCH 030/185] removing lysed cells since they are no longer part of the output --- src/arcade/patch/sim/PatchSimulation.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/arcade/patch/sim/PatchSimulation.java b/src/arcade/patch/sim/PatchSimulation.java index 265267bd1..d7c738f09 100644 --- a/src/arcade/patch/sim/PatchSimulation.java +++ b/src/arcade/patch/sim/PatchSimulation.java @@ -56,9 +56,6 @@ public abstract class PatchSimulation extends SimState implements Simulation { /** Lattice factory instance for the simulation. */ public final PatchLatticeFactory latticeFactory; - - /** list of series cells lysed */ - public ArrayList lysedCells; /** * Simulation instance for a {@link Series} for given random seed. @@ -168,10 +165,6 @@ public void start() { setupAgents(); setupEnvironment(); - - // Create lysed cell list - this.lysedCells = new ArrayList(); - scheduleActions(); scheduleComponents(); From 94ee843afafcdeda8982417a9c2ea75a39b516a3 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 15 Nov 2024 21:53:21 +0000 Subject: [PATCH 031/185] adding spacing --- src/arcade/patch/sim/PatchSimulation.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arcade/patch/sim/PatchSimulation.java b/src/arcade/patch/sim/PatchSimulation.java index d7c738f09..9bdaa4e41 100644 --- a/src/arcade/patch/sim/PatchSimulation.java +++ b/src/arcade/patch/sim/PatchSimulation.java @@ -165,6 +165,7 @@ public void start() { setupAgents(); setupEnvironment(); + scheduleActions(); scheduleComponents(); From f99dd6f948d922ce5e0068a63a320219cd6075c7 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 15 Nov 2024 22:24:21 +0000 Subject: [PATCH 032/185] adding linting --- .../patch/agent/action/PatchActionKill.java | 117 ++-- .../patch/agent/action/PatchActionReset.java | 73 ++- .../patch/agent/action/PatchActionTreat.java | 572 ++++++++++-------- src/arcade/patch/agent/cell/PatchCell.java | 33 +- .../patch/agent/cell/PatchCellCART.java | 328 +++++----- .../patch/agent/cell/PatchCellCARTCD4.java | 270 +++++---- .../patch/agent/cell/PatchCellCARTCD8.java | 270 +++++---- .../patch/agent/cell/PatchCellCancer.java | 1 - .../patch/agent/cell/PatchCellTissue.java | 40 +- .../module/PatchModuleProliferation.java | 6 +- .../process/PatchProcessInflammation.java | 540 +++++++++-------- .../process/PatchProcessInflammationCD4.java | 186 +++--- .../process/PatchProcessInflammationCD8.java | 149 ++--- .../agent/process/PatchProcessMetabolism.java | 1 - .../process/PatchProcessMetabolismCART.java | 243 ++++---- src/arcade/patch/parameter.patch.xml | 38 +- src/arcade/patch/sim/PatchSeries.java | 1 - src/arcade/patch/sim/PatchSimulation.java | 4 +- src/arcade/patch/util/PatchEnums.java | 20 +- src/arcade/patch/vis/PatchColorMaps.java | 2 +- .../patch/agent/cell/PatchCARTCellTest.java | 405 ++++++++----- .../patch/agent/cell/PatchCellTest.java | 234 +++++-- test/arcade/patch/util/PatchEnumsTest.java | 34 +- 23 files changed, 1971 insertions(+), 1596 deletions(-) diff --git a/src/arcade/patch/agent/action/PatchActionKill.java b/src/arcade/patch/agent/action/PatchActionKill.java index 5a8b9845b..0a556880e 100644 --- a/src/arcade/patch/agent/action/PatchActionKill.java +++ b/src/arcade/patch/agent/action/PatchActionKill.java @@ -1,5 +1,8 @@ package arcade.patch.agent.action; +import sim.engine.Schedule; +import sim.engine.SimState; +import ec.util.MersenneTwisterFast; import arcade.core.agent.action.Action; import arcade.core.sim.Series; import arcade.core.sim.Simulation; @@ -11,54 +14,52 @@ import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.Ordering; import arcade.patch.util.PatchEnums.State; -import ec.util.MersenneTwisterFast; -import sim.engine.Schedule; -import sim.engine.SimState; -import arcade.core.util.Parameters; /** - * Implementation of {@link Action} for killing tissue agents. - *

    - * {@code PatchActionKill} is stepped once after a CD8 CAR T-cell binds to a - * target tissue cell. - * The {@code PatchActionKill} determines if cell has enough granzyme to kill. - * If so, it kills cell and calls the reset to neutral helper to return to neutral state. - * If not, it waits until it has enough granzyme to kill cell. + * Implementation of {@link Action} for killing tissue agents. + * + *

    {@code PatchActionKill} is stepped once after a CD8 CAR T-cell binds to a target tissue cell. + * The {@code PatchActionKill} determines if cell has enough granzyme to kill. If so, it kills cell + * and calls the reset to neutral helper to return to neutral state. If not, it waits until it has + * enough granzyme to kill cell. */ - public class PatchActionKill implements Action { - - /** Target cell cytotoxic CAR T-cell is bound to */ - PatchCellTissue target; - - /** CAR T-cell inflammation module */ - PatchProcessInflammation inflammation; - - /** Amount of granzyme inside CAR T-cell */ - double granzyme; + + /** Target cell cytotoxic CAR T-cell is bound to */ + PatchCellTissue target; + + /** CAR T-cell inflammation module */ + PatchProcessInflammation inflammation; + + /** Amount of granzyme inside CAR T-cell */ + double granzyme; /** CAR T-cell that the module is linked to */ - PatchCellCART c; + PatchCellCART c; /** Time delay before calling the action [min]. */ private final int timeDelay; - /** - * Creates a {@code PatchActionKill} for the given - * {@link arcade.patch.agent.cell.PatchCellCART}. - * - * @param c the {@link arcade.patch.agent.cell.PatchCellCART} the helper is associated with - * @param target the {@link arcade.patch.agent.cell.PatchCellTissue} the CAR T-cell is bound to - */ - - public PatchActionKill(PatchCellCART c, PatchCellTissue target, MersenneTwisterFast random, Series series, Parameters parameters) { - this.c = c; - this.target = target; - this.inflammation = (PatchProcessInflammation)c.getProcess(Domain.INFLAMMATION); - this.granzyme = inflammation.getInternal("granzyme"); + /** + * Creates a {@code PatchActionKill} for the given {@link + * arcade.patch.agent.cell.PatchCellCART}. + * + * @param c the {@link arcade.patch.agent.cell.PatchCellCART} the helper is associated with + * @param target the {@link arcade.patch.agent.cell.PatchCellTissue} the CAR T-cell is bound to + */ + public PatchActionKill( + PatchCellCART c, + PatchCellTissue target, + MersenneTwisterFast random, + Series series, + Parameters parameters) { + this.c = c; + this.target = target; + this.inflammation = (PatchProcessInflammation) c.getProcess(Domain.INFLAMMATION); + this.granzyme = inflammation.getInternal("granzyme"); timeDelay = 0; - } - + } + @Override public void schedule(Schedule schedule) { schedule.scheduleOnce(schedule.getTime() + timeDelay, Ordering.ACTIONS.ordinal(), this); @@ -69,33 +70,33 @@ public void register(Simulation sim, String population) {} @Override public void step(SimState state) { - Simulation sim = (Simulation)state; - - // If current CAR T-cell is stopped, stop helper. - if (c.isStopped()) {return; } - - // If bound target cell is stopped, stop helper. - if (target.isStopped()) { + Simulation sim = (Simulation) state; + + // If current CAR T-cell is stopped, stop helper. + if (c.isStopped()) { + return; + } + + // If bound target cell is stopped, stop helper. + if (target.isStopped()) { if (c.binding == AntigenFlag.BOUND_ANTIGEN) { c.binding = AntigenFlag.UNBOUND; } else { c.binding = AntigenFlag.BOUND_CELL_RECEPTOR; } - return; + return; } - - if (granzyme >= 1) { - - // Kill bound target cell. - PatchCellTissue tissueCell = (PatchCellTissue)target; - tissueCell.setState(State.APOPTOTIC); - tissueCell.getModule().step(state.random,sim); - - // Use up some granzyme in the process. - granzyme--; - inflammation.setInternal("granzyme", granzyme); - } - } + if (granzyme >= 1) { + + // Kill bound target cell. + PatchCellTissue tissueCell = (PatchCellTissue) target; + tissueCell.setState(State.APOPTOTIC); + tissueCell.getModule().step(state.random, sim); + // Use up some granzyme in the process. + granzyme--; + inflammation.setInternal("granzyme", granzyme); + } + } } diff --git a/src/arcade/patch/agent/action/PatchActionReset.java b/src/arcade/patch/agent/action/PatchActionReset.java index ede5d6624..963f39832 100644 --- a/src/arcade/patch/agent/action/PatchActionReset.java +++ b/src/arcade/patch/agent/action/PatchActionReset.java @@ -1,5 +1,8 @@ package arcade.patch.agent.action; +import sim.engine.Schedule; +import sim.engine.SimState; +import ec.util.MersenneTwisterFast; import arcade.core.agent.action.Action; import arcade.core.sim.Series; import arcade.core.sim.Simulation; @@ -9,50 +12,44 @@ import arcade.patch.util.PatchEnums.AntigenFlag; import arcade.patch.util.PatchEnums.Ordering; import arcade.patch.util.PatchEnums.State; -import ec.util.MersenneTwisterFast; -import sim.engine.Schedule; -import sim.engine.SimState; /** - * Implementation of {@link Action} for killing tissue agents. - *

    - * {@code PatchActionKill} is stepped once after a CD8 CAR T-cell binds to a - * target tissue cell. - * The {@code PatchActionKill} determines if cell has enough granzyme to kill. - * If so, it kills cell and calls the reset to neutral helper to return to neutral state. - * If not, it waits until it has enough granzyme to kill cell. + * Implementation of {@link Action} for killing tissue agents. + * + *

    {@code PatchActionKill} is stepped once after a CD8 CAR T-cell binds to a target tissue cell. + * The {@code PatchActionKill} determines if cell has enough granzyme to kill. If so, it kills cell + * and calls the reset to neutral helper to return to neutral state. If not, it waits until it has + * enough granzyme to kill cell. */ - public class PatchActionReset implements Action { - - - /** CAR T-cell inflammation module */ - PatchProcessInflammation inflammation; - - /** Amount of granzyme inside CAR T-cell */ - double granzyme; + + /** CAR T-cell inflammation module */ + PatchProcessInflammation inflammation; + + /** Amount of granzyme inside CAR T-cell */ + double granzyme; /** CAR T-cell that the module is linked to */ - PatchCellCART c; + PatchCellCART c; /** Time delay before calling the action [min]. */ private final int timeDelay; - /** - * Creates a {@code PatchActionKill} for the given - * {@link arcade.patch.agent.cell.PatchCellCART}. - * - * @param c the {@link arcade.patch.agent.cell.PatchCellCART} the helper is associated with - * @param target the {@link arcade.patch.agent.cell.PatchCellTissue} the CAR T-cell is bound to - */ - - public PatchActionReset(PatchCellCART c, MersenneTwisterFast random, Series series, Parameters parameters) { - this.c = c; + /** + * Creates a {@code PatchActionKill} for the given {@link + * arcade.patch.agent.cell.PatchCellCART}. + * + * @param c the {@link arcade.patch.agent.cell.PatchCellCART} the helper is associated with + * @param target the {@link arcade.patch.agent.cell.PatchCellTissue} the CAR T-cell is bound to + */ + public PatchActionReset( + PatchCellCART c, MersenneTwisterFast random, Series series, Parameters parameters) { + this.c = c; double boundTime = parameters.getInt("BOUND_TIME"); double boundRange = parameters.getInt("BOUND_RANGE"); - timeDelay = (int)(boundTime + Math.round((boundRange*(2*random.nextInt() - 1)))); - } - + timeDelay = (int) (boundTime + Math.round((boundRange * (2 * random.nextInt() - 1)))); + } + @Override public void schedule(Schedule schedule) { schedule.scheduleOnce(schedule.getTime() + timeDelay, Ordering.ACTIONS.ordinal(), this); @@ -63,14 +60,14 @@ public void register(Simulation sim, String population) {} @Override public void step(SimState state) { - // If current CAR T-cell is stopped, stop helper. - if (c.isStopped()) {return; } - - if (c.getState() == State.CYTOTOXIC || c.getState() == State.STIMULATORY) { + // If current CAR T-cell is stopped, stop helper. + if (c.isStopped()) { + return; + } + + if (c.getState() == State.CYTOTOXIC || c.getState() == State.STIMULATORY) { c.binding = AntigenFlag.UNBOUND; c.setState(State.QUIESCENT); } } - - } diff --git a/src/arcade/patch/agent/action/PatchActionTreat.java b/src/arcade/patch/agent/action/PatchActionTreat.java index fbbefb69c..918f967b5 100644 --- a/src/arcade/patch/agent/action/PatchActionTreat.java +++ b/src/arcade/patch/agent/action/PatchActionTreat.java @@ -1,4 +1,5 @@ package arcade.patch.agent.action; + import java.util.ArrayList; import sim.engine.Schedule; import sim.engine.SimState; @@ -8,17 +9,9 @@ import arcade.core.env.location.LocationContainer; import arcade.core.sim.Series; import arcade.core.sim.Simulation; +import arcade.core.util.Graph; import arcade.core.util.MiniBox; import arcade.core.util.Utilities; -import arcade.patch.env.grid.PatchGrid; -import arcade.patch.env.location.Coordinate; -import arcade.patch.env.location.CoordinateXYZ; -import arcade.patch.env.location.PatchLocation; -import arcade.patch.env.location.PatchLocationContainer; -import arcade.patch.sim.PatchSeries; -import arcade.patch.sim.PatchSimulation; -import arcade.patch.env.component.PatchComponentSitesSource; -import arcade.patch.env.component.PatchComponentSitesPattern; import arcade.patch.agent.cell.PatchCell; import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.agent.cell.PatchCellContainer; @@ -26,287 +19,334 @@ import arcade.patch.env.component.PatchComponentSites; import arcade.patch.env.component.PatchComponentSitesGraph; import arcade.patch.env.component.PatchComponentSitesGraph.SiteEdge; -import arcade.patch.env.component.PatchComponentSitesGraphTri; import arcade.patch.env.component.PatchComponentSitesGraphRect; -import arcade.core.util.Graph; +import arcade.patch.env.component.PatchComponentSitesGraphTri; +import arcade.patch.env.component.PatchComponentSitesPattern; +import arcade.patch.env.component.PatchComponentSitesSource; +import arcade.patch.env.grid.PatchGrid; +import arcade.patch.env.location.Coordinate; +import arcade.patch.env.location.CoordinateXYZ; +import arcade.patch.env.location.PatchLocation; +import arcade.patch.env.location.PatchLocationContainer; +import arcade.patch.sim.PatchSeries; +import arcade.patch.sim.PatchSimulation; import arcade.patch.util.PatchEnums.Ordering; /** * Implementation of {@link Action} for removing cell agents. - *

    - * The action is stepped once after {@code TIME_DELAY}. - * The {@code TreatAction} will add CAR T-cell agents of specified dose - * and ratio next to source points or vasculature. + * + *

    The action is stepped once after {@code TIME_DELAY}. The {@code TreatAction} will add CAR + * T-cell agents of specified dose and ratio next to source points or vasculature. */ - public class PatchActionTreat implements Action { - /** Serialization version identifier */ - private static final long serialVersionUID = 0; - - /** Delay before calling the helper (in minutes) */ - private final int delay; - - /** Total number of CAR T-cells to treat with */ - private final int dose; - - /** List of populations being treated with */ - //private final ArrayList treatPops; - - /** List of freaction of each population to treat with. CD4 to CD8 ratio */ - private final double treatFrac; - - /** Maximum damage value at which T-cells can spawn next to in source or pattern source */ - private double max_damage; - - /** Minimum radius value at which T- cells can spawn next to in graph source*/ - - private double min_damage_radius; - - /** Number of agent positions per lattice site */ - private int latPositions; - - /** Coordinate system used for simulation */ - private String coord; - - /** List of populations. */ - private final ArrayList populations; + /** Serialization version identifier */ + private static final long serialVersionUID = 0; - /** parameters */ - MiniBox parameters; + /** Delay before calling the helper (in minutes) */ + private final int delay; - /** - * Creates an {@code Action} to add agents after a delay. - * - * @param series the simulation series - * @param parameters the component parameters dictionary - */ + /** Total number of CAR T-cells to treat with */ + private final int dose; - public PatchActionTreat(Series series, MiniBox parameters) { - // Set loaded parameters. - this.delay = parameters.getInt("TIME_DELAY"); - this.dose = parameters.getInt("DOSE"); - this.treatFrac = parameters.getDouble("RATIO"); - this.max_damage = parameters.getDouble("MAX_DAMAGE_SEED"); - this.min_damage_radius = parameters.getDouble("MIN_RADIUS_SEED"); - this.parameters = parameters; + /** List of populations being treated with */ + // private final ArrayList treatPops; + + /** List of freaction of each population to treat with. CD4 to CD8 ratio */ + private final double treatFrac; + + /** Maximum damage value at which T-cells can spawn next to in source or pattern source */ + private double max_damage; + + /** Minimum radius value at which T- cells can spawn next to in graph source */ + private double min_damage_radius; - this.coord = ((PatchSeries) series).patch.get("GEOMETRY").equalsIgnoreCase("HEX") ? "Hex" : "Rect"; - if (coord == "Hex") { latPositions = 9; } - if (coord == "Rect") { latPositions = 16;} + /** Number of agent positions per lattice site */ + private int latPositions; - // Initialize population register. + /** Coordinate system used for simulation */ + private String coord; + + /** List of populations. */ + private final ArrayList populations; + + /** parameters */ + MiniBox parameters; + + /** + * Creates an {@code Action} to add agents after a delay. + * + * @param series the simulation series + * @param parameters the component parameters dictionary + */ + public PatchActionTreat(Series series, MiniBox parameters) { + // Set loaded parameters. + this.delay = parameters.getInt("TIME_DELAY"); + this.dose = parameters.getInt("DOSE"); + this.treatFrac = parameters.getDouble("RATIO"); + this.max_damage = parameters.getDouble("MAX_DAMAGE_SEED"); + this.min_damage_radius = parameters.getDouble("MIN_RADIUS_SEED"); + this.parameters = parameters; + + this.coord = + ((PatchSeries) series).patch.get("GEOMETRY").equalsIgnoreCase("HEX") + ? "Hex" + : "Rect"; + if (coord == "Hex") { + latPositions = 9; + } + if (coord == "Rect") { + latPositions = 16; + } + + // Initialize population register. populations = new ArrayList<>(); } - + @Override public void schedule(Schedule schedule) { schedule.scheduleOnce(delay, Ordering.ACTIONS.ordinal(), this); } - + @Override public void register(Simulation sim, String population) { - populations.add(sim.getSeries().populations.get(population)); + populations.add(sim.getSeries().populations.get(population)); } - /** - * Steps the helper to insert cells of the treatment population(s). - * - * @param state the MASON simulation state - */ - public void step(SimState simstate) { + /** + * Steps the helper to insert cells of the treatment population(s). + * + * @param state the MASON simulation state + */ + public void step(SimState simstate) { - PatchSimulation sim = (PatchSimulation) simstate; - String type = "null"; + PatchSimulation sim = (PatchSimulation) simstate; + String type = "null"; PatchGrid grid = (PatchGrid) sim.getGrid(); - PatchComponentSites comp = (PatchComponentSites) sim.getComponent("SITES"); - - ArrayList locs = sim.getLocations(); - - - - ArrayList siteLocs0 = new ArrayList(); - ArrayList siteLocs1 = new ArrayList(); - ArrayList siteLocs2 = new ArrayList(); - ArrayList siteLocs3 = new ArrayList(); - ArrayList siteLocs = new ArrayList(); - - // Determine type of sites component implemented. - if (comp instanceof PatchComponentSitesSource) { type = "source"; } - else if (comp instanceof PatchComponentSitesPattern) { type = "pattern"; } - else if (comp instanceof PatchComponentSitesGraph) { type = "graph"; } - - // Find sites without specified level of damage based on component type. - switch (type) { - case "source": case "pattern": - double[][][] damage; - boolean[][][] sitesLat; - - if (type == "source") { - damage = ((PatchComponentSitesSource)comp).getDamage(); - sitesLat = ((PatchComponentSitesSource)comp).getSources(); - } else { - damage = ((PatchComponentSitesPattern)comp).getDamage(); - sitesLat = ((PatchComponentSitesPattern)comp).getPatterns(); - } - - // Iterate through list of locations and remove locations not next to a site. - for (LocationContainer l:locs) { - PatchLocationContainer contain = (PatchLocationContainer) l; - PatchLocation loc = (PatchLocation) contain.convert(sim.locationFactory, sim.cellFactory.createCellForPopulation(0, populations.get(0).getInt("CODE"))); - CoordinateXYZ coord = (CoordinateXYZ) loc.getSubcoordinate(); - int z = coord.z; - if ( sitesLat[z][coord.x][coord.y] && damage[z][coord.x][coord.y] <= this.max_damage) { - addCellsIntoList(grid, loc, siteLocs0, siteLocs1, siteLocs2, siteLocs3); - } - } - break; - - case "graph": - Graph G = ((PatchComponentSitesGraph)comp).getGraph(); - Bag allEdges = new Bag(G.getAllEdges()); - PatchComponentSitesGraph graphSites = (PatchComponentSitesGraph) comp; - - for (Object edgeObj : allEdges) { - SiteEdge edge = (SiteEdge)edgeObj; - Bag allEdgeLocs = new Bag(); - if (coord == "Hex") { - allEdgeLocs.add(((PatchComponentSitesGraphTri) graphSites).getSpan(edge.getFrom(), edge.getTo())); - } else { - allEdgeLocs.add(((PatchComponentSitesGraphRect) graphSites).getSpan(edge.getFrom(), edge.getTo())); - } - - for (Object locObj : allEdgeLocs) { - Location loc = (Location)locObj; - if (locs.contains(loc)) { - if (edge.getRadius() >= min_damage_radius) { - addCellsIntoList(grid, loc, siteLocs0, siteLocs1, siteLocs2, siteLocs3); - } - } - } - } - break; - } - - Utilities.shuffleList(siteLocs3, sim.random); - Utilities.shuffleList(siteLocs2, sim.random); - Utilities.shuffleList(siteLocs1, sim.random); - Utilities.shuffleList(siteLocs0, sim.random); - siteLocs.addAll(siteLocs3); - siteLocs.addAll(siteLocs2); - siteLocs.addAll(siteLocs1); - siteLocs.addAll(siteLocs0); - //insert(siteLocs, sim, grid); - insert(siteLocs, simstate); - } - - -private void addCellsIntoList(PatchGrid grid, Location loc, ArrayList siteLocs0, ArrayList siteLocs1, ArrayList siteLocs2, ArrayList siteLocs3){ - Bag bag = new Bag(grid.getObjectsAtLocation(loc)); - int numAgents = bag.numObjs; - - if (numAgents == 0) { - for (int p = 0; p < latPositions; p++) { siteLocs0.add(loc); } - } - else if (numAgents == 1) { - for (int p = 0; p < latPositions; p++) { siteLocs1.add(loc); } - } - else if (numAgents == 2) { - for (int p = 0; p < latPositions; p++) { siteLocs2.add(loc); } - } - else { for (int p = 0; p < latPositions; p++) { siteLocs3.add(loc); } } - // Remove break statement if more than one per hex can appear - // with break statement, each location can only be added to list once - // without it, places with more vasc sites get added more times to list - //break; -} + PatchComponentSites comp = (PatchComponentSites) sim.getComponent("SITES"); + + ArrayList locs = sim.getLocations(); + + ArrayList siteLocs0 = new ArrayList(); + ArrayList siteLocs1 = new ArrayList(); + ArrayList siteLocs2 = new ArrayList(); + ArrayList siteLocs3 = new ArrayList(); + ArrayList siteLocs = new ArrayList(); + + // Determine type of sites component implemented. + if (comp instanceof PatchComponentSitesSource) { + type = "source"; + } else if (comp instanceof PatchComponentSitesPattern) { + type = "pattern"; + } else if (comp instanceof PatchComponentSitesGraph) { + type = "graph"; + } + + // Find sites without specified level of damage based on component type. + switch (type) { + case "source": + case "pattern": + double[][][] damage; + boolean[][][] sitesLat; + + if (type == "source") { + damage = ((PatchComponentSitesSource) comp).getDamage(); + sitesLat = ((PatchComponentSitesSource) comp).getSources(); + } else { + damage = ((PatchComponentSitesPattern) comp).getDamage(); + sitesLat = ((PatchComponentSitesPattern) comp).getPatterns(); + } + + // Iterate through list of locations and remove locations not next to a site. + for (LocationContainer l : locs) { + PatchLocationContainer contain = (PatchLocationContainer) l; + PatchLocation loc = + (PatchLocation) + contain.convert( + sim.locationFactory, + sim.cellFactory.createCellForPopulation( + 0, populations.get(0).getInt("CODE"))); + CoordinateXYZ coord = (CoordinateXYZ) loc.getSubcoordinate(); + int z = coord.z; + if (sitesLat[z][coord.x][coord.y] + && damage[z][coord.x][coord.y] <= this.max_damage) { + addCellsIntoList(grid, loc, siteLocs0, siteLocs1, siteLocs2, siteLocs3); + } + } + break; + + case "graph": + Graph G = ((PatchComponentSitesGraph) comp).getGraph(); + Bag allEdges = new Bag(G.getAllEdges()); + PatchComponentSitesGraph graphSites = (PatchComponentSitesGraph) comp; + + for (Object edgeObj : allEdges) { + SiteEdge edge = (SiteEdge) edgeObj; + Bag allEdgeLocs = new Bag(); + if (coord == "Hex") { + allEdgeLocs.add( + ((PatchComponentSitesGraphTri) graphSites) + .getSpan(edge.getFrom(), edge.getTo())); + } else { + allEdgeLocs.add( + ((PatchComponentSitesGraphRect) graphSites) + .getSpan(edge.getFrom(), edge.getTo())); + } + + for (Object locObj : allEdgeLocs) { + Location loc = (Location) locObj; + if (locs.contains(loc)) { + if (edge.getRadius() >= min_damage_radius) { + addCellsIntoList( + grid, loc, siteLocs0, siteLocs1, siteLocs2, siteLocs3); + } + } + } + } + break; + } + + Utilities.shuffleList(siteLocs3, sim.random); + Utilities.shuffleList(siteLocs2, sim.random); + Utilities.shuffleList(siteLocs1, sim.random); + Utilities.shuffleList(siteLocs0, sim.random); + siteLocs.addAll(siteLocs3); + siteLocs.addAll(siteLocs2); + siteLocs.addAll(siteLocs1); + siteLocs.addAll(siteLocs0); + // insert(siteLocs, sim, grid); + insert(siteLocs, simstate); + } -private void insert(ArrayList coordinates, SimState simstate ){ - PatchSimulation sim = (PatchSimulation) simstate; - PatchGrid grid = (PatchGrid) sim.getGrid(); - Utilities.shuffleList(coordinates, sim.random); - - int cd4Code = 0; - int cd8Code = 0; - - for (MiniBox population : populations) { - String className = population.get("CLASS"); - if (className.equals("cart_cd4")) { - cd4Code = population.getInt("CODE"); - } - if (className.equals("cart_cd8")) { - cd8Code = population.getInt("CODE"); - } - } - - for (int i = 0; i < dose; i++) { - - int id = sim.getID(); - - int pop = cd4Code; - - if (sim.random.nextDouble() > treatFrac){ - pop = cd8Code; - } - - PatchLocation loc = ((PatchLocation) coordinates.remove(0)); - Coordinate coord = loc.getCoordinate(); - - //find available locaiton space - while (!coordinates.isEmpty() && !checkLocationSpace(sim, loc, grid)) { - loc = (PatchLocation) coordinates.remove(0); - } - - if (coordinates.isEmpty()) { - break; - } - - PatchLocationContainer locationContainer = new PatchLocationContainer(id, coord); - PatchCellContainer cellContainer = sim.cellFactory.createCellForPopulation(id, pop); - Location location = locationContainer.convert(sim.locationFactory, cellContainer); - PatchCell cell = (PatchCell) cellContainer.convert(sim.cellFactory, location, sim.random); - grid.addObject(cell, location); - cell.schedule(sim.getSchedule()); - } -} + private void addCellsIntoList( + PatchGrid grid, + Location loc, + ArrayList siteLocs0, + ArrayList siteLocs1, + ArrayList siteLocs2, + ArrayList siteLocs3) { + Bag bag = new Bag(grid.getObjectsAtLocation(loc)); + int numAgents = bag.numObjs; + + if (numAgents == 0) { + for (int p = 0; p < latPositions; p++) { + siteLocs0.add(loc); + } + } else if (numAgents == 1) { + for (int p = 0; p < latPositions; p++) { + siteLocs1.add(loc); + } + } else if (numAgents == 2) { + for (int p = 0; p < latPositions; p++) { + siteLocs2.add(loc); + } + } else { + for (int p = 0; p < latPositions; p++) { + siteLocs3.add(loc); + } + } + // Remove break statement if more than one per hex can appear + // with break statement, each location can only be added to list once + // without it, places with more vasc sites get added more times to list + // break; + } -protected boolean checkLocationSpace(Simulation sim, Location loc, PatchGrid grid) { - boolean available; - int locMax = ((PatchLocation) loc).getMaximum(); - double locVolume = ((PatchLocation) loc).getVolume(); - double locArea = ((PatchLocation) loc).getArea(); - - - Bag bag = new Bag(grid.getObjectsAtLocation(loc)); - int n = bag.numObjs; // number of agents in location - - if (n == 0) { available = true; } // no cells in location - else if (n >= locMax) { available = false; } // location already full - else { - available = true; - double totalVol = PatchCell.calculateTotalVolume(bag); - double currentHeight = totalVol/locArea; - - if (totalVol > locVolume) { available = false; } - - for (Object cellObj : bag) { - PatchCell cell = (PatchCell)cellObj; - // MiniBox cellParams = cell.getParameters(); - // String className = cellParams.get("CLASS"); - // if(className.equals("cart_cd4") || className.equals("cart_cd8")){ - if (cell instanceof PatchCellCART){ - //totalVol = PatchCell.calculateTotalVolume(bag) + cell.getParameters().getDouble("T_CELL_VOL_AVG"); - totalVol = PatchCell.calculateTotalVolume(bag) + parameters.getDouble("T_CELL_VOL_AVG"); - currentHeight = totalVol/locArea; - } - // if (className.equals("tissue") || className.equals("cancer") || className.equals("cancer_stem")) { - if (cell instanceof PatchCellTissue){ - if (currentHeight > cell.getCriticalHeight()) { available = false; } - } - } - - } - - return available; -} + private void insert(ArrayList coordinates, SimState simstate) { + PatchSimulation sim = (PatchSimulation) simstate; + PatchGrid grid = (PatchGrid) sim.getGrid(); + Utilities.shuffleList(coordinates, sim.random); + + int cd4Code = 0; + int cd8Code = 0; + + for (MiniBox population : populations) { + String className = population.get("CLASS"); + if (className.equals("cart_cd4")) { + cd4Code = population.getInt("CODE"); + } + if (className.equals("cart_cd8")) { + cd8Code = population.getInt("CODE"); + } + } + + for (int i = 0; i < dose; i++) { + + int id = sim.getID(); + + int pop = cd4Code; + + if (sim.random.nextDouble() > treatFrac) { + pop = cd8Code; + } + + PatchLocation loc = ((PatchLocation) coordinates.remove(0)); + Coordinate coord = loc.getCoordinate(); + + // find available locaiton space + while (!coordinates.isEmpty() && !checkLocationSpace(sim, loc, grid)) { + loc = (PatchLocation) coordinates.remove(0); + } + + if (coordinates.isEmpty()) { + break; + } + + PatchLocationContainer locationContainer = new PatchLocationContainer(id, coord); + PatchCellContainer cellContainer = sim.cellFactory.createCellForPopulation(id, pop); + Location location = locationContainer.convert(sim.locationFactory, cellContainer); + PatchCell cell = + (PatchCell) cellContainer.convert(sim.cellFactory, location, sim.random); + grid.addObject(cell, location); + cell.schedule(sim.getSchedule()); + } + } -} \ No newline at end of file + protected boolean checkLocationSpace(Simulation sim, Location loc, PatchGrid grid) { + boolean available; + int locMax = ((PatchLocation) loc).getMaximum(); + double locVolume = ((PatchLocation) loc).getVolume(); + double locArea = ((PatchLocation) loc).getArea(); + + Bag bag = new Bag(grid.getObjectsAtLocation(loc)); + int n = bag.numObjs; // number of agents in location + + if (n == 0) { + available = true; + } // no cells in location + else if (n >= locMax) { + available = false; + } // location already full + else { + available = true; + double totalVol = PatchCell.calculateTotalVolume(bag); + double currentHeight = totalVol / locArea; + + if (totalVol > locVolume) { + available = false; + } + + for (Object cellObj : bag) { + PatchCell cell = (PatchCell) cellObj; + // MiniBox cellParams = cell.getParameters(); + // String className = cellParams.get("CLASS"); + // if(className.equals("cart_cd4") || className.equals("cart_cd8")){ + if (cell instanceof PatchCellCART) { + // totalVol = PatchCell.calculateTotalVolume(bag) + + // cell.getParameters().getDouble("T_CELL_VOL_AVG"); + totalVol = + PatchCell.calculateTotalVolume(bag) + + parameters.getDouble("T_CELL_VOL_AVG"); + currentHeight = totalVol / locArea; + } + // if (className.equals("tissue") || className.equals("cancer") || + // className.equals("cancer_stem")) { + if (cell instanceof PatchCellTissue) { + if (currentHeight > cell.getCriticalHeight()) { + available = false; + } + } + } + } + + return available; + } +} diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 5a1ef202e..e0d38defc 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -29,7 +29,6 @@ import arcade.patch.util.PatchEnums.Flag; import arcade.patch.util.PatchEnums.Ordering; import arcade.patch.util.PatchEnums.State; - import static arcade.patch.util.PatchEnums.Domain; import static arcade.patch.util.PatchEnums.Flag; import static arcade.patch.util.PatchEnums.Ordering; @@ -90,7 +89,7 @@ public abstract class PatchCell implements Cell { /** Cell energy [fmol ATP]. */ double energy; - + /** Number of divisions. */ int divisions; @@ -120,7 +119,7 @@ public abstract class PatchCell implements Cell { /** Maximum energy deficit before necrosis. */ final double energyThreshold; - + /** Cell state module. */ protected Module module; @@ -133,9 +132,9 @@ public abstract class PatchCell implements Cell { /** Cell population links. */ final GrabBag links; - /** If cell is stopped in the simulation */ - private boolean isStopped; - + /** If cell is stopped in the simulation */ + private boolean isStopped; + /** * Creates a {@code PatchCell} agent. * @@ -184,11 +183,11 @@ public PatchCell( MiniBox processBox = parameters.filter("(PROCESS)"); if (processBox != null) { for (String processKey : processBox.getKeys()) { - ProcessDomain domain = Domain.valueOf(processKey); - String version = processBox.get(processKey); - Process process = makeProcess(domain, version); - processes.put(domain, process); - } + ProcessDomain domain = Domain.valueOf(processKey); + String version = processBox.get(processKey); + Process process = makeProcess(domain, version); + processes.put(domain, process); + } } } @@ -299,13 +298,15 @@ public void setEnergy(double energy) { } @Override - public void stop() { - stopper.stop(); + public void stop() { + stopper.stop(); isStopped = true; } - public boolean isStopped(){ return isStopped;} - + public boolean isStopped() { + return isStopped; + } + @Override public void setState(CellState state) { this.state = state; @@ -341,7 +342,7 @@ public Process makeProcess(ProcessDomain domain, String version) { case SIGNALING: return PatchProcessSignaling.make(this, version); case INFLAMMATION: - return PatchProcessInflammation.make(this,version); + return PatchProcessInflammation.make(this, version); case UNDEFINED: default: return null; diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 136062d87..79eb0f02c 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -2,66 +2,55 @@ import sim.util.Bag; import ec.util.MersenneTwisterFast; -//import javafx.stage.PopupWindow.AnchorLocation; import arcade.core.agent.cell.Cell; -import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; +import arcade.core.sim.Simulation; import arcade.core.util.GrabBag; -import arcade.core.util.MiniBox; import arcade.core.util.Parameters; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; import arcade.patch.util.PatchEnums.AntigenFlag; import arcade.patch.util.PatchEnums.State; -import arcade.core.sim.Simulation; -import static arcade.patch.util.PatchEnums.State; - import static arcade.patch.util.PatchEnums.AntigenFlag; +import static arcade.patch.util.PatchEnums.State; /** * Implementation of {@link Cell} for generic CART cell. - * - *

    - * {@code PatchCellCART} agents exist in one of thirteen states: neutral, apoptotic, - * migratory, proliferative, senescent, cytotoxic (CD8), stimulatory (CD4), - * exhausted, anergic, starved, or paused. - * The neutral state is an transition state for "undecided" cells, and does not - * have any biological analog. - *

    - * - * {@code PatchCellCART} agents have two required {@link Process} domains: - * metabolism and inflammation. Metabolism controls changes in cell energy and - * volume. Inflammation controls effector functions. - *

    - * - * General order of rules for the {@code PatchCellCART} step: + * + *

    {@code PatchCellCART} agents exist in one of thirteen states: neutral, apoptotic, migratory, + * proliferative, senescent, cytotoxic (CD8), stimulatory (CD4), exhausted, anergic, starved, or + * paused. The neutral state is an transition state for "undecided" cells, and does not have any + * biological analog. + * + *

    {@code PatchCellCART} agents have two required {@link Process} domains: metabolism and + * inflammation. Metabolism controls changes in cell energy and volume. Inflammation controls + * effector functions. + * + *

    General order of rules for the {@code PatchCellCART} step: + * *

      - *
    • update age
    • - *
    • check lifespan (possible change to apoptotic)
    • - *
    • step metabolism module
    • - *
    • check energy status (possible change to starved, apoptotic)
    • - *
    • step inflammation module
    • - *
    • check if neutral or paused (change to proliferative, migratory, senescent, - * cytotoxic, stimulatory, exhausted, anergic)
    • + *
    • update age + *
    • check lifespan (possible change to apoptotic) + *
    • step metabolism module + *
    • check energy status (possible change to starved, apoptotic) + *
    • step inflammation module + *
    • check if neutral or paused (change to proliferative, migratory, senescent, cytotoxic, + * stimulatory, exhausted, anergic) *
    - * - *

    - * Cells that become senescent, exhausted, anergic, or proliferative have a change to become apoptotic - * instead {@code SENESCENT_FRACTION}, ({@code EXHAUSTED_FRACTION}, ({@code ANERGIC_FRACTION}, and ({@code PROLIFERATIVE_FRACTION}, - * respectively). - *

    - * - * Cell parameters are tracked using a map between the parameter name and value. - * Daughter cell parameter values are drawn from a distribution centered on the - * parent cell parameter with the specified amount of heterogeneity - * ({@code HETEROGENEITY}). + * + *

    Cells that become senescent, exhausted, anergic, or proliferative have a change to become + * apoptotic instead {@code SENESCENT_FRACTION}, ({@code EXHAUSTED_FRACTION}, ({@code + * ANERGIC_FRACTION}, and ({@code PROLIFERATIVE_FRACTION}, respectively). + * + *

    Cell parameters are tracked using a map between the parameter name and value. Daughter cell + * parameter values are drawn from a distribution centered on the parent cell parameter with the + * specified amount of heterogeneity ({@code HETEROGENEITY}). */ - public abstract class PatchCellCART extends PatchCell { // /** Fraction of exhausted cells that become apoptotic. */ // protected final double exhaustedFraction; - + // /** Fraction of senescent cells that become apoptotic. */ // protected final double senescentFraction; @@ -70,31 +59,33 @@ public abstract class PatchCellCART extends PatchCell { // /** Fraction of proliferative cells that become apoptotic. */ // protected final double proliferativeFraction; - - /** Cell binding flag */ - public AntigenFlag binding; - /** Cell activation flag */ - protected boolean activated; + /** Cell binding flag */ + public AntigenFlag binding; + + /** Cell activation flag */ + protected boolean activated; /** lack of documentation so these parameters are TBD */ - protected int selfReceptors; - protected int selfReceptorsStart; - protected int boundAntigensCount; - protected int boundSelfCount; - - /** lack of documentation so these loaded parameters are TBD */ - protected final double searchAbility; - protected final double carAffinity; - protected final double carAlpha; - protected final double carBeta; - protected final double selfReceptorAffinity; - protected final double selfAlpha; - protected final double selfBeta; - protected final double contactFraction; - protected final int maxAntigenBinding; - protected final int cars; - protected int lastActiveTicker; + protected int selfReceptors; + + protected int selfReceptorsStart; + protected int boundAntigensCount; + protected int boundSelfCount; + + /** lack of documentation so these loaded parameters are TBD */ + protected final double searchAbility; + + protected final double carAffinity; + protected final double carAlpha; + protected final double carBeta; + protected final double selfReceptorAffinity; + protected final double selfAlpha; + protected final double selfBeta; + protected final double contactFraction; + protected final int maxAntigenBinding; + protected final int cars; + protected int lastActiveTicker; /** Fraction of exhausted cells that become apoptotic. */ protected final double exhaustedFraction; @@ -107,52 +98,49 @@ public abstract class PatchCellCART extends PatchCell { /** Fraction of proliferative cells that become apoptotic. */ protected final double proliferativeFraction; - - /** - * Creates a tissue {@code PatchCellCART} agent. - * *

    - * Loaded parameters include: - *

      - *
    • {@code EXHAUSTED_FRACTION} = fraction of exhausted cells that - * become apoptotic
    • - *
    • {@code SENESCENT_FRACTION} = fraction of senescent cells that - * become apoptotic
    • - *
    • {@code ANERGIC_FRACTION} = fraction of anergic cells that - * become apoptotic
    • - *
    • {@code PROLIFERATIVE_FRACTION} = fraction of proliferative cells that - * become apoptotic
    • - *
    • {@code CAR_ANTIGENS} = Cell surface antigen count
    • - *
    • {@code SELF_TARGETS} = Cell surface PDL1 count
    • - * - *
    • {@code SEARCH_ABILITY} = TBD
    • - *
    • {@code CAR_AFFINITY} = TBD
    • - *
    • {@code CAR_ALPHA} = TBD
    • - *
    • {@code CAR_BETA} = TBD
    • - *
    • {@code SELF_RECEPTOR_AFFINITY} = TBD
    • - *
    • {@code SELF_ALPHA} = TBD
    • - *
    • {@code SELF_BETA} = TBD
    • - *
    • {@code CONTACT_FRACTION} = TBD
    • - *
    • {@code MAX_ANTIGEN_BINDING} = TBD
    • - *
    • {@code CARS} = TBD
    • - *
    • {@code SELF_RECEPTORS} = TBD
    • - *
    • {@code SELF_RECEPTORS_START} = TBD
    • - *
    - * < THERE IS A LACK OF DOCUMENTATION FOR THE REST OF THE LOADED PARAMS SO THEY ARE TBD> - * - * @param id the cell ID - * @param parent the parent ID - * @param pop the cell population index - * @param state the cell state - * @param age the cell age - * @param divisions the number of cell divisions - * @param location the {@link Location} of the cell - * @param parameters the dictionary of parameters - * @param volume the cell volume - * @param height the cell height - * @param criticalVolume the critical cell volume - * @param criticalHeight the critical cell height - */ - public PatchCellCART(PatchCellContainer container, Location location, Parameters parameters) { + + /** + * Creates a tissue {@code PatchCellCART} agent. * + * + *

    Loaded parameters include: + * + *

      + *
    • {@code EXHAUSTED_FRACTION} = fraction of exhausted cells that become apoptotic + *
    • {@code SENESCENT_FRACTION} = fraction of senescent cells that become apoptotic + *
    • {@code ANERGIC_FRACTION} = fraction of anergic cells that become apoptotic + *
    • {@code PROLIFERATIVE_FRACTION} = fraction of proliferative cells that become apoptotic + *
    • {@code CAR_ANTIGENS} = Cell surface antigen count + *
    • {@code SELF_TARGETS} = Cell surface PDL1 count + *
    • {@code SEARCH_ABILITY} = TBD + *
    • {@code CAR_AFFINITY} = TBD + *
    • {@code CAR_ALPHA} = TBD + *
    • {@code CAR_BETA} = TBD + *
    • {@code SELF_RECEPTOR_AFFINITY} = TBD + *
    • {@code SELF_ALPHA} = TBD + *
    • {@code SELF_BETA} = TBD + *
    • {@code CONTACT_FRACTION} = TBD + *
    • {@code MAX_ANTIGEN_BINDING} = TBD + *
    • {@code CARS} = TBD + *
    • {@code SELF_RECEPTORS} = TBD + *
    • {@code SELF_RECEPTORS_START} = TBD + *
    + * + * < THERE IS A LACK OF DOCUMENTATION FOR THE REST OF THE LOADED PARAMS SO THEY ARE TBD> + * + * @param id the cell ID + * @param parent the parent ID + * @param pop the cell population index + * @param state the cell state + * @param age the cell age + * @param divisions the number of cell divisions + * @param location the {@link Location} of the cell + * @param parameters the dictionary of parameters + * @param volume the cell volume + * @param height the cell height + * @param criticalVolume the critical cell volume + * @param criticalHeight the critical cell height + */ + public PatchCellCART(PatchCellContainer container, Location location, Parameters parameters) { this(container, location, parameters, null); } @@ -164,9 +152,10 @@ public PatchCellCART(PatchCellContainer container, Location location, Parameters * @param parameters the dictionary of parameters * @param links the map of population links */ - public PatchCellCART(PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { + public PatchCellCART( + PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { super(container, location, parameters, links); - //initialized non-loaded parameters + // initialized non-loaded parameters boundAntigensCount = 0; boundSelfCount = 0; lastActiveTicker = 0; @@ -174,7 +163,7 @@ public PatchCellCART(PatchCellContainer container, Location location, Parameters activated = true; // Set loaded parameters. - exhaustedFraction = parameters.getDouble( "EXHAU_FRAC"); + exhaustedFraction = parameters.getDouble("EXHAU_FRAC"); senescentFraction = parameters.getDouble("SENESCENT_FRACTION"); anergicFraction = parameters.getDouble("ANERGIC_FRACTION"); proliferativeFraction = parameters.getDouble("PROLIFERATIVE_FRACTION"); @@ -191,96 +180,112 @@ public PatchCellCART(PatchCellContainer container, Location location, Parameters maxAntigenBinding = parameters.getInt("MAX_ANTIGEN_BINDING"); cars = parameters.getInt("CARS"); } - /* need to implement bindTarget equivalent here*/ /** - * Determines if CAR T cell agent is bound to neighbor through receptor-target binding. - *

    - * Searches the number of allowed neighbors in series, calculates bound probability to antigen - * and self receptors, compares values to random variable. Sets flags accordingly - * and returns a target cell if one was bound by antigen or self receptor. - * - * @param state the MASON simulation state - * @param loc the location of the CAR T-cell - * @param random random seed - */ - - public PatchCellTissue bindTarget(Simulation sim, PatchLocation loc, MersenneTwisterFast random) { + * Determines if CAR T cell agent is bound to neighbor through receptor-target binding. + * + *

    Searches the number of allowed neighbors in series, calculates bound probability to + * antigen and self receptors, compares values to random variable. Sets flags accordingly and + * returns a target cell if one was bound by antigen or self receptor. + * + * @param state the MASON simulation state + * @param loc the location of the CAR T-cell + * @param random random seed + */ + public PatchCellTissue bindTarget( + Simulation sim, PatchLocation loc, MersenneTwisterFast random) { double KDCAR = carAffinity * (loc.getVolume() * 1e-15 * 6.022E23); - double KDSelf = selfReceptorAffinity * (loc.getVolume() * 1e-15 * 6.022E23); + double KDSelf = selfReceptorAffinity * (loc.getVolume() * 1e-15 * 6.022E23); PatchGrid grid = (PatchGrid) sim.getGrid(); - //get all agents from this location + // get all agents from this location Bag allAgents = new Bag(grid.getObjectsAtLocation(loc)); - //get all agents from neighboring locations + // get all agents from neighboring locations for (Location neighborLocation : loc.getNeighbors()) { Bag bag = new Bag(grid.getObjectsAtLocation(neighborLocation)); for (Object b : bag) { - //add all agents from neighboring locations + // add all agents from neighboring locations if (!allAgents.contains(b)) allAgents.add(b); } - } + } - //remove self + // remove self allAgents.remove(this); - //shuffle bag + // shuffle bag allAgents.shuffle(random); - //get number of neighbors + // get number of neighbors int neighbors = allAgents.size(); // Bind target with some probability if a nearby cell has targets to bind. int maxSearch = 0; - if (neighbors == 0) { - binding = AntigenFlag.UNBOUND; + if (neighbors == 0) { + binding = AntigenFlag.UNBOUND; return null; - } else { + } else { if (neighbors < searchAbility) { maxSearch = neighbors; } else { maxSearch = (int) searchAbility; } - - // Within maximum search vicinity, search for neighboring cells to bind to + // Within maximum search vicinity, search for neighboring cells to bind to for (int i = 0; i < maxSearch; i++) { Cell cell = (Cell) allAgents.get(i); - if (!(cell instanceof PatchCellCART) && cell.getState() != State.APOPTOTIC && cell.getState() != State.NECROTIC) { + if (!(cell instanceof PatchCellCART) + && cell.getState() != State.APOPTOTIC + && cell.getState() != State.NECROTIC) { PatchCellTissue tissueCell = (PatchCellTissue) cell; double CARAntigens = tissueCell.carAntigens; double selfTargets = tissueCell.selfTargets; - double hillCAR = (CARAntigens*contactFraction/ (KDCAR*carBeta + CARAntigens*contactFraction))*(cars/50000)*carAlpha; - double hillSelf = (selfTargets*contactFraction / (KDSelf*selfBeta + selfTargets*contactFraction))*(selfReceptors/selfReceptorsStart)*selfAlpha; + double hillCAR = + (CARAntigens + * contactFraction + / (KDCAR * carBeta + CARAntigens * contactFraction)) + * (cars / 50000) + * carAlpha; + double hillSelf = + (selfTargets + * contactFraction + / (KDSelf * selfBeta + selfTargets * contactFraction)) + * (selfReceptors / selfReceptorsStart) + * selfAlpha; - double logCAR = 2*(1/(1 + Math.exp(-1*hillCAR))) - 1; - double logSelf = 2*(1/(1 + Math.exp(-1*hillSelf))) - 1; + double logCAR = 2 * (1 / (1 + Math.exp(-1 * hillCAR))) - 1; + double logSelf = 2 * (1 / (1 + Math.exp(-1 * hillSelf))) - 1; double randomAntigen = random.nextDouble(); double randomSelf = random.nextDouble(); - if (logCAR >= randomAntigen && logSelf < randomSelf ) { + if (logCAR >= randomAntigen && logSelf < randomSelf) { // cell binds to antigen receptor binding = AntigenFlag.BOUND_ANTIGEN; boundAntigensCount++; - selfReceptors += (int)((double)selfReceptorsStart * (0.95 + random.nextDouble()/10)); + selfReceptors += + (int) + ((double) selfReceptorsStart + * (0.95 + random.nextDouble() / 10)); return tissueCell; - } else if ( logCAR >= randomAntigen && logSelf >= randomSelf ) { + } else if (logCAR >= randomAntigen && logSelf >= randomSelf) { // cell binds to antigen receptor and self binding = AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR; boundAntigensCount++; boundSelfCount++; - selfReceptors += (int)((double)selfReceptorsStart * (0.95 + random.nextDouble()/10)); + selfReceptors += + (int) + ((double) selfReceptorsStart + * (0.95 + random.nextDouble() / 10)); return tissueCell; - } else if ( logCAR < randomAntigen && logSelf >= randomSelf ) { + } else if (logCAR < randomAntigen && logSelf >= randomSelf) { // cell binds to self binding = AntigenFlag.BOUND_CELL_RECEPTOR; boundSelfCount++; return tissueCell; - } else { + } else { // cell doesn't bind to anything binding = AntigenFlag.UNBOUND; } @@ -290,24 +295,27 @@ public PatchCellTissue bindTarget(Simulation sim, PatchLocation loc, MersenneTwi } return null; } - + /** * Sets the cell binding flag. * - * @param antigenFlag the target cell antigen binding state + * @param antigenFlag the target cell antigen binding state */ - public void setAntigenFlag(AntigenFlag flag) { this.binding = flag; } + public void setAntigenFlag(AntigenFlag flag) { + this.binding = flag; + } - /** + /** * Returns the cell binding flag. * * @return the cell antigen binding state */ - public AntigenFlag getAntigenFlag() { return this.binding; } - - /** - * Returns activation status - */ - public boolean getActivationStatus(){ return this.activated;} - + public AntigenFlag getAntigenFlag() { + return this.binding; + } + + /** Returns activation status */ + public boolean getActivationStatus() { + return this.activated; + } } diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 87822614e..87c5e97b2 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -1,4 +1,7 @@ package arcade.patch.agent.cell; + +import sim.engine.SimState; +import ec.util.MersenneTwisterFast; import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; @@ -9,47 +12,45 @@ import arcade.patch.util.PatchEnums.AntigenFlag; import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.State; -import ec.util.MersenneTwisterFast; -import sim.engine.SimState; -public class PatchCellCARTCD4 extends PatchCellCART{ +public class PatchCellCARTCD4 extends PatchCellCART { /** - * Creates a tissue {@code PatchCellCARTCD4} agent. - * *

    - * Loaded parameters include: - *

      - *
    • {@code STIMULATORY_FRACTION} = fraction of stimulatory cells that - * become apoptotic
    • - *
    - * - * @param id the cell ID - * @param parent the parent ID - * @param pop the cell population index - * @param state the cell state - * @param age the cell age - * @param divisions the number of cell divisions - * @param location the {@link Location} of the cell - * @param parameters the dictionary of parameters - * @param volume the cell volume - * @param height the cell height - * @param criticalVolume the critical cell volume - * @param criticalHeight the critical cell height - */ - - public PatchCellCARTCD4(PatchCellContainer container, Location location, Parameters parameters) { - this(container, location, parameters, null); - } + * Creates a tissue {@code PatchCellCARTCD4} agent. * + * + *

    Loaded parameters include: + * + *

      + *
    • {@code STIMULATORY_FRACTION} = fraction of stimulatory cells that become apoptotic + *
    + * + * @param id the cell ID + * @param parent the parent ID + * @param pop the cell population index + * @param state the cell state + * @param age the cell age + * @param divisions the number of cell divisions + * @param location the {@link Location} of the cell + * @param parameters the dictionary of parameters + * @param volume the cell volume + * @param height the cell height + * @param criticalVolume the critical cell volume + * @param criticalHeight the critical cell height + */ + public PatchCellCARTCD4( + PatchCellContainer container, Location location, Parameters parameters) { + this(container, location, parameters, null); + } - public PatchCellCARTCD4(PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { - super(container, location, parameters, links); - } + public PatchCellCARTCD4( + PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { + super(container, location, parameters, links); + } - - @Override - public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFast random) { - divisions--; - return new PatchCellContainer( + @Override + public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFast random) { + divisions--; + return new PatchCellContainer( newID, id, pop, @@ -60,121 +61,130 @@ public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFas height, criticalVolume, criticalHeight); - + } + + @Override + public void step(SimState simstate) { + Simulation sim = (Simulation) simstate; + + // Increase age of cell. + super.age++; + + // TODO: check for death due to age + + // Increase time since last active ticker + super.lastActiveTicker++; + if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { + if (super.boundAntigensCount != 0) super.boundAntigensCount--; } - - @Override - public void step(SimState simstate) { - Simulation sim = (Simulation) simstate; - - // Increase age of cell. - super.age++; - - // TODO: check for death due to age - - - // Increase time since last active ticker - super.lastActiveTicker++; - if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { - if (super.boundAntigensCount != 0) super.boundAntigensCount--; + if (super.lastActiveTicker / 1440 >= 7) super.activated = false; + + // Step metabolism process. + super.processes.get(Domain.METABOLISM).step(simstate.random, sim); + + // Check energy status. If cell has less energy than threshold, it will + // apoptose. If overall energy is negative, then cell enters quiescence. + if (state != State.APOPTOTIC && energy < 0) { + if (super.energy < super.energyThreshold) { + super.setState(State.APOPTOTIC); + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; + } else if (state != State.ANERGIC + && state != State.SENESCENT + && state != State.EXHAUSTED + && state != State.STARVED) { + super.setState(State.STARVED); + super.setAntigenFlag(AntigenFlag.UNBOUND); } - if (super.lastActiveTicker/1440 >= 7) super.activated = false; - - // Step metabolism process. - super.processes.get(Domain.METABOLISM).step(simstate.random, sim); - - // Check energy status. If cell has less energy than threshold, it will - // apoptose. If overall energy is negative, then cell enters quiescence. - if (state != State.APOPTOTIC && energy < 0) { - if (super.energy < super.energyThreshold) { + } else if (state == State.STARVED && energy >= 0) { + super.setState(State.UNDEFINED); + } + + // Step inflammation process. + super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); + + // Change state from undefined. + if (super.state == State.UNDEFINED + || super.state == State.PAUSED + || super.state == State.QUIESCENT) { + if (divisions == 0) { + if (simstate.random.nextDouble() > super.senescentFraction) { super.setState(State.APOPTOTIC); - super.setAntigenFlag(AntigenFlag.UNBOUND); - this.activated = false; - } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED && state != State.STARVED ) { - super.setState(State.STARVED); - super.setAntigenFlag(AntigenFlag.UNBOUND); + } else { + super.setState(State.SENESCENT); } - } else if (state == State.STARVED && energy >= 0) { - super.setState(State.UNDEFINED); - } - - // Step inflammation process. - super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); - - // Change state from undefined. - if (super.state == State.UNDEFINED|| super.state == State.PAUSED || super.state == State.QUIESCENT) { - if (divisions == 0) { - if (simstate.random.nextDouble() > super.senescentFraction) { + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; + } else { + // Cell attempts to bind to a target + PatchCellTissue target = + super.bindTarget(sim, location, new MersenneTwisterFast(simstate.seed())); + + // If cell is bound to both antigen and self it will become anergic. + if (binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { + if (simstate.random.nextDouble() > super.anergicFraction) { super.setState(State.APOPTOTIC); } else { - super.setState(State.SENESCENT); + super.setState(State.ANERGIC); } super.setAntigenFlag(AntigenFlag.UNBOUND); this.activated = false; - } else { - // Cell attempts to bind to a target - PatchCellTissue target = super.bindTarget(sim, location, new MersenneTwisterFast(simstate.seed())); + } else if (binding == AntigenFlag.BOUND_ANTIGEN) { + // If cell is only bound to target antigen, the cell + // can potentially become properly activated. - //If cell is bound to both antigen and self it will become anergic. - if (binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { - if (simstate.random.nextDouble() > super.anergicFraction) { + // Check overstimulation. If cell has bound to + // target antigens too many times, becomes exhausted. + if (boundAntigensCount > maxAntigenBinding) { + if (simstate.random.nextDouble() > super.exhaustedFraction) { super.setState(State.APOPTOTIC); } else { - super.setState(State.ANERGIC); + super.setState(State.EXHAUSTED); } super.setAntigenFlag(AntigenFlag.UNBOUND); this.activated = false; - } else if (binding == AntigenFlag.BOUND_ANTIGEN) { - // If cell is only bound to target antigen, the cell - // can potentially become properly activated. - - // Check overstimulation. If cell has bound to - // target antigens too many times, becomes exhausted. - if (boundAntigensCount > maxAntigenBinding) { - if (simstate.random.nextDouble() > super.exhaustedFraction) { - super.setState(State.APOPTOTIC); - } else { - super.setState(State.EXHAUSTED); - } - super.setAntigenFlag(AntigenFlag.UNBOUND); - this.activated = false; - } else { - //if CD4 cell is properly activated, it can stimulate - super.setState(State.STIMULATORY); - //reset the cell - this.lastActiveTicker = 0; - this.activated = true; - if (target.isStopped()) { - target.binding = (AntigenFlag.UNBOUND); - } - target.setState(State.QUIESCENT); - this.binding = AntigenFlag.UNBOUND; - //need to reset - PatchActionReset reset = new PatchActionReset(this, simstate.random, ((PatchSimulation) simstate).getSeries(), parameters); - reset.schedule(sim.getSchedule()); - + } else { + // if CD4 cell is properly activated, it can stimulate + super.setState(State.STIMULATORY); + // reset the cell + this.lastActiveTicker = 0; + this.activated = true; + if (target.isStopped()) { + target.binding = (AntigenFlag.UNBOUND); } + target.setState(State.QUIESCENT); + this.binding = AntigenFlag.UNBOUND; + // need to reset + PatchActionReset reset = + new PatchActionReset( + this, + simstate.random, + ((PatchSimulation) simstate).getSeries(), + parameters); + reset.schedule(sim.getSchedule()); + } + } else { + // If self binding, unbind + if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) + super.setAntigenFlag(AntigenFlag.UNBOUND); + // Check activation status. If cell has been activated before, + // it will proliferate. If not, it will migrate. + if (activated) { + super.setState(State.PROLIFERATIVE); } else { - //If self binding, unbind - if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) super.setAntigenFlag(AntigenFlag.UNBOUND); - // Check activation status. If cell has been activated before, - // it will proliferate. If not, it will migrate. - if (activated) { - super.setState(State.PROLIFERATIVE); + if (simstate.random.nextDouble() > super.proliferativeFraction) { + super.setState(State.MIGRATORY); } else { - if (simstate.random.nextDouble() > super.proliferativeFraction) { - super.setState(State.MIGRATORY); - } else { - super.setState(State.PROLIFERATIVE); - } + super.setState(State.PROLIFERATIVE); } } } } - - // Step the module for the cell state. - if (super.module != null) { - super.module.step(simstate.random, sim); - } } + + // Step the module for the cell state. + if (super.module != null) { + super.module.step(simstate.random, sim); + } + } } diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index f7e0a5fc6..d80c456be 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -1,5 +1,7 @@ package arcade.patch.agent.cell; +import sim.engine.SimState; +import ec.util.MersenneTwisterFast; import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; @@ -11,48 +13,47 @@ import arcade.patch.util.PatchEnums.AntigenFlag; import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.State; -import ec.util.MersenneTwisterFast; -import sim.engine.SimState; public class PatchCellCARTCD8 extends PatchCellCART { /** - * Creates a tissue {@code PatchCellCARTCD8} agent. - * *

    - * Loaded parameters include: - *

      - *
    • {@code CYTOTOXIC_FRACTION} = fraction of cytotoxic cells that - * become apoptotic
    • - *
    - * - * @param id the cell ID - * @param parent the parent ID - * @param pop the cell population index - * @param state the cell state - * @param age the cell age - * @param divisions the number of cell divisions - * @param location the {@link Location} of the cell - * @param parameters the dictionary of parameters - * @param volume the cell volume - * @param height the cell height - * @param criticalVolume the critical cell volume - * @param criticalHeight the critical cell height - */ - - public PatchCellCARTCD8(PatchCellContainer container, Location location, Parameters parameters) { - this(container, location, parameters, null); - } + * Creates a tissue {@code PatchCellCARTCD8} agent. * + * + *

    Loaded parameters include: + * + *

      + *
    • {@code CYTOTOXIC_FRACTION} = fraction of cytotoxic cells that become apoptotic + *
    + * + * @param id the cell ID + * @param parent the parent ID + * @param pop the cell population index + * @param state the cell state + * @param age the cell age + * @param divisions the number of cell divisions + * @param location the {@link Location} of the cell + * @param parameters the dictionary of parameters + * @param volume the cell volume + * @param height the cell height + * @param criticalVolume the critical cell volume + * @param criticalHeight the critical cell height + */ + public PatchCellCARTCD8( + PatchCellContainer container, Location location, Parameters parameters) { + this(container, location, parameters, null); + } - public PatchCellCARTCD8(PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { - super(container, location, parameters, links); - } - - @Override - public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFast random) { - - divisions--; - // return new PatchCellCARTCD8(newID, id, pop, newState, age, divisions, newLocation, - // parameters, volume, height, criticalVolume, criticalHeight); - return new PatchCellContainer( + public PatchCellCARTCD8( + PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { + super(container, location, parameters, links); + } + + @Override + public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFast random) { + + divisions--; + // return new PatchCellCARTCD8(newID, id, pop, newState, age, divisions, newLocation, + // parameters, volume, height, criticalVolume, criticalHeight); + return new PatchCellContainer( newID, id, pop, @@ -63,117 +64,132 @@ public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFas height, criticalVolume, criticalHeight); - } + } + + @Override + public void step(SimState simstate) { + Simulation sim = (Simulation) simstate; - @Override - public void step(SimState simstate) { - Simulation sim = (Simulation) simstate; - - // Increase age of cell. - super.age++; - - // TODO: check for death due to age + // Increase age of cell. + super.age++; + // TODO: check for death due to age - // Increase time since last active ticker - super.lastActiveTicker++; - if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { - if (super.boundAntigensCount != 0) super.boundAntigensCount--; + // Increase time since last active ticker + super.lastActiveTicker++; + if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { + if (super.boundAntigensCount != 0) super.boundAntigensCount--; + } + if (super.lastActiveTicker / 1440 > 7) super.activated = false; + + // Step metabolism process. + super.processes.get(Domain.METABOLISM).step(simstate.random, sim); + + // Check energy status. If cell has less energy than threshold, it will + // apoptose. If overall energy is negative, then cell enters quiescence. + if (state != State.APOPTOTIC && energy < 0) { + if (super.energy < super.energyThreshold) { + super.setState(State.APOPTOTIC); + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; + } else if (state != State.ANERGIC + && state != State.SENESCENT + && state != State.EXHAUSTED + && state != State.STARVED) { + super.setState(State.STARVED); + super.setAntigenFlag(AntigenFlag.UNBOUND); } - if (super.lastActiveTicker/1440 > 7) super.activated = false; - - // Step metabolism process. - super.processes.get(Domain.METABOLISM).step(simstate.random, sim); - - // Check energy status. If cell has less energy than threshold, it will - // apoptose. If overall energy is negative, then cell enters quiescence. - if (state != State.APOPTOTIC && energy < 0) { - if (super.energy < super.energyThreshold) { + } else if (state == State.STARVED && energy >= 0) { + super.setState(State.UNDEFINED); + } + + // Step inflammation process. + super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); + + // Change state from undefined. + if (super.state == State.UNDEFINED + || super.state == State.PAUSED + || super.state == State.QUIESCENT) { + if (divisions == 0) { + if (simstate.random.nextDouble() > super.senescentFraction) { super.setState(State.APOPTOTIC); - super.setAntigenFlag(AntigenFlag.UNBOUND); - this.activated = false; - } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED && state != State.STARVED ) { - super.setState(State.STARVED); - super.setAntigenFlag(AntigenFlag.UNBOUND); + } else { + super.setState(State.SENESCENT); } - } else if (state == State.STARVED && energy >= 0) { - super.setState(State.UNDEFINED); - } - - // Step inflammation process. - super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); - - // Change state from undefined. - if (super.state == State.UNDEFINED|| super.state == State.PAUSED || super.state == State.QUIESCENT) { - if (divisions == 0) { - if (simstate.random.nextDouble() > super.senescentFraction) { + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; + } else { + // Cell attempts to bind to a target + PatchCellTissue target = super.bindTarget(sim, location, simstate.random); + + // If cell is bound to both antigen and self it will become anergic. + if (binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { + if (simstate.random.nextDouble() > super.anergicFraction) { super.setState(State.APOPTOTIC); } else { - super.setState(State.SENESCENT); + super.setState(State.ANERGIC); } super.setAntigenFlag(AntigenFlag.UNBOUND); this.activated = false; - } else { - // Cell attempts to bind to a target - PatchCellTissue target = super.bindTarget(sim, location, simstate.random); + } else if (binding == AntigenFlag.BOUND_ANTIGEN) { + // If cell is only bound to target antigen, the cell + // can potentially become properly activated. - //If cell is bound to both antigen and self it will become anergic. - if (binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { - if (simstate.random.nextDouble() > super.anergicFraction) { + // Check overstimulation. If cell has bound to + // target antigens too many times, becomes exhausted. + if (boundAntigensCount > maxAntigenBinding) { + if (simstate.random.nextDouble() > super.exhaustedFraction) { super.setState(State.APOPTOTIC); } else { - super.setState(State.ANERGIC); + super.setState(State.EXHAUSTED); } super.setAntigenFlag(AntigenFlag.UNBOUND); this.activated = false; - } else if (binding == AntigenFlag.BOUND_ANTIGEN) { - // If cell is only bound to target antigen, the cell - // can potentially become properly activated. - - // Check overstimulation. If cell has bound to - // target antigens too many times, becomes exhausted. - if (boundAntigensCount > maxAntigenBinding) { - if (simstate.random.nextDouble() > super.exhaustedFraction) { - super.setState(State.APOPTOTIC); - } else { - super.setState(State.EXHAUSTED); - } - super.setAntigenFlag(AntigenFlag.UNBOUND); - this.activated = false; - } else { - //if CD4 cell is properly activated, it can stimulate - this.lastActiveTicker = 0; - this.activated = true; - super.setState(State.CYTOTOXIC); - //need to call kill - PatchActionKill kill = new PatchActionKill(this, target, simstate.random,((PatchSimulation) simstate).getSeries(), parameters); - kill.schedule(sim.getSchedule()); - //need to reset - PatchActionReset reset = new PatchActionReset(this, simstate.random, ((PatchSimulation) simstate).getSeries(), parameters); - reset.schedule(sim.getSchedule()); - - } } else { - //If self binding, unbind - if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) super.setAntigenFlag(AntigenFlag.UNBOUND); - // Check activation status. If cell has been activated before, - // it will proliferate. If not, it will migrate. - if (activated) { - super.setState(State.PROLIFERATIVE); + // if CD4 cell is properly activated, it can stimulate + this.lastActiveTicker = 0; + this.activated = true; + super.setState(State.CYTOTOXIC); + // need to call kill + PatchActionKill kill = + new PatchActionKill( + this, + target, + simstate.random, + ((PatchSimulation) simstate).getSeries(), + parameters); + kill.schedule(sim.getSchedule()); + // need to reset + PatchActionReset reset = + new PatchActionReset( + this, + simstate.random, + ((PatchSimulation) simstate).getSeries(), + parameters); + reset.schedule(sim.getSchedule()); + } + } else { + // If self binding, unbind + if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) + super.setAntigenFlag(AntigenFlag.UNBOUND); + // Check activation status. If cell has been activated before, + // it will proliferate. If not, it will migrate. + if (activated) { + super.setState(State.PROLIFERATIVE); + } else { + if (simstate.random.nextDouble() > super.proliferativeFraction) { + super.setState(State.MIGRATORY); } else { - if (simstate.random.nextDouble() > super.proliferativeFraction) { - super.setState(State.MIGRATORY); - } else { - super.setState(State.PROLIFERATIVE); - } + super.setState(State.PROLIFERATIVE); } } } } - - // Step the module for the cell state. - if (super.module != null) { - super.module.step(simstate.random, sim); - } } + + // Step the module for the cell state. + if (super.module != null) { + super.module.step(simstate.random, sim); + } + } } diff --git a/src/arcade/patch/agent/cell/PatchCellCancer.java b/src/arcade/patch/agent/cell/PatchCellCancer.java index ea4a15323..2fad89dc9 100644 --- a/src/arcade/patch/agent/cell/PatchCellCancer.java +++ b/src/arcade/patch/agent/cell/PatchCellCancer.java @@ -8,7 +8,6 @@ import arcade.core.util.GrabBag; import arcade.core.util.Parameters; import arcade.patch.util.PatchEnums.State; - import static arcade.patch.util.PatchEnums.State; /** diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index 8a3e7ca7a..f6c71f673 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -1,7 +1,7 @@ package arcade.patch.agent.cell; -import ec.util.MersenneTwisterFast; import sim.engine.SimState; +import ec.util.MersenneTwisterFast; import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; @@ -16,21 +16,21 @@ public class PatchCellTissue extends PatchCell { // /** Fraction of necrotic cells that become apoptotic. */ // private final double necroticFraction; - + // /** Fraction of senescent cells that become apoptotic. */ // private final double senescentFraction; - //these two variables are public bc I don't want to implement setter/getter methods for sims that do not use CART cells. - + // these two variables are public bc I don't want to implement setter/getter methods for sims + // that do not use CART cells. + /** Cell surface antigen count */ - int carAntigens; - - /** Cell surface PDL1 count */ - int selfTargets; + int carAntigens; - /** Cell binding flag */ - public AntigenFlag binding; + /** Cell surface PDL1 count */ + int selfTargets; + /** Cell binding flag */ + public AntigenFlag binding; /** * Creates a tissue {@code PatchCell} agent. @@ -51,7 +51,8 @@ public PatchCellTissue(PatchCellContainer container, Location location, Paramete * @param parameters the dictionary of parameters * @param links the map of population links */ - public PatchCellTissue(PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { + public PatchCellTissue( + PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { super(container, location, parameters, links); carAntigens = parameters.getInt("CAR_ANTIGENS_HEALTHY"); selfTargets = parameters.getInt("SELF_TARGETS"); @@ -75,23 +76,20 @@ public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFas criticalHeight); } - - - /* consider making PatchCell parameters protected instead of private */ @Override public void step(SimState simstate) { Simulation sim = (Simulation) simstate; - + // Increase age of cell. super.age++; - + // TODO: check for death due to age - + // Step metabolism process. super.processes.get(Domain.METABOLISM).step(simstate.random, sim); - + // Check energy status. If cell has less energy than threshold, it will // necrose. If overall energy is negative, then cell enters quiescence. if (state != State.APOPTOTIC && energy < 0) { @@ -105,10 +103,10 @@ public void step(SimState simstate) { super.setState(State.QUIESCENT); } } - + // Step signaling network process. super.processes.get(Domain.SIGNALING).step(simstate.random, sim); - + // Change state from undefined. if (super.state == State.UNDEFINED) { if (super.flag == Flag.MIGRATORY) { @@ -123,7 +121,7 @@ public void step(SimState simstate) { super.setState(State.PROLIFERATIVE); } } - + // Step the module for the cell state. if (super.module != null) { super.module.step(simstate.random, sim); diff --git a/src/arcade/patch/agent/module/PatchModuleProliferation.java b/src/arcade/patch/agent/module/PatchModuleProliferation.java index e50c45f34..ff16577b6 100644 --- a/src/arcade/patch/agent/module/PatchModuleProliferation.java +++ b/src/arcade/patch/agent/module/PatchModuleProliferation.java @@ -114,10 +114,12 @@ public void step(MersenneTwisterFast random, Simulation sim) { PatchProcess metabolism = (PatchProcess) newCell.getProcess(Domain.METABOLISM); metabolism.update(cell.getProcess(Domain.METABOLISM)); if (cell instanceof PatchCellCART) { - PatchProcess inflammation = (PatchProcess) newCell.getProcess(Domain.INFLAMMATION); + PatchProcess inflammation = + (PatchProcess) newCell.getProcess(Domain.INFLAMMATION); inflammation.update(cell.getProcess(Domain.INFLAMMATION)); } else { - PatchProcess signaling = (PatchProcess) newCell.getProcess(Domain.SIGNALING); + PatchProcess signaling = + (PatchProcess) newCell.getProcess(Domain.SIGNALING); signaling.update(cell.getProcess(Domain.SIGNALING)); } // TODO: Update environment generator sites. diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index b8c6e509a..f4f06139b 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -3,270 +3,328 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; - +import ec.util.MersenneTwisterFast; import arcade.core.env.location.Location; -import arcade.core.util.Parameters; import arcade.core.sim.Simulation; +import arcade.core.util.Parameters; +import arcade.core.util.Solver; import arcade.core.util.Solver.Equations; -import ec.util.MersenneTwisterFast; import arcade.patch.agent.cell.PatchCell; import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.env.lattice.PatchLattice; -import arcade.core.util.Solver; + /** - * Implementation of {@link arcade.patch.agent.process.Process} for inflammation type modules - * in which IL-2 is taken up and cytotoxic/stimulatory functions are modified. - *

    - * The {@code Inflammation} module represents an 8-component signaling network. + * Implementation of {@link arcade.patch.agent.process.Process} for inflammation type modules in + * which IL-2 is taken up and cytotoxic/stimulatory functions are modified. + * + *

    The {@code Inflammation} module represents an 8-component signaling network. */ +public abstract class PatchProcessInflammation extends PatchProcess { -public abstract class PatchProcessInflammation extends PatchProcess{ - /** Number of components in signaling network */ - protected static final int NUM_COMPONENTS = 8; - - /** ID for IL-2, bound total */ - protected static final int IL2_INT_TOTAL = 0; - - /** ID for IL-2, external */ - protected static final int IL2_EXT = 1; - - /** ID for IL-2 receptors, total between both two and three chain complex */ - protected static final int IL2R_TOTAL = 2; - - /** ID for two-chain IL-2 receptor complex */ - protected static final int IL2Rbg = 3; - - /** ID for three-chain IL-2 receptor complex */ - protected static final int IL2Rbga = 4; - - /** ID for IL-2-two-chain IL-2 receptor complex */ - protected static final int IL2_IL2Rbg = 5; - - /** ID for IL-2-three-chain IL-2 receptor complex */ - protected static final int IL2_IL2Rbga = 6; - - /** ID for granzyme, internal */ - protected static final int GRANZYME = 7; - - /** Number of steps per second to take in ODE */ - private static final double STEP_DIVIDER = 3.0; - - /** Rate of conversion of IL-2R two-chian complex to IL-2R three chian complex [/sec/step divider] */ - private static final double K_CONVERT = 1e-3/STEP_DIVIDER; - - /** Rate of recycling of recptor complexes back to IL-2 receptor two chain complex [/sec/step divider] */ - private static final double K_REC = 1e-5/STEP_DIVIDER; - - /** Rate of IL-2 binding to two-chain IL-2 recpetor complex [um^3/molecules IL-2/min] */ - private double IL2_BINDING_ON_RATE_MIN = 3.8193E-2; - - /** Rate of IL-2 binding to three-chain IL-2 recpetor complex [um^3/molecules IL-2/min] */ - private double IL2_BINDING_ON_RATE_MAX = 3.155; - - /** Rate of unbinding of IL-2 from two- or three- chain IL-2 receptor complex [/min] */ - private double IL2_BINDING_OFF_RATE = 0.015; - - /** Step size for module (in seconds) */ - static final double STEP_SIZE = 1.0/STEP_DIVIDER; - - /** Location of cell */ - protected Location loc; - - /** Cell the module is associated with */ - protected PatchCellCART c; - - /** Cell population index */ - protected int pop; - - /** List of internal names */ - protected List names; - - /** List of amounts of each species */ - protected double[] amts; - - /** External IL-2 [molecules] */ - protected double extIL2; - - /** Shell around cell volume fraction */ - protected double f; - - /** Volume of cell [um3] */ - protected double volume; - - /** Flag marking if cell is activated via antigen-induced activation */ - protected boolean active; - - /** Time since cell first bound IL-2 */ - protected int IL2Ticker; - - /** Time since cell became activated via antigen-induced activation */ - protected int activeTicker; - - /** List of amounts of IL-2 bound to cell at previous time points */ - protected double[] boundArray; - - /** Distance outward from surface a cell can sense */ - protected final double SHELL_THICKNESS; - - /** Total 2-complex receptors */ - protected final double IL2_RECEPTORS; - - - /** - * Creates an {@code Inflammation} module for the given {@link arcade.patch.agent.PatchCell.PatchCellCART}. - *

    - * Module parameters are specific for the cell population. - * The module starts with no IL-2 bound and no three-chain receptors. - * Daughter cells split amounts of bound IL-2 and three-chain receptors upon dividing. - * - * @param c the {@link arcade.patch.agent.PatchCell.PatchCellCART} the module is associated with - * @param sim the simulation instance - */ - public PatchProcessInflammation(PatchCellCART c) { + protected static final int NUM_COMPONENTS = 8; + + /** ID for IL-2, bound total */ + protected static final int IL2_INT_TOTAL = 0; + + /** ID for IL-2, external */ + protected static final int IL2_EXT = 1; + + /** ID for IL-2 receptors, total between both two and three chain complex */ + protected static final int IL2R_TOTAL = 2; + + /** ID for two-chain IL-2 receptor complex */ + protected static final int IL2Rbg = 3; + + /** ID for three-chain IL-2 receptor complex */ + protected static final int IL2Rbga = 4; + + /** ID for IL-2-two-chain IL-2 receptor complex */ + protected static final int IL2_IL2Rbg = 5; + + /** ID for IL-2-three-chain IL-2 receptor complex */ + protected static final int IL2_IL2Rbga = 6; + + /** ID for granzyme, internal */ + protected static final int GRANZYME = 7; + + /** Number of steps per second to take in ODE */ + private static final double STEP_DIVIDER = 3.0; + + /** + * Rate of conversion of IL-2R two-chian complex to IL-2R three chian complex [/sec/step + * divider] + */ + private static final double K_CONVERT = 1e-3 / STEP_DIVIDER; + + /** + * Rate of recycling of recptor complexes back to IL-2 receptor two chain complex [/sec/step + * divider] + */ + private static final double K_REC = 1e-5 / STEP_DIVIDER; + + /** Rate of IL-2 binding to two-chain IL-2 recpetor complex [um^3/molecules IL-2/min] */ + private double IL2_BINDING_ON_RATE_MIN = 3.8193E-2; + + /** Rate of IL-2 binding to three-chain IL-2 recpetor complex [um^3/molecules IL-2/min] */ + private double IL2_BINDING_ON_RATE_MAX = 3.155; + + /** Rate of unbinding of IL-2 from two- or three- chain IL-2 receptor complex [/min] */ + private double IL2_BINDING_OFF_RATE = 0.015; + + /** Step size for module (in seconds) */ + static final double STEP_SIZE = 1.0 / STEP_DIVIDER; + + /** Location of cell */ + protected Location loc; + + /** Cell the module is associated with */ + protected PatchCellCART c; + + /** Cell population index */ + protected int pop; + + /** List of internal names */ + protected List names; + + /** List of amounts of each species */ + protected double[] amts; + + /** External IL-2 [molecules] */ + protected double extIL2; + + /** Shell around cell volume fraction */ + protected double f; + + /** Volume of cell [um3] */ + protected double volume; + + /** Flag marking if cell is activated via antigen-induced activation */ + protected boolean active; + + /** Time since cell first bound IL-2 */ + protected int IL2Ticker; + + /** Time since cell became activated via antigen-induced activation */ + protected int activeTicker; + + /** List of amounts of IL-2 bound to cell at previous time points */ + protected double[] boundArray; + + /** Distance outward from surface a cell can sense */ + protected final double SHELL_THICKNESS; + + /** Total 2-complex receptors */ + protected final double IL2_RECEPTORS; + + /** + * Creates an {@code Inflammation} module for the given {@link + * arcade.patch.agent.PatchCell.PatchCellCART}. + * + *

    Module parameters are specific for the cell population. The module starts with no IL-2 + * bound and no three-chain receptors. Daughter cells split amounts of bound IL-2 and + * three-chain receptors upon dividing. + * + * @param c the {@link arcade.patch.agent.PatchCell.PatchCellCART} the module is associated with + * @param sim the simulation instance + */ + public PatchProcessInflammation(PatchCellCART c) { super(c); - // Initialize module. - this.loc = c.getLocation(); - this.c = c; - this.pop = c.getPop(); - this.volume = c.getVolume(); - this.IL2Ticker = 0; - this.activeTicker = 0; - - // Set parameters. - Parameters parameters = cell.getParameters(); - this.SHELL_THICKNESS = parameters.getDouble("inflammation/SHELL_THICKNESS"); - this.IL2_RECEPTORS = parameters.getDouble("inflammation/IL2_RECEPTORS"); - this.IL2_BINDING_ON_RATE_MIN = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MIN"); - this.IL2_BINDING_ON_RATE_MAX = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MAX"); - this.IL2_BINDING_OFF_RATE = parameters.getDouble("inflammation/IL2_BINDING_OFF_RATE"); - - // Set external concentrations. - //updateExternal(sim); + // Initialize module. + this.loc = c.getLocation(); + this.c = c; + this.pop = c.getPop(); + this.volume = c.getVolume(); + this.IL2Ticker = 0; + this.activeTicker = 0; + + // Set parameters. + Parameters parameters = cell.getParameters(); + this.SHELL_THICKNESS = parameters.getDouble("inflammation/SHELL_THICKNESS"); + this.IL2_RECEPTORS = parameters.getDouble("inflammation/IL2_RECEPTORS"); + this.IL2_BINDING_ON_RATE_MIN = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MIN"); + this.IL2_BINDING_ON_RATE_MAX = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MAX"); + this.IL2_BINDING_OFF_RATE = parameters.getDouble("inflammation/IL2_BINDING_OFF_RATE"); + + // Set external concentrations. + // updateExternal(sim); extIL2 = 0; - - // Initial amounts of each species, all in molecules/cell. - amts = new double[NUM_COMPONENTS]; - amts[IL2_INT_TOTAL] = 0; - amts[IL2R_TOTAL] = IL2_RECEPTORS; - amts[IL2Rbg] = IL2_RECEPTORS; - amts[IL2Rbga] = 0; - amts[IL2_IL2Rbg] = 0; - amts[IL2_IL2Rbga] = 0; - - // Molecule names. - names = new ArrayList(); - names.add(IL2_INT_TOTAL, "IL-2"); - names.add(IL2_EXT, "external_IL-2"); - names.add(IL2R_TOTAL, "IL2R_total"); - names.add(IL2Rbg, "IL2R_two_chain_complex"); - names.add(IL2Rbga, "IL2R_three_chain_complex"); - names.add(IL2_IL2Rbg, "IL-2_IL2R_two_chain_complex"); - names.add(IL2_IL2Rbga, "IL-2_IL2R_three_chain_complex"); - - // Initialize prior IL2 array. - this.boundArray = new double[180]; - } - - /** - * System of ODEs for network - */ - Equations dydt = (Equations & Serializable) (t, y) -> { - double[] dydt = new double[NUM_COMPONENTS]; - - double kon_2 = IL2_BINDING_ON_RATE_MIN/loc.getVolume()/60/STEP_DIVIDER; - double kon_3 = IL2_BINDING_ON_RATE_MAX/loc.getVolume()/60/STEP_DIVIDER; - double koff = IL2_BINDING_OFF_RATE/60/STEP_DIVIDER; - - dydt[IL2_EXT] = koff*y[IL2_IL2Rbg] + koff*y[IL2_IL2Rbga] - kon_2*y[IL2Rbg]*y[IL2_EXT] - kon_3*y[IL2Rbga]*y[IL2_EXT]; - dydt[IL2Rbg] = koff*y[IL2_IL2Rbg] - kon_2*y[IL2Rbg]*y[IL2_EXT] - K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2Rbg] + K_REC*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga] + y[IL2Rbga]); - dydt[IL2Rbga] = koff*y[IL2_IL2Rbga] - kon_3*y[IL2Rbga]*y[IL2_EXT] + K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2Rbg] - K_REC*y[IL2Rbga]; - dydt[IL2_IL2Rbg] = kon_2*y[IL2Rbg]*y[IL2_EXT] - koff*y[IL2_IL2Rbg] - K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2_IL2Rbg] - K_REC*y[IL2_IL2Rbg]; - dydt[IL2_IL2Rbga] = kon_3*y[IL2Rbga]*y[IL2_EXT] - koff*y[IL2_IL2Rbga] + K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2_IL2Rbg] - K_REC*y[IL2_IL2Rbga]; - dydt[IL2_INT_TOTAL] = kon_2*y[IL2Rbg]*y[IL2_EXT] - koff*y[IL2_IL2Rbg] - K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2_IL2Rbg] - K_REC*y[IL2_IL2Rbg] + kon_3*y[IL2Rbga]*y[IL2_EXT] - koff*y[IL2_IL2Rbga] + K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2_IL2Rbg] - K_REC*y[IL2_IL2Rbga]; - dydt[IL2R_TOTAL] = koff*y[IL2_IL2Rbg] - kon_2*y[IL2Rbg]*y[IL2_EXT] - K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2Rbg] + K_REC*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga] + y[IL2Rbga]) + koff*y[IL2_IL2Rbga] - kon_3*y[IL2Rbga]*y[IL2_EXT] + K_CONVERT*(y[IL2_IL2Rbg] + y[IL2_IL2Rbga])*y[IL2Rbg] - K_REC*y[IL2Rbga]; - - return dydt; - }; - - /** - * Gets the internal amounts of requested key. - * - * @param key the requested substance - */ - public double getInternal(String key) {return amts[names.indexOf(key)]; } - - /** - * Steps the inflammation module. - * - * @param sim the simulation instance - */ - // abstract void stepInflammationModule(Simulation sim); - - public void setInternal(String key, double val) { - amts[names.indexOf(key)] = val; - } - - /** + + // Initial amounts of each species, all in molecules/cell. + amts = new double[NUM_COMPONENTS]; + amts[IL2_INT_TOTAL] = 0; + amts[IL2R_TOTAL] = IL2_RECEPTORS; + amts[IL2Rbg] = IL2_RECEPTORS; + amts[IL2Rbga] = 0; + amts[IL2_IL2Rbg] = 0; + amts[IL2_IL2Rbga] = 0; + + // Molecule names. + names = new ArrayList(); + names.add(IL2_INT_TOTAL, "IL-2"); + names.add(IL2_EXT, "external_IL-2"); + names.add(IL2R_TOTAL, "IL2R_total"); + names.add(IL2Rbg, "IL2R_two_chain_complex"); + names.add(IL2Rbga, "IL2R_three_chain_complex"); + names.add(IL2_IL2Rbg, "IL-2_IL2R_two_chain_complex"); + names.add(IL2_IL2Rbga, "IL-2_IL2R_three_chain_complex"); + + // Initialize prior IL2 array. + this.boundArray = new double[180]; + } + + /** System of ODEs for network */ + Equations dydt = + (Equations & Serializable) + (t, y) -> { + double[] dydt = new double[NUM_COMPONENTS]; + + double kon_2 = + IL2_BINDING_ON_RATE_MIN / loc.getVolume() / 60 / STEP_DIVIDER; + double kon_3 = + IL2_BINDING_ON_RATE_MAX / loc.getVolume() / 60 / STEP_DIVIDER; + double koff = IL2_BINDING_OFF_RATE / 60 / STEP_DIVIDER; + + dydt[IL2_EXT] = + koff * y[IL2_IL2Rbg] + + koff * y[IL2_IL2Rbga] + - kon_2 * y[IL2Rbg] * y[IL2_EXT] + - kon_3 * y[IL2Rbga] * y[IL2_EXT]; + dydt[IL2Rbg] = + koff * y[IL2_IL2Rbg] + - kon_2 * y[IL2Rbg] * y[IL2_EXT] + - K_CONVERT * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) * y[IL2Rbg] + + K_REC * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga] + y[IL2Rbga]); + dydt[IL2Rbga] = + koff * y[IL2_IL2Rbga] + - kon_3 * y[IL2Rbga] * y[IL2_EXT] + + K_CONVERT * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) * y[IL2Rbg] + - K_REC * y[IL2Rbga]; + dydt[IL2_IL2Rbg] = + kon_2 * y[IL2Rbg] * y[IL2_EXT] + - koff * y[IL2_IL2Rbg] + - K_CONVERT + * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) + * y[IL2_IL2Rbg] + - K_REC * y[IL2_IL2Rbg]; + dydt[IL2_IL2Rbga] = + kon_3 * y[IL2Rbga] * y[IL2_EXT] + - koff * y[IL2_IL2Rbga] + + K_CONVERT + * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) + * y[IL2_IL2Rbg] + - K_REC * y[IL2_IL2Rbga]; + dydt[IL2_INT_TOTAL] = + kon_2 * y[IL2Rbg] * y[IL2_EXT] + - koff * y[IL2_IL2Rbg] + - K_CONVERT + * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) + * y[IL2_IL2Rbg] + - K_REC * y[IL2_IL2Rbg] + + kon_3 * y[IL2Rbga] * y[IL2_EXT] + - koff * y[IL2_IL2Rbga] + + K_CONVERT + * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) + * y[IL2_IL2Rbg] + - K_REC * y[IL2_IL2Rbga]; + dydt[IL2R_TOTAL] = + koff * y[IL2_IL2Rbg] + - kon_2 * y[IL2Rbg] * y[IL2_EXT] + - K_CONVERT * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) * y[IL2Rbg] + + K_REC * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga] + y[IL2Rbga]) + + koff * y[IL2_IL2Rbga] + - kon_3 * y[IL2Rbga] * y[IL2_EXT] + + K_CONVERT * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) * y[IL2Rbg] + - K_REC * y[IL2Rbga]; + + return dydt; + }; + + /** + * Gets the internal amounts of requested key. + * + * @param key the requested substance + */ + public double getInternal(String key) { + return amts[names.indexOf(key)]; + } + + /** + * Steps the inflammation module. + * + * @param sim the simulation instance + */ + // abstract void stepInflammationModule(Simulation sim); + + public void setInternal(String key, double val) { + amts[names.indexOf(key)] = val; + } + + /** * Steps the metabolism process. * - * @param random the random number generator - * @param sim the simulation instance + * @param random the random number generator + * @param sim the simulation instance */ abstract void stepProcess(MersenneTwisterFast random, Simulation sim); - - /** - * Gets the external amounts of IL-2. - *

    - * Multiply by location volume and divide by 1E12 to convert from cm3 - * to um3 to get in molecules. - * - * @param sim the simulation instance - */ - private void updateExternal(Simulation sim) { + + /** + * Gets the external amounts of IL-2. + * + *

    Multiply by location volume and divide by 1E12 to convert from cm3 to + * um3 to get in molecules. + * + * @param sim the simulation instance + */ + private void updateExternal(Simulation sim) { // Convert to molecules. PatchLattice il2 = (PatchLattice) sim.getLattice("IL-2"); - extIL2 = il2.getAverageValue(loc)*loc.getVolume() / 1E12; - } - - // METHOD: stepModule. - public void step(MersenneTwisterFast random, Simulation sim) { - // Calculate shell volume 2 um outside of cell. - double radCell = Math.cbrt((3.0/4.0)*(1.0/Math.PI)*volume); - double radShell = radCell + SHELL_THICKNESS; - double volShell = volume*(((radShell*radShell*radShell)/(radCell*radCell*radCell)) - 1.0); + extIL2 = il2.getAverageValue(loc) * loc.getVolume() / 1E12; + } + + // METHOD: stepModule. + public void step(MersenneTwisterFast random, Simulation sim) { + // Calculate shell volume 2 um outside of cell. + double radCell = Math.cbrt((3.0 / 4.0) * (1.0 / Math.PI) * volume); + double radShell = radCell + SHELL_THICKNESS; + double volShell = + volume * (((radShell * radShell * radShell) / (radCell * radCell * radCell)) - 1.0); // this f might be the actual fraction instead of split - f = volShell/loc.getVolume(); - updateExternal(sim); - - // Check active status. - active = c.getActivationStatus(); - if (active) { activeTicker++; } - else { activeTicker = 0; } - - // Calculate external IL-2 used in inflammation module. - // Local IL-2 total available to cell is fraction of total available - // where that fraction is the relative volume fraction the cell occupies - // in the location. - amts[IL2_EXT] = extIL2*f; // [molecules] - - // Solve system of equations. - amts = Solver.rungeKutta(dydt, 0, amts, 60, STEP_SIZE); - - // Modify internal inflammation response. - stepProcess(random, sim); - - // Update bound array. - boundArray[IL2Ticker % boundArray.length] = amts[IL2_INT_TOTAL]; - IL2Ticker++; - } + f = volShell / loc.getVolume(); + updateExternal(sim); + + // Check active status. + active = c.getActivationStatus(); + if (active) { + activeTicker++; + } else { + activeTicker = 0; + } + + // Calculate external IL-2 used in inflammation module. + // Local IL-2 total available to cell is fraction of total available + // where that fraction is the relative volume fraction the cell occupies + // in the location. + amts[IL2_EXT] = extIL2 * f; // [molecules] + + // Solve system of equations. + amts = Solver.rungeKutta(dydt, 0, amts, 60, STEP_SIZE); + + // Modify internal inflammation response. + stepProcess(random, sim); + + // Update bound array. + boundArray[IL2Ticker % boundArray.length] = amts[IL2_INT_TOTAL]; + IL2Ticker++; + } /** * Creates a {@code PatchProcessInflammation} for given version. * - * @param cell the {@link arcade.patch.agent.PatchCell.PatchCellCART} the process is associated with - * @param version the process version - * @return the process instance + * @param cell the {@link arcade.patch.agent.PatchCell.PatchCellCART} the process is associated + * with + * @param version the process version + * @return the process instance */ public static PatchProcess make(PatchCell cell, String version) { switch (version.toUpperCase()) { diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java index ae4bfab85..d7fdd24b8 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java @@ -1,100 +1,112 @@ package arcade.patch.agent.process; + +import ec.util.MersenneTwisterFast; import arcade.core.agent.process.Process; -import arcade.core.util.Parameters; import arcade.core.sim.Simulation; -import ec.util.MersenneTwisterFast; +import arcade.core.util.Parameters; import arcade.patch.agent.cell.PatchCellCART; + /** * Extension of {@link arcade.patch.agent.process} for CD4 CAR T-cells - *

    - * {@code InflammationCD4} determines IL-2 amounts produced for stimulatory effector - * functions as a antigen-induced activation state. + * + *

    {@code InflammationCD4} determines IL-2 amounts produced for stimulatory effector functions as + * a antigen-induced activation state. */ public class PatchProcessInflammationCD4 extends PatchProcessInflammation { - + /** Rate of IL-2 production due to antigen-induced activation */ - private final double IL2_PROD_RATE_ACTIVE; - - /** Rate of IL-2 production due to IL-2 feedback */ - private final double IL2_PROD_RATE_IL2; - - /** Delay in IL-2 synthesis after antigen-induced activation */ - private final int IL2_SYNTHESIS_DELAY; - - /** Total rate of IL-2 production */ - private double IL2ProdRate; - - /** Total IL-2 produced in step */ - private double IL2Produced; - - /** Amount of IL-2 bound in past being used for current IL-2 production calculation */ - private double priorIL2prod; - - /** - * Creates a CD4 {@link arcade.agent.module.Inflammation} module. - *

    - * IL-2 production rate parameters set. - * - * @param c the {@link arcade.agent.cell.CARTCell} the module is associated with - * @param sim the simulation instance - */ - public PatchProcessInflammationCD4(PatchCellCART c) { - super(c); - - // Set parameters. - Parameters parameters = cell.getParameters(); - this.IL2_PROD_RATE_IL2 = parameters.getDouble( "inflammation/IL2_PROD_RATE_IL2"); - this.IL2_PROD_RATE_ACTIVE = parameters.getDouble("inflammation/IL2_PROD_RATE_ACTIVE"); - this.IL2_SYNTHESIS_DELAY = parameters.getInt("inflammation/IL2_SYNTHESIS_DELAY"); - IL2ProdRate = 0; - } - - + private final double IL2_PROD_RATE_ACTIVE; + + /** Rate of IL-2 production due to IL-2 feedback */ + private final double IL2_PROD_RATE_IL2; + + /** Delay in IL-2 synthesis after antigen-induced activation */ + private final int IL2_SYNTHESIS_DELAY; + + /** Total rate of IL-2 production */ + private double IL2ProdRate; + + /** Total IL-2 produced in step */ + private double IL2Produced; + + /** Amount of IL-2 bound in past being used for current IL-2 production calculation */ + private double priorIL2prod; + + /** + * Creates a CD4 {@link arcade.agent.module.Inflammation} module. + * + *

    IL-2 production rate parameters set. + * + * @param c the {@link arcade.agent.cell.CARTCell} the module is associated with + * @param sim the simulation instance + */ + public PatchProcessInflammationCD4(PatchCellCART c) { + super(c); + + // Set parameters. + Parameters parameters = cell.getParameters(); + this.IL2_PROD_RATE_IL2 = parameters.getDouble("inflammation/IL2_PROD_RATE_IL2"); + this.IL2_PROD_RATE_ACTIVE = parameters.getDouble("inflammation/IL2_PROD_RATE_ACTIVE"); + this.IL2_SYNTHESIS_DELAY = parameters.getInt("inflammation/IL2_SYNTHESIS_DELAY"); + IL2ProdRate = 0; + } + @Override - public void stepProcess(MersenneTwisterFast random, Simulation sim) { - - // Determine IL-2 production rate as a function of IL-2 bound. - int prodIndex = (IL2Ticker % boundArray.length) - IL2_SYNTHESIS_DELAY; - if (prodIndex < 0) { prodIndex += boundArray.length; } - priorIL2prod = boundArray[prodIndex]; - IL2ProdRate = IL2_PROD_RATE_IL2 * (priorIL2prod/IL2_RECEPTORS); - - // Add IL-2 production rate dependent on antigen-induced - // cell activation if cell is activated. - if (active && activeTicker >= IL2_SYNTHESIS_DELAY) { IL2ProdRate += IL2_PROD_RATE_ACTIVE; } - - // Produce IL-2 to environment. - IL2Produced = IL2ProdRate; // [molecules], rate is already per minute - - // Update environment. - // Take current IL2 external concentration and add the amount produced, - // then convert units back to molecules/cm^3. - double IL2Env = (((extIL2 - (extIL2*f - amts[IL2_EXT])) + IL2Produced)*1E12/loc.getVolume()); - sim.getLattice("IL-2").setValue(loc, IL2Env); + public void stepProcess(MersenneTwisterFast random, Simulation sim) { + + // Determine IL-2 production rate as a function of IL-2 bound. + int prodIndex = (IL2Ticker % boundArray.length) - IL2_SYNTHESIS_DELAY; + if (prodIndex < 0) { + prodIndex += boundArray.length; + } + priorIL2prod = boundArray[prodIndex]; + IL2ProdRate = IL2_PROD_RATE_IL2 * (priorIL2prod / IL2_RECEPTORS); + + // Add IL-2 production rate dependent on antigen-induced + // cell activation if cell is activated. + if (active && activeTicker >= IL2_SYNTHESIS_DELAY) { + IL2ProdRate += IL2_PROD_RATE_ACTIVE; + } + + // Produce IL-2 to environment. + IL2Produced = IL2ProdRate; // [molecules], rate is already per minute + + // Update environment. + // Take current IL2 external concentration and add the amount produced, + // then convert units back to molecules/cm^3. + double IL2Env = + (((extIL2 - (extIL2 * f - amts[IL2_EXT])) + IL2Produced) * 1E12 / loc.getVolume()); + sim.getLattice("IL-2").setValue(loc, IL2Env); } - + @Override - public void update(Process mod) { - PatchProcessInflammationCD4 inflammation = (PatchProcessInflammationCD4) mod; - double split = (this.cell.getVolume() / this.volume); - - // Update daughter cell inflammation as a fraction of parent. - // this.volume = this.cell.getVolume(); - this.amts[IL2Rbga] = inflammation.amts[IL2Rbga]*split; - this.amts[IL2_IL2Rbg] = inflammation.amts[IL2_IL2Rbg]*split; - this.amts[IL2_IL2Rbga] = inflammation.amts[IL2_IL2Rbga]*split; - this.amts[IL2Rbg] = IL2_RECEPTORS - this.amts[IL2Rbga] - this.amts[IL2_IL2Rbg] - this.amts[IL2_IL2Rbga]; - this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2Rbg] + this.amts[IL2_IL2Rbga]; - this.amts[IL2R_TOTAL] = this.amts[IL2Rbg] + this.amts[IL2Rbga]; - this.boundArray = (inflammation.boundArray).clone(); - - // Update parent cell with remaining fraction. - inflammation.amts[IL2Rbga] *= (1 - split); - inflammation.amts[IL2_IL2Rbg] *= (1 - split); - inflammation.amts[IL2_IL2Rbga] *= (1 - split); - inflammation.amts[IL2Rbg] = IL2_RECEPTORS - inflammation.amts[IL2Rbga] - inflammation.amts[IL2_IL2Rbg] - inflammation.amts[IL2_IL2Rbga]; - inflammation.amts[IL2_INT_TOTAL] = inflammation.amts[IL2_IL2Rbg] + inflammation.amts[IL2_IL2Rbga]; - inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2Rbg] + inflammation.amts[IL2Rbga]; - inflammation.volume *= (1 - split); - } + public void update(Process mod) { + PatchProcessInflammationCD4 inflammation = (PatchProcessInflammationCD4) mod; + double split = (this.cell.getVolume() / this.volume); + + // Update daughter cell inflammation as a fraction of parent. + // this.volume = this.cell.getVolume(); + this.amts[IL2Rbga] = inflammation.amts[IL2Rbga] * split; + this.amts[IL2_IL2Rbg] = inflammation.amts[IL2_IL2Rbg] * split; + this.amts[IL2_IL2Rbga] = inflammation.amts[IL2_IL2Rbga] * split; + this.amts[IL2Rbg] = + IL2_RECEPTORS - this.amts[IL2Rbga] - this.amts[IL2_IL2Rbg] - this.amts[IL2_IL2Rbga]; + this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2Rbg] + this.amts[IL2_IL2Rbga]; + this.amts[IL2R_TOTAL] = this.amts[IL2Rbg] + this.amts[IL2Rbga]; + this.boundArray = (inflammation.boundArray).clone(); + + // Update parent cell with remaining fraction. + inflammation.amts[IL2Rbga] *= (1 - split); + inflammation.amts[IL2_IL2Rbg] *= (1 - split); + inflammation.amts[IL2_IL2Rbga] *= (1 - split); + inflammation.amts[IL2Rbg] = + IL2_RECEPTORS + - inflammation.amts[IL2Rbga] + - inflammation.amts[IL2_IL2Rbg] + - inflammation.amts[IL2_IL2Rbga]; + inflammation.amts[IL2_INT_TOTAL] = + inflammation.amts[IL2_IL2Rbg] + inflammation.amts[IL2_IL2Rbga]; + inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2Rbg] + inflammation.amts[IL2Rbga]; + inflammation.volume *= (1 - split); + } } diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index 8838074aa..20f4bd8ec 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -1,87 +1,94 @@ package arcade.patch.agent.process; +import ec.util.MersenneTwisterFast; import arcade.core.agent.process.Process; +import arcade.core.sim.Simulation; import arcade.core.util.Parameters; -import ec.util.MersenneTwisterFast; import arcade.patch.agent.cell.PatchCellCART; -import arcade.core.sim.Simulation; public class PatchProcessInflammationCD8 extends PatchProcessInflammation { /** Moles of granzyme produced per moles IL-2 [mol granzyme/mol IL-2] */ - private static final double GRANZ_PER_IL2 = 0.005; - - /** Delay in IL-2 synthesis after antigen-induced activation */ - private final int GRANZ_SYNTHESIS_DELAY; - - /** Amount of IL-2 bound in past being used for current granzyme production calculation */ - private double priorIL2granz; - - /** - * Creates a CD8 {@link arcade.agent.module.Inflammation} module. - *

    - * Initial amount of internal granzyme is set. - * Granzyme production parameters set. - * - * @param c the {@link arcade.agent.cell.CARTCell} the module is associated with - * @param sim the simulation instance - */ - public PatchProcessInflammationCD8(PatchCellCART c) { - super(c); - - // Set parameters. - Parameters parameters = cell.getParameters(); - this.GRANZ_SYNTHESIS_DELAY = parameters.getInt("inflammation/GRANZ_SYNTHESIS_DELAY"); - this.priorIL2granz = 0; - - // Initialize internal, external, and uptake concentration arrays. - amts[GRANZYME] = 1; // [molecules] - - // Molecule names. - names.add(GRANZYME, "granzyme"); - } + private static final double GRANZ_PER_IL2 = 0.005; + + /** Delay in IL-2 synthesis after antigen-induced activation */ + private final int GRANZ_SYNTHESIS_DELAY; + + /** Amount of IL-2 bound in past being used for current granzyme production calculation */ + private double priorIL2granz; + + /** + * Creates a CD8 {@link arcade.agent.module.Inflammation} module. + * + *

    Initial amount of internal granzyme is set. Granzyme production parameters set. + * + * @param c the {@link arcade.agent.cell.CARTCell} the module is associated with + * @param sim the simulation instance + */ + public PatchProcessInflammationCD8(PatchCellCART c) { + super(c); - public void stepProcess(MersenneTwisterFast random, Simulation sim) { - - // Determine amount of granzyme production based on if cell is activated - // as a function of IL-2 production. - int granzIndex = (IL2Ticker % boundArray.length) - GRANZ_SYNTHESIS_DELAY; - if (granzIndex < 0) { granzIndex += boundArray.length; } - priorIL2granz = boundArray[granzIndex]; + // Set parameters. + Parameters parameters = cell.getParameters(); + this.GRANZ_SYNTHESIS_DELAY = parameters.getInt("inflammation/GRANZ_SYNTHESIS_DELAY"); + this.priorIL2granz = 0; - if (active && activeTicker > GRANZ_SYNTHESIS_DELAY) { - amts[GRANZYME] += GRANZ_PER_IL2*(priorIL2granz/IL2_RECEPTORS); - } - - // Update environment. - // Convert units back from molecules to molecules/cm^3. - double IL2Env = ((extIL2 - (extIL2*f - amts[IL2_EXT]))*1E12/loc.getVolume()); + // Initialize internal, external, and uptake concentration arrays. + amts[GRANZYME] = 1; // [molecules] + + // Molecule names. + names.add(GRANZYME, "granzyme"); + } + + public void stepProcess(MersenneTwisterFast random, Simulation sim) { + + // Determine amount of granzyme production based on if cell is activated + // as a function of IL-2 production. + int granzIndex = (IL2Ticker % boundArray.length) - GRANZ_SYNTHESIS_DELAY; + if (granzIndex < 0) { + granzIndex += boundArray.length; + } + priorIL2granz = boundArray[granzIndex]; + + if (active && activeTicker > GRANZ_SYNTHESIS_DELAY) { + amts[GRANZYME] += GRANZ_PER_IL2 * (priorIL2granz / IL2_RECEPTORS); + } + + // Update environment. + // Convert units back from molecules to molecules/cm^3. + double IL2Env = ((extIL2 - (extIL2 * f - amts[IL2_EXT])) * 1E12 / loc.getVolume()); sim.getLattice("IL-2").setValue(loc, IL2Env); - } + } @Override public void update(Process mod) { - PatchProcessInflammationCD8 inflammation = (PatchProcessInflammationCD8) mod; + PatchProcessInflammationCD8 inflammation = (PatchProcessInflammationCD8) mod; double split = (this.cell.getVolume() / this.volume); - - // Update daughter cell inflammation as a fraction of parent. - // this.volume = this.cell.getVolume(); - this.amts[IL2Rbga] = inflammation.amts[IL2Rbga]*split; - this.amts[IL2_IL2Rbg] = inflammation.amts[IL2_IL2Rbg]*split; - this.amts[IL2_IL2Rbga] = inflammation.amts[IL2_IL2Rbga]*split; - this.amts[IL2Rbg] = IL2_RECEPTORS - this.amts[IL2Rbga] - this.amts[IL2_IL2Rbg] - this.amts[IL2_IL2Rbga]; - this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2Rbg] + this.amts[IL2_IL2Rbga]; - this.amts[IL2R_TOTAL] = this.amts[IL2Rbg] + this.amts[IL2Rbga]; - this.amts[GRANZYME] = inflammation.amts[GRANZYME]*split; - this.boundArray = (inflammation.boundArray).clone(); - - // Update parent cell with remaining fraction. - inflammation.amts[IL2Rbga] *= (1 - split); - inflammation.amts[IL2_IL2Rbg] *= (1 - split); - inflammation.amts[IL2_IL2Rbga] *= (1 - split); - inflammation.amts[IL2Rbg] = IL2_RECEPTORS - inflammation.amts[IL2Rbga] - inflammation.amts[IL2_IL2Rbg] - inflammation.amts[IL2_IL2Rbga]; - inflammation.amts[IL2_INT_TOTAL] = inflammation.amts[IL2_IL2Rbg] + inflammation.amts[IL2_IL2Rbga]; - inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2Rbg] + inflammation.amts[IL2Rbga]; - inflammation.amts[GRANZYME] *= (1 - split); - inflammation.volume *= (1 - split); - } + + // Update daughter cell inflammation as a fraction of parent. + // this.volume = this.cell.getVolume(); + this.amts[IL2Rbga] = inflammation.amts[IL2Rbga] * split; + this.amts[IL2_IL2Rbg] = inflammation.amts[IL2_IL2Rbg] * split; + this.amts[IL2_IL2Rbga] = inflammation.amts[IL2_IL2Rbga] * split; + this.amts[IL2Rbg] = + IL2_RECEPTORS - this.amts[IL2Rbga] - this.amts[IL2_IL2Rbg] - this.amts[IL2_IL2Rbga]; + this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2Rbg] + this.amts[IL2_IL2Rbga]; + this.amts[IL2R_TOTAL] = this.amts[IL2Rbg] + this.amts[IL2Rbga]; + this.amts[GRANZYME] = inflammation.amts[GRANZYME] * split; + this.boundArray = (inflammation.boundArray).clone(); + + // Update parent cell with remaining fraction. + inflammation.amts[IL2Rbga] *= (1 - split); + inflammation.amts[IL2_IL2Rbg] *= (1 - split); + inflammation.amts[IL2_IL2Rbga] *= (1 - split); + inflammation.amts[IL2Rbg] = + IL2_RECEPTORS + - inflammation.amts[IL2Rbga] + - inflammation.amts[IL2_IL2Rbg] + - inflammation.amts[IL2_IL2Rbga]; + inflammation.amts[IL2_INT_TOTAL] = + inflammation.amts[IL2_IL2Rbg] + inflammation.amts[IL2_IL2Rbga]; + inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2Rbg] + inflammation.amts[IL2Rbga]; + inflammation.amts[GRANZYME] *= (1 - split); + inflammation.volume *= (1 - split); + } } diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolism.java b/src/arcade/patch/agent/process/PatchProcessMetabolism.java index 8eda1831d..0473e6dc0 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolism.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolism.java @@ -8,7 +8,6 @@ import arcade.patch.agent.cell.PatchCell; import arcade.patch.env.grid.PatchGrid; import static arcade.patch.util.PatchEnums.State; -import sim.engine.SimState; /** * Implementation of {@link Process} for cell metabolism. diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java index ef9bf92b9..74ae29d6d 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java @@ -1,84 +1,81 @@ package arcade.patch.agent.process; import java.util.Arrays; +import ec.util.MersenneTwisterFast; import arcade.core.agent.process.Process; import arcade.core.sim.Simulation; import arcade.core.util.Parameters; import arcade.patch.agent.cell.PatchCell; import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.util.PatchEnums.Domain; -import ec.util.MersenneTwisterFast; public class PatchProcessMetabolismCART extends PatchProcessMetabolism { /** ID for pyruvate */ - public static final int PYRUVATE = 1; - - /** Flag indicating T-cell's antigen induced activation state. */ - private boolean active; - - /** Metabolic preference for glycolysis over oxidative phosphorylation */ - private final double metaPref; - - /** Minimal cell mass */ - private final double fracMass; - - /** Fraction of internal glucose/pyruvate converted to mass. */ + public static final int PYRUVATE = 1; + + /** Flag indicating T-cell's antigen induced activation state. */ + private boolean active; + + /** Metabolic preference for glycolysis over oxidative phosphorylation */ + private final double metaPref; + + /** Minimal cell mass */ + private final double fracMass; + + /** Fraction of internal glucose/pyruvate converted to mass. */ private final double conversionFraction; - - /** Preference for glucose over pyruvate for mass */ - private final double ratioGlucosePyruvate; - - /** Rate of lactate production */ - private final double lactateRate; - - /** Rate of autophagy */ - private final double autophagyRate; - - /** Rate of glucose uptake */ - private final double glucUptakeRate; - - /** Max incrase in metabolic preference for glycolysis over oxidative phosphorylation */ - private final double metabolicPreference_IL2; - - /** Increase in rate of glucose uptake due antigen-induced activation */ - private final double metabolicPreference_active; - - /** Max increase in rate of glucose uptake due to IL-2 bound to surface */ - private final double glucoseUptakeRate_IL2; - - /** Increase in rate of glucose uptake due to antigen-induced activation. */ - private final double glucoseUptakeRate_active; - - /** Increase in fraction of glucose used for cell mass due to antigen-induced activation. */ - private final double minimumMassFraction_active; - - /** Time delay for changes in metabolism. */ - private final int timeDelay; + + /** Preference for glucose over pyruvate for mass */ + private final double ratioGlucosePyruvate; + + /** Rate of lactate production */ + private final double lactateRate; + + /** Rate of autophagy */ + private final double autophagyRate; + + /** Rate of glucose uptake */ + private final double glucUptakeRate; + + /** Max incrase in metabolic preference for glycolysis over oxidative phosphorylation */ + private final double metabolicPreference_IL2; + + /** Increase in rate of glucose uptake due antigen-induced activation */ + private final double metabolicPreference_active; + + /** Max increase in rate of glucose uptake due to IL-2 bound to surface */ + private final double glucoseUptakeRate_IL2; + + /** Increase in rate of glucose uptake due to antigen-induced activation. */ + private final double glucoseUptakeRate_active; + + /** Increase in fraction of glucose used for cell mass due to antigen-induced activation. */ + private final double minimumMassFraction_active; + + /** Time delay for changes in metabolism. */ + private final int timeDelay; /** * Creates a metabolism {@link PatchProcess} for the given cell. - *

    - * Process parameters are specific for the cell population. - * Loaded parameters include: + * + *

    Process parameters are specific for the cell population. Loaded parameters include: + * *

      - *
    • {@code METABOLIC_PREFERENCE} = preference for glycolysis over - * oxidative phosphorylation
    • - *
    • {@code CONVERSION_FRACTION} = fraction of internal glucose / - * pyruvate converted to mass
    • - *
    • {@code MINIMUM_MASS_FRACTION} = minimum viable cell mass - * fraction
    • - *
    • {@code RATIO_GLUCOSE_PYRUVATE} = preference for glucose over - * pyruvate for mass
    • - *
    • {@code LACTATE_RATE} = rate of lactate production
    • - *
    • {@code AUTOPHAGY_RATE} = rate of autophagy
    • - *
    • {@code GLUCOSE_UPTAKE_RATE} = rate of glucose uptake
    • - *
    • {@code INITIAL_GLUCOSE_CONCENTRATION} = initial cell internal glucose concentration + *
    • {@code METABOLIC_PREFERENCE} = preference for glycolysis over oxidative phosphorylation + *
    • {@code CONVERSION_FRACTION} = fraction of internal glucose / pyruvate converted to mass + *
    • {@code MINIMUM_MASS_FRACTION} = minimum viable cell mass fraction + *
    • {@code RATIO_GLUCOSE_PYRUVATE} = preference for glucose over pyruvate for mass + *
    • {@code LACTATE_RATE} = rate of lactate production + *
    • {@code AUTOPHAGY_RATE} = rate of autophagy + *
    • {@code GLUCOSE_UPTAKE_RATE} = rate of glucose uptake + *
    • {@code INITIAL_GLUCOSE_CONCENTRATION} = initial cell internal glucose concentration *
    - * The process starts with energy at zero and assumes a constant ratio - * between mass and volume (through density). * - * @param cell the {@link PatchCell} the process is associated with + * The process starts with energy at zero and assumes a constant ratio between mass and volume + * (through density). + * + * @param cell the {@link PatchCell} the process is associated with */ public PatchProcessMetabolismCART(PatchCell cell) { super(cell); @@ -87,11 +84,11 @@ public PatchProcessMetabolismCART(PatchCell cell) { intNames[GLUCOSE] = "glucose"; intNames[PYRUVATE] = "pyruvate"; names = Arrays.asList(intNames); - + // Set loaded parameters. // TODO: pull metabolic preference from distribution Parameters parameters = cell.getParameters(); - metaPref = parameters.getDouble("metabolism/METABOLIC_PREFERENCE"); + metaPref = parameters.getDouble("metabolism/METABOLIC_PREFERENCE"); conversionFraction = parameters.getDouble("metabolism/CONVERSION_FRACTION"); fracMass = parameters.getDouble("metabolism/MINIMUM_MASS_FRACTION"); ratioGlucosePyruvate = parameters.getDouble("metabolism/RATIO_GLUCOSE_PYRUVATE"); @@ -113,39 +110,44 @@ public PatchProcessMetabolismCART(PatchCell cell) { intAmts[PYRUVATE] = intAmts[GLUCOSE] * PYRU_PER_GLUC; } - @Override + @Override void stepProcess(MersenneTwisterFast random, Simulation sim) { - double glucInt = intAmts[GLUCOSE]; // [fmol] + double glucInt = intAmts[GLUCOSE]; // [fmol] double pyruInt = intAmts[PYRUVATE]; // [fmol] - double glucExt = extAmts[GLUCOSE]; // [fmol] - double oxyExt = extAmts[OXYGEN]; // [fmol] - - PatchProcessInflammation inflammation = (PatchProcessInflammation) cell.getProcess(Domain.INFLAMMATION); - double[] boundArray = inflammation.boundArray; // [molecules] - int IL2Ticker = inflammation.IL2Ticker; - double IL2ReceptorsTotal = inflammation.IL2_RECEPTORS; - - int metaIndex = (IL2Ticker % boundArray.length) - timeDelay; - if (metaIndex < 0) { metaIndex += boundArray.length; } - double priorIL2meta = boundArray[metaIndex]; - - // Calculate metabolic preference and glucose uptake rate - // as a function of base values plus impact of IL-2 bound to surface. - double metabolicPreference = metaPref + (metabolicPreference_IL2 * (priorIL2meta/IL2ReceptorsTotal)); - double glucoseUptakeRate = glucUptakeRate + (glucoseUptakeRate_IL2 * (priorIL2meta/IL2ReceptorsTotal)); - double minimumMassFraction = fracMass; - - // Check active status - active = ((PatchCellCART) cell).getActivationStatus(); - double activeTicker = inflammation.activeTicker; - - // Add metabolic preference and glucose uptake rate depdendent on - // antigen-induced cell activation if cell is activated. - if (active && activeTicker >= timeDelay) { - metabolicPreference += metabolicPreference_active; - glucoseUptakeRate += glucoseUptakeRate_active; - minimumMassFraction += minimumMassFraction_active; - } + double glucExt = extAmts[GLUCOSE]; // [fmol] + double oxyExt = extAmts[OXYGEN]; // [fmol] + + PatchProcessInflammation inflammation = + (PatchProcessInflammation) cell.getProcess(Domain.INFLAMMATION); + double[] boundArray = inflammation.boundArray; // [molecules] + int IL2Ticker = inflammation.IL2Ticker; + double IL2ReceptorsTotal = inflammation.IL2_RECEPTORS; + + int metaIndex = (IL2Ticker % boundArray.length) - timeDelay; + if (metaIndex < 0) { + metaIndex += boundArray.length; + } + double priorIL2meta = boundArray[metaIndex]; + + // Calculate metabolic preference and glucose uptake rate + // as a function of base values plus impact of IL-2 bound to surface. + double metabolicPreference = + metaPref + (metabolicPreference_IL2 * (priorIL2meta / IL2ReceptorsTotal)); + double glucoseUptakeRate = + glucUptakeRate + (glucoseUptakeRate_IL2 * (priorIL2meta / IL2ReceptorsTotal)); + double minimumMassFraction = fracMass; + + // Check active status + active = ((PatchCellCART) cell).getActivationStatus(); + double activeTicker = inflammation.activeTicker; + + // Add metabolic preference and glucose uptake rate depdendent on + // antigen-induced cell activation if cell is activated. + if (active && activeTicker >= timeDelay) { + metabolicPreference += metabolicPreference_active; + glucoseUptakeRate += glucoseUptakeRate_active; + minimumMassFraction += minimumMassFraction_active; + } // Take up glucose from environment, relative to glucose gradient. // If agent shares location with other agents, occupied area for @@ -156,19 +158,19 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { glucGrad *= glucGrad < 1E-10 ? 0 : 1; double glucUptake = glucoseUptakeRate * surfaceArea * glucGrad; glucInt += glucUptake; - + // Determine energy requirement given current type in terms of glucose. // Additional energy needed for cell that is migrating or proliferating. // Arrays indicate oxidative phosphorylation (0) and glycolysis (1). - double[] energyGen = { 0, 0 }; + double[] energyGen = {0, 0}; double glucReq = metabolicPreference * energyReq / ENERGY_FROM_GLYC; double pyruReq = (1 - metabolicPreference) * energyReq / ENERGY_FROM_OXPHOS; - + // Calculate oxygen required and take up from environment. double oxyReq = pyruReq * OXY_PER_PYRU; double oxyUptake = Math.min(oxyExt, oxyReq); oxyUptake *= oxyUptake < 1E-10 ? 0 : 1; - + // Perform oxidative phosphorylation using internal pyruvate. double oxyUptakeInPyru = oxyUptake / OXY_PER_PYRU; if (pyruInt > oxyUptakeInPyru) { @@ -179,14 +181,14 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { oxyUptake = pyruInt * OXY_PER_PYRU; // return unused oxygen pyruInt = 0.0; // use up internal pyruvate } - + // Check if more glucose needs to be diverted to compensate for energy // deficit (from not enough oxygen) and is available. if (energy <= 0 && glucInt > 0) { double glucNeeded = -(energy - energyCons + energyGen[0]) / ENERGY_FROM_GLYC; glucReq = Math.max(glucReq, glucNeeded); } - + // Perform glycolysis. Internal glucose is converted to internal pyruvate // which is used in oxidative phosphorylation or to increase mass. if (glucInt > glucReq) { @@ -198,23 +200,26 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { pyruInt += glucInt * PYRU_PER_GLUC; // increase internal pyruvate glucInt = 0.0; // use up all internal glucose } - + // Update energy. energy += energyGen[0]; energy += energyGen[1]; energy -= energyCons; energy *= Math.abs(energy) < 1E-10 ? 0 : 1; - + // Increase mass if (i) dividing and less than double mass or (ii) // below critical mass for maintenance. if ((energy >= 0 && isProliferative && mass < 2 * critMass) || (energy >= 0 && mass < 0.99 * critMass)) { - mass += conversionFraction * (ratioGlucosePyruvate * glucInt - + (1 - ratioGlucosePyruvate) * pyruInt / PYRU_PER_GLUC) / ratioGlucoseBiomass; + mass += + conversionFraction + * (ratioGlucosePyruvate * glucInt + + (1 - ratioGlucosePyruvate) * pyruInt / PYRU_PER_GLUC) + / ratioGlucoseBiomass; glucInt *= (1 - conversionFraction * ratioGlucosePyruvate); pyruInt *= (1 - conversionFraction * (1 - ratioGlucosePyruvate)); } - + // Decrease mass through autophagy if (i) negative energy indicating // not enough nutrients or (ii) above critical mass for maintenance if ((energy < 0 && mass > minimumMassFraction * critMass) @@ -222,13 +227,13 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { mass -= autophagyRate; glucInt += autophagyRate * ratioGlucoseBiomass; } - + // Update volume based on changes in mass. volume = mass / cellDensity; - + // Convert internal pyruvate to lactate (i.e. remove pyruvate). pyruInt -= lactateRate * pyruInt; - + // Reset values. intAmts[GLUCOSE] = glucInt; upAmts[GLUCOSE] = glucUptake; @@ -236,23 +241,22 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { intAmts[PYRUVATE] = pyruInt; } - @Override public void update(Process process) { PatchProcessMetabolismCART metabolism = (PatchProcessMetabolismCART) process; double split = this.cell.getVolume() / this.volume; // Update daughter cell metabolism as fraction of parent. - this.energy = metabolism.energy*f; - this.intAmts[GLUCOSE] = metabolism.intAmts[GLUCOSE]*split; - this.intAmts[PYRUVATE] = metabolism.intAmts[PYRUVATE]*split; - - // Update parent cell with remaining fraction. - metabolism.energy *= (1 - split); - metabolism.intAmts[GLUCOSE] *= (1 - split); - metabolism.intAmts[PYRUVATE] *= (1 - split); - metabolism.volume *= (1 - split); - metabolism.mass *= (1 - split); + this.energy = metabolism.energy * f; + this.intAmts[GLUCOSE] = metabolism.intAmts[GLUCOSE] * split; + this.intAmts[PYRUVATE] = metabolism.intAmts[PYRUVATE] * split; + + // Update parent cell with remaining fraction. + metabolism.energy *= (1 - split); + metabolism.intAmts[GLUCOSE] *= (1 - split); + metabolism.intAmts[PYRUVATE] *= (1 - split); + metabolism.volume *= (1 - split); + metabolism.mass *= (1 - split); // PatchProcessMetabolismCART metabolism = (PatchProcessMetabolismCART) process; // double split = this.cell.getVolume() / this.volume; @@ -271,5 +275,4 @@ public void update(Process process) { // metabolism.intAmts[GLUCOSE] *= (1 - split); // metabolism.intAmts[PYRUVATE] *= (1 - split); } - } diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index 62e2ffce7..5c2c369ad 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -22,7 +22,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -73,7 +73,7 @@ - + @@ -87,20 +87,20 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -135,8 +135,8 @@ - - + + diff --git a/src/arcade/patch/sim/PatchSeries.java b/src/arcade/patch/sim/PatchSeries.java index af379b292..861002b09 100644 --- a/src/arcade/patch/sim/PatchSeries.java +++ b/src/arcade/patch/sim/PatchSeries.java @@ -95,7 +95,6 @@ protected void initialize(HashMap> setupLists, Box parame MiniBox patchDefaults = parameters.getIdValForTag("PATCH"); ArrayList patchBox = setupLists.get("patch"); updatePatch(patchBox, patchDefaults); - } /** diff --git a/src/arcade/patch/sim/PatchSimulation.java b/src/arcade/patch/sim/PatchSimulation.java index 9bdaa4e41..172cb3849 100644 --- a/src/arcade/patch/sim/PatchSimulation.java +++ b/src/arcade/patch/sim/PatchSimulation.java @@ -56,7 +56,7 @@ public abstract class PatchSimulation extends SimState implements Simulation { /** Lattice factory instance for the simulation. */ public final PatchLatticeFactory latticeFactory; - + /** * Simulation instance for a {@link Series} for given random seed. * @@ -165,7 +165,7 @@ public void start() { setupAgents(); setupEnvironment(); - + scheduleActions(); scheduleComponents(); diff --git a/src/arcade/patch/util/PatchEnums.java b/src/arcade/patch/util/PatchEnums.java index 2db77759d..f46b85e65 100644 --- a/src/arcade/patch/util/PatchEnums.java +++ b/src/arcade/patch/util/PatchEnums.java @@ -106,7 +106,7 @@ public enum State implements CellState { /** Code for starved cells. */ STARVED, - + /** Code for senescent cells. */ SENESCENT; @@ -131,7 +131,7 @@ public enum Domain implements ProcessDomain { /** Code for inflammation domain. */ INFLAMMATION, - + /** Code for signaling domain. */ SIGNALING; @@ -168,34 +168,34 @@ public static Flag random(MersenneTwisterFast rng) { } } - /** Antigen binding for CART simulations. */ + /** Antigen binding for CART simulations. */ public enum AntigenFlag { /** Code for undefined flag. */ UNDEFINED, - + /** Code for cell bound to antigen. */ BOUND_ANTIGEN, - + /** Code for cell bound to self. */ BOUND_CELL_RECEPTOR, /** Code for cell bound to self and antigen. */ BOUND_ANTIGEN_CELL_RECEPTOR, - + /** Code for cell bound to nothing. */ UNBOUND; - + /** * Randomly selects a {@code AntigenFlag}. * - * @param rng the random number generator - * @return a random {@code AntigenFlag} + * @param rng the random number generator + * @return a random {@code AntigenFlag} */ public static AntigenFlag random(MersenneTwisterFast rng) { return values()[rng.nextInt(values().length - 1) + 1]; } } - + /** Operation category codes for patch simulations. */ public enum Category implements OperationCategory { /** Code for undefined category. */ diff --git a/src/arcade/patch/vis/PatchColorMaps.java b/src/arcade/patch/vis/PatchColorMaps.java index 05a819742..cdd4685a4 100644 --- a/src/arcade/patch/vis/PatchColorMaps.java +++ b/src/arcade/patch/vis/PatchColorMaps.java @@ -310,7 +310,7 @@ class PatchColorMaps { 6. / 7 * tgfa, tgfa, }); - + double il2 = series.layers.get("IL-2").getDouble("INITIAL_CONCENTRATION"); mapIL2 = diff --git a/test/arcade/patch/agent/cell/PatchCARTCellTest.java b/test/arcade/patch/agent/cell/PatchCARTCellTest.java index 561c53ef8..264994f29 100644 --- a/test/arcade/patch/agent/cell/PatchCARTCellTest.java +++ b/test/arcade/patch/agent/cell/PatchCARTCellTest.java @@ -1,40 +1,28 @@ package arcade.patch.agent.cell; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.stubbing.Answer; - -import static arcade.core.ARCADETestUtilities.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.anyDouble; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - import java.util.ArrayList; import java.util.Arrays; - -import arcade.core.util.MiniBox; -import arcade.patch.agent.module.PatchModule; -import arcade.patch.env.location.PatchLocation; -import arcade.patch.util.PatchEnums.Flag; -import arcade.patch.util.PatchEnums.AntigenFlag; -import arcade.patch.util.PatchEnums.Domain; -import arcade.patch.util.PatchEnums.State; -import ec.util.MersenneTwisterFast; +import org.junit.BeforeClass; +import org.junit.Test; import sim.util.Bag; -import arcade.patch.env.grid.PatchGrid; +import ec.util.MersenneTwisterFast; import arcade.core.agent.cell.Cell; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; +import arcade.core.util.MiniBox; +import arcade.patch.env.grid.PatchGrid; +import arcade.patch.env.location.PatchLocation; +import arcade.patch.util.PatchEnums.AntigenFlag; +import arcade.patch.util.PatchEnums.State; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static arcade.core.ARCADETestUtilities.*; public class PatchCARTCellTest { - + private static final double EPSILON = 1E-8; - + private static final MersenneTwisterFast RANDOM = new MersenneTwisterFast(randomSeed()); static int cellID = randomIntBetween(1, 10); @@ -54,7 +42,6 @@ public class PatchCARTCellTest { static double cellCriticalVolume = randomDoubleBetween(10, 100); static double cellCriticalHeight = randomDoubleBetween(10, 100); - static State cellState = State.QUIESCENT; @@ -68,7 +55,6 @@ public class PatchCARTCellTest { static Simulation simMock; static MersenneTwisterFast random; - @BeforeClass public static void setupMocks() { parametersMock = mock(MiniBox.class); @@ -76,215 +62,336 @@ public static void setupMocks() { gridMock = mock(PatchGrid.class); simMock = mock(Simulation.class); random = new MersenneTwisterFast(); - - //make both a default CD4 cell and a CD8 cell - cellDefaultCD4 = new PatchCellCARTCD4(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); - - cellDefaultCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); - cellDefault = new PatchCellTissue(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + + // make both a default CD4 cell and a CD8 cell + cellDefaultCD4 = + new PatchCellCARTCD4( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); + + cellDefaultCD8 = + new PatchCellCARTCD8( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); + cellDefault = + new PatchCellTissue( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); } - - //test bindTarget() + + // test bindTarget() // Test if bind targets grab all agents in this location, and all neighbors of this location @Test public void bind_target_grabs_all_neighbors() { - //adding all dummy neighbors for this cell + // adding all dummy neighbors for this cell Bag sampleBag = new Bag(); Bag dummyBag = new Bag(); - for (int i = 0; i <=5; i++) { - sampleBag.add(cellDefaultCD8.make(cellID+i+1,cellState, locationMock, random)); - dummyBag.add(cellDefaultCD8.make(cellID+i+6,cellState, locationMock, random)); + for (int i = 0; i <= 5; i++) { + sampleBag.add(cellDefaultCD8.make(cellID + i + 1, cellState, locationMock, random)); + dummyBag.add(cellDefaultCD8.make(cellID + i + 6, cellState, locationMock, random)); } - //setting up mocks + // setting up mocks when(simMock.getGrid()).thenReturn(gridMock); when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); PatchLocation dummyNeighbor = mock(PatchLocation.class); - when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList(dummyNeighbor))); + when(locationMock.getNeighbors()) + .thenReturn(new ArrayList(Arrays.asList(dummyNeighbor))); when(gridMock.getObjectsAtLocation(dummyNeighbor)).thenReturn(dummyBag); - //number of neighbors should be the size of the bags we just established + // number of neighbors should be the size of the bags we just established int neighbors = sampleBag.size() * 2; - //set searchAbility to neighbors + 1 so it will always be more than neighbors - when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(neighbors+1.0); - //make new cell - PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + // set searchAbility to neighbors + 1 so it will always be more than neighbors + when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(neighbors + 1.0); + // make new cell + PatchCellCARTCD8 sampleCellCD8 = + new PatchCellCARTCD8( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); sampleCellCD8.bindTarget(simMock, locationMock, random); - //check that searchAbility is now neighbors if there are less neighbors than search ability - assertEquals(sampleCellCD8.searchAbility, neighbors, EPSILON); + // check that searchAbility is now neighbors if there are less neighbors than search ability + assertEquals(sampleCellCD8.searchAbility, neighbors, EPSILON); } - //Test that it is removing itself from potential neighbors + // Test that it is removing itself from potential neighbors @Test - public void bind_target_removes_self_from_neighbors(){ - //adding all dummy neighbors for this cell + public void bind_target_removes_self_from_neighbors() { + // adding all dummy neighbors for this cell Bag sampleBag = new Bag(); - for (int i = 0; i <=5; i++) { - sampleBag.add(cellDefaultCD8.make(cellID+i+1,cellState, locationMock, random)); + for (int i = 0; i <= 5; i++) { + sampleBag.add(cellDefaultCD8.make(cellID + i + 1, cellState, locationMock, random)); } - //number of neighbors should be the size of the bags we just established + // number of neighbors should be the size of the bags we just established // +1 because we will be adding it in later int neighbors = sampleBag.size() + 1; - //set searchAbility to neighbors to verify that it eventually removes self + // set searchAbility to neighbors to verify that it eventually removes self when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(neighbors * 1.0); - //make new cell - PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); - //adding self to neighbors + // make new cell + PatchCellCARTCD8 sampleCellCD8 = + new PatchCellCARTCD8( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); + // adding self to neighbors sampleBag.add(sampleCellCD8); - //setting up mocks + // setting up mocks when(simMock.getGrid()).thenReturn(gridMock); when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList())); sampleCellCD8.bindTarget(simMock, locationMock, random); - //check that searchAbility is now neighbors if there are less neighbors than search ability - assertEquals(sampleCellCD8.searchAbility, neighbors-1, EPSILON); + // check that searchAbility is now neighbors if there are less neighbors than search ability + assertEquals(sampleCellCD8.searchAbility, neighbors - 1, EPSILON); } - //Test that it is not binding to other T cells - @Test - public void bind_target_removes_avoid_tcells(){ - //adding all dummy tcell neighbors for this cell + // Test that it is not binding to other T cells + @Test + public void bind_target_removes_avoid_tcells() { + // adding all dummy tcell neighbors for this cell Bag sampleBag = new Bag(); - for (int i = 0; i <=5; i++) { - sampleBag.add(cellDefaultCD8.make(cellID+i+1,cellState, locationMock, random)); + for (int i = 0; i <= 5; i++) { + sampleBag.add(cellDefaultCD8.make(cellID + i + 1, cellState, locationMock, random)); } - //set searchAbility to some number that accomodates all neighbors + // set searchAbility to some number that accomodates all neighbors when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(sampleBag.size() + 1.0); - //make new cell - PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); - //setting up mocks + // make new cell + PatchCellCARTCD8 sampleCellCD8 = + new PatchCellCARTCD8( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); + // setting up mocks when(simMock.getGrid()).thenReturn(gridMock); when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList())); sampleCellCD8.bindTarget(simMock, locationMock, random); - //check that the cell is not binding to anything + // check that the cell is not binding to anything assertEquals(sampleCellCD8.getAntigenFlag(), AntigenFlag.UNDEFINED); } - - //Test that it is not binding to apoptotic cells + + // Test that it is not binding to apoptotic cells @Test - public void bind_target_removes_avoid_apoptotic_cells(){ - //adding all dummy apoptotic neighbors for this cell + public void bind_target_removes_avoid_apoptotic_cells() { + // adding all dummy apoptotic neighbors for this cell Bag sampleBag = new Bag(); - for (int i = 0; i <=5; i++) { - Cell dummyCell = cellDefault.make(cellID+i+1,cellState, locationMock, random); + for (int i = 0; i <= 5; i++) { + Cell dummyCell = cellDefault.make(cellID + i + 1, cellState, locationMock, random); dummyCell.setState(State.APOPTOTIC); sampleBag.add(dummyCell); } - //set searchAbility to some number that accomodates all neighbors + // set searchAbility to some number that accomodates all neighbors when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(sampleBag.size() + 1.0); - //make new cell - PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); - //setting up mocks + // make new cell + PatchCellCARTCD8 sampleCellCD8 = + new PatchCellCARTCD8( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); + // setting up mocks when(simMock.getGrid()).thenReturn(gridMock); when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList())); sampleCellCD8.bindTarget(simMock, locationMock, random); - //check that the cell is not binding to anything + // check that the cell is not binding to anything assertEquals(sampleCellCD8.getAntigenFlag(), AntigenFlag.UNDEFINED); } - - //Test that it is not binding to necrotic cells - @Test - public void bind_target_removes_avoid_necrotic_cells(){ - //adding all dummy necrotic neighbors for this cell + + // Test that it is not binding to necrotic cells + @Test + public void bind_target_removes_avoid_necrotic_cells() { + // adding all dummy necrotic neighbors for this cell Bag sampleBag = new Bag(); - for (int i = 0; i <=5; i++) { - Cell dummyCell = cellDefault.make(cellID+i+1,cellState, locationMock, random); + for (int i = 0; i <= 5; i++) { + Cell dummyCell = cellDefault.make(cellID + i + 1, cellState, locationMock, random); dummyCell.setState(State.NECROTIC); sampleBag.add(dummyCell); } - //set searchAbility to some number that accomodates all neighbors + // set searchAbility to some number that accomodates all neighbors when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(sampleBag.size() + 1.0); - //make new cell - PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); - //setting up mocks + // make new cell + PatchCellCARTCD8 sampleCellCD8 = + new PatchCellCARTCD8( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); + // setting up mocks when(simMock.getGrid()).thenReturn(gridMock); when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList())); sampleCellCD8.bindTarget(simMock, locationMock, random); - //check that the cell is not binding to anything + // check that the cell is not binding to anything assertEquals(sampleCellCD8.getAntigenFlag(), AntigenFlag.UNDEFINED); } - //Test that maxSearch is calculated correctly when neighbors > searchAbility + // Test that maxSearch is calculated correctly when neighbors > searchAbility @Test public void maxSearch_returns_neighbors_when_less() { - //set searchAbility to some number + // set searchAbility to some number when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(2.0); - //make new cell - PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); - //make allAgents greater than searchAbility + // make new cell + PatchCellCARTCD8 sampleCellCD8 = + new PatchCellCARTCD8( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); + // make allAgents greater than searchAbility Bag sampleBag = new Bag(); - for (int i = 0; i <=5; i++) { - sampleBag.add(cellDefaultCD8.make(cellID+i+1,cellState, locationMock, random)); + for (int i = 0; i <= 5; i++) { + sampleBag.add(cellDefaultCD8.make(cellID + i + 1, cellState, locationMock, random)); } when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); when(simMock.getGrid()).thenReturn(gridMock); when(locationMock.getNeighbors()).thenReturn(new ArrayList()); sampleCellCD8.bindTarget(simMock, locationMock, random); - //check that searchAbility stays the same - assertEquals(sampleCellCD8.searchAbility, 2, EPSILON); + // check that searchAbility stays the same + assertEquals(sampleCellCD8.searchAbility, 2, EPSILON); } - - //Test that maxSearch is calculated correctly when neighbors < searchAbility + + // Test that maxSearch is calculated correctly when neighbors < searchAbility @Test public void maxSearch_returns_neighbors_when_more() { - //set searchAbility to some number + // set searchAbility to some number when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(6.0); - //make new cell - PatchCellCARTCD8 sampleCellCD8 = new PatchCellCARTCD8(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); - //make allAgents less than searchAbility + // make new cell + PatchCellCARTCD8 sampleCellCD8 = + new PatchCellCARTCD8( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); + // make allAgents less than searchAbility Bag sampleBag = new Bag(); - for (int i = 0; i <=5; i++) { - sampleBag.add(cellDefaultCD8.make(cellID+i+1,cellState, locationMock, random)); + for (int i = 0; i <= 5; i++) { + sampleBag.add(cellDefaultCD8.make(cellID + i + 1, cellState, locationMock, random)); } when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); when(simMock.getGrid()).thenReturn(gridMock); when(locationMock.getNeighbors()).thenReturn(new ArrayList()); sampleCellCD8.bindTarget(simMock, locationMock, random); - //check that searchAbility stays the same - assertEquals(sampleCellCD8.searchAbility, sampleBag.size(), EPSILON); + // check that searchAbility stays the same + assertEquals(sampleCellCD8.searchAbility, sampleBag.size(), EPSILON); } - - //Is it worth testing these cases?????? - - //logCAR >= randomAntigen && logSelf < randomSelf - //set random antigen and random self that fits conditions - //verify flag set - //verify antigen count incremented - //verify self receptors calculated correctly - - //logCAR >= randomAntigen && logSelf >= randomSelf - //set random antigen and random self that fits conditions - //verify flag set - //verify antigen count incremented - //verify self receptors calculated correctly - - //logCAR < randomAntigen && logSelf >= randomSelf - //set random antigen and random self that fits conditions - //verify flag set - //verify antigen count incremented - //verify self receptors calculated correctly - - //logCAR < randomAntigen && logSelf < randomSelf - //set random antigen and random self that fits conditions - //verify flag set to unbound + + // Is it worth testing these cases?????? + + // logCAR >= randomAntigen && logSelf < randomSelf + // set random antigen and random self that fits conditions + // verify flag set + // verify antigen count incremented + // verify self receptors calculated correctly + + // logCAR >= randomAntigen && logSelf >= randomSelf + // set random antigen and random self that fits conditions + // verify flag set + // verify antigen count incremented + // verify self receptors calculated correctly + + // logCAR < randomAntigen && logSelf >= randomSelf + // set random antigen and random self that fits conditions + // verify flag set + // verify antigen count incremented + // verify self receptors calculated correctly + + // logCAR < randomAntigen && logSelf < randomSelf + // set random antigen and random self that fits conditions + // verify flag set to unbound } diff --git a/test/arcade/patch/agent/cell/PatchCellTest.java b/test/arcade/patch/agent/cell/PatchCellTest.java index 2b0f91a32..7d9df507a 100644 --- a/test/arcade/patch/agent/cell/PatchCellTest.java +++ b/test/arcade/patch/agent/cell/PatchCellTest.java @@ -2,48 +2,46 @@ import org.junit.BeforeClass; import org.junit.Test; - -import static arcade.core.ARCADETestUtilities.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.mockito.Mockito.mock; - +import sim.util.Bag; +import ec.util.MersenneTwisterFast; import arcade.core.util.MiniBox; import arcade.patch.env.location.PatchLocation; -import arcade.patch.util.PatchEnums.Flag; import arcade.patch.util.PatchEnums.Domain; +import arcade.patch.util.PatchEnums.Flag; import arcade.patch.util.PatchEnums.State; -import ec.util.MersenneTwisterFast; -import sim.util.Bag; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.mockito.Mockito.mock; +import static arcade.core.ARCADETestUtilities.*; public class PatchCellTest { private static final double EPSILON = 1E-8; - + private static final MersenneTwisterFast RANDOM = new MersenneTwisterFast(randomSeed()); - + static int cellID = randomIntBetween(1, 10); - + static int cellParent = randomIntBetween(1, 10); - + static int cellPop = randomIntBetween(1, 10); - + static int cellAge = randomIntBetween(1, 1000); - + static int cellDivisions = randomIntBetween(1, 100); static double cellVolume = randomDoubleBetween(10, 100); - + static double cellHeight = randomDoubleBetween(10, 100); - + static double cellCriticalVolume = randomDoubleBetween(10, 100); - + static double cellCriticalHeight = randomDoubleBetween(10, 100); - + static State cellState = State.QUIESCENT; - + static PatchCellTissue cellDefault; - + static MiniBox parametersMock; static PatchLocation locationMock; @@ -51,11 +49,23 @@ public class PatchCellTest { public static void setupMocks() { parametersMock = mock(MiniBox.class); locationMock = mock(PatchLocation.class); - - cellDefault = new PatchCellTissue(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + + cellDefault = + new PatchCellTissue( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); } - + @Test public void getID_defaultConstructor_returnsValue() { assertEquals(cellID, cellDefault.getID()); @@ -69,8 +79,20 @@ public void getParent_defaultConstructor_returnsValue() { @Test public void getParent_valueAssigned_returnsValue() { int parent = randomIntBetween(0, 100); - PatchCellTissue cell = new PatchCellTissue(cellID, parent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + PatchCellTissue cell = + new PatchCellTissue( + cellID, + parent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); assertEquals(parent, cell.getParent()); } @@ -82,8 +104,20 @@ public void getPop_defaultConstructor_returnsValue() { @Test public void getPop_valueAssigned_returnsValue() { int pop = randomIntBetween(0, 100); - PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, pop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + PatchCellTissue cell = + new PatchCellTissue( + cellID, + cellParent, + pop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); assertEquals(pop, cell.getPop()); } @@ -95,8 +129,20 @@ public void getState_defaultConstructor_returnsValue() { @Test public void getState_valueAssigned_returnsValue() { State state = State.random(RANDOM); - PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, cellPop, state, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + PatchCellTissue cell = + new PatchCellTissue( + cellID, + cellParent, + cellPop, + state, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); assertEquals(state, cell.getState()); } @@ -108,8 +154,20 @@ public void getAge_defaultConstructor_returnsValue() { @Test public void getAge_valueAssigned_returnsValue() { int age = randomIntBetween(0, 100); - PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, cellPop, cellState, age, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + PatchCellTissue cell = + new PatchCellTissue( + cellID, + cellParent, + cellPop, + cellState, + age, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); assertEquals(age, cell.getAge()); } @@ -121,8 +179,20 @@ public void getDivisions_defaultConstructor_returnsValue() { @Test public void getDivisions_valueAssigned_returnsValue() { int divisions = randomIntBetween(0, 100); - PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, cellPop, cellState, cellAge, divisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + PatchCellTissue cell = + new PatchCellTissue( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + divisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); assertEquals(divisions, cell.getDivisions()); } @@ -148,43 +218,67 @@ public void getParameters_defaultConstructor_returnsObject() { @Test public void getVolume_defaultConstructor_returnsValue() { - assertEquals(cellVolume, cellDefault.getVolume(),EPSILON); + assertEquals(cellVolume, cellDefault.getVolume(), EPSILON); } @Test public void getHeight_defaultConstructor_returnsValue() { - assertEquals(cellHeight, cellDefault.getHeight(),EPSILON); + assertEquals(cellHeight, cellDefault.getHeight(), EPSILON); } @Test public void getCriticalVolume_defaultConstructor_returnsValue() { - assertEquals(cellCriticalVolume, cellDefault.getCriticalVolume(),EPSILON); + assertEquals(cellCriticalVolume, cellDefault.getCriticalVolume(), EPSILON); } @Test public void getCriticalHeight_defaultConstructor_returnsValue() { - assertEquals(cellCriticalHeight, cellDefault.getCriticalHeight(),EPSILON); + assertEquals(cellCriticalHeight, cellDefault.getCriticalHeight(), EPSILON); } @Test public void getEnergy_defaultConstructor_returnsValue() { - assertEquals(0, cellDefault.getEnergy(),EPSILON); + assertEquals(0, cellDefault.getEnergy(), EPSILON); } @Test public void setEnergy_returnsValue() { double energy = randomDoubleBetween(0, 100); - PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, cellPop, cellState,cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + PatchCellTissue cell = + new PatchCellTissue( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); cell.setEnergy(energy); - assertEquals(energy, cell.getEnergy(),EPSILON); + assertEquals(energy, cell.getEnergy(), EPSILON); } @Test public void setFlag_valueAssigned_returnsValue() { Flag flag = Flag.random(RANDOM); - PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, cellVolume, cellHeight, cellCriticalVolume, cellCriticalHeight); + PatchCellTissue cell = + new PatchCellTissue( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); cell.setFlag(flag); assertEquals(flag, cell.flag); } @@ -193,7 +287,7 @@ public void setFlag_valueAssigned_returnsValue() { public void convert_createsContainer() { PatchLocation location = mock(PatchLocation.class); MiniBox parameters = mock(MiniBox.class); - + int id = randomIntBetween(1, 10); int parent = randomIntBetween(1, 10); int pop = randomIntBetween(1, 10); @@ -204,12 +298,24 @@ public void convert_createsContainer() { double criticalHeight = randomDoubleBetween(10, 100); double volume = randomDoubleBetween(10, 100); double height = randomDoubleBetween(10, 100); - - PatchCellTissue cell = new PatchCellTissue(id, parent, pop, state, age, divisions, - location, parameters, volume, height, criticalVolume, criticalHeight); - + + PatchCellTissue cell = + new PatchCellTissue( + id, + parent, + pop, + state, + age, + divisions, + location, + parameters, + volume, + height, + criticalVolume, + criticalHeight); + PatchCellContainer container = (PatchCellContainer) cell.convert(); - + assertEquals(id, container.id); assertEquals(parent, container.parent); assertEquals(pop, container.pop); @@ -224,16 +330,28 @@ public void convert_createsContainer() { public void calculate_total_volume_returnsValue() { Bag cells = new Bag(); double runningSum = 0; - for (int i = 0; i < randomIntBetween(1,10); i++) { + for (int i = 0; i < randomIntBetween(1, 10); i++) { double v = randomDoubleBetween(10, 100); - PatchCellTissue cell = new PatchCellTissue(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - locationMock, parametersMock, v, cellHeight, cellCriticalVolume, cellCriticalHeight); + PatchCellTissue cell = + new PatchCellTissue( + cellID, + cellParent, + cellPop, + cellState, + cellAge, + cellDivisions, + locationMock, + parametersMock, + v, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); cells.add(cell); - runningSum+=v; + runningSum += v; } assertEquals(runningSum, PatchCell.calculateTotalVolume(cells), EPSILON); } - //once implemented, make sure location methods and step is working - + // once implemented, make sure location methods and step is working + } diff --git a/test/arcade/patch/util/PatchEnumsTest.java b/test/arcade/patch/util/PatchEnumsTest.java index 052da1919..02d3c692e 100644 --- a/test/arcade/patch/util/PatchEnumsTest.java +++ b/test/arcade/patch/util/PatchEnumsTest.java @@ -7,12 +7,12 @@ import ec.util.MersenneTwisterFast; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; -import static arcade.patch.util.PatchEnums.Flag; +import static arcade.patch.util.PatchEnums.AntigenFlag; +import static arcade.patch.util.PatchEnums.Category; import static arcade.patch.util.PatchEnums.Domain; +import static arcade.patch.util.PatchEnums.Flag; import static arcade.patch.util.PatchEnums.Ordering; import static arcade.patch.util.PatchEnums.State; -import static arcade.patch.util.PatchEnums.Category; -import static arcade.patch.util.PatchEnums.AntigenFlag; public class PatchEnumsTest { @Test @@ -46,17 +46,17 @@ public void Domain_random_returnsDomain() { // Create set of all values. EnumSet enumSet = EnumSet.allOf(Domain.class); enumSet.remove(Domain.UNDEFINED); - + // Create set of all random values. ArrayList enumRandom = new ArrayList<>(); - + int n = Domain.values().length - 1; for (int i = 0; i < n; i++) { MersenneTwisterFast rng = mock(MersenneTwisterFast.class); doReturn(i).when(rng).nextInt(n); enumRandom.add(Domain.random(rng)); } - + // Compare resulting sets. EnumSet enumSetRandom = EnumSet.copyOf(enumRandom); assertEquals(enumSet, enumSetRandom); @@ -67,17 +67,17 @@ public void State_random_returnsState() { // Create set of all values. EnumSet enumSet = EnumSet.allOf(State.class); enumSet.remove(State.UNDEFINED); - + // Create set of all random values. ArrayList enumRandom = new ArrayList<>(); - + int n = State.values().length - 1; for (int i = 0; i < n; i++) { MersenneTwisterFast rng = mock(MersenneTwisterFast.class); doReturn(i).when(rng).nextInt(n); enumRandom.add(State.random(rng)); } - + // Compare resulting sets. EnumSet enumSetRandom = EnumSet.copyOf(enumRandom); assertEquals(enumSet, enumSetRandom); @@ -88,17 +88,17 @@ public void Category_random_returnsCategory() { // Create set of all values. EnumSet enumSet = EnumSet.allOf(Category.class); enumSet.remove(Category.UNDEFINED); - + // Create set of all random values. ArrayList enumRandom = new ArrayList<>(); - + int n = Category.values().length - 1; for (int i = 0; i < n; i++) { MersenneTwisterFast rng = mock(MersenneTwisterFast.class); doReturn(i).when(rng).nextInt(n); enumRandom.add(Category.random(rng)); } - + // Compare resulting sets. EnumSet enumSetRandom = EnumSet.copyOf(enumRandom); assertEquals(enumSet, enumSetRandom); @@ -109,17 +109,17 @@ public void AntigenFlag_random_returnsAntigenFlag() { // Create set of all values. EnumSet enumSet = EnumSet.allOf(AntigenFlag.class); enumSet.remove(AntigenFlag.UNDEFINED); - + // Create set of all random values. ArrayList enumRandom = new ArrayList<>(); - + int n = AntigenFlag.values().length - 1; for (int i = 0; i < n; i++) { MersenneTwisterFast rng = mock(MersenneTwisterFast.class); doReturn(i).when(rng).nextInt(n); enumRandom.add(AntigenFlag.random(rng)); } - + // Compare resulting sets. EnumSet enumSetRandom = EnumSet.copyOf(enumRandom); assertEquals(enumSet, enumSetRandom); @@ -129,11 +129,11 @@ public void AntigenFlag_random_returnsAntigenFlag() { public void Ordering_in_expected_order() { // Create list of all values. ArrayList enumList = new ArrayList(Arrays.asList(Ordering.values())); - + int n = -1; int verify = -2; // Grabbing order of items in enum - for (Ordering x: enumList){ + for (Ordering x : enumList) { verify = x.ordinal(); n++; // Verify order of enum From 8956e485714420d2d1605c86f00a285d4389a8b1 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 15 Nov 2024 22:33:34 +0000 Subject: [PATCH 033/185] reverting some files to main --- src/arcade/patch/vis/PatchColorMaps.java | 19 - src/arcade/patch/vis/PatchVisualization.java | 18 - .../patch/agent/cell/PatchCARTCellTest.java | 397 ------------------ .../patch/agent/cell/PatchCellTest.java | 357 ---------------- 4 files changed, 791 deletions(-) delete mode 100644 test/arcade/patch/agent/cell/PatchCARTCellTest.java delete mode 100644 test/arcade/patch/agent/cell/PatchCellTest.java diff --git a/src/arcade/patch/vis/PatchColorMaps.java b/src/arcade/patch/vis/PatchColorMaps.java index cdd4685a4..e0536e036 100644 --- a/src/arcade/patch/vis/PatchColorMaps.java +++ b/src/arcade/patch/vis/PatchColorMaps.java @@ -161,9 +161,6 @@ class PatchColorMaps { /** Color map for TGFa concentration. */ final Colors mapTGFa; - /** Color map for IL2 concentration. */ - final Colors mapIL2; - /** * Creates {@code ColorMaps} for the given series. * @@ -310,21 +307,5 @@ class PatchColorMaps { 6. / 7 * tgfa, tgfa, }); - - double il2 = series.layers.get("IL-2").getDouble("INITIAL_CONCENTRATION"); - - mapIL2 = - new Colors( - DARK_MINT, - new double[] { - 0, - 1. / 7 * il2, - 2. / 7 * il2, - 3. / 7 * il2, - 4. / 7 * il2, - 5. / 7 * il2, - 6. / 7 * il2, - il2, - }); } } diff --git a/src/arcade/patch/vis/PatchVisualization.java b/src/arcade/patch/vis/PatchVisualization.java index 930b0d756..0f0032804 100644 --- a/src/arcade/patch/vis/PatchVisualization.java +++ b/src/arcade/patch/vis/PatchVisualization.java @@ -111,18 +111,9 @@ Drawer[] createHexDrawers() { height, maps.mapTGFa, getBox(0, 2 * v, h, v)), - new PatchDrawerHex.PatchLayers( - panels[1], - "environment:CONCENTRATION:IL2", - length, - width, - height, - maps.mapIL2, - getBox(0, 2 * v, h, v)), new PatchDrawer.Label(panels[1], "label", 0, 0, "GLUCOSE"), new PatchDrawer.Label(panels[1], "label", 0, 33, "OXYGEN"), new PatchDrawer.Label(panels[1], "label", 0, 67, "TGFα"), - new PatchDrawer.Label(panels[1], "label", 0, 100, "IL2"), new PatchDrawerHex.PatchCells( panels[2], "agents:VOLUME", @@ -275,18 +266,9 @@ Drawer[] createRectDrawers() { height, maps.mapTGFa, getBox(0, 2 * v, h, v)), - new PatchDrawerHex.PatchLayers( - panels[1], - "environment:CONCENTRATION:IL2", - length, - width, - height, - maps.mapIL2, - getBox(0, 2 * v, h, v)), new PatchDrawer.Label(panels[1], "label", 0, 0, "GLUCOSE"), new PatchDrawer.Label(panels[1], "label", 0, 33, "OXYGEN"), new PatchDrawer.Label(panels[1], "label", 0, 67, "TGFα"), - new PatchDrawer.Label(panels[1], "label", 0, 100, "IL2"), new PatchDrawerRect.PatchCells( panels[2], "agents:VOLUME", diff --git a/test/arcade/patch/agent/cell/PatchCARTCellTest.java b/test/arcade/patch/agent/cell/PatchCARTCellTest.java deleted file mode 100644 index 264994f29..000000000 --- a/test/arcade/patch/agent/cell/PatchCARTCellTest.java +++ /dev/null @@ -1,397 +0,0 @@ -package arcade.patch.agent.cell; - -import java.util.ArrayList; -import java.util.Arrays; -import org.junit.BeforeClass; -import org.junit.Test; -import sim.util.Bag; -import ec.util.MersenneTwisterFast; -import arcade.core.agent.cell.Cell; -import arcade.core.env.location.Location; -import arcade.core.sim.Simulation; -import arcade.core.util.MiniBox; -import arcade.patch.env.grid.PatchGrid; -import arcade.patch.env.location.PatchLocation; -import arcade.patch.util.PatchEnums.AntigenFlag; -import arcade.patch.util.PatchEnums.State; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static arcade.core.ARCADETestUtilities.*; - -public class PatchCARTCellTest { - - private static final double EPSILON = 1E-8; - - private static final MersenneTwisterFast RANDOM = new MersenneTwisterFast(randomSeed()); - - static int cellID = randomIntBetween(1, 10); - - static int cellParent = randomIntBetween(1, 10); - - static int cellPop = randomIntBetween(1, 10); - - static int cellAge = randomIntBetween(1, 1000); - - static int cellDivisions = randomIntBetween(1, 100); - - static double cellVolume = randomDoubleBetween(10, 100); - - static double cellHeight = randomDoubleBetween(10, 100); - - static double cellCriticalVolume = randomDoubleBetween(10, 100); - - static double cellCriticalHeight = randomDoubleBetween(10, 100); - - static State cellState = State.QUIESCENT; - - static PatchCellCART cellDefaultCD4; - static PatchCellCART cellDefaultCD8; - static PatchCell cellDefault; - - static MiniBox parametersMock; - static PatchLocation locationMock; - static PatchGrid gridMock; - static Simulation simMock; - static MersenneTwisterFast random; - - @BeforeClass - public static void setupMocks() { - parametersMock = mock(MiniBox.class); - locationMock = mock(PatchLocation.class); - gridMock = mock(PatchGrid.class); - simMock = mock(Simulation.class); - random = new MersenneTwisterFast(); - - // make both a default CD4 cell and a CD8 cell - cellDefaultCD4 = - new PatchCellCARTCD4( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - - cellDefaultCD8 = - new PatchCellCARTCD8( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - cellDefault = - new PatchCellTissue( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - } - - // test bindTarget() - - // Test if bind targets grab all agents in this location, and all neighbors of this location - @Test - public void bind_target_grabs_all_neighbors() { - // adding all dummy neighbors for this cell - Bag sampleBag = new Bag(); - Bag dummyBag = new Bag(); - for (int i = 0; i <= 5; i++) { - sampleBag.add(cellDefaultCD8.make(cellID + i + 1, cellState, locationMock, random)); - dummyBag.add(cellDefaultCD8.make(cellID + i + 6, cellState, locationMock, random)); - } - // setting up mocks - when(simMock.getGrid()).thenReturn(gridMock); - when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); - PatchLocation dummyNeighbor = mock(PatchLocation.class); - when(locationMock.getNeighbors()) - .thenReturn(new ArrayList(Arrays.asList(dummyNeighbor))); - when(gridMock.getObjectsAtLocation(dummyNeighbor)).thenReturn(dummyBag); - // number of neighbors should be the size of the bags we just established - int neighbors = sampleBag.size() * 2; - // set searchAbility to neighbors + 1 so it will always be more than neighbors - when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(neighbors + 1.0); - // make new cell - PatchCellCARTCD8 sampleCellCD8 = - new PatchCellCARTCD8( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - sampleCellCD8.bindTarget(simMock, locationMock, random); - // check that searchAbility is now neighbors if there are less neighbors than search ability - assertEquals(sampleCellCD8.searchAbility, neighbors, EPSILON); - } - - // Test that it is removing itself from potential neighbors - @Test - public void bind_target_removes_self_from_neighbors() { - // adding all dummy neighbors for this cell - Bag sampleBag = new Bag(); - for (int i = 0; i <= 5; i++) { - sampleBag.add(cellDefaultCD8.make(cellID + i + 1, cellState, locationMock, random)); - } - // number of neighbors should be the size of the bags we just established - // +1 because we will be adding it in later - int neighbors = sampleBag.size() + 1; - // set searchAbility to neighbors to verify that it eventually removes self - when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(neighbors * 1.0); - // make new cell - PatchCellCARTCD8 sampleCellCD8 = - new PatchCellCARTCD8( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - // adding self to neighbors - sampleBag.add(sampleCellCD8); - // setting up mocks - when(simMock.getGrid()).thenReturn(gridMock); - when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); - when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList())); - - sampleCellCD8.bindTarget(simMock, locationMock, random); - // check that searchAbility is now neighbors if there are less neighbors than search ability - assertEquals(sampleCellCD8.searchAbility, neighbors - 1, EPSILON); - } - - // Test that it is not binding to other T cells - @Test - public void bind_target_removes_avoid_tcells() { - // adding all dummy tcell neighbors for this cell - Bag sampleBag = new Bag(); - for (int i = 0; i <= 5; i++) { - sampleBag.add(cellDefaultCD8.make(cellID + i + 1, cellState, locationMock, random)); - } - // set searchAbility to some number that accomodates all neighbors - when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(sampleBag.size() + 1.0); - // make new cell - PatchCellCARTCD8 sampleCellCD8 = - new PatchCellCARTCD8( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - // setting up mocks - when(simMock.getGrid()).thenReturn(gridMock); - when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); - when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList())); - - sampleCellCD8.bindTarget(simMock, locationMock, random); - - // check that the cell is not binding to anything - assertEquals(sampleCellCD8.getAntigenFlag(), AntigenFlag.UNDEFINED); - } - - // Test that it is not binding to apoptotic cells - @Test - public void bind_target_removes_avoid_apoptotic_cells() { - // adding all dummy apoptotic neighbors for this cell - Bag sampleBag = new Bag(); - for (int i = 0; i <= 5; i++) { - Cell dummyCell = cellDefault.make(cellID + i + 1, cellState, locationMock, random); - dummyCell.setState(State.APOPTOTIC); - sampleBag.add(dummyCell); - } - // set searchAbility to some number that accomodates all neighbors - when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(sampleBag.size() + 1.0); - // make new cell - PatchCellCARTCD8 sampleCellCD8 = - new PatchCellCARTCD8( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - // setting up mocks - when(simMock.getGrid()).thenReturn(gridMock); - when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); - when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList())); - - sampleCellCD8.bindTarget(simMock, locationMock, random); - - // check that the cell is not binding to anything - assertEquals(sampleCellCD8.getAntigenFlag(), AntigenFlag.UNDEFINED); - } - - // Test that it is not binding to necrotic cells - @Test - public void bind_target_removes_avoid_necrotic_cells() { - // adding all dummy necrotic neighbors for this cell - Bag sampleBag = new Bag(); - for (int i = 0; i <= 5; i++) { - Cell dummyCell = cellDefault.make(cellID + i + 1, cellState, locationMock, random); - dummyCell.setState(State.NECROTIC); - sampleBag.add(dummyCell); - } - // set searchAbility to some number that accomodates all neighbors - when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(sampleBag.size() + 1.0); - // make new cell - PatchCellCARTCD8 sampleCellCD8 = - new PatchCellCARTCD8( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - // setting up mocks - when(simMock.getGrid()).thenReturn(gridMock); - when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); - when(locationMock.getNeighbors()).thenReturn(new ArrayList(Arrays.asList())); - - sampleCellCD8.bindTarget(simMock, locationMock, random); - - // check that the cell is not binding to anything - assertEquals(sampleCellCD8.getAntigenFlag(), AntigenFlag.UNDEFINED); - } - - // Test that maxSearch is calculated correctly when neighbors > searchAbility - @Test - public void maxSearch_returns_neighbors_when_less() { - // set searchAbility to some number - when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(2.0); - // make new cell - PatchCellCARTCD8 sampleCellCD8 = - new PatchCellCARTCD8( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - // make allAgents greater than searchAbility - Bag sampleBag = new Bag(); - for (int i = 0; i <= 5; i++) { - sampleBag.add(cellDefaultCD8.make(cellID + i + 1, cellState, locationMock, random)); - } - when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); - when(simMock.getGrid()).thenReturn(gridMock); - when(locationMock.getNeighbors()).thenReturn(new ArrayList()); - sampleCellCD8.bindTarget(simMock, locationMock, random); - // check that searchAbility stays the same - assertEquals(sampleCellCD8.searchAbility, 2, EPSILON); - } - - // Test that maxSearch is calculated correctly when neighbors < searchAbility - @Test - public void maxSearch_returns_neighbors_when_more() { - // set searchAbility to some number - when(parametersMock.getDouble("SEARCH_ABILITY")).thenReturn(6.0); - // make new cell - PatchCellCARTCD8 sampleCellCD8 = - new PatchCellCARTCD8( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - // make allAgents less than searchAbility - Bag sampleBag = new Bag(); - for (int i = 0; i <= 5; i++) { - sampleBag.add(cellDefaultCD8.make(cellID + i + 1, cellState, locationMock, random)); - } - when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(sampleBag); - when(simMock.getGrid()).thenReturn(gridMock); - when(locationMock.getNeighbors()).thenReturn(new ArrayList()); - sampleCellCD8.bindTarget(simMock, locationMock, random); - // check that searchAbility stays the same - assertEquals(sampleCellCD8.searchAbility, sampleBag.size(), EPSILON); - } - - // Is it worth testing these cases?????? - - // logCAR >= randomAntigen && logSelf < randomSelf - // set random antigen and random self that fits conditions - // verify flag set - // verify antigen count incremented - // verify self receptors calculated correctly - - // logCAR >= randomAntigen && logSelf >= randomSelf - // set random antigen and random self that fits conditions - // verify flag set - // verify antigen count incremented - // verify self receptors calculated correctly - - // logCAR < randomAntigen && logSelf >= randomSelf - // set random antigen and random self that fits conditions - // verify flag set - // verify antigen count incremented - // verify self receptors calculated correctly - - // logCAR < randomAntigen && logSelf < randomSelf - // set random antigen and random self that fits conditions - // verify flag set to unbound - -} diff --git a/test/arcade/patch/agent/cell/PatchCellTest.java b/test/arcade/patch/agent/cell/PatchCellTest.java deleted file mode 100644 index 7d9df507a..000000000 --- a/test/arcade/patch/agent/cell/PatchCellTest.java +++ /dev/null @@ -1,357 +0,0 @@ -package arcade.patch.agent.cell; - -import org.junit.BeforeClass; -import org.junit.Test; -import sim.util.Bag; -import ec.util.MersenneTwisterFast; -import arcade.core.util.MiniBox; -import arcade.patch.env.location.PatchLocation; -import arcade.patch.util.PatchEnums.Domain; -import arcade.patch.util.PatchEnums.Flag; -import arcade.patch.util.PatchEnums.State; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.mockito.Mockito.mock; -import static arcade.core.ARCADETestUtilities.*; - -public class PatchCellTest { - private static final double EPSILON = 1E-8; - - private static final MersenneTwisterFast RANDOM = new MersenneTwisterFast(randomSeed()); - - static int cellID = randomIntBetween(1, 10); - - static int cellParent = randomIntBetween(1, 10); - - static int cellPop = randomIntBetween(1, 10); - - static int cellAge = randomIntBetween(1, 1000); - - static int cellDivisions = randomIntBetween(1, 100); - - static double cellVolume = randomDoubleBetween(10, 100); - - static double cellHeight = randomDoubleBetween(10, 100); - - static double cellCriticalVolume = randomDoubleBetween(10, 100); - - static double cellCriticalHeight = randomDoubleBetween(10, 100); - - static State cellState = State.QUIESCENT; - - static PatchCellTissue cellDefault; - - static MiniBox parametersMock; - static PatchLocation locationMock; - - @BeforeClass - public static void setupMocks() { - parametersMock = mock(MiniBox.class); - locationMock = mock(PatchLocation.class); - - cellDefault = - new PatchCellTissue( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - } - - @Test - public void getID_defaultConstructor_returnsValue() { - assertEquals(cellID, cellDefault.getID()); - } - - @Test - public void getParent_defaultConstructor_returnsValue() { - assertEquals(cellParent, cellDefault.getParent()); - } - - @Test - public void getParent_valueAssigned_returnsValue() { - int parent = randomIntBetween(0, 100); - PatchCellTissue cell = - new PatchCellTissue( - cellID, - parent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - assertEquals(parent, cell.getParent()); - } - - @Test - public void getPop_defaultConstructor_returnsValue() { - assertEquals(cellPop, cellDefault.getPop()); - } - - @Test - public void getPop_valueAssigned_returnsValue() { - int pop = randomIntBetween(0, 100); - PatchCellTissue cell = - new PatchCellTissue( - cellID, - cellParent, - pop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - assertEquals(pop, cell.getPop()); - } - - @Test - public void getState_defaultConstructor_returnsValue() { - assertEquals(cellState, cellDefault.getState()); - } - - @Test - public void getState_valueAssigned_returnsValue() { - State state = State.random(RANDOM); - PatchCellTissue cell = - new PatchCellTissue( - cellID, - cellParent, - cellPop, - state, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - assertEquals(state, cell.getState()); - } - - @Test - public void getAge_defaultConstructor_returnsValue() { - assertEquals(cellAge, cellDefault.getAge()); - } - - @Test - public void getAge_valueAssigned_returnsValue() { - int age = randomIntBetween(0, 100); - PatchCellTissue cell = - new PatchCellTissue( - cellID, - cellParent, - cellPop, - cellState, - age, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - assertEquals(age, cell.getAge()); - } - - @Test - public void getDivisions_defaultConstructor_returnsValue() { - assertEquals(cellDivisions, cellDefault.getDivisions()); - } - - @Test - public void getDivisions_valueAssigned_returnsValue() { - int divisions = randomIntBetween(0, 100); - PatchCellTissue cell = - new PatchCellTissue( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - divisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - assertEquals(divisions, cell.getDivisions()); - } - - @Test - public void getLocation_defaultConstructor_returnsObject() { - assertSame(locationMock, cellDefault.getLocation()); - } - - @Test - public void getModule_defaultConstructor_returnsNull() { - assertEquals(cellDefault.getModule(), null); - } - - @Test - public void getProcess_defaultConstructor_returnsNull() { - assertNull(cellDefault.getProcess(Domain.UNDEFINED)); - } - - @Test - public void getParameters_defaultConstructor_returnsObject() { - assertSame(parametersMock, cellDefault.getParameters()); - } - - @Test - public void getVolume_defaultConstructor_returnsValue() { - assertEquals(cellVolume, cellDefault.getVolume(), EPSILON); - } - - @Test - public void getHeight_defaultConstructor_returnsValue() { - assertEquals(cellHeight, cellDefault.getHeight(), EPSILON); - } - - @Test - public void getCriticalVolume_defaultConstructor_returnsValue() { - assertEquals(cellCriticalVolume, cellDefault.getCriticalVolume(), EPSILON); - } - - @Test - public void getCriticalHeight_defaultConstructor_returnsValue() { - assertEquals(cellCriticalHeight, cellDefault.getCriticalHeight(), EPSILON); - } - - @Test - public void getEnergy_defaultConstructor_returnsValue() { - assertEquals(0, cellDefault.getEnergy(), EPSILON); - } - - @Test - public void setEnergy_returnsValue() { - double energy = randomDoubleBetween(0, 100); - PatchCellTissue cell = - new PatchCellTissue( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - cell.setEnergy(energy); - assertEquals(energy, cell.getEnergy(), EPSILON); - } - - @Test - public void setFlag_valueAssigned_returnsValue() { - Flag flag = Flag.random(RANDOM); - PatchCellTissue cell = - new PatchCellTissue( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - cell.setFlag(flag); - assertEquals(flag, cell.flag); - } - - @Test - public void convert_createsContainer() { - PatchLocation location = mock(PatchLocation.class); - MiniBox parameters = mock(MiniBox.class); - - int id = randomIntBetween(1, 10); - int parent = randomIntBetween(1, 10); - int pop = randomIntBetween(1, 10); - int age = randomIntBetween(1, 100); - int divisions = randomIntBetween(1, 100); - State state = State.PROLIFERATIVE; - double criticalVolume = randomDoubleBetween(10, 100); - double criticalHeight = randomDoubleBetween(10, 100); - double volume = randomDoubleBetween(10, 100); - double height = randomDoubleBetween(10, 100); - - PatchCellTissue cell = - new PatchCellTissue( - id, - parent, - pop, - state, - age, - divisions, - location, - parameters, - volume, - height, - criticalVolume, - criticalHeight); - - PatchCellContainer container = (PatchCellContainer) cell.convert(); - - assertEquals(id, container.id); - assertEquals(parent, container.parent); - assertEquals(pop, container.pop); - assertEquals(age, container.age); - assertEquals(divisions, container.divisions); - assertEquals(state, container.state); - assertEquals(criticalVolume, container.criticalVolume, EPSILON); - assertEquals(criticalHeight, container.criticalHeight, EPSILON); - } - - @Test - public void calculate_total_volume_returnsValue() { - Bag cells = new Bag(); - double runningSum = 0; - for (int i = 0; i < randomIntBetween(1, 10); i++) { - double v = randomDoubleBetween(10, 100); - PatchCellTissue cell = - new PatchCellTissue( - cellID, - cellParent, - cellPop, - cellState, - cellAge, - cellDivisions, - locationMock, - parametersMock, - v, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - cells.add(cell); - runningSum += v; - } - assertEquals(runningSum, PatchCell.calculateTotalVolume(cells), EPSILON); - } - - // once implemented, make sure location methods and step is working - -} From bfb52a9816fa8f14737ead84e1c29da5c4789295 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Sun, 17 Nov 2024 00:12:10 +0000 Subject: [PATCH 034/185] removing unnecessary imports --- src/arcade/patch/agent/cell/PatchCell.java | 4 ---- src/arcade/patch/agent/cell/PatchCellCART.java | 2 -- src/arcade/patch/agent/cell/PatchCellCancer.java | 1 - 3 files changed, 7 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index e0d38defc..2c621c98e 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -25,10 +25,6 @@ import arcade.patch.agent.process.PatchProcessSignaling; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; -import arcade.patch.util.PatchEnums.Domain; -import arcade.patch.util.PatchEnums.Flag; -import arcade.patch.util.PatchEnums.Ordering; -import arcade.patch.util.PatchEnums.State; import static arcade.patch.util.PatchEnums.Domain; import static arcade.patch.util.PatchEnums.Flag; import static arcade.patch.util.PatchEnums.Ordering; diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 79eb0f02c..dbfb26966 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -9,8 +9,6 @@ import arcade.core.util.Parameters; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; -import arcade.patch.util.PatchEnums.AntigenFlag; -import arcade.patch.util.PatchEnums.State; import static arcade.patch.util.PatchEnums.AntigenFlag; import static arcade.patch.util.PatchEnums.State; diff --git a/src/arcade/patch/agent/cell/PatchCellCancer.java b/src/arcade/patch/agent/cell/PatchCellCancer.java index 2fad89dc9..cc2783adf 100644 --- a/src/arcade/patch/agent/cell/PatchCellCancer.java +++ b/src/arcade/patch/agent/cell/PatchCellCancer.java @@ -7,7 +7,6 @@ import arcade.core.sim.Simulation; import arcade.core.util.GrabBag; import arcade.core.util.Parameters; -import arcade.patch.util.PatchEnums.State; import static arcade.patch.util.PatchEnums.State; /** From 9c4d7674642a2842e7e59129bb99e20af0e94515 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 19 Nov 2024 06:58:43 +0000 Subject: [PATCH 035/185] adding CD4 cell tests --- .../agent/cell/PatchCellCARTCD4Test.java | 547 ++++++++++++++++++ 1 file changed, 547 insertions(+) create mode 100644 test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java new file mode 100644 index 000000000..c1b2117c4 --- /dev/null +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -0,0 +1,547 @@ +package arcade.patch.agent.cell; + +import java.util.ArrayList; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import sim.engine.Schedule; +import sim.engine.Steppable; +import sim.util.Bag; +import ec.util.MersenneTwisterFast; +import arcade.core.env.location.Location; +import arcade.core.sim.Simulation; +import arcade.core.util.Parameters; +import arcade.patch.agent.module.PatchModule; +import arcade.patch.agent.process.PatchProcessInflammation; +import arcade.patch.agent.process.PatchProcessMetabolism; +import arcade.patch.agent.process.PatchProcessSignaling; +import arcade.patch.env.grid.PatchGrid; +import arcade.patch.env.location.PatchLocation; +import arcade.patch.sim.PatchSimulation; +import arcade.patch.util.PatchEnums.Domain; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; +import static arcade.core.ARCADETestUtilities.randomDoubleBetween; +import static arcade.core.ARCADETestUtilities.randomIntBetween; +import static arcade.patch.util.PatchEnums.AntigenFlag; +import static arcade.patch.util.PatchEnums.State; + +public class PatchCellCARTCD4Test { + + private PatchCellCARTCD4 patchCellCART; + private Parameters parameters; + private PatchLocation location; + private PatchCellContainer container; + + @BeforeEach + public void setUp() { + parameters = mock(Parameters.class); + location = mock(PatchLocation.class); + + int id = 1; + int parentId = 1; + int pop = 1; + int age = randomIntBetween(1, 100800); + int divisions = 10; + double volume = randomDoubleBetween(100, 200); + double height = randomDoubleBetween(4, 10); + double criticalVolume = randomDoubleBetween(100, 200); + double criticalHeight = randomDoubleBetween(4, 10); + State state = State.UNDEFINED; + ; + + container = + new PatchCellContainer( + id, + parentId, + pop, + age, + divisions, + state, + volume, + height, + criticalVolume, + criticalHeight); + + when(parameters.getDouble("HETEROGENEITY")).thenReturn(0.0); + when(parameters.getDouble("ENERGY_THRESHOLD")).thenReturn(1.0); + + when(parameters.getDouble("NECROTIC_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("EXHAU_FRAC")).thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("SENESCENT_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("ANERGIC_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("PROLIFERATIVE_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getInt("SELF_RECEPTORS")).thenReturn(randomIntBetween(100, 200)); + when(parameters.getDouble("SEARCH_ABILITY")).thenReturn(1.0); + when(parameters.getDouble("CAR_AFFINITY")).thenReturn(10 * Math.pow(10, -7)); + when(parameters.getDouble("CAR_ALPHA")).thenReturn(3.0); + when(parameters.getDouble("CAR_BETA")).thenReturn(0.01); + when(parameters.getDouble("SELF_RECEPTOR_AFFINITY")).thenReturn(7.8E-6); + when(parameters.getDouble("SELF_ALPHA")).thenReturn(3.0); + when(parameters.getDouble("SELF_BETA")).thenReturn(0.02); + when(parameters.getDouble("CONTACT_FRAC")).thenReturn(7.8E-6); + when(parameters.getInt("MAX_ANTIGEN_BINDING")).thenReturn(10); + when(parameters.getInt("CARS")).thenReturn(50000); + + patchCellCART = new PatchCellCARTCD4(container, location, parameters); + } + + @Test + public void testSetAntigenFlag() { + patchCellCART.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); + } + + @Test + public void testGetAntigenFlag() { + patchCellCART.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTargetNoNeighbors() { + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNull(result); + assertEquals(AntigenFlag.UNBOUND, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTargetWithSelfBinding() { + // lots of self antigens, not a lot of car antigens + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + when(loc.getVolume()).thenReturn(6000.0); + + when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(10); + when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(10); + when(parameters.getInt("SELF_TARGETS")).thenReturn(10000000); + PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + + bag.add(tissueCell); + + when(random.nextDouble()).thenReturn(0.0000005); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNotNull(result); + assertEquals(AntigenFlag.BOUND_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTargetWithSelfAndAntigenBinding() { + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + when(loc.getVolume()).thenReturn(6000.0); + + when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); + when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); + when(parameters.getInt("SELF_TARGETS")).thenReturn(50000000); + + PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + + bag.add(tissueCell); + + when(random.nextDouble()).thenReturn(0.0000005); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNotNull(result); + assertEquals(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); + } + + @Test + public void testGetActivationStatus() { + assertTrue(patchCellCART.getActivationStatus()); + } + + @Test + public void testBindTarget() { + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + when(loc.getVolume()).thenReturn(6000.0); + + when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); + when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); + when(parameters.getInt("SELF_TARGETS")).thenReturn(5000); + + PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + + bag.add(tissueCell); + + when(random.nextDouble()).thenReturn(0.0000005); + + bag.add(tissueCell); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNotNull(result); + assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); + } + + @Test + public void testStepIncreasesAge() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + int initialAge = cell.getAge(); + cell.step(sim); + assertEquals(initialAge + 1, cell.getAge()); + } + + @Test + public void testStepSetsStateToApoptoticWhenEnergyIsLow() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.setEnergy(-1); + cell.step(sim); + + assertEquals(State.APOPTOTIC, cell.getState()); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertFalse(cell.getActivationStatus()); + } + + @Test + public void testStepSetsStateToStarvedWhenEnergyIsNegativeAndMoreThanThreshold() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.setEnergy(-0.5); + cell.step(sim); + + assertEquals(State.STARVED, cell.getState()); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + } + + @Test + public void testStepSetsStateToApoptoticWhenEnergyIsNegativeAndLessThanThreshold() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.setEnergy(-1.5); + cell.step(sim); + + assertEquals(State.APOPTOTIC, cell.getState()); + } + + @Test + public void testStepSetsStateToSenescentWhenDivisionsAreZero() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.divisions = 0; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.step(sim); + + assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.SENESCENT); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertFalse(cell.getActivationStatus()); + } + + @Test + public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); + cell.step(sim); + + assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.ANERGIC); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertFalse(cell.getActivationStatus()); + } + + @Test + public void testStepSetsStateToStimulatoryWhenBoundToAntigen() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.boundAntigensCount = 0; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + + Schedule schedule = mock(Schedule.class); + doReturn(true).when(schedule).scheduleOnce(any(Steppable.class)); + doReturn(schedule).when(sim).getSchedule(); + + cell.step(sim); + + assertEquals(State.STIMULATORY, cell.getState()); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertTrue(cell.getActivationStatus()); + } + + @Test + public void testStepSetsStateToProliferativeWhenActivated() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.activated = true; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.step(sim); + + assertEquals(State.PROLIFERATIVE, cell.getState()); + } + + @Test + public void testStepSetsStateToMigratoryWhenNotActivated() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.activated = false; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.step(sim); + + assertTrue(cell.getState() == State.MIGRATORY || cell.getState() == State.PROLIFERATIVE); + } + + @Test + public void testStepSetsStatetoExhaustedWhenOverstimulated() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.boundAntigensCount = cell.maxAntigenBinding + 1; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + + cell.step(sim); + + assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.EXHAUSTED); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertFalse(cell.getActivationStatus()); + } +} From 5cfd63153e6aa92019ab64d6ca86d646ea7297e0 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 19 Nov 2024 07:02:57 +0000 Subject: [PATCH 036/185] changing energy threshold in test --- test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index c1b2117c4..5e1365212 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -266,7 +266,7 @@ public void testStepSetsStateToApoptoticWhenEnergyIsLow() { sim.random = random; cell.setState(State.UNDEFINED); - cell.setEnergy(-1); + cell.setEnergy(-1 * randomIntBetween(1, 5)); cell.step(sim); assertEquals(State.APOPTOTIC, cell.getState()); From 1a9e7ed2e166c1ea49bf599b871159f17fe76c56 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 20 Dec 2024 21:53:36 +0000 Subject: [PATCH 037/185] adding CART cell tests --- .../agent/cell/PatchCellCARTCD4Test.java | 542 ++++++++++++++++++ .../agent/cell/PatchCellCARTCD8Test.java | 540 +++++++++++++++++ 2 files changed, 1082 insertions(+) create mode 100644 test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java create mode 100644 test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java new file mode 100644 index 000000000..f5e0e8e86 --- /dev/null +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -0,0 +1,542 @@ +package arcade.patch.agent.cell; + +import java.util.ArrayList; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import sim.engine.Schedule; +import sim.engine.Steppable; +import sim.util.Bag; +import ec.util.MersenneTwisterFast; +import arcade.core.env.location.Location; +import arcade.core.sim.Simulation; +import arcade.core.util.Parameters; +import arcade.patch.agent.module.PatchModule; +import arcade.patch.agent.process.PatchProcessInflammation; +import arcade.patch.agent.process.PatchProcessMetabolism; +import arcade.patch.agent.process.PatchProcessSignaling; +import arcade.patch.env.grid.PatchGrid; +import arcade.patch.env.location.PatchLocation; +import arcade.patch.sim.PatchSimulation; +import arcade.patch.util.PatchEnums.Domain; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; +import static arcade.core.ARCADETestUtilities.randomDoubleBetween; +import static arcade.core.ARCADETestUtilities.randomIntBetween; +import static arcade.patch.util.PatchEnums.AntigenFlag; +import static arcade.patch.util.PatchEnums.State; + +public class PatchCellCARTCD4Test { + + private PatchCellCARTCD4 patchCellCART; + private Parameters parameters; + private PatchLocation location; + private PatchCellContainer container; + + @BeforeEach + public void setUp() { + parameters = mock(Parameters.class); + location = mock(PatchLocation.class); + + int id = 1; + int parentId = 1; + int pop = 1; + int age = randomIntBetween(1, 100800); + int divisions = 10; + double volume = randomDoubleBetween(100, 200); + double height = randomDoubleBetween(4, 10); + double criticalVolume = randomDoubleBetween(100, 200); + double criticalHeight = randomDoubleBetween(4, 10); + State state = State.UNDEFINED; + ; + + container = + new PatchCellContainer( + id, + parentId, + pop, + age, + divisions, + state, + volume, + height, + criticalVolume, + criticalHeight); + + when(parameters.getDouble("HETEROGENEITY")).thenReturn(0.0); + when(parameters.getDouble("ENERGY_THRESHOLD")).thenReturn(1.0); + + when(parameters.getDouble("NECROTIC_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("EXHAU_FRAC")).thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("SENESCENT_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("ANERGIC_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("PROLIFERATIVE_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getInt("SELF_RECEPTORS")).thenReturn(randomIntBetween(100, 200)); + when(parameters.getDouble("SEARCH_ABILITY")).thenReturn(1.0); + when(parameters.getDouble("CAR_AFFINITY")).thenReturn(10 * Math.pow(10, -7)); + when(parameters.getDouble("CAR_ALPHA")).thenReturn(3.0); + when(parameters.getDouble("CAR_BETA")).thenReturn(0.01); + when(parameters.getDouble("SELF_RECEPTOR_AFFINITY")).thenReturn(7.8E-6); + when(parameters.getDouble("SELF_ALPHA")).thenReturn(3.0); + when(parameters.getDouble("SELF_BETA")).thenReturn(0.02); + when(parameters.getDouble("CONTACT_FRAC")).thenReturn(7.8E-6); + when(parameters.getInt("MAX_ANTIGEN_BINDING")).thenReturn(10); + when(parameters.getInt("CARS")).thenReturn(50000); + + patchCellCART = new PatchCellCARTCD4(container, location, parameters); + } + + @Test + public void testSetAntigenFlag() { + patchCellCART.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); + } + + @Test + public void testGetAntigenFlag() { + patchCellCART.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTargetNoNeighbors() { + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNull(result); + assertEquals(AntigenFlag.UNBOUND, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTargetWithSelfBinding() { + // lots of self antigens, not a lot of car antigens + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + when(loc.getVolume()).thenReturn(6000.0); + + when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(10); + when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(10); + when(parameters.getInt("SELF_TARGETS")).thenReturn(10000000); + PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + + bag.add(tissueCell); + + when(random.nextDouble()).thenReturn(0.0000005); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNotNull(result); + assertEquals(AntigenFlag.BOUND_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTargetWithSelfAndAntigenBinding() { + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + when(loc.getVolume()).thenReturn(6000.0); + + when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); + when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); + when(parameters.getInt("SELF_TARGETS")).thenReturn(50000000); + + PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + + bag.add(tissueCell); + + when(random.nextDouble()).thenReturn(0.0000005); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNotNull(result); + assertEquals(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTarget() { + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + when(loc.getVolume()).thenReturn(6000.0); + + when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); + when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); + when(parameters.getInt("SELF_TARGETS")).thenReturn(5000); + + PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + + bag.add(tissueCell); + + when(random.nextDouble()).thenReturn(0.0000005); + + bag.add(tissueCell); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNotNull(result); + assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); + } + + @Test + public void testStepIncreasesAge() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + int initialAge = cell.getAge(); + cell.step(sim); + assertEquals(initialAge + 1, cell.getAge()); + } + + @Test + public void testStepSetsStateToApoptoticWhenEnergyIsLow() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.setEnergy(-1 * randomIntBetween(1,5)); + cell.step(sim); + + assertEquals(State.APOPTOTIC, cell.getState()); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertFalse(cell.getActivationStatus()); + } + + @Test + public void testStepSetsStateToStarvedWhenEnergyIsNegativeAndMoreThanThreshold() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.setEnergy(-0.5); + cell.step(sim); + + assertEquals(State.STARVED, cell.getState()); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + } + + @Test + public void testStepSetsStateToApoptoticWhenEnergyIsNegativeAndLessThanThreshold() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.setEnergy(-1.5); + cell.step(sim); + + assertEquals(State.APOPTOTIC, cell.getState()); + } + + @Test + public void testStepSetsStateToSenescentWhenDivisionsAreZero() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.divisions = 0; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.step(sim); + + assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.SENESCENT); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertFalse(cell.getActivationStatus()); + } + + @Test + public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); + cell.step(sim); + + assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.ANERGIC); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertFalse(cell.getActivationStatus()); + } + + @Test + public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.boundAntigensCount = 0; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + + Schedule schedule = mock(Schedule.class); + doReturn(true).when(schedule).scheduleOnce(any(Steppable.class)); + doReturn(schedule).when(sim).getSchedule(); + + cell.step(sim); + + assertEquals(State.STIMULATORY, cell.getState()); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertTrue(cell.getActivationStatus()); + } + + @Test + public void testStepSetsStateToProliferativeWhenActivated() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.activated = true; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.step(sim); + + assertEquals(State.PROLIFERATIVE, cell.getState()); + } + + @Test + public void testStepSetsStateToMigratoryWhenNotActivated() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.activated = false; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.step(sim); + + assertTrue(cell.getState() == State.MIGRATORY || cell.getState() == State.PROLIFERATIVE); + } + + @Test + public void testStepSetsStatetoExhaustedWhenOverstimulated() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.boundAntigensCount = cell.maxAntigenBinding + 1; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + + cell.step(sim); + + assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.EXHAUSTED); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertFalse(cell.getActivationStatus()); + } +} diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java new file mode 100644 index 000000000..235b2e9cf --- /dev/null +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -0,0 +1,540 @@ +package arcade.patch.agent.cell; + +import java.util.ArrayList; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import sim.engine.Schedule; +import sim.engine.Steppable; +import sim.util.Bag; +import ec.util.MersenneTwisterFast; +import arcade.core.env.location.Location; +import arcade.core.sim.Simulation; +import arcade.core.util.Parameters; +import arcade.patch.agent.module.PatchModule; +import arcade.patch.agent.process.PatchProcessInflammation; +import arcade.patch.agent.process.PatchProcessMetabolism; +import arcade.patch.agent.process.PatchProcessSignaling; +import arcade.patch.env.grid.PatchGrid; +import arcade.patch.env.location.PatchLocation; +import arcade.patch.sim.PatchSimulation; +import arcade.patch.util.PatchEnums.Domain; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; +import static arcade.core.ARCADETestUtilities.randomDoubleBetween; +import static arcade.core.ARCADETestUtilities.randomIntBetween; +import static arcade.patch.util.PatchEnums.AntigenFlag; +import static arcade.patch.util.PatchEnums.State; + +public class PatchCellCARTCD8Test { + + private PatchCellCARTCD8 patchCellCART; + private Parameters parameters; + private PatchLocation location; + private PatchCellContainer container; + + @BeforeEach + public void setUp() { + parameters = mock(Parameters.class); + location = mock(PatchLocation.class); + + int id = 1; + int parentId = 1; + int pop = 1; + int age = randomIntBetween(1, 100800); + int divisions = 10; + double volume = randomDoubleBetween(100, 200); + double height = randomDoubleBetween(4, 10); + double criticalVolume = randomDoubleBetween(100, 200); + double criticalHeight = randomDoubleBetween(4, 10); + State state = State.UNDEFINED; + ; + + container = + new PatchCellContainer( + id, + parentId, + pop, + age, + divisions, + state, + volume, + height, + criticalVolume, + criticalHeight); + + when(parameters.getDouble("HETEROGENEITY")).thenReturn(0.0); + when(parameters.getDouble("ENERGY_THRESHOLD")).thenReturn(1.0); + + when(parameters.getDouble("NECROTIC_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("EXHAU_FRAC")).thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("SENESCENT_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("ANERGIC_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("PROLIFERATIVE_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getInt("SELF_RECEPTORS")).thenReturn(randomIntBetween(100, 200)); + when(parameters.getDouble("SEARCH_ABILITY")).thenReturn(1.0); + when(parameters.getDouble("CAR_AFFINITY")).thenReturn(10 * Math.pow(10, -7)); + when(parameters.getDouble("CAR_ALPHA")).thenReturn(3.0); + when(parameters.getDouble("CAR_BETA")).thenReturn(0.01); + when(parameters.getDouble("SELF_RECEPTOR_AFFINITY")).thenReturn(7.8E-6); + when(parameters.getDouble("SELF_ALPHA")).thenReturn(3.0); + when(parameters.getDouble("SELF_BETA")).thenReturn(0.02); + when(parameters.getDouble("CONTACT_FRAC")).thenReturn(7.8E-6); + when(parameters.getInt("MAX_ANTIGEN_BINDING")).thenReturn(10); + when(parameters.getInt("CARS")).thenReturn(50000); + + patchCellCART = new PatchCellCARTCD8(container, location, parameters); + } + + @Test + public void testSetAntigenFlag() { + patchCellCART.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); + } + + @Test + public void testGetAntigenFlag() { + patchCellCART.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTargetNoNeighbors() { + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNull(result); + assertEquals(AntigenFlag.UNBOUND, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTargetWithSelfBinding() { + // lots of self antigens, not a lot of car antigens + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + when(loc.getVolume()).thenReturn(6000.0); + + when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(10); + when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(10); + when(parameters.getInt("SELF_TARGETS")).thenReturn(10000000); + PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + + bag.add(tissueCell); + + when(random.nextDouble()).thenReturn(0.0000005); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNotNull(result); + assertEquals(AntigenFlag.BOUND_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTargetWithSelfAndAntigenBinding() { + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + when(loc.getVolume()).thenReturn(6000.0); + + when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); + when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); + when(parameters.getInt("SELF_TARGETS")).thenReturn(50000000); + + PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + + bag.add(tissueCell); + + when(random.nextDouble()).thenReturn(0.0000005); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNotNull(result); + assertEquals(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTarget() { + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + when(loc.getVolume()).thenReturn(6000.0); + + when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); + when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); + when(parameters.getInt("SELF_TARGETS")).thenReturn(5000); + + PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + + bag.add(tissueCell); + + when(random.nextDouble()).thenReturn(0.0000005); + + bag.add(tissueCell); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNotNull(result); + assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); + } + + @Test + public void testStepIncreasesAge() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + int initialAge = cell.getAge(); + cell.step(sim); + assertEquals(initialAge + 1, cell.getAge()); + } + + @Test + public void testStepSetsStateToApoptoticWhenEnergyIsLow() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.setEnergy(-1 * randomIntBetween(1,5)); + cell.step(sim); + + assertEquals(State.APOPTOTIC, cell.getState()); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertFalse(cell.getActivationStatus()); + } + + @Test + public void testStepSetsStateToStarvedWhenEnergyIsNegativeAndMoreThanThreshold() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.setEnergy(-0.5); + cell.step(sim); + + assertEquals(State.STARVED, cell.getState()); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + } + + @Test + public void testStepSetsStateToApoptoticWhenEnergyIsNegativeAndLessThanThreshold() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.setEnergy(-1.5); + cell.step(sim); + + assertEquals(State.APOPTOTIC, cell.getState()); + } + + @Test + public void testStepSetsStateToSenescentWhenDivisionsAreZero() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.divisions = 0; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.step(sim); + + assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.SENESCENT); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertFalse(cell.getActivationStatus()); + } + + @Test + public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); + cell.step(sim); + + assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.ANERGIC); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertFalse(cell.getActivationStatus()); + } + + @Test + public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.boundAntigensCount = 0; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + + Schedule schedule = mock(Schedule.class); + doReturn(true).when(schedule).scheduleOnce(any(Steppable.class)); + doReturn(schedule).when(sim).getSchedule(); + + cell.step(sim); + + verify(cell, times(1)).setState(State.CYTOTOXIC); + } + + @Test + public void testStepSetsStateToProliferativeWhenActivated() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.activated = true; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.step(sim); + + assertEquals(State.PROLIFERATIVE, cell.getState()); + } + + @Test + public void testStepSetsStateToMigratoryWhenNotActivated() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.activated = false; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + + cell.step(sim); + + assertTrue(cell.getState() == State.MIGRATORY || cell.getState() == State.PROLIFERATIVE); + } + + @Test + public void testStepSetsStatetoExhaustedWhenOverstimulated() { + PatchSimulation sim = mock(PatchSimulation.class); + PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); + cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); + cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); + cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); + PatchModule module = mock(PatchModule.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.boundAntigensCount = cell.maxAntigenBinding + 1; + cell.module = module; + return null; + }) + .when(cell) + .setState(any(State.class)); + doReturn(new PatchCellTissue(container, location, parameters)) + .when(cell) + .bindTarget( + any(Simulation.class), + any(PatchLocation.class), + any(MersenneTwisterFast.class)); + sim.random = random; + cell.setState(State.UNDEFINED); + cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + + cell.step(sim); + + assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.EXHAUSTED); + assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertFalse(cell.getActivationStatus()); + } +} From 6a3f6bed1377c4ca8e9d37a8936867253b410882 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 20 Dec 2024 22:04:41 +0000 Subject: [PATCH 038/185] adding cell --- src/arcade/patch/agent/cell/PatchCellCARTCD8.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index f7e0a5fc6..e37ab515d 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -67,6 +67,7 @@ public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFas @Override public void step(SimState simstate) { + // return; Simulation sim = (Simulation) simstate; // Increase age of cell. From a86a860aa915b3a81c7b5fcedd197e8bb765b4ce Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 20 Dec 2024 22:13:39 +0000 Subject: [PATCH 039/185] applying linting --- .../patch/agent/cell/PatchCellCARTCD8.java | 54 +++++++++---------- .../agent/cell/PatchCellCARTCD4Test.java | 12 ++--- .../agent/cell/PatchCellCARTCD8Test.java | 2 +- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index 16e912a45..d80c456be 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -1,5 +1,7 @@ package arcade.patch.agent.cell; +import sim.engine.SimState; +import ec.util.MersenneTwisterFast; import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; @@ -11,36 +13,34 @@ import arcade.patch.util.PatchEnums.AntigenFlag; import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.State; -import ec.util.MersenneTwisterFast; -import sim.engine.SimState; public class PatchCellCARTCD8 extends PatchCellCART { /** - * Creates a tissue {@code PatchCellCARTCD8} agent. - * *

    - * Loaded parameters include: - *

      - *
    • {@code CYTOTOXIC_FRACTION} = fraction of cytotoxic cells that - * become apoptotic
    • - *
    - * - * @param id the cell ID - * @param parent the parent ID - * @param pop the cell population index - * @param state the cell state - * @param age the cell age - * @param divisions the number of cell divisions - * @param location the {@link Location} of the cell - * @param parameters the dictionary of parameters - * @param volume the cell volume - * @param height the cell height - * @param criticalVolume the critical cell volume - * @param criticalHeight the critical cell height - */ - - public PatchCellCARTCD8(PatchCellContainer container, Location location, Parameters parameters) { - this(container, location, parameters, null); - } + * Creates a tissue {@code PatchCellCARTCD8} agent. * + * + *

    Loaded parameters include: + * + *

      + *
    • {@code CYTOTOXIC_FRACTION} = fraction of cytotoxic cells that become apoptotic + *
    + * + * @param id the cell ID + * @param parent the parent ID + * @param pop the cell population index + * @param state the cell state + * @param age the cell age + * @param divisions the number of cell divisions + * @param location the {@link Location} of the cell + * @param parameters the dictionary of parameters + * @param volume the cell volume + * @param height the cell height + * @param criticalVolume the critical cell volume + * @param criticalHeight the critical cell height + */ + public PatchCellCARTCD8( + PatchCellContainer container, Location location, Parameters parameters) { + this(container, location, parameters, null); + } public PatchCellCARTCD8( PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index f93342cbc..c43deb0ac 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -412,12 +412,12 @@ public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { PatchModule module = mock(PatchModule.class); MersenneTwisterFast random = mock(MersenneTwisterFast.class); doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - cell.boundAntigensCount = 0; - cell.module = module; - return null; - }) + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + cell.boundAntigensCount = 0; + cell.module = module; + return null; + }) .when(cell) .setState(any(State.class)); doReturn(new PatchCellTissue(container, location, parameters)) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index 235b2e9cf..a384bf4b2 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -261,7 +261,7 @@ public void testStepSetsStateToApoptoticWhenEnergyIsLow() { sim.random = random; cell.setState(State.UNDEFINED); - cell.setEnergy(-1 * randomIntBetween(1,5)); + cell.setEnergy(-1 * randomIntBetween(1, 5)); cell.step(sim); assertEquals(State.APOPTOTIC, cell.getState()); From 2fea3ea4bf67a48fdb66ff44c4b066949707abbc Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 20 Dec 2024 22:18:59 +0000 Subject: [PATCH 040/185] testing git access --- test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index c43deb0ac..cb0c7e5a9 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -9,7 +9,7 @@ import ec.util.MersenneTwisterFast; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; -import arcade.core.util.Parameters; +import arcade.core.util.Parameters; import arcade.patch.agent.module.PatchModule; import arcade.patch.agent.process.PatchProcessInflammation; import arcade.patch.agent.process.PatchProcessMetabolism; From 47bb54aa7b045fba05eb4c08cdfb2950e7edcc9e Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 20 Dec 2024 22:24:40 +0000 Subject: [PATCH 041/185] testing git again --- test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index cb0c7e5a9..72531a734 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -9,7 +9,7 @@ import ec.util.MersenneTwisterFast; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; -import arcade.core.util.Parameters; +import arcade.core.util.Parameters; import arcade.patch.agent.module.PatchModule; import arcade.patch.agent.process.PatchProcessInflammation; import arcade.patch.agent.process.PatchProcessMetabolism; From 82c4e3735eb4f7292bc4d22751e9290119ba9e8f Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 20 Dec 2024 22:26:42 +0000 Subject: [PATCH 042/185] I am once again, testing git --- test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index 72531a734..c43deb0ac 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -9,7 +9,7 @@ import ec.util.MersenneTwisterFast; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; -import arcade.core.util.Parameters; +import arcade.core.util.Parameters; import arcade.patch.agent.module.PatchModule; import arcade.patch.agent.process.PatchProcessInflammation; import arcade.patch.agent.process.PatchProcessMetabolism; From 485cdb3a6f1feff14146451c75b92a9c4a1fa314 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 20 Dec 2024 22:39:33 +0000 Subject: [PATCH 043/185] editing test for edge case --- test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java | 2 +- test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index c43deb0ac..e38c6ac69 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -261,7 +261,7 @@ public void testStepSetsStateToApoptoticWhenEnergyIsLow() { sim.random = random; cell.setState(State.UNDEFINED); - cell.setEnergy(-1 * randomIntBetween(1, 5)); + cell.setEnergy(-1 * randomIntBetween(2, 5)); cell.step(sim); assertEquals(State.APOPTOTIC, cell.getState()); diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index a384bf4b2..21281a1b8 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -261,7 +261,7 @@ public void testStepSetsStateToApoptoticWhenEnergyIsLow() { sim.random = random; cell.setState(State.UNDEFINED); - cell.setEnergy(-1 * randomIntBetween(1, 5)); + cell.setEnergy(-1 * randomIntBetween(2, 5)); cell.step(sim); assertEquals(State.APOPTOTIC, cell.getState()); From dcac9d02b1f1936e5a7e3d1bc9e1e4f9030347c9 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 20 Dec 2024 23:11:04 +0000 Subject: [PATCH 044/185] writing java documentation for T cell agents --- .../patch/agent/cell/PatchCellCART.java | 103 ++++++++++-------- .../patch/agent/cell/PatchCellCARTCD4.java | 30 ++--- .../patch/agent/cell/PatchCellCARTCD8.java | 35 ++---- .../patch/agent/cell/PatchCellTissue.java | 11 -- 4 files changed, 81 insertions(+), 98 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index dbfb26966..ff7e9f95e 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -13,11 +13,11 @@ import static arcade.patch.util.PatchEnums.State; /** - * Implementation of {@link Cell} for generic CART cell. + * Implementation of {@link PatchCell} for generic CART cell. * *

    {@code PatchCellCART} agents exist in one of thirteen states: neutral, apoptotic, migratory, * proliferative, senescent, cytotoxic (CD8), stimulatory (CD4), exhausted, anergic, starved, or - * paused. The neutral state is an transition state for "undecided" cells, and does not have any + * paused. The neutral state is a transition state for "undecided" cells, and does not have any * biological analog. * *

    {@code PatchCellCART} agents have two required {@link Process} domains: metabolism and @@ -64,25 +64,49 @@ public abstract class PatchCellCART extends PatchCell { /** Cell activation flag */ protected boolean activated; - /** lack of documentation so these parameters are TBD */ + /** number of current PDL-1 receptors on CART cell */ protected int selfReceptors; + /** initial number of PDL-1 receptors on CART cell */ protected int selfReceptorsStart; + + /** number of bound CAR antigens */ protected int boundAntigensCount; + + /** number of bound PDL-1 antigens */ protected int boundSelfCount; - /** lack of documentation so these loaded parameters are TBD */ + /** number of neighbors that T cell is able to search through */ protected final double searchAbility; + /** binding affinity for CAR receptor */ protected final double carAffinity; + + /** tuning factor for CAR binding */ protected final double carAlpha; + + /** tuning factor for CAR binding */ protected final double carBeta; + + /** binding affinity for PDL-1 receptor */ protected final double selfReceptorAffinity; + + /** tuning factor for PDL-1 receptor binding */ protected final double selfAlpha; + + /** tuning factor for PDL-1 receptor binding */ protected final double selfBeta; + + /** fraction of cell surface that contacts when binding */ protected final double contactFraction; + + /** max antigens threshold for T cell exhaustion */ protected final int maxAntigenBinding; + + /** number of CARs on T cell surface */ protected final int cars; + + /** simulation time since T cell was last activated */ protected int lastActiveTicker; /** Fraction of exhausted cells that become apoptotic. */ @@ -98,52 +122,38 @@ public abstract class PatchCellCART extends PatchCell { protected final double proliferativeFraction; /** - * Creates a tissue {@code PatchCellCART} agent. * - * - *

    Loaded parameters include: - * - *

      - *
    • {@code EXHAUSTED_FRACTION} = fraction of exhausted cells that become apoptotic - *
    • {@code SENESCENT_FRACTION} = fraction of senescent cells that become apoptotic - *
    • {@code ANERGIC_FRACTION} = fraction of anergic cells that become apoptotic - *
    • {@code PROLIFERATIVE_FRACTION} = fraction of proliferative cells that become apoptotic - *
    • {@code CAR_ANTIGENS} = Cell surface antigen count - *
    • {@code SELF_TARGETS} = Cell surface PDL1 count - *
    • {@code SEARCH_ABILITY} = TBD - *
    • {@code CAR_AFFINITY} = TBD - *
    • {@code CAR_ALPHA} = TBD - *
    • {@code CAR_BETA} = TBD - *
    • {@code SELF_RECEPTOR_AFFINITY} = TBD - *
    • {@code SELF_ALPHA} = TBD - *
    • {@code SELF_BETA} = TBD - *
    • {@code CONTACT_FRACTION} = TBD - *
    • {@code MAX_ANTIGEN_BINDING} = TBD - *
    • {@code CARS} = TBD - *
    • {@code SELF_RECEPTORS} = TBD - *
    • {@code SELF_RECEPTORS_START} = TBD - *
    - * - * < THERE IS A LACK OF DOCUMENTATION FOR THE REST OF THE LOADED PARAMS SO THEY ARE TBD> + * Creates a {@code PatchCellCART} agent. * * - * @param id the cell ID - * @param parent the parent ID - * @param pop the cell population index - * @param state the cell state - * @param age the cell age - * @param divisions the number of cell divisions + * @param container the cell container * @param location the {@link Location} of the cell * @param parameters the dictionary of parameters - * @param volume the cell volume - * @param height the cell height - * @param criticalVolume the critical cell volume - * @param criticalHeight the critical cell height */ public PatchCellCART(PatchCellContainer container, Location location, Parameters parameters) { this(container, location, parameters, null); } /** - * Creates a tissue {@code PatchCell} agent with population links. + * Creates a {@code PatchCellCART} agent. * + * + *

    Loaded parameters include: + * + *

      + *
    • {@code EXHAU_FRACTION} = fraction of exhausted cells that become apoptotic + *
    • {@code SENESCENT_FRACTION} = fraction of senescent cells that become apoptotic + *
    • {@code ANERGIC_FRACTION} = fraction of anergic cells that become apoptotic + *
    • {@code PROLIFERATIVE_FRACTION} = fraction of proliferative cells that become apoptotic + *
    • {@code SELF_RECEPTORS} = current number of PDL-1 receptors on cell surface + *
    • {@code SEARCH_ABILITY} = number of neighbors that T cell can search through + *
    • {@code CAR_AFFINITY} = CAR receptor binding affinity + *
    • {@code CAR_ALPHA} = tuning factor for CAR binding + *
    • {@code CAR_BETA} = tuning factor for CAR binding + *
    • {@code SELF_RECEPTOR_AFFINITY} = PDL-1 receptor binding affinity + *
    • {@code SELF_ALPHA} = tuning factor for PDL-1 receptor binding + *
    • {@code SELF_BETA} = tuning factor for PDL-1 receptor binding + *
    • {@code CONTACT_FRAC} = fraction of surface area that contacts target cell when binding + *
    • {@code MAX_ANTIGEN_BINDING} = maximum bound antigen count for T cell exhaustion + *
    • {@code CARS} = number of CAR receptors on the cell + *
    * * @param container the cell container * @param location the {@link Location} of the cell @@ -179,7 +189,6 @@ public PatchCellCART( cars = parameters.getInt("CARS"); } - /* need to implement bindTarget equivalent here*/ /** * Determines if CAR T cell agent is bound to neighbor through receptor-target binding. * @@ -187,7 +196,7 @@ public PatchCellCART( * antigen and self receptors, compares values to random variable. Sets flags accordingly and * returns a target cell if one was bound by antigen or self receptor. * - * @param state the MASON simulation state + * @param sim the MASON simulation * @param loc the location of the CAR T-cell * @param random random seed */ @@ -297,7 +306,7 @@ public PatchCellTissue bindTarget( /** * Sets the cell binding flag. * - * @param antigenFlag the target cell antigen binding state + * @param flag the target cell antigen binding state */ public void setAntigenFlag(AntigenFlag flag) { this.binding = flag; @@ -312,7 +321,11 @@ public AntigenFlag getAntigenFlag() { return this.binding; } - /** Returns activation status */ + /** + * Returns the cell activation status + * + * @return the activation status + */ public boolean getActivationStatus() { return this.activated; } diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 87c5e97b2..6692e74dd 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -16,32 +16,25 @@ public class PatchCellCARTCD4 extends PatchCellCART { /** - * Creates a tissue {@code PatchCellCARTCD4} agent. * + * Creates a T cell {@code PatchCellCARTCD4} agent. * * - *

    Loaded parameters include: - * - *

      - *
    • {@code STIMULATORY_FRACTION} = fraction of stimulatory cells that become apoptotic - *
    - * - * @param id the cell ID - * @param parent the parent ID - * @param pop the cell population index - * @param state the cell state - * @param age the cell age - * @param divisions the number of cell divisions + * @param container the cell container * @param location the {@link Location} of the cell * @param parameters the dictionary of parameters - * @param volume the cell volume - * @param height the cell height - * @param criticalVolume the critical cell volume - * @param criticalHeight the critical cell height */ public PatchCellCARTCD4( PatchCellContainer container, Location location, Parameters parameters) { this(container, location, parameters, null); } + /** + * Creates a T cell {@code PatchCellCARTCD4} agent. * + * + * @param container the cell container + * @param location the {@link Location} of the cell + * @param parameters the dictionary of parameters + * @param links the map of population links + */ public PatchCellCARTCD4( PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { super(container, location, parameters, links); @@ -146,7 +139,6 @@ public void step(SimState simstate) { } else { // if CD4 cell is properly activated, it can stimulate super.setState(State.STIMULATORY); - // reset the cell this.lastActiveTicker = 0; this.activated = true; if (target.isStopped()) { @@ -154,7 +146,7 @@ public void step(SimState simstate) { } target.setState(State.QUIESCENT); this.binding = AntigenFlag.UNBOUND; - // need to reset + // reset the cell PatchActionReset reset = new PatchActionReset( this, diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index d80c456be..01bc42f1a 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -16,32 +16,25 @@ public class PatchCellCARTCD8 extends PatchCellCART { /** - * Creates a tissue {@code PatchCellCARTCD8} agent. * + * Creates a T cell {@code PatchCellCARTCD8} agent. * * - *

    Loaded parameters include: - * - *

      - *
    • {@code CYTOTOXIC_FRACTION} = fraction of cytotoxic cells that become apoptotic - *
    - * - * @param id the cell ID - * @param parent the parent ID - * @param pop the cell population index - * @param state the cell state - * @param age the cell age - * @param divisions the number of cell divisions + * @param container the cell container * @param location the {@link Location} of the cell * @param parameters the dictionary of parameters - * @param volume the cell volume - * @param height the cell height - * @param criticalVolume the critical cell volume - * @param criticalHeight the critical cell height */ public PatchCellCARTCD8( PatchCellContainer container, Location location, Parameters parameters) { this(container, location, parameters, null); } + /** + * Creates a T cell {@code PatchCellCARTCD8} agent. * + * + * @param container the cell container + * @param location the {@link Location} of the cell + * @param parameters the dictionary of parameters + * @param links the map of population links + */ public PatchCellCARTCD8( PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { super(container, location, parameters, links); @@ -49,10 +42,7 @@ public PatchCellCARTCD8( @Override public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFast random) { - divisions--; - // return new PatchCellCARTCD8(newID, id, pop, newState, age, divisions, newLocation, - // parameters, volume, height, criticalVolume, criticalHeight); return new PatchCellContainer( newID, id, @@ -146,11 +136,10 @@ public void step(SimState simstate) { super.setAntigenFlag(AntigenFlag.UNBOUND); this.activated = false; } else { - // if CD4 cell is properly activated, it can stimulate + // if CD8 cell is properly activated, it can be cytotoxic this.lastActiveTicker = 0; this.activated = true; super.setState(State.CYTOTOXIC); - // need to call kill PatchActionKill kill = new PatchActionKill( this, @@ -159,7 +148,7 @@ public void step(SimState simstate) { ((PatchSimulation) simstate).getSeries(), parameters); kill.schedule(sim.getSchedule()); - // need to reset + // cell resets after binding PatchActionReset reset = new PatchActionReset( this, diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index f6c71f673..9bd26e2be 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -14,15 +14,6 @@ /** Extension of {@link PatchCell} for healthy tissue cells. */ public class PatchCellTissue extends PatchCell { - // /** Fraction of necrotic cells that become apoptotic. */ - // private final double necroticFraction; - - // /** Fraction of senescent cells that become apoptotic. */ - // private final double senescentFraction; - - // these two variables are public bc I don't want to implement setter/getter methods for sims - // that do not use CART cells. - /** Cell surface antigen count */ int carAntigens; @@ -76,8 +67,6 @@ public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFas criticalHeight); } - /* consider making PatchCell parameters protected instead of private */ - @Override public void step(SimState simstate) { Simulation sim = (Simulation) simstate; From b76be6a447cc52429c0a8abc55bdba2cfff15f02 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 26 Dec 2024 23:50:38 +0000 Subject: [PATCH 045/185] fixing documentation for these classes --- .../patch/agent/cell/PatchCellCART.java | 13 -------- .../process/PatchProcessInflammation.java | 30 ++++++------------- .../process/PatchProcessInflammationCD4.java | 5 ++-- .../process/PatchProcessInflammationCD8.java | 6 ++-- .../PatchProcessMetabolismCARTTest.java | 2 ++ 5 files changed, 15 insertions(+), 41 deletions(-) create mode 100644 test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index ff7e9f95e..f2ef206b7 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -45,19 +45,6 @@ * specified amount of heterogeneity ({@code HETEROGENEITY}). */ public abstract class PatchCellCART extends PatchCell { - - // /** Fraction of exhausted cells that become apoptotic. */ - // protected final double exhaustedFraction; - - // /** Fraction of senescent cells that become apoptotic. */ - // protected final double senescentFraction; - - // /** Fraction of anergic cells that become apoptotic. */ - // protected final double anergicFraction; - - // /** Fraction of proliferative cells that become apoptotic. */ - // protected final double proliferativeFraction; - /** Cell binding flag */ public AntigenFlag binding; diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index f4f06139b..443ba0cae 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -14,8 +14,8 @@ import arcade.patch.env.lattice.PatchLattice; /** - * Implementation of {@link arcade.patch.agent.process.Process} for inflammation type modules in - * which IL-2 is taken up and cytotoxic/stimulatory functions are modified. + * Implementation of {@link Process} for inflammation type modules in which IL-2 is taken up and + * cytotoxic/stimulatory functions are modified. * *

    The {@code Inflammation} module represents an 8-component signaling network. */ @@ -52,21 +52,21 @@ public abstract class PatchProcessInflammation extends PatchProcess { private static final double STEP_DIVIDER = 3.0; /** - * Rate of conversion of IL-2R two-chian complex to IL-2R three chian complex [/sec/step + * Rate of conversion of IL-2R two-chain complex to IL-2R three chain complex [/sec/step * divider] */ private static final double K_CONVERT = 1e-3 / STEP_DIVIDER; /** - * Rate of recycling of recptor complexes back to IL-2 receptor two chain complex [/sec/step + * Rate of recycling of receptor complexes back to IL-2 receptor two chain complex [/sec/step * divider] */ private static final double K_REC = 1e-5 / STEP_DIVIDER; - /** Rate of IL-2 binding to two-chain IL-2 recpetor complex [um^3/molecules IL-2/min] */ + /** Rate of IL-2 binding to two-chain IL-2 receptor complex [um^3/molecules IL-2/min] */ private double IL2_BINDING_ON_RATE_MIN = 3.8193E-2; - /** Rate of IL-2 binding to three-chain IL-2 recpetor complex [um^3/molecules IL-2/min] */ + /** Rate of IL-2 binding to three-chain IL-2 receptor complex [um^3/molecules IL-2/min] */ private double IL2_BINDING_ON_RATE_MAX = 3.155; /** Rate of unbinding of IL-2 from two- or three- chain IL-2 receptor complex [/min] */ @@ -118,15 +118,13 @@ public abstract class PatchProcessInflammation extends PatchProcess { protected final double IL2_RECEPTORS; /** - * Creates an {@code Inflammation} module for the given {@link - * arcade.patch.agent.PatchCell.PatchCellCART}. + * Creates an {@code Inflammation} module for the given {@link PatchCellCART}. * *

    Module parameters are specific for the cell population. The module starts with no IL-2 * bound and no three-chain receptors. Daughter cells split amounts of bound IL-2 and * three-chain receptors upon dividing. * - * @param c the {@link arcade.patch.agent.PatchCell.PatchCellCART} the module is associated with - * @param sim the simulation instance + * @param c the {@link PatchCellCART} the module is associated with */ public PatchProcessInflammation(PatchCellCART c) { super(c); @@ -146,8 +144,6 @@ public PatchProcessInflammation(PatchCellCART c) { this.IL2_BINDING_ON_RATE_MAX = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MAX"); this.IL2_BINDING_OFF_RATE = parameters.getDouble("inflammation/IL2_BINDING_OFF_RATE"); - // Set external concentrations. - // updateExternal(sim); extIL2 = 0; // Initial amounts of each species, all in molecules/cell. @@ -249,13 +245,6 @@ public double getInternal(String key) { return amts[names.indexOf(key)]; } - /** - * Steps the inflammation module. - * - * @param sim the simulation instance - */ - // abstract void stepInflammationModule(Simulation sim); - public void setInternal(String key, double val) { amts[names.indexOf(key)] = val; } @@ -321,8 +310,7 @@ public void step(MersenneTwisterFast random, Simulation sim) { /** * Creates a {@code PatchProcessInflammation} for given version. * - * @param cell the {@link arcade.patch.agent.PatchCell.PatchCellCART} the process is associated - * with + * @param cell the {@link PatchCellCART} the process is associated with * @param version the process version * @return the process instance */ diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java index d7fdd24b8..d8e777258 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java @@ -33,12 +33,11 @@ public class PatchProcessInflammationCD4 extends PatchProcessInflammation { private double priorIL2prod; /** - * Creates a CD4 {@link arcade.agent.module.Inflammation} module. + * Creates a CD4 {@link PatchProcessInflammation} module. * *

    IL-2 production rate parameters set. * - * @param c the {@link arcade.agent.cell.CARTCell} the module is associated with - * @param sim the simulation instance + * @param c the {@link PatchCellCART} the module is associated with */ public PatchProcessInflammationCD4(PatchCellCART c) { super(c); diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index 20f4bd8ec..b2254d6de 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -17,12 +17,11 @@ public class PatchProcessInflammationCD8 extends PatchProcessInflammation { private double priorIL2granz; /** - * Creates a CD8 {@link arcade.agent.module.Inflammation} module. + * Creates a CD8 {@link PatchProcessInflammation} module. * *

    Initial amount of internal granzyme is set. Granzyme production parameters set. * - * @param c the {@link arcade.agent.cell.CARTCell} the module is associated with - * @param sim the simulation instance + * @param c the {@link PatchCellCART} the module is associated with */ public PatchProcessInflammationCD8(PatchCellCART c) { super(c); @@ -65,7 +64,6 @@ public void update(Process mod) { double split = (this.cell.getVolume() / this.volume); // Update daughter cell inflammation as a fraction of parent. - // this.volume = this.cell.getVolume(); this.amts[IL2Rbga] = inflammation.amts[IL2Rbga] * split; this.amts[IL2_IL2Rbg] = inflammation.amts[IL2_IL2Rbg] * split; this.amts[IL2_IL2Rbga] = inflammation.amts[IL2_IL2Rbga] * split; diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java new file mode 100644 index 000000000..821215256 --- /dev/null +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -0,0 +1,2 @@ +public class PatchProcessMetabolismCARTTest { +} From b0b31d39c5eca0c4c2402958dd00a5d4cebadfd4 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 26 Dec 2024 23:51:06 +0000 Subject: [PATCH 046/185] adding testing specific methods to access field values --- .../process/PatchProcessMetabolismCART.java | 61 ++++++++++++++----- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java index 74ae29d6d..79a949583 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java @@ -56,6 +56,15 @@ public class PatchProcessMetabolismCART extends PatchProcessMetabolism { /** Time delay for changes in metabolism. */ private final int timeDelay; + /** Metabolic preference value after stepping through the process. For testing purposes only */ + private double finalMetabolicPreference; + + /** Glucose uptake rate value after stepping through the process. For testing purposes only */ + private double finalGlucoseUptakeRate; + + /** Minimum mass fraction value after stepping through the process. For testing purposes only */ + private double finalMinimumMassFraction; + /** * Creates a metabolism {@link PatchProcess} for the given cell. * @@ -239,6 +248,13 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { upAmts[GLUCOSE] = glucUptake; upAmts[OXYGEN] = oxyUptake; intAmts[PYRUVATE] = pyruInt; + + // Set final metabolic preference for testing + finalMetabolicPreference = metabolicPreference; + // Set final glucose uptake rate for testing + finalGlucoseUptakeRate = glucoseUptakeRate; + // Set final min mass fraction for testing + finalMinimumMassFraction = minimumMassFraction; } @Override @@ -257,22 +273,35 @@ public void update(Process process) { metabolism.intAmts[PYRUVATE] *= (1 - split); metabolism.volume *= (1 - split); metabolism.mass *= (1 - split); + } + + /** + * Returns final value of metabolic preference after stepping process Exists for testing + * purposes only + * + * @return final value of the metabolic preference + */ + public double getFinalMetabolicPreference() { + return finalMetabolicPreference; + } - // PatchProcessMetabolismCART metabolism = (PatchProcessMetabolismCART) process; - // double split = this.cell.getVolume() / this.volume; - - // // Update this process as split of given process. - // this.volume = this.cell.getVolume(); - // this.energy = this.cell.getEnergy(); - // this.mass = this.volume * cellDensity; - // this.intAmts[GLUCOSE] = metabolism.intAmts[GLUCOSE] * split; - // this.intAmts[PYRUVATE] = metabolism.intAmts[PYRUVATE] * split; - - // // Update given process with remaining split. - // metabolism.volume = metabolism.cell.getVolume(); - // metabolism.energy = metabolism.cell.getEnergy(); - // metabolism.mass = metabolism.volume * cellDensity; - // metabolism.intAmts[GLUCOSE] *= (1 - split); - // metabolism.intAmts[PYRUVATE] *= (1 - split); + /** + * Returns final value of glucose uptake rate after stepping process Exists for testing purposes + * only + * + * @return final value of glucose uptake rate + */ + public double getFinalGlucoseUptakeRate() { + return finalGlucoseUptakeRate; + } + + /** + * Returns final value of minimum mass fraction after stepping process Exists for testing + * purposes only + * + * @return final value of min mass fraction + */ + public double getFinalMinimumMassFraction() { + return finalMinimumMassFraction; } } From edd42cb84d696f1870817d5eac58b82865caa65e Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 26 Dec 2024 23:51:36 +0000 Subject: [PATCH 047/185] adding metabolism tests for CART cells --- .../PatchProcessMetabolismCARTTest.java | 317 ++++++++++++++++++ 1 file changed, 317 insertions(+) diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java index 821215256..b5b724d03 100644 --- a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -1,2 +1,319 @@ +package arcade.patch.agent.process; + +import java.lang.reflect.Field; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import ec.util.MersenneTwisterFast; +import arcade.core.sim.Simulation; +import arcade.core.util.Parameters; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.patch.env.location.PatchLocation; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static arcade.core.ARCADETestUtilities.randomDoubleBetween; + public class PatchProcessMetabolismCARTTest { + + private PatchCellCART mockCell; + private Parameters mockParameters; + private PatchProcessMetabolismCART metabolism; + private PatchLocation mockLocation; + + @BeforeEach + public void setUp() { + mockCell = mock(PatchCellCART.class); + mockParameters = mock(Parameters.class); + mockLocation = mock(PatchLocation.class); + + when(mockCell.getParameters()).thenReturn(mockParameters); + when(mockParameters.getDouble(anyString())).thenReturn(1.0); + when(mockCell.getLocation()).thenReturn(mockLocation); + when(mockCell.getVolume()).thenReturn(randomDoubleBetween(165, 180)); + when(mockLocation.getPerimeter(anyDouble())) + .thenReturn(randomDoubleBetween(0, 1.0) * 6 * 30 / Math.sqrt(3)); + when(mockLocation.getArea()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30); + when(mockLocation.getVolume()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30 * 8.7); + } + + @Test + public void testConstructorInitializesFields() + throws NoSuchFieldException, IllegalAccessException { + metabolism = new PatchProcessMetabolismCART(mockCell); + + assertNotNull(metabolism); + + Field metaPrefField = PatchProcessMetabolismCART.class.getDeclaredField("metaPref"); + metaPrefField.setAccessible(true); + assertEquals(1.0, metaPrefField.get(metabolism)); + + Field conversionFractionField = + PatchProcessMetabolismCART.class.getDeclaredField("conversionFraction"); + conversionFractionField.setAccessible(true); + assertEquals(1.0, conversionFractionField.get(metabolism)); + + Field fracMassField = PatchProcessMetabolismCART.class.getDeclaredField("fracMass"); + fracMassField.setAccessible(true); + assertEquals(1.0, fracMassField.get(metabolism)); + + Field ratioGlucosePyruvateField = + PatchProcessMetabolismCART.class.getDeclaredField("ratioGlucosePyruvate"); + ratioGlucosePyruvateField.setAccessible(true); + assertEquals(1.0, ratioGlucosePyruvateField.get(metabolism)); + + Field lactateRateField = PatchProcessMetabolismCART.class.getDeclaredField("lactateRate"); + lactateRateField.setAccessible(true); + assertEquals(1.0, lactateRateField.get(metabolism)); + + Field autophagyRateField = + PatchProcessMetabolismCART.class.getDeclaredField("autophagyRate"); + autophagyRateField.setAccessible(true); + assertEquals(1.0, autophagyRateField.get(metabolism)); + + Field glucUptakeRateField = + PatchProcessMetabolismCART.class.getDeclaredField("glucUptakeRate"); + glucUptakeRateField.setAccessible(true); + assertEquals(1.0, glucUptakeRateField.get(metabolism)); + + Field metabolicPreference_IL2Field = + PatchProcessMetabolismCART.class.getDeclaredField("metabolicPreference_IL2"); + metabolicPreference_IL2Field.setAccessible(true); + assertEquals(1.0, metabolicPreference_IL2Field.get(metabolism)); + + Field metabolicPreference_activeField = + PatchProcessMetabolismCART.class.getDeclaredField("metabolicPreference_active"); + metabolicPreference_activeField.setAccessible(true); + assertEquals(1.0, metabolicPreference_activeField.get(metabolism)); + + Field glucoseUptakeRate_IL2Field = + PatchProcessMetabolismCART.class.getDeclaredField("glucoseUptakeRate_IL2"); + glucoseUptakeRate_IL2Field.setAccessible(true); + assertEquals(1.0, glucoseUptakeRate_IL2Field.get(metabolism)); + + Field glucoseUptakeRate_activeField = + PatchProcessMetabolismCART.class.getDeclaredField("glucoseUptakeRate_active"); + glucoseUptakeRate_activeField.setAccessible(true); + assertEquals(1.0, glucoseUptakeRate_activeField.get(metabolism)); + + Field minimumMassFraction_activeField = + PatchProcessMetabolismCART.class.getDeclaredField("minimumMassFraction_active"); + minimumMassFraction_activeField.setAccessible(true); + assertEquals(1.0, minimumMassFraction_activeField.get(metabolism)); + + Field timeDelayField = PatchProcessMetabolismCART.class.getDeclaredField("timeDelay"); + timeDelayField.setAccessible(true); + assertEquals(1, timeDelayField.get(metabolism)); + } + + @Test + public void testStepProcess() throws NoSuchFieldException, IllegalAccessException { + // set up metabolism class + when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); + when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); + metabolism = new PatchProcessMetabolismCART(mockCell); + Field fraction = PatchProcessMetabolism.class.getDeclaredField("f"); + fraction.setAccessible(true); + fraction.set(metabolism, 1.0); + + // set up simulation + MersenneTwisterFast random = new MersenneTwisterFast(); + Simulation sim = mock(Simulation.class); + + // mock inflammation process + PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + when(mockCell.getProcess(any())).thenReturn(inflammation); + when(mockCell.getActivationStatus()).thenReturn(true); + + metabolism.stepProcess(random, sim); + + assertTrue(metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] >= 0); + assertTrue(metabolism.intAmts[PatchProcessMetabolismCART.PYRUVATE] >= 0); + } + + @Test + public void testStepProcessWithZeroInitialGlucose() { + // set up metabolism class + when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); + when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.0); + metabolism = new PatchProcessMetabolismCART(mockCell); + + // set up simulation + MersenneTwisterFast random = new MersenneTwisterFast(); + Simulation sim = mock(Simulation.class); + + // mock inflammation process + PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + when(mockCell.getProcess(any())).thenReturn(inflammation); + when(mockCell.getActivationStatus()).thenReturn(true); + + metabolism.stepProcess(random, sim); + + assertEquals(0.0, metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]); + } + + @Test + public void testStepProcessWithMaxGlucoseConcentration() { + // set up metabolism class + when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); + when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")) + .thenReturn(Double.MAX_VALUE); + metabolism = new PatchProcessMetabolismCART(mockCell); + + // set up simulation + MersenneTwisterFast random = new MersenneTwisterFast(); + Simulation sim = mock(Simulation.class); + + // mock inflammation process + PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + when(mockCell.getProcess(any())).thenReturn(inflammation); + when(mockCell.getActivationStatus()).thenReturn(true); + + metabolism.stepProcess(random, sim); + + assertTrue(metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] <= Double.MAX_VALUE); + } + + @Test + public void testStepProcessWithNegativeGlucoseConcentration() { + // set up metabolism class + when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); + when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(-1.0); + metabolism = new PatchProcessMetabolismCART(mockCell); + + // set up simulation + MersenneTwisterFast random = new MersenneTwisterFast(); + Simulation sim = mock(Simulation.class); + + // mock inflammation process + PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + when(mockCell.getProcess(any())).thenReturn(inflammation); + when(mockCell.getActivationStatus()).thenReturn(true); + + metabolism.stepProcess(random, sim); + + assertTrue(metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] >= 0); + } + + @Test + public void testStepProcessWithZeroOxygenConcentration() { + // set up metabolism class + when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); + when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); + metabolism = new PatchProcessMetabolismCART(mockCell); + + // set up simulation + MersenneTwisterFast random = new MersenneTwisterFast(); + Simulation sim = mock(Simulation.class); + + // mock inflammation process + PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + when(mockCell.getProcess(any())).thenReturn(inflammation); + when(mockCell.getActivationStatus()).thenReturn(true); + + metabolism.extAmts[PatchProcessMetabolismCART.OXYGEN] = 0.0; + + metabolism.stepProcess(random, sim); + + assertEquals(0.0, metabolism.extAmts[PatchProcessMetabolismCART.OXYGEN]); + } + + @Test + public void testStepProcessWithMaxOxygenConcentration() { + // set up metabolism class + when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); + when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); + metabolism = new PatchProcessMetabolismCART(mockCell); + + // set up simulation + MersenneTwisterFast random = new MersenneTwisterFast(); + Simulation sim = mock(Simulation.class); + + // mock inflammation process + PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + when(mockCell.getProcess(any())).thenReturn(inflammation); + when(mockCell.getActivationStatus()).thenReturn(true); + + metabolism.extAmts[PatchProcessMetabolismCART.OXYGEN] = Double.MAX_VALUE; + + metabolism.stepProcess(random, sim); + + assertTrue(metabolism.extAmts[PatchProcessMetabolismCART.OXYGEN] <= Double.MAX_VALUE); + } + + @Test + public void testActivatedMetabolicPreference() + throws IllegalAccessException, NoSuchFieldException { + // set up metabolism class + when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); + when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); + metabolism = new PatchProcessMetabolismCART(mockCell); + + // set up simulation + MersenneTwisterFast random = new MersenneTwisterFast(); + Simulation sim = mock(Simulation.class); + + // mock inflammation process + PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker"); + activeTicker.setAccessible(true); + activeTicker.set(inflammation, 1); + when(mockCell.getProcess(any())).thenReturn(inflammation); + when(mockCell.getActivationStatus()).thenReturn(true); + + metabolism.stepProcess(random, sim); + + double expectedMetabolicPreference = 1.0 + 1.0; // base + active + assertEquals(expectedMetabolicPreference, metabolism.getFinalMetabolicPreference()); + } + + @Test + public void testActivatedGlucoseUptakeRate() + throws IllegalAccessException, NoSuchFieldException { + // set up metabolism class + when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); + when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); + metabolism = new PatchProcessMetabolismCART(mockCell); + + // set up simulation + MersenneTwisterFast random = new MersenneTwisterFast(); + Simulation sim = mock(Simulation.class); + + // mock inflammation process + PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker"); + activeTicker.setAccessible(true); + activeTicker.set(inflammation, 1); + when(mockCell.getProcess(any())).thenReturn(inflammation); + when(mockCell.getActivationStatus()).thenReturn(true); + + metabolism.stepProcess(random, sim); + + double expectedGlucoseUptakeRate = 1.12 + 1.0; // base + active + assertEquals(expectedGlucoseUptakeRate, metabolism.getFinalGlucoseUptakeRate()); + } + + @Test + public void testActivatedMinimumMassFraction() + throws NoSuchFieldException, IllegalAccessException { + // set up metabolism class + when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); + when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); + metabolism = new PatchProcessMetabolismCART(mockCell); + + // set up simulation + MersenneTwisterFast random = new MersenneTwisterFast(); + Simulation sim = mock(Simulation.class); + + // mock inflammation process + PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker"); + activeTicker.setAccessible(true); + activeTicker.set(inflammation, 1); + when(mockCell.getProcess(any())).thenReturn(inflammation); + when(mockCell.getActivationStatus()).thenReturn(true); + + metabolism.stepProcess(random, sim); + + double expectedMinimumMassFraction = 1.0 + 1.0; // base + active + assertEquals(expectedMinimumMassFraction, metabolism.getFinalMinimumMassFraction()); + } } From 36a9c658cf5b23fa58bacb86625180f9d95f7d29 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 27 Dec 2024 20:01:02 +0000 Subject: [PATCH 048/185] adding cd8 inflammation module tests --- .../PatchProcessInflammationCD8Test.java | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java new file mode 100644 index 000000000..459d1fa2b --- /dev/null +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java @@ -0,0 +1,147 @@ +package arcade.patch.agent.process; + +import java.lang.reflect.Field; +import java.util.Arrays; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import ec.util.MersenneTwisterFast; +import arcade.core.sim.Simulation; +import arcade.core.util.Parameters; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.patch.env.lattice.PatchLattice; +import arcade.patch.env.location.PatchLocation; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.*; +import static arcade.core.ARCADETestUtilities.randomDoubleBetween; + +public class PatchProcessInflammationCD8Test { + + private PatchProcessInflammationCD8 inflammation; + private PatchCellCART mockCell; + private Parameters mockParameters; + private Simulation mockSimulation; + private MersenneTwisterFast mockRandom; + private double cellVolume; + + @BeforeEach + public void setUp() { + mockCell = Mockito.mock(PatchCellCART.class); + mockParameters = Mockito.mock(Parameters.class); + mockSimulation = Mockito.mock(Simulation.class); + mockRandom = Mockito.mock(MersenneTwisterFast.class); + PatchLocation mockLocation = mock(PatchLocation.class); + PatchLattice mockLattice = mock(PatchLattice.class); + + Mockito.when(mockCell.getParameters()).thenReturn(mockParameters); + cellVolume = randomDoubleBetween(165, 180); + when(mockCell.getVolume()).thenReturn(cellVolume); + when(mockCell.getLocation()).thenReturn(mockLocation); + when(mockLocation.getVolume()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30 * 8.7); + when(mockParameters.getDouble(anyString())).thenReturn(1.0); + when(mockParameters.getInt(anyString())).thenReturn(1); + + when(mockSimulation.getLattice(anyString())).thenReturn(mockLattice); + doNothing().when(mockLattice).setValue(any(PatchLocation.class), anyDouble()); + } + + @Test + public void testConstructor() throws NoSuchFieldException, IllegalAccessException { + inflammation = new PatchProcessInflammationCD8(mockCell); + assertNotNull(inflammation); + + assertEquals(1, inflammation.amts[PatchProcessInflammationCD8.GRANZYME]); + + Field prior = PatchProcessInflammationCD8.class.getDeclaredField("priorIL2granz"); + prior.setAccessible(true); + assertEquals(0.0, prior.get(inflammation)); + + Field delay = PatchProcessInflammationCD8.class.getDeclaredField("GRANZ_SYNTHESIS_DELAY"); + delay.setAccessible(true); + assertEquals(1, delay.get(inflammation)); + } + + @Test + public void testStepProcess() throws NoSuchFieldException, IllegalAccessException { + inflammation = new PatchProcessInflammationCD8(mockCell); + inflammation.active = true; + inflammation.activeTicker = 10; + inflammation.IL2Ticker = 10; + inflammation.boundArray = new double[180]; + Arrays.fill(inflammation.boundArray, 10000); + + Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + receptors.setAccessible(true); + receptors.set(inflammation, 5000); + + inflammation.stepProcess(mockRandom, mockSimulation); + + assertTrue(inflammation.amts[PatchProcessInflammationCD8.GRANZYME] > 1); + } + + @Test + public void testStepProcessInactive() throws NoSuchFieldException, IllegalAccessException { + inflammation = new PatchProcessInflammationCD8(mockCell); + inflammation.active = false; + inflammation.activeTicker = 10; + inflammation.IL2Ticker = 10; + inflammation.boundArray = new double[] {0, 0, 0, 0, 100}; + Arrays.fill(inflammation.boundArray, 10000); + + Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + receptors.setAccessible(true); + receptors.set(inflammation, 5000); + + inflammation.stepProcess(mockRandom, mockSimulation); + + assertEquals(1, inflammation.amts[PatchProcessInflammationCD8.GRANZYME]); + } + + @Test + public void testStepProcessActiveTickerLessThanDelay() + throws NoSuchFieldException, IllegalAccessException { + Mockito.when(mockParameters.getInt("inflammation/GRANZ_SYNTHESIS_DELAY")).thenReturn(5); + inflammation = new PatchProcessInflammationCD8(mockCell); + inflammation.active = true; + inflammation.activeTicker = 3; + inflammation.IL2Ticker = 10; + inflammation.boundArray = new double[] {0, 0, 0, 0, 100}; + Arrays.fill(inflammation.boundArray, 10000); + + Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + receptors.setAccessible(true); + receptors.set(inflammation, 5000); + + inflammation.stepProcess(mockRandom, mockSimulation); + + assertEquals(1, inflammation.amts[PatchProcessInflammationCD8.GRANZYME]); + } + + @Test + public void testUpdate() { + inflammation = new PatchProcessInflammationCD8(mockCell); + PatchProcessInflammationCD8 parentProcess = new PatchProcessInflammationCD8(mockCell); + parentProcess.amts[PatchProcessInflammationCD8.GRANZYME] = 100; + when(mockCell.getVolume()).thenReturn(cellVolume / 2); + + inflammation.update(parentProcess); + + assertEquals(50, inflammation.amts[PatchProcessInflammationCD8.GRANZYME]); + assertEquals(50, parentProcess.amts[PatchProcessInflammationCD8.GRANZYME]); + } + + @Test + public void testUpdateZeroVolumeParent() { + inflammation = new PatchProcessInflammationCD8(mockCell); + PatchProcessInflammationCD8 parentProcess = new PatchProcessInflammationCD8(mockCell); + parentProcess.amts[PatchProcessInflammationCD8.GRANZYME] = 100; + when(mockCell.getVolume()).thenReturn(0.0); + + inflammation.update(parentProcess); + + assertEquals(0, inflammation.amts[PatchProcessInflammationCD8.GRANZYME]); + assertEquals(100, parentProcess.amts[PatchProcessInflammationCD8.GRANZYME]); + } +} From 6d27509e58d0600ab3246e6f6b1bb5fd40df7962 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 27 Dec 2024 20:05:02 +0000 Subject: [PATCH 049/185] update array size in inflammation cd8 tests --- .../patch/agent/process/PatchProcessInflammationCD8Test.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java index 459d1fa2b..e6b5ade5a 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java @@ -87,7 +87,7 @@ public void testStepProcessInactive() throws NoSuchFieldException, IllegalAccess inflammation.active = false; inflammation.activeTicker = 10; inflammation.IL2Ticker = 10; - inflammation.boundArray = new double[] {0, 0, 0, 0, 100}; + inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); @@ -107,7 +107,7 @@ public void testStepProcessActiveTickerLessThanDelay() inflammation.active = true; inflammation.activeTicker = 3; inflammation.IL2Ticker = 10; - inflammation.boundArray = new double[] {0, 0, 0, 0, 100}; + inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); From f5990610a73f904bfbfca5917cc97b425a20d80a Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 27 Dec 2024 20:12:16 +0000 Subject: [PATCH 050/185] adding update process tests to CART metabolism --- .../PatchProcessMetabolismCARTTest.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java index b5b724d03..de2965be9 100644 --- a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -18,6 +18,7 @@ public class PatchProcessMetabolismCARTTest { private Parameters mockParameters; private PatchProcessMetabolismCART metabolism; private PatchLocation mockLocation; + private double cellVolume; @BeforeEach public void setUp() { @@ -28,7 +29,8 @@ public void setUp() { when(mockCell.getParameters()).thenReturn(mockParameters); when(mockParameters.getDouble(anyString())).thenReturn(1.0); when(mockCell.getLocation()).thenReturn(mockLocation); - when(mockCell.getVolume()).thenReturn(randomDoubleBetween(165, 180)); + cellVolume = randomDoubleBetween(165, 180); + when(mockCell.getVolume()).thenReturn(cellVolume); when(mockLocation.getPerimeter(anyDouble())) .thenReturn(randomDoubleBetween(0, 1.0) * 6 * 30 / Math.sqrt(3)); when(mockLocation.getArea()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30); @@ -316,4 +318,30 @@ public void testActivatedMinimumMassFraction() double expectedMinimumMassFraction = 1.0 + 1.0; // base + active assertEquals(expectedMinimumMassFraction, metabolism.getFinalMinimumMassFraction()); } + + @Test + public void testUpdate() { + metabolism = new PatchProcessMetabolismCART(mockCell); + PatchProcessMetabolismCART parentProcess = new PatchProcessMetabolismCART(mockCell); + parentProcess.intAmts[PatchProcessMetabolismCART.GLUCOSE] = 100; + when(mockCell.getVolume()).thenReturn(cellVolume / 2); + + metabolism.update(parentProcess); + + assertEquals(50, metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]); + assertEquals(50, parentProcess.intAmts[PatchProcessMetabolismCART.GLUCOSE]); + } + + @Test + public void testUpdateZeroVolumeParent() { + metabolism = new PatchProcessMetabolismCART(mockCell); + PatchProcessMetabolismCART parentProcess = new PatchProcessMetabolismCART(mockCell); + parentProcess.intAmts[PatchProcessMetabolismCART.GLUCOSE] = 100; + when(mockCell.getVolume()).thenReturn(0.0); + + metabolism.update(parentProcess); + + assertEquals(0, metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]); + assertEquals(100, parentProcess.intAmts[PatchProcessMetabolismCART.GLUCOSE]); + } } From b24017151764f334574b4fbc5dc38f56c7b6fdb1 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Sat, 28 Dec 2024 00:26:02 +0000 Subject: [PATCH 051/185] adding additional accessor method for testing purposes --- .../process/PatchProcessInflammationCD4.java | 16 ++++++++++++++++ .../process/PatchProcessInflammationCD4Test.java | 4 ++++ 2 files changed, 20 insertions(+) create mode 100644 test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java index d8e777258..92aa0f077 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java @@ -32,6 +32,9 @@ public class PatchProcessInflammationCD4 extends PatchProcessInflammation { /** Amount of IL-2 bound in past being used for current IL-2 production calculation */ private double priorIL2prod; + /** External IL-2 sent into environment after each step. Used for testing only */ + private double IL2EnvTesting; + /** * Creates a CD4 {@link PatchProcessInflammation} module. * @@ -75,6 +78,10 @@ public void stepProcess(MersenneTwisterFast random, Simulation sim) { // then convert units back to molecules/cm^3. double IL2Env = (((extIL2 - (extIL2 * f - amts[IL2_EXT])) + IL2Produced) * 1E12 / loc.getVolume()); + + // update IL2 env variable for testing + IL2EnvTesting = IL2Env; + sim.getLattice("IL-2").setValue(loc, IL2Env); } @@ -108,4 +115,13 @@ public void update(Process mod) { inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2Rbg] + inflammation.amts[IL2Rbga]; inflammation.volume *= (1 - split); } + + /** + * Returns final value of external IL2 after stepping process. Exists for testing purposes only + * + * @return final value of external IL2 + */ + public double getIL2EnvTesting() { + return IL2EnvTesting; + } } diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java new file mode 100644 index 000000000..0791a83bd --- /dev/null +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java @@ -0,0 +1,4 @@ +package arcade.patch.agent.process; + +public class PatchProcessInflammationCD4Test { +} From 7bf29dad89f6018b3ab037749b25c978c3bcb1a6 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Sat, 28 Dec 2024 00:26:18 +0000 Subject: [PATCH 052/185] adding cd4 inflammation tests --- .../PatchProcessInflammationCD4Test.java | 272 ++++++++++++++++++ 1 file changed, 272 insertions(+) diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java index 0791a83bd..6a8276001 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java @@ -1,4 +1,276 @@ package arcade.patch.agent.process; +import java.lang.reflect.Field; +import java.util.Arrays; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import ec.util.MersenneTwisterFast; +import arcade.core.sim.Simulation; +import arcade.core.util.Parameters; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.patch.env.lattice.PatchLattice; +import arcade.patch.env.location.PatchLocation; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static arcade.core.ARCADETestUtilities.randomDoubleBetween; + public class PatchProcessInflammationCD4Test { + + private PatchProcessInflammationCD4 inflammation; + private PatchCellCART mockCell; + private PatchLattice mockLattice; + private Parameters mockParameters; + private Simulation mockSim; + private MersenneTwisterFast mockRandom; + private double cellVolume; + private PatchLocation mockLocation; + + @BeforeEach + public void setUp() { + mockCell = Mockito.mock(PatchCellCART.class); + mockParameters = Mockito.mock(Parameters.class); + mockSim = Mockito.mock(Simulation.class); + mockRandom = Mockito.mock(MersenneTwisterFast.class); + mockLocation = mock(PatchLocation.class); + mockLattice = mock(PatchLattice.class); + + Mockito.when(mockCell.getParameters()).thenReturn(mockParameters); + cellVolume = randomDoubleBetween(165, 180); + when(mockCell.getVolume()).thenReturn(cellVolume); + when(mockCell.getLocation()).thenReturn(mockLocation); + when(mockLocation.getVolume()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30 * 8.7); + when(mockParameters.getDouble(anyString())).thenReturn(1.0); + when(mockParameters.getInt(anyString())).thenReturn(1); + + when(mockSim.getLattice(anyString())).thenReturn(mockLattice); + doNothing().when(mockLattice).setValue(any(PatchLocation.class), anyDouble()); + } + + @Test + public void testConstructor() throws NoSuchFieldException, IllegalAccessException { + inflammation = new PatchProcessInflammationCD4(mockCell); + assertNotNull(inflammation); + + Field il2ProdRate = PatchProcessInflammationCD4.class.getDeclaredField("IL2ProdRate"); + il2ProdRate.setAccessible(true); + assertEquals(0.0, il2ProdRate.get(inflammation)); + + Field il2ProdRateIL2 = + PatchProcessInflammationCD4.class.getDeclaredField("IL2_PROD_RATE_IL2"); + il2ProdRateIL2.setAccessible(true); + assertEquals(1.0, il2ProdRateIL2.get(inflammation)); + + Field il2ProdRateActive = + PatchProcessInflammationCD4.class.getDeclaredField("IL2_PROD_RATE_ACTIVE"); + il2ProdRateActive.setAccessible(true); + assertEquals(1.0, il2ProdRateActive.get(inflammation)); + + Field il2SynthesisDelay = + PatchProcessInflammationCD4.class.getDeclaredField("IL2_SYNTHESIS_DELAY"); + il2SynthesisDelay.setAccessible(true); + assertEquals(1, il2SynthesisDelay.get(inflammation)); + } + + @Test + public void testStepProcess() throws NoSuchFieldException, IllegalAccessException { + inflammation = new PatchProcessInflammationCD4(mockCell); + + inflammation.active = true; + inflammation.activeTicker = 10; + inflammation.IL2Ticker = 10; + inflammation.boundArray = new double[180]; + Arrays.fill(inflammation.boundArray, 10000); + + Field il2ProdRateIL2 = + PatchProcessInflammationCD4.class.getDeclaredField("IL2_PROD_RATE_IL2"); + il2ProdRateIL2.setAccessible(true); + il2ProdRateIL2.set(inflammation, 0.05); + + Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + receptors.setAccessible(true); + receptors.set(inflammation, 5000); + + Field fraction = PatchProcessInflammation.class.getDeclaredField("f"); + fraction.setAccessible(true); + fraction.set(inflammation, 1.0); + + inflammation.stepProcess(mockRandom, mockSim); + + // check that patch lattice set value is called + verify(mockLattice, times(1)).setValue(any(PatchLocation.class), anyDouble()); + + // check that IL2 produced is calculated correctly + Field il2Produced = PatchProcessInflammationCD4.class.getDeclaredField("IL2Produced"); + il2Produced.setAccessible(true); + assertEquals(1.1, il2Produced.get(inflammation)); + + // check that extIL2 is calculated correctly + double expectedIL2 = + (1.1 + inflammation.amts[PatchProcessInflammationCD4.IL2_EXT]) + * 1E12 + / mockLocation.getVolume(); + assertEquals(expectedIL2, inflammation.getIL2EnvTesting()); + } + + @Test + public void testStepProcessActive() throws NoSuchFieldException, IllegalAccessException { + inflammation = new PatchProcessInflammationCD4(mockCell); + + inflammation.active = true; + inflammation.activeTicker = 10; + inflammation.IL2Ticker = 10; + inflammation.boundArray = new double[180]; + Arrays.fill(inflammation.boundArray, 10000); + + Field il2ProdRateIL2 = + PatchProcessInflammationCD4.class.getDeclaredField("IL2_PROD_RATE_IL2"); + il2ProdRateIL2.setAccessible(true); + il2ProdRateIL2.set(inflammation, 0.05); + + Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + receptors.setAccessible(true); + receptors.set(inflammation, 5000); + + Field fraction = PatchProcessInflammation.class.getDeclaredField("f"); + fraction.setAccessible(true); + fraction.set(inflammation, 1.0); + + Field activeIl2Rate = + PatchProcessInflammationCD4.class.getDeclaredField("IL2_PROD_RATE_ACTIVE"); + activeIl2Rate.setAccessible(true); + activeIl2Rate.set(inflammation, 2.5); + + inflammation.stepProcess(mockRandom, mockSim); + + Field il2ProdRate = PatchProcessInflammationCD4.class.getDeclaredField("IL2ProdRate"); + il2ProdRate.setAccessible(true); + assertEquals(2.6, il2ProdRate.get(inflammation)); + } + + @Test + public void testStepProcessInactive() throws NoSuchFieldException, IllegalAccessException { + inflammation = new PatchProcessInflammationCD4(mockCell); + + inflammation.active = false; + inflammation.activeTicker = 10; + inflammation.IL2Ticker = 10; + inflammation.boundArray = new double[180]; + Arrays.fill(inflammation.boundArray, 10000); + + Field il2ProdRateIL2 = + PatchProcessInflammationCD4.class.getDeclaredField("IL2_PROD_RATE_IL2"); + il2ProdRateIL2.setAccessible(true); + il2ProdRateIL2.set(inflammation, 0.05); + + Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + receptors.setAccessible(true); + receptors.set(inflammation, 5000); + + Field fraction = PatchProcessInflammation.class.getDeclaredField("f"); + fraction.setAccessible(true); + fraction.set(inflammation, 1.0); + + inflammation.stepProcess(mockRandom, mockSim); + + Field il2ProdRate = PatchProcessInflammationCD4.class.getDeclaredField("IL2ProdRate"); + il2ProdRate.setAccessible(true); + assertEquals(0.1, il2ProdRate.get(inflammation)); + } + + @Test + public void testStepProcessActiveTickerLessThanDelay() + throws NoSuchFieldException, IllegalAccessException { + inflammation = new PatchProcessInflammationCD4(mockCell); + + inflammation.active = true; + inflammation.activeTicker = 10; + inflammation.IL2Ticker = 10; + inflammation.boundArray = new double[180]; + Arrays.fill(inflammation.boundArray, 10000); + + Field il2ProdRateIL2 = + PatchProcessInflammationCD4.class.getDeclaredField("IL2_PROD_RATE_IL2"); + il2ProdRateIL2.setAccessible(true); + il2ProdRateIL2.set(inflammation, 0.05); + + Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + receptors.setAccessible(true); + receptors.set(inflammation, 5000); + + Field fraction = PatchProcessInflammation.class.getDeclaredField("f"); + fraction.setAccessible(true); + fraction.set(inflammation, 1.0); + + Field delay = PatchProcessInflammationCD4.class.getDeclaredField("IL2_SYNTHESIS_DELAY"); + delay.setAccessible(true); + delay.set(inflammation, 15); + + inflammation.stepProcess(mockRandom, mockSim); + + Field il2ProdRate = PatchProcessInflammationCD4.class.getDeclaredField("IL2ProdRate"); + il2ProdRate.setAccessible(true); + assertEquals(0.1, il2ProdRate.get(inflammation)); + } + + @Test + public void testStepProcessWithZeroIL2ProdRate() + throws NoSuchFieldException, IllegalAccessException { + when(mockParameters.getDouble("inflammation/IL2_PROD_RATE_IL2")).thenReturn(0.0); + when(mockParameters.getDouble("inflammation/IL2_PROD_RATE_ACTIVE")).thenReturn(0.0); + inflammation = new PatchProcessInflammationCD4(mockCell); + + inflammation.active = true; + inflammation.activeTicker = 10; + inflammation.IL2Ticker = 10; + inflammation.boundArray = new double[180]; + Arrays.fill(inflammation.boundArray, 10000); + + Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + receptors.setAccessible(true); + receptors.set(inflammation, 5000); + + Field fraction = PatchProcessInflammation.class.getDeclaredField("f"); + fraction.setAccessible(true); + fraction.set(inflammation, 1.0); + + inflammation.stepProcess(mockRandom, mockSim); + + Field il2ProdRate = PatchProcessInflammationCD4.class.getDeclaredField("IL2ProdRate"); + il2ProdRate.setAccessible(true); + assertEquals(0.0, il2ProdRate.get(inflammation)); + + Field il2Produced = PatchProcessInflammationCD4.class.getDeclaredField("IL2Produced"); + il2Produced.setAccessible(true); + assertEquals(0.0, il2Produced.get(inflammation)); + } + + @Test + public void testUpdate() { + inflammation = new PatchProcessInflammationCD4(mockCell); + PatchProcessInflammationCD4 parentProcess = new PatchProcessInflammationCD4(mockCell); + parentProcess.amts[PatchProcessInflammationCD4.IL2Rbga] = 100; + when(mockCell.getVolume()).thenReturn(cellVolume / 2); + + inflammation.update(parentProcess); + + assertEquals(50, inflammation.amts[PatchProcessInflammationCD4.IL2Rbga]); + assertEquals(50, parentProcess.amts[PatchProcessInflammationCD4.IL2Rbga]); + } + + @Test + public void testUpdateWithZeroVolume() { + inflammation = new PatchProcessInflammationCD4(mockCell); + PatchProcessInflammationCD4 parentProcess = new PatchProcessInflammationCD4(mockCell); + parentProcess.amts[PatchProcessInflammationCD4.IL2Rbga] = 100; + when(mockCell.getVolume()).thenReturn(0.0); + + inflammation.update(parentProcess); + + assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2Rbga]); + assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2_IL2Rbg]); + assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2_IL2Rbga]); + + assertEquals(100, parentProcess.amts[PatchProcessInflammationCD4.IL2Rbga]); + } } From e64eeffc6e415c3e7233c31319c4da47ab4a4992 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 31 Dec 2024 00:47:20 +0000 Subject: [PATCH 053/185] adding tests for inflammation, treat, kill --- test/arcade/patch/agent/action/PatchActionKillTest.java | 4 ++++ test/arcade/patch/agent/action/PatchActionResetTest.java | 4 ++++ .../patch/agent/process/PatchProcessInflammationTest.java | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 test/arcade/patch/agent/action/PatchActionKillTest.java create mode 100644 test/arcade/patch/agent/action/PatchActionResetTest.java create mode 100644 test/arcade/patch/agent/process/PatchProcessInflammationTest.java diff --git a/test/arcade/patch/agent/action/PatchActionKillTest.java b/test/arcade/patch/agent/action/PatchActionKillTest.java new file mode 100644 index 000000000..ab7398f65 --- /dev/null +++ b/test/arcade/patch/agent/action/PatchActionKillTest.java @@ -0,0 +1,4 @@ +package arcade.patch.agent.action; + +public class PatchActionKillTest { +} diff --git a/test/arcade/patch/agent/action/PatchActionResetTest.java b/test/arcade/patch/agent/action/PatchActionResetTest.java new file mode 100644 index 000000000..90d608bfb --- /dev/null +++ b/test/arcade/patch/agent/action/PatchActionResetTest.java @@ -0,0 +1,4 @@ +package arcade.patch.agent.action; + +public class PatchActionResetTest { +} diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java new file mode 100644 index 000000000..0ccf6517d --- /dev/null +++ b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java @@ -0,0 +1,4 @@ +package arcade.patch.agent.process; + +public class PatchProcessInflammationTest { +} From 4cb5faa337a03f6870913d3f5edf51a00851cd42 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 31 Dec 2024 00:48:17 +0000 Subject: [PATCH 054/185] updating inflammation documentation, adding unit tests for inflammation class --- .../process/PatchProcessInflammation.java | 1 - .../process/PatchProcessInflammationTest.java | 65 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index 443ba0cae..e98c7b3d9 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -278,7 +278,6 @@ public void step(MersenneTwisterFast random, Simulation sim) { double radShell = radCell + SHELL_THICKNESS; double volShell = volume * (((radShell * radShell * radShell) / (radCell * radCell * radCell)) - 1.0); - // this f might be the actual fraction instead of split f = volShell / loc.getVolume(); updateExternal(sim); diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java index 0ccf6517d..8da083b57 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java @@ -1,4 +1,69 @@ package arcade.patch.agent.process; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import ec.util.MersenneTwisterFast; +import arcade.core.sim.Simulation; +import arcade.core.util.Parameters; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.patch.env.lattice.PatchLattice; +import arcade.patch.env.location.PatchLocation; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.*; + public class PatchProcessInflammationTest { + + private PatchProcessInflammation inflammation; + private PatchCellCART mockCell; + private Parameters mockParameters; + private Simulation mockSimulation; + private MersenneTwisterFast mockRandom; + + @BeforeEach + public void setUp() { + mockCell = Mockito.mock(PatchCellCART.class); + mockParameters = Mockito.mock(Parameters.class); + mockSimulation = Mockito.mock(Simulation.class); + mockRandom = Mockito.mock(MersenneTwisterFast.class); + PatchLocation mockLocation = mock(PatchLocation.class); + PatchLattice mockLattice = mock(PatchLattice.class); + + Mockito.when(mockCell.getParameters()).thenReturn(mockParameters); + Mockito.when(mockCell.getLocation()).thenReturn(mockLocation); + Mockito.when(mockCell.getVolume()).thenReturn(150.0); + Mockito.when(mockLocation.getVolume()).thenReturn(1000.0); + Mockito.when(mockParameters.getDouble(anyString())).thenReturn(1.0); + Mockito.when(mockParameters.getInt(anyString())).thenReturn(1); + Mockito.when(mockSimulation.getLattice(anyString())).thenReturn(mockLattice); + doNothing().when(mockLattice).setValue(any(PatchLocation.class), anyDouble()); + + inflammation = new PatchProcessInflammationCD8(mockCell); + } + + @Test + public void testConstructor() { + assertNotNull(inflammation); + assertEquals(0, inflammation.getInternal("IL-2")); + assertEquals(1.0, inflammation.getInternal("IL2R_total")); + } + + @Test + public void testStep() { + inflammation.step(mockRandom, mockSimulation); + assertTrue(inflammation.getInternal("IL-2") >= 0); + } + + @Test + public void testGetInternal() { + assertEquals(0, inflammation.getInternal("IL-2")); + } + + @Test + public void testSetInternal() { + inflammation.setInternal("IL-2", 10.0); + assertEquals(10.0, inflammation.getInternal("IL-2")); + } } From 8d6428f4299d0cf79a750ba6dadc8a7c56177d16 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 31 Dec 2024 00:48:58 +0000 Subject: [PATCH 055/185] updating documentation for reset action, adding unit tests for reset action: --- .../patch/agent/action/PatchActionReset.java | 18 +-- .../agent/action/PatchActionResetTest.java | 105 ++++++++++++++++++ 2 files changed, 111 insertions(+), 12 deletions(-) diff --git a/src/arcade/patch/agent/action/PatchActionReset.java b/src/arcade/patch/agent/action/PatchActionReset.java index 963f39832..9e8bc8a73 100644 --- a/src/arcade/patch/agent/action/PatchActionReset.java +++ b/src/arcade/patch/agent/action/PatchActionReset.java @@ -14,21 +14,17 @@ import arcade.patch.util.PatchEnums.State; /** - * Implementation of {@link Action} for killing tissue agents. + * Implementation of {@link Action} for resetting T cell agents. * - *

    {@code PatchActionKill} is stepped once after a CD8 CAR T-cell binds to a target tissue cell. - * The {@code PatchActionKill} determines if cell has enough granzyme to kill. If so, it kills cell - * and calls the reset to neutral helper to return to neutral state. If not, it waits until it has - * enough granzyme to kill cell. + *

    {@code PatchActionReset} is stepped once after a CD8 CAR T-cell binds to a target tissue cell, + * or after a CD4 CAR T-cell gets stimulated. The {@code PatchReset} unbinds to any target cell that + * the T cell is bound to, and sets the cell state back to quiescent. */ public class PatchActionReset implements Action { /** CAR T-cell inflammation module */ PatchProcessInflammation inflammation; - /** Amount of granzyme inside CAR T-cell */ - double granzyme; - /** CAR T-cell that the module is linked to */ PatchCellCART c; @@ -36,11 +32,9 @@ public class PatchActionReset implements Action { private final int timeDelay; /** - * Creates a {@code PatchActionKill} for the given {@link - * arcade.patch.agent.cell.PatchCellCART}. + * Creates a {@code PatchActionReset} for the given {@link PatchCellCART}. * - * @param c the {@link arcade.patch.agent.cell.PatchCellCART} the helper is associated with - * @param target the {@link arcade.patch.agent.cell.PatchCellTissue} the CAR T-cell is bound to + * @param c the {@link PatchCellCART} the helper is associated with */ public PatchActionReset( PatchCellCART c, MersenneTwisterFast random, Series series, Parameters parameters) { diff --git a/test/arcade/patch/agent/action/PatchActionResetTest.java b/test/arcade/patch/agent/action/PatchActionResetTest.java index 90d608bfb..cf4cf966e 100644 --- a/test/arcade/patch/agent/action/PatchActionResetTest.java +++ b/test/arcade/patch/agent/action/PatchActionResetTest.java @@ -1,4 +1,109 @@ package arcade.patch.agent.action; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import sim.engine.Schedule; +import sim.engine.SimState; +import ec.util.MersenneTwisterFast; +import arcade.core.sim.Series; +import arcade.core.util.Parameters; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.patch.agent.cell.PatchCellCARTCD4; +import arcade.patch.agent.cell.PatchCellContainer; +import arcade.patch.env.location.PatchLocation; +import arcade.patch.util.PatchEnums; +import arcade.patch.util.PatchEnums.AntigenFlag; +import arcade.patch.util.PatchEnums.State; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static arcade.core.ARCADETestUtilities.randomDoubleBetween; +import static arcade.core.ARCADETestUtilities.randomIntBetween; + public class PatchActionResetTest { + + private PatchCellCART mockCell; + private PatchActionReset actionReset; + + @BeforeEach + public void setUp() { + MersenneTwisterFast mockRandom = mock(MersenneTwisterFast.class); + Series mockSeries = mock(Series.class); + Parameters mockParameters = mock(Parameters.class); + PatchLocation mockLocation = mock(PatchLocation.class); + + when(mockParameters.getInt("BOUND_TIME")).thenReturn(10); + when(mockParameters.getInt("BOUND_RANGE")).thenReturn(5); + when(mockRandom.nextInt()).thenReturn(1); + + int id = 1; + int parentId = 1; + int pop = 4; + int age = randomIntBetween(1, 100800); + int divisions = 10; + double volume = randomDoubleBetween(100, 200); + double height = randomDoubleBetween(4, 10); + double criticalVolume = randomDoubleBetween(100, 200); + double criticalHeight = randomDoubleBetween(4, 10); + State state = State.UNDEFINED; + ; + + PatchCellContainer container = + new PatchCellContainer( + id, + parentId, + pop, + age, + divisions, + state, + volume, + height, + criticalVolume, + criticalHeight); + + mockCell = spy(new PatchCellCARTCD4(container, mockLocation, mockParameters)); + + actionReset = new PatchActionReset(mockCell, mockRandom, mockSeries, mockParameters); + } + + @Test + public void testSchedule() { + Schedule mockSchedule = mock(Schedule.class); + actionReset.schedule(mockSchedule); + verify(mockSchedule) + .scheduleOnce( + anyDouble(), eq(PatchEnums.Ordering.ACTIONS.ordinal()), eq(actionReset)); + } + + @Test + public void testStep_CytotoxicState() { + when(mockCell.isStopped()).thenReturn(false); + mockCell.binding = AntigenFlag.BOUND_ANTIGEN; + when(mockCell.getState()).thenReturn(State.CYTOTOXIC); + + actionReset.step(mock(SimState.class)); + + verify(mockCell).setState(State.QUIESCENT); + assertEquals(AntigenFlag.UNBOUND, mockCell.getAntigenFlag()); + } + + @Test + public void testStep_StimulatoryState() { + when(mockCell.isStopped()).thenReturn(false); + mockCell.binding = AntigenFlag.BOUND_ANTIGEN; + when(mockCell.getState()).thenReturn(State.STIMULATORY); + + actionReset.step(mock(SimState.class)); + + verify(mockCell).setState(State.QUIESCENT); + assertEquals(AntigenFlag.UNBOUND, mockCell.getAntigenFlag()); + } + + @Test + public void testStep_StoppedCell() { + when(mockCell.isStopped()).thenReturn(true); + mockCell.binding = AntigenFlag.BOUND_ANTIGEN; + actionReset.step(mock(SimState.class)); + verify(mockCell, never()).setState(any(State.class)); + assertEquals(AntigenFlag.BOUND_ANTIGEN, mockCell.getAntigenFlag()); + } } From 08527d8754bf26bf9a3b62d2c98a4e7322a05e89 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 31 Dec 2024 00:49:36 +0000 Subject: [PATCH 056/185] updating documentation for kill action, adding unit tests for kill action: --- .../patch/agent/action/PatchActionKill.java | 7 +- .../agent/action/PatchActionKillTest.java | 74 +++++++++++++++++++ 2 files changed, 77 insertions(+), 4 deletions(-) diff --git a/src/arcade/patch/agent/action/PatchActionKill.java b/src/arcade/patch/agent/action/PatchActionKill.java index 0a556880e..432403b95 100644 --- a/src/arcade/patch/agent/action/PatchActionKill.java +++ b/src/arcade/patch/agent/action/PatchActionKill.java @@ -41,11 +41,10 @@ public class PatchActionKill implements Action { private final int timeDelay; /** - * Creates a {@code PatchActionKill} for the given {@link - * arcade.patch.agent.cell.PatchCellCART}. + * Creates a {@code PatchActionKill} for the given {@link PatchCellCART}. * - * @param c the {@link arcade.patch.agent.cell.PatchCellCART} the helper is associated with - * @param target the {@link arcade.patch.agent.cell.PatchCellTissue} the CAR T-cell is bound to + * @param c the {@link PatchCellCART} the helper is associated with + * @param target the {@link PatchCellTissue} the CAR T-cell is bound to */ public PatchActionKill( PatchCellCART c, diff --git a/test/arcade/patch/agent/action/PatchActionKillTest.java b/test/arcade/patch/agent/action/PatchActionKillTest.java index ab7398f65..6f1e423f2 100644 --- a/test/arcade/patch/agent/action/PatchActionKillTest.java +++ b/test/arcade/patch/agent/action/PatchActionKillTest.java @@ -1,4 +1,78 @@ package arcade.patch.agent.action; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import sim.engine.Schedule; +import ec.util.MersenneTwisterFast; +import arcade.core.sim.Series; +import arcade.core.util.Parameters; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.patch.agent.cell.PatchCellTissue; +import arcade.patch.agent.module.PatchModuleApoptosis; +import arcade.patch.agent.process.PatchProcessInflammation; +import arcade.patch.sim.PatchSimulation; +import arcade.patch.util.PatchEnums; +import arcade.patch.util.PatchEnums.AntigenFlag; +import arcade.patch.util.PatchEnums.State; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + public class PatchActionKillTest { + + private PatchCellCART mockCell; + private PatchCellTissue mockTarget; + private PatchProcessInflammation mockInflammation; + private PatchActionKill action; + private Schedule schedule; + private PatchSimulation sim; + + @BeforeEach + public void setUp() { + mockCell = mock(PatchCellCART.class); + mockTarget = mock(PatchCellTissue.class); + mockInflammation = mock(PatchProcessInflammation.class); + MersenneTwisterFast random = new MersenneTwisterFast(); + Series series = mock(Series.class); + Parameters parameters = mock(Parameters.class); + schedule = mock(Schedule.class); + sim = mock(PatchSimulation.class); + + when(mockCell.getProcess(any())).thenReturn(mockInflammation); + when(mockInflammation.getInternal("granzyme")).thenReturn(1.0); + + action = new PatchActionKill(mockCell, mockTarget, random, series, parameters); + } + + @Test + public void testSchedule() { + action.schedule(schedule); + verify(schedule) + .scheduleOnce(anyDouble(), eq(PatchEnums.Ordering.ACTIONS.ordinal()), eq(action)); + } + + @Test + public void testStep_CARCellStopped() { + when(mockCell.isStopped()).thenReturn(true); + action.step(sim); + verify(mockTarget, never()).setState(any()); + } + + @Test + public void testStep_TargetCellStopped() { + when(mockTarget.isStopped()).thenReturn(true); + action.step(sim); + verify(mockTarget, never()).setState(any()); + assertEquals(AntigenFlag.BOUND_CELL_RECEPTOR, mockCell.binding); + } + + @Test + public void testStep_KillTargetCell() { + when(mockCell.isStopped()).thenReturn(false); + when(mockTarget.isStopped()).thenReturn(false); + PatchModuleApoptosis mockProcess = mock(PatchModuleApoptosis.class); + when(mockTarget.getModule()).thenReturn(mockProcess); + action.step(sim); + verify(mockTarget).setState(State.APOPTOTIC); + verify(mockInflammation).setInternal("granzyme", 0.0); + } } From 68e1e91dcd421084a3db735a3a44dc176566d76d Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 31 Dec 2024 00:50:14 +0000 Subject: [PATCH 057/185] updating documentation, swapping out comparisons for object safe equality methods --- .../patch/agent/action/PatchActionTreat.java | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/arcade/patch/agent/action/PatchActionTreat.java b/src/arcade/patch/agent/action/PatchActionTreat.java index 918f967b5..b0898b030 100644 --- a/src/arcade/patch/agent/action/PatchActionTreat.java +++ b/src/arcade/patch/agent/action/PatchActionTreat.java @@ -1,6 +1,7 @@ package arcade.patch.agent.action; import java.util.ArrayList; +import java.util.Objects; import sim.engine.Schedule; import sim.engine.SimState; import sim.util.Bag; @@ -48,10 +49,7 @@ public class PatchActionTreat implements Action { /** Total number of CAR T-cells to treat with */ private final int dose; - /** List of populations being treated with */ - // private final ArrayList treatPops; - - /** List of freaction of each population to treat with. CD4 to CD8 ratio */ + /** List of fraction of each population to treat with. CD4 to CD8 ratio */ private final double treatFrac; /** Maximum damage value at which T-cells can spawn next to in source or pattern source */ @@ -91,10 +89,10 @@ public PatchActionTreat(Series series, MiniBox parameters) { ((PatchSeries) series).patch.get("GEOMETRY").equalsIgnoreCase("HEX") ? "Hex" : "Rect"; - if (coord == "Hex") { + if (coord.equals("Hex")) { latPositions = 9; } - if (coord == "Rect") { + if (coord.equals("Rect")) { latPositions = 16; } @@ -115,7 +113,7 @@ public void register(Simulation sim, String population) { /** * Steps the helper to insert cells of the treatment population(s). * - * @param state the MASON simulation state + * @param simstate the MASON simulation state */ public void step(SimState simstate) { @@ -148,7 +146,7 @@ public void step(SimState simstate) { double[][][] damage; boolean[][][] sitesLat; - if (type == "source") { + if (type.equals("source")) { damage = ((PatchComponentSitesSource) comp).getDamage(); sitesLat = ((PatchComponentSitesSource) comp).getSources(); } else { @@ -182,7 +180,7 @@ public void step(SimState simstate) { for (Object edgeObj : allEdges) { SiteEdge edge = (SiteEdge) edgeObj; Bag allEdgeLocs = new Bag(); - if (coord == "Hex") { + if (Objects.equals(coord, "Hex")) { allEdgeLocs.add( ((PatchComponentSitesGraphTri) graphSites) .getSpan(edge.getFrom(), edge.getTo())); @@ -281,7 +279,7 @@ private void insert(ArrayList coordinates, SimState simstate) { PatchLocation loc = ((PatchLocation) coordinates.remove(0)); Coordinate coord = loc.getCoordinate(); - // find available locaiton space + // find available location space while (!coordinates.isEmpty() && !checkLocationSpace(sim, loc, grid)) { loc = (PatchLocation) coordinates.remove(0); } @@ -326,19 +324,12 @@ else if (n >= locMax) { for (Object cellObj : bag) { PatchCell cell = (PatchCell) cellObj; - // MiniBox cellParams = cell.getParameters(); - // String className = cellParams.get("CLASS"); - // if(className.equals("cart_cd4") || className.equals("cart_cd8")){ if (cell instanceof PatchCellCART) { - // totalVol = PatchCell.calculateTotalVolume(bag) + - // cell.getParameters().getDouble("T_CELL_VOL_AVG"); totalVol = PatchCell.calculateTotalVolume(bag) + parameters.getDouble("T_CELL_VOL_AVG"); currentHeight = totalVol / locArea; } - // if (className.equals("tissue") || className.equals("cancer") || - // className.equals("cancer_stem")) { if (cell instanceof PatchCellTissue) { if (currentHeight > cell.getCriticalHeight()) { available = false; From 4b090e3a0c7d21da2199397f060b35f37b39687c Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 31 Dec 2024 22:46:49 +0000 Subject: [PATCH 058/185] adding in cell age death to T cells --- src/arcade/patch/agent/cell/PatchCell.java | 13 ++++--- .../patch/agent/cell/PatchCellCARTCD4.java | 6 ++- .../patch/agent/cell/PatchCellCARTCD8.java | 6 ++- .../patch/agent/cell/PatchCellTissue.java | 37 ++++++++++--------- .../agent/action/PatchActionTreatTest.java | 4 ++ 5 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 test/arcade/patch/agent/action/PatchActionTreatTest.java diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index b727cc9ce..272071247 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -3,7 +3,6 @@ import java.util.HashMap; import java.util.Map; import sim.engine.Schedule; -import sim.engine.SimState; import sim.engine.Stoppable; import sim.util.Bag; import ec.util.MersenneTwisterFast; @@ -193,11 +192,13 @@ public PatchCell( // Add cell processes. processes = new HashMap<>(); MiniBox processBox = parameters.filter("(PROCESS)"); - for (String processKey : processBox.getKeys()) { - ProcessDomain domain = Domain.valueOf(processKey); - String version = processBox.get(processKey); - Process process = makeProcess(domain, version); - processes.put(domain, process); + if (processBox != null) { + for (String processKey : processBox.getKeys()) { + ProcessDomain domain = Domain.valueOf(processKey); + String version = processBox.get(processKey); + Process process = makeProcess(domain, version); + processes.put(domain, process); + } } } diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 6692e74dd..3dbce7b34 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -63,7 +63,11 @@ public void step(SimState simstate) { // Increase age of cell. super.age++; - // TODO: check for death due to age + if (state != State.APOPTOTIC && age > apoptosisAge) { + setState(State.APOPTOTIC); + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; + } // Increase time since last active ticker super.lastActiveTicker++; diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index 01bc42f1a..8a293722f 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -63,7 +63,11 @@ public void step(SimState simstate) { // Increase age of cell. super.age++; - // TODO: check for death due to age + if (state != State.APOPTOTIC && age > apoptosisAge) { + setState(State.APOPTOTIC); + super.setAntigenFlag(AntigenFlag.UNBOUND); + this.activated = false; + } // Increase time since last active ticker super.lastActiveTicker++; diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index 9bd26e2be..b7dc98b98 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -70,50 +70,51 @@ public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFas @Override public void step(SimState simstate) { Simulation sim = (Simulation) simstate; - // Increase age of cell. - super.age++; + age++; - // TODO: check for death due to age + if (state != State.APOPTOTIC && age > apoptosisAge) { + setState(State.APOPTOTIC); + } // Step metabolism process. - super.processes.get(Domain.METABOLISM).step(simstate.random, sim); + processes.get(Domain.METABOLISM).step(simstate.random, sim); // Check energy status. If cell has less energy than threshold, it will // necrose. If overall energy is negative, then cell enters quiescence. if (state != State.APOPTOTIC && energy < 0) { - if (super.energy < super.energyThreshold) { + if (energy < energyThreshold) { if (simstate.random.nextDouble() > necroticFraction) { - super.setState(State.APOPTOTIC); + setState(State.APOPTOTIC); } else { - super.setState(State.NECROTIC); + setState(State.NECROTIC); } } else if (state != State.QUIESCENT && state != State.SENESCENT) { - super.setState(State.QUIESCENT); + setState(State.QUIESCENT); } } // Step signaling network process. - super.processes.get(Domain.SIGNALING).step(simstate.random, sim); + processes.get(Domain.SIGNALING).step(simstate.random, sim); // Change state from undefined. - if (super.state == State.UNDEFINED) { - if (super.flag == Flag.MIGRATORY) { - super.setState(State.MIGRATORY); - } else if (super.divisions == 0) { + if (state == State.UNDEFINED) { + if (flag == Flag.MIGRATORY) { + setState(State.MIGRATORY); + } else if (divisions == 0) { if (simstate.random.nextDouble() > senescentFraction) { - super.setState(State.APOPTOTIC); + setState(State.APOPTOTIC); } else { - super.setState(State.SENESCENT); + setState(State.SENESCENT); } } else { - super.setState(State.PROLIFERATIVE); + setState(State.PROLIFERATIVE); } } // Step the module for the cell state. - if (super.module != null) { - super.module.step(simstate.random, sim); + if (module != null) { + module.step(simstate.random, sim); } } } diff --git a/test/arcade/patch/agent/action/PatchActionTreatTest.java b/test/arcade/patch/agent/action/PatchActionTreatTest.java new file mode 100644 index 000000000..f84057062 --- /dev/null +++ b/test/arcade/patch/agent/action/PatchActionTreatTest.java @@ -0,0 +1,4 @@ +package arcade.patch.agent.action; + +public class PatchActionTreatTest { +} From 93d330347fd2d39af9da76a556dc4001fe1921e5 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 31 Dec 2024 22:47:53 +0000 Subject: [PATCH 059/185] adding new parameters: cell death age and max confluency --- src/arcade/patch/parameter.patch.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index 87f29dee6..efd270a98 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -22,7 +22,7 @@ - + From 0413b6cfe5e6be264000b5a2cca4bf769e0d2953 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 31 Dec 2024 22:48:37 +0000 Subject: [PATCH 060/185] changing T cell tests to accomodate for cell death due to age --- .../agent/cell/PatchCellCARTCD4Test.java | 27 ++++++++++--------- .../agent/cell/PatchCellCARTCD8Test.java | 27 ++++++++++--------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index e38c6ac69..4fd82fcef 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -1,5 +1,6 @@ package arcade.patch.agent.cell; +import java.lang.reflect.Field; import java.util.ArrayList; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -32,16 +33,17 @@ public class PatchCellCARTCD4Test { private Parameters parameters; private PatchLocation location; private PatchCellContainer container; + private PatchCellCARTCD4 cell; @BeforeEach - public void setUp() { + public void setUp() throws NoSuchFieldException, IllegalAccessException { parameters = mock(Parameters.class); location = mock(PatchLocation.class); int id = 1; int parentId = 1; int pop = 1; - int age = randomIntBetween(1, 100800); + int age = randomIntBetween(1, 120950); int divisions = 10; double volume = randomDoubleBetween(100, 200); double height = randomDoubleBetween(4, 10); @@ -87,7 +89,18 @@ public void setUp() { when(parameters.getInt("MAX_ANTIGEN_BINDING")).thenReturn(10); when(parameters.getInt("CARS")).thenReturn(50000); + when(parameters.getInt("APOPTOSIS_AGE")).thenReturn(120960); + when(parameters.getInt("MAX_DENSITY")).thenReturn(54); + patchCellCART = new PatchCellCARTCD4(container, location, parameters); + cell = spy(new PatchCellCARTCD4(container, location, parameters)); + Field apoptosisAge = PatchCell.class.getDeclaredField("apoptosisAge"); + apoptosisAge.setAccessible(true); + apoptosisAge.set(cell, 120958); + + Field maxDensity = PatchCell.class.getDeclaredField("maxDensity"); + maxDensity.setAccessible(true); + maxDensity.set(cell, 54); } @Test @@ -208,7 +221,6 @@ public void testBindTarget() { @Test public void testStepIncreasesAge() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -238,7 +250,6 @@ public void testStepIncreasesAge() { @Test public void testStepSetsStateToApoptoticWhenEnergyIsLow() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -272,7 +283,6 @@ public void testStepSetsStateToApoptoticWhenEnergyIsLow() { @Test public void testStepSetsStateToStarvedWhenEnergyIsNegativeAndMoreThanThreshold() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -305,7 +315,6 @@ public void testStepSetsStateToStarvedWhenEnergyIsNegativeAndMoreThanThreshold() @Test public void testStepSetsStateToApoptoticWhenEnergyIsNegativeAndLessThanThreshold() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -337,7 +346,6 @@ public void testStepSetsStateToApoptoticWhenEnergyIsNegativeAndLessThanThreshold @Test public void testStepSetsStateToSenescentWhenDivisionsAreZero() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -371,7 +379,6 @@ public void testStepSetsStateToSenescentWhenDivisionsAreZero() { @Test public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -405,7 +412,6 @@ public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { @Test public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -444,7 +450,6 @@ public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { @Test public void testStepSetsStateToProliferativeWhenActivated() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -476,7 +481,6 @@ public void testStepSetsStateToProliferativeWhenActivated() { @Test public void testStepSetsStateToMigratoryWhenNotActivated() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -508,7 +512,6 @@ public void testStepSetsStateToMigratoryWhenNotActivated() { @Test public void testStepSetsStatetoExhaustedWhenOverstimulated() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD4 cell = spy(new PatchCellCARTCD4(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index 21281a1b8..f15f8b07a 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -1,5 +1,6 @@ package arcade.patch.agent.cell; +import java.lang.reflect.Field; import java.util.ArrayList; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -29,19 +30,20 @@ public class PatchCellCARTCD8Test { private PatchCellCARTCD8 patchCellCART; + private PatchCellCARTCD8 cell; private Parameters parameters; private PatchLocation location; private PatchCellContainer container; @BeforeEach - public void setUp() { + public void setUp() throws NoSuchFieldException, IllegalAccessException { parameters = mock(Parameters.class); location = mock(PatchLocation.class); int id = 1; int parentId = 1; int pop = 1; - int age = randomIntBetween(1, 100800); + int age = randomIntBetween(1, 120950); int divisions = 10; double volume = randomDoubleBetween(100, 200); double height = randomDoubleBetween(4, 10); @@ -86,8 +88,19 @@ public void setUp() { when(parameters.getDouble("CONTACT_FRAC")).thenReturn(7.8E-6); when(parameters.getInt("MAX_ANTIGEN_BINDING")).thenReturn(10); when(parameters.getInt("CARS")).thenReturn(50000); + when(parameters.getInt("APOPTOSIS_AGE")).thenReturn(120960); + when(parameters.getInt("MAX_DENSITY")).thenReturn(54); patchCellCART = new PatchCellCARTCD8(container, location, parameters); + + cell = spy(new PatchCellCARTCD8(container, location, parameters)); + Field apoptosisAge = PatchCell.class.getDeclaredField("apoptosisAge"); + apoptosisAge.setAccessible(true); + apoptosisAge.set(cell, 120958); + + Field maxDensity = PatchCell.class.getDeclaredField("maxDensity"); + maxDensity.setAccessible(true); + maxDensity.set(cell, 54); } @Test @@ -208,7 +221,6 @@ public void testBindTarget() { @Test public void testStepIncreasesAge() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -238,7 +250,6 @@ public void testStepIncreasesAge() { @Test public void testStepSetsStateToApoptoticWhenEnergyIsLow() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -272,7 +283,6 @@ public void testStepSetsStateToApoptoticWhenEnergyIsLow() { @Test public void testStepSetsStateToStarvedWhenEnergyIsNegativeAndMoreThanThreshold() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -305,7 +315,6 @@ public void testStepSetsStateToStarvedWhenEnergyIsNegativeAndMoreThanThreshold() @Test public void testStepSetsStateToApoptoticWhenEnergyIsNegativeAndLessThanThreshold() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -337,7 +346,6 @@ public void testStepSetsStateToApoptoticWhenEnergyIsNegativeAndLessThanThreshold @Test public void testStepSetsStateToSenescentWhenDivisionsAreZero() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -371,7 +379,6 @@ public void testStepSetsStateToSenescentWhenDivisionsAreZero() { @Test public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -405,7 +412,6 @@ public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { @Test public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -442,7 +448,6 @@ public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { @Test public void testStepSetsStateToProliferativeWhenActivated() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -474,7 +479,6 @@ public void testStepSetsStateToProliferativeWhenActivated() { @Test public void testStepSetsStateToMigratoryWhenNotActivated() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -506,7 +510,6 @@ public void testStepSetsStateToMigratoryWhenNotActivated() { @Test public void testStepSetsStatetoExhaustedWhenOverstimulated() { PatchSimulation sim = mock(PatchSimulation.class); - PatchCellCARTCD8 cell = spy(new PatchCellCARTCD8(container, location, parameters)); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); From 7a0f2dfccc9674c19b0ef076a754faf395065588 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 31 Dec 2024 22:49:18 +0000 Subject: [PATCH 061/185] updating treat documentation, adding unit tests for treat class --- .../patch/agent/action/PatchActionTreat.java | 37 +++- .../agent/action/PatchActionTreatTest.java | 203 ++++++++++++++++++ 2 files changed, 234 insertions(+), 6 deletions(-) diff --git a/src/arcade/patch/agent/action/PatchActionTreat.java b/src/arcade/patch/agent/action/PatchActionTreat.java index b0898b030..7db30f33b 100644 --- a/src/arcade/patch/agent/action/PatchActionTreat.java +++ b/src/arcade/patch/agent/action/PatchActionTreat.java @@ -56,13 +56,13 @@ public class PatchActionTreat implements Action { private double max_damage; /** Minimum radius value at which T- cells can spawn next to in graph source */ - private double min_damage_radius; + private final double min_damage_radius; /** Number of agent positions per lattice site */ private int latPositions; /** Coordinate system used for simulation */ - private String coord; + private final String coord; /** List of populations. */ private final ArrayList populations; @@ -70,6 +70,12 @@ public class PatchActionTreat implements Action { /** parameters */ MiniBox parameters; + /** Maximum confluency of cells in any location */ + final int maxConfluency; + + /** location of available places to insert T cells. For testing purposes only */ + private ArrayList siteLocations; + /** * Creates an {@code Action} to add agents after a delay. * @@ -83,6 +89,7 @@ public PatchActionTreat(Series series, MiniBox parameters) { this.treatFrac = parameters.getDouble("RATIO"); this.max_damage = parameters.getDouble("MAX_DAMAGE_SEED"); this.min_damage_radius = parameters.getDouble("MIN_RADIUS_SEED"); + this.maxConfluency = parameters.getInt("MAX_DENSITY"); this.parameters = parameters; this.coord = @@ -211,7 +218,7 @@ public void step(SimState simstate) { siteLocs.addAll(siteLocs2); siteLocs.addAll(siteLocs1); siteLocs.addAll(siteLocs0); - // insert(siteLocs, sim, grid); + siteLocations = (ArrayList) siteLocs.clone(); insert(siteLocs, simstate); } @@ -280,7 +287,7 @@ private void insert(ArrayList coordinates, SimState simstate) { Coordinate coord = loc.getCoordinate(); // find available location space - while (!coordinates.isEmpty() && !checkLocationSpace(sim, loc, grid)) { + while (!coordinates.isEmpty() && !checkLocationSpace(loc, grid)) { loc = (PatchLocation) coordinates.remove(0); } @@ -298,9 +305,9 @@ private void insert(ArrayList coordinates, SimState simstate) { } } - protected boolean checkLocationSpace(Simulation sim, Location loc, PatchGrid grid) { + protected boolean checkLocationSpace(Location loc, PatchGrid grid) { boolean available; - int locMax = ((PatchLocation) loc).getMaximum(); + int locMax = this.maxConfluency; double locVolume = ((PatchLocation) loc).getVolume(); double locArea = ((PatchLocation) loc).getArea(); @@ -340,4 +347,22 @@ else if (n >= locMax) { return available; } + + /** + * Returns registered populations for the action. Exists for testing purposes only + * + * @return registered populations for the action + */ + public ArrayList getPopulations() { + return populations; + } + + /** + * Returns locations of sites available for insertion. Exists for testing purposes only + * + * @return Returns locations of sites available for insertion + */ + public ArrayList getSiteLocs() { + return siteLocations; + } } diff --git a/test/arcade/patch/agent/action/PatchActionTreatTest.java b/test/arcade/patch/agent/action/PatchActionTreatTest.java index f84057062..0dc3fb18e 100644 --- a/test/arcade/patch/agent/action/PatchActionTreatTest.java +++ b/test/arcade/patch/agent/action/PatchActionTreatTest.java @@ -1,4 +1,207 @@ package arcade.patch.agent.action; +import java.lang.reflect.Field; +import java.util.ArrayList; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import sim.engine.Schedule; +import sim.util.Bag; +import ec.util.MersenneTwisterFast; +import arcade.core.env.location.LocationContainer; +import arcade.core.util.MiniBox; +import arcade.patch.agent.cell.PatchCell; +import arcade.patch.agent.cell.PatchCellContainer; +import arcade.patch.agent.cell.PatchCellFactory; +import arcade.patch.env.component.PatchComponentSitesSource; +import arcade.patch.env.grid.PatchGrid; +import arcade.patch.env.location.*; +import arcade.patch.sim.PatchSeries; +import arcade.patch.sim.PatchSimulation; +import arcade.patch.util.PatchEnums; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + public class PatchActionTreatTest { + + private PatchActionTreat action; + private PatchSimulation sim; + private PatchGrid gridMock; + private PatchCell cellMock; + MiniBox parameters; + PatchSeries series; + + @BeforeEach + public void setUp() throws NoSuchFieldException, IllegalAccessException { + parameters = mock(MiniBox.class); + when(parameters.getInt("TIME_DELAY")).thenReturn(10); + when(parameters.getInt("DOSE")).thenReturn(10); + when(parameters.getDouble("RATIO")).thenReturn(0.5); + when(parameters.getDouble("MAX_DAMAGE_SEED")).thenReturn(0.1); + when(parameters.getDouble("MIN_RADIUS_SEED")).thenReturn(0.01); + when(parameters.getDouble("T_CELL_VOL_AVG")).thenReturn(175.0); + series = mock(PatchSeries.class); + MiniBox patchMock = mock(MiniBox.class); + series.patch = patchMock; + gridMock = mock(PatchGrid.class); + Schedule mockSchedule = mock(Schedule.class); + when(patchMock.get("GEOMETRY")).thenReturn("HEX"); + sim = mock(PatchSimulation.class); + when(sim.getSeries()).thenReturn(series); + when(sim.getGrid()).thenReturn(gridMock); + when(sim.getSchedule()).thenReturn(mockSchedule); + PatchComponentSitesSource sources = mock(PatchComponentSitesSource.class); + double[][][] damage = new double[20][20][20]; + boolean[][][] sitesLat = new boolean[20][20][20]; + damage[0][0][0] = 0.05; + sitesLat[0][0][0] = true; + when(sources.getDamage()).thenReturn(damage); + when(sources.getSources()).thenReturn(sitesLat); + when(sim.getComponent("SITES")).thenReturn(sources); + ArrayList locations = new ArrayList<>(); + PatchLocationContainer container = mock(PatchLocationContainer.class); + PatchLocation loc = mock(PatchLocation.class); + CoordinateXYZ coord = mock(CoordinateXYZ.class); + Field x = CoordinateXYZ.class.getDeclaredField("x"); + x.setAccessible(true); + x.set(coord, 0); + Field y = CoordinateXYZ.class.getDeclaredField("y"); + y.setAccessible(true); + y.set(coord, 0); + Field z = Coordinate.class.getDeclaredField("z"); + z.setAccessible(true); + z.set(coord, 0); + CoordinateUVWZ c = mock(CoordinateUVWZ.class); + z.set(c, 0); + when(loc.getSubcoordinate()).thenReturn(coord); + when(loc.getCoordinate()).thenReturn(c); + when(container.convert(any(), any())).thenReturn(loc); + locations.add(container); + when(sim.getLocations()).thenReturn(locations); + sim.random = mock(MersenneTwisterFast.class); + + PatchCellFactory factoryMock = mock(PatchCellFactory.class); + PatchCellContainer patchCellContainerMock = mock(PatchCellContainer.class); + when(factoryMock.createCellForPopulation(any(Integer.class), any(Integer.class))) + .thenReturn(patchCellContainerMock); + cellMock = mock(PatchCell.class); + when(patchCellContainerMock.convert(any(), any(), any())).thenReturn(cellMock); + + Field factory = PatchSimulation.class.getDeclaredField("cellFactory"); + factory.setAccessible(true); + factory.set(sim, factoryMock); + } + + final Bag createPatchCellsWithVolumeAndCriticalHeight(int n, double volume, double critHeight) { + Bag bag = new Bag(); + for (int i = 0; i < n; i++) { + PatchCell cell = mock(PatchCell.class); + when(cell.getVolume()).thenReturn(volume); + when(cell.getHeight()).thenReturn(critHeight); + bag.add(cell); + } + return bag; + } + + @Test + public void testSchedule() throws NoSuchFieldException, IllegalAccessException { + action = new PatchActionTreat(series, parameters); + + ArrayList populations = new ArrayList<>(); + MiniBox populationMock = mock(MiniBox.class); + when(populationMock.getInt("CODE")).thenReturn(4); + when(populationMock.get("CLASS")).thenReturn("cart_cd4"); + populations.add(populationMock); + Field pops = PatchActionTreat.class.getDeclaredField("populations"); + pops.setAccessible(true); + pops.set(action, populations); + + Schedule schedule = mock(Schedule.class); + action.schedule(schedule); + verify(schedule) + .scheduleOnce(anyDouble(), eq(PatchEnums.Ordering.ACTIONS.ordinal()), eq(action)); + } + + @Test + public void testStep() throws NoSuchFieldException, IllegalAccessException { + action = new PatchActionTreat(series, parameters); + + ArrayList populations = new ArrayList<>(); + MiniBox populationMock = mock(MiniBox.class); + when(populationMock.getInt("CODE")).thenReturn(4); + when(populationMock.get("CLASS")).thenReturn("cart_cd4"); + populations.add(populationMock); + Field pops = PatchActionTreat.class.getDeclaredField("populations"); + pops.setAccessible(true); + pops.set(action, populations); + + action.step(sim); + assertFalse(action.getSiteLocs().isEmpty()); + verify(gridMock, times(action.getSiteLocs().size() - 1)).addObject(any(), any()); + verify(cellMock, times(action.getSiteLocs().size() - 1)).schedule(any()); + } + + @Test + public void testZeroDose() throws NoSuchFieldException, IllegalAccessException { + when(parameters.getInt("DOSE")).thenReturn(0); + action = new PatchActionTreat(series, parameters); + + ArrayList populations = new ArrayList<>(); + MiniBox populationMock = mock(MiniBox.class); + when(populationMock.getInt("CODE")).thenReturn(4); + when(populationMock.get("CLASS")).thenReturn("cart_cd4"); + populations.add(populationMock); + Field pops = PatchActionTreat.class.getDeclaredField("populations"); + pops.setAccessible(true); + pops.set(action, populations); + + action.step(sim); + verify(gridMock, times(0)).addObject(any(), any()); + verify(cellMock, times(0)).schedule(any()); + } + + @Test + public void testCheckLocationSpace() throws NoSuchFieldException, IllegalAccessException { + when(parameters.getInt("MAX_DENSITY")).thenReturn(54); + action = new PatchActionTreat(series, parameters); + + ArrayList populations = new ArrayList<>(); + MiniBox populationMock = mock(MiniBox.class); + when(populationMock.getInt("CODE")).thenReturn(4); + when(populationMock.get("CLASS")).thenReturn("cart_cd4"); + populations.add(populationMock); + Field pops = PatchActionTreat.class.getDeclaredField("populations"); + pops.setAccessible(true); + pops.set(action, populations); + + PatchLocation locationMock = mock(PatchLocation.class); + when(locationMock.getArea()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30); + when(locationMock.getVolume()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30 * 8.7); + Bag testBag = createPatchCellsWithVolumeAndCriticalHeight(2, 10, 12.5); + when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(testBag); + boolean result = action.checkLocationSpace(locationMock, gridMock); + assertTrue(result); + } + + @Test + public void testMaxConfluency() throws NoSuchFieldException, IllegalAccessException { + when(parameters.getInt("MAX_DENSITY")).thenReturn(1); + action = new PatchActionTreat(series, parameters); + + ArrayList populations = new ArrayList<>(); + MiniBox populationMock = mock(MiniBox.class); + when(populationMock.getInt("CODE")).thenReturn(4); + when(populationMock.get("CLASS")).thenReturn("cart_cd4"); + populations.add(populationMock); + Field pops = PatchActionTreat.class.getDeclaredField("populations"); + pops.setAccessible(true); + pops.set(action, populations); + + PatchLocation locationMock = mock(PatchLocation.class); + when(locationMock.getArea()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30); + when(locationMock.getVolume()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30 * 8.7); + Bag testBag = createPatchCellsWithVolumeAndCriticalHeight(2, 10, 12.5); + when(gridMock.getObjectsAtLocation(locationMock)).thenReturn(testBag); + boolean result = action.checkLocationSpace(locationMock, gridMock); + assertFalse(result); + } } From 3fde90e9a6a96e13b90d55bbae5b9ba8b89a67ab Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 31 Dec 2024 23:08:28 +0000 Subject: [PATCH 062/185] had to change the subclass because of step() refactoring from PatchCell --- test/arcade/patch/agent/cell/PatchCellTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/arcade/patch/agent/cell/PatchCellTest.java b/test/arcade/patch/agent/cell/PatchCellTest.java index dfb97a5d7..2df183894 100644 --- a/test/arcade/patch/agent/cell/PatchCellTest.java +++ b/test/arcade/patch/agent/cell/PatchCellTest.java @@ -68,7 +68,7 @@ public class PatchCellTest { cellCriticalVolume, cellCriticalHeight); - static class PatchCellMock extends PatchCell { + static class PatchCellMock extends PatchCellTissue { PatchCellMock(PatchCellContainer container, Location location, Parameters parameters) { super(container, location, parameters, null); } From e741e783b8ab6e7cc02f36bb7f78a69b4ee0e68d Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 1 Jan 2025 03:07:31 +0000 Subject: [PATCH 063/185] edit confluency limit --- src/arcade/patch/agent/action/PatchActionTreat.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/arcade/patch/agent/action/PatchActionTreat.java b/src/arcade/patch/agent/action/PatchActionTreat.java index 7db30f33b..28b207a47 100644 --- a/src/arcade/patch/agent/action/PatchActionTreat.java +++ b/src/arcade/patch/agent/action/PatchActionTreat.java @@ -71,7 +71,7 @@ public class PatchActionTreat implements Action { MiniBox parameters; /** Maximum confluency of cells in any location */ - final int maxConfluency; + final int maxConfluency = 54; /** location of available places to insert T cells. For testing purposes only */ private ArrayList siteLocations; @@ -89,7 +89,6 @@ public PatchActionTreat(Series series, MiniBox parameters) { this.treatFrac = parameters.getDouble("RATIO"); this.max_damage = parameters.getDouble("MAX_DAMAGE_SEED"); this.min_damage_radius = parameters.getDouble("MIN_RADIUS_SEED"); - this.maxConfluency = parameters.getInt("MAX_DENSITY"); this.parameters = parameters; this.coord = From c1bbf598cbdd59636277b3a893d374a4e073b5d9 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 1 Jan 2025 03:34:16 +0000 Subject: [PATCH 064/185] changing test structure after editing confluency limitation in treat class --- src/arcade/patch/agent/action/PatchActionTreat.java | 3 ++- test/arcade/patch/agent/action/PatchActionTreatTest.java | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/arcade/patch/agent/action/PatchActionTreat.java b/src/arcade/patch/agent/action/PatchActionTreat.java index 28b207a47..071d1942a 100644 --- a/src/arcade/patch/agent/action/PatchActionTreat.java +++ b/src/arcade/patch/agent/action/PatchActionTreat.java @@ -71,7 +71,7 @@ public class PatchActionTreat implements Action { MiniBox parameters; /** Maximum confluency of cells in any location */ - final int maxConfluency = 54; + final int maxConfluency; /** location of available places to insert T cells. For testing purposes only */ private ArrayList siteLocations; @@ -89,6 +89,7 @@ public PatchActionTreat(Series series, MiniBox parameters) { this.treatFrac = parameters.getDouble("RATIO"); this.max_damage = parameters.getDouble("MAX_DAMAGE_SEED"); this.min_damage_radius = parameters.getDouble("MIN_RADIUS_SEED"); + this.maxConfluency = 54; this.parameters = parameters; this.coord = diff --git a/test/arcade/patch/agent/action/PatchActionTreatTest.java b/test/arcade/patch/agent/action/PatchActionTreatTest.java index 0dc3fb18e..727fb3c8d 100644 --- a/test/arcade/patch/agent/action/PatchActionTreatTest.java +++ b/test/arcade/patch/agent/action/PatchActionTreatTest.java @@ -161,9 +161,7 @@ public void testZeroDose() throws NoSuchFieldException, IllegalAccessException { @Test public void testCheckLocationSpace() throws NoSuchFieldException, IllegalAccessException { - when(parameters.getInt("MAX_DENSITY")).thenReturn(54); action = new PatchActionTreat(series, parameters); - ArrayList populations = new ArrayList<>(); MiniBox populationMock = mock(MiniBox.class); when(populationMock.getInt("CODE")).thenReturn(4); @@ -184,8 +182,10 @@ public void testCheckLocationSpace() throws NoSuchFieldException, IllegalAccessE @Test public void testMaxConfluency() throws NoSuchFieldException, IllegalAccessException { - when(parameters.getInt("MAX_DENSITY")).thenReturn(1); action = new PatchActionTreat(series, parameters); + Field density = PatchActionTreat.class.getDeclaredField("maxConfluency"); + density.setAccessible(true); + density.set(action, 1); ArrayList populations = new ArrayList<>(); MiniBox populationMock = mock(MiniBox.class); From 1466d8b5d54663cb076cd7f777c6e1ab569ac4a5 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 8 Jan 2025 20:24:27 +0000 Subject: [PATCH 065/185] making patch cell fields protected instead of public --- src/arcade/patch/agent/cell/PatchCell.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 272071247..e06049b63 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -108,19 +108,16 @@ public abstract class PatchCell implements Cell { final double criticalHeight; /** Cell state change flag. */ - Flag flag; - - /** Variation in cell agent parameters. */ - private final double heterogeneity; + protected Flag flag; /** Fraction of necrotic cells that become apoptotic. */ - final double necroticFraction; + protected final double necroticFraction; /** Fraction of senescent cells that become apoptotic. */ - final double senescentFraction; + protected final double senescentFraction; /** Maximum energy deficit before necrosis. */ - final double energyThreshold; + protected final double energyThreshold; /** Cell state module. */ protected Module module; @@ -149,7 +146,6 @@ public abstract class PatchCell implements Cell { *

  • {@code NECROTIC_FRACTION} = fraction of necrotic cells that become apoptotic *
  • {@code SENESCENT_FRACTION} = fraction of senescent cells that become apoptotic *
  • {@code ENERGY_THRESHOLD} = maximum energy deficit before necrosis - *
  • {@code HETEROGENEITY} = variation in cell agent parameters * * * @param container the cell container @@ -180,15 +176,12 @@ public PatchCell( // Set loaded parameters. necroticFraction = parameters.getDouble("NECROTIC_FRACTION"); senescentFraction = parameters.getDouble("SENESCENT_FRACTION"); - heterogeneity = parameters.getDouble("HETEROGENEITY"); energyThreshold = -parameters.getDouble("ENERGY_THRESHOLD"); apoptosisAge = parameters.getDouble("APOPTOSIS_AGE"); int densityInput = parameters.getInt("MAX_DENSITY"); maxDensity = (densityInput >= 0 ? densityInput : Integer.MAX_VALUE); - // TODO: implement heterogeneity - // Add cell processes. processes = new HashMap<>(); MiniBox processBox = parameters.filter("(PROCESS)"); From 8910e084bedae00dafc6b8fb5ae67f5715c693cd Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 8 Jan 2025 23:16:01 +0000 Subject: [PATCH 066/185] changing visibility of variables --- src/arcade/patch/agent/cell/PatchCell.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index e06049b63..817631d90 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -87,7 +87,7 @@ public abstract class PatchCell implements Cell { int age; /** Cell energy [fmol ATP]. */ - double energy; + protected double energy; /** Number of divisions. */ int divisions; From 73d95fbdfea5fa9f726c2a7349506e54cc779688 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 9 Jan 2025 03:41:23 +0000 Subject: [PATCH 067/185] revise kill action to not step apoptosis module immediately --- src/arcade/patch/agent/action/PatchActionKill.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/arcade/patch/agent/action/PatchActionKill.java b/src/arcade/patch/agent/action/PatchActionKill.java index 432403b95..faff050e0 100644 --- a/src/arcade/patch/agent/action/PatchActionKill.java +++ b/src/arcade/patch/agent/action/PatchActionKill.java @@ -91,7 +91,6 @@ public void step(SimState state) { // Kill bound target cell. PatchCellTissue tissueCell = (PatchCellTissue) target; tissueCell.setState(State.APOPTOTIC); - tissueCell.getModule().step(state.random, sim); // Use up some granzyme in the process. granzyme--; From d4b073851709226a8cb00e6bdcd3f8cfdd41a69e Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 9 Jan 2025 04:15:55 +0000 Subject: [PATCH 068/185] editing javadoc for antigen flag enum --- src/arcade/patch/util/PatchEnums.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arcade/patch/util/PatchEnums.java b/src/arcade/patch/util/PatchEnums.java index f46b85e65..6cc940453 100644 --- a/src/arcade/patch/util/PatchEnums.java +++ b/src/arcade/patch/util/PatchEnums.java @@ -16,6 +16,7 @@ *
  • {@code Domain} defining domain for a given process *
  • {@code Flag} defining state change flags *
  • {@code Category} defining operation categories + *
  • {@code AntigenFlag} defining cell antigen binding status * */ public final class PatchEnums { From 7605b783e933b33b965920af53874f0906429f5c Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 9 Jan 2025 04:37:48 +0000 Subject: [PATCH 069/185] changing order of parameters to match main branch --- src/arcade/patch/parameter.patch.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index efd270a98..218aa28b4 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -23,8 +23,6 @@ - - @@ -46,6 +44,8 @@ + + @@ -75,14 +75,13 @@ - + - From 6860f059f43d52b765363aaac5c58e3b9769cb33 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 9 Jan 2025 04:38:34 +0000 Subject: [PATCH 070/185] adding in default parameters relevant to T cell agent, inflammation module, and treat action --- src/arcade/patch/parameter.patch.xml | 60 +--------------------------- 1 file changed, 2 insertions(+), 58 deletions(-) diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index 218aa28b4..df20be271 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -19,37 +19,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + - @@ -76,32 +51,11 @@ - - - - - - - - - - - - - - - - - - - - - @@ -128,16 +82,6 @@ - - - - - - - - - - @@ -175,4 +119,4 @@ - + \ No newline at end of file From 3ca62f4a953ee58eeae613f31f635b1279903f70 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 9 Jan 2025 04:44:42 +0000 Subject: [PATCH 071/185] reverting state of project to previous commit --- src/arcade/patch/parameter.patch.xml | 60 +++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index df20be271..218aa28b4 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -19,12 +19,37 @@ + - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -51,11 +76,32 @@ + + + + + + + + + + + + + + + + + + + + + @@ -82,6 +128,16 @@ + + + + + + + + + + @@ -119,4 +175,4 @@ - \ No newline at end of file + From 7f8a8e2bc8d999ab94ed86c5552edd512a041b58 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 14 Jan 2025 19:45:10 +0000 Subject: [PATCH 072/185] pushing step() specific tests down to PatchCellTissue test class --- .../patch/agent/cell/PatchCellTest.java | 124 ---------- .../patch/agent/cell/PatchCellTissueTest.java | 226 ++++++++++++++++++ 2 files changed, 226 insertions(+), 124 deletions(-) create mode 100644 test/arcade/patch/agent/cell/PatchCellTissueTest.java diff --git a/test/arcade/patch/agent/cell/PatchCellTest.java b/test/arcade/patch/agent/cell/PatchCellTest.java index 2df183894..596852487 100644 --- a/test/arcade/patch/agent/cell/PatchCellTest.java +++ b/test/arcade/patch/agent/cell/PatchCellTest.java @@ -124,130 +124,6 @@ public void addCycle_givenCycles_appendValues() { assertEquals(3, cell.getCycles().size()); } - @Test - public void step_calledWhenAgeGreaterThanApoptosisAge_setsApoptoticState() { - PatchModule module = mock(PatchModule.class); - doReturn(0.0).when(parametersMock).getDouble(any(String.class)); - doReturn(0).when(parametersMock).getInt(any(String.class)); - doReturn(10.0).when(parametersMock).getDouble("APOPTOSIS_AGE"); - int age = 11; - ArrayList relevantStates = new ArrayList<>(); - relevantStates.add(State.QUIESCENT); - relevantStates.add(State.MIGRATORY); - relevantStates.add(State.PROLIFERATIVE); - - for (State state : relevantStates) { - PatchCellContainer container = - new PatchCellContainer( - cellID, - cellParent, - cellPop, - age, - cellDivisions, - state, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - PatchCell cell = spy(new PatchCellMock(container, locationMock, parametersMock)); - cell.processes.put(Domain.METABOLISM, metabolismMock); - cell.processes.put(Domain.SIGNALING, signalingMock); - cell.module = module; - doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - return null; - }) - .when(cell) - .setState(any(State.class)); - - cell.step(simMock); - - assertEquals(State.APOPTOTIC, cell.getState()); - } - } - - @Test - public void step_calledWhenAgeLessThanApoptosisAge_doesNotSetState() { - PatchModule module = mock(PatchModule.class); - doReturn(0.0).when(parametersMock).getDouble(any(String.class)); - doReturn(0).when(parametersMock).getInt(any(String.class)); - doReturn(10.0).when(parametersMock).getDouble("APOPTOSIS_AGE"); - int age = 9; - ArrayList relevantStates = new ArrayList<>(); - relevantStates.add(State.QUIESCENT); - relevantStates.add(State.MIGRATORY); - relevantStates.add(State.PROLIFERATIVE); - - for (State state : relevantStates) { - PatchCellContainer container = - new PatchCellContainer( - cellID, - cellParent, - cellPop, - age, - cellDivisions, - state, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - PatchCell cell = spy(new PatchCellMock(container, locationMock, parametersMock)); - cell.processes.put(Domain.METABOLISM, metabolismMock); - cell.processes.put(Domain.SIGNALING, signalingMock); - cell.module = module; - doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - return null; - }) - .when(cell) - .setState(any(State.class)); - - cell.step(simMock); - - assertEquals(state, cell.getState()); - } - } - - @Test - public void step_calledApoptoticStateAndApoptoticAge_doesNotResetState() { - PatchModule module = mock(PatchModule.class); - doReturn(0.0).when(parametersMock).getDouble(any(String.class)); - doReturn(0).when(parametersMock).getInt(any(String.class)); - doReturn(10.0).when(parametersMock).getDouble("APOPTOSIS_AGE"); - int age = 12; - State state = State.APOPTOTIC; - - PatchCellContainer container = - new PatchCellContainer( - cellID, - cellParent, - cellPop, - age, - cellDivisions, - state, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - PatchCell cell = spy(new PatchCellMock(container, locationMock, parametersMock)); - cell.processes.put(Domain.METABOLISM, metabolismMock); - cell.processes.put(Domain.SIGNALING, signalingMock); - cell.module = module; - doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - return null; - }) - .when(cell) - .setState(any(State.class)); - - cell.step(simMock); - - verify(cell, times(0)).setState(any(State.class)); - } - @Test public void checkLocation_locationEmpty_returnTrue() { doReturn(0.0).when(parametersMock).getDouble(any(String.class)); diff --git a/test/arcade/patch/agent/cell/PatchCellTissueTest.java b/test/arcade/patch/agent/cell/PatchCellTissueTest.java new file mode 100644 index 000000000..f8a5b128f --- /dev/null +++ b/test/arcade/patch/agent/cell/PatchCellTissueTest.java @@ -0,0 +1,226 @@ +package arcade.patch.agent.cell; + +import java.util.ArrayList; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import sim.util.Bag; +import ec.util.MersenneTwisterFast; +import arcade.core.agent.cell.CellState; +import arcade.core.env.location.*; +import arcade.core.util.MiniBox; +import arcade.core.util.Parameters; +import arcade.patch.agent.module.PatchModule; +import arcade.patch.agent.process.PatchProcessMetabolism; +import arcade.patch.agent.process.PatchProcessSignaling; +import arcade.patch.env.grid.PatchGrid; +import arcade.patch.env.location.PatchLocation; +import arcade.patch.sim.PatchSimulation; +import arcade.patch.util.PatchEnums.Domain; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; +import static arcade.core.ARCADETestUtilities.*; +import static arcade.patch.util.PatchEnums.State; + +public class PatchCellTissueTest { + static PatchSimulation simMock; + + static PatchLocation locationMock; + + static Parameters parametersMock; + + static PatchProcessMetabolism metabolismMock; + + static PatchProcessSignaling signalingMock; + + static PatchGrid gridMock; + + static int cellID = randomIntBetween(1, 10); + + static int cellParent = randomIntBetween(1, 10); + + static int cellPop = randomIntBetween(1, 10); + + static int cellAge = randomIntBetween(1, 1000); + + static int cellDivisions = randomIntBetween(1, 100); + + static double cellVolume = randomDoubleBetween(10, 100); + + static double cellHeight = randomDoubleBetween(10, 100); + + static double cellCriticalVolume = randomDoubleBetween(10, 100); + + static double cellCriticalHeight = randomDoubleBetween(10, 100); + + static State cellState = State.QUIESCENT; + + static PatchCellContainer baseContainer = + new PatchCellContainer( + cellID, + cellParent, + cellPop, + cellAge, + cellDivisions, + cellState, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); + + static class PatchCellMock extends PatchCellTissue { + PatchCellMock(PatchCellContainer container, Location location, Parameters parameters) { + super(container, location, parameters, null); + } + + @Override + public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFast random) { + return new PatchCellContainer( + newID, + id, + pop, + age, + divisions, + newState, + volume, + height, + criticalVolume, + criticalHeight); + } + } + + @BeforeAll + public static void setupMocks() { + simMock = mock(PatchSimulation.class); + locationMock = mock(PatchLocation.class); + parametersMock = spy(new Parameters(new MiniBox(), null, null)); + metabolismMock = mock(PatchProcessMetabolism.class); + signalingMock = mock(PatchProcessSignaling.class); + gridMock = mock(PatchGrid.class); + doReturn(gridMock).when(simMock).getGrid(); + } + + @Test + public void step_calledWhenAgeGreaterThanApoptosisAge_setsApoptoticState() { + PatchModule module = mock(PatchModule.class); + doReturn(0.0).when(parametersMock).getDouble(any(String.class)); + doReturn(0).when(parametersMock).getInt(any(String.class)); + doReturn(10.0).when(parametersMock).getDouble("APOPTOSIS_AGE"); + int age = 11; + ArrayList relevantStates = new ArrayList<>(); + relevantStates.add(State.QUIESCENT); + relevantStates.add(State.MIGRATORY); + relevantStates.add(State.PROLIFERATIVE); + + for (State state : relevantStates) { + PatchCellContainer container = + new PatchCellContainer( + cellID, + cellParent, + cellPop, + age, + cellDivisions, + state, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); + PatchCell cell = spy(new PatchCellMock(container, locationMock, parametersMock)); + cell.processes.put(Domain.METABOLISM, metabolismMock); + cell.processes.put(Domain.SIGNALING, signalingMock); + cell.module = module; + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + return null; + }) + .when(cell) + .setState(any(State.class)); + + cell.step(simMock); + + assertEquals(State.APOPTOTIC, cell.getState()); + } + } + + @Test + public void step_calledWhenAgeLessThanApoptosisAge_doesNotSetState() { + PatchModule module = mock(PatchModule.class); + doReturn(0.0).when(parametersMock).getDouble(any(String.class)); + doReturn(0).when(parametersMock).getInt(any(String.class)); + doReturn(10.0).when(parametersMock).getDouble("APOPTOSIS_AGE"); + int age = 9; + ArrayList relevantStates = new ArrayList<>(); + relevantStates.add(State.QUIESCENT); + relevantStates.add(State.MIGRATORY); + relevantStates.add(State.PROLIFERATIVE); + + for (State state : relevantStates) { + PatchCellContainer container = + new PatchCellContainer( + cellID, + cellParent, + cellPop, + age, + cellDivisions, + state, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); + PatchCell cell = spy(new PatchCellMock(container, locationMock, parametersMock)); + cell.processes.put(Domain.METABOLISM, metabolismMock); + cell.processes.put(Domain.SIGNALING, signalingMock); + cell.module = module; + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + return null; + }) + .when(cell) + .setState(any(State.class)); + + cell.step(simMock); + + assertEquals(state, cell.getState()); + } + } + + @Test + public void step_calledApoptoticStateAndApoptoticAge_doesNotResetState() { + PatchModule module = mock(PatchModule.class); + doReturn(0.0).when(parametersMock).getDouble(any(String.class)); + doReturn(0).when(parametersMock).getInt(any(String.class)); + doReturn(10.0).when(parametersMock).getDouble("APOPTOSIS_AGE"); + int age = 12; + State state = State.APOPTOTIC; + + PatchCellContainer container = + new PatchCellContainer( + cellID, + cellParent, + cellPop, + age, + cellDivisions, + state, + cellVolume, + cellHeight, + cellCriticalVolume, + cellCriticalHeight); + PatchCell cell = spy(new PatchCellMock(container, locationMock, parametersMock)); + cell.processes.put(Domain.METABOLISM, metabolismMock); + cell.processes.put(Domain.SIGNALING, signalingMock); + cell.module = module; + doAnswer( + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + return null; + }) + .when(cell) + .setState(any(State.class)); + + cell.step(simMock); + + verify(cell, times(0)).setState(any(State.class)); + } +} From 6cd65303f8e00668e392c6013d6828358632f883 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 14 Jan 2025 19:47:35 +0000 Subject: [PATCH 073/185] deleting methods with no usages --- .../patch/agent/cell/PatchCellTissueTest.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/test/arcade/patch/agent/cell/PatchCellTissueTest.java b/test/arcade/patch/agent/cell/PatchCellTissueTest.java index f8a5b128f..df7d81930 100644 --- a/test/arcade/patch/agent/cell/PatchCellTissueTest.java +++ b/test/arcade/patch/agent/cell/PatchCellTissueTest.java @@ -53,21 +53,6 @@ public class PatchCellTissueTest { static double cellCriticalHeight = randomDoubleBetween(10, 100); - static State cellState = State.QUIESCENT; - - static PatchCellContainer baseContainer = - new PatchCellContainer( - cellID, - cellParent, - cellPop, - cellAge, - cellDivisions, - cellState, - cellVolume, - cellHeight, - cellCriticalVolume, - cellCriticalHeight); - static class PatchCellMock extends PatchCellTissue { PatchCellMock(PatchCellContainer container, Location location, Parameters parameters) { super(container, location, parameters, null); From f615a9ba5b4392fd2b123ada15205d9173d5c136 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 14 Jan 2025 20:14:20 +0000 Subject: [PATCH 074/185] refactoring PatchCellCART classes --- .../agent/cell/PatchCellCARTCD4Test.java | 121 ----------------- .../agent/cell/PatchCellCARTCD8Test.java | 122 ------------------ .../patch/agent/cell/PatchCellTest.java | 2 - .../patch/agent/cell/PatchCellTissueTest.java | 25 ++-- 4 files changed, 12 insertions(+), 258 deletions(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index 4fd82fcef..846223661 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -1,21 +1,17 @@ package arcade.patch.agent.cell; import java.lang.reflect.Field; -import java.util.ArrayList; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import sim.engine.Schedule; import sim.engine.Steppable; -import sim.util.Bag; import ec.util.MersenneTwisterFast; -import arcade.core.env.location.Location; import arcade.core.sim.Simulation; import arcade.core.util.Parameters; import arcade.patch.agent.module.PatchModule; import arcade.patch.agent.process.PatchProcessInflammation; import arcade.patch.agent.process.PatchProcessMetabolism; import arcade.patch.agent.process.PatchProcessSignaling; -import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; import arcade.patch.sim.PatchSimulation; import arcade.patch.util.PatchEnums.Domain; @@ -29,7 +25,6 @@ public class PatchCellCARTCD4Test { - private PatchCellCARTCD4 patchCellCART; private Parameters parameters; private PatchLocation location; private PatchCellContainer container; @@ -92,7 +87,6 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { when(parameters.getInt("APOPTOSIS_AGE")).thenReturn(120960); when(parameters.getInt("MAX_DENSITY")).thenReturn(54); - patchCellCART = new PatchCellCARTCD4(container, location, parameters); cell = spy(new PatchCellCARTCD4(container, location, parameters)); Field apoptosisAge = PatchCell.class.getDeclaredField("apoptosisAge"); apoptosisAge.setAccessible(true); @@ -103,121 +97,6 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { maxDensity.set(cell, 54); } - @Test - public void testSetAntigenFlag() { - patchCellCART.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); - assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); - } - - @Test - public void testGetAntigenFlag() { - patchCellCART.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); - assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); - } - - @Test - public void testBindTargetNoNeighbors() { - Simulation sim = mock(Simulation.class); - PatchLocation loc = mock(PatchLocation.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - PatchGrid grid = mock(PatchGrid.class); - Bag bag = new Bag(); - - when(sim.getGrid()).thenReturn(grid); - when(grid.getObjectsAtLocation(loc)).thenReturn(bag); - when(loc.getNeighbors()).thenReturn(new ArrayList()); - - PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); - assertNull(result); - assertEquals(AntigenFlag.UNBOUND, patchCellCART.getAntigenFlag()); - } - - @Test - public void testBindTargetWithSelfBinding() { - // lots of self antigens, not a lot of car antigens - Simulation sim = mock(Simulation.class); - PatchLocation loc = mock(PatchLocation.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - PatchGrid grid = mock(PatchGrid.class); - Bag bag = new Bag(); - - when(sim.getGrid()).thenReturn(grid); - when(grid.getObjectsAtLocation(loc)).thenReturn(bag); - when(loc.getNeighbors()).thenReturn(new ArrayList()); - when(loc.getVolume()).thenReturn(6000.0); - - when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(10); - when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(10); - when(parameters.getInt("SELF_TARGETS")).thenReturn(10000000); - PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); - - bag.add(tissueCell); - - when(random.nextDouble()).thenReturn(0.0000005); - - PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); - assertNotNull(result); - assertEquals(AntigenFlag.BOUND_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); - } - - @Test - public void testBindTargetWithSelfAndAntigenBinding() { - Simulation sim = mock(Simulation.class); - PatchLocation loc = mock(PatchLocation.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - PatchGrid grid = mock(PatchGrid.class); - Bag bag = new Bag(); - - when(sim.getGrid()).thenReturn(grid); - when(grid.getObjectsAtLocation(loc)).thenReturn(bag); - when(loc.getNeighbors()).thenReturn(new ArrayList()); - when(loc.getVolume()).thenReturn(6000.0); - - when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); - when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); - when(parameters.getInt("SELF_TARGETS")).thenReturn(50000000); - - PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); - - bag.add(tissueCell); - - when(random.nextDouble()).thenReturn(0.0000005); - - PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); - assertNotNull(result); - assertEquals(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); - } - - @Test - public void testBindTarget() { - Simulation sim = mock(Simulation.class); - PatchLocation loc = mock(PatchLocation.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - PatchGrid grid = mock(PatchGrid.class); - Bag bag = new Bag(); - - when(sim.getGrid()).thenReturn(grid); - when(grid.getObjectsAtLocation(loc)).thenReturn(bag); - when(loc.getNeighbors()).thenReturn(new ArrayList()); - when(loc.getVolume()).thenReturn(6000.0); - - when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); - when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); - when(parameters.getInt("SELF_TARGETS")).thenReturn(5000); - - PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); - - bag.add(tissueCell); - - when(random.nextDouble()).thenReturn(0.0000005); - - bag.add(tissueCell); - - PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); - assertNotNull(result); - assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); - } - @Test public void testStepIncreasesAge() { PatchSimulation sim = mock(PatchSimulation.class); diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index f15f8b07a..1fa132557 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -1,21 +1,17 @@ package arcade.patch.agent.cell; import java.lang.reflect.Field; -import java.util.ArrayList; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import sim.engine.Schedule; import sim.engine.Steppable; -import sim.util.Bag; import ec.util.MersenneTwisterFast; -import arcade.core.env.location.Location; import arcade.core.sim.Simulation; import arcade.core.util.Parameters; import arcade.patch.agent.module.PatchModule; import arcade.patch.agent.process.PatchProcessInflammation; import arcade.patch.agent.process.PatchProcessMetabolism; import arcade.patch.agent.process.PatchProcessSignaling; -import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; import arcade.patch.sim.PatchSimulation; import arcade.patch.util.PatchEnums.Domain; @@ -29,7 +25,6 @@ public class PatchCellCARTCD8Test { - private PatchCellCARTCD8 patchCellCART; private PatchCellCARTCD8 cell; private Parameters parameters; private PatchLocation location; @@ -91,8 +86,6 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { when(parameters.getInt("APOPTOSIS_AGE")).thenReturn(120960); when(parameters.getInt("MAX_DENSITY")).thenReturn(54); - patchCellCART = new PatchCellCARTCD8(container, location, parameters); - cell = spy(new PatchCellCARTCD8(container, location, parameters)); Field apoptosisAge = PatchCell.class.getDeclaredField("apoptosisAge"); apoptosisAge.setAccessible(true); @@ -103,121 +96,6 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { maxDensity.set(cell, 54); } - @Test - public void testSetAntigenFlag() { - patchCellCART.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); - assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); - } - - @Test - public void testGetAntigenFlag() { - patchCellCART.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); - assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); - } - - @Test - public void testBindTargetNoNeighbors() { - Simulation sim = mock(Simulation.class); - PatchLocation loc = mock(PatchLocation.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - PatchGrid grid = mock(PatchGrid.class); - Bag bag = new Bag(); - - when(sim.getGrid()).thenReturn(grid); - when(grid.getObjectsAtLocation(loc)).thenReturn(bag); - when(loc.getNeighbors()).thenReturn(new ArrayList()); - - PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); - assertNull(result); - assertEquals(AntigenFlag.UNBOUND, patchCellCART.getAntigenFlag()); - } - - @Test - public void testBindTargetWithSelfBinding() { - // lots of self antigens, not a lot of car antigens - Simulation sim = mock(Simulation.class); - PatchLocation loc = mock(PatchLocation.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - PatchGrid grid = mock(PatchGrid.class); - Bag bag = new Bag(); - - when(sim.getGrid()).thenReturn(grid); - when(grid.getObjectsAtLocation(loc)).thenReturn(bag); - when(loc.getNeighbors()).thenReturn(new ArrayList()); - when(loc.getVolume()).thenReturn(6000.0); - - when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(10); - when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(10); - when(parameters.getInt("SELF_TARGETS")).thenReturn(10000000); - PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); - - bag.add(tissueCell); - - when(random.nextDouble()).thenReturn(0.0000005); - - PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); - assertNotNull(result); - assertEquals(AntigenFlag.BOUND_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); - } - - @Test - public void testBindTargetWithSelfAndAntigenBinding() { - Simulation sim = mock(Simulation.class); - PatchLocation loc = mock(PatchLocation.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - PatchGrid grid = mock(PatchGrid.class); - Bag bag = new Bag(); - - when(sim.getGrid()).thenReturn(grid); - when(grid.getObjectsAtLocation(loc)).thenReturn(bag); - when(loc.getNeighbors()).thenReturn(new ArrayList()); - when(loc.getVolume()).thenReturn(6000.0); - - when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); - when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); - when(parameters.getInt("SELF_TARGETS")).thenReturn(50000000); - - PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); - - bag.add(tissueCell); - - when(random.nextDouble()).thenReturn(0.0000005); - - PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); - assertNotNull(result); - assertEquals(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); - } - - @Test - public void testBindTarget() { - Simulation sim = mock(Simulation.class); - PatchLocation loc = mock(PatchLocation.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - PatchGrid grid = mock(PatchGrid.class); - Bag bag = new Bag(); - - when(sim.getGrid()).thenReturn(grid); - when(grid.getObjectsAtLocation(loc)).thenReturn(bag); - when(loc.getNeighbors()).thenReturn(new ArrayList()); - when(loc.getVolume()).thenReturn(6000.0); - - when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); - when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); - when(parameters.getInt("SELF_TARGETS")).thenReturn(5000); - - PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); - - bag.add(tissueCell); - - when(random.nextDouble()).thenReturn(0.0000005); - - bag.add(tissueCell); - - PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); - assertNotNull(result); - assertEquals(AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); - } - @Test public void testStepIncreasesAge() { PatchSimulation sim = mock(PatchSimulation.class); diff --git a/test/arcade/patch/agent/cell/PatchCellTest.java b/test/arcade/patch/agent/cell/PatchCellTest.java index 596852487..bae40fe57 100644 --- a/test/arcade/patch/agent/cell/PatchCellTest.java +++ b/test/arcade/patch/agent/cell/PatchCellTest.java @@ -9,13 +9,11 @@ import arcade.core.env.location.*; import arcade.core.util.MiniBox; import arcade.core.util.Parameters; -import arcade.patch.agent.module.PatchModule; import arcade.patch.agent.process.PatchProcessMetabolism; import arcade.patch.agent.process.PatchProcessSignaling; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; import arcade.patch.sim.PatchSimulation; -import arcade.patch.util.PatchEnums.Domain; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; diff --git a/test/arcade/patch/agent/cell/PatchCellTissueTest.java b/test/arcade/patch/agent/cell/PatchCellTissueTest.java index df7d81930..710c49d71 100644 --- a/test/arcade/patch/agent/cell/PatchCellTissueTest.java +++ b/test/arcade/patch/agent/cell/PatchCellTissueTest.java @@ -3,7 +3,6 @@ import java.util.ArrayList; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import sim.util.Bag; import ec.util.MersenneTwisterFast; import arcade.core.agent.cell.CellState; import arcade.core.env.location.*; @@ -115,10 +114,10 @@ public void step_calledWhenAgeGreaterThanApoptosisAge_setsApoptoticState() { cell.processes.put(Domain.SIGNALING, signalingMock); cell.module = module; doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - return null; - }) + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + return null; + }) .when(cell) .setState(any(State.class)); @@ -158,10 +157,10 @@ public void step_calledWhenAgeLessThanApoptosisAge_doesNotSetState() { cell.processes.put(Domain.SIGNALING, signalingMock); cell.module = module; doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - return null; - }) + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + return null; + }) .when(cell) .setState(any(State.class)); @@ -197,10 +196,10 @@ public void step_calledApoptoticStateAndApoptoticAge_doesNotResetState() { cell.processes.put(Domain.SIGNALING, signalingMock); cell.module = module; doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - return null; - }) + invocationOnMock -> { + cell.state = invocationOnMock.getArgument(0); + return null; + }) .when(cell) .setState(any(State.class)); From 0feb2e1b7ddc76627ebf0bdb42f187e511a6bafd Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 14 Jan 2025 20:17:15 +0000 Subject: [PATCH 075/185] adding CART abstract clas tests --- .../patch/agent/cell/PatchCellCARTTest.java | 230 ++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 test/arcade/patch/agent/cell/PatchCellCARTTest.java diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java new file mode 100644 index 000000000..d4ade94bd --- /dev/null +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -0,0 +1,230 @@ +package arcade.patch.agent.cell; + +import java.util.ArrayList; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import sim.engine.SimState; +import sim.util.Bag; +import ec.util.MersenneTwisterFast; +import arcade.core.agent.cell.CellState; +import arcade.core.env.location.Location; +import arcade.core.sim.Simulation; +import arcade.core.util.Parameters; +import arcade.patch.env.grid.PatchGrid; +import arcade.patch.env.location.PatchLocation; +import arcade.patch.util.PatchEnums; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.*; +import static arcade.core.ARCADETestUtilities.randomDoubleBetween; +import static arcade.core.ARCADETestUtilities.randomIntBetween; + +public class PatchCellCARTTest { + private PatchCellCART patchCellCART; + private Parameters parameters; + private PatchLocation location; + private PatchCellContainer container; + + static class PatchCellMock extends PatchCellCART { + PatchCellMock(PatchCellContainer container, Location location, Parameters parameters) { + super(container, location, parameters, null); + } + + @Override + public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFast random) { + return new PatchCellContainer( + newID, + id, + pop, + age, + divisions, + newState, + volume, + height, + criticalVolume, + criticalHeight); + } + + @Override + public void step(SimState state) {} + } + + @BeforeEach + public void setUp() throws NoSuchFieldException, IllegalAccessException { + parameters = mock(Parameters.class); + location = mock(PatchLocation.class); + + doReturn(0.0).when(parameters).getDouble(any(String.class)); + doReturn(0).when(parameters).getInt(any(String.class)); + + int id = 1; + int parentId = 1; + int pop = 1; + int age = randomIntBetween(1, 120950); + int divisions = 10; + double volume = randomDoubleBetween(100, 200); + double height = randomDoubleBetween(4, 10); + double criticalVolume = randomDoubleBetween(100, 200); + double criticalHeight = randomDoubleBetween(4, 10); + PatchEnums.State state = PatchEnums.State.UNDEFINED; + ; + + container = + new PatchCellContainer( + id, + parentId, + pop, + age, + divisions, + state, + volume, + height, + criticalVolume, + criticalHeight); + + when(parameters.getDouble("HETEROGENEITY")).thenReturn(0.0); + when(parameters.getDouble("ENERGY_THRESHOLD")).thenReturn(1.0); + + when(parameters.getDouble("NECROTIC_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("EXHAU_FRAC")).thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("SENESCENT_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("ANERGIC_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("PROLIFERATIVE_FRACTION")) + .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getInt("SELF_RECEPTORS")).thenReturn(randomIntBetween(100, 200)); + when(parameters.getDouble("SEARCH_ABILITY")).thenReturn(1.0); + when(parameters.getDouble("CAR_AFFINITY")).thenReturn(10 * Math.pow(10, -7)); + when(parameters.getDouble("CAR_ALPHA")).thenReturn(3.0); + when(parameters.getDouble("CAR_BETA")).thenReturn(0.01); + when(parameters.getDouble("SELF_RECEPTOR_AFFINITY")).thenReturn(7.8E-6); + when(parameters.getDouble("SELF_ALPHA")).thenReturn(3.0); + when(parameters.getDouble("SELF_BETA")).thenReturn(0.02); + when(parameters.getDouble("CONTACT_FRAC")).thenReturn(7.8E-6); + when(parameters.getInt("MAX_ANTIGEN_BINDING")).thenReturn(10); + when(parameters.getInt("CARS")).thenReturn(50000); + + when(parameters.getInt("APOPTOSIS_AGE")).thenReturn(120960); + when(parameters.getInt("MAX_DENSITY")).thenReturn(54); + + patchCellCART = new PatchCellMock(container, location, parameters); + } + + @Test + public void testSetAntigenFlag() { + patchCellCART.setAntigenFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); + assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); + } + + @Test + public void testGetAntigenFlag() { + patchCellCART.setAntigenFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); + assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTargetNoNeighbors() { + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNull(result); + assertEquals(PatchEnums.AntigenFlag.UNBOUND, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTargetWithSelfBinding() { + // lots of self antigens, not a lot of car antigens + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + when(loc.getVolume()).thenReturn(6000.0); + + when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(10); + when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(10); + when(parameters.getInt("SELF_TARGETS")).thenReturn(10000000); + PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + + bag.add(tissueCell); + + when(random.nextDouble()).thenReturn(0.0000005); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNotNull(result); + assertEquals(PatchEnums.AntigenFlag.BOUND_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTargetWithSelfAndAntigenBinding() { + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + when(loc.getVolume()).thenReturn(6000.0); + + when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); + when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); + when(parameters.getInt("SELF_TARGETS")).thenReturn(50000000); + + PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + + bag.add(tissueCell); + + when(random.nextDouble()).thenReturn(0.0000005); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNotNull(result); + assertEquals( + PatchEnums.AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); + } + + @Test + public void testBindTarget() { + Simulation sim = mock(Simulation.class); + PatchLocation loc = mock(PatchLocation.class); + MersenneTwisterFast random = mock(MersenneTwisterFast.class); + PatchGrid grid = mock(PatchGrid.class); + Bag bag = new Bag(); + + when(sim.getGrid()).thenReturn(grid); + when(grid.getObjectsAtLocation(loc)).thenReturn(bag); + when(loc.getNeighbors()).thenReturn(new ArrayList()); + when(loc.getVolume()).thenReturn(6000.0); + + when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); + when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); + when(parameters.getInt("SELF_TARGETS")).thenReturn(5000); + + PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + + bag.add(tissueCell); + + when(random.nextDouble()).thenReturn(0.0000005); + + bag.add(tissueCell); + + PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + assertNotNull(result); + assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); + } +} From 3eed6d6ea79cd1db98843e7370aa6f36efbf170f Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 14 Jan 2025 20:30:12 +0000 Subject: [PATCH 076/185] refactoring inflammation abstract tests --- .../process/PatchProcessInflammationTest.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java index 8da083b57..ff024a479 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; import ec.util.MersenneTwisterFast; +import arcade.core.agent.process.Process; import arcade.core.sim.Simulation; import arcade.core.util.Parameters; import arcade.patch.agent.cell.PatchCellCART; @@ -22,6 +23,18 @@ public class PatchProcessInflammationTest { private Simulation mockSimulation; private MersenneTwisterFast mockRandom; + static class inflammationMock extends PatchProcessInflammation { + public inflammationMock(PatchCellCART c) { + super(c); + } + + @Override + void stepProcess(MersenneTwisterFast random, Simulation sim) {} + + @Override + public void update(Process process) {} + } + @BeforeEach public void setUp() { mockCell = Mockito.mock(PatchCellCART.class); @@ -39,8 +52,7 @@ public void setUp() { Mockito.when(mockParameters.getInt(anyString())).thenReturn(1); Mockito.when(mockSimulation.getLattice(anyString())).thenReturn(mockLattice); doNothing().when(mockLattice).setValue(any(PatchLocation.class), anyDouble()); - - inflammation = new PatchProcessInflammationCD8(mockCell); + inflammation = new inflammationMock(mockCell); } @Test From 7283e718761e9d5b258653a6d04373875281b663 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 14 Jan 2025 20:42:11 +0000 Subject: [PATCH 077/185] refactoring metabolism cart tests --- .../PatchProcessMetabolismCARTTest.java | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java index de2965be9..e11888c9b 100644 --- a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import ec.util.MersenneTwisterFast; +import arcade.core.agent.process.Process; import arcade.core.sim.Simulation; import arcade.core.util.Parameters; import arcade.patch.agent.cell.PatchCellCART; @@ -20,6 +21,18 @@ public class PatchProcessMetabolismCARTTest { private PatchLocation mockLocation; private double cellVolume; + static class inflammationMock extends PatchProcessInflammation { + public inflammationMock(PatchCellCART c) { + super(c); + } + + @Override + void stepProcess(MersenneTwisterFast random, Simulation sim) {} + + @Override + public void update(Process process) {} + } + @BeforeEach public void setUp() { mockCell = mock(PatchCellCART.class); @@ -121,7 +134,7 @@ public void testStepProcess() throws NoSuchFieldException, IllegalAccessExceptio Simulation sim = mock(Simulation.class); // mock inflammation process - PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); @@ -143,7 +156,7 @@ public void testStepProcessWithZeroInitialGlucose() { Simulation sim = mock(Simulation.class); // mock inflammation process - PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); @@ -165,7 +178,7 @@ public void testStepProcessWithMaxGlucoseConcentration() { Simulation sim = mock(Simulation.class); // mock inflammation process - PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); @@ -186,7 +199,7 @@ public void testStepProcessWithNegativeGlucoseConcentration() { Simulation sim = mock(Simulation.class); // mock inflammation process - PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); @@ -207,7 +220,7 @@ public void testStepProcessWithZeroOxygenConcentration() { Simulation sim = mock(Simulation.class); // mock inflammation process - PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); @@ -230,7 +243,7 @@ public void testStepProcessWithMaxOxygenConcentration() { Simulation sim = mock(Simulation.class); // mock inflammation process - PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); @@ -254,7 +267,7 @@ public void testActivatedMetabolicPreference() Simulation sim = mock(Simulation.class); // mock inflammation process - PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + PatchProcessInflammation inflammation = new inflammationMock(mockCell); Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker"); activeTicker.setAccessible(true); activeTicker.set(inflammation, 1); @@ -280,7 +293,7 @@ public void testActivatedGlucoseUptakeRate() Simulation sim = mock(Simulation.class); // mock inflammation process - PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + PatchProcessInflammation inflammation = new inflammationMock(mockCell); Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker"); activeTicker.setAccessible(true); activeTicker.set(inflammation, 1); @@ -306,7 +319,7 @@ public void testActivatedMinimumMassFraction() Simulation sim = mock(Simulation.class); // mock inflammation process - PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell)); + PatchProcessInflammation inflammation = new inflammationMock(mockCell); Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker"); activeTicker.setAccessible(true); activeTicker.set(inflammation, 1); From 38a0eacaf035ac0ea61091c6968ba00019080c21 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 18:26:16 +0000 Subject: [PATCH 078/185] fixing linting of patch cell class --- src/arcade/patch/agent/cell/PatchCell.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 259669de1..641fac1d5 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -140,7 +140,7 @@ public abstract class PatchCell implements Cell { /** List of cell cycle lengths (in minutes). */ private final Bag cycles = new Bag(); - /** If cell is stopped in the simulation */ + /** If cell is stopped in the simulation. */ private boolean isStopped; /** @@ -333,6 +333,11 @@ public void stop() { isStopped = true; } + /** + * Gets stopping status of the cell. + * + * @return if the cell has been stopped in the simulation + */ public boolean isStopped() { return isStopped; } From 8c5b9ba7cac5dc1914c3297b67cf311dcccd90d2 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 18:32:08 +0000 Subject: [PATCH 079/185] adding periods and changing variable casing of patch cell cart class --- .../patch/agent/cell/PatchCellCART.java | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index f2ef206b7..c54d5eefd 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -45,55 +45,55 @@ * specified amount of heterogeneity ({@code HETEROGENEITY}). */ public abstract class PatchCellCART extends PatchCell { - /** Cell binding flag */ + /** Cell binding flag. */ public AntigenFlag binding; - /** Cell activation flag */ + /** Cell activation flag. */ protected boolean activated; - /** number of current PDL-1 receptors on CART cell */ + /** number of current PDL-1 receptors on CART cell. */ protected int selfReceptors; - /** initial number of PDL-1 receptors on CART cell */ + /** initial number of PDL-1 receptors on CART cell. */ protected int selfReceptorsStart; - /** number of bound CAR antigens */ + /** number of bound CAR antigens. */ protected int boundAntigensCount; - /** number of bound PDL-1 antigens */ + /** number of bound PDL-1 antigens. */ protected int boundSelfCount; - /** number of neighbors that T cell is able to search through */ + /** number of neighbors that T cell is able to search through. */ protected final double searchAbility; - /** binding affinity for CAR receptor */ + /** binding affinity for CAR receptor. */ protected final double carAffinity; - /** tuning factor for CAR binding */ + /** tuning factor for CAR binding. */ protected final double carAlpha; - /** tuning factor for CAR binding */ + /** tuning factor for CAR binding. */ protected final double carBeta; - /** binding affinity for PDL-1 receptor */ + /** binding affinity for PDL-1 receptor. */ protected final double selfReceptorAffinity; - /** tuning factor for PDL-1 receptor binding */ + /** tuning factor for PDL-1 receptor binding. */ protected final double selfAlpha; - /** tuning factor for PDL-1 receptor binding */ + /** tuning factor for PDL-1 receptor binding. */ protected final double selfBeta; - /** fraction of cell surface that contacts when binding */ + /** fraction of cell surface that contacts when binding. */ protected final double contactFraction; - /** max antigens threshold for T cell exhaustion */ + /** max antigens threshold for T cell exhaustion. */ protected final int maxAntigenBinding; - /** number of CARs on T cell surface */ + /** number of CARs on T cell surface. */ protected final int cars; - /** simulation time since T cell was last activated */ + /** simulation time since T cell was last activated. */ protected int lastActiveTicker; /** Fraction of exhausted cells that become apoptotic. */ @@ -186,11 +186,13 @@ public PatchCellCART( * @param sim the MASON simulation * @param loc the location of the CAR T-cell * @param random random seed + * + * @return the target cell if one was bound. Null if none were bound. */ public PatchCellTissue bindTarget( Simulation sim, PatchLocation loc, MersenneTwisterFast random) { - double KDCAR = carAffinity * (loc.getVolume() * 1e-15 * 6.022E23); - double KDSelf = selfReceptorAffinity * (loc.getVolume() * 1e-15 * 6.022E23); + double kDCAR = carAffinity * (loc.getVolume() * 1e-15 * 6.022E23); + double kDSelf = selfReceptorAffinity * (loc.getVolume() * 1e-15 * 6.022E23); PatchGrid grid = (PatchGrid) sim.getGrid(); // get all agents from this location @@ -233,19 +235,19 @@ public PatchCellTissue bindTarget( && cell.getState() != State.APOPTOTIC && cell.getState() != State.NECROTIC) { PatchCellTissue tissueCell = (PatchCellTissue) cell; - double CARAntigens = tissueCell.carAntigens; + double cARAntigens = tissueCell.carAntigens; double selfTargets = tissueCell.selfTargets; double hillCAR = - (CARAntigens + (cARAntigens * contactFraction - / (KDCAR * carBeta + CARAntigens * contactFraction)) + / (kDCAR * carBeta + cARAntigens * contactFraction)) * (cars / 50000) * carAlpha; double hillSelf = (selfTargets * contactFraction - / (KDSelf * selfBeta + selfTargets * contactFraction)) + / (kDSelf * selfBeta + selfTargets * contactFraction)) * (selfReceptors / selfReceptorsStart) * selfAlpha; @@ -309,7 +311,7 @@ public AntigenFlag getAntigenFlag() { } /** - * Returns the cell activation status + * Returns the cell activation status. * * @return the activation status */ From b7481b9f525555554812a0dd0a333eaa73937523 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 18:45:57 +0000 Subject: [PATCH 080/185] adding spotlessApply to patch cell cart class --- src/arcade/patch/agent/cell/PatchCellCART.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index c54d5eefd..0c5ddb5e3 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -186,7 +186,6 @@ public PatchCellCART( * @param sim the MASON simulation * @param loc the location of the CAR T-cell * @param random random seed - * * @return the target cell if one was bound. Null if none were bound. */ public PatchCellTissue bindTarget( From c1768d77a5b0b1a3e27ca98bb3533718a14b98a0 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 18:52:09 +0000 Subject: [PATCH 081/185] adding periods to descriptions in tissue class --- src/arcade/patch/agent/cell/PatchCellTissue.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index b7dc98b98..8841f14a7 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -14,13 +14,13 @@ /** Extension of {@link PatchCell} for healthy tissue cells. */ public class PatchCellTissue extends PatchCell { - /** Cell surface antigen count */ + /** Cell surface antigen count. */ int carAntigens; - /** Cell surface PDL1 count */ + /** Cell surface PDL1 count. */ int selfTargets; - /** Cell binding flag */ + /** Cell binding flag. */ public AntigenFlag binding; /** From d4eba48f2a007a16bfef4bd5ea9e42338fe6bc8f Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 19:22:38 +0000 Subject: [PATCH 082/185] adding periods and changing field casings related to the PatchInflammation class --- .../process/PatchProcessInflammation.java | 212 +++++++++--------- .../process/PatchProcessInflammationCD4.java | 34 +-- .../process/PatchProcessInflammationCD8.java | 34 +-- .../process/PatchProcessMetabolismCART.java | 2 +- .../PatchProcessInflammationCD4Test.java | 26 +-- .../PatchProcessInflammationCD8Test.java | 6 +- 6 files changed, 160 insertions(+), 154 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index e98c7b3d9..03619788a 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -21,100 +21,100 @@ */ public abstract class PatchProcessInflammation extends PatchProcess { - /** Number of components in signaling network */ + /** Number of components in signaling network. */ protected static final int NUM_COMPONENTS = 8; - /** ID for IL-2, bound total */ + /** ID for IL-2, bound total. */ protected static final int IL2_INT_TOTAL = 0; - /** ID for IL-2, external */ + /** ID for IL-2, external. */ protected static final int IL2_EXT = 1; - /** ID for IL-2 receptors, total between both two and three chain complex */ + /** ID for IL-2 receptors, total between both two and three chain complex. */ protected static final int IL2R_TOTAL = 2; - /** ID for two-chain IL-2 receptor complex */ - protected static final int IL2Rbg = 3; + /** ID for two-chain IL-2 receptor complex. */ + protected static final int IL2RBG = 3; - /** ID for three-chain IL-2 receptor complex */ - protected static final int IL2Rbga = 4; + /** ID for three-chain IL-2 receptor complex. */ + protected static final int IL2RBGa = 4; - /** ID for IL-2-two-chain IL-2 receptor complex */ - protected static final int IL2_IL2Rbg = 5; + /** ID for IL-2-two-chain IL-2 receptor complex. */ + protected static final int IL2_IL2RBG = 5; - /** ID for IL-2-three-chain IL-2 receptor complex */ - protected static final int IL2_IL2Rbga = 6; + /** ID for IL-2-three-chain IL-2 receptor complex. */ + protected static final int IL2_IL2RBGa = 6; - /** ID for granzyme, internal */ + /** ID for granzyme, internal. */ protected static final int GRANZYME = 7; - /** Number of steps per second to take in ODE */ + /** Number of steps per second to take in ODE. */ private static final double STEP_DIVIDER = 3.0; /** * Rate of conversion of IL-2R two-chain complex to IL-2R three chain complex [/sec/step - * divider] + * divider]. */ private static final double K_CONVERT = 1e-3 / STEP_DIVIDER; /** * Rate of recycling of receptor complexes back to IL-2 receptor two chain complex [/sec/step - * divider] + * divider]. */ private static final double K_REC = 1e-5 / STEP_DIVIDER; - /** Rate of IL-2 binding to two-chain IL-2 receptor complex [um^3/molecules IL-2/min] */ - private double IL2_BINDING_ON_RATE_MIN = 3.8193E-2; + /** Rate of IL-2 binding to two-chain IL-2 receptor complex [um^3/molecules IL-2/min]. */ + private double iL2BindingOnRateMin = 3.8193E-2; - /** Rate of IL-2 binding to three-chain IL-2 receptor complex [um^3/molecules IL-2/min] */ - private double IL2_BINDING_ON_RATE_MAX = 3.155; + /** Rate of IL-2 binding to three-chain IL-2 receptor complex [um^3/molecules IL-2/min]. */ + private double iL2BindingOnRateMax = 3.155; - /** Rate of unbinding of IL-2 from two- or three- chain IL-2 receptor complex [/min] */ - private double IL2_BINDING_OFF_RATE = 0.015; + /** Rate of unbinding of IL-2 from two- or three- chain IL-2 receptor complex [/min]. */ + private double iL2BindingOffRate = 0.015; - /** Step size for module (in seconds) */ + /** Step size for module (in seconds). */ static final double STEP_SIZE = 1.0 / STEP_DIVIDER; - /** Location of cell */ + /** Location of cell. */ protected Location loc; - /** Cell the module is associated with */ + /** Cell the module is associated with. */ protected PatchCellCART c; - /** Cell population index */ + /** Cell population index. */ protected int pop; - /** List of internal names */ + /** List of internal names. */ protected List names; - /** List of amounts of each species */ + /** List of amounts of each species. */ protected double[] amts; - /** External IL-2 [molecules] */ + /** External IL-2 [molecules]. */ protected double extIL2; - /** Shell around cell volume fraction */ + /** Shell around cell volume fraction. */ protected double f; - /** Volume of cell [um3] */ + /** Volume of cell [um3]. */ protected double volume; - /** Flag marking if cell is activated via antigen-induced activation */ + /** Flag marking if cell is activated via antigen-induced activation. */ protected boolean active; - /** Time since cell first bound IL-2 */ - protected int IL2Ticker; + /** Time since cell first bound IL-2 .*/ + protected int iL2Ticker; - /** Time since cell became activated via antigen-induced activation */ + /** Time since cell became activated via antigen-induced activation. */ protected int activeTicker; - /** List of amounts of IL-2 bound to cell at previous time points */ + /** List of amounts of IL-2 bound to cell at previous time points. */ protected double[] boundArray; - /** Distance outward from surface a cell can sense */ + /** Distance outward from surface a cell can sense. */ protected final double SHELL_THICKNESS; - /** Total 2-complex receptors */ + /** Total 2-complex receptors. */ protected final double IL2_RECEPTORS; /** @@ -133,16 +133,16 @@ public PatchProcessInflammation(PatchCellCART c) { this.c = c; this.pop = c.getPop(); this.volume = c.getVolume(); - this.IL2Ticker = 0; + this.iL2Ticker = 0; this.activeTicker = 0; // Set parameters. Parameters parameters = cell.getParameters(); this.SHELL_THICKNESS = parameters.getDouble("inflammation/SHELL_THICKNESS"); this.IL2_RECEPTORS = parameters.getDouble("inflammation/IL2_RECEPTORS"); - this.IL2_BINDING_ON_RATE_MIN = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MIN"); - this.IL2_BINDING_ON_RATE_MAX = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MAX"); - this.IL2_BINDING_OFF_RATE = parameters.getDouble("inflammation/IL2_BINDING_OFF_RATE"); + this.iL2BindingOnRateMin = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MIN"); + this.iL2BindingOnRateMax = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MAX"); + this.iL2BindingOffRate = parameters.getDouble("inflammation/IL2_BINDING_OFF_RATE"); extIL2 = 0; @@ -150,88 +150,88 @@ public PatchProcessInflammation(PatchCellCART c) { amts = new double[NUM_COMPONENTS]; amts[IL2_INT_TOTAL] = 0; amts[IL2R_TOTAL] = IL2_RECEPTORS; - amts[IL2Rbg] = IL2_RECEPTORS; - amts[IL2Rbga] = 0; - amts[IL2_IL2Rbg] = 0; - amts[IL2_IL2Rbga] = 0; + amts[IL2RBG] = IL2_RECEPTORS; + amts[IL2RBGa] = 0; + amts[IL2_IL2RBG] = 0; + amts[IL2_IL2RBGa] = 0; // Molecule names. names = new ArrayList(); names.add(IL2_INT_TOTAL, "IL-2"); names.add(IL2_EXT, "external_IL-2"); names.add(IL2R_TOTAL, "IL2R_total"); - names.add(IL2Rbg, "IL2R_two_chain_complex"); - names.add(IL2Rbga, "IL2R_three_chain_complex"); - names.add(IL2_IL2Rbg, "IL-2_IL2R_two_chain_complex"); - names.add(IL2_IL2Rbga, "IL-2_IL2R_three_chain_complex"); + names.add(IL2RBG, "IL2R_two_chain_complex"); + names.add(IL2RBGa, "IL2R_three_chain_complex"); + names.add(IL2_IL2RBG, "IL-2_IL2R_two_chain_complex"); + names.add(IL2_IL2RBGa, "IL-2_IL2R_three_chain_complex"); // Initialize prior IL2 array. this.boundArray = new double[180]; } - /** System of ODEs for network */ + /** System of ODEs for network. */ Equations dydt = (Equations & Serializable) (t, y) -> { double[] dydt = new double[NUM_COMPONENTS]; - double kon_2 = - IL2_BINDING_ON_RATE_MIN / loc.getVolume() / 60 / STEP_DIVIDER; - double kon_3 = - IL2_BINDING_ON_RATE_MAX / loc.getVolume() / 60 / STEP_DIVIDER; - double koff = IL2_BINDING_OFF_RATE / 60 / STEP_DIVIDER; + double kOn2 = + iL2BindingOnRateMin / loc.getVolume() / 60 / STEP_DIVIDER; + double kOn3 = + iL2BindingOnRateMax / loc.getVolume() / 60 / STEP_DIVIDER; + double kOff = iL2BindingOffRate / 60 / STEP_DIVIDER; dydt[IL2_EXT] = - koff * y[IL2_IL2Rbg] - + koff * y[IL2_IL2Rbga] - - kon_2 * y[IL2Rbg] * y[IL2_EXT] - - kon_3 * y[IL2Rbga] * y[IL2_EXT]; - dydt[IL2Rbg] = - koff * y[IL2_IL2Rbg] - - kon_2 * y[IL2Rbg] * y[IL2_EXT] - - K_CONVERT * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) * y[IL2Rbg] - + K_REC * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga] + y[IL2Rbga]); - dydt[IL2Rbga] = - koff * y[IL2_IL2Rbga] - - kon_3 * y[IL2Rbga] * y[IL2_EXT] - + K_CONVERT * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) * y[IL2Rbg] - - K_REC * y[IL2Rbga]; - dydt[IL2_IL2Rbg] = - kon_2 * y[IL2Rbg] * y[IL2_EXT] - - koff * y[IL2_IL2Rbg] + kOff * y[IL2_IL2RBG] + + kOff * y[IL2_IL2RBGa] + - kOn2 * y[IL2RBG] * y[IL2_EXT] + - kOn3 * y[IL2RBGa] * y[IL2_EXT]; + dydt[IL2RBG] = + kOff * y[IL2_IL2RBG] + - kOn2 * y[IL2RBG] * y[IL2_EXT] + - K_CONVERT * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) * y[IL2RBG] + + K_REC * (y[IL2_IL2RBG] + y[IL2_IL2RBGa] + y[IL2RBGa]); + dydt[IL2RBGa] = + kOff * y[IL2_IL2RBGa] + - kOn3 * y[IL2RBGa] * y[IL2_EXT] + + K_CONVERT * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) * y[IL2RBG] + - K_REC * y[IL2RBGa]; + dydt[IL2_IL2RBG] = + kOn2 * y[IL2RBG] * y[IL2_EXT] + - kOff * y[IL2_IL2RBG] - K_CONVERT - * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) - * y[IL2_IL2Rbg] - - K_REC * y[IL2_IL2Rbg]; - dydt[IL2_IL2Rbga] = - kon_3 * y[IL2Rbga] * y[IL2_EXT] - - koff * y[IL2_IL2Rbga] + * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) + * y[IL2_IL2RBG] + - K_REC * y[IL2_IL2RBG]; + dydt[IL2_IL2RBGa] = + kOn3 * y[IL2RBGa] * y[IL2_EXT] + - kOff * y[IL2_IL2RBGa] + K_CONVERT - * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) - * y[IL2_IL2Rbg] - - K_REC * y[IL2_IL2Rbga]; + * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) + * y[IL2_IL2RBG] + - K_REC * y[IL2_IL2RBGa]; dydt[IL2_INT_TOTAL] = - kon_2 * y[IL2Rbg] * y[IL2_EXT] - - koff * y[IL2_IL2Rbg] + kOn2 * y[IL2RBG] * y[IL2_EXT] + - kOff * y[IL2_IL2RBG] - K_CONVERT - * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) - * y[IL2_IL2Rbg] - - K_REC * y[IL2_IL2Rbg] - + kon_3 * y[IL2Rbga] * y[IL2_EXT] - - koff * y[IL2_IL2Rbga] + * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) + * y[IL2_IL2RBG] + - K_REC * y[IL2_IL2RBG] + + kOn3 * y[IL2RBGa] * y[IL2_EXT] + - kOff * y[IL2_IL2RBGa] + K_CONVERT - * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) - * y[IL2_IL2Rbg] - - K_REC * y[IL2_IL2Rbga]; + * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) + * y[IL2_IL2RBG] + - K_REC * y[IL2_IL2RBGa]; dydt[IL2R_TOTAL] = - koff * y[IL2_IL2Rbg] - - kon_2 * y[IL2Rbg] * y[IL2_EXT] - - K_CONVERT * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) * y[IL2Rbg] - + K_REC * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga] + y[IL2Rbga]) - + koff * y[IL2_IL2Rbga] - - kon_3 * y[IL2Rbga] * y[IL2_EXT] - + K_CONVERT * (y[IL2_IL2Rbg] + y[IL2_IL2Rbga]) * y[IL2Rbg] - - K_REC * y[IL2Rbga]; + kOff * y[IL2_IL2RBG] + - kOn2 * y[IL2RBG] * y[IL2_EXT] + - K_CONVERT * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) * y[IL2RBG] + + K_REC * (y[IL2_IL2RBG] + y[IL2_IL2RBGa] + y[IL2RBGa]) + + kOff * y[IL2_IL2RBGa] + - kOn3 * y[IL2RBGa] * y[IL2_EXT] + + K_CONVERT * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) * y[IL2RBG] + - K_REC * y[IL2RBGa]; return dydt; }; @@ -240,11 +240,17 @@ public PatchProcessInflammation(PatchCellCART c) { * Gets the internal amounts of requested key. * * @param key the requested substance + * @return the internal cell amount of requested substance */ public double getInternal(String key) { return amts[names.indexOf(key)]; } + /** + * Sets the internal amounts of requested key. + * + * @param key the requested substance + */ public void setInternal(String key, double val) { amts[names.indexOf(key)] = val; } @@ -271,7 +277,7 @@ private void updateExternal(Simulation sim) { extIL2 = il2.getAverageValue(loc) * loc.getVolume() / 1E12; } - // METHOD: stepModule. + @Override public void step(MersenneTwisterFast random, Simulation sim) { // Calculate shell volume 2 um outside of cell. double radCell = Math.cbrt((3.0 / 4.0) * (1.0 / Math.PI) * volume); @@ -302,8 +308,8 @@ public void step(MersenneTwisterFast random, Simulation sim) { stepProcess(random, sim); // Update bound array. - boundArray[IL2Ticker % boundArray.length] = amts[IL2_INT_TOTAL]; - IL2Ticker++; + boundArray[iL2Ticker % boundArray.length] = amts[IL2_INT_TOTAL]; + iL2Ticker++; } /** diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java index 92aa0f077..1aeeca2fb 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java @@ -57,7 +57,7 @@ public PatchProcessInflammationCD4(PatchCellCART c) { public void stepProcess(MersenneTwisterFast random, Simulation sim) { // Determine IL-2 production rate as a function of IL-2 bound. - int prodIndex = (IL2Ticker % boundArray.length) - IL2_SYNTHESIS_DELAY; + int prodIndex = (iL2Ticker % boundArray.length) - IL2_SYNTHESIS_DELAY; if (prodIndex < 0) { prodIndex += boundArray.length; } @@ -92,27 +92,27 @@ public void update(Process mod) { // Update daughter cell inflammation as a fraction of parent. // this.volume = this.cell.getVolume(); - this.amts[IL2Rbga] = inflammation.amts[IL2Rbga] * split; - this.amts[IL2_IL2Rbg] = inflammation.amts[IL2_IL2Rbg] * split; - this.amts[IL2_IL2Rbga] = inflammation.amts[IL2_IL2Rbga] * split; - this.amts[IL2Rbg] = - IL2_RECEPTORS - this.amts[IL2Rbga] - this.amts[IL2_IL2Rbg] - this.amts[IL2_IL2Rbga]; - this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2Rbg] + this.amts[IL2_IL2Rbga]; - this.amts[IL2R_TOTAL] = this.amts[IL2Rbg] + this.amts[IL2Rbga]; + this.amts[IL2RBGa] = inflammation.amts[IL2RBGa] * split; + this.amts[IL2_IL2RBG] = inflammation.amts[IL2_IL2RBG] * split; + this.amts[IL2_IL2RBGa] = inflammation.amts[IL2_IL2RBGa] * split; + this.amts[IL2RBG] = + IL2_RECEPTORS - this.amts[IL2RBGa] - this.amts[IL2_IL2RBG] - this.amts[IL2_IL2RBGa]; + this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2RBG] + this.amts[IL2_IL2RBGa]; + this.amts[IL2R_TOTAL] = this.amts[IL2RBG] + this.amts[IL2RBGa]; this.boundArray = (inflammation.boundArray).clone(); // Update parent cell with remaining fraction. - inflammation.amts[IL2Rbga] *= (1 - split); - inflammation.amts[IL2_IL2Rbg] *= (1 - split); - inflammation.amts[IL2_IL2Rbga] *= (1 - split); - inflammation.amts[IL2Rbg] = + inflammation.amts[IL2RBGa] *= (1 - split); + inflammation.amts[IL2_IL2RBG] *= (1 - split); + inflammation.amts[IL2_IL2RBGa] *= (1 - split); + inflammation.amts[IL2RBG] = IL2_RECEPTORS - - inflammation.amts[IL2Rbga] - - inflammation.amts[IL2_IL2Rbg] - - inflammation.amts[IL2_IL2Rbga]; + - inflammation.amts[IL2RBGa] + - inflammation.amts[IL2_IL2RBG] + - inflammation.amts[IL2_IL2RBGa]; inflammation.amts[IL2_INT_TOTAL] = - inflammation.amts[IL2_IL2Rbg] + inflammation.amts[IL2_IL2Rbga]; - inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2Rbg] + inflammation.amts[IL2Rbga]; + inflammation.amts[IL2_IL2RBG] + inflammation.amts[IL2_IL2RBGa]; + inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2RBG] + inflammation.amts[IL2RBGa]; inflammation.volume *= (1 - split); } diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index b2254d6de..79f0527ed 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -42,7 +42,7 @@ public void stepProcess(MersenneTwisterFast random, Simulation sim) { // Determine amount of granzyme production based on if cell is activated // as a function of IL-2 production. - int granzIndex = (IL2Ticker % boundArray.length) - GRANZ_SYNTHESIS_DELAY; + int granzIndex = (iL2Ticker % boundArray.length) - GRANZ_SYNTHESIS_DELAY; if (granzIndex < 0) { granzIndex += boundArray.length; } @@ -64,28 +64,28 @@ public void update(Process mod) { double split = (this.cell.getVolume() / this.volume); // Update daughter cell inflammation as a fraction of parent. - this.amts[IL2Rbga] = inflammation.amts[IL2Rbga] * split; - this.amts[IL2_IL2Rbg] = inflammation.amts[IL2_IL2Rbg] * split; - this.amts[IL2_IL2Rbga] = inflammation.amts[IL2_IL2Rbga] * split; - this.amts[IL2Rbg] = - IL2_RECEPTORS - this.amts[IL2Rbga] - this.amts[IL2_IL2Rbg] - this.amts[IL2_IL2Rbga]; - this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2Rbg] + this.amts[IL2_IL2Rbga]; - this.amts[IL2R_TOTAL] = this.amts[IL2Rbg] + this.amts[IL2Rbga]; + this.amts[IL2RBGa] = inflammation.amts[IL2RBGa] * split; + this.amts[IL2_IL2RBG] = inflammation.amts[IL2_IL2RBG] * split; + this.amts[IL2_IL2RBGa] = inflammation.amts[IL2_IL2RBGa] * split; + this.amts[IL2RBG] = + IL2_RECEPTORS - this.amts[IL2RBGa] - this.amts[IL2_IL2RBG] - this.amts[IL2_IL2RBGa]; + this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2RBG] + this.amts[IL2_IL2RBGa]; + this.amts[IL2R_TOTAL] = this.amts[IL2RBG] + this.amts[IL2RBGa]; this.amts[GRANZYME] = inflammation.amts[GRANZYME] * split; this.boundArray = (inflammation.boundArray).clone(); // Update parent cell with remaining fraction. - inflammation.amts[IL2Rbga] *= (1 - split); - inflammation.amts[IL2_IL2Rbg] *= (1 - split); - inflammation.amts[IL2_IL2Rbga] *= (1 - split); - inflammation.amts[IL2Rbg] = + inflammation.amts[IL2RBGa] *= (1 - split); + inflammation.amts[IL2_IL2RBG] *= (1 - split); + inflammation.amts[IL2_IL2RBGa] *= (1 - split); + inflammation.amts[IL2RBG] = IL2_RECEPTORS - - inflammation.amts[IL2Rbga] - - inflammation.amts[IL2_IL2Rbg] - - inflammation.amts[IL2_IL2Rbga]; + - inflammation.amts[IL2RBGa] + - inflammation.amts[IL2_IL2RBG] + - inflammation.amts[IL2_IL2RBGa]; inflammation.amts[IL2_INT_TOTAL] = - inflammation.amts[IL2_IL2Rbg] + inflammation.amts[IL2_IL2Rbga]; - inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2Rbg] + inflammation.amts[IL2Rbga]; + inflammation.amts[IL2_IL2RBG] + inflammation.amts[IL2_IL2RBGa]; + inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2RBG] + inflammation.amts[IL2RBGa]; inflammation.amts[GRANZYME] *= (1 - split); inflammation.volume *= (1 - split); } diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java index 79a949583..7cd36d2b0 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java @@ -129,7 +129,7 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { PatchProcessInflammation inflammation = (PatchProcessInflammation) cell.getProcess(Domain.INFLAMMATION); double[] boundArray = inflammation.boundArray; // [molecules] - int IL2Ticker = inflammation.IL2Ticker; + int IL2Ticker = inflammation.iL2Ticker; double IL2ReceptorsTotal = inflammation.IL2_RECEPTORS; int metaIndex = (IL2Ticker % boundArray.length) - timeDelay; diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java index 6a8276001..6ad116a92 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java @@ -78,7 +78,7 @@ public void testStepProcess() throws NoSuchFieldException, IllegalAccessExceptio inflammation.active = true; inflammation.activeTicker = 10; - inflammation.IL2Ticker = 10; + inflammation.iL2Ticker = 10; inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); @@ -119,7 +119,7 @@ public void testStepProcessActive() throws NoSuchFieldException, IllegalAccessEx inflammation.active = true; inflammation.activeTicker = 10; - inflammation.IL2Ticker = 10; + inflammation.iL2Ticker = 10; inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); @@ -154,7 +154,7 @@ public void testStepProcessInactive() throws NoSuchFieldException, IllegalAccess inflammation.active = false; inflammation.activeTicker = 10; - inflammation.IL2Ticker = 10; + inflammation.iL2Ticker = 10; inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); @@ -185,7 +185,7 @@ public void testStepProcessActiveTickerLessThanDelay() inflammation.active = true; inflammation.activeTicker = 10; - inflammation.IL2Ticker = 10; + inflammation.iL2Ticker = 10; inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); @@ -222,7 +222,7 @@ public void testStepProcessWithZeroIL2ProdRate() inflammation.active = true; inflammation.activeTicker = 10; - inflammation.IL2Ticker = 10; + inflammation.iL2Ticker = 10; inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); @@ -249,28 +249,28 @@ public void testStepProcessWithZeroIL2ProdRate() public void testUpdate() { inflammation = new PatchProcessInflammationCD4(mockCell); PatchProcessInflammationCD4 parentProcess = new PatchProcessInflammationCD4(mockCell); - parentProcess.amts[PatchProcessInflammationCD4.IL2Rbga] = 100; + parentProcess.amts[PatchProcessInflammationCD4.IL2RBGa] = 100; when(mockCell.getVolume()).thenReturn(cellVolume / 2); inflammation.update(parentProcess); - assertEquals(50, inflammation.amts[PatchProcessInflammationCD4.IL2Rbga]); - assertEquals(50, parentProcess.amts[PatchProcessInflammationCD4.IL2Rbga]); + assertEquals(50, inflammation.amts[PatchProcessInflammationCD4.IL2RBGa]); + assertEquals(50, parentProcess.amts[PatchProcessInflammationCD4.IL2RBGa]); } @Test public void testUpdateWithZeroVolume() { inflammation = new PatchProcessInflammationCD4(mockCell); PatchProcessInflammationCD4 parentProcess = new PatchProcessInflammationCD4(mockCell); - parentProcess.amts[PatchProcessInflammationCD4.IL2Rbga] = 100; + parentProcess.amts[PatchProcessInflammationCD4.IL2RBGa] = 100; when(mockCell.getVolume()).thenReturn(0.0); inflammation.update(parentProcess); - assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2Rbga]); - assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2_IL2Rbg]); - assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2_IL2Rbga]); + assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2RBGa]); + assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2_IL2RBG]); + assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2_IL2RBGa]); - assertEquals(100, parentProcess.amts[PatchProcessInflammationCD4.IL2Rbga]); + assertEquals(100, parentProcess.amts[PatchProcessInflammationCD4.IL2RBGa]); } } diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java index e6b5ade5a..f5f93e69d 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java @@ -68,7 +68,7 @@ public void testStepProcess() throws NoSuchFieldException, IllegalAccessExceptio inflammation = new PatchProcessInflammationCD8(mockCell); inflammation.active = true; inflammation.activeTicker = 10; - inflammation.IL2Ticker = 10; + inflammation.iL2Ticker = 10; inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); @@ -86,7 +86,7 @@ public void testStepProcessInactive() throws NoSuchFieldException, IllegalAccess inflammation = new PatchProcessInflammationCD8(mockCell); inflammation.active = false; inflammation.activeTicker = 10; - inflammation.IL2Ticker = 10; + inflammation.iL2Ticker = 10; inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); @@ -106,7 +106,7 @@ public void testStepProcessActiveTickerLessThanDelay() inflammation = new PatchProcessInflammationCD8(mockCell); inflammation.active = true; inflammation.activeTicker = 3; - inflammation.IL2Ticker = 10; + inflammation.iL2Ticker = 10; inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); From f1234145ff3d3021cf1e95ddc2592d557c6df36e Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 19:28:15 +0000 Subject: [PATCH 083/185] lining metabolism cart class --- .../process/PatchProcessMetabolismCART.java | 104 ++++++++++++------ 1 file changed, 69 insertions(+), 35 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java index 7cd36d2b0..33d662df8 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java @@ -8,61 +8,95 @@ import arcade.patch.agent.cell.PatchCell; import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.util.PatchEnums.Domain; - +/** + * Extension of {@link PatchProcessMetabolism} for CAR T-cell metabolism. + *

    + * {@code PatchProcessMetabolismCART} is adapted from {@code PatchProcessMetabolismComplex} and thus + * this module explicitly includes pyruvate intermediate between + * glycolysis and oxidative phosphorylation and glucose uptake is based on cell + * surface area. + * Metabolic preference between glycolysis and oxidative phosphorylation is + * controlled by the {@code META_PREF} parameter. + * The glycolysis pathway will compensate if there is not enough oxygen to meet + * energetic requirements through the oxidative phosphorylation pathway given + * the specified metabolic preference. + * The preference for glycolysis can be further increased due to IL-2 bound to the + * cell surface by a maximum of {@code META_PREF_IL2} parameter and by the T-cell's + * antigen-induced activation state by the {@code META_PREF_ACTIVE} parameter. + * The antigen-induced activation state can also increase the rate of uptake of + * glucose by the {@code GLUC_UPTAKE_RATE_ACTIVE} parameter and the fraction of + * glucose being used to make cell mass by the {@code FRAC_MASS_ACTIVE} parameter. + * The amount of IL-2 bound to the cell surface can also incrase the uptake rate of + * glucose by a max of the {@code GLUC_UPTAKE_RATE_IL2} parameter. + *

    + * {@code PatchProcessMetabolismCART} will increase cell mass (using specified fractions + * of internal glucose and pyruvate) if: + *

      + *
    • cell is dividing and less than double in size
    • + *
    • cell is below critical mass for maintenance
    • + *
    + * {@code PatchProcessMetabolismCART} will decrease cell mass if: + *
      + *
    • cell has negative energy levels indicating insufficient nutrients
    • + *
    • cell is above critical mass for maintenance
    • + *
    + *

    + * Internal pyruvate is removed through conversion to lactate. + */ public class PatchProcessMetabolismCART extends PatchProcessMetabolism { - /** ID for pyruvate */ + /** ID for pyruvate. */ public static final int PYRUVATE = 1; /** Flag indicating T-cell's antigen induced activation state. */ private boolean active; - /** Metabolic preference for glycolysis over oxidative phosphorylation */ + /** Metabolic preference for glycolysis over oxidative phosphorylation. */ private final double metaPref; - /** Minimal cell mass */ + /** Minimal cell mass. */ private final double fracMass; /** Fraction of internal glucose/pyruvate converted to mass. */ private final double conversionFraction; - /** Preference for glucose over pyruvate for mass */ + /** Preference for glucose over pyruvate for mass. */ private final double ratioGlucosePyruvate; - /** Rate of lactate production */ + /** Rate of lactate production. */ private final double lactateRate; - /** Rate of autophagy */ + /** Rate of autophagy. */ private final double autophagyRate; - /** Rate of glucose uptake */ + /** Rate of glucose uptake. */ private final double glucUptakeRate; - /** Max incrase in metabolic preference for glycolysis over oxidative phosphorylation */ - private final double metabolicPreference_IL2; + /** Max incrase in metabolic preference for glycolysis over oxidative phosphorylation. */ + private final double metabolicPreferenceIL2; - /** Increase in rate of glucose uptake due antigen-induced activation */ - private final double metabolicPreference_active; + /** Increase in rate of glucose uptake due antigen-induced activation. */ + private final double metabolicPreferenceActive; - /** Max increase in rate of glucose uptake due to IL-2 bound to surface */ - private final double glucoseUptakeRate_IL2; + /** Max increase in rate of glucose uptake due to IL-2 bound to surface. */ + private final double glucoseUptakeRateIL2; /** Increase in rate of glucose uptake due to antigen-induced activation. */ - private final double glucoseUptakeRate_active; + private final double glucoseUptakeRateActive; /** Increase in fraction of glucose used for cell mass due to antigen-induced activation. */ - private final double minimumMassFraction_active; + private final double minimumMassFractionActive; /** Time delay for changes in metabolism. */ private final int timeDelay; - /** Metabolic preference value after stepping through the process. For testing purposes only */ + /** Metabolic preference value after stepping through the process. For testing purposes only. */ private double finalMetabolicPreference; - /** Glucose uptake rate value after stepping through the process. For testing purposes only */ + /** Glucose uptake rate value after stepping through the process. For testing purposes only. */ private double finalGlucoseUptakeRate; - /** Minimum mass fraction value after stepping through the process. For testing purposes only */ + /** Minimum mass fraction value after stepping through the process. For testing purposes only. */ private double finalMinimumMassFraction; /** @@ -105,11 +139,11 @@ public PatchProcessMetabolismCART(PatchCell cell) { autophagyRate = parameters.getDouble("metabolism/AUTOPHAGY_RATE"); glucUptakeRate = parameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE"); - metabolicPreference_IL2 = parameters.getDouble("metabolism/META_PREF_IL2"); - metabolicPreference_active = parameters.getDouble("metabolism/META_PREF_ACTIVE"); - glucoseUptakeRate_IL2 = parameters.getDouble("metabolism/GLUC_UPTAKE_RATE_IL2"); - glucoseUptakeRate_active = parameters.getDouble("metabolism/GLUC_UPTAKE_RATE_ACTIVE"); - minimumMassFraction_active = parameters.getDouble("metabolism/FRAC_MASS_ACTIVE"); + metabolicPreferenceIL2 = parameters.getDouble("metabolism/META_PREF_IL2"); + metabolicPreferenceActive = parameters.getDouble("metabolism/META_PREF_ACTIVE"); + glucoseUptakeRateIL2 = parameters.getDouble("metabolism/GLUC_UPTAKE_RATE_IL2"); + glucoseUptakeRateActive = parameters.getDouble("metabolism/GLUC_UPTAKE_RATE_ACTIVE"); + minimumMassFractionActive = parameters.getDouble("metabolism/FRAC_MASS_ACTIVE"); timeDelay = (int) parameters.getDouble("metabolism/META_SWITCH_DELAY"); // Initial internal concentrations. @@ -129,10 +163,10 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { PatchProcessInflammation inflammation = (PatchProcessInflammation) cell.getProcess(Domain.INFLAMMATION); double[] boundArray = inflammation.boundArray; // [molecules] - int IL2Ticker = inflammation.iL2Ticker; - double IL2ReceptorsTotal = inflammation.IL2_RECEPTORS; + int iL2Ticker = inflammation.iL2Ticker; + double iL2ReceptorsTotal = inflammation.IL2_RECEPTORS; - int metaIndex = (IL2Ticker % boundArray.length) - timeDelay; + int metaIndex = (iL2Ticker % boundArray.length) - timeDelay; if (metaIndex < 0) { metaIndex += boundArray.length; } @@ -141,9 +175,9 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { // Calculate metabolic preference and glucose uptake rate // as a function of base values plus impact of IL-2 bound to surface. double metabolicPreference = - metaPref + (metabolicPreference_IL2 * (priorIL2meta / IL2ReceptorsTotal)); + metaPref + (metabolicPreferenceIL2 * (priorIL2meta / iL2ReceptorsTotal)); double glucoseUptakeRate = - glucUptakeRate + (glucoseUptakeRate_IL2 * (priorIL2meta / IL2ReceptorsTotal)); + glucUptakeRate + (glucoseUptakeRateIL2 * (priorIL2meta / iL2ReceptorsTotal)); double minimumMassFraction = fracMass; // Check active status @@ -153,9 +187,9 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { // Add metabolic preference and glucose uptake rate depdendent on // antigen-induced cell activation if cell is activated. if (active && activeTicker >= timeDelay) { - metabolicPreference += metabolicPreference_active; - glucoseUptakeRate += glucoseUptakeRate_active; - minimumMassFraction += minimumMassFraction_active; + metabolicPreference += metabolicPreferenceActive; + glucoseUptakeRate += glucoseUptakeRateActive; + minimumMassFraction += minimumMassFractionActive; } // Take up glucose from environment, relative to glucose gradient. @@ -277,7 +311,7 @@ public void update(Process process) { /** * Returns final value of metabolic preference after stepping process Exists for testing - * purposes only + * purposes only. * * @return final value of the metabolic preference */ @@ -287,7 +321,7 @@ public double getFinalMetabolicPreference() { /** * Returns final value of glucose uptake rate after stepping process Exists for testing purposes - * only + * only. * * @return final value of glucose uptake rate */ @@ -297,7 +331,7 @@ public double getFinalGlucoseUptakeRate() { /** * Returns final value of minimum mass fraction after stepping process Exists for testing - * purposes only + * purposes only. * * @return final value of min mass fraction */ From 42bec69869653d1af9e8342aa81cbd7a73ae0864 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 19:31:57 +0000 Subject: [PATCH 084/185] changing variable casing of inflammation class variables --- .../agent/process/PatchProcessInflammation.java | 14 +++++++------- .../agent/process/PatchProcessInflammationCD4.java | 6 +++--- .../agent/process/PatchProcessInflammationCD8.java | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index 03619788a..af7117792 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -112,10 +112,10 @@ public abstract class PatchProcessInflammation extends PatchProcess { protected double[] boundArray; /** Distance outward from surface a cell can sense. */ - protected final double SHELL_THICKNESS; + protected final double shellThickness; /** Total 2-complex receptors. */ - protected final double IL2_RECEPTORS; + protected final double iL2Receptors; /** * Creates an {@code Inflammation} module for the given {@link PatchCellCART}. @@ -138,8 +138,8 @@ public PatchProcessInflammation(PatchCellCART c) { // Set parameters. Parameters parameters = cell.getParameters(); - this.SHELL_THICKNESS = parameters.getDouble("inflammation/SHELL_THICKNESS"); - this.IL2_RECEPTORS = parameters.getDouble("inflammation/IL2_RECEPTORS"); + this.shellThickness= parameters.getDouble("inflammation/SHELL_THICKNESS"); + this.iL2Receptors = parameters.getDouble("inflammation/IL2_RECEPTORS"); this.iL2BindingOnRateMin = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MIN"); this.iL2BindingOnRateMax = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MAX"); this.iL2BindingOffRate = parameters.getDouble("inflammation/IL2_BINDING_OFF_RATE"); @@ -149,8 +149,8 @@ public PatchProcessInflammation(PatchCellCART c) { // Initial amounts of each species, all in molecules/cell. amts = new double[NUM_COMPONENTS]; amts[IL2_INT_TOTAL] = 0; - amts[IL2R_TOTAL] = IL2_RECEPTORS; - amts[IL2RBG] = IL2_RECEPTORS; + amts[IL2R_TOTAL] = iL2Receptors; + amts[IL2RBG] = iL2Receptors; amts[IL2RBGa] = 0; amts[IL2_IL2RBG] = 0; amts[IL2_IL2RBGa] = 0; @@ -281,7 +281,7 @@ private void updateExternal(Simulation sim) { public void step(MersenneTwisterFast random, Simulation sim) { // Calculate shell volume 2 um outside of cell. double radCell = Math.cbrt((3.0 / 4.0) * (1.0 / Math.PI) * volume); - double radShell = radCell + SHELL_THICKNESS; + double radShell = radCell + shellThickness; double volShell = volume * (((radShell * radShell * radShell) / (radCell * radCell * radCell)) - 1.0); f = volShell / loc.getVolume(); diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java index 1aeeca2fb..d0e23e92e 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java @@ -62,7 +62,7 @@ public void stepProcess(MersenneTwisterFast random, Simulation sim) { prodIndex += boundArray.length; } priorIL2prod = boundArray[prodIndex]; - IL2ProdRate = IL2_PROD_RATE_IL2 * (priorIL2prod / IL2_RECEPTORS); + IL2ProdRate = IL2_PROD_RATE_IL2 * (priorIL2prod / iL2Receptors); // Add IL-2 production rate dependent on antigen-induced // cell activation if cell is activated. @@ -96,7 +96,7 @@ public void update(Process mod) { this.amts[IL2_IL2RBG] = inflammation.amts[IL2_IL2RBG] * split; this.amts[IL2_IL2RBGa] = inflammation.amts[IL2_IL2RBGa] * split; this.amts[IL2RBG] = - IL2_RECEPTORS - this.amts[IL2RBGa] - this.amts[IL2_IL2RBG] - this.amts[IL2_IL2RBGa]; + iL2Receptors - this.amts[IL2RBGa] - this.amts[IL2_IL2RBG] - this.amts[IL2_IL2RBGa]; this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2RBG] + this.amts[IL2_IL2RBGa]; this.amts[IL2R_TOTAL] = this.amts[IL2RBG] + this.amts[IL2RBGa]; this.boundArray = (inflammation.boundArray).clone(); @@ -106,7 +106,7 @@ public void update(Process mod) { inflammation.amts[IL2_IL2RBG] *= (1 - split); inflammation.amts[IL2_IL2RBGa] *= (1 - split); inflammation.amts[IL2RBG] = - IL2_RECEPTORS + iL2Receptors - inflammation.amts[IL2RBGa] - inflammation.amts[IL2_IL2RBG] - inflammation.amts[IL2_IL2RBGa]; diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index 79f0527ed..3fd0d5108 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -49,7 +49,7 @@ public void stepProcess(MersenneTwisterFast random, Simulation sim) { priorIL2granz = boundArray[granzIndex]; if (active && activeTicker > GRANZ_SYNTHESIS_DELAY) { - amts[GRANZYME] += GRANZ_PER_IL2 * (priorIL2granz / IL2_RECEPTORS); + amts[GRANZYME] += GRANZ_PER_IL2 * (priorIL2granz / iL2Receptors); } // Update environment. @@ -68,7 +68,7 @@ public void update(Process mod) { this.amts[IL2_IL2RBG] = inflammation.amts[IL2_IL2RBG] * split; this.amts[IL2_IL2RBGa] = inflammation.amts[IL2_IL2RBGa] * split; this.amts[IL2RBG] = - IL2_RECEPTORS - this.amts[IL2RBGa] - this.amts[IL2_IL2RBG] - this.amts[IL2_IL2RBGa]; + iL2Receptors - this.amts[IL2RBGa] - this.amts[IL2_IL2RBG] - this.amts[IL2_IL2RBGa]; this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2RBG] + this.amts[IL2_IL2RBGa]; this.amts[IL2R_TOTAL] = this.amts[IL2RBG] + this.amts[IL2RBGa]; this.amts[GRANZYME] = inflammation.amts[GRANZYME] * split; @@ -79,7 +79,7 @@ public void update(Process mod) { inflammation.amts[IL2_IL2RBG] *= (1 - split); inflammation.amts[IL2_IL2RBGa] *= (1 - split); inflammation.amts[IL2RBG] = - IL2_RECEPTORS + iL2Receptors - inflammation.amts[IL2RBGa] - inflammation.amts[IL2_IL2RBG] - inflammation.amts[IL2_IL2RBGa]; From 9ae3078e458cda3029d996c9c1d3b73287b70097 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 19:32:22 +0000 Subject: [PATCH 085/185] spotlessApply linting --- .../process/PatchProcessInflammation.java | 10 ++-- .../process/PatchProcessMetabolismCART.java | 58 ++++++++++--------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index af7117792..e48f8ec4f 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -102,7 +102,7 @@ public abstract class PatchProcessInflammation extends PatchProcess { /** Flag marking if cell is activated via antigen-induced activation. */ protected boolean active; - /** Time since cell first bound IL-2 .*/ + /** Time since cell first bound IL-2 . */ protected int iL2Ticker; /** Time since cell became activated via antigen-induced activation. */ @@ -138,7 +138,7 @@ public PatchProcessInflammation(PatchCellCART c) { // Set parameters. Parameters parameters = cell.getParameters(); - this.shellThickness= parameters.getDouble("inflammation/SHELL_THICKNESS"); + this.shellThickness = parameters.getDouble("inflammation/SHELL_THICKNESS"); this.iL2Receptors = parameters.getDouble("inflammation/IL2_RECEPTORS"); this.iL2BindingOnRateMin = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MIN"); this.iL2BindingOnRateMax = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MAX"); @@ -175,10 +175,8 @@ public PatchProcessInflammation(PatchCellCART c) { (t, y) -> { double[] dydt = new double[NUM_COMPONENTS]; - double kOn2 = - iL2BindingOnRateMin / loc.getVolume() / 60 / STEP_DIVIDER; - double kOn3 = - iL2BindingOnRateMax / loc.getVolume() / 60 / STEP_DIVIDER; + double kOn2 = iL2BindingOnRateMin / loc.getVolume() / 60 / STEP_DIVIDER; + double kOn3 = iL2BindingOnRateMax / loc.getVolume() / 60 / STEP_DIVIDER; double kOff = iL2BindingOffRate / 60 / STEP_DIVIDER; dydt[IL2_EXT] = diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java index 33d662df8..2f8e203a0 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java @@ -8,40 +8,40 @@ import arcade.patch.agent.cell.PatchCell; import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.util.PatchEnums.Domain; + /** * Extension of {@link PatchProcessMetabolism} for CAR T-cell metabolism. - *

    - * {@code PatchProcessMetabolismCART} is adapted from {@code PatchProcessMetabolismComplex} and thus - * this module explicitly includes pyruvate intermediate between - * glycolysis and oxidative phosphorylation and glucose uptake is based on cell - * surface area. - * Metabolic preference between glycolysis and oxidative phosphorylation is - * controlled by the {@code META_PREF} parameter. - * The glycolysis pathway will compensate if there is not enough oxygen to meet - * energetic requirements through the oxidative phosphorylation pathway given - * the specified metabolic preference. - * The preference for glycolysis can be further increased due to IL-2 bound to the - * cell surface by a maximum of {@code META_PREF_IL2} parameter and by the T-cell's - * antigen-induced activation state by the {@code META_PREF_ACTIVE} parameter. - * The antigen-induced activation state can also increase the rate of uptake of - * glucose by the {@code GLUC_UPTAKE_RATE_ACTIVE} parameter and the fraction of - * glucose being used to make cell mass by the {@code FRAC_MASS_ACTIVE} parameter. - * The amount of IL-2 bound to the cell surface can also incrase the uptake rate of - * glucose by a max of the {@code GLUC_UPTAKE_RATE_IL2} parameter. - *

    - * {@code PatchProcessMetabolismCART} will increase cell mass (using specified fractions - * of internal glucose and pyruvate) if: + * + *

    {@code PatchProcessMetabolismCART} is adapted from {@code PatchProcessMetabolismComplex} and + * thus this module explicitly includes pyruvate intermediate between glycolysis and oxidative + * phosphorylation and glucose uptake is based on cell surface area. Metabolic preference between + * glycolysis and oxidative phosphorylation is controlled by the {@code META_PREF} parameter. The + * glycolysis pathway will compensate if there is not enough oxygen to meet energetic requirements + * through the oxidative phosphorylation pathway given the specified metabolic preference. The + * preference for glycolysis can be further increased due to IL-2 bound to the cell surface by a + * maximum of {@code META_PREF_IL2} parameter and by the T-cell's antigen-induced activation state + * by the {@code META_PREF_ACTIVE} parameter. The antigen-induced activation state can also increase + * the rate of uptake of glucose by the {@code GLUC_UPTAKE_RATE_ACTIVE} parameter and the fraction + * of glucose being used to make cell mass by the {@code FRAC_MASS_ACTIVE} parameter. The amount of + * IL-2 bound to the cell surface can also incrase the uptake rate of glucose by a max of the {@code + * GLUC_UPTAKE_RATE_IL2} parameter. + * + *

    {@code PatchProcessMetabolismCART} will increase cell mass (using specified fractions of + * internal glucose and pyruvate) if: + * *

      - *
    • cell is dividing and less than double in size
    • - *
    • cell is below critical mass for maintenance
    • + *
    • cell is dividing and less than double in size + *
    • cell is below critical mass for maintenance *
    + * * {@code PatchProcessMetabolismCART} will decrease cell mass if: + * *
      - *
    • cell has negative energy levels indicating insufficient nutrients
    • - *
    • cell is above critical mass for maintenance
    • + *
    • cell has negative energy levels indicating insufficient nutrients + *
    • cell is above critical mass for maintenance *
    - *

    - * Internal pyruvate is removed through conversion to lactate. + * + *

    Internal pyruvate is removed through conversion to lactate. */ public class PatchProcessMetabolismCART extends PatchProcessMetabolism { @@ -96,7 +96,9 @@ public class PatchProcessMetabolismCART extends PatchProcessMetabolism { /** Glucose uptake rate value after stepping through the process. For testing purposes only. */ private double finalGlucoseUptakeRate; - /** Minimum mass fraction value after stepping through the process. For testing purposes only. */ + /** + * Minimum mass fraction value after stepping through the process. For testing purposes only. + */ private double finalMinimumMassFraction; /** From 2b18d598baf9d3da20be12f02959c32b0cfe2b36 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 19:35:29 +0000 Subject: [PATCH 086/185] fixing metabolism variable name swap --- src/arcade/patch/agent/process/PatchProcessMetabolismCART.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java index 2f8e203a0..b7729af8a 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java @@ -166,7 +166,7 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { (PatchProcessInflammation) cell.getProcess(Domain.INFLAMMATION); double[] boundArray = inflammation.boundArray; // [molecules] int iL2Ticker = inflammation.iL2Ticker; - double iL2ReceptorsTotal = inflammation.IL2_RECEPTORS; + double iL2ReceptorsTotal = inflammation.iL2Receptors; int metaIndex = (iL2Ticker % boundArray.length) - timeDelay; if (metaIndex < 0) { From b51417798adc65a064d8ca930b0ecb6fa93873e8 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 19:38:52 +0000 Subject: [PATCH 087/185] adding variable swap names in cd4 and cd8 tests --- .../agent/process/PatchProcessInflammationCD4Test.java | 10 +++++----- .../agent/process/PatchProcessInflammationCD8Test.java | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java index 6ad116a92..a482fc296 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java @@ -87,7 +87,7 @@ public void testStepProcess() throws NoSuchFieldException, IllegalAccessExceptio il2ProdRateIL2.setAccessible(true); il2ProdRateIL2.set(inflammation, 0.05); - Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + Field receptors = PatchProcessInflammation.class.getDeclaredField("iL2Receptors"); receptors.setAccessible(true); receptors.set(inflammation, 5000); @@ -128,7 +128,7 @@ public void testStepProcessActive() throws NoSuchFieldException, IllegalAccessEx il2ProdRateIL2.setAccessible(true); il2ProdRateIL2.set(inflammation, 0.05); - Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + Field receptors = PatchProcessInflammation.class.getDeclaredField("iL2Receptors"); receptors.setAccessible(true); receptors.set(inflammation, 5000); @@ -163,7 +163,7 @@ public void testStepProcessInactive() throws NoSuchFieldException, IllegalAccess il2ProdRateIL2.setAccessible(true); il2ProdRateIL2.set(inflammation, 0.05); - Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + Field receptors = PatchProcessInflammation.class.getDeclaredField("iL2Receptors"); receptors.setAccessible(true); receptors.set(inflammation, 5000); @@ -194,7 +194,7 @@ public void testStepProcessActiveTickerLessThanDelay() il2ProdRateIL2.setAccessible(true); il2ProdRateIL2.set(inflammation, 0.05); - Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + Field receptors = PatchProcessInflammation.class.getDeclaredField("iL2Receptors"); receptors.setAccessible(true); receptors.set(inflammation, 5000); @@ -226,7 +226,7 @@ public void testStepProcessWithZeroIL2ProdRate() inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); - Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + Field receptors = PatchProcessInflammation.class.getDeclaredField("iL2Receptors"); receptors.setAccessible(true); receptors.set(inflammation, 5000); diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java index f5f93e69d..895c1d368 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java @@ -72,7 +72,7 @@ public void testStepProcess() throws NoSuchFieldException, IllegalAccessExceptio inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); - Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + Field receptors = PatchProcessInflammation.class.getDeclaredField("iL2Receptors"); receptors.setAccessible(true); receptors.set(inflammation, 5000); @@ -90,7 +90,7 @@ public void testStepProcessInactive() throws NoSuchFieldException, IllegalAccess inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); - Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + Field receptors = PatchProcessInflammation.class.getDeclaredField("iL2Receptors"); receptors.setAccessible(true); receptors.set(inflammation, 5000); @@ -110,7 +110,7 @@ public void testStepProcessActiveTickerLessThanDelay() inflammation.boundArray = new double[180]; Arrays.fill(inflammation.boundArray, 10000); - Field receptors = PatchProcessInflammation.class.getDeclaredField("IL2_RECEPTORS"); + Field receptors = PatchProcessInflammation.class.getDeclaredField("iL2Receptors"); receptors.setAccessible(true); receptors.set(inflammation, 5000); From 7c310161e558a9b6a9d7d958a831737d3999386a Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 19:42:54 +0000 Subject: [PATCH 088/185] changing variable names in metabolism class --- .../agent/process/PatchProcessMetabolismCARTTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java index e11888c9b..3a2b6274e 100644 --- a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -90,27 +90,27 @@ public void testConstructorInitializesFields() assertEquals(1.0, glucUptakeRateField.get(metabolism)); Field metabolicPreference_IL2Field = - PatchProcessMetabolismCART.class.getDeclaredField("metabolicPreference_IL2"); + PatchProcessMetabolismCART.class.getDeclaredField("metabolicPreferenceIL2"); metabolicPreference_IL2Field.setAccessible(true); assertEquals(1.0, metabolicPreference_IL2Field.get(metabolism)); Field metabolicPreference_activeField = - PatchProcessMetabolismCART.class.getDeclaredField("metabolicPreference_active"); + PatchProcessMetabolismCART.class.getDeclaredField("metabolicPreferenceActive"); metabolicPreference_activeField.setAccessible(true); assertEquals(1.0, metabolicPreference_activeField.get(metabolism)); Field glucoseUptakeRate_IL2Field = - PatchProcessMetabolismCART.class.getDeclaredField("glucoseUptakeRate_IL2"); + PatchProcessMetabolismCART.class.getDeclaredField("glucoseUptakeRateIL2"); glucoseUptakeRate_IL2Field.setAccessible(true); assertEquals(1.0, glucoseUptakeRate_IL2Field.get(metabolism)); Field glucoseUptakeRate_activeField = - PatchProcessMetabolismCART.class.getDeclaredField("glucoseUptakeRate_active"); + PatchProcessMetabolismCART.class.getDeclaredField("glucoseUptakeRateActive"); glucoseUptakeRate_activeField.setAccessible(true); assertEquals(1.0, glucoseUptakeRate_activeField.get(metabolism)); Field minimumMassFraction_activeField = - PatchProcessMetabolismCART.class.getDeclaredField("minimumMassFraction_active"); + PatchProcessMetabolismCART.class.getDeclaredField("minimumMassFractionActive"); minimumMassFraction_activeField.setAccessible(true); assertEquals(1.0, minimumMassFraction_activeField.get(metabolism)); From b27526098eda647bbeb55b1280c5437c60a9bac0 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 19:59:47 +0000 Subject: [PATCH 089/185] missing javadoc for inflammation method --- src/arcade/patch/agent/process/PatchProcessInflammation.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index e48f8ec4f..982aebff1 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -248,6 +248,7 @@ public double getInternal(String key) { * Sets the internal amounts of requested key. * * @param key the requested substance + * @param val the amount of the requested substance */ public void setInternal(String key, double val) { amts[names.indexOf(key)] = val; From 259d4b4a319d7de8d3931ac59347f1e34f3996ee Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 20:00:57 +0000 Subject: [PATCH 090/185] adding new lines to variable defs in metabolism class --- .../patch/agent/process/PatchProcessMetabolismCARTTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java index 3a2b6274e..ba6bb903b 100644 --- a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -16,9 +16,13 @@ public class PatchProcessMetabolismCARTTest { private PatchCellCART mockCell; + private Parameters mockParameters; + private PatchProcessMetabolismCART metabolism; + private PatchLocation mockLocation; + private double cellVolume; static class inflammationMock extends PatchProcessInflammation { From 2eaef3815cf458d2525d63e5c3687d49eee35169 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 20:02:29 +0000 Subject: [PATCH 091/185] changing variable casing in metabolism tests --- .../PatchProcessMetabolismCARTTest.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java index ba6bb903b..683d98998 100644 --- a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -22,7 +22,7 @@ public class PatchProcessMetabolismCARTTest { private PatchProcessMetabolismCART metabolism; private PatchLocation mockLocation; - + private double cellVolume; static class inflammationMock extends PatchProcessInflammation { @@ -93,30 +93,30 @@ public void testConstructorInitializesFields() glucUptakeRateField.setAccessible(true); assertEquals(1.0, glucUptakeRateField.get(metabolism)); - Field metabolicPreference_IL2Field = + Field metabolicPreferenceIL2Field = PatchProcessMetabolismCART.class.getDeclaredField("metabolicPreferenceIL2"); - metabolicPreference_IL2Field.setAccessible(true); - assertEquals(1.0, metabolicPreference_IL2Field.get(metabolism)); + metabolicPreferenceIL2Field.setAccessible(true); + assertEquals(1.0, metabolicPreferenceIL2Field.get(metabolism)); - Field metabolicPreference_activeField = + Field metabolicPreferenceActiveField = PatchProcessMetabolismCART.class.getDeclaredField("metabolicPreferenceActive"); - metabolicPreference_activeField.setAccessible(true); - assertEquals(1.0, metabolicPreference_activeField.get(metabolism)); + metabolicPreferenceActiveField.setAccessible(true); + assertEquals(1.0, metabolicPreferenceActiveField.get(metabolism)); - Field glucoseUptakeRate_IL2Field = + Field glucoseUptakeRateIL2Field = PatchProcessMetabolismCART.class.getDeclaredField("glucoseUptakeRateIL2"); - glucoseUptakeRate_IL2Field.setAccessible(true); - assertEquals(1.0, glucoseUptakeRate_IL2Field.get(metabolism)); + glucoseUptakeRateIL2Field.setAccessible(true); + assertEquals(1.0, glucoseUptakeRateIL2Field.get(metabolism)); - Field glucoseUptakeRate_activeField = + Field glucoseUptakeRateActiveField = PatchProcessMetabolismCART.class.getDeclaredField("glucoseUptakeRateActive"); - glucoseUptakeRate_activeField.setAccessible(true); - assertEquals(1.0, glucoseUptakeRate_activeField.get(metabolism)); + glucoseUptakeRateActiveField.setAccessible(true); + assertEquals(1.0, glucoseUptakeRateActiveField.get(metabolism)); - Field minimumMassFraction_activeField = + Field minimumMassFractionActiveField = PatchProcessMetabolismCART.class.getDeclaredField("minimumMassFractionActive"); - minimumMassFraction_activeField.setAccessible(true); - assertEquals(1.0, minimumMassFraction_activeField.get(metabolism)); + minimumMassFractionActiveField.setAccessible(true); + assertEquals(1.0, minimumMassFractionActiveField.get(metabolism)); Field timeDelayField = PatchProcessMetabolismCART.class.getDeclaredField("timeDelay"); timeDelayField.setAccessible(true); From ad870e7317ef9279757e3338bc058843a3518b5a Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 20:04:20 +0000 Subject: [PATCH 092/185] adding newlines and variable casing to inflammation tests --- .../agent/process/PatchProcessInflammationTest.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java index ff024a479..3b9f1181e 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java @@ -18,13 +18,17 @@ public class PatchProcessInflammationTest { private PatchProcessInflammation inflammation; + private PatchCellCART mockCell; + private Parameters mockParameters; + private Simulation mockSimulation; + private MersenneTwisterFast mockRandom; - static class inflammationMock extends PatchProcessInflammation { - public inflammationMock(PatchCellCART c) { + static class InflammationMock extends PatchProcessInflammation { + InflammationMock(PatchCellCART c) { super(c); } @@ -52,7 +56,7 @@ public void setUp() { Mockito.when(mockParameters.getInt(anyString())).thenReturn(1); Mockito.when(mockSimulation.getLattice(anyString())).thenReturn(mockLattice); doNothing().when(mockLattice).setValue(any(PatchLocation.class), anyDouble()); - inflammation = new inflammationMock(mockCell); + inflammation = new InflammationMock(mockCell); } @Test From 5bb1c8636e614df95acb8692530f1b9e8b530f31 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 16 Jan 2025 20:12:35 +0000 Subject: [PATCH 093/185] adding new lines to cart cell test variable declaration --- test/arcade/patch/agent/cell/PatchCellCARTTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java index d4ade94bd..65d3e72ea 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTTest.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -20,9 +20,13 @@ import static arcade.core.ARCADETestUtilities.randomIntBetween; public class PatchCellCARTTest { + private PatchCellCART patchCellCART; + private Parameters parameters; + private PatchLocation location; + private PatchCellContainer container; static class PatchCellMock extends PatchCellCART { From 3e14469b67e3fec9b92774b6a9d696e089d63c94 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 21 Jan 2025 19:28:49 +0000 Subject: [PATCH 094/185] null parameters should not be silently failing --- src/arcade/patch/agent/cell/PatchCell.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 9dcd23d04..3690c7b9d 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -193,13 +193,12 @@ public PatchCell( // Add cell processes. processes = new HashMap<>(); MiniBox processBox = parameters.filter("(PROCESS)"); - if (processBox != null) { - for (String processKey : processBox.getKeys()) { - ProcessDomain domain = Domain.valueOf(processKey); - String version = processBox.get(processKey); - Process process = makeProcess(domain, version); - processes.put(domain, process); - } + + for (String processKey : processBox.getKeys()) { + ProcessDomain domain = Domain.valueOf(processKey); + String version = processBox.get(processKey); + Process process = makeProcess(domain, version); + processes.put(domain, process); } } From 289c7c3fa2a5a094733d571b09d9042b31626256 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 21 Jan 2025 19:58:30 +0000 Subject: [PATCH 095/185] changing tests to handle null parameters for processes and such --- test/arcade/patch/agent/cell/PatchCellCARTTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java index 65d3e72ea..1c23c2100 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTTest.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -1,6 +1,8 @@ package arcade.patch.agent.cell; import java.util.ArrayList; + +import arcade.core.util.MiniBox; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import sim.engine.SimState; @@ -55,7 +57,7 @@ public void step(SimState state) {} @BeforeEach public void setUp() throws NoSuchFieldException, IllegalAccessException { - parameters = mock(Parameters.class); + parameters = spy(new Parameters(new MiniBox(), null, null)); location = mock(PatchLocation.class); doReturn(0.0).when(parameters).getDouble(any(String.class)); From 0e153c1eb5460aa39ed183be798997d3764f52f5 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 21 Jan 2025 20:03:48 +0000 Subject: [PATCH 096/185] changing cd4 tests to accomadate for null parameters --- test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index 846223661..9bd6e3c56 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -1,6 +1,8 @@ package arcade.patch.agent.cell; import java.lang.reflect.Field; + +import arcade.core.util.MiniBox; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import sim.engine.Schedule; @@ -32,7 +34,7 @@ public class PatchCellCARTCD4Test { @BeforeEach public void setUp() throws NoSuchFieldException, IllegalAccessException { - parameters = mock(Parameters.class); + parameters = spy(new Parameters(new MiniBox(), null, null)); location = mock(PatchLocation.class); int id = 1; @@ -59,7 +61,8 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { height, criticalVolume, criticalHeight); - + doReturn(0.0).when(parameters).getDouble(any(String.class)); + doReturn(0).when(parameters).getInt(any(String.class)); when(parameters.getDouble("HETEROGENEITY")).thenReturn(0.0); when(parameters.getDouble("ENERGY_THRESHOLD")).thenReturn(1.0); From 38af247464b83cdfae5800f4ee8a6294528f513a Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 21 Jan 2025 20:04:53 +0000 Subject: [PATCH 097/185] changing cd8 tests to accomadate for null parameters --- test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index 1fa132557..5d9478ae9 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -1,6 +1,8 @@ package arcade.patch.agent.cell; import java.lang.reflect.Field; + +import arcade.core.util.MiniBox; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import sim.engine.Schedule; @@ -32,7 +34,7 @@ public class PatchCellCARTCD8Test { @BeforeEach public void setUp() throws NoSuchFieldException, IllegalAccessException { - parameters = mock(Parameters.class); + parameters = spy(new Parameters(new MiniBox(), null, null)); location = mock(PatchLocation.class); int id = 1; @@ -59,7 +61,8 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { height, criticalVolume, criticalHeight); - + doReturn(0.0).when(parameters).getDouble(any(String.class)); + doReturn(0).when(parameters).getInt(any(String.class)); when(parameters.getDouble("HETEROGENEITY")).thenReturn(0.0); when(parameters.getDouble("ENERGY_THRESHOLD")).thenReturn(1.0); From b4a50ce5443ba0353b87b6d4813cc9b9880be191 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 21 Jan 2025 20:06:12 +0000 Subject: [PATCH 098/185] changing reset tests to accomadate for null parameters: --- test/arcade/patch/agent/action/PatchActionResetTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/arcade/patch/agent/action/PatchActionResetTest.java b/test/arcade/patch/agent/action/PatchActionResetTest.java index cf4cf966e..1fd27627b 100644 --- a/test/arcade/patch/agent/action/PatchActionResetTest.java +++ b/test/arcade/patch/agent/action/PatchActionResetTest.java @@ -1,5 +1,6 @@ package arcade.patch.agent.action; +import arcade.core.util.MiniBox; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import sim.engine.Schedule; @@ -28,9 +29,11 @@ public class PatchActionResetTest { public void setUp() { MersenneTwisterFast mockRandom = mock(MersenneTwisterFast.class); Series mockSeries = mock(Series.class); - Parameters mockParameters = mock(Parameters.class); + Parameters mockParameters = spy(new Parameters(new MiniBox(), null, null)); PatchLocation mockLocation = mock(PatchLocation.class); + doReturn(0.0).when(mockParameters).getDouble(any(String.class)); + doReturn(0).when(mockParameters).getInt(any(String.class)); when(mockParameters.getInt("BOUND_TIME")).thenReturn(10); when(mockParameters.getInt("BOUND_RANGE")).thenReturn(5); when(mockRandom.nextInt()).thenReturn(1); From 5db3cd8a46e6973c1f3b3c4bd089797b03a58226 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 21 Jan 2025 20:06:34 +0000 Subject: [PATCH 099/185] linting --- test/arcade/patch/agent/action/PatchActionResetTest.java | 2 +- test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java | 3 +-- test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java | 3 +-- test/arcade/patch/agent/cell/PatchCellCARTTest.java | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/test/arcade/patch/agent/action/PatchActionResetTest.java b/test/arcade/patch/agent/action/PatchActionResetTest.java index 1fd27627b..f794fe85e 100644 --- a/test/arcade/patch/agent/action/PatchActionResetTest.java +++ b/test/arcade/patch/agent/action/PatchActionResetTest.java @@ -1,12 +1,12 @@ package arcade.patch.agent.action; -import arcade.core.util.MiniBox; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import sim.engine.Schedule; import sim.engine.SimState; import ec.util.MersenneTwisterFast; import arcade.core.sim.Series; +import arcade.core.util.MiniBox; import arcade.core.util.Parameters; import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.agent.cell.PatchCellCARTCD4; diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index 9bd6e3c56..c424bbd11 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -1,14 +1,13 @@ package arcade.patch.agent.cell; import java.lang.reflect.Field; - -import arcade.core.util.MiniBox; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import sim.engine.Schedule; import sim.engine.Steppable; import ec.util.MersenneTwisterFast; import arcade.core.sim.Simulation; +import arcade.core.util.MiniBox; import arcade.core.util.Parameters; import arcade.patch.agent.module.PatchModule; import arcade.patch.agent.process.PatchProcessInflammation; diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index 5d9478ae9..14988ffb4 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -1,14 +1,13 @@ package arcade.patch.agent.cell; import java.lang.reflect.Field; - -import arcade.core.util.MiniBox; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import sim.engine.Schedule; import sim.engine.Steppable; import ec.util.MersenneTwisterFast; import arcade.core.sim.Simulation; +import arcade.core.util.MiniBox; import arcade.core.util.Parameters; import arcade.patch.agent.module.PatchModule; import arcade.patch.agent.process.PatchProcessInflammation; diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java index 1c23c2100..b5435ebfc 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTTest.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -1,8 +1,6 @@ package arcade.patch.agent.cell; import java.util.ArrayList; - -import arcade.core.util.MiniBox; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import sim.engine.SimState; @@ -11,6 +9,7 @@ import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; +import arcade.core.util.MiniBox; import arcade.core.util.Parameters; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; From 629ffe6f727467b60d90f3451ad12a00409ea9fd Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 21 Jan 2025 20:10:51 +0000 Subject: [PATCH 100/185] removing todo comment in metabolism CART as it is addressed --- src/arcade/patch/agent/process/PatchProcessMetabolismCART.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java index b7729af8a..e7de90580 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java @@ -131,7 +131,6 @@ public PatchProcessMetabolismCART(PatchCell cell) { names = Arrays.asList(intNames); // Set loaded parameters. - // TODO: pull metabolic preference from distribution Parameters parameters = cell.getParameters(); metaPref = parameters.getDouble("metabolism/METABOLIC_PREFERENCE"); conversionFraction = parameters.getDouble("metabolism/CONVERSION_FRACTION"); From 9705d936512c2906b74ad6f6cd1398b3b5b0c77d Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 21 Jan 2025 20:15:46 +0000 Subject: [PATCH 101/185] renaming redundant dydt variable in inflammation --- src/arcade/patch/agent/process/PatchProcessInflammation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index 982aebff1..817cbcca6 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -170,7 +170,7 @@ public PatchProcessInflammation(PatchCellCART c) { } /** System of ODEs for network. */ - Equations dydt = + Equations equations = (Equations & Serializable) (t, y) -> { double[] dydt = new double[NUM_COMPONENTS]; @@ -301,7 +301,7 @@ public void step(MersenneTwisterFast random, Simulation sim) { amts[IL2_EXT] = extIL2 * f; // [molecules] // Solve system of equations. - amts = Solver.rungeKutta(dydt, 0, amts, 60, STEP_SIZE); + amts = Solver.rungeKutta(equations, 0, amts, 60, STEP_SIZE); // Modify internal inflammation response. stepProcess(random, sim); From c43de0b57c328ed2b4c1e5c9e5c71b24d578043b Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 21 Jan 2025 20:24:12 +0000 Subject: [PATCH 102/185] adding only tissue cells to possible neighbors in bindTarget method --- src/arcade/patch/agent/cell/PatchCellCART.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 0c5ddb5e3..615409435 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -200,9 +200,10 @@ public PatchCellTissue bindTarget( // get all agents from neighboring locations for (Location neighborLocation : loc.getNeighbors()) { Bag bag = new Bag(grid.getObjectsAtLocation(neighborLocation)); - for (Object b : bag) { - // add all agents from neighboring locations - if (!allAgents.contains(b)) allAgents.add(b); + for (Object agent : bag) { + Cell cell = (Cell) agent; + // add all tissue agents from neighboring locations + if (cell instanceof PatchCellTissue) allAgents.add(cell); } } @@ -230,8 +231,7 @@ public PatchCellTissue bindTarget( // Within maximum search vicinity, search for neighboring cells to bind to for (int i = 0; i < maxSearch; i++) { Cell cell = (Cell) allAgents.get(i); - if (!(cell instanceof PatchCellCART) - && cell.getState() != State.APOPTOTIC + if (cell.getState() != State.APOPTOTIC && cell.getState() != State.NECROTIC) { PatchCellTissue tissueCell = (PatchCellTissue) cell; double cARAntigens = tissueCell.carAntigens; From 5a43a2fb33c315c932bca006d301ee1fbf22672f Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 21 Jan 2025 20:25:29 +0000 Subject: [PATCH 103/185] linting --- src/arcade/patch/agent/cell/PatchCellCART.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 615409435..21bb96a8d 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -231,8 +231,7 @@ public PatchCellTissue bindTarget( // Within maximum search vicinity, search for neighboring cells to bind to for (int i = 0; i < maxSearch; i++) { Cell cell = (Cell) allAgents.get(i); - if (cell.getState() != State.APOPTOTIC - && cell.getState() != State.NECROTIC) { + if (cell.getState() != State.APOPTOTIC && cell.getState() != State.NECROTIC) { PatchCellTissue tissueCell = (PatchCellTissue) cell; double cARAntigens = tissueCell.carAntigens; double selfTargets = tissueCell.selfTargets; From 6a605ca8a0e63e6e441ad6da218a4c0de0877fa2 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 23 Jan 2025 01:24:54 +0000 Subject: [PATCH 104/185] fixing bindTarget method to only consider tissue cells --- .../patch/agent/cell/PatchCellCART.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 21bb96a8d..fc6bde566 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -194,17 +194,14 @@ public PatchCellTissue bindTarget( double kDSelf = selfReceptorAffinity * (loc.getVolume() * 1e-15 * 6.022E23); PatchGrid grid = (PatchGrid) sim.getGrid(); - // get all agents from this location - Bag allAgents = new Bag(grid.getObjectsAtLocation(loc)); + // get all tissue agents from this location + Bag allAgents = new Bag(); + getTissueAgents(allAgents, grid.getObjectsAtLocation(loc)); // get all agents from neighboring locations for (Location neighborLocation : loc.getNeighbors()) { Bag bag = new Bag(grid.getObjectsAtLocation(neighborLocation)); - for (Object agent : bag) { - Cell cell = (Cell) agent; - // add all tissue agents from neighboring locations - if (cell instanceof PatchCellTissue) allAgents.add(cell); - } + getTissueAgents(allAgents, bag); } // remove self @@ -316,4 +313,19 @@ public AntigenFlag getAntigenFlag() { public boolean getActivationStatus() { return this.activated; } + + /** + * Adds only tissue cells to the provided bag. Helper method for bindTarget. + * + * @param tissueAgents the bag to add tissue cells into + * @param possibleAgents the bag of possible agents to check for tissue cells + */ + private void getTissueAgents(Bag tissueAgents, Bag possibleAgents) { + for (Object agent : possibleAgents) { + Cell cell = (Cell) agent; + if (cell instanceof PatchCellTissue) { + tissueAgents.add(cell); + } + } + } } From 13799100aee057ca9137bf354c7cac8c6ccac027 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 23 Jan 2025 01:25:14 +0000 Subject: [PATCH 105/185] removing instance checking in proliferation module --- .../agent/module/PatchModuleProliferation.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/arcade/patch/agent/module/PatchModuleProliferation.java b/src/arcade/patch/agent/module/PatchModuleProliferation.java index e609775cf..629e766c8 100644 --- a/src/arcade/patch/agent/module/PatchModuleProliferation.java +++ b/src/arcade/patch/agent/module/PatchModuleProliferation.java @@ -112,16 +112,12 @@ public void step(MersenneTwisterFast random, Simulation sim) { newCell.setEnergy(energy * (1 - split)); // Update processes. - PatchProcess metabolism = (PatchProcess) newCell.getProcess(Domain.METABOLISM); - metabolism.update(cell.getProcess(Domain.METABOLISM)); - if (cell instanceof PatchCellCART) { - PatchProcess inflammation = - (PatchProcess) newCell.getProcess(Domain.INFLAMMATION); - inflammation.update(cell.getProcess(Domain.INFLAMMATION)); - } else { - PatchProcess signaling = - (PatchProcess) newCell.getProcess(Domain.SIGNALING); - signaling.update(cell.getProcess(Domain.SIGNALING)); + Domain[] processes = Domain.values(); + for (Domain processName : processes) { + PatchProcess process = (PatchProcess) newCell.getProcess(processName); + if (process != null) { + process.update(cell.getProcess(processName)); + } } // TODO: Update environment generator sites. } else { From 59ce2fdde694dc31b2b1cc34019f31a13ae3c3f7 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 23 Jan 2025 19:07:55 +0000 Subject: [PATCH 106/185] moving binding flag to up to patch cell class --- .../patch/agent/action/PatchActionKill.java | 6 ++-- .../patch/agent/action/PatchActionReset.java | 2 +- src/arcade/patch/agent/cell/PatchCell.java | 23 +++++++++++++ .../patch/agent/cell/PatchCellCART.java | 34 ++++--------------- .../patch/agent/cell/PatchCellCARTCD4.java | 10 +++--- .../patch/agent/cell/PatchCellCARTCD8.java | 6 ++-- .../patch/agent/cell/PatchCellTissue.java | 5 --- .../agent/action/PatchActionKillTest.java | 2 +- .../agent/action/PatchActionResetTest.java | 6 ++-- 9 files changed, 45 insertions(+), 49 deletions(-) diff --git a/src/arcade/patch/agent/action/PatchActionKill.java b/src/arcade/patch/agent/action/PatchActionKill.java index faff050e0..5273319b7 100644 --- a/src/arcade/patch/agent/action/PatchActionKill.java +++ b/src/arcade/patch/agent/action/PatchActionKill.java @@ -78,10 +78,10 @@ public void step(SimState state) { // If bound target cell is stopped, stop helper. if (target.isStopped()) { - if (c.binding == AntigenFlag.BOUND_ANTIGEN) { - c.binding = AntigenFlag.UNBOUND; + if (c.getAntigenFlag() == AntigenFlag.BOUND_ANTIGEN) { + c.setAntigenFlag(AntigenFlag.UNBOUND); } else { - c.binding = AntigenFlag.BOUND_CELL_RECEPTOR; + c.setAntigenFlag(AntigenFlag.BOUND_CELL_RECEPTOR); } return; } diff --git a/src/arcade/patch/agent/action/PatchActionReset.java b/src/arcade/patch/agent/action/PatchActionReset.java index 9e8bc8a73..3d4c52c5f 100644 --- a/src/arcade/patch/agent/action/PatchActionReset.java +++ b/src/arcade/patch/agent/action/PatchActionReset.java @@ -60,7 +60,7 @@ public void step(SimState state) { } if (c.getState() == State.CYTOTOXIC || c.getState() == State.STIMULATORY) { - c.binding = AntigenFlag.UNBOUND; + c.setAntigenFlag(AntigenFlag.UNBOUND); c.setState(State.QUIESCENT); } } diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 3690c7b9d..6f6d7e386 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -25,6 +25,7 @@ import arcade.patch.agent.process.PatchProcessSignaling; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; +import arcade.patch.util.PatchEnums; import static arcade.patch.util.PatchEnums.Domain; import static arcade.patch.util.PatchEnums.Flag; import static arcade.patch.util.PatchEnums.Ordering; @@ -143,6 +144,9 @@ public abstract class PatchCell implements Cell { /** If cell is stopped in the simulation. */ private boolean isStopped; + /** Cell binding flag. */ + protected PatchEnums.AntigenFlag bindingFlag; + /** * Creates a {@code PatchCell} agent. * @@ -175,6 +179,7 @@ public PatchCell( this.flag = Flag.UNDEFINED; this.parameters = parameters; this.isStopped = false; + bindingFlag = PatchEnums.AntigenFlag.UNDEFINED; this.links = links; setState(container.state); @@ -552,4 +557,22 @@ static boolean checkLocation( } return true; } + + /** + * Sets the cell binding flag. + * + * @param flag the target cell antigen binding state + */ + public void setAntigenFlag(PatchEnums.AntigenFlag flag) { + this.bindingFlag = flag; + } + + /** + * Returns the cell binding flag. + * + * @return the cell antigen binding state + */ + public PatchEnums.AntigenFlag getAntigenFlag() { + return this.bindingFlag; + } } diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index fc6bde566..7f61e6f4e 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -45,9 +45,6 @@ * specified amount of heterogeneity ({@code HETEROGENEITY}). */ public abstract class PatchCellCART extends PatchCell { - /** Cell binding flag. */ - public AntigenFlag binding; - /** Cell activation flag. */ protected boolean activated; @@ -154,7 +151,6 @@ public PatchCellCART( boundAntigensCount = 0; boundSelfCount = 0; lastActiveTicker = 0; - binding = AntigenFlag.UNDEFINED; activated = true; // Set loaded parameters. @@ -216,7 +212,7 @@ public PatchCellTissue bindTarget( // Bind target with some probability if a nearby cell has targets to bind. int maxSearch = 0; if (neighbors == 0) { - binding = AntigenFlag.UNBOUND; + super.setAntigenFlag(AntigenFlag.UNBOUND); return null; } else { if (neighbors < searchAbility) { @@ -254,7 +250,7 @@ public PatchCellTissue bindTarget( if (logCAR >= randomAntigen && logSelf < randomSelf) { // cell binds to antigen receptor - binding = AntigenFlag.BOUND_ANTIGEN; + super.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); boundAntigensCount++; selfReceptors += (int) @@ -263,7 +259,7 @@ public PatchCellTissue bindTarget( return tissueCell; } else if (logCAR >= randomAntigen && logSelf >= randomSelf) { // cell binds to antigen receptor and self - binding = AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR; + super.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); boundAntigensCount++; boundSelfCount++; selfReceptors += @@ -273,38 +269,20 @@ public PatchCellTissue bindTarget( return tissueCell; } else if (logCAR < randomAntigen && logSelf >= randomSelf) { // cell binds to self - binding = AntigenFlag.BOUND_CELL_RECEPTOR; + super.setAntigenFlag(AntigenFlag.BOUND_CELL_RECEPTOR); boundSelfCount++; return tissueCell; } else { // cell doesn't bind to anything - binding = AntigenFlag.UNBOUND; + super.setAntigenFlag(AntigenFlag.UNBOUND); } } } - binding = AntigenFlag.UNBOUND; + super.setAntigenFlag(AntigenFlag.UNBOUND); } return null; } - /** - * Sets the cell binding flag. - * - * @param flag the target cell antigen binding state - */ - public void setAntigenFlag(AntigenFlag flag) { - this.binding = flag; - } - - /** - * Returns the cell binding flag. - * - * @return the cell antigen binding state - */ - public AntigenFlag getAntigenFlag() { - return this.binding; - } - /** * Returns the cell activation status. * diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 3dbce7b34..4f7695646 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -118,7 +118,7 @@ public void step(SimState simstate) { super.bindTarget(sim, location, new MersenneTwisterFast(simstate.seed())); // If cell is bound to both antigen and self it will become anergic. - if (binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { + if (super.getAntigenFlag() == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { if (simstate.random.nextDouble() > super.anergicFraction) { super.setState(State.APOPTOTIC); } else { @@ -126,7 +126,7 @@ public void step(SimState simstate) { } super.setAntigenFlag(AntigenFlag.UNBOUND); this.activated = false; - } else if (binding == AntigenFlag.BOUND_ANTIGEN) { + } else if (super.getAntigenFlag() == AntigenFlag.BOUND_ANTIGEN) { // If cell is only bound to target antigen, the cell // can potentially become properly activated. @@ -146,10 +146,10 @@ public void step(SimState simstate) { this.lastActiveTicker = 0; this.activated = true; if (target.isStopped()) { - target.binding = (AntigenFlag.UNBOUND); + target.setAntigenFlag(AntigenFlag.UNBOUND); } target.setState(State.QUIESCENT); - this.binding = AntigenFlag.UNBOUND; + super.setAntigenFlag(AntigenFlag.UNBOUND); // reset the cell PatchActionReset reset = new PatchActionReset( @@ -161,7 +161,7 @@ public void step(SimState simstate) { } } else { // If self binding, unbind - if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) + if (super.getAntigenFlag() == AntigenFlag.BOUND_CELL_RECEPTOR) super.setAntigenFlag(AntigenFlag.UNBOUND); // Check activation status. If cell has been activated before, // it will proliferate. If not, it will migrate. diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index 8a293722f..b3f621616 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -117,7 +117,7 @@ public void step(SimState simstate) { PatchCellTissue target = super.bindTarget(sim, location, simstate.random); // If cell is bound to both antigen and self it will become anergic. - if (binding == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { + if (super.getAntigenFlag() == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { if (simstate.random.nextDouble() > super.anergicFraction) { super.setState(State.APOPTOTIC); } else { @@ -125,7 +125,7 @@ public void step(SimState simstate) { } super.setAntigenFlag(AntigenFlag.UNBOUND); this.activated = false; - } else if (binding == AntigenFlag.BOUND_ANTIGEN) { + } else if (super.getAntigenFlag() == AntigenFlag.BOUND_ANTIGEN) { // If cell is only bound to target antigen, the cell // can potentially become properly activated. @@ -163,7 +163,7 @@ public void step(SimState simstate) { } } else { // If self binding, unbind - if (binding == AntigenFlag.BOUND_CELL_RECEPTOR) + if (super.getAntigenFlag() == AntigenFlag.BOUND_CELL_RECEPTOR) super.setAntigenFlag(AntigenFlag.UNBOUND); // Check activation status. If cell has been activated before, // it will proliferate. If not, it will migrate. diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index 8841f14a7..d3712ec8f 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -7,7 +7,6 @@ import arcade.core.sim.Simulation; import arcade.core.util.GrabBag; import arcade.core.util.Parameters; -import arcade.patch.util.PatchEnums.AntigenFlag; import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.Flag; import arcade.patch.util.PatchEnums.State; @@ -20,9 +19,6 @@ public class PatchCellTissue extends PatchCell { /** Cell surface PDL1 count. */ int selfTargets; - /** Cell binding flag. */ - public AntigenFlag binding; - /** * Creates a tissue {@code PatchCell} agent. * @@ -47,7 +43,6 @@ public PatchCellTissue( super(container, location, parameters, links); carAntigens = parameters.getInt("CAR_ANTIGENS_HEALTHY"); selfTargets = parameters.getInt("SELF_TARGETS"); - this.binding = AntigenFlag.UNDEFINED; } @Override diff --git a/test/arcade/patch/agent/action/PatchActionKillTest.java b/test/arcade/patch/agent/action/PatchActionKillTest.java index 6f1e423f2..2060dbbed 100644 --- a/test/arcade/patch/agent/action/PatchActionKillTest.java +++ b/test/arcade/patch/agent/action/PatchActionKillTest.java @@ -62,7 +62,7 @@ public void testStep_TargetCellStopped() { when(mockTarget.isStopped()).thenReturn(true); action.step(sim); verify(mockTarget, never()).setState(any()); - assertEquals(AntigenFlag.BOUND_CELL_RECEPTOR, mockCell.binding); + assertEquals(AntigenFlag.BOUND_CELL_RECEPTOR, mockCell.getAntigenFlag()); } @Test diff --git a/test/arcade/patch/agent/action/PatchActionResetTest.java b/test/arcade/patch/agent/action/PatchActionResetTest.java index f794fe85e..838b06185 100644 --- a/test/arcade/patch/agent/action/PatchActionResetTest.java +++ b/test/arcade/patch/agent/action/PatchActionResetTest.java @@ -80,7 +80,7 @@ public void testSchedule() { @Test public void testStep_CytotoxicState() { when(mockCell.isStopped()).thenReturn(false); - mockCell.binding = AntigenFlag.BOUND_ANTIGEN; + mockCell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); when(mockCell.getState()).thenReturn(State.CYTOTOXIC); actionReset.step(mock(SimState.class)); @@ -92,7 +92,7 @@ public void testStep_CytotoxicState() { @Test public void testStep_StimulatoryState() { when(mockCell.isStopped()).thenReturn(false); - mockCell.binding = AntigenFlag.BOUND_ANTIGEN; + mockCell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); when(mockCell.getState()).thenReturn(State.STIMULATORY); actionReset.step(mock(SimState.class)); @@ -104,7 +104,7 @@ public void testStep_StimulatoryState() { @Test public void testStep_StoppedCell() { when(mockCell.isStopped()).thenReturn(true); - mockCell.binding = AntigenFlag.BOUND_ANTIGEN; + mockCell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); actionReset.step(mock(SimState.class)); verify(mockCell, never()).setState(any(State.class)); assertEquals(AntigenFlag.BOUND_ANTIGEN, mockCell.getAntigenFlag()); From e9597d19da2d1bad24ba4de2417ccda565ddb777 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 23 Jan 2025 19:29:07 +0000 Subject: [PATCH 107/185] refactoring antigen tests --- src/arcade/patch/agent/cell/PatchCell.java | 2 +- .../patch/agent/action/PatchActionKillTest.java | 2 +- .../patch/agent/cell/PatchCellCARTTest.java | 12 ------------ test/arcade/patch/agent/cell/PatchCellTest.java | 15 +++++++++++++++ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 6f6d7e386..a22fe61f8 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -179,7 +179,7 @@ public PatchCell( this.flag = Flag.UNDEFINED; this.parameters = parameters; this.isStopped = false; - bindingFlag = PatchEnums.AntigenFlag.UNDEFINED; + this.bindingFlag = PatchEnums.AntigenFlag.UNDEFINED; this.links = links; setState(container.state); diff --git a/test/arcade/patch/agent/action/PatchActionKillTest.java b/test/arcade/patch/agent/action/PatchActionKillTest.java index 2060dbbed..312a50d4b 100644 --- a/test/arcade/patch/agent/action/PatchActionKillTest.java +++ b/test/arcade/patch/agent/action/PatchActionKillTest.java @@ -62,7 +62,7 @@ public void testStep_TargetCellStopped() { when(mockTarget.isStopped()).thenReturn(true); action.step(sim); verify(mockTarget, never()).setState(any()); - assertEquals(AntigenFlag.BOUND_CELL_RECEPTOR, mockCell.getAntigenFlag()); + verify(mockCell).setAntigenFlag(AntigenFlag.BOUND_CELL_RECEPTOR); } @Test diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java index b5435ebfc..293844e36 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTTest.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -117,18 +117,6 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { patchCellCART = new PatchCellMock(container, location, parameters); } - @Test - public void testSetAntigenFlag() { - patchCellCART.setAntigenFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); - assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); - } - - @Test - public void testGetAntigenFlag() { - patchCellCART.setAntigenFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); - assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); - } - @Test public void testBindTargetNoNeighbors() { Simulation sim = mock(Simulation.class); diff --git a/test/arcade/patch/agent/cell/PatchCellTest.java b/test/arcade/patch/agent/cell/PatchCellTest.java index 45da9bdcc..ea51ca049 100644 --- a/test/arcade/patch/agent/cell/PatchCellTest.java +++ b/test/arcade/patch/agent/cell/PatchCellTest.java @@ -15,6 +15,7 @@ import arcade.patch.env.lattice.PatchLattice; import arcade.patch.env.location.PatchLocation; import arcade.patch.sim.PatchSimulation; +import arcade.patch.util.PatchEnums; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; @@ -126,6 +127,20 @@ public void addCycle_givenCycles_appendValues() { assertEquals(3, cell.getCycles().size()); } + @Test + public void testSetAntigenFlag() { + PatchCell cell = new PatchCellMock(baseContainer, locationMock, parametersMock); + cell.setAntigenFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); + assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, cell.getAntigenFlag()); + } + + @Test + public void testGetAntigenFlag() { + PatchCell cell = new PatchCellMock(baseContainer, locationMock, parametersMock); + cell.setAntigenFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); + assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, cell.getAntigenFlag()); + } + @Test public void checkLocation_locationEmpty_returnTrue() { doReturn(0.0).when(parametersMock).getDouble(any(String.class)); From 5e6972122278b56060d22df1c9ae024eb4e45c54 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 23 Jan 2025 22:10:51 +0000 Subject: [PATCH 108/185] refactoring bindTarget method into helper methods --- .../patch/agent/cell/PatchCellCART.java | 55 +++++++++++++++---- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 7f61e6f4e..2ded2742e 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -230,20 +230,18 @@ public PatchCellTissue bindTarget( double selfTargets = tissueCell.selfTargets; double hillCAR = - (cARAntigens - * contactFraction - / (kDCAR * carBeta + cARAntigens * contactFraction)) - * (cars / 50000) - * carAlpha; + getHillCoefficient(cARAntigens, kDCAR, cars, 5000, carAlpha, carBeta); double hillSelf = - (selfTargets - * contactFraction - / (kDSelf * selfBeta + selfTargets * contactFraction)) - * (selfReceptors / selfReceptorsStart) - * selfAlpha; + getHillCoefficient( + selfTargets, + kDSelf, + selfReceptors, + selfReceptorsStart, + selfAlpha, + selfBeta); - double logCAR = 2 * (1 / (1 + Math.exp(-1 * hillCAR))) - 1; - double logSelf = 2 * (1 / (1 + Math.exp(-1 * hillSelf))) - 1; + double logCAR = getLog(hillCAR); + double logSelf = getLog(hillSelf); double randomAntigen = random.nextDouble(); double randomSelf = random.nextDouble(); @@ -306,4 +304,37 @@ private void getTissueAgents(Bag tissueAgents, Bag possibleAgents) { } } } + + /** + * Computes Hill Coefficient for given parameters. + * + * @param targets the number of antigens on the target cell + * @param affinity binding affinity of receptor + * @param currentReceptors number of receptors currently on the cell + * @param startReceptors number of starting receptors on the cell + * @param alpha fudge factor for receptor binding + * @param beta fudge factor for receptor binding + * @return the Hill Coefficient + */ + private double getHillCoefficient( + double targets, + double affinity, + int currentReceptors, + int startReceptors, + double alpha, + double beta) { + return (targets * contactFraction / (affinity * alpha + targets * contactFraction)) + * (currentReceptors / startReceptors) + * beta; + } + + /** + * Computes log function for given hill coeffient. + * + * @param hill hill coefficient for the log function + * @return the log value + */ + private double getLog(double hill) { + return 2 * (1 / (1 + Math.exp(-1 * hill))) - 1; + } } From ec75cf6796e0a53435971694de8b86b1455a6b97 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 23 Jan 2025 22:25:14 +0000 Subject: [PATCH 109/185] accidentally swapped alpha and beta in bindTarget --- src/arcade/patch/agent/cell/PatchCellCART.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 2ded2742e..31af2b3d4 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -323,9 +323,9 @@ private double getHillCoefficient( int startReceptors, double alpha, double beta) { - return (targets * contactFraction / (affinity * alpha + targets * contactFraction)) + return (targets * contactFraction / (affinity * beta + targets * contactFraction)) * (currentReceptors / startReceptors) - * beta; + * alpha; } /** From f53a9b314e85c5b1b26d284680f1b2cd69ad88e4 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 23 Jan 2025 23:05:19 +0000 Subject: [PATCH 110/185] making proliferation a cell level param --- src/arcade/patch/agent/cell/PatchCell.java | 13 +++++++++++++ .../agent/module/PatchModuleProliferation.java | 11 ++--------- src/arcade/patch/parameter.patch.xml | 3 +-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index a22fe61f8..12d92fabc 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -102,6 +102,9 @@ public abstract class PatchCell implements Cell { /** Death age due to apoptosis [min]. */ double apoptosisAge; + /** Time required for DNA synthesis [min]. */ + final int synthesisDuration; + /** Critical volume for cell [um3]. */ final double criticalVolume; @@ -191,6 +194,7 @@ public PatchCell( apoptosisAge = parameters.getDouble("APOPTOSIS_AGE"); accuracy = parameters.getDouble("ACCURACY"); affinity = parameters.getDouble("AFFINITY"); + synthesisDuration = parameters.getInt("SYNTHESIS_DURATION"); int densityInput = parameters.getInt("MAX_DENSITY"); maxDensity = (densityInput >= 0 ? densityInput : Integer.MAX_VALUE); @@ -575,4 +579,13 @@ public void setAntigenFlag(PatchEnums.AntigenFlag flag) { public PatchEnums.AntigenFlag getAntigenFlag() { return this.bindingFlag; } + + /** + * Returns the synthesis duration period. + * + * @return the cell antigen binding state + */ + public int getSynthesisDuration() { + return this.synthesisDuration; + } } diff --git a/src/arcade/patch/agent/module/PatchModuleProliferation.java b/src/arcade/patch/agent/module/PatchModuleProliferation.java index 629e766c8..a515a5eaf 100644 --- a/src/arcade/patch/agent/module/PatchModuleProliferation.java +++ b/src/arcade/patch/agent/module/PatchModuleProliferation.java @@ -4,9 +4,7 @@ import ec.util.MersenneTwisterFast; import arcade.core.agent.cell.CellContainer; import arcade.core.sim.Simulation; -import arcade.core.util.Parameters; import arcade.patch.agent.cell.PatchCell; -import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.agent.process.PatchProcess; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; @@ -55,13 +53,8 @@ public PatchModuleProliferation(PatchCell cell) { targetVolume = 2 * cell.getCriticalVolume(); maxHeight = cell.getCriticalHeight(); duration = 0; - // Set loaded parameters. - Parameters parameters = cell.getParameters(); - if (cell instanceof PatchCellCART) { - synthesisDuration = parameters.getInt("proliferation/T_CELL_SYNTHESIS_DURATION"); - } else { - synthesisDuration = parameters.getInt("proliferation/SYNTHESIS_DURATION"); - } + // Load parameters. + synthesisDuration = cell.getSynthesisDuration(); } @Override diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index 6a9ff31d2..f0323211d 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -26,6 +26,7 @@ + @@ -51,8 +52,6 @@ - - From 1ce8a7ca54b7b69b5688f2ade30c28e7ab6f9aef Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 24 Jan 2025 00:44:00 +0000 Subject: [PATCH 111/185] removing inflammation kinetic parameters as a user input --- src/arcade/patch/agent/process/PatchProcessInflammation.java | 4 ---- src/arcade/patch/parameter.patch.xml | 3 --- 2 files changed, 7 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index 817cbcca6..87523dcf8 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -140,10 +140,6 @@ public PatchProcessInflammation(PatchCellCART c) { Parameters parameters = cell.getParameters(); this.shellThickness = parameters.getDouble("inflammation/SHELL_THICKNESS"); this.iL2Receptors = parameters.getDouble("inflammation/IL2_RECEPTORS"); - this.iL2BindingOnRateMin = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MIN"); - this.iL2BindingOnRateMax = parameters.getDouble("inflammation/IL2_BINDING_ON_RATE_MAX"); - this.iL2BindingOffRate = parameters.getDouble("inflammation/IL2_BINDING_OFF_RATE"); - extIL2 = 0; // Initial amounts of each species, all in molecules/cell. diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index f0323211d..42a86f14a 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -92,9 +92,6 @@ - - - From e5dc3f88da30898263c0cfa6ccd6a8e3d31969a7 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 24 Jan 2025 01:02:29 +0000 Subject: [PATCH 112/185] making car antigens a population definition --- src/arcade/patch/agent/cell/PatchCellCancer.java | 1 - src/arcade/patch/agent/cell/PatchCellTissue.java | 2 +- src/arcade/patch/parameter.patch.xml | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCancer.java b/src/arcade/patch/agent/cell/PatchCellCancer.java index 59f0d3f67..6a82210f2 100644 --- a/src/arcade/patch/agent/cell/PatchCellCancer.java +++ b/src/arcade/patch/agent/cell/PatchCellCancer.java @@ -42,7 +42,6 @@ public PatchCellCancer(PatchCellContainer container, Location location, Paramete public PatchCellCancer( PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { super(container, location, parameters, links); - super.carAntigens = parameters.getInt("CAR_ANTIGENS_CANCER"); } /** diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index d3712ec8f..d64dcd0c3 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -41,7 +41,7 @@ public PatchCellTissue(PatchCellContainer container, Location location, Paramete public PatchCellTissue( PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { super(container, location, parameters, links); - carAntigens = parameters.getInt("CAR_ANTIGENS_HEALTHY"); + carAntigens = parameters.getInt("CAR_ANTIGENS"); selfTargets = parameters.getInt("SELF_TARGETS"); } diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index 42a86f14a..408d98a8c 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -35,8 +35,7 @@ - - + From e0c50153e35b91f89f95a3f39b4b77fce233181f Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 24 Jan 2025 01:06:34 +0000 Subject: [PATCH 113/185] fixing up cart tests --- test/arcade/patch/agent/cell/PatchCellCARTTest.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java index 293844e36..18a2d0d56 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTTest.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -148,8 +148,7 @@ public void testBindTargetWithSelfBinding() { when(loc.getNeighbors()).thenReturn(new ArrayList()); when(loc.getVolume()).thenReturn(6000.0); - when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(10); - when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(10); + when(parameters.getInt("CAR_ANTIGENS")).thenReturn(10); when(parameters.getInt("SELF_TARGETS")).thenReturn(10000000); PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); @@ -175,8 +174,7 @@ public void testBindTargetWithSelfAndAntigenBinding() { when(loc.getNeighbors()).thenReturn(new ArrayList()); when(loc.getVolume()).thenReturn(6000.0); - when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); - when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); + when(parameters.getInt("CAR_ANTIGENS")).thenReturn(5000); when(parameters.getInt("SELF_TARGETS")).thenReturn(50000000); PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); @@ -204,8 +202,7 @@ public void testBindTarget() { when(loc.getNeighbors()).thenReturn(new ArrayList()); when(loc.getVolume()).thenReturn(6000.0); - when(parameters.getInt("CAR_ANTIGENS_HEALTHY")).thenReturn(5000); - when(parameters.getInt("CAR_ANTIGENS_CANCER")).thenReturn(5000); + when(parameters.getInt("CAR_ANTIGENS")).thenReturn(5000); when(parameters.getInt("SELF_TARGETS")).thenReturn(5000); PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); From c93c0573dabb6f016f94223f3864f3a245a57707 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 24 Jan 2025 01:18:58 +0000 Subject: [PATCH 114/185] writing getters for antigens --- .../patch/agent/cell/PatchCellCART.java | 4 ++-- .../patch/agent/cell/PatchCellTissue.java | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 31af2b3d4..ef1791c65 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -226,8 +226,8 @@ public PatchCellTissue bindTarget( Cell cell = (Cell) allAgents.get(i); if (cell.getState() != State.APOPTOTIC && cell.getState() != State.NECROTIC) { PatchCellTissue tissueCell = (PatchCellTissue) cell; - double cARAntigens = tissueCell.carAntigens; - double selfTargets = tissueCell.selfTargets; + double cARAntigens = tissueCell.getCarAntigens(); + double selfTargets = tissueCell.getSelfAntigens(); double hillCAR = getHillCoefficient(cARAntigens, kDCAR, cars, 5000, carAlpha, carBeta); diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index d64dcd0c3..3b6afedf3 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -14,10 +14,10 @@ /** Extension of {@link PatchCell} for healthy tissue cells. */ public class PatchCellTissue extends PatchCell { /** Cell surface antigen count. */ - int carAntigens; + private int carAntigens; /** Cell surface PDL1 count. */ - int selfTargets; + private int selfTargets; /** * Creates a tissue {@code PatchCell} agent. @@ -112,4 +112,22 @@ public void step(SimState simstate) { module.step(simstate.random, sim); } } + + /** + * Returns the number of CAR antigens on this cell. + * + * @return the number of CAR antigens on this cell. + */ + public int getCarAntigens() { + return carAntigens; + } + + /** + * Returns the number of self receptor antigens on this cell. + * + * @return the number of self receptor antigens on this cell. + */ + public int getSelfAntigens() { + return selfTargets; + } } From 9cf5205e0d0ad0187a21a91fab4b60f890dc613c Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Fri, 24 Jan 2025 01:20:51 +0000 Subject: [PATCH 115/185] making antigen fields final --- src/arcade/patch/agent/cell/PatchCellTissue.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index 3b6afedf3..8d8d826c4 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -14,10 +14,10 @@ /** Extension of {@link PatchCell} for healthy tissue cells. */ public class PatchCellTissue extends PatchCell { /** Cell surface antigen count. */ - private int carAntigens; + private final int carAntigens; /** Cell surface PDL1 count. */ - private int selfTargets; + private final int selfTargets; /** * Creates a tissue {@code PatchCell} agent. From 4b586066c5e247373a5b12ec054073ac81c96d97 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 29 Jan 2025 19:48:26 +0000 Subject: [PATCH 116/185] renaming il2 rate variables names to be more readable --- .../patch/agent/process/PatchProcessInflammation.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index 87523dcf8..4c5efe0db 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -64,10 +64,10 @@ public abstract class PatchProcessInflammation extends PatchProcess { private static final double K_REC = 1e-5 / STEP_DIVIDER; /** Rate of IL-2 binding to two-chain IL-2 receptor complex [um^3/molecules IL-2/min]. */ - private double iL2BindingOnRateMin = 3.8193E-2; + private double iL2BindingMin = 3.8193E-2; /** Rate of IL-2 binding to three-chain IL-2 receptor complex [um^3/molecules IL-2/min]. */ - private double iL2BindingOnRateMax = 3.155; + private double iL2BindingMax = 3.155; /** Rate of unbinding of IL-2 from two- or three- chain IL-2 receptor complex [/min]. */ private double iL2BindingOffRate = 0.015; @@ -171,8 +171,8 @@ public PatchProcessInflammation(PatchCellCART c) { (t, y) -> { double[] dydt = new double[NUM_COMPONENTS]; - double kOn2 = iL2BindingOnRateMin / loc.getVolume() / 60 / STEP_DIVIDER; - double kOn3 = iL2BindingOnRateMax / loc.getVolume() / 60 / STEP_DIVIDER; + double kOn2 = iL2BindingMin / loc.getVolume() / 60 / STEP_DIVIDER; + double kOn3 = iL2BindingMax / loc.getVolume() / 60 / STEP_DIVIDER; double kOff = iL2BindingOffRate / 60 / STEP_DIVIDER; dydt[IL2_EXT] = From 7d93d3c1b6ea9c72b88e607fce02aeff72176345 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 29 Jan 2025 20:43:42 +0000 Subject: [PATCH 117/185] refactoring and renaming CART tests --- .../patch/agent/cell/PatchCellCARTTest.java | 105 +++++++----------- 1 file changed, 39 insertions(+), 66 deletions(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java index 18a2d0d56..0d6867744 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTTest.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -1,6 +1,7 @@ package arcade.patch.agent.cell; import java.util.ArrayList; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import sim.engine.SimState; @@ -30,6 +31,18 @@ public class PatchCellCARTTest { private PatchCellContainer container; + private static Simulation sim; + + private static PatchLocation loc; + + private static MersenneTwisterFast random; + + private static PatchGrid grid; + + private static PatchCellTissue tissueCell; + + private static Bag bag; + static class PatchCellMock extends PatchCellCART { PatchCellMock(PatchCellContainer container, Location location, Parameters parameters) { super(container, location, parameters, null); @@ -87,9 +100,7 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { criticalVolume, criticalHeight); - when(parameters.getDouble("HETEROGENEITY")).thenReturn(0.0); when(parameters.getDouble("ENERGY_THRESHOLD")).thenReturn(1.0); - when(parameters.getDouble("NECROTIC_FRACTION")) .thenReturn(randomIntBetween(40, 100) / 100.0); when(parameters.getDouble("EXHAU_FRAC")).thenReturn(randomIntBetween(40, 100) / 100.0); @@ -110,110 +121,72 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { when(parameters.getDouble("CONTACT_FRAC")).thenReturn(7.8E-6); when(parameters.getInt("MAX_ANTIGEN_BINDING")).thenReturn(10); when(parameters.getInt("CARS")).thenReturn(50000); - when(parameters.getInt("APOPTOSIS_AGE")).thenReturn(120960); when(parameters.getInt("MAX_DENSITY")).thenReturn(54); patchCellCART = new PatchCellMock(container, location, parameters); } - @Test - public void testBindTargetNoNeighbors() { - Simulation sim = mock(Simulation.class); - PatchLocation loc = mock(PatchLocation.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - PatchGrid grid = mock(PatchGrid.class); - Bag bag = new Bag(); - + @BeforeAll + public static void setupMocks() { + sim = mock(Simulation.class); + loc = mock(PatchLocation.class); + random = mock(MersenneTwisterFast.class); + grid = mock(PatchGrid.class); + bag = new Bag(); when(sim.getGrid()).thenReturn(grid); when(grid.getObjectsAtLocation(loc)).thenReturn(bag); when(loc.getNeighbors()).thenReturn(new ArrayList()); + when(loc.getVolume()).thenReturn(6000.0); + tissueCell = mock(PatchCellTissue.class); + } + @Test + public void bindTargetNoNeighborsDoesNotBind() { PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); assertNull(result); assertEquals(PatchEnums.AntigenFlag.UNBOUND, patchCellCART.getAntigenFlag()); } @Test - public void testBindTargetWithSelfBinding() { - // lots of self antigens, not a lot of car antigens - Simulation sim = mock(Simulation.class); - PatchLocation loc = mock(PatchLocation.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - PatchGrid grid = mock(PatchGrid.class); - Bag bag = new Bag(); - - when(sim.getGrid()).thenReturn(grid); - when(grid.getObjectsAtLocation(loc)).thenReturn(bag); - when(loc.getNeighbors()).thenReturn(new ArrayList()); - when(loc.getVolume()).thenReturn(6000.0); - - when(parameters.getInt("CAR_ANTIGENS")).thenReturn(10); - when(parameters.getInt("SELF_TARGETS")).thenReturn(10000000); - PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + public void bindTargetWithSelfBindingBindsToCell() { + when(tissueCell.getCarAntigens()).thenReturn(10); + when(tissueCell.getSelfAntigens()).thenReturn(10000000); + when(random.nextDouble()).thenReturn(0.0000005); bag.add(tissueCell); - when(random.nextDouble()).thenReturn(0.0000005); - PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + bag.clear(); assertNotNull(result); assertEquals(PatchEnums.AntigenFlag.BOUND_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); } @Test - public void testBindTargetWithSelfAndAntigenBinding() { - Simulation sim = mock(Simulation.class); - PatchLocation loc = mock(PatchLocation.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - PatchGrid grid = mock(PatchGrid.class); - Bag bag = new Bag(); - - when(sim.getGrid()).thenReturn(grid); - when(grid.getObjectsAtLocation(loc)).thenReturn(bag); - when(loc.getNeighbors()).thenReturn(new ArrayList()); - when(loc.getVolume()).thenReturn(6000.0); - - when(parameters.getInt("CAR_ANTIGENS")).thenReturn(5000); - when(parameters.getInt("SELF_TARGETS")).thenReturn(50000000); - - PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); + public void bindTargetWithSelfAndAntigenBindingBindsToCell() { + when(tissueCell.getCarAntigens()).thenReturn(5000); + when(tissueCell.getSelfAntigens()).thenReturn(50000000); + when(random.nextDouble()).thenReturn(0.0000005); bag.add(tissueCell); - when(random.nextDouble()).thenReturn(0.0000005); - PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + bag.clear(); assertNotNull(result); assertEquals( PatchEnums.AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); } @Test - public void testBindTarget() { - Simulation sim = mock(Simulation.class); - PatchLocation loc = mock(PatchLocation.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - PatchGrid grid = mock(PatchGrid.class); - Bag bag = new Bag(); - - when(sim.getGrid()).thenReturn(grid); - when(grid.getObjectsAtLocation(loc)).thenReturn(bag); - when(loc.getNeighbors()).thenReturn(new ArrayList()); - when(loc.getVolume()).thenReturn(6000.0); - - when(parameters.getInt("CAR_ANTIGENS")).thenReturn(5000); - when(parameters.getInt("SELF_TARGETS")).thenReturn(5000); - - PatchCellTissue tissueCell = new PatchCellTissue(container, location, parameters); - - bag.add(tissueCell); - + public void bindTargetBindsToCell() { + when(tissueCell.getCarAntigens()).thenReturn(5000); + when(tissueCell.getSelfAntigens()).thenReturn(5000); when(random.nextDouble()).thenReturn(0.0000005); bag.add(tissueCell); PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); + bag.clear(); assertNotNull(result); assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); } From 0c6590ef422d500bba0eaf5b1e383d815658e8e9 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 29 Jan 2025 23:07:30 +0000 Subject: [PATCH 118/185] changing inflammation test to not test default value --- .../agent/process/PatchProcessInflammationTest.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java index 3b9f1181e..ce6b70bde 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java @@ -60,25 +60,26 @@ public void setUp() { } @Test - public void testConstructor() { + public void constructorInitiatesValues() { assertNotNull(inflammation); assertEquals(0, inflammation.getInternal("IL-2")); assertEquals(1.0, inflammation.getInternal("IL2R_total")); } @Test - public void testStep() { + public void stepCalculatesIL2() { inflammation.step(mockRandom, mockSimulation); assertTrue(inflammation.getInternal("IL-2") >= 0); } @Test - public void testGetInternal() { - assertEquals(0, inflammation.getInternal("IL-2")); + public void getInternalReturnsInternalValue() { + inflammation.amts[PatchProcessInflammation.IL2_INT_TOTAL] = 10.0; + assertEquals(10.0, inflammation.getInternal("IL-2")); } @Test - public void testSetInternal() { + public void setInternalSetsLayer() { inflammation.setInternal("IL-2", 10.0); assertEquals(10.0, inflammation.getInternal("IL-2")); } From 8ddf35fb092c4794d819668e297484fb42ce5cba Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 29 Jan 2025 23:13:50 +0000 Subject: [PATCH 119/185] better code writing for PatchEnums test --- test/arcade/patch/util/PatchEnumsTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/arcade/patch/util/PatchEnumsTest.java b/test/arcade/patch/util/PatchEnumsTest.java index 02d3c692e..0c6a3b090 100644 --- a/test/arcade/patch/util/PatchEnumsTest.java +++ b/test/arcade/patch/util/PatchEnumsTest.java @@ -130,14 +130,14 @@ public void Ordering_in_expected_order() { // Create list of all values. ArrayList enumList = new ArrayList(Arrays.asList(Ordering.values())); - int n = -1; - int verify = -2; + int n = 0; + int verify; // Grabbing order of items in enum for (Ordering x : enumList) { verify = x.ordinal(); - n++; // Verify order of enum assertEquals(n, verify); + n++; } } } From 05874c514d3f689330706898493a5a08f9f64cc5 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 29 Jan 2025 23:22:54 +0000 Subject: [PATCH 120/185] updating docstring for patch cell class --- src/arcade/patch/agent/cell/PatchCell.java | 25 ++---------------- .../patch/agent/cell/PatchCellTissue.java | 26 ++++++++++++++++++- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 12d92fabc..2ebef843b 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -32,28 +32,7 @@ import static arcade.patch.util.PatchEnums.State; /** - * Implementation of {@link Cell} for generic tissue cell. - * - *

    {@code PatchCell} agents exist in one of seven states: undefined, apoptotic, quiescent, - * migratory, proliferative, senescent, and necrotic. The undefined state is a transition state for - * "undecided" cells, and does not have any biological analog. - * - *

    {@code PatchCell} agents have two required {@link Process} domains: metabolism and signaling. - * Metabolism controls changes in cell energy and volume. Signaling controls the proliferative vs. - * migratory decision. - * - *

    General order of rules for the {@code PatchCell} step: - * - *

      - *
    • update age - *
    • check lifespan (possible change to apoptotic) - *
    • step metabolism process - *
    • check energy status (possible change to quiescent or necrotic depending on {@code - * ENERGY_THRESHOLD}) - *
    • step signaling process - *
    • check if neutral (change to proliferative, migratory, senescent) - *
    • step state-specific module - *
    + * Implementation of {@link Cell} for generic cell agent. * *

    Cells that become necrotic or senescent have a change to become apoptotic instead ({@code * NECROTIC_FRACTION} and {@code SENESCENT_FRACTION}, respectively). @@ -522,7 +501,7 @@ public Bag findFreeLocations(Simulation sim) { * @param maxHeight the maximum height tolerance * @param population the population index * @param maxDensity the maximum density of population in the location - * @return a list of free locations + * @return if the location is available for the cell */ static boolean checkLocation( Simulation sim, diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index 8d8d826c4..6c8ee00f4 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -3,6 +3,7 @@ import sim.engine.SimState; import ec.util.MersenneTwisterFast; import arcade.core.agent.cell.CellState; +import arcade.core.agent.process.Process; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; import arcade.core.util.GrabBag; @@ -11,7 +12,30 @@ import arcade.patch.util.PatchEnums.Flag; import arcade.patch.util.PatchEnums.State; -/** Extension of {@link PatchCell} for healthy tissue cells. */ +/** + * Extension of {@link PatchCell} for healthy tissue cells. * + * + *

    {@code PatchCellTissue} agents exist in one of seven states: undefined, apoptotic, quiescent, + * migratory, proliferative, senescent, and necrotic. The undefined state is a transition state for + * "undecided" cells, and does not have any biological analog. + * + *

    {@code PatchCellTissue} agents have two required {@link Process} domains: metabolism and + * signaling. Metabolism controls changes in cell energy and volume. Signaling controls the + * proliferative vs. migratory decision. + * + *

    General order of rules for the {@code PatchCellTissue} step: + * + *

      + *
    • update age + *
    • check lifespan (possible change to apoptotic) + *
    • step metabolism process + *
    • check energy status (possible change to quiescent or necrotic depending on {@code + * ENERGY_THRESHOLD}) + *
    • step signaling process + *
    • check if neutral (change to proliferative, migratory, senescent) + *
    • step state-specific module + *
    + */ public class PatchCellTissue extends PatchCell { /** Cell surface antigen count. */ private final int carAntigens; From 9f6a60987e17bdbf064a7e76407d616ab4791375 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 29 Jan 2025 23:36:39 +0000 Subject: [PATCH 121/185] update docstrings and variable names --- src/arcade/patch/agent/cell/PatchCell.java | 4 ++-- src/arcade/patch/agent/cell/PatchCellCART.java | 12 ++++++++---- src/arcade/patch/parameter.patch.xml | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 2ebef843b..e5e198916 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -38,8 +38,8 @@ * NECROTIC_FRACTION} and {@code SENESCENT_FRACTION}, respectively). * *

    Cell parameters are tracked using a map between the parameter name and value. Daughter cell - * parameter values are drawn from a distribution centered on the parent cell parameter with the - * specified amount of heterogeneity ({@code HETEROGENEITY}). + * parameter values are drawn from a distribution centered on the parent cell. The parameter classes + * have support for loading in distributions to reflect heterogeneity. ({@code HETEROGENEITY}). */ public abstract class PatchCell implements Cell { /** Stopper used to stop this agent from being stepped in the schedule. */ diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index ef1791c65..a16285c9d 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -32,8 +32,11 @@ *

  • step metabolism module *
  • check energy status (possible change to starved, apoptotic) *
  • step inflammation module + *
  • check for bound targets (possible state change to cytotoxic, stimulatory, exhausted, + * anergic) *
  • check if neutral or paused (change to proliferative, migratory, senescent, cytotoxic, * stimulatory, exhausted, anergic) + *
  • step state-specific module * * *

    Cells that become senescent, exhausted, anergic, or proliferative have a change to become @@ -41,8 +44,9 @@ * ANERGIC_FRACTION}, and ({@code PROLIFERATIVE_FRACTION}, respectively). * *

    Cell parameters are tracked using a map between the parameter name and value. Daughter cell - * parameter values are drawn from a distribution centered on the parent cell parameter with the - * specified amount of heterogeneity ({@code HETEROGENEITY}). + * parameter values are drawn from a distribution centered on the parent cell parameter. The + * parameter classes have support for loading in distributions to reflect heterogeneity. ({@code + * HETEROGENEITY}). */ public abstract class PatchCellCART extends PatchCell { /** Cell activation flag. */ @@ -122,7 +126,7 @@ public PatchCellCART(PatchCellContainer container, Location location, Parameters *

    Loaded parameters include: * *

      - *
    • {@code EXHAU_FRACTION} = fraction of exhausted cells that become apoptotic + *
    • {@code EXHAUSTED_FRACTION} = fraction of exhausted cells that become apoptotic *
    • {@code SENESCENT_FRACTION} = fraction of senescent cells that become apoptotic *
    • {@code ANERGIC_FRACTION} = fraction of anergic cells that become apoptotic *
    • {@code PROLIFERATIVE_FRACTION} = fraction of proliferative cells that become apoptotic @@ -154,7 +158,7 @@ public PatchCellCART( activated = true; // Set loaded parameters. - exhaustedFraction = parameters.getDouble("EXHAU_FRAC"); + exhaustedFraction = parameters.getDouble("EXHAUSTED_FRAC"); senescentFraction = parameters.getDouble("SENESCENT_FRACTION"); anergicFraction = parameters.getDouble("ANERGIC_FRACTION"); proliferativeFraction = parameters.getDouble("PROLIFERATIVE_FRACTION"); diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index 408d98a8c..d2fe9cb4d 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -31,7 +31,7 @@ - + From 1ec27e72ea7281422e8ca5f926bfe692e1470982 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 29 Jan 2025 23:49:51 +0000 Subject: [PATCH 122/185] removing empty statement and unused imports --- src/arcade/patch/agent/cell/PatchCellTissue.java | 1 - test/arcade/patch/agent/cell/PatchCellCARTTest.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index 6c8ee00f4..a3aff01b5 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -3,7 +3,6 @@ import sim.engine.SimState; import ec.util.MersenneTwisterFast; import arcade.core.agent.cell.CellState; -import arcade.core.agent.process.Process; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; import arcade.core.util.GrabBag; diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java index 0d6867744..9f4b6167c 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTTest.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -85,7 +85,6 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { double criticalVolume = randomDoubleBetween(100, 200); double criticalHeight = randomDoubleBetween(4, 10); PatchEnums.State state = PatchEnums.State.UNDEFINED; - ; container = new PatchCellContainer( From f79778eede7cbeab53705c61565236f0a8a419b0 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 30 Jan 2025 00:47:52 +0000 Subject: [PATCH 123/185] updating metabolism cart tests to test obj behavior --- .../process/PatchProcessMetabolismCART.java | 48 ----- .../PatchProcessMetabolismCARTTest.java | 174 ++++-------------- 2 files changed, 36 insertions(+), 186 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java index e7de90580..08a8c9fab 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java @@ -90,17 +90,6 @@ public class PatchProcessMetabolismCART extends PatchProcessMetabolism { /** Time delay for changes in metabolism. */ private final int timeDelay; - /** Metabolic preference value after stepping through the process. For testing purposes only. */ - private double finalMetabolicPreference; - - /** Glucose uptake rate value after stepping through the process. For testing purposes only. */ - private double finalGlucoseUptakeRate; - - /** - * Minimum mass fraction value after stepping through the process. For testing purposes only. - */ - private double finalMinimumMassFraction; - /** * Creates a metabolism {@link PatchProcess} for the given cell. * @@ -283,13 +272,6 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { upAmts[GLUCOSE] = glucUptake; upAmts[OXYGEN] = oxyUptake; intAmts[PYRUVATE] = pyruInt; - - // Set final metabolic preference for testing - finalMetabolicPreference = metabolicPreference; - // Set final glucose uptake rate for testing - finalGlucoseUptakeRate = glucoseUptakeRate; - // Set final min mass fraction for testing - finalMinimumMassFraction = minimumMassFraction; } @Override @@ -309,34 +291,4 @@ public void update(Process process) { metabolism.volume *= (1 - split); metabolism.mass *= (1 - split); } - - /** - * Returns final value of metabolic preference after stepping process Exists for testing - * purposes only. - * - * @return final value of the metabolic preference - */ - public double getFinalMetabolicPreference() { - return finalMetabolicPreference; - } - - /** - * Returns final value of glucose uptake rate after stepping process Exists for testing purposes - * only. - * - * @return final value of glucose uptake rate - */ - public double getFinalGlucoseUptakeRate() { - return finalGlucoseUptakeRate; - } - - /** - * Returns final value of minimum mass fraction after stepping process Exists for testing - * purposes only. - * - * @return final value of min mass fraction - */ - public double getFinalMinimumMassFraction() { - return finalMinimumMassFraction; - } } diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java index 683d98998..9d585bf36 100644 --- a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -25,6 +25,10 @@ public class PatchProcessMetabolismCARTTest { private double cellVolume; + private MersenneTwisterFast random = new MersenneTwisterFast(); + + private Simulation sim; + static class inflammationMock extends PatchProcessInflammation { public inflammationMock(PatchCellCART c) { super(c); @@ -38,7 +42,7 @@ public void update(Process process) {} } @BeforeEach - public void setUp() { + public void setUp() throws NoSuchFieldException, IllegalAccessException { mockCell = mock(PatchCellCART.class); mockParameters = mock(Parameters.class); mockLocation = mock(PatchLocation.class); @@ -52,13 +56,19 @@ public void setUp() { .thenReturn(randomDoubleBetween(0, 1.0) * 6 * 30 / Math.sqrt(3)); when(mockLocation.getArea()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30); when(mockLocation.getVolume()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30 * 8.7); - } - @Test - public void testConstructorInitializesFields() - throws NoSuchFieldException, IllegalAccessException { + // set up metabolism class + when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); + when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); metabolism = new PatchProcessMetabolismCART(mockCell); + Field fraction = PatchProcessMetabolism.class.getDeclaredField("f"); + fraction.setAccessible(true); + fraction.set(metabolism, 1.0); + sim = mock(Simulation.class); + } + @Test + public void constructorInitializesFields() throws NoSuchFieldException, IllegalAccessException { assertNotNull(metabolism); Field metaPrefField = PatchProcessMetabolismCART.class.getDeclaredField("metaPref"); @@ -91,7 +101,7 @@ public void testConstructorInitializesFields() Field glucUptakeRateField = PatchProcessMetabolismCART.class.getDeclaredField("glucUptakeRate"); glucUptakeRateField.setAccessible(true); - assertEquals(1.0, glucUptakeRateField.get(metabolism)); + assertEquals(1.12, glucUptakeRateField.get(metabolism)); Field metabolicPreferenceIL2Field = PatchProcessMetabolismCART.class.getDeclaredField("metabolicPreferenceIL2"); @@ -124,19 +134,8 @@ public void testConstructorInitializesFields() } @Test - public void testStepProcess() throws NoSuchFieldException, IllegalAccessException { - // set up metabolism class - when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); - when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); - metabolism = new PatchProcessMetabolismCART(mockCell); - Field fraction = PatchProcessMetabolism.class.getDeclaredField("f"); - fraction.setAccessible(true); - fraction.set(metabolism, 1.0); - - // set up simulation - MersenneTwisterFast random = new MersenneTwisterFast(); - Simulation sim = mock(Simulation.class); - + public void stepProcessUpdatesInternalGlucoseAndPyruvate() + throws NoSuchFieldException, IllegalAccessException { // mock inflammation process PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); @@ -149,38 +148,23 @@ public void testStepProcess() throws NoSuchFieldException, IllegalAccessExceptio } @Test - public void testStepProcessWithZeroInitialGlucose() { - // set up metabolism class - when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); - when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.0); - metabolism = new PatchProcessMetabolismCART(mockCell); - - // set up simulation - MersenneTwisterFast random = new MersenneTwisterFast(); - Simulation sim = mock(Simulation.class); + public void stepProcessWithZeroInitialGlucoseReducesMass() { + metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] = 0; // mock inflammation process PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); + double initialMass = metabolism.mass; metabolism.stepProcess(random, sim); + double finalMass = metabolism.mass; - assertEquals(0.0, metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]); + assertTrue(finalMass < initialMass); } @Test - public void testStepProcessWithMaxGlucoseConcentration() { - // set up metabolism class - when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); - when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")) - .thenReturn(Double.MAX_VALUE); - metabolism = new PatchProcessMetabolismCART(mockCell); - - // set up simulation - MersenneTwisterFast random = new MersenneTwisterFast(); - Simulation sim = mock(Simulation.class); - + public void stepProcessWithMaxGlucoseConcentrationDoesNotOverflow() { // mock inflammation process PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); @@ -192,16 +176,7 @@ public void testStepProcessWithMaxGlucoseConcentration() { } @Test - public void testStepProcessWithNegativeGlucoseConcentration() { - // set up metabolism class - when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); - when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(-1.0); - metabolism = new PatchProcessMetabolismCART(mockCell); - - // set up simulation - MersenneTwisterFast random = new MersenneTwisterFast(); - Simulation sim = mock(Simulation.class); - + public void stepProcessWithNegativeGlucoseConcentrationStaysPositive() { // mock inflammation process PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); @@ -213,16 +188,7 @@ public void testStepProcessWithNegativeGlucoseConcentration() { } @Test - public void testStepProcessWithZeroOxygenConcentration() { - // set up metabolism class - when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); - when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); - metabolism = new PatchProcessMetabolismCART(mockCell); - - // set up simulation - MersenneTwisterFast random = new MersenneTwisterFast(); - Simulation sim = mock(Simulation.class); - + public void stepProcessWithZeroOxygenConcentrationProducesNoOxygen() { // mock inflammation process PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); @@ -236,16 +202,7 @@ public void testStepProcessWithZeroOxygenConcentration() { } @Test - public void testStepProcessWithMaxOxygenConcentration() { - // set up metabolism class - when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); - when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); - metabolism = new PatchProcessMetabolismCART(mockCell); - - // set up simulation - MersenneTwisterFast random = new MersenneTwisterFast(); - Simulation sim = mock(Simulation.class); - + public void stepProcessWithMaxOxygenConcentrationDoesNotOverflow() { // mock inflammation process PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); @@ -259,86 +216,28 @@ public void testStepProcessWithMaxOxygenConcentration() { } @Test - public void testActivatedMetabolicPreference() + public void activatedCellProducesMoreGlucose() throws IllegalAccessException, NoSuchFieldException { - // set up metabolism class - when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); - when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); - metabolism = new PatchProcessMetabolismCART(mockCell); - - // set up simulation - MersenneTwisterFast random = new MersenneTwisterFast(); - Simulation sim = mock(Simulation.class); - - // mock inflammation process - PatchProcessInflammation inflammation = new inflammationMock(mockCell); - Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker"); - activeTicker.setAccessible(true); - activeTicker.set(inflammation, 1); - when(mockCell.getProcess(any())).thenReturn(inflammation); - when(mockCell.getActivationStatus()).thenReturn(true); - - metabolism.stepProcess(random, sim); - - double expectedMetabolicPreference = 1.0 + 1.0; // base + active - assertEquals(expectedMetabolicPreference, metabolism.getFinalMetabolicPreference()); - } - - @Test - public void testActivatedGlucoseUptakeRate() - throws IllegalAccessException, NoSuchFieldException { - // set up metabolism class - when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); - when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); - metabolism = new PatchProcessMetabolismCART(mockCell); - - // set up simulation - MersenneTwisterFast random = new MersenneTwisterFast(); - Simulation sim = mock(Simulation.class); - + metabolism.extAmts[PatchProcessMetabolismCART.GLUCOSE] = 10000.0; // mock inflammation process PatchProcessInflammation inflammation = new inflammationMock(mockCell); - Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker"); - activeTicker.setAccessible(true); - activeTicker.set(inflammation, 1); when(mockCell.getProcess(any())).thenReturn(inflammation); - when(mockCell.getActivationStatus()).thenReturn(true); - metabolism.stepProcess(random, sim); - - double expectedGlucoseUptakeRate = 1.12 + 1.0; // base + active - assertEquals(expectedGlucoseUptakeRate, metabolism.getFinalGlucoseUptakeRate()); - } - - @Test - public void testActivatedMinimumMassFraction() - throws NoSuchFieldException, IllegalAccessException { - // set up metabolism class - when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); - when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); - metabolism = new PatchProcessMetabolismCART(mockCell); - - // set up simulation - MersenneTwisterFast random = new MersenneTwisterFast(); - Simulation sim = mock(Simulation.class); - - // mock inflammation process - PatchProcessInflammation inflammation = new inflammationMock(mockCell); + double inactiveGlucose = metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]; + double inactivePyruvate = metabolism.intAmts[PatchProcessMetabolismCART.PYRUVATE]; Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker"); activeTicker.setAccessible(true); activeTicker.set(inflammation, 1); - when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); - metabolism.stepProcess(random, sim); + double activatedGlucose = metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]; + double activatedPyruvate = metabolism.intAmts[PatchProcessMetabolismCART.PYRUVATE]; - double expectedMinimumMassFraction = 1.0 + 1.0; // base + active - assertEquals(expectedMinimumMassFraction, metabolism.getFinalMinimumMassFraction()); + assertTrue(activatedGlucose > inactiveGlucose); } @Test - public void testUpdate() { - metabolism = new PatchProcessMetabolismCART(mockCell); + public void updateSplitCellEvenlyDividesGlucose() { PatchProcessMetabolismCART parentProcess = new PatchProcessMetabolismCART(mockCell); parentProcess.intAmts[PatchProcessMetabolismCART.GLUCOSE] = 100; when(mockCell.getVolume()).thenReturn(cellVolume / 2); @@ -350,8 +249,7 @@ public void testUpdate() { } @Test - public void testUpdateZeroVolumeParent() { - metabolism = new PatchProcessMetabolismCART(mockCell); + public void updateSplitCellUnevenlyDividesGlucose() { PatchProcessMetabolismCART parentProcess = new PatchProcessMetabolismCART(mockCell); parentProcess.intAmts[PatchProcessMetabolismCART.GLUCOSE] = 100; when(mockCell.getVolume()).thenReturn(0.0); From cf5213b2596e159a7b518dbada03ad3e5f4967d5 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Feb 2025 18:27:05 +0000 Subject: [PATCH 124/185] changing antigen getter/setter method names, changing flag variable name --- .../patch/agent/action/PatchActionKill.java | 6 ++--- .../patch/agent/action/PatchActionReset.java | 2 +- src/arcade/patch/agent/cell/PatchCell.java | 8 +++---- .../patch/agent/cell/PatchCellCART.java | 12 +++++----- .../patch/agent/cell/PatchCellCARTCD4.java | 24 +++++++++---------- .../patch/agent/cell/PatchCellCARTCD8.java | 20 ++++++++-------- .../agent/action/PatchActionKillTest.java | 3 +-- .../agent/action/PatchActionResetTest.java | 12 +++++----- .../agent/cell/PatchCellCARTCD4Test.java | 18 +++++++------- .../agent/cell/PatchCellCARTCD8Test.java | 16 ++++++------- .../patch/agent/cell/PatchCellCARTTest.java | 8 +++---- .../patch/agent/cell/PatchCellTest.java | 12 +++++----- 12 files changed, 70 insertions(+), 71 deletions(-) diff --git a/src/arcade/patch/agent/action/PatchActionKill.java b/src/arcade/patch/agent/action/PatchActionKill.java index 5273319b7..a0119a7dd 100644 --- a/src/arcade/patch/agent/action/PatchActionKill.java +++ b/src/arcade/patch/agent/action/PatchActionKill.java @@ -78,10 +78,10 @@ public void step(SimState state) { // If bound target cell is stopped, stop helper. if (target.isStopped()) { - if (c.getAntigenFlag() == AntigenFlag.BOUND_ANTIGEN) { - c.setAntigenFlag(AntigenFlag.UNBOUND); + if (c.getBindingFlag() == AntigenFlag.BOUND_ANTIGEN) { + c.setBindingFlag(AntigenFlag.UNBOUND); } else { - c.setAntigenFlag(AntigenFlag.BOUND_CELL_RECEPTOR); + c.setBindingFlag(AntigenFlag.BOUND_CELL_RECEPTOR); } return; } diff --git a/src/arcade/patch/agent/action/PatchActionReset.java b/src/arcade/patch/agent/action/PatchActionReset.java index 3d4c52c5f..ce8717403 100644 --- a/src/arcade/patch/agent/action/PatchActionReset.java +++ b/src/arcade/patch/agent/action/PatchActionReset.java @@ -60,7 +60,7 @@ public void step(SimState state) { } if (c.getState() == State.CYTOTOXIC || c.getState() == State.STIMULATORY) { - c.setAntigenFlag(AntigenFlag.UNBOUND); + c.setBindingFlag(AntigenFlag.UNBOUND); c.setState(State.QUIESCENT); } } diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index e5e198916..3d7d84115 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -544,10 +544,10 @@ static boolean checkLocation( /** * Sets the cell binding flag. * - * @param flag the target cell antigen binding state + * @param newBindingFlag the target cell antigen binding state */ - public void setAntigenFlag(PatchEnums.AntigenFlag flag) { - this.bindingFlag = flag; + public void setBindingFlag(PatchEnums.AntigenFlag newBindingFlag) { + this.bindingFlag = newBindingFlag; } /** @@ -555,7 +555,7 @@ public void setAntigenFlag(PatchEnums.AntigenFlag flag) { * * @return the cell antigen binding state */ - public PatchEnums.AntigenFlag getAntigenFlag() { + public PatchEnums.AntigenFlag getBindingFlag() { return this.bindingFlag; } diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index a16285c9d..ae0bc1b51 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -216,7 +216,7 @@ public PatchCellTissue bindTarget( // Bind target with some probability if a nearby cell has targets to bind. int maxSearch = 0; if (neighbors == 0) { - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); return null; } else { if (neighbors < searchAbility) { @@ -252,7 +252,7 @@ public PatchCellTissue bindTarget( if (logCAR >= randomAntigen && logSelf < randomSelf) { // cell binds to antigen receptor - super.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + super.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); boundAntigensCount++; selfReceptors += (int) @@ -261,7 +261,7 @@ public PatchCellTissue bindTarget( return tissueCell; } else if (logCAR >= randomAntigen && logSelf >= randomSelf) { // cell binds to antigen receptor and self - super.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); + super.setBindingFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); boundAntigensCount++; boundSelfCount++; selfReceptors += @@ -271,16 +271,16 @@ public PatchCellTissue bindTarget( return tissueCell; } else if (logCAR < randomAntigen && logSelf >= randomSelf) { // cell binds to self - super.setAntigenFlag(AntigenFlag.BOUND_CELL_RECEPTOR); + super.setBindingFlag(AntigenFlag.BOUND_CELL_RECEPTOR); boundSelfCount++; return tissueCell; } else { // cell doesn't bind to anything - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); } } } - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); } return null; } diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 4f7695646..014423d81 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -65,7 +65,7 @@ public void step(SimState simstate) { if (state != State.APOPTOTIC && age > apoptosisAge) { setState(State.APOPTOTIC); - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); this.activated = false; } @@ -84,14 +84,14 @@ public void step(SimState simstate) { if (state != State.APOPTOTIC && energy < 0) { if (super.energy < super.energyThreshold) { super.setState(State.APOPTOTIC); - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); this.activated = false; } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED && state != State.STARVED) { super.setState(State.STARVED); - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); } } else if (state == State.STARVED && energy >= 0) { super.setState(State.UNDEFINED); @@ -110,7 +110,7 @@ public void step(SimState simstate) { } else { super.setState(State.SENESCENT); } - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); this.activated = false; } else { // Cell attempts to bind to a target @@ -118,15 +118,15 @@ public void step(SimState simstate) { super.bindTarget(sim, location, new MersenneTwisterFast(simstate.seed())); // If cell is bound to both antigen and self it will become anergic. - if (super.getAntigenFlag() == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { + if (super.getBindingFlag() == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { if (simstate.random.nextDouble() > super.anergicFraction) { super.setState(State.APOPTOTIC); } else { super.setState(State.ANERGIC); } - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); this.activated = false; - } else if (super.getAntigenFlag() == AntigenFlag.BOUND_ANTIGEN) { + } else if (super.getBindingFlag() == AntigenFlag.BOUND_ANTIGEN) { // If cell is only bound to target antigen, the cell // can potentially become properly activated. @@ -138,7 +138,7 @@ public void step(SimState simstate) { } else { super.setState(State.EXHAUSTED); } - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); this.activated = false; } else { // if CD4 cell is properly activated, it can stimulate @@ -146,10 +146,10 @@ public void step(SimState simstate) { this.lastActiveTicker = 0; this.activated = true; if (target.isStopped()) { - target.setAntigenFlag(AntigenFlag.UNBOUND); + target.setBindingFlag(AntigenFlag.UNBOUND); } target.setState(State.QUIESCENT); - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); // reset the cell PatchActionReset reset = new PatchActionReset( @@ -161,8 +161,8 @@ public void step(SimState simstate) { } } else { // If self binding, unbind - if (super.getAntigenFlag() == AntigenFlag.BOUND_CELL_RECEPTOR) - super.setAntigenFlag(AntigenFlag.UNBOUND); + if (super.getBindingFlag() == AntigenFlag.BOUND_CELL_RECEPTOR) + super.setBindingFlag(AntigenFlag.UNBOUND); // Check activation status. If cell has been activated before, // it will proliferate. If not, it will migrate. if (activated) { diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index b3f621616..c2c7fb6ae 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -65,7 +65,7 @@ public void step(SimState simstate) { if (state != State.APOPTOTIC && age > apoptosisAge) { setState(State.APOPTOTIC); - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); this.activated = false; } @@ -84,14 +84,14 @@ public void step(SimState simstate) { if (state != State.APOPTOTIC && energy < 0) { if (super.energy < super.energyThreshold) { super.setState(State.APOPTOTIC); - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); this.activated = false; } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED && state != State.STARVED) { super.setState(State.STARVED); - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); } } else if (state == State.STARVED && energy >= 0) { super.setState(State.UNDEFINED); @@ -110,22 +110,22 @@ public void step(SimState simstate) { } else { super.setState(State.SENESCENT); } - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); this.activated = false; } else { // Cell attempts to bind to a target PatchCellTissue target = super.bindTarget(sim, location, simstate.random); // If cell is bound to both antigen and self it will become anergic. - if (super.getAntigenFlag() == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { + if (super.getBindingFlag() == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { if (simstate.random.nextDouble() > super.anergicFraction) { super.setState(State.APOPTOTIC); } else { super.setState(State.ANERGIC); } - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); this.activated = false; - } else if (super.getAntigenFlag() == AntigenFlag.BOUND_ANTIGEN) { + } else if (super.getBindingFlag() == AntigenFlag.BOUND_ANTIGEN) { // If cell is only bound to target antigen, the cell // can potentially become properly activated. @@ -137,7 +137,7 @@ public void step(SimState simstate) { } else { super.setState(State.EXHAUSTED); } - super.setAntigenFlag(AntigenFlag.UNBOUND); + super.setBindingFlag(AntigenFlag.UNBOUND); this.activated = false; } else { // if CD8 cell is properly activated, it can be cytotoxic @@ -163,8 +163,8 @@ public void step(SimState simstate) { } } else { // If self binding, unbind - if (super.getAntigenFlag() == AntigenFlag.BOUND_CELL_RECEPTOR) - super.setAntigenFlag(AntigenFlag.UNBOUND); + if (super.getBindingFlag() == AntigenFlag.BOUND_CELL_RECEPTOR) + super.setBindingFlag(AntigenFlag.UNBOUND); // Check activation status. If cell has been activated before, // it will proliferate. If not, it will migrate. if (activated) { diff --git a/test/arcade/patch/agent/action/PatchActionKillTest.java b/test/arcade/patch/agent/action/PatchActionKillTest.java index 312a50d4b..a5e9d412b 100644 --- a/test/arcade/patch/agent/action/PatchActionKillTest.java +++ b/test/arcade/patch/agent/action/PatchActionKillTest.java @@ -14,7 +14,6 @@ import arcade.patch.util.PatchEnums; import arcade.patch.util.PatchEnums.AntigenFlag; import arcade.patch.util.PatchEnums.State; -import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; public class PatchActionKillTest { @@ -62,7 +61,7 @@ public void testStep_TargetCellStopped() { when(mockTarget.isStopped()).thenReturn(true); action.step(sim); verify(mockTarget, never()).setState(any()); - verify(mockCell).setAntigenFlag(AntigenFlag.BOUND_CELL_RECEPTOR); + verify(mockCell).setBindingFlag(AntigenFlag.BOUND_CELL_RECEPTOR); } @Test diff --git a/test/arcade/patch/agent/action/PatchActionResetTest.java b/test/arcade/patch/agent/action/PatchActionResetTest.java index 838b06185..69b5ac408 100644 --- a/test/arcade/patch/agent/action/PatchActionResetTest.java +++ b/test/arcade/patch/agent/action/PatchActionResetTest.java @@ -80,33 +80,33 @@ public void testSchedule() { @Test public void testStep_CytotoxicState() { when(mockCell.isStopped()).thenReturn(false); - mockCell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + mockCell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); when(mockCell.getState()).thenReturn(State.CYTOTOXIC); actionReset.step(mock(SimState.class)); verify(mockCell).setState(State.QUIESCENT); - assertEquals(AntigenFlag.UNBOUND, mockCell.getAntigenFlag()); + assertEquals(AntigenFlag.UNBOUND, mockCell.getBindingFlag()); } @Test public void testStep_StimulatoryState() { when(mockCell.isStopped()).thenReturn(false); - mockCell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + mockCell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); when(mockCell.getState()).thenReturn(State.STIMULATORY); actionReset.step(mock(SimState.class)); verify(mockCell).setState(State.QUIESCENT); - assertEquals(AntigenFlag.UNBOUND, mockCell.getAntigenFlag()); + assertEquals(AntigenFlag.UNBOUND, mockCell.getBindingFlag()); } @Test public void testStep_StoppedCell() { when(mockCell.isStopped()).thenReturn(true); - mockCell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + mockCell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); actionReset.step(mock(SimState.class)); verify(mockCell, never()).setState(any(State.class)); - assertEquals(AntigenFlag.BOUND_ANTIGEN, mockCell.getAntigenFlag()); + assertEquals(AntigenFlag.BOUND_ANTIGEN, mockCell.getBindingFlag()); } } diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index c424bbd11..602a7ebd4 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -157,7 +157,7 @@ public void testStepSetsStateToApoptoticWhenEnergyIsLow() { cell.step(sim); assertEquals(State.APOPTOTIC, cell.getState()); - assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); assertFalse(cell.getActivationStatus()); } @@ -190,7 +190,7 @@ public void testStepSetsStateToStarvedWhenEnergyIsNegativeAndMoreThanThreshold() cell.step(sim); assertEquals(State.STARVED, cell.getState()); - assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); } @Test @@ -253,7 +253,7 @@ public void testStepSetsStateToSenescentWhenDivisionsAreZero() { cell.step(sim); assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.SENESCENT); - assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); assertFalse(cell.getActivationStatus()); } @@ -282,11 +282,11 @@ public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { sim.random = random; cell.setState(State.UNDEFINED); - cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); + cell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); cell.step(sim); assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.ANERGIC); - assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); assertFalse(cell.getActivationStatus()); } @@ -315,7 +315,7 @@ public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { any(MersenneTwisterFast.class)); sim.random = random; cell.setState(State.UNDEFINED); - cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + cell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); Schedule schedule = mock(Schedule.class); doReturn(true).when(schedule).scheduleOnce(any(Steppable.class)); @@ -324,7 +324,7 @@ public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { cell.step(sim); assertEquals(State.STIMULATORY, cell.getState()); - assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); assertTrue(cell.getActivationStatus()); } @@ -415,12 +415,12 @@ public void testStepSetsStatetoExhaustedWhenOverstimulated() { any(MersenneTwisterFast.class)); sim.random = random; cell.setState(State.UNDEFINED); - cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + cell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); cell.step(sim); assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.EXHAUSTED); - assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); assertFalse(cell.getActivationStatus()); } } diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index 14988ffb4..32758774e 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -156,7 +156,7 @@ public void testStepSetsStateToApoptoticWhenEnergyIsLow() { cell.step(sim); assertEquals(State.APOPTOTIC, cell.getState()); - assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); assertFalse(cell.getActivationStatus()); } @@ -189,7 +189,7 @@ public void testStepSetsStateToStarvedWhenEnergyIsNegativeAndMoreThanThreshold() cell.step(sim); assertEquals(State.STARVED, cell.getState()); - assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); } @Test @@ -252,7 +252,7 @@ public void testStepSetsStateToSenescentWhenDivisionsAreZero() { cell.step(sim); assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.SENESCENT); - assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); assertFalse(cell.getActivationStatus()); } @@ -281,11 +281,11 @@ public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { sim.random = random; cell.setState(State.UNDEFINED); - cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); + cell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); cell.step(sim); assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.ANERGIC); - assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); assertFalse(cell.getActivationStatus()); } @@ -314,7 +314,7 @@ public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { any(MersenneTwisterFast.class)); sim.random = random; cell.setState(State.UNDEFINED); - cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + cell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); Schedule schedule = mock(Schedule.class); doReturn(true).when(schedule).scheduleOnce(any(Steppable.class)); @@ -412,12 +412,12 @@ public void testStepSetsStatetoExhaustedWhenOverstimulated() { any(MersenneTwisterFast.class)); sim.random = random; cell.setState(State.UNDEFINED); - cell.setAntigenFlag(AntigenFlag.BOUND_ANTIGEN); + cell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); cell.step(sim); assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.EXHAUSTED); - assertEquals(AntigenFlag.UNBOUND, cell.getAntigenFlag()); + assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); assertFalse(cell.getActivationStatus()); } } diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java index 9f4b6167c..c0d00670e 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTTest.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -144,7 +144,7 @@ public static void setupMocks() { public void bindTargetNoNeighborsDoesNotBind() { PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); assertNull(result); - assertEquals(PatchEnums.AntigenFlag.UNBOUND, patchCellCART.getAntigenFlag()); + assertEquals(PatchEnums.AntigenFlag.UNBOUND, patchCellCART.getBindingFlag()); } @Test @@ -158,7 +158,7 @@ public void bindTargetWithSelfBindingBindsToCell() { PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); bag.clear(); assertNotNull(result); - assertEquals(PatchEnums.AntigenFlag.BOUND_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); + assertEquals(PatchEnums.AntigenFlag.BOUND_CELL_RECEPTOR, patchCellCART.getBindingFlag()); } @Test @@ -173,7 +173,7 @@ public void bindTargetWithSelfAndAntigenBindingBindsToCell() { bag.clear(); assertNotNull(result); assertEquals( - PatchEnums.AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR, patchCellCART.getAntigenFlag()); + PatchEnums.AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR, patchCellCART.getBindingFlag()); } @Test @@ -187,6 +187,6 @@ public void bindTargetBindsToCell() { PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); bag.clear(); assertNotNull(result); - assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, patchCellCART.getAntigenFlag()); + assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, patchCellCART.getBindingFlag()); } } diff --git a/test/arcade/patch/agent/cell/PatchCellTest.java b/test/arcade/patch/agent/cell/PatchCellTest.java index ea51ca049..c31681e56 100644 --- a/test/arcade/patch/agent/cell/PatchCellTest.java +++ b/test/arcade/patch/agent/cell/PatchCellTest.java @@ -128,17 +128,17 @@ public void addCycle_givenCycles_appendValues() { } @Test - public void testSetAntigenFlag() { + public void testSetBindingFlag() { PatchCell cell = new PatchCellMock(baseContainer, locationMock, parametersMock); - cell.setAntigenFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); - assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, cell.getAntigenFlag()); + cell.setBindingFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); + assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, cell.getBindingFlag()); } @Test - public void testGetAntigenFlag() { + public void testGetBindingFlag() { PatchCell cell = new PatchCellMock(baseContainer, locationMock, parametersMock); - cell.setAntigenFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); - assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, cell.getAntigenFlag()); + cell.setBindingFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); + assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, cell.getBindingFlag()); } @Test From 68496b2da9b11936c807184e06fe1417fc28349f Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Feb 2025 18:46:20 +0000 Subject: [PATCH 125/185] removing javadoc for param that does not exist --- src/arcade/patch/agent/cell/PatchCellCART.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index ae0bc1b51..9037a5def 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -45,8 +45,7 @@ * *

      Cell parameters are tracked using a map between the parameter name and value. Daughter cell * parameter values are drawn from a distribution centered on the parent cell parameter. The - * parameter classes have support for loading in distributions to reflect heterogeneity. ({@code - * HETEROGENEITY}). + * parameter classes have support for loading in distributions to reflect heterogeneity. */ public abstract class PatchCellCART extends PatchCell { /** Cell activation flag. */ From 4823de815e7f13d01bcdf918ebd1e9098309b65a Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Feb 2025 18:54:51 +0000 Subject: [PATCH 126/185] renaming self and car antigen vars to be more intuitive --- src/arcade/patch/agent/cell/PatchCellCART.java | 16 ++++++++-------- .../patch/agent/cell/PatchCellCARTCD4.java | 4 ++-- .../patch/agent/cell/PatchCellCARTCD8.java | 4 ++-- .../patch/agent/cell/PatchCellCARTCD4Test.java | 4 ++-- .../patch/agent/cell/PatchCellCARTCD8Test.java | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 9037a5def..d4ffff5d3 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -58,10 +58,10 @@ public abstract class PatchCellCART extends PatchCell { protected int selfReceptorsStart; /** number of bound CAR antigens. */ - protected int boundAntigensCount; + protected int boundCARAntigensCount; /** number of bound PDL-1 antigens. */ - protected int boundSelfCount; + protected int boundSelfAntigensCount; /** number of neighbors that T cell is able to search through. */ protected final double searchAbility; @@ -151,8 +151,8 @@ public PatchCellCART( PatchCellContainer container, Location location, Parameters parameters, GrabBag links) { super(container, location, parameters, links); // initialized non-loaded parameters - boundAntigensCount = 0; - boundSelfCount = 0; + boundCARAntigensCount = 0; + boundSelfAntigensCount = 0; lastActiveTicker = 0; activated = true; @@ -252,7 +252,7 @@ public PatchCellTissue bindTarget( if (logCAR >= randomAntigen && logSelf < randomSelf) { // cell binds to antigen receptor super.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); - boundAntigensCount++; + boundCARAntigensCount++; selfReceptors += (int) ((double) selfReceptorsStart @@ -261,8 +261,8 @@ public PatchCellTissue bindTarget( } else if (logCAR >= randomAntigen && logSelf >= randomSelf) { // cell binds to antigen receptor and self super.setBindingFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); - boundAntigensCount++; - boundSelfCount++; + boundCARAntigensCount++; + boundSelfAntigensCount++; selfReceptors += (int) ((double) selfReceptorsStart @@ -271,7 +271,7 @@ public PatchCellTissue bindTarget( } else if (logCAR < randomAntigen && logSelf >= randomSelf) { // cell binds to self super.setBindingFlag(AntigenFlag.BOUND_CELL_RECEPTOR); - boundSelfCount++; + boundSelfAntigensCount++; return tissueCell; } else { // cell doesn't bind to anything diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 014423d81..09e36425c 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -72,7 +72,7 @@ public void step(SimState simstate) { // Increase time since last active ticker super.lastActiveTicker++; if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { - if (super.boundAntigensCount != 0) super.boundAntigensCount--; + if (super.boundCARAntigensCount != 0) super.boundCARAntigensCount--; } if (super.lastActiveTicker / 1440 >= 7) super.activated = false; @@ -132,7 +132,7 @@ public void step(SimState simstate) { // Check overstimulation. If cell has bound to // target antigens too many times, becomes exhausted. - if (boundAntigensCount > maxAntigenBinding) { + if (boundCARAntigensCount > maxAntigenBinding) { if (simstate.random.nextDouble() > super.exhaustedFraction) { super.setState(State.APOPTOTIC); } else { diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index c2c7fb6ae..05a70a135 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -72,7 +72,7 @@ public void step(SimState simstate) { // Increase time since last active ticker super.lastActiveTicker++; if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { - if (super.boundAntigensCount != 0) super.boundAntigensCount--; + if (super.boundCARAntigensCount != 0) super.boundCARAntigensCount--; } if (super.lastActiveTicker / 1440 > 7) super.activated = false; @@ -131,7 +131,7 @@ public void step(SimState simstate) { // Check overstimulation. If cell has bound to // target antigens too many times, becomes exhausted. - if (boundAntigensCount > maxAntigenBinding) { + if (boundCARAntigensCount > maxAntigenBinding) { if (simstate.random.nextDouble() > super.exhaustedFraction) { super.setState(State.APOPTOTIC); } else { diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index 602a7ebd4..f87e805ce 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -301,7 +301,7 @@ public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { doAnswer( invocationOnMock -> { cell.state = invocationOnMock.getArgument(0); - cell.boundAntigensCount = 0; + cell.boundCARAntigensCount = 0; cell.module = module; return null; }) @@ -401,7 +401,7 @@ public void testStepSetsStatetoExhaustedWhenOverstimulated() { doAnswer( invocationOnMock -> { cell.state = invocationOnMock.getArgument(0); - cell.boundAntigensCount = cell.maxAntigenBinding + 1; + cell.boundCARAntigensCount = cell.maxAntigenBinding + 1; cell.module = module; return null; }) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index 32758774e..4ea409092 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -300,7 +300,7 @@ public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { doAnswer( invocationOnMock -> { cell.state = invocationOnMock.getArgument(0); - cell.boundAntigensCount = 0; + cell.boundCARAntigensCount = 0; cell.module = module; return null; }) @@ -398,7 +398,7 @@ public void testStepSetsStatetoExhaustedWhenOverstimulated() { doAnswer( invocationOnMock -> { cell.state = invocationOnMock.getArgument(0); - cell.boundAntigensCount = cell.maxAntigenBinding + 1; + cell.boundCARAntigensCount = cell.maxAntigenBinding + 1; cell.module = module; return null; }) From 9d4249c2237257680890e6e9f4d467f65457c30b Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Feb 2025 20:17:46 +0000 Subject: [PATCH 127/185] refactoring bindTarget method --- .../patch/agent/cell/PatchCellCART.java | 187 +++++++++++------- 1 file changed, 121 insertions(+), 66 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index d4ffff5d3..3fa2ec2cf 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -189,42 +189,21 @@ public PatchCellCART( */ public PatchCellTissue bindTarget( Simulation sim, PatchLocation loc, MersenneTwisterFast random) { - double kDCAR = carAffinity * (loc.getVolume() * 1e-15 * 6.022E23); - double kDSelf = selfReceptorAffinity * (loc.getVolume() * 1e-15 * 6.022E23); - PatchGrid grid = (PatchGrid) sim.getGrid(); - - // get all tissue agents from this location - Bag allAgents = new Bag(); - getTissueAgents(allAgents, grid.getObjectsAtLocation(loc)); - // get all agents from neighboring locations - for (Location neighborLocation : loc.getNeighbors()) { - Bag bag = new Bag(grid.getObjectsAtLocation(neighborLocation)); - getTissueAgents(allAgents, bag); - } + double kDCAR = computeAffinity(carAffinity, loc); + double kDSelf = computeAffinity(selfReceptorAffinity, loc); + PatchGrid grid = (PatchGrid) sim.getGrid(); - // remove self + Bag allAgents = getAllTissueNeighbors(grid, loc); allAgents.remove(this); - - // shuffle bag allAgents.shuffle(random); - - // get number of neighbors int neighbors = allAgents.size(); - // Bind target with some probability if a nearby cell has targets to bind. - int maxSearch = 0; if (neighbors == 0) { super.setBindingFlag(AntigenFlag.UNBOUND); return null; } else { - if (neighbors < searchAbility) { - maxSearch = neighbors; - } else { - maxSearch = (int) searchAbility; - } - - // Within maximum search vicinity, search for neighboring cells to bind to + int maxSearch = (int) Math.min(neighbors, searchAbility); for (int i = 0; i < maxSearch; i++) { Cell cell = (Cell) allAgents.get(i); if (cell.getState() != State.APOPTOTIC && cell.getState() != State.NECROTIC) { @@ -232,10 +211,10 @@ public PatchCellTissue bindTarget( double cARAntigens = tissueCell.getCarAntigens(); double selfTargets = tissueCell.getSelfAntigens(); - double hillCAR = - getHillCoefficient(cARAntigens, kDCAR, cars, 5000, carAlpha, carBeta); - double hillSelf = - getHillCoefficient( + double probabilityCAR = + computeProbability(cARAntigens, kDCAR, cars, 5000, carAlpha, carBeta); + double probabilitySelf = + computeProbability( selfTargets, kDSelf, selfReceptors, @@ -243,36 +222,15 @@ public PatchCellTissue bindTarget( selfAlpha, selfBeta); - double logCAR = getLog(hillCAR); - double logSelf = getLog(hillSelf); - - double randomAntigen = random.nextDouble(); + double randomCAR = random.nextDouble(); double randomSelf = random.nextDouble(); - if (logCAR >= randomAntigen && logSelf < randomSelf) { - // cell binds to antigen receptor - super.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); - boundCARAntigensCount++; - selfReceptors += - (int) - ((double) selfReceptorsStart - * (0.95 + random.nextDouble() / 10)); - return tissueCell; - } else if (logCAR >= randomAntigen && logSelf >= randomSelf) { - // cell binds to antigen receptor and self - super.setBindingFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); - boundCARAntigensCount++; - boundSelfAntigensCount++; - selfReceptors += - (int) - ((double) selfReceptorsStart - * (0.95 + random.nextDouble() / 10)); - return tissueCell; - } else if (logCAR < randomAntigen && logSelf >= randomSelf) { - // cell binds to self - super.setBindingFlag(AntigenFlag.BOUND_CELL_RECEPTOR); - boundSelfAntigensCount++; - return tissueCell; + if (probabilityCAR >= randomCAR && probabilitySelf < randomSelf) { + return bindToCARAntigen(tissueCell); + } else if (probabilityCAR >= randomCAR && probabilitySelf >= randomSelf) { + return bindToCARAndSelfAntigen(tissueCell); + } else if (probabilityCAR < randomCAR && probabilitySelf >= randomSelf) { + return bindToSelfAntigen(tissueCell); } else { // cell doesn't bind to anything super.setBindingFlag(AntigenFlag.UNBOUND); @@ -309,7 +267,88 @@ private void getTissueAgents(Bag tissueAgents, Bag possibleAgents) { } /** - * Computes Hill Coefficient for given parameters. + * Computes the binding probability for the receptor with the given parameters. + * + * @param antigens the number of antigens on the target cell + * @param kD binding affinity of receptor + * @param currentReceptors number of receptors currently on the cell + * @param startingReceptors number of starting receptors on the cell + * @param alpha fudge factor for receptor binding + * @param beta fudge factor for receptor binding + * @return the binding probability for the receptor + */ + private double computeProbability( + double antigens, + double kD, + int currentReceptors, + int startingReceptors, + double alpha, + double beta) { + double bind = + getBindingCoefficient( + antigens, kD, currentReceptors, startingReceptors, alpha, beta); + return getSig(bind); + } + + /** + * Updates T cell as response to CAR antigen binding. + * + * @param tissueCell the target cell to bind to + * @return the target tissue cell to bind to + */ + private PatchCellTissue bindToCARAntigen(PatchCellTissue tissueCell) { + super.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); + boundCARAntigensCount++; + updateSelfReceptors(); + return tissueCell; + } + + /** + * Updates T cell as response to CAR and PLD1 antigen binding. + * + * @param tissueCell the target cell to bind to + * @return the target tissue cell to bind to + */ + private PatchCellTissue bindToCARAndSelfAntigen(PatchCellTissue tissueCell) { + super.setBindingFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); + boundCARAntigensCount++; + boundSelfAntigensCount++; + updateSelfReceptors(); + return tissueCell; + } + + /** + * Updates T cell as response to PLD1 antigen binding. + * + * @param tissueCell the target cell to bind to + * @return the target tissue cell to bind to + */ + private PatchCellTissue bindToSelfAntigen(PatchCellTissue tissueCell) { + super.setBindingFlag(AntigenFlag.BOUND_CELL_RECEPTOR); + boundSelfAntigensCount++; + return tissueCell; + } + + /** + * Returns all tissue cells in neighborhood and current location. + * + * @param grid the grid used in the simulation + * @param loc current location of the cell + * @return bag of all tissue cells in neighborhood and current location + */ + private Bag getAllTissueNeighbors(PatchGrid grid, PatchLocation loc) { + Bag neighbors = new Bag(); + getTissueAgents(neighbors, grid.getObjectsAtLocation(loc)); + for (Location neighborLocation : loc.getNeighbors()) { + Bag bag = new Bag(grid.getObjectsAtLocation(neighborLocation)); + getTissueAgents(neighbors, bag); + } + + return neighbors; + } + + /** + * Computes binding coefficient for given parameters. * * @param targets the number of antigens on the target cell * @param affinity binding affinity of receptor @@ -317,9 +356,9 @@ private void getTissueAgents(Bag tissueAgents, Bag possibleAgents) { * @param startReceptors number of starting receptors on the cell * @param alpha fudge factor for receptor binding * @param beta fudge factor for receptor binding - * @return the Hill Coefficient + * @return the binding Coefficient */ - private double getHillCoefficient( + private double getBindingCoefficient( double targets, double affinity, int currentReceptors, @@ -332,12 +371,28 @@ private double getHillCoefficient( } /** - * Computes log function for given hill coeffient. + * Applies sigmoidal function onto given binding coeffient. * - * @param hill hill coefficient for the log function - * @return the log value + * @param bindingCoefficient the binding coefficient for the log function + * @return the sigmoidal value */ - private double getLog(double hill) { - return 2 * (1 / (1 + Math.exp(-1 * hill))) - 1; + private double getSig(double bindingCoefficient) { + return 2 * (1 / (1 + Math.exp(-1 * bindingCoefficient))) - 1; + } + + /** + * Converts the affinity units to molecules. + * + * @param affinity the molar affinity of the receptor + * @param loc the current location of the cell + * @return the affinity per receptor molecule + */ + private double computeAffinity(double affinity, PatchLocation loc) { + return affinity * (loc.getVolume() * 1e-15 * 6.022E23); + } + + /** Randomly increases number of self receptors after CAR binding. */ + private void updateSelfReceptors() { + selfReceptors += (int) ((double) selfReceptorsStart * (0.95 + Math.random() / 10)); } } From d002a802d53ca7f04925064759d8ac1d7ee29e3b Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Feb 2025 20:32:28 +0000 Subject: [PATCH 128/185] updating process updating in proliferation module --- .../agent/module/PatchModuleProliferation.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/arcade/patch/agent/module/PatchModuleProliferation.java b/src/arcade/patch/agent/module/PatchModuleProliferation.java index a515a5eaf..8190f1419 100644 --- a/src/arcade/patch/agent/module/PatchModuleProliferation.java +++ b/src/arcade/patch/agent/module/PatchModuleProliferation.java @@ -3,7 +3,10 @@ import sim.util.Bag; import ec.util.MersenneTwisterFast; import arcade.core.agent.cell.CellContainer; +import arcade.core.agent.process.ProcessDomain; import arcade.core.sim.Simulation; +import arcade.core.util.MiniBox; +import arcade.core.util.Parameters; import arcade.patch.agent.cell.PatchCell; import arcade.patch.agent.process.PatchProcess; import arcade.patch.env.grid.PatchGrid; @@ -85,13 +88,14 @@ public void step(MersenneTwisterFast random, Simulation sim) { // Create and schedule new cell. int newID = sim.getID(); CellContainer newContainer = cell.make(newID, State.UNDEFINED, random); + Parameters newParameters = cell.getParameters(); PatchCell newCell = (PatchCell) newContainer.convert( sim.getCellFactory(), newLocation, random, - cell.getParameters()); + newParameters); sim.getGrid().addObject(newCell, newLocation); newCell.schedule(sim.getSchedule()); @@ -105,12 +109,11 @@ public void step(MersenneTwisterFast random, Simulation sim) { newCell.setEnergy(energy * (1 - split)); // Update processes. - Domain[] processes = Domain.values(); - for (Domain processName : processes) { - PatchProcess process = (PatchProcess) newCell.getProcess(processName); - if (process != null) { - process.update(cell.getProcess(processName)); - } + MiniBox processBox = newParameters.filter("(PROCESS)"); + for (String processKey : processBox.getKeys()) { + ProcessDomain domain = Domain.valueOf(processKey); + PatchProcess process = (PatchProcess) newCell.getProcess(domain); + process.update(cell.getProcess(domain)); } // TODO: Update environment generator sites. } else { From de6554185e4dd64463d4ddf718aa278ddd0a3d76 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Feb 2025 22:03:09 +0000 Subject: [PATCH 129/185] moving setState down to subclass, adding T cell specific states --- .../patch/agent/action/PatchActionReset.java | 2 +- src/arcade/patch/agent/cell/PatchCell.java | 24 -------------- .../patch/agent/cell/PatchCellCART.java | 32 +++++++++++++++++++ .../patch/agent/cell/PatchCellTissue.java | 24 ++++++++++++++ 4 files changed, 57 insertions(+), 25 deletions(-) diff --git a/src/arcade/patch/agent/action/PatchActionReset.java b/src/arcade/patch/agent/action/PatchActionReset.java index ce8717403..29478355c 100644 --- a/src/arcade/patch/agent/action/PatchActionReset.java +++ b/src/arcade/patch/agent/action/PatchActionReset.java @@ -61,7 +61,7 @@ public void step(SimState state) { if (c.getState() == State.CYTOTOXIC || c.getState() == State.STIMULATORY) { c.setBindingFlag(AntigenFlag.UNBOUND); - c.setState(State.QUIESCENT); + c.setState(State.UNDEFINED); } } } diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 3d7d84115..b3ae64a42 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -17,9 +17,6 @@ import arcade.core.util.GrabBag; import arcade.core.util.MiniBox; import arcade.core.util.Parameters; -import arcade.patch.agent.module.PatchModuleApoptosis; -import arcade.patch.agent.module.PatchModuleMigration; -import arcade.patch.agent.module.PatchModuleProliferation; import arcade.patch.agent.process.PatchProcessInflammation; import arcade.patch.agent.process.PatchProcessMetabolism; import arcade.patch.agent.process.PatchProcessSignaling; @@ -329,27 +326,6 @@ public boolean isStopped() { return isStopped; } - @Override - public void setState(CellState state) { - this.state = state; - this.flag = Flag.UNDEFINED; - - switch ((State) state) { - case PROLIFERATIVE: - module = new PatchModuleProliferation(this); - break; - case MIGRATORY: - module = new PatchModuleMigration(this); - break; - case APOPTOTIC: - module = new PatchModuleApoptosis(this); - break; - default: - module = null; - break; - } - } - /** * Makes the specified {@link Process} object. * diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 3fa2ec2cf..503d4343a 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -3,12 +3,17 @@ import sim.util.Bag; import ec.util.MersenneTwisterFast; import arcade.core.agent.cell.Cell; +import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; import arcade.core.util.GrabBag; import arcade.core.util.Parameters; +import arcade.patch.agent.module.PatchModuleApoptosis; +import arcade.patch.agent.module.PatchModuleMigration; +import arcade.patch.agent.module.PatchModuleProliferation; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; +import arcade.patch.util.PatchEnums; import static arcade.patch.util.PatchEnums.AntigenFlag; import static arcade.patch.util.PatchEnums.State; @@ -175,6 +180,33 @@ public PatchCellCART( cars = parameters.getInt("CARS"); } + @Override + public void setState(CellState state) { + this.state = state; + this.flag = PatchEnums.Flag.UNDEFINED; + + switch ((State) state) { + case PROLIFERATIVE: + module = new PatchModuleProliferation(this); + break; + case MIGRATORY: + module = new PatchModuleMigration(this); + break; + case APOPTOTIC: + module = new PatchModuleApoptosis(this); + break; + case CYTOTOXIC: + throw new UnsupportedOperationException(); + case QUIESCENT: + this.setState(State.PAUSED); + case STIMULATORY: + throw new UnsupportedOperationException(); + default: + module = null; + break; + } + } + /** * Determines if CAR T cell agent is bound to neighbor through receptor-target binding. * diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index a3aff01b5..d448db239 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -7,6 +7,9 @@ import arcade.core.sim.Simulation; import arcade.core.util.GrabBag; import arcade.core.util.Parameters; +import arcade.patch.agent.module.PatchModuleApoptosis; +import arcade.patch.agent.module.PatchModuleMigration; +import arcade.patch.agent.module.PatchModuleProliferation; import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.Flag; import arcade.patch.util.PatchEnums.State; @@ -136,6 +139,27 @@ public void step(SimState simstate) { } } + @Override + public void setState(CellState state) { + this.state = state; + this.flag = Flag.UNDEFINED; + + switch ((State) state) { + case PROLIFERATIVE: + module = new PatchModuleProliferation(this); + break; + case MIGRATORY: + module = new PatchModuleMigration(this); + break; + case APOPTOTIC: + module = new PatchModuleApoptosis(this); + break; + default: + module = null; + break; + } + } + /** * Returns the number of CAR antigens on this cell. * From f066a513d76bc303035acf03d980360565e32ae1 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Feb 2025 22:09:30 +0000 Subject: [PATCH 130/185] making car setState override the tissue one --- src/arcade/patch/agent/cell/PatchCell.java | 24 +++++++++++++++++++ .../patch/agent/cell/PatchCellTissue.java | 24 ------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index b3ae64a42..d4ae9562a 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -17,6 +17,9 @@ import arcade.core.util.GrabBag; import arcade.core.util.MiniBox; import arcade.core.util.Parameters; +import arcade.patch.agent.module.PatchModuleApoptosis; +import arcade.patch.agent.module.PatchModuleMigration; +import arcade.patch.agent.module.PatchModuleProliferation; import arcade.patch.agent.process.PatchProcessInflammation; import arcade.patch.agent.process.PatchProcessMetabolism; import arcade.patch.agent.process.PatchProcessSignaling; @@ -347,6 +350,27 @@ public Process makeProcess(ProcessDomain domain, String version) { } } + @Override + public void setState(CellState state) { + this.state = state; + this.flag = Flag.UNDEFINED; + + switch ((State) state) { + case PROLIFERATIVE: + module = new PatchModuleProliferation(this); + break; + case MIGRATORY: + module = new PatchModuleMigration(this); + break; + case APOPTOTIC: + module = new PatchModuleApoptosis(this); + break; + default: + module = null; + break; + } + } + @Override public void schedule(Schedule schedule) { stopper = schedule.scheduleRepeating(this, Ordering.CELLS.ordinal(), 1); diff --git a/src/arcade/patch/agent/cell/PatchCellTissue.java b/src/arcade/patch/agent/cell/PatchCellTissue.java index d448db239..a3aff01b5 100644 --- a/src/arcade/patch/agent/cell/PatchCellTissue.java +++ b/src/arcade/patch/agent/cell/PatchCellTissue.java @@ -7,9 +7,6 @@ import arcade.core.sim.Simulation; import arcade.core.util.GrabBag; import arcade.core.util.Parameters; -import arcade.patch.agent.module.PatchModuleApoptosis; -import arcade.patch.agent.module.PatchModuleMigration; -import arcade.patch.agent.module.PatchModuleProliferation; import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.Flag; import arcade.patch.util.PatchEnums.State; @@ -139,27 +136,6 @@ public void step(SimState simstate) { } } - @Override - public void setState(CellState state) { - this.state = state; - this.flag = Flag.UNDEFINED; - - switch ((State) state) { - case PROLIFERATIVE: - module = new PatchModuleProliferation(this); - break; - case MIGRATORY: - module = new PatchModuleMigration(this); - break; - case APOPTOTIC: - module = new PatchModuleApoptosis(this); - break; - default: - module = null; - break; - } - } - /** * Returns the number of CAR antigens on this cell. * From 6fe1a9775360c57a7438218926d6d244dcc9f27b Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Feb 2025 22:17:48 +0000 Subject: [PATCH 131/185] uncommeting WIP comments --- src/arcade/patch/agent/cell/PatchCellCART.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 503d4343a..f5b8b16bf 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -195,12 +195,12 @@ public void setState(CellState state) { case APOPTOTIC: module = new PatchModuleApoptosis(this); break; - case CYTOTOXIC: - throw new UnsupportedOperationException(); + // case CYTOTOXIC: + // throw new UnsupportedOperationException(); case QUIESCENT: this.setState(State.PAUSED); - case STIMULATORY: - throw new UnsupportedOperationException(); + // case STIMULATORY: + // throw new UnsupportedOperationException(); default: module = null; break; From d2c924fe2d8d68d49faf0a6523dcb46714249781 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Feb 2025 22:22:41 +0000 Subject: [PATCH 132/185] renaming tests, editing test to accomodate state change --- test/arcade/patch/agent/action/PatchActionResetTest.java | 4 ++-- test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/arcade/patch/agent/action/PatchActionResetTest.java b/test/arcade/patch/agent/action/PatchActionResetTest.java index 69b5ac408..177007c70 100644 --- a/test/arcade/patch/agent/action/PatchActionResetTest.java +++ b/test/arcade/patch/agent/action/PatchActionResetTest.java @@ -85,7 +85,7 @@ public void testStep_CytotoxicState() { actionReset.step(mock(SimState.class)); - verify(mockCell).setState(State.QUIESCENT); + verify(mockCell).setState(State.UNDEFINED); assertEquals(AntigenFlag.UNBOUND, mockCell.getBindingFlag()); } @@ -97,7 +97,7 @@ public void testStep_StimulatoryState() { actionReset.step(mock(SimState.class)); - verify(mockCell).setState(State.QUIESCENT); + verify(mockCell).setState(State.UNDEFINED); assertEquals(AntigenFlag.UNBOUND, mockCell.getBindingFlag()); } diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index f87e805ce..5e7edf594 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -291,7 +291,7 @@ public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { } @Test - public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { + public void testStepSetsStateToStimulatoryWhenBoundToAntigen() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); From abb533a6930d7d03dcea0ab9063a1cc05c459c5c Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Feb 2025 22:39:25 +0000 Subject: [PATCH 133/185] renaming inflammmation variable names to appease linter --- .../process/PatchProcessInflammation.java | 64 +++++++++---------- .../process/PatchProcessInflammationCD4.java | 22 +++---- .../process/PatchProcessInflammationCD8.java | 22 +++---- .../PatchProcessInflammationCD4Test.java | 14 ++-- 4 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index 4c5efe0db..f3acefa16 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -37,13 +37,13 @@ public abstract class PatchProcessInflammation extends PatchProcess { protected static final int IL2RBG = 3; /** ID for three-chain IL-2 receptor complex. */ - protected static final int IL2RBGa = 4; + protected static final int IL2RBGA = 4; /** ID for IL-2-two-chain IL-2 receptor complex. */ protected static final int IL2_IL2RBG = 5; /** ID for IL-2-three-chain IL-2 receptor complex. */ - protected static final int IL2_IL2RBGa = 6; + protected static final int IL2_IL2RBGA = 6; /** ID for granzyme, internal. */ protected static final int GRANZYME = 7; @@ -147,9 +147,9 @@ public PatchProcessInflammation(PatchCellCART c) { amts[IL2_INT_TOTAL] = 0; amts[IL2R_TOTAL] = iL2Receptors; amts[IL2RBG] = iL2Receptors; - amts[IL2RBGa] = 0; + amts[IL2RBGA] = 0; amts[IL2_IL2RBG] = 0; - amts[IL2_IL2RBGa] = 0; + amts[IL2_IL2RBGA] = 0; // Molecule names. names = new ArrayList(); @@ -157,9 +157,9 @@ public PatchProcessInflammation(PatchCellCART c) { names.add(IL2_EXT, "external_IL-2"); names.add(IL2R_TOTAL, "IL2R_total"); names.add(IL2RBG, "IL2R_two_chain_complex"); - names.add(IL2RBGa, "IL2R_three_chain_complex"); + names.add(IL2RBGA, "IL2R_three_chain_complex"); names.add(IL2_IL2RBG, "IL-2_IL2R_two_chain_complex"); - names.add(IL2_IL2RBGa, "IL-2_IL2R_three_chain_complex"); + names.add(IL2_IL2RBGA, "IL-2_IL2R_three_chain_complex"); // Initialize prior IL2 array. this.boundArray = new double[180]; @@ -177,55 +177,55 @@ public PatchProcessInflammation(PatchCellCART c) { dydt[IL2_EXT] = kOff * y[IL2_IL2RBG] - + kOff * y[IL2_IL2RBGa] + + kOff * y[IL2_IL2RBGA] - kOn2 * y[IL2RBG] * y[IL2_EXT] - - kOn3 * y[IL2RBGa] * y[IL2_EXT]; + - kOn3 * y[IL2RBGA] * y[IL2_EXT]; dydt[IL2RBG] = kOff * y[IL2_IL2RBG] - kOn2 * y[IL2RBG] * y[IL2_EXT] - - K_CONVERT * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) * y[IL2RBG] - + K_REC * (y[IL2_IL2RBG] + y[IL2_IL2RBGa] + y[IL2RBGa]); - dydt[IL2RBGa] = - kOff * y[IL2_IL2RBGa] - - kOn3 * y[IL2RBGa] * y[IL2_EXT] - + K_CONVERT * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) * y[IL2RBG] - - K_REC * y[IL2RBGa]; + - K_CONVERT * (y[IL2_IL2RBG] + y[IL2_IL2RBGA]) * y[IL2RBG] + + K_REC * (y[IL2_IL2RBG] + y[IL2_IL2RBGA] + y[IL2RBGA]); + dydt[IL2RBGA] = + kOff * y[IL2_IL2RBGA] + - kOn3 * y[IL2RBGA] * y[IL2_EXT] + + K_CONVERT * (y[IL2_IL2RBG] + y[IL2_IL2RBGA]) * y[IL2RBG] + - K_REC * y[IL2RBGA]; dydt[IL2_IL2RBG] = kOn2 * y[IL2RBG] * y[IL2_EXT] - kOff * y[IL2_IL2RBG] - K_CONVERT - * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) + * (y[IL2_IL2RBG] + y[IL2_IL2RBGA]) * y[IL2_IL2RBG] - K_REC * y[IL2_IL2RBG]; - dydt[IL2_IL2RBGa] = - kOn3 * y[IL2RBGa] * y[IL2_EXT] - - kOff * y[IL2_IL2RBGa] + dydt[IL2_IL2RBGA] = + kOn3 * y[IL2RBGA] * y[IL2_EXT] + - kOff * y[IL2_IL2RBGA] + K_CONVERT - * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) + * (y[IL2_IL2RBG] + y[IL2_IL2RBGA]) * y[IL2_IL2RBG] - - K_REC * y[IL2_IL2RBGa]; + - K_REC * y[IL2_IL2RBGA]; dydt[IL2_INT_TOTAL] = kOn2 * y[IL2RBG] * y[IL2_EXT] - kOff * y[IL2_IL2RBG] - K_CONVERT - * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) + * (y[IL2_IL2RBG] + y[IL2_IL2RBGA]) * y[IL2_IL2RBG] - K_REC * y[IL2_IL2RBG] - + kOn3 * y[IL2RBGa] * y[IL2_EXT] - - kOff * y[IL2_IL2RBGa] + + kOn3 * y[IL2RBGA] * y[IL2_EXT] + - kOff * y[IL2_IL2RBGA] + K_CONVERT - * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) + * (y[IL2_IL2RBG] + y[IL2_IL2RBGA]) * y[IL2_IL2RBG] - - K_REC * y[IL2_IL2RBGa]; + - K_REC * y[IL2_IL2RBGA]; dydt[IL2R_TOTAL] = kOff * y[IL2_IL2RBG] - kOn2 * y[IL2RBG] * y[IL2_EXT] - - K_CONVERT * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) * y[IL2RBG] - + K_REC * (y[IL2_IL2RBG] + y[IL2_IL2RBGa] + y[IL2RBGa]) - + kOff * y[IL2_IL2RBGa] - - kOn3 * y[IL2RBGa] * y[IL2_EXT] - + K_CONVERT * (y[IL2_IL2RBG] + y[IL2_IL2RBGa]) * y[IL2RBG] - - K_REC * y[IL2RBGa]; + - K_CONVERT * (y[IL2_IL2RBG] + y[IL2_IL2RBGA]) * y[IL2RBG] + + K_REC * (y[IL2_IL2RBG] + y[IL2_IL2RBGA] + y[IL2RBGA]) + + kOff * y[IL2_IL2RBGA] + - kOn3 * y[IL2RBGA] * y[IL2_EXT] + + K_CONVERT * (y[IL2_IL2RBG] + y[IL2_IL2RBGA]) * y[IL2RBG] + - K_REC * y[IL2RBGA]; return dydt; }; diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java index d0e23e92e..4062957d8 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java @@ -92,27 +92,27 @@ public void update(Process mod) { // Update daughter cell inflammation as a fraction of parent. // this.volume = this.cell.getVolume(); - this.amts[IL2RBGa] = inflammation.amts[IL2RBGa] * split; + this.amts[IL2RBGA] = inflammation.amts[IL2RBGA] * split; this.amts[IL2_IL2RBG] = inflammation.amts[IL2_IL2RBG] * split; - this.amts[IL2_IL2RBGa] = inflammation.amts[IL2_IL2RBGa] * split; + this.amts[IL2_IL2RBGA] = inflammation.amts[IL2_IL2RBGA] * split; this.amts[IL2RBG] = - iL2Receptors - this.amts[IL2RBGa] - this.amts[IL2_IL2RBG] - this.amts[IL2_IL2RBGa]; - this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2RBG] + this.amts[IL2_IL2RBGa]; - this.amts[IL2R_TOTAL] = this.amts[IL2RBG] + this.amts[IL2RBGa]; + iL2Receptors - this.amts[IL2RBGA] - this.amts[IL2_IL2RBG] - this.amts[IL2_IL2RBGA]; + this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2RBG] + this.amts[IL2_IL2RBGA]; + this.amts[IL2R_TOTAL] = this.amts[IL2RBG] + this.amts[IL2RBGA]; this.boundArray = (inflammation.boundArray).clone(); // Update parent cell with remaining fraction. - inflammation.amts[IL2RBGa] *= (1 - split); + inflammation.amts[IL2RBGA] *= (1 - split); inflammation.amts[IL2_IL2RBG] *= (1 - split); - inflammation.amts[IL2_IL2RBGa] *= (1 - split); + inflammation.amts[IL2_IL2RBGA] *= (1 - split); inflammation.amts[IL2RBG] = iL2Receptors - - inflammation.amts[IL2RBGa] + - inflammation.amts[IL2RBGA] - inflammation.amts[IL2_IL2RBG] - - inflammation.amts[IL2_IL2RBGa]; + - inflammation.amts[IL2_IL2RBGA]; inflammation.amts[IL2_INT_TOTAL] = - inflammation.amts[IL2_IL2RBG] + inflammation.amts[IL2_IL2RBGa]; - inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2RBG] + inflammation.amts[IL2RBGa]; + inflammation.amts[IL2_IL2RBG] + inflammation.amts[IL2_IL2RBGA]; + inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2RBG] + inflammation.amts[IL2RBGA]; inflammation.volume *= (1 - split); } diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index 3fd0d5108..2d1e2f0f0 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -64,28 +64,28 @@ public void update(Process mod) { double split = (this.cell.getVolume() / this.volume); // Update daughter cell inflammation as a fraction of parent. - this.amts[IL2RBGa] = inflammation.amts[IL2RBGa] * split; + this.amts[IL2RBGA] = inflammation.amts[IL2RBGA] * split; this.amts[IL2_IL2RBG] = inflammation.amts[IL2_IL2RBG] * split; - this.amts[IL2_IL2RBGa] = inflammation.amts[IL2_IL2RBGa] * split; + this.amts[IL2_IL2RBGA] = inflammation.amts[IL2_IL2RBGA] * split; this.amts[IL2RBG] = - iL2Receptors - this.amts[IL2RBGa] - this.amts[IL2_IL2RBG] - this.amts[IL2_IL2RBGa]; - this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2RBG] + this.amts[IL2_IL2RBGa]; - this.amts[IL2R_TOTAL] = this.amts[IL2RBG] + this.amts[IL2RBGa]; + iL2Receptors - this.amts[IL2RBGA] - this.amts[IL2_IL2RBG] - this.amts[IL2_IL2RBGA]; + this.amts[IL2_INT_TOTAL] = this.amts[IL2_IL2RBG] + this.amts[IL2_IL2RBGA]; + this.amts[IL2R_TOTAL] = this.amts[IL2RBG] + this.amts[IL2RBGA]; this.amts[GRANZYME] = inflammation.amts[GRANZYME] * split; this.boundArray = (inflammation.boundArray).clone(); // Update parent cell with remaining fraction. - inflammation.amts[IL2RBGa] *= (1 - split); + inflammation.amts[IL2RBGA] *= (1 - split); inflammation.amts[IL2_IL2RBG] *= (1 - split); - inflammation.amts[IL2_IL2RBGa] *= (1 - split); + inflammation.amts[IL2_IL2RBGA] *= (1 - split); inflammation.amts[IL2RBG] = iL2Receptors - - inflammation.amts[IL2RBGa] + - inflammation.amts[IL2RBGA] - inflammation.amts[IL2_IL2RBG] - - inflammation.amts[IL2_IL2RBGa]; + - inflammation.amts[IL2_IL2RBGA]; inflammation.amts[IL2_INT_TOTAL] = - inflammation.amts[IL2_IL2RBG] + inflammation.amts[IL2_IL2RBGa]; - inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2RBG] + inflammation.amts[IL2RBGa]; + inflammation.amts[IL2_IL2RBG] + inflammation.amts[IL2_IL2RBGA]; + inflammation.amts[IL2R_TOTAL] = inflammation.amts[IL2RBG] + inflammation.amts[IL2RBGA]; inflammation.amts[GRANZYME] *= (1 - split); inflammation.volume *= (1 - split); } diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java index a482fc296..45274eb6c 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java @@ -249,28 +249,28 @@ public void testStepProcessWithZeroIL2ProdRate() public void testUpdate() { inflammation = new PatchProcessInflammationCD4(mockCell); PatchProcessInflammationCD4 parentProcess = new PatchProcessInflammationCD4(mockCell); - parentProcess.amts[PatchProcessInflammationCD4.IL2RBGa] = 100; + parentProcess.amts[PatchProcessInflammationCD4.IL2RBGA] = 100; when(mockCell.getVolume()).thenReturn(cellVolume / 2); inflammation.update(parentProcess); - assertEquals(50, inflammation.amts[PatchProcessInflammationCD4.IL2RBGa]); - assertEquals(50, parentProcess.amts[PatchProcessInflammationCD4.IL2RBGa]); + assertEquals(50, inflammation.amts[PatchProcessInflammationCD4.IL2RBGA]); + assertEquals(50, parentProcess.amts[PatchProcessInflammationCD4.IL2RBGA]); } @Test public void testUpdateWithZeroVolume() { inflammation = new PatchProcessInflammationCD4(mockCell); PatchProcessInflammationCD4 parentProcess = new PatchProcessInflammationCD4(mockCell); - parentProcess.amts[PatchProcessInflammationCD4.IL2RBGa] = 100; + parentProcess.amts[PatchProcessInflammationCD4.IL2RBGA] = 100; when(mockCell.getVolume()).thenReturn(0.0); inflammation.update(parentProcess); - assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2RBGa]); + assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2RBGA]); assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2_IL2RBG]); - assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2_IL2RBGa]); + assertEquals(0.0, inflammation.amts[PatchProcessInflammationCD8.IL2_IL2RBGA]); - assertEquals(100, parentProcess.amts[PatchProcessInflammationCD4.IL2RBGa]); + assertEquals(100, parentProcess.amts[PatchProcessInflammationCD4.IL2RBGA]); } } From d7f191d376269793f6469f87ce1b740c90119c65 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Feb 2025 22:53:23 +0000 Subject: [PATCH 134/185] renaming private methods to not be confused with public --- src/arcade/patch/agent/cell/PatchCellCART.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index f5b8b16bf..c7f562ff1 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -226,7 +226,7 @@ public PatchCellTissue bindTarget( double kDSelf = computeAffinity(selfReceptorAffinity, loc); PatchGrid grid = (PatchGrid) sim.getGrid(); - Bag allAgents = getAllTissueNeighbors(grid, loc); + Bag allAgents = grabAllTissueNeighbors(grid, loc); allAgents.remove(this); allAgents.shuffle(random); int neighbors = allAgents.size(); @@ -289,7 +289,7 @@ public boolean getActivationStatus() { * @param tissueAgents the bag to add tissue cells into * @param possibleAgents the bag of possible agents to check for tissue cells */ - private void getTissueAgents(Bag tissueAgents, Bag possibleAgents) { + private void grabTissueAgents(Bag tissueAgents, Bag possibleAgents) { for (Object agent : possibleAgents) { Cell cell = (Cell) agent; if (cell instanceof PatchCellTissue) { @@ -317,9 +317,9 @@ private double computeProbability( double alpha, double beta) { double bind = - getBindingCoefficient( + calculateBindingCoefficient( antigens, kD, currentReceptors, startingReceptors, alpha, beta); - return getSig(bind); + return applySig(bind); } /** @@ -368,12 +368,12 @@ private PatchCellTissue bindToSelfAntigen(PatchCellTissue tissueCell) { * @param loc current location of the cell * @return bag of all tissue cells in neighborhood and current location */ - private Bag getAllTissueNeighbors(PatchGrid grid, PatchLocation loc) { + private Bag grabAllTissueNeighbors(PatchGrid grid, PatchLocation loc) { Bag neighbors = new Bag(); - getTissueAgents(neighbors, grid.getObjectsAtLocation(loc)); + grabTissueAgents(neighbors, grid.getObjectsAtLocation(loc)); for (Location neighborLocation : loc.getNeighbors()) { Bag bag = new Bag(grid.getObjectsAtLocation(neighborLocation)); - getTissueAgents(neighbors, bag); + grabTissueAgents(neighbors, bag); } return neighbors; @@ -390,7 +390,7 @@ private Bag getAllTissueNeighbors(PatchGrid grid, PatchLocation loc) { * @param beta fudge factor for receptor binding * @return the binding Coefficient */ - private double getBindingCoefficient( + private double calculateBindingCoefficient( double targets, double affinity, int currentReceptors, @@ -408,7 +408,7 @@ private double getBindingCoefficient( * @param bindingCoefficient the binding coefficient for the log function * @return the sigmoidal value */ - private double getSig(double bindingCoefficient) { + private double applySig(double bindingCoefficient) { return 2 * (1 / (1 + Math.exp(-1 * bindingCoefficient))) - 1; } From e2b794a62e127053ed4e5d3249cb10e01a7a8dfa Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Feb 2025 23:00:42 +0000 Subject: [PATCH 135/185] adding test for fetching activation status --- test/arcade/patch/agent/cell/PatchCellCARTTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java index c0d00670e..0387a0f05 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTTest.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -1,5 +1,6 @@ package arcade.patch.agent.cell; +import java.lang.reflect.Field; import java.util.ArrayList; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -189,4 +190,13 @@ public void bindTargetBindsToCell() { assertNotNull(result); assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, patchCellCART.getBindingFlag()); } + + @Test + public void getActivationStatusReturnsStatus() + throws NoSuchFieldException, IllegalAccessException { + Field activation = PatchCellCART.class.getDeclaredField("activated"); + activation.setAccessible(true); + activation.set(patchCellCART, true); + assertTrue(patchCellCART.getActivationStatus()); + } } From f386ae22afcae8efc87e302c0b440af1635f9369 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Feb 2025 23:48:58 +0000 Subject: [PATCH 136/185] editing test naming conventions --- .../agent/action/PatchActionKillTest.java | 8 +++---- .../agent/action/PatchActionResetTest.java | 8 +++---- .../agent/action/PatchActionTreatTest.java | 14 ++++++++----- .../agent/cell/PatchCellCARTCD4Test.java | 20 +++++++++--------- .../agent/cell/PatchCellCARTCD8Test.java | 20 +++++++++--------- .../patch/agent/cell/PatchCellCARTTest.java | 10 ++++----- .../patch/agent/cell/PatchCellTest.java | 4 ++-- .../PatchProcessInflammationCD4Test.java | 19 ++++++++++------- .../PatchProcessInflammationCD8Test.java | 14 +++++++------ .../process/PatchProcessInflammationTest.java | 8 +++---- .../PatchProcessMetabolismCARTTest.java | 21 ++++++++++--------- 11 files changed, 78 insertions(+), 68 deletions(-) diff --git a/test/arcade/patch/agent/action/PatchActionKillTest.java b/test/arcade/patch/agent/action/PatchActionKillTest.java index a5e9d412b..a3698ecd8 100644 --- a/test/arcade/patch/agent/action/PatchActionKillTest.java +++ b/test/arcade/patch/agent/action/PatchActionKillTest.java @@ -43,21 +43,21 @@ public void setUp() { } @Test - public void testSchedule() { + public void schedule_updatesSchedule() { action.schedule(schedule); verify(schedule) .scheduleOnce(anyDouble(), eq(PatchEnums.Ordering.ACTIONS.ordinal()), eq(action)); } @Test - public void testStep_CARCellStopped() { + public void step_CARCellStopped_doesNotChangeCell() { when(mockCell.isStopped()).thenReturn(true); action.step(sim); verify(mockTarget, never()).setState(any()); } @Test - public void testStep_TargetCellStopped() { + public void step_targetCellStopped_doesNotChangeCell() { when(mockTarget.isStopped()).thenReturn(true); action.step(sim); verify(mockTarget, never()).setState(any()); @@ -65,7 +65,7 @@ public void testStep_TargetCellStopped() { } @Test - public void testStep_KillTargetCell() { + public void step_killTargetCell_killsCellAndUsesGranzyme() { when(mockCell.isStopped()).thenReturn(false); when(mockTarget.isStopped()).thenReturn(false); PatchModuleApoptosis mockProcess = mock(PatchModuleApoptosis.class); diff --git a/test/arcade/patch/agent/action/PatchActionResetTest.java b/test/arcade/patch/agent/action/PatchActionResetTest.java index 177007c70..c927866e3 100644 --- a/test/arcade/patch/agent/action/PatchActionResetTest.java +++ b/test/arcade/patch/agent/action/PatchActionResetTest.java @@ -69,7 +69,7 @@ public void setUp() { } @Test - public void testSchedule() { + public void schedule_updatesSimSchedule() { Schedule mockSchedule = mock(Schedule.class); actionReset.schedule(mockSchedule); verify(mockSchedule) @@ -78,7 +78,7 @@ public void testSchedule() { } @Test - public void testStep_CytotoxicState() { + public void step_cytotoxicState_unbindsAndUncommitsCell() { when(mockCell.isStopped()).thenReturn(false); mockCell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); when(mockCell.getState()).thenReturn(State.CYTOTOXIC); @@ -90,7 +90,7 @@ public void testStep_CytotoxicState() { } @Test - public void testStep_StimulatoryState() { + public void step_stimulatoryState_unbindsAndUncommitsCell() { when(mockCell.isStopped()).thenReturn(false); mockCell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); when(mockCell.getState()).thenReturn(State.STIMULATORY); @@ -102,7 +102,7 @@ public void testStep_StimulatoryState() { } @Test - public void testStep_StoppedCell() { + public void step_stoppedCell_doesNotChangeCell() { when(mockCell.isStopped()).thenReturn(true); mockCell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); actionReset.step(mock(SimState.class)); diff --git a/test/arcade/patch/agent/action/PatchActionTreatTest.java b/test/arcade/patch/agent/action/PatchActionTreatTest.java index 727fb3c8d..2f23f9615 100644 --- a/test/arcade/patch/agent/action/PatchActionTreatTest.java +++ b/test/arcade/patch/agent/action/PatchActionTreatTest.java @@ -103,7 +103,8 @@ final Bag createPatchCellsWithVolumeAndCriticalHeight(int n, double volume, doub } @Test - public void testSchedule() throws NoSuchFieldException, IllegalAccessException { + public void schedule_callsScheduleOnAction() + throws NoSuchFieldException, IllegalAccessException { action = new PatchActionTreat(series, parameters); ArrayList populations = new ArrayList<>(); @@ -122,7 +123,7 @@ public void testSchedule() throws NoSuchFieldException, IllegalAccessException { } @Test - public void testStep() throws NoSuchFieldException, IllegalAccessException { + public void step_addsObjectsToSim() throws NoSuchFieldException, IllegalAccessException { action = new PatchActionTreat(series, parameters); ArrayList populations = new ArrayList<>(); @@ -141,7 +142,8 @@ public void testStep() throws NoSuchFieldException, IllegalAccessException { } @Test - public void testZeroDose() throws NoSuchFieldException, IllegalAccessException { + public void step_zeroDose_doesNotAddObjects() + throws NoSuchFieldException, IllegalAccessException { when(parameters.getInt("DOSE")).thenReturn(0); action = new PatchActionTreat(series, parameters); @@ -160,7 +162,8 @@ public void testZeroDose() throws NoSuchFieldException, IllegalAccessException { } @Test - public void testCheckLocationSpace() throws NoSuchFieldException, IllegalAccessException { + public void checkLocationSpace_withEmptySpaces_returnsAvailable() + throws NoSuchFieldException, IllegalAccessException { action = new PatchActionTreat(series, parameters); ArrayList populations = new ArrayList<>(); MiniBox populationMock = mock(MiniBox.class); @@ -181,7 +184,8 @@ public void testCheckLocationSpace() throws NoSuchFieldException, IllegalAccessE } @Test - public void testMaxConfluency() throws NoSuchFieldException, IllegalAccessException { + public void checkLocation_maxConfluency_returnsUnavailable() + throws NoSuchFieldException, IllegalAccessException { action = new PatchActionTreat(series, parameters); Field density = PatchActionTreat.class.getDeclaredField("maxConfluency"); density.setAccessible(true); diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index 5e7edf594..4d86cc8aa 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -100,7 +100,7 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { } @Test - public void testStepIncreasesAge() { + public void step_increasesAge() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -129,7 +129,7 @@ public void testStepIncreasesAge() { } @Test - public void testStepSetsStateToApoptoticWhenEnergyIsLow() { + public void step_whenEnergyIsLow_setsStateToApoptotic() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -162,7 +162,7 @@ public void testStepSetsStateToApoptoticWhenEnergyIsLow() { } @Test - public void testStepSetsStateToStarvedWhenEnergyIsNegativeAndMoreThanThreshold() { + public void step_whenEnergyIsNegativeAndMoreThanThreshold_setsStateToStarved() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -194,7 +194,7 @@ public void testStepSetsStateToStarvedWhenEnergyIsNegativeAndMoreThanThreshold() } @Test - public void testStepSetsStateToApoptoticWhenEnergyIsNegativeAndLessThanThreshold() { + public void step_whenEnergyIsNegativeAndLessThanThreshold_setsStateToApoptotic() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -225,7 +225,7 @@ public void testStepSetsStateToApoptoticWhenEnergyIsNegativeAndLessThanThreshold } @Test - public void testStepSetsStateToSenescentWhenDivisionsAreZero() { + public void step_whenDivisionsAreZero_setsStateToSenescent() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -258,7 +258,7 @@ public void testStepSetsStateToSenescentWhenDivisionsAreZero() { } @Test - public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { + public void step_whenBoundToBothAntigenAndSelf_setsStateToAnergic() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -291,7 +291,7 @@ public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { } @Test - public void testStepSetsStateToStimulatoryWhenBoundToAntigen() { + public void step_whenBoundToAntigen_setsStateToStimulatory() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -329,7 +329,7 @@ public void testStepSetsStateToStimulatoryWhenBoundToAntigen() { } @Test - public void testStepSetsStateToProliferativeWhenActivated() { + public void step_whenActivated_setsStateToProliferative() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -360,7 +360,7 @@ public void testStepSetsStateToProliferativeWhenActivated() { } @Test - public void testStepSetsStateToMigratoryWhenNotActivated() { + public void step_whenNotActivated_setsStateToMigratory() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -391,7 +391,7 @@ public void testStepSetsStateToMigratoryWhenNotActivated() { } @Test - public void testStepSetsStatetoExhaustedWhenOverstimulated() { + public void step_whenOverstimulated_setsStateToExhausted() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index 4ea409092..f04103aa3 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -99,7 +99,7 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { } @Test - public void testStepIncreasesAge() { + public void step_increasesAge() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -128,7 +128,7 @@ public void testStepIncreasesAge() { } @Test - public void testStepSetsStateToApoptoticWhenEnergyIsLow() { + public void step_whenEnergyIsLow_setsStateToApoptotic() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -161,7 +161,7 @@ public void testStepSetsStateToApoptoticWhenEnergyIsLow() { } @Test - public void testStepSetsStateToStarvedWhenEnergyIsNegativeAndMoreThanThreshold() { + public void step_whenEnergyIsNegativeAndMoreThanThreshold_setsStateToStarved() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -193,7 +193,7 @@ public void testStepSetsStateToStarvedWhenEnergyIsNegativeAndMoreThanThreshold() } @Test - public void testStepSetsStateToApoptoticWhenEnergyIsNegativeAndLessThanThreshold() { + public void step_whenEnergyIsNegativeAndMoreThanThreshold_setsStateToApoptotic() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -224,7 +224,7 @@ public void testStepSetsStateToApoptoticWhenEnergyIsNegativeAndLessThanThreshold } @Test - public void testStepSetsStateToSenescentWhenDivisionsAreZero() { + public void step_whenDivisionsAreZero_setsStateToSenescent() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -257,7 +257,7 @@ public void testStepSetsStateToSenescentWhenDivisionsAreZero() { } @Test - public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { + public void step_whenBoundToBothAntigenAndSelf_setsStateToAnergic() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -290,7 +290,7 @@ public void testStepSetsStateToAnergicWhenBoundToBothAntigenAndSelf() { } @Test - public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { + public void step_whenBoundToAntigen_setsStateToCytotoxic() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -326,7 +326,7 @@ public void testStepSetsStateToCytotoxicWhenBoundToAntigen() { } @Test - public void testStepSetsStateToProliferativeWhenActivated() { + public void step_whenActivated_setsStateToProliferative() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -357,7 +357,7 @@ public void testStepSetsStateToProliferativeWhenActivated() { } @Test - public void testStepSetsStateToMigratoryWhenNotActivated() { + public void step_whenNotActivated_setsStateToMigratory() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); @@ -388,7 +388,7 @@ public void testStepSetsStateToMigratoryWhenNotActivated() { } @Test - public void testStepSetsStatetoExhaustedWhenOverstimulated() { + public void step_whenOverstimulated_setsStateToExhausted() { PatchSimulation sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java index 0387a0f05..e206df13b 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTTest.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -142,14 +142,14 @@ public static void setupMocks() { } @Test - public void bindTargetNoNeighborsDoesNotBind() { + public void bindTarget_noNeighbors_doesNotBind() { PatchCellTissue result = patchCellCART.bindTarget(sim, loc, random); assertNull(result); assertEquals(PatchEnums.AntigenFlag.UNBOUND, patchCellCART.getBindingFlag()); } @Test - public void bindTargetWithSelfBindingBindsToCell() { + public void bindTarget_withSelfBinding_bindsToCell() { when(tissueCell.getCarAntigens()).thenReturn(10); when(tissueCell.getSelfAntigens()).thenReturn(10000000); when(random.nextDouble()).thenReturn(0.0000005); @@ -163,7 +163,7 @@ public void bindTargetWithSelfBindingBindsToCell() { } @Test - public void bindTargetWithSelfAndAntigenBindingBindsToCell() { + public void bindTarget_withSelfAndAntigenBinding_bindsToCell() { when(tissueCell.getCarAntigens()).thenReturn(5000); when(tissueCell.getSelfAntigens()).thenReturn(50000000); when(random.nextDouble()).thenReturn(0.0000005); @@ -178,7 +178,7 @@ public void bindTargetWithSelfAndAntigenBindingBindsToCell() { } @Test - public void bindTargetBindsToCell() { + public void bindTarget_bindsToCell() { when(tissueCell.getCarAntigens()).thenReturn(5000); when(tissueCell.getSelfAntigens()).thenReturn(5000); when(random.nextDouble()).thenReturn(0.0000005); @@ -192,7 +192,7 @@ public void bindTargetBindsToCell() { } @Test - public void getActivationStatusReturnsStatus() + public void getActivationStatus_returnsStatus() throws NoSuchFieldException, IllegalAccessException { Field activation = PatchCellCART.class.getDeclaredField("activated"); activation.setAccessible(true); diff --git a/test/arcade/patch/agent/cell/PatchCellTest.java b/test/arcade/patch/agent/cell/PatchCellTest.java index c31681e56..4c52ef6bb 100644 --- a/test/arcade/patch/agent/cell/PatchCellTest.java +++ b/test/arcade/patch/agent/cell/PatchCellTest.java @@ -128,14 +128,14 @@ public void addCycle_givenCycles_appendValues() { } @Test - public void testSetBindingFlag() { + public void setBindingFlag_setsFlag() { PatchCell cell = new PatchCellMock(baseContainer, locationMock, parametersMock); cell.setBindingFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, cell.getBindingFlag()); } @Test - public void testGetBindingFlag() { + public void getBindingFlag_returnsFlag() { PatchCell cell = new PatchCellMock(baseContainer, locationMock, parametersMock); cell.setBindingFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, cell.getBindingFlag()); diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java index 45274eb6c..58f600356 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java @@ -48,7 +48,7 @@ public void setUp() { } @Test - public void testConstructor() throws NoSuchFieldException, IllegalAccessException { + public void constructor_setsParameters() throws NoSuchFieldException, IllegalAccessException { inflammation = new PatchProcessInflammationCD4(mockCell); assertNotNull(inflammation); @@ -73,7 +73,8 @@ public void testConstructor() throws NoSuchFieldException, IllegalAccessExceptio } @Test - public void testStepProcess() throws NoSuchFieldException, IllegalAccessException { + public void stepProcess_updatesEnvironment() + throws NoSuchFieldException, IllegalAccessException { inflammation = new PatchProcessInflammationCD4(mockCell); inflammation.active = true; @@ -114,7 +115,8 @@ public void testStepProcess() throws NoSuchFieldException, IllegalAccessExceptio } @Test - public void testStepProcessActive() throws NoSuchFieldException, IllegalAccessException { + public void stepProcess_whenActive_returnsHigherRate() + throws NoSuchFieldException, IllegalAccessException { inflammation = new PatchProcessInflammationCD4(mockCell); inflammation.active = true; @@ -149,7 +151,8 @@ public void testStepProcessActive() throws NoSuchFieldException, IllegalAccessEx } @Test - public void testStepProcessInactive() throws NoSuchFieldException, IllegalAccessException { + public void stepProcess_whenInactive_returnsDefaultRate() + throws NoSuchFieldException, IllegalAccessException { inflammation = new PatchProcessInflammationCD4(mockCell); inflammation.active = false; @@ -179,7 +182,7 @@ public void testStepProcessInactive() throws NoSuchFieldException, IllegalAccess } @Test - public void testStepProcessActiveTickerLessThanDelay() + public void stepProcess_activeTickerLessThanDelay_usesDefaultRate() throws NoSuchFieldException, IllegalAccessException { inflammation = new PatchProcessInflammationCD4(mockCell); @@ -214,7 +217,7 @@ public void testStepProcessActiveTickerLessThanDelay() } @Test - public void testStepProcessWithZeroIL2ProdRate() + public void stepProcess_withZeroIL2ProdRate_returnsZero() throws NoSuchFieldException, IllegalAccessException { when(mockParameters.getDouble("inflammation/IL2_PROD_RATE_IL2")).thenReturn(0.0); when(mockParameters.getDouble("inflammation/IL2_PROD_RATE_ACTIVE")).thenReturn(0.0); @@ -246,7 +249,7 @@ public void testStepProcessWithZeroIL2ProdRate() } @Test - public void testUpdate() { + public void update_evenSplit_splitsEvenly() { inflammation = new PatchProcessInflammationCD4(mockCell); PatchProcessInflammationCD4 parentProcess = new PatchProcessInflammationCD4(mockCell); parentProcess.amts[PatchProcessInflammationCD4.IL2RBGA] = 100; @@ -259,7 +262,7 @@ public void testUpdate() { } @Test - public void testUpdateWithZeroVolume() { + public void update_withZeroVolume_splitsUnevenly() { inflammation = new PatchProcessInflammationCD4(mockCell); PatchProcessInflammationCD4 parentProcess = new PatchProcessInflammationCD4(mockCell); parentProcess.amts[PatchProcessInflammationCD4.IL2RBGA] = 100; diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java index 895c1d368..74171ff8a 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java @@ -48,7 +48,7 @@ public void setUp() { } @Test - public void testConstructor() throws NoSuchFieldException, IllegalAccessException { + public void constructor_setsParameters() throws NoSuchFieldException, IllegalAccessException { inflammation = new PatchProcessInflammationCD8(mockCell); assertNotNull(inflammation); @@ -64,7 +64,8 @@ public void testConstructor() throws NoSuchFieldException, IllegalAccessExceptio } @Test - public void testStepProcess() throws NoSuchFieldException, IllegalAccessException { + public void stepProcess_updatesEnvironment() + throws NoSuchFieldException, IllegalAccessException { inflammation = new PatchProcessInflammationCD8(mockCell); inflammation.active = true; inflammation.activeTicker = 10; @@ -82,7 +83,8 @@ public void testStepProcess() throws NoSuchFieldException, IllegalAccessExceptio } @Test - public void testStepProcessInactive() throws NoSuchFieldException, IllegalAccessException { + public void stepProcess_whenInactive_returnsDefaultRate() + throws NoSuchFieldException, IllegalAccessException { inflammation = new PatchProcessInflammationCD8(mockCell); inflammation.active = false; inflammation.activeTicker = 10; @@ -100,7 +102,7 @@ public void testStepProcessInactive() throws NoSuchFieldException, IllegalAccess } @Test - public void testStepProcessActiveTickerLessThanDelay() + public void stepProcess_activeTickerLessThanDelay_usesDefaultRate() throws NoSuchFieldException, IllegalAccessException { Mockito.when(mockParameters.getInt("inflammation/GRANZ_SYNTHESIS_DELAY")).thenReturn(5); inflammation = new PatchProcessInflammationCD8(mockCell); @@ -120,7 +122,7 @@ public void testStepProcessActiveTickerLessThanDelay() } @Test - public void testUpdate() { + public void update_evenSplit_splitsEvenly() { inflammation = new PatchProcessInflammationCD8(mockCell); PatchProcessInflammationCD8 parentProcess = new PatchProcessInflammationCD8(mockCell); parentProcess.amts[PatchProcessInflammationCD8.GRANZYME] = 100; @@ -133,7 +135,7 @@ public void testUpdate() { } @Test - public void testUpdateZeroVolumeParent() { + public void update_withZeroVolume_splitsUnevenly() { inflammation = new PatchProcessInflammationCD8(mockCell); PatchProcessInflammationCD8 parentProcess = new PatchProcessInflammationCD8(mockCell); parentProcess.amts[PatchProcessInflammationCD8.GRANZYME] = 100; diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java index ce6b70bde..ab3916401 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java @@ -60,26 +60,26 @@ public void setUp() { } @Test - public void constructorInitiatesValues() { + public void constructor_initiatesValues() { assertNotNull(inflammation); assertEquals(0, inflammation.getInternal("IL-2")); assertEquals(1.0, inflammation.getInternal("IL2R_total")); } @Test - public void stepCalculatesIL2() { + public void step_calculatesIL2() { inflammation.step(mockRandom, mockSimulation); assertTrue(inflammation.getInternal("IL-2") >= 0); } @Test - public void getInternalReturnsInternalValue() { + public void getInternal_returnsInternalValue() { inflammation.amts[PatchProcessInflammation.IL2_INT_TOTAL] = 10.0; assertEquals(10.0, inflammation.getInternal("IL-2")); } @Test - public void setInternalSetsLayer() { + public void setInternal_setsLayer() { inflammation.setInternal("IL-2", 10.0); assertEquals(10.0, inflammation.getInternal("IL-2")); } diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java index 9d585bf36..60e84183d 100644 --- a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -68,7 +68,8 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { } @Test - public void constructorInitializesFields() throws NoSuchFieldException, IllegalAccessException { + public void constructor_initializesFields() + throws NoSuchFieldException, IllegalAccessException { assertNotNull(metabolism); Field metaPrefField = PatchProcessMetabolismCART.class.getDeclaredField("metaPref"); @@ -134,7 +135,7 @@ public void constructorInitializesFields() throws NoSuchFieldException, IllegalA } @Test - public void stepProcessUpdatesInternalGlucoseAndPyruvate() + public void stepProcess_updatesInternalGlucoseAndPyruvate() throws NoSuchFieldException, IllegalAccessException { // mock inflammation process PatchProcessInflammation inflammation = new inflammationMock(mockCell); @@ -148,7 +149,7 @@ public void stepProcessUpdatesInternalGlucoseAndPyruvate() } @Test - public void stepProcessWithZeroInitialGlucoseReducesMass() { + public void stepProcess_reducesMass_withZeroInitialGlucose() { metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] = 0; // mock inflammation process @@ -164,7 +165,7 @@ public void stepProcessWithZeroInitialGlucoseReducesMass() { } @Test - public void stepProcessWithMaxGlucoseConcentrationDoesNotOverflow() { + public void stepProcess_withMaxGlucoseConcentration_doesNotOverflow() { // mock inflammation process PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); @@ -176,7 +177,7 @@ public void stepProcessWithMaxGlucoseConcentrationDoesNotOverflow() { } @Test - public void stepProcessWithNegativeGlucoseConcentrationStaysPositive() { + public void stepProcess_withNegativeGlucoseConcentration_staysPositive() { // mock inflammation process PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); @@ -188,7 +189,7 @@ public void stepProcessWithNegativeGlucoseConcentrationStaysPositive() { } @Test - public void stepProcessWithZeroOxygenConcentrationProducesNoOxygen() { + public void stepProcess_withZeroOxygenConcentration_producesNoOxygen() { // mock inflammation process PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); @@ -202,7 +203,7 @@ public void stepProcessWithZeroOxygenConcentrationProducesNoOxygen() { } @Test - public void stepProcessWithMaxOxygenConcentrationDoesNotOverflow() { + public void stepProcess_withMaxOxygenConcentration_doesNotOverflow() { // mock inflammation process PatchProcessInflammation inflammation = new inflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); @@ -216,7 +217,7 @@ public void stepProcessWithMaxOxygenConcentrationDoesNotOverflow() { } @Test - public void activatedCellProducesMoreGlucose() + public void step_whenActivated_producesMoreGlucose() throws IllegalAccessException, NoSuchFieldException { metabolism.extAmts[PatchProcessMetabolismCART.GLUCOSE] = 10000.0; // mock inflammation process @@ -237,7 +238,7 @@ public void activatedCellProducesMoreGlucose() } @Test - public void updateSplitCellEvenlyDividesGlucose() { + public void update_evenSplit_splitCellEvenly() { PatchProcessMetabolismCART parentProcess = new PatchProcessMetabolismCART(mockCell); parentProcess.intAmts[PatchProcessMetabolismCART.GLUCOSE] = 100; when(mockCell.getVolume()).thenReturn(cellVolume / 2); @@ -249,7 +250,7 @@ public void updateSplitCellEvenlyDividesGlucose() { } @Test - public void updateSplitCellUnevenlyDividesGlucose() { + public void update_unevenSplit_splitCellUnevenly() { PatchProcessMetabolismCART parentProcess = new PatchProcessMetabolismCART(mockCell); parentProcess.intAmts[PatchProcessMetabolismCART.GLUCOSE] = 100; when(mockCell.getVolume()).thenReturn(0.0); From 5f06fbb2dff4b426f3c8909f296f2f13fd89097b Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 11 Feb 2025 00:11:44 +0000 Subject: [PATCH 137/185] renaming single letter variables --- .../agent/process/PatchProcessInflammation.java | 12 ++++++------ .../agent/process/PatchProcessInflammationCD4.java | 4 +++- .../agent/process/PatchProcessInflammationCD8.java | 2 +- .../process/PatchProcessInflammationCD4Test.java | 10 +++++----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index f3acefa16..e594bbd2d 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -79,7 +79,7 @@ public abstract class PatchProcessInflammation extends PatchProcess { protected Location loc; /** Cell the module is associated with. */ - protected PatchCellCART c; + protected PatchCellCART cell; /** Cell population index. */ protected int pop; @@ -94,7 +94,7 @@ public abstract class PatchProcessInflammation extends PatchProcess { protected double extIL2; /** Shell around cell volume fraction. */ - protected double f; + protected double fraction; /** Volume of cell [um3]. */ protected double volume; @@ -130,7 +130,7 @@ public PatchProcessInflammation(PatchCellCART c) { super(c); // Initialize module. this.loc = c.getLocation(); - this.c = c; + this.cell = c; this.pop = c.getPop(); this.volume = c.getVolume(); this.iL2Ticker = 0; @@ -279,11 +279,11 @@ public void step(MersenneTwisterFast random, Simulation sim) { double radShell = radCell + shellThickness; double volShell = volume * (((radShell * radShell * radShell) / (radCell * radCell * radCell)) - 1.0); - f = volShell / loc.getVolume(); + fraction = volShell / loc.getVolume(); updateExternal(sim); // Check active status. - active = c.getActivationStatus(); + active = cell.getActivationStatus(); if (active) { activeTicker++; } else { @@ -294,7 +294,7 @@ public void step(MersenneTwisterFast random, Simulation sim) { // Local IL-2 total available to cell is fraction of total available // where that fraction is the relative volume fraction the cell occupies // in the location. - amts[IL2_EXT] = extIL2 * f; // [molecules] + amts[IL2_EXT] = extIL2 * fraction; // [molecules] // Solve system of equations. amts = Solver.rungeKutta(equations, 0, amts, 60, STEP_SIZE); diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java index 4062957d8..d76134f41 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java @@ -77,7 +77,9 @@ public void stepProcess(MersenneTwisterFast random, Simulation sim) { // Take current IL2 external concentration and add the amount produced, // then convert units back to molecules/cm^3. double IL2Env = - (((extIL2 - (extIL2 * f - amts[IL2_EXT])) + IL2Produced) * 1E12 / loc.getVolume()); + (((extIL2 - (extIL2 * fraction - amts[IL2_EXT])) + IL2Produced) + * 1E12 + / loc.getVolume()); // update IL2 env variable for testing IL2EnvTesting = IL2Env; diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index 2d1e2f0f0..9627c809a 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -54,7 +54,7 @@ public void stepProcess(MersenneTwisterFast random, Simulation sim) { // Update environment. // Convert units back from molecules to molecules/cm^3. - double IL2Env = ((extIL2 - (extIL2 * f - amts[IL2_EXT])) * 1E12 / loc.getVolume()); + double IL2Env = ((extIL2 - (extIL2 * fraction - amts[IL2_EXT])) * 1E12 / loc.getVolume()); sim.getLattice("IL-2").setValue(loc, IL2Env); } diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java index 58f600356..7e910de3b 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD4Test.java @@ -92,7 +92,7 @@ public void stepProcess_updatesEnvironment() receptors.setAccessible(true); receptors.set(inflammation, 5000); - Field fraction = PatchProcessInflammation.class.getDeclaredField("f"); + Field fraction = PatchProcessInflammation.class.getDeclaredField("fraction"); fraction.setAccessible(true); fraction.set(inflammation, 1.0); @@ -134,7 +134,7 @@ public void stepProcess_whenActive_returnsHigherRate() receptors.setAccessible(true); receptors.set(inflammation, 5000); - Field fraction = PatchProcessInflammation.class.getDeclaredField("f"); + Field fraction = PatchProcessInflammation.class.getDeclaredField("fraction"); fraction.setAccessible(true); fraction.set(inflammation, 1.0); @@ -170,7 +170,7 @@ public void stepProcess_whenInactive_returnsDefaultRate() receptors.setAccessible(true); receptors.set(inflammation, 5000); - Field fraction = PatchProcessInflammation.class.getDeclaredField("f"); + Field fraction = PatchProcessInflammation.class.getDeclaredField("fraction"); fraction.setAccessible(true); fraction.set(inflammation, 1.0); @@ -201,7 +201,7 @@ public void stepProcess_activeTickerLessThanDelay_usesDefaultRate() receptors.setAccessible(true); receptors.set(inflammation, 5000); - Field fraction = PatchProcessInflammation.class.getDeclaredField("f"); + Field fraction = PatchProcessInflammation.class.getDeclaredField("fraction"); fraction.setAccessible(true); fraction.set(inflammation, 1.0); @@ -233,7 +233,7 @@ public void stepProcess_withZeroIL2ProdRate_returnsZero() receptors.setAccessible(true); receptors.set(inflammation, 5000); - Field fraction = PatchProcessInflammation.class.getDeclaredField("f"); + Field fraction = PatchProcessInflammation.class.getDeclaredField("fraction"); fraction.setAccessible(true); fraction.set(inflammation, 1.0); From 89a3672c49286ae34a7e051471e1415dd5e248fa Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 11 Feb 2025 00:19:38 +0000 Subject: [PATCH 138/185] renaming mock var name in metabolism test --- .../PatchProcessMetabolismCARTTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java index 60e84183d..5a486f43d 100644 --- a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -29,8 +29,8 @@ public class PatchProcessMetabolismCARTTest { private Simulation sim; - static class inflammationMock extends PatchProcessInflammation { - public inflammationMock(PatchCellCART c) { + static class InflammationMock extends PatchProcessInflammation { + InflammationMock(PatchCellCART c) { super(c); } @@ -138,7 +138,7 @@ public void constructor_initializesFields() public void stepProcess_updatesInternalGlucoseAndPyruvate() throws NoSuchFieldException, IllegalAccessException { // mock inflammation process - PatchProcessInflammation inflammation = new inflammationMock(mockCell); + PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); @@ -153,7 +153,7 @@ public void stepProcess_reducesMass_withZeroInitialGlucose() { metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] = 0; // mock inflammation process - PatchProcessInflammation inflammation = new inflammationMock(mockCell); + PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); @@ -167,7 +167,7 @@ public void stepProcess_reducesMass_withZeroInitialGlucose() { @Test public void stepProcess_withMaxGlucoseConcentration_doesNotOverflow() { // mock inflammation process - PatchProcessInflammation inflammation = new inflammationMock(mockCell); + PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); @@ -179,7 +179,7 @@ public void stepProcess_withMaxGlucoseConcentration_doesNotOverflow() { @Test public void stepProcess_withNegativeGlucoseConcentration_staysPositive() { // mock inflammation process - PatchProcessInflammation inflammation = new inflammationMock(mockCell); + PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); @@ -191,7 +191,7 @@ public void stepProcess_withNegativeGlucoseConcentration_staysPositive() { @Test public void stepProcess_withZeroOxygenConcentration_producesNoOxygen() { // mock inflammation process - PatchProcessInflammation inflammation = new inflammationMock(mockCell); + PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); @@ -205,7 +205,7 @@ public void stepProcess_withZeroOxygenConcentration_producesNoOxygen() { @Test public void stepProcess_withMaxOxygenConcentration_doesNotOverflow() { // mock inflammation process - PatchProcessInflammation inflammation = new inflammationMock(mockCell); + PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); @@ -221,7 +221,7 @@ public void step_whenActivated_producesMoreGlucose() throws IllegalAccessException, NoSuchFieldException { metabolism.extAmts[PatchProcessMetabolismCART.GLUCOSE] = 10000.0; // mock inflammation process - PatchProcessInflammation inflammation = new inflammationMock(mockCell); + PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); metabolism.stepProcess(random, sim); double inactiveGlucose = metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]; From ff3a165f5a7c6109c7a5a4a2f0372e952c6dfc29 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 11 Feb 2025 00:27:59 +0000 Subject: [PATCH 139/185] renaming binding method --- src/arcade/patch/agent/cell/PatchCellCART.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index c7f562ff1..1b6e52665 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -317,7 +317,7 @@ private double computeProbability( double alpha, double beta) { double bind = - calculateBindingCoefficient( + calculateMichaelisMenten( antigens, kD, currentReceptors, startingReceptors, alpha, beta); return applySig(bind); } @@ -390,7 +390,7 @@ private Bag grabAllTissueNeighbors(PatchGrid grid, PatchLocation loc) { * @param beta fudge factor for receptor binding * @return the binding Coefficient */ - private double calculateBindingCoefficient( + private double calculateMichaelisMenten( double targets, double affinity, int currentReceptors, From b4cb868e8d879b6d6f9ce7e1151b64b9296a63f6 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 11 Feb 2025 00:42:11 +0000 Subject: [PATCH 140/185] adding break statement back into the setState function --- src/arcade/patch/agent/cell/PatchCellCART.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 1b6e52665..0f9efd6a4 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -199,6 +199,7 @@ public void setState(CellState state) { // throw new UnsupportedOperationException(); case QUIESCENT: this.setState(State.PAUSED); + break; // case STIMULATORY: // throw new UnsupportedOperationException(); default: From 572e9b345381116a7dcc377d203e07c0de433f34 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 11 Feb 2025 20:15:44 +0000 Subject: [PATCH 141/185] changing location of setState method --- .../patch/agent/cell/PatchCellCART.java | 33 ------------------- .../agent/module/PatchModuleMigration.java | 7 +++- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 0f9efd6a4..ed35c4b65 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -3,17 +3,12 @@ import sim.util.Bag; import ec.util.MersenneTwisterFast; import arcade.core.agent.cell.Cell; -import arcade.core.agent.cell.CellState; import arcade.core.env.location.Location; import arcade.core.sim.Simulation; import arcade.core.util.GrabBag; import arcade.core.util.Parameters; -import arcade.patch.agent.module.PatchModuleApoptosis; -import arcade.patch.agent.module.PatchModuleMigration; -import arcade.patch.agent.module.PatchModuleProliferation; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; -import arcade.patch.util.PatchEnums; import static arcade.patch.util.PatchEnums.AntigenFlag; import static arcade.patch.util.PatchEnums.State; @@ -180,34 +175,6 @@ public PatchCellCART( cars = parameters.getInt("CARS"); } - @Override - public void setState(CellState state) { - this.state = state; - this.flag = PatchEnums.Flag.UNDEFINED; - - switch ((State) state) { - case PROLIFERATIVE: - module = new PatchModuleProliferation(this); - break; - case MIGRATORY: - module = new PatchModuleMigration(this); - break; - case APOPTOTIC: - module = new PatchModuleApoptosis(this); - break; - // case CYTOTOXIC: - // throw new UnsupportedOperationException(); - case QUIESCENT: - this.setState(State.PAUSED); - break; - // case STIMULATORY: - // throw new UnsupportedOperationException(); - default: - module = null; - break; - } - } - /** * Determines if CAR T cell agent is bound to neighbor through receptor-target binding. * diff --git a/src/arcade/patch/agent/module/PatchModuleMigration.java b/src/arcade/patch/agent/module/PatchModuleMigration.java index 3c7c58c27..bac78bdc0 100644 --- a/src/arcade/patch/agent/module/PatchModuleMigration.java +++ b/src/arcade/patch/agent/module/PatchModuleMigration.java @@ -4,6 +4,7 @@ import arcade.core.sim.Simulation; import arcade.core.util.Parameters; import arcade.patch.agent.cell.PatchCell; +import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.env.location.PatchLocation; import static arcade.patch.util.PatchEnums.State; @@ -50,7 +51,11 @@ public void step(MersenneTwisterFast random, Simulation sim) { PatchLocation newLocation = cell.selectBestLocation(sim, random); if (newLocation == null) { - cell.setState(State.QUIESCENT); + if (cell instanceof PatchCellCART) { + cell.setState(State.PAUSED); + } else { + cell.setState(State.QUIESCENT); + } } else { if (!location.equals(newLocation)) { sim.getGrid().moveObject(cell, location, newLocation); From bf4e434311b19cfe22eb52577808343691b3ceb3 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 12 Feb 2025 19:51:01 +0000 Subject: [PATCH 142/185] polishing unit tests for metabolism cart class --- .../PatchProcessMetabolismCARTTest.java | 95 +++++++++++-------- 1 file changed, 53 insertions(+), 42 deletions(-) diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java index 5a486f43d..cb6440374 100644 --- a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -25,10 +25,12 @@ public class PatchProcessMetabolismCARTTest { private double cellVolume; - private MersenneTwisterFast random = new MersenneTwisterFast(); + private MersenneTwisterFast random = new MersenneTwisterFast(0); private Simulation sim; + private double delta = 0.001; + static class InflammationMock extends PatchProcessInflammation { InflammationMock(PatchCellCART c) { super(c); @@ -60,6 +62,7 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { // set up metabolism class when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); + when(mockParameters.getDouble("metabolism/LACTATE_RATE")).thenReturn(0.05); metabolism = new PatchProcessMetabolismCART(mockCell); Field fraction = PatchProcessMetabolism.class.getDeclaredField("f"); fraction.setAccessible(true); @@ -92,7 +95,7 @@ public void constructor_initializesFields() Field lactateRateField = PatchProcessMetabolismCART.class.getDeclaredField("lactateRate"); lactateRateField.setAccessible(true); - assertEquals(1.0, lactateRateField.get(metabolism)); + assertEquals(0.05, lactateRateField.get(metabolism)); Field autophagyRateField = PatchProcessMetabolismCART.class.getDeclaredField("autophagyRate"); @@ -135,24 +138,30 @@ public void constructor_initializesFields() } @Test - public void stepProcess_updatesInternalGlucoseAndPyruvate() - throws NoSuchFieldException, IllegalAccessException { - // mock inflammation process + public void stepProcess_updatesInternalGlucoseAndPyruvate() { PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); + double initialGlucose = metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]; metabolism.stepProcess(random, sim); - assertTrue(metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] >= 0); - assertTrue(metabolism.intAmts[PatchProcessMetabolismCART.PYRUVATE] >= 0); + double producedGlucose = metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]; + double producedPyruvate = metabolism.intAmts[PatchProcessMetabolismCART.PYRUVATE]; + double gradient = 0; + double surfaceArea = + mockLocation.getArea() * 2 + + (cellVolume / mockLocation.getArea()) * mockLocation.getPerimeter(1.0); + double expectedGlucose = initialGlucose + 1.12 * surfaceArea * gradient + 1; + double expectedPyruvate = (initialGlucose * 2) * (1 - 0.05); + + assertEquals(producedGlucose, expectedGlucose, delta); + assertEquals(producedPyruvate, expectedPyruvate, delta); } @Test public void stepProcess_reducesMass_withZeroInitialGlucose() { metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] = 0; - - // mock inflammation process PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); @@ -164,77 +173,79 @@ public void stepProcess_reducesMass_withZeroInitialGlucose() { assertTrue(finalMass < initialMass); } - @Test - public void stepProcess_withMaxGlucoseConcentration_doesNotOverflow() { - // mock inflammation process - PatchProcessInflammation inflammation = new InflammationMock(mockCell); - when(mockCell.getProcess(any())).thenReturn(inflammation); - when(mockCell.getActivationStatus()).thenReturn(true); - - metabolism.stepProcess(random, sim); - - assertTrue(metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] <= Double.MAX_VALUE); - } - @Test public void stepProcess_withNegativeGlucoseConcentration_staysPositive() { - // mock inflammation process PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); + double initialGlucose = metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]; metabolism.stepProcess(random, sim); + double producedGlucose = metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]; + double gradient = 0; + double surfaceArea = + mockLocation.getArea() * 2 + + (cellVolume / mockLocation.getArea()) * mockLocation.getPerimeter(1.0); + double expectedGlucose = initialGlucose + 1.12 * surfaceArea * gradient + 1; + assertTrue(metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] >= 0); + assertEquals(producedGlucose, expectedGlucose, delta); } @Test public void stepProcess_withZeroOxygenConcentration_producesNoOxygen() { - // mock inflammation process PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); when(mockCell.getActivationStatus()).thenReturn(true); metabolism.extAmts[PatchProcessMetabolismCART.OXYGEN] = 0.0; - metabolism.stepProcess(random, sim); assertEquals(0.0, metabolism.extAmts[PatchProcessMetabolismCART.OXYGEN]); } @Test - public void stepProcess_withMaxOxygenConcentration_doesNotOverflow() { - // mock inflammation process + public void stepProcess_whenActivated_producesMoreGlucose() + throws IllegalAccessException, NoSuchFieldException { + metabolism.extAmts[PatchProcessMetabolismCART.GLUCOSE] = 10000.0; + double initialGlucose = metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]; PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); - when(mockCell.getActivationStatus()).thenReturn(true); - - metabolism.extAmts[PatchProcessMetabolismCART.OXYGEN] = Double.MAX_VALUE; + Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker"); + activeTicker.setAccessible(true); + activeTicker.set(inflammation, 1); + when(mockCell.getActivationStatus()).thenReturn(true); metabolism.stepProcess(random, sim); - assertTrue(metabolism.extAmts[PatchProcessMetabolismCART.OXYGEN] <= Double.MAX_VALUE); + double activatedGlucose = metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]; + double gradient = (10000.0 / mockLocation.getVolume()) - (initialGlucose / cellVolume); + double surfaceArea = + mockLocation.getArea() * 2 + + (cellVolume / mockLocation.getArea()) * mockLocation.getPerimeter(1.0); + double expectedGlucose = initialGlucose + 2.12 * surfaceArea * gradient + 1; + + assertEquals(activatedGlucose, expectedGlucose, delta); } @Test - public void step_whenActivated_producesMoreGlucose() - throws IllegalAccessException, NoSuchFieldException { + public void stepProcess_whenInactive_updatesGlucose() { metabolism.extAmts[PatchProcessMetabolismCART.GLUCOSE] = 10000.0; - // mock inflammation process PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); + double initialGlucose = metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]; + metabolism.stepProcess(random, sim); + double inactiveGlucose = metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]; - double inactivePyruvate = metabolism.intAmts[PatchProcessMetabolismCART.PYRUVATE]; - Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker"); - activeTicker.setAccessible(true); - activeTicker.set(inflammation, 1); - when(mockCell.getActivationStatus()).thenReturn(true); - metabolism.stepProcess(random, sim); - double activatedGlucose = metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]; - double activatedPyruvate = metabolism.intAmts[PatchProcessMetabolismCART.PYRUVATE]; + double gradient = (10000.0 / mockLocation.getVolume()) - (initialGlucose / cellVolume); + double surfaceArea = + mockLocation.getArea() * 2 + + (cellVolume / mockLocation.getArea()) * mockLocation.getPerimeter(1.0); + double expectedGlucose = initialGlucose + 1.12 * surfaceArea * gradient + 1; - assertTrue(activatedGlucose > inactiveGlucose); + assertEquals(inactiveGlucose, expectedGlucose, delta); } @Test From 6b65118b16ffbc67c85c0350e1b6b279f1ff2bcd Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 12 Feb 2025 22:57:51 +0000 Subject: [PATCH 143/185] removing superfluous comment --- .../patch/agent/process/PatchProcessMetabolismCARTTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java index cb6440374..d1f01388c 100644 --- a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -59,7 +59,6 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { when(mockLocation.getArea()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30); when(mockLocation.getVolume()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30 * 8.7); - // set up metabolism class when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12); when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05); when(mockParameters.getDouble("metabolism/LACTATE_RATE")).thenReturn(0.05); From 9409ae2a475bfbeb89bf5406496793e3b5cc9271 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 12 Feb 2025 23:00:57 +0000 Subject: [PATCH 144/185] removing superflous comments in inflammation class --- .../patch/agent/process/PatchProcessInflammation.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index e594bbd2d..e8d4b2760 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -128,7 +128,6 @@ public abstract class PatchProcessInflammation extends PatchProcess { */ public PatchProcessInflammation(PatchCellCART c) { super(c); - // Initialize module. this.loc = c.getLocation(); this.cell = c; this.pop = c.getPop(); @@ -136,7 +135,6 @@ public PatchProcessInflammation(PatchCellCART c) { this.iL2Ticker = 0; this.activeTicker = 0; - // Set parameters. Parameters parameters = cell.getParameters(); this.shellThickness = parameters.getDouble("inflammation/SHELL_THICKNESS"); this.iL2Receptors = parameters.getDouble("inflammation/IL2_RECEPTORS"); @@ -151,7 +149,6 @@ public PatchProcessInflammation(PatchCellCART c) { amts[IL2_IL2RBG] = 0; amts[IL2_IL2RBGA] = 0; - // Molecule names. names = new ArrayList(); names.add(IL2_INT_TOTAL, "IL-2"); names.add(IL2_EXT, "external_IL-2"); @@ -282,7 +279,6 @@ public void step(MersenneTwisterFast random, Simulation sim) { fraction = volShell / loc.getVolume(); updateExternal(sim); - // Check active status. active = cell.getActivationStatus(); if (active) { activeTicker++; @@ -296,13 +292,10 @@ public void step(MersenneTwisterFast random, Simulation sim) { // in the location. amts[IL2_EXT] = extIL2 * fraction; // [molecules] - // Solve system of equations. amts = Solver.rungeKutta(equations, 0, amts, 60, STEP_SIZE); - // Modify internal inflammation response. stepProcess(random, sim); - // Update bound array. boundArray[iL2Ticker % boundArray.length] = amts[IL2_INT_TOTAL]; iL2Ticker++; } From 2d9d1d08817518a6cfa69670fd391b47b2edb272 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 12 Feb 2025 23:05:21 +0000 Subject: [PATCH 145/185] removing superflous comments in metabolism class --- .../patch/agent/process/PatchProcessMetabolismCART.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java index 08a8c9fab..8a4a76c47 100644 --- a/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java +++ b/src/arcade/patch/agent/process/PatchProcessMetabolismCART.java @@ -113,13 +113,11 @@ public class PatchProcessMetabolismCART extends PatchProcessMetabolism { */ public PatchProcessMetabolismCART(PatchCell cell) { super(cell); - // Mapping for internal concentration access. String[] intNames = new String[2]; intNames[GLUCOSE] = "glucose"; intNames[PYRUVATE] = "pyruvate"; names = Arrays.asList(intNames); - // Set loaded parameters. Parameters parameters = cell.getParameters(); metaPref = parameters.getDouble("metabolism/METABOLIC_PREFERENCE"); conversionFraction = parameters.getDouble("metabolism/CONVERSION_FRACTION"); @@ -136,7 +134,6 @@ public PatchProcessMetabolismCART(PatchCell cell) { minimumMassFractionActive = parameters.getDouble("metabolism/FRAC_MASS_ACTIVE"); timeDelay = (int) parameters.getDouble("metabolism/META_SWITCH_DELAY"); - // Initial internal concentrations. intAmts = new double[2]; intAmts[GLUCOSE] = parameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION") * volume; @@ -170,11 +167,10 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { glucUptakeRate + (glucoseUptakeRateIL2 * (priorIL2meta / iL2ReceptorsTotal)); double minimumMassFraction = fracMass; - // Check active status active = ((PatchCellCART) cell).getActivationStatus(); double activeTicker = inflammation.activeTicker; - // Add metabolic preference and glucose uptake rate depdendent on + // Add metabolic preference and glucose uptake rate dependent on // antigen-induced cell activation if cell is activated. if (active && activeTicker >= timeDelay) { metabolicPreference += metabolicPreferenceActive; @@ -234,7 +230,6 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { glucInt = 0.0; // use up all internal glucose } - // Update energy. energy += energyGen[0]; energy += energyGen[1]; energy -= energyCons; @@ -261,7 +256,6 @@ void stepProcess(MersenneTwisterFast random, Simulation sim) { glucInt += autophagyRate * ratioGlucoseBiomass; } - // Update volume based on changes in mass. volume = mass / cellDensity; // Convert internal pyruvate to lactate (i.e. remove pyruvate). From 6aee6acd70a31c5f96868720fcbc59888d4ea41c Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 17 Feb 2025 19:49:36 +0000 Subject: [PATCH 146/185] editing test names, deleting trivial tests, making test cases more clear --- test/arcade/patch/agent/cell/PatchCellCARTTest.java | 4 ++-- test/arcade/patch/agent/cell/PatchCellTest.java | 4 ++-- .../agent/process/PatchProcessInflammationTest.java | 12 +++--------- .../process/PatchProcessMetabolismCARTTest.java | 8 ++++---- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java index e206df13b..52a9dbe62 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTTest.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -178,7 +178,7 @@ public void bindTarget_withSelfAndAntigenBinding_bindsToCell() { } @Test - public void bindTarget_bindsToCell() { + public void bindTarget_called_bindsToCell() { when(tissueCell.getCarAntigens()).thenReturn(5000); when(tissueCell.getSelfAntigens()).thenReturn(5000); when(random.nextDouble()).thenReturn(0.0000005); @@ -192,7 +192,7 @@ public void bindTarget_bindsToCell() { } @Test - public void getActivationStatus_returnsStatus() + public void getActivationStatus_called_returnsStatus() throws NoSuchFieldException, IllegalAccessException { Field activation = PatchCellCART.class.getDeclaredField("activated"); activation.setAccessible(true); diff --git a/test/arcade/patch/agent/cell/PatchCellTest.java b/test/arcade/patch/agent/cell/PatchCellTest.java index 4c52ef6bb..9cb3f9e6f 100644 --- a/test/arcade/patch/agent/cell/PatchCellTest.java +++ b/test/arcade/patch/agent/cell/PatchCellTest.java @@ -128,14 +128,14 @@ public void addCycle_givenCycles_appendValues() { } @Test - public void setBindingFlag_setsFlag() { + public void setBindingFlag_called_setsFlag() { PatchCell cell = new PatchCellMock(baseContainer, locationMock, parametersMock); cell.setBindingFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, cell.getBindingFlag()); } @Test - public void getBindingFlag_returnsFlag() { + public void getBindingFlag_called_returnsFlag() { PatchCell cell = new PatchCellMock(baseContainer, locationMock, parametersMock); cell.setBindingFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, cell.getBindingFlag()); diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java index ab3916401..fe5ea50cf 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java @@ -60,26 +60,20 @@ public void setUp() { } @Test - public void constructor_initiatesValues() { + public void constructor_called_initiatesValues() { assertNotNull(inflammation); assertEquals(0, inflammation.getInternal("IL-2")); assertEquals(1.0, inflammation.getInternal("IL2R_total")); } @Test - public void step_calculatesIL2() { - inflammation.step(mockRandom, mockSimulation); - assertTrue(inflammation.getInternal("IL-2") >= 0); - } - - @Test - public void getInternal_returnsInternalValue() { + public void getInternal_called_returnsInternalValue() { inflammation.amts[PatchProcessInflammation.IL2_INT_TOTAL] = 10.0; assertEquals(10.0, inflammation.getInternal("IL-2")); } @Test - public void setInternal_setsLayer() { + public void setInternal_called_setsLayer() { inflammation.setInternal("IL-2", 10.0); assertEquals(10.0, inflammation.getInternal("IL-2")); } diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java index d1f01388c..a853628ba 100644 --- a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -159,7 +159,7 @@ public void stepProcess_updatesInternalGlucoseAndPyruvate() { } @Test - public void stepProcess_reducesMass_withZeroInitialGlucose() { + public void stepProcess_withZeroInitialGlucose_reducesMass() { metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] = 0; PatchProcessInflammation inflammation = new InflammationMock(mockCell); when(mockCell.getProcess(any())).thenReturn(inflammation); @@ -263,11 +263,11 @@ public void update_evenSplit_splitCellEvenly() { public void update_unevenSplit_splitCellUnevenly() { PatchProcessMetabolismCART parentProcess = new PatchProcessMetabolismCART(mockCell); parentProcess.intAmts[PatchProcessMetabolismCART.GLUCOSE] = 100; - when(mockCell.getVolume()).thenReturn(0.0); + when(mockCell.getVolume()).thenReturn(cellVolume / 4); metabolism.update(parentProcess); - assertEquals(0, metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]); - assertEquals(100, parentProcess.intAmts[PatchProcessMetabolismCART.GLUCOSE]); + assertEquals(25, metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]); + assertEquals(75, parentProcess.intAmts[PatchProcessMetabolismCART.GLUCOSE]); } } From 7a6eb31534e4aa1216ff03e80ea87383ba669631 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 17 Feb 2025 20:04:13 +0000 Subject: [PATCH 147/185] changing bindingflag tests to return 0 --- test/arcade/patch/agent/cell/PatchCellTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/arcade/patch/agent/cell/PatchCellTest.java b/test/arcade/patch/agent/cell/PatchCellTest.java index 9cb3f9e6f..703741c8d 100644 --- a/test/arcade/patch/agent/cell/PatchCellTest.java +++ b/test/arcade/patch/agent/cell/PatchCellTest.java @@ -129,15 +129,23 @@ public void addCycle_givenCycles_appendValues() { @Test public void setBindingFlag_called_setsFlag() { + doReturn(0.0).when(parametersMock).getDouble(any(String.class)); + doReturn(0).when(parametersMock).getInt(any(String.class)); PatchCell cell = new PatchCellMock(baseContainer, locationMock, parametersMock); + cell.setBindingFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); + assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, cell.getBindingFlag()); } @Test public void getBindingFlag_called_returnsFlag() { + doReturn(0.0).when(parametersMock).getDouble(any(String.class)); + doReturn(0).when(parametersMock).getInt(any(String.class)); PatchCell cell = new PatchCellMock(baseContainer, locationMock, parametersMock); + cell.setBindingFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); + assertEquals(PatchEnums.AntigenFlag.BOUND_ANTIGEN, cell.getBindingFlag()); } From cbe0dc5be7880632848a9fee91420f187a88c2b9 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 17 Feb 2025 20:11:28 +0000 Subject: [PATCH 148/185] adding CART binding target field, editing reset --- src/arcade/patch/agent/action/PatchActionReset.java | 2 +- src/arcade/patch/agent/cell/PatchCellCART.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/arcade/patch/agent/action/PatchActionReset.java b/src/arcade/patch/agent/action/PatchActionReset.java index 29478355c..78ffa48c9 100644 --- a/src/arcade/patch/agent/action/PatchActionReset.java +++ b/src/arcade/patch/agent/action/PatchActionReset.java @@ -18,7 +18,7 @@ * *

      {@code PatchActionReset} is stepped once after a CD8 CAR T-cell binds to a target tissue cell, * or after a CD4 CAR T-cell gets stimulated. The {@code PatchReset} unbinds to any target cell that - * the T cell is bound to, and sets the cell state back to quiescent. + * the T cell is bound to, and sets the cell state back to undefined. */ public class PatchActionReset implements Action { diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index ed35c4b65..5bfccae4a 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -108,6 +108,9 @@ public abstract class PatchCellCART extends PatchCell { /** Fraction of proliferative cells that become apoptotic. */ protected final double proliferativeFraction; + /** Target cell that current T cell is bound to. */ + protected PatchCell boundTarget; + /** * Creates a {@code PatchCellCART} agent. * * @@ -155,6 +158,7 @@ public PatchCellCART( boundSelfAntigensCount = 0; lastActiveTicker = 0; activated = true; + boundTarget = null; // Set loaded parameters. exhaustedFraction = parameters.getDouble("EXHAUSTED_FRAC"); @@ -252,7 +256,7 @@ public boolean getActivationStatus() { } /** - * Adds only tissue cells to the provided bag. Helper method for bindTarget. + * Adds only tissue cells to the provided bag. * * @param tissueAgents the bag to add tissue cells into * @param possibleAgents the bag of possible agents to check for tissue cells @@ -287,7 +291,7 @@ private double computeProbability( double bind = calculateMichaelisMenten( antigens, kD, currentReceptors, startingReceptors, alpha, beta); - return applySig(bind); + return applySigmoid(bind); } /** @@ -376,7 +380,7 @@ private double calculateMichaelisMenten( * @param bindingCoefficient the binding coefficient for the log function * @return the sigmoidal value */ - private double applySig(double bindingCoefficient) { + private double applySigmoid(double bindingCoefficient) { return 2 * (1 / (1 + Math.exp(-1 * bindingCoefficient))) - 1; } From 30cb7d0254dcce2aed0af77cb998fc228113536e Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 19 Feb 2025 21:02:09 +0000 Subject: [PATCH 149/185] removing redundant max density parameter --- src/arcade/patch/parameter.patch.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index d2fe9cb4d..f024b930a 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -25,7 +25,6 @@ - From 1e978adf14c44ca73737134bde840f0c27024270 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 20 Feb 2025 18:50:58 +0000 Subject: [PATCH 150/185] adding final keyword to appease linter --- test/arcade/patch/agent/cell/PatchCellCARTTest.java | 2 +- .../patch/agent/process/PatchProcessInflammationTest.java | 2 +- .../patch/agent/process/PatchProcessMetabolismCARTTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java index 52a9dbe62..09afbb5df 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTTest.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -69,7 +69,7 @@ public void step(SimState state) {} } @BeforeEach - public void setUp() throws NoSuchFieldException, IllegalAccessException { + public final void setUp() throws NoSuchFieldException, IllegalAccessException { parameters = spy(new Parameters(new MiniBox(), null, null)); location = mock(PatchLocation.class); diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java index fe5ea50cf..fa53ff474 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationTest.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationTest.java @@ -40,7 +40,7 @@ public void update(Process process) {} } @BeforeEach - public void setUp() { + public final void setUp() { mockCell = Mockito.mock(PatchCellCART.class); mockParameters = Mockito.mock(Parameters.class); mockSimulation = Mockito.mock(Simulation.class); diff --git a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java index a853628ba..2c332bbfd 100644 --- a/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java +++ b/test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java @@ -44,7 +44,7 @@ public void update(Process process) {} } @BeforeEach - public void setUp() throws NoSuchFieldException, IllegalAccessException { + public final void setUp() throws NoSuchFieldException, IllegalAccessException { mockCell = mock(PatchCellCART.class); mockParameters = mock(Parameters.class); mockLocation = mock(PatchLocation.class); From 5da7d0b90bb99548de3c4970aa0d1e4452ce1008 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 20 Feb 2025 18:59:02 +0000 Subject: [PATCH 151/185] refactoring actions as modules --- src/arcade/patch/agent/cell/PatchCell.java | 15 +++- .../patch/agent/cell/PatchCellCART.java | 15 ++++ .../patch/agent/cell/PatchCellCARTCD4.java | 47 ++++------ .../patch/agent/cell/PatchCellCARTCD8.java | 52 ++++------- .../agent/module/PatchModuleCytotoxicity.java | 88 +++++++++++++++++++ .../agent/module/PatchModuleStimulation.java | 72 +++++++++++++++ .../agent/cell/PatchCellCARTCD4Test.java | 1 - 7 files changed, 222 insertions(+), 68 deletions(-) create mode 100644 src/arcade/patch/agent/module/PatchModuleCytotoxicity.java create mode 100644 src/arcade/patch/agent/module/PatchModuleStimulation.java diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index d4ae9562a..e61e9b9fa 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -17,9 +17,7 @@ import arcade.core.util.GrabBag; import arcade.core.util.MiniBox; import arcade.core.util.Parameters; -import arcade.patch.agent.module.PatchModuleApoptosis; -import arcade.patch.agent.module.PatchModuleMigration; -import arcade.patch.agent.module.PatchModuleProliferation; +import arcade.patch.agent.module.*; import arcade.patch.agent.process.PatchProcessInflammation; import arcade.patch.agent.process.PatchProcessMetabolism; import arcade.patch.agent.process.PatchProcessSignaling; @@ -365,6 +363,17 @@ public void setState(CellState state) { case APOPTOTIC: module = new PatchModuleApoptosis(this); break; + case STIMULATORY: + module = new PatchModuleStimulation(this); + break; + case CYTOTOXIC: + module = new PatchModuleCytotoxicity(this); + break; + case QUIESCENT: + if (this instanceof PatchCellCART) { + this.setState(State.UNDEFINED); + } + break; default: module = null; break; diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 5bfccae4a..23c205771 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -399,4 +399,19 @@ private double computeAffinity(double affinity, PatchLocation loc) { private void updateSelfReceptors() { selfReceptors += (int) ((double) selfReceptorsStart * (0.95 + Math.random() / 10)); } + + /** + * Returns bound cell. + * + * @return the bound cell + */ + public PatchCell getBoundTarget() { + return this.boundTarget; + } + + /** Sets binding flag to unbound and binding target to null. */ + public void unbind() { + super.setBindingFlag(AntigenFlag.UNBOUND); + this.boundTarget = null; + } } diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 09e36425c..2d2dafb54 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -7,8 +7,6 @@ import arcade.core.sim.Simulation; import arcade.core.util.GrabBag; import arcade.core.util.Parameters; -import arcade.patch.agent.action.PatchActionReset; -import arcade.patch.sim.PatchSimulation; import arcade.patch.util.PatchEnums.AntigenFlag; import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.State; @@ -81,42 +79,43 @@ public void step(SimState simstate) { // Check energy status. If cell has less energy than threshold, it will // apoptose. If overall energy is negative, then cell enters quiescence. - if (state != State.APOPTOTIC && energy < 0) { + if (state != State.APOPTOTIC) { if (super.energy < super.energyThreshold) { + super.setState(State.APOPTOTIC); - super.setBindingFlag(AntigenFlag.UNBOUND); + super.unbind(); this.activated = false; } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED - && state != State.STARVED) { + && state != State.STARVED + && energy < 0) { + super.setState(State.STARVED); - super.setBindingFlag(AntigenFlag.UNBOUND); + super.unbind(); + } else if (state == State.STARVED && energy >= 0) { + super.setState(State.UNDEFINED); } - } else if (state == State.STARVED && energy >= 0) { - super.setState(State.UNDEFINED); } // Step inflammation process. super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); // Change state from undefined. - if (super.state == State.UNDEFINED - || super.state == State.PAUSED - || super.state == State.QUIESCENT) { + if (super.state == State.UNDEFINED || super.state == State.PAUSED) { if (divisions == 0) { if (simstate.random.nextDouble() > super.senescentFraction) { super.setState(State.APOPTOTIC); } else { super.setState(State.SENESCENT); } - super.setBindingFlag(AntigenFlag.UNBOUND); + super.unbind(); this.activated = false; } else { // Cell attempts to bind to a target PatchCellTissue target = super.bindTarget(sim, location, new MersenneTwisterFast(simstate.seed())); - + super.boundTarget = target; // If cell is bound to both antigen and self it will become anergic. if (super.getBindingFlag() == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { if (simstate.random.nextDouble() > super.anergicFraction) { @@ -124,7 +123,7 @@ public void step(SimState simstate) { } else { super.setState(State.ANERGIC); } - super.setBindingFlag(AntigenFlag.UNBOUND); + super.unbind(); this.activated = false; } else if (super.getBindingFlag() == AntigenFlag.BOUND_ANTIGEN) { // If cell is only bound to target antigen, the cell @@ -138,31 +137,19 @@ public void step(SimState simstate) { } else { super.setState(State.EXHAUSTED); } - super.setBindingFlag(AntigenFlag.UNBOUND); + super.unbind(); this.activated = false; } else { // if CD4 cell is properly activated, it can stimulate super.setState(State.STIMULATORY); this.lastActiveTicker = 0; this.activated = true; - if (target.isStopped()) { - target.setBindingFlag(AntigenFlag.UNBOUND); - } - target.setState(State.QUIESCENT); - super.setBindingFlag(AntigenFlag.UNBOUND); - // reset the cell - PatchActionReset reset = - new PatchActionReset( - this, - simstate.random, - ((PatchSimulation) simstate).getSeries(), - parameters); - reset.schedule(sim.getSchedule()); } } else { // If self binding, unbind - if (super.getBindingFlag() == AntigenFlag.BOUND_CELL_RECEPTOR) - super.setBindingFlag(AntigenFlag.UNBOUND); + if (super.getBindingFlag() == AntigenFlag.BOUND_CELL_RECEPTOR) { + super.unbind(); + } // Check activation status. If cell has been activated before, // it will proliferate. If not, it will migrate. if (activated) { diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index 05a70a135..33aa14b6d 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -7,9 +7,6 @@ import arcade.core.sim.Simulation; import arcade.core.util.GrabBag; import arcade.core.util.Parameters; -import arcade.patch.agent.action.PatchActionKill; -import arcade.patch.agent.action.PatchActionReset; -import arcade.patch.sim.PatchSimulation; import arcade.patch.util.PatchEnums.AntigenFlag; import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.State; @@ -65,7 +62,7 @@ public void step(SimState simstate) { if (state != State.APOPTOTIC && age > apoptosisAge) { setState(State.APOPTOTIC); - super.setBindingFlag(AntigenFlag.UNBOUND); + super.unbind(); this.activated = false; } @@ -81,40 +78,42 @@ public void step(SimState simstate) { // Check energy status. If cell has less energy than threshold, it will // apoptose. If overall energy is negative, then cell enters quiescence. - if (state != State.APOPTOTIC && energy < 0) { + if (state != State.APOPTOTIC) { if (super.energy < super.energyThreshold) { + super.setState(State.APOPTOTIC); - super.setBindingFlag(AntigenFlag.UNBOUND); + super.unbind(); this.activated = false; } else if (state != State.ANERGIC && state != State.SENESCENT && state != State.EXHAUSTED - && state != State.STARVED) { + && state != State.STARVED + && energy < 0) { + super.setState(State.STARVED); - super.setBindingFlag(AntigenFlag.UNBOUND); + super.unbind(); + } else if (state == State.STARVED && energy >= 0) { + super.setState(State.UNDEFINED); } - } else if (state == State.STARVED && energy >= 0) { - super.setState(State.UNDEFINED); } // Step inflammation process. super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); // Change state from undefined. - if (super.state == State.UNDEFINED - || super.state == State.PAUSED - || super.state == State.QUIESCENT) { + if (super.state == State.UNDEFINED || super.state == State.PAUSED) { if (divisions == 0) { if (simstate.random.nextDouble() > super.senescentFraction) { super.setState(State.APOPTOTIC); } else { super.setState(State.SENESCENT); } - super.setBindingFlag(AntigenFlag.UNBOUND); + super.unbind(); this.activated = false; } else { // Cell attempts to bind to a target PatchCellTissue target = super.bindTarget(sim, location, simstate.random); + super.boundTarget = target; // If cell is bound to both antigen and self it will become anergic. if (super.getBindingFlag() == AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR) { @@ -123,7 +122,7 @@ public void step(SimState simstate) { } else { super.setState(State.ANERGIC); } - super.setBindingFlag(AntigenFlag.UNBOUND); + super.unbind(); this.activated = false; } else if (super.getBindingFlag() == AntigenFlag.BOUND_ANTIGEN) { // If cell is only bound to target antigen, the cell @@ -137,34 +136,19 @@ public void step(SimState simstate) { } else { super.setState(State.EXHAUSTED); } - super.setBindingFlag(AntigenFlag.UNBOUND); + super.unbind(); this.activated = false; } else { // if CD8 cell is properly activated, it can be cytotoxic this.lastActiveTicker = 0; this.activated = true; super.setState(State.CYTOTOXIC); - PatchActionKill kill = - new PatchActionKill( - this, - target, - simstate.random, - ((PatchSimulation) simstate).getSeries(), - parameters); - kill.schedule(sim.getSchedule()); - // cell resets after binding - PatchActionReset reset = - new PatchActionReset( - this, - simstate.random, - ((PatchSimulation) simstate).getSeries(), - parameters); - reset.schedule(sim.getSchedule()); } } else { // If self binding, unbind - if (super.getBindingFlag() == AntigenFlag.BOUND_CELL_RECEPTOR) - super.setBindingFlag(AntigenFlag.UNBOUND); + if (super.getBindingFlag() == AntigenFlag.BOUND_CELL_RECEPTOR) { + super.unbind(); + } // Check activation status. If cell has been activated before, // it will proliferate. If not, it will migrate. if (activated) { diff --git a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java new file mode 100644 index 000000000..d8283009a --- /dev/null +++ b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java @@ -0,0 +1,88 @@ +package arcade.patch.agent.module; + +import ec.util.MersenneTwisterFast; +import arcade.core.sim.Simulation; +import arcade.core.util.Parameters; +import arcade.patch.agent.cell.PatchCell; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.patch.agent.cell.PatchCellTissue; +import arcade.patch.agent.process.PatchProcessInflammation; +import arcade.patch.util.PatchEnums; + +/** + * Implementation of {@link Module} for killing tissue agents. + * + *

      {@code PatchModuleCytotoxicity} is stepped once after a CD8 CAR T-cell binds to a target + * tissue cell. The {@code PatchModuleCytotoxicity} determines if cell has enough granzyme to kill. + * If so, it kills cell and calls the reset to neutral helper to return to neutral state. If not, it + * waits until it has enough granzyme to kill cell. + */ +public class PatchModuleCytotoxicity extends PatchModule { + /** Target cell cytotoxic CAR T-cell is bound to */ + PatchCellTissue target; + + /** CAR T-cell inflammation module */ + PatchProcessInflammation inflammation; + + /** Amount of granzyme inside CAR T-cell */ + double granzyme; + + /** Time delay before calling the action [min]. */ + private int timeDelay; + + /** Ticker to keep track of the time delay [min]. */ + private int ticker; + + /** Average time that T cell is bound to target [min]. */ + private double boundTime; + + /** Range in bound time [min]. */ + private double boundRange; + + /** + * Creates a {@code PatchActionKill} for the given {@link PatchCellCART}. + * + * @param c the {@link PatchCell} the helper is associated with + */ + public PatchModuleCytotoxicity(PatchCell c) { + super(c); + this.target = (PatchCellTissue) ((PatchCellCART) c).getBoundTarget(); + this.inflammation = (PatchProcessInflammation) c.getProcess(PatchEnums.Domain.INFLAMMATION); + this.granzyme = inflammation.getInternal("granzyme"); + + Parameters parameters = c.getParameters(); + this.boundTime = parameters.getInt("BOUND_TIME"); + this.boundRange = parameters.getInt("BOUND_RANGE"); + this.timeDelay = 0; + this.ticker = 0; + } + + @Override + public void step(MersenneTwisterFast random, Simulation sim) { + if (cell.isStopped()) { + return; + } + + if (target.isStopped()) { + ((PatchCellCART) cell).unbind(); + cell.setState(PatchEnums.State.UNDEFINED); + return; + } + + if (ticker == 0) { + this.timeDelay = + (int) (boundTime + Math.round((boundRange * (2 * random.nextInt() - 1)))); + if (granzyme >= 1) { + PatchCellTissue tissueCell = (PatchCellTissue) target; + tissueCell.setState(PatchEnums.State.APOPTOTIC); + granzyme--; + inflammation.setInternal("granzyme", granzyme); + } + } else if (ticker >= timeDelay) { + ((PatchCellCART) cell).unbind(); + cell.setState(PatchEnums.State.UNDEFINED); + } + + ticker++; + } +} diff --git a/src/arcade/patch/agent/module/PatchModuleStimulation.java b/src/arcade/patch/agent/module/PatchModuleStimulation.java new file mode 100644 index 000000000..d45985076 --- /dev/null +++ b/src/arcade/patch/agent/module/PatchModuleStimulation.java @@ -0,0 +1,72 @@ +package arcade.patch.agent.module; + +import ec.util.MersenneTwisterFast; +import arcade.core.sim.Simulation; +import arcade.core.util.Parameters; +import arcade.patch.agent.cell.PatchCell; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.patch.agent.cell.PatchCellTissue; +import arcade.patch.util.PatchEnums; + +/** + * Implementation of {@link Module} for stimulatory T cell agents. + * + *

      {@code PatchModuleStimulation} is stepped once after a CD4 CAR T-cell gets stimulated. The + * {@code PatchModuleStimulation} activates the T cell, unbinds to any target cell that the T cell + * is bound to, and sets the cell state back to undefined. + */ +public class PatchModuleStimulation extends PatchModule { + /** Target cell cytotoxic CAR T-cell is bound to */ + PatchCellTissue target; + + /** Time delay before calling the action [min]. */ + private int timeDelay; + + /** Ticker to keep track of the time delay [min]. */ + private int ticker; + + /** Average time that T cell is bound to target [min]. */ + private double boundTime; + + /** Range in bound time [min]. */ + private double boundRange; + + /** + * Creates a {@code PatchModuleStimulation} for the given {@link PatchCellCART}. + * + * @param c the {@link PatchCellCART} the helper is associated with + */ + public PatchModuleStimulation(PatchCell c) { + super(c); + this.target = (PatchCellTissue) ((PatchCellCART) c).getBoundTarget(); + Parameters parameters = c.getParameters(); + this.boundTime = parameters.getInt("BOUND_TIME"); + this.boundRange = parameters.getInt("BOUND_RANGE"); + this.timeDelay = 0; + this.ticker = 0; + } + + @Override + public void step(MersenneTwisterFast random, Simulation sim) { + if (cell.isStopped()) { + return; + } + + if (target.isStopped()) { + ((PatchCellCART) cell).unbind(); + cell.setState(PatchEnums.State.UNDEFINED); + return; + } + + if (ticker == 0) { + this.timeDelay = + (int) (boundTime + Math.round((boundRange * (2 * random.nextInt() - 1)))); + target.setState(PatchEnums.State.QUIESCENT); + } else if (ticker >= timeDelay) { + ((PatchCellCART) cell).unbind(); + cell.setState(PatchEnums.State.UNDEFINED); + } + + ticker++; + } +} diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java index 4d86cc8aa..2f6716b2c 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD4Test.java @@ -324,7 +324,6 @@ public void step_whenBoundToAntigen_setsStateToStimulatory() { cell.step(sim); assertEquals(State.STIMULATORY, cell.getState()); - assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); assertTrue(cell.getActivationStatus()); } From 1a68317415f5bdc713305ce89c2c385511224d1f Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 25 Feb 2025 21:44:29 +0000 Subject: [PATCH 152/185] linting: javadoc and curly braces --- src/arcade/patch/agent/cell/PatchCellCARTCD8.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index 33aa14b6d..f30c8dcae 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -11,6 +11,7 @@ import arcade.patch.util.PatchEnums.Domain; import arcade.patch.util.PatchEnums.State; +/** Extension of {@link PatchCellCART} for CD8 CART-cells with selected module versions. */ public class PatchCellCARTCD8 extends PatchCellCART { /** * Creates a T cell {@code PatchCellCARTCD8} agent. * @@ -69,9 +70,13 @@ public void step(SimState simstate) { // Increase time since last active ticker super.lastActiveTicker++; if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { - if (super.boundCARAntigensCount != 0) super.boundCARAntigensCount--; + if (super.boundCARAntigensCount != 0) { + super.boundCARAntigensCount--; + } + } + if (super.lastActiveTicker / 1440 > 7) { + super.activated = false; } - if (super.lastActiveTicker / 1440 > 7) super.activated = false; // Step metabolism process. super.processes.get(Domain.METABOLISM).step(simstate.random, sim); From 34fda97e545329def6afe052389b00203049e30a Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 25 Feb 2025 21:45:10 +0000 Subject: [PATCH 153/185] they wanted periods --- src/arcade/patch/agent/module/PatchModuleCytotoxicity.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java index d8283009a..8d4699564 100644 --- a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java +++ b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java @@ -18,13 +18,13 @@ * waits until it has enough granzyme to kill cell. */ public class PatchModuleCytotoxicity extends PatchModule { - /** Target cell cytotoxic CAR T-cell is bound to */ + /** Target cell cytotoxic CAR T-cell is bound to. */ PatchCellTissue target; - /** CAR T-cell inflammation module */ + /** CAR T-cell inflammation module. */ PatchProcessInflammation inflammation; - /** Amount of granzyme inside CAR T-cell */ + /** Amount of granzyme inside CAR T-cell. */ double granzyme; /** Time delay before calling the action [min]. */ From 7bf87d542a90e69d6322d5fa4aa1d513b511fe1b Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 25 Feb 2025 21:50:20 +0000 Subject: [PATCH 154/185] fixing inflammmation linting issues --- .../process/PatchProcessInflammationCD8.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index 9627c809a..0ae7ed50e 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -7,13 +7,13 @@ import arcade.patch.agent.cell.PatchCellCART; public class PatchProcessInflammationCD8 extends PatchProcessInflammation { - /** Moles of granzyme produced per moles IL-2 [mol granzyme/mol IL-2] */ + /** Moles of granzyme produced per moles IL-2 [mol granzyme/mol IL-2]. */ private static final double GRANZ_PER_IL2 = 0.005; - /** Delay in IL-2 synthesis after antigen-induced activation */ - private final int GRANZ_SYNTHESIS_DELAY; + /** Delay in IL-2 synthesis after antigen-induced activation. */ + private final int granz_synthesis_delay; - /** Amount of IL-2 bound in past being used for current granzyme production calculation */ + /** Amount of IL-2 bound in past being used for current granzyme production calculation. */ private double priorIL2granz; /** @@ -28,7 +28,7 @@ public PatchProcessInflammationCD8(PatchCellCART c) { // Set parameters. Parameters parameters = cell.getParameters(); - this.GRANZ_SYNTHESIS_DELAY = parameters.getInt("inflammation/GRANZ_SYNTHESIS_DELAY"); + this.granz_synthesis_delay = parameters.getInt("inflammation/granz_synthesis_delay"); this.priorIL2granz = 0; // Initialize internal, external, and uptake concentration arrays. @@ -38,24 +38,25 @@ public PatchProcessInflammationCD8(PatchCellCART c) { names.add(GRANZYME, "granzyme"); } + @Override public void stepProcess(MersenneTwisterFast random, Simulation sim) { // Determine amount of granzyme production based on if cell is activated // as a function of IL-2 production. - int granzIndex = (iL2Ticker % boundArray.length) - GRANZ_SYNTHESIS_DELAY; + int granzIndex = (iL2Ticker % boundArray.length) - granz_synthesis_delay; if (granzIndex < 0) { granzIndex += boundArray.length; } priorIL2granz = boundArray[granzIndex]; - if (active && activeTicker > GRANZ_SYNTHESIS_DELAY) { + if (active && activeTicker > granz_synthesis_delay) { amts[GRANZYME] += GRANZ_PER_IL2 * (priorIL2granz / iL2Receptors); } // Update environment. // Convert units back from molecules to molecules/cm^3. - double IL2Env = ((extIL2 - (extIL2 * fraction - amts[IL2_EXT])) * 1E12 / loc.getVolume()); - sim.getLattice("IL-2").setValue(loc, IL2Env); + double iL2Env = ((extIL2 - (extIL2 * fraction - amts[IL2_EXT])) * 1E12 / loc.getVolume()); + sim.getLattice("IL-2").setValue(loc, iL2Env); } @Override From 92eb773be696071d3836a17a1bc36f5812cf55d6 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 25 Feb 2025 21:57:41 +0000 Subject: [PATCH 155/185] reverting accidental replace --- src/arcade/patch/agent/process/PatchProcessInflammationCD8.java | 2 +- .../patch/agent/process/PatchProcessInflammationCD8Test.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index 0ae7ed50e..8a42f68d2 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -28,7 +28,7 @@ public PatchProcessInflammationCD8(PatchCellCART c) { // Set parameters. Parameters parameters = cell.getParameters(); - this.granz_synthesis_delay = parameters.getInt("inflammation/granz_synthesis_delay"); + this.granz_synthesis_delay = parameters.getInt("inflammation/GRANZ_SYNTHESIS_DELAY"); this.priorIL2granz = 0; // Initialize internal, external, and uptake concentration arrays. diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java index 74171ff8a..bb62575b6 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java @@ -58,7 +58,7 @@ public void constructor_setsParameters() throws NoSuchFieldException, IllegalAcc prior.setAccessible(true); assertEquals(0.0, prior.get(inflammation)); - Field delay = PatchProcessInflammationCD8.class.getDeclaredField("GRANZ_SYNTHESIS_DELAY"); + Field delay = PatchProcessInflammationCD8.class.getDeclaredField("granz_synthesis_delay"); delay.setAccessible(true); assertEquals(1, delay.get(inflammation)); } From 774e83082b8930e54d25000f552a01d657a9023f Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 25 Feb 2025 22:05:09 +0000 Subject: [PATCH 156/185] removing superflous comments --- src/arcade/patch/agent/cell/PatchCellCARTCD8.java | 7 ------- .../patch/agent/process/PatchProcessInflammationCD8.java | 4 ---- 2 files changed, 11 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index f30c8dcae..94f4daf9a 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -58,7 +58,6 @@ public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFas public void step(SimState simstate) { Simulation sim = (Simulation) simstate; - // Increase age of cell. super.age++; if (state != State.APOPTOTIC && age > apoptosisAge) { @@ -67,7 +66,6 @@ public void step(SimState simstate) { this.activated = false; } - // Increase time since last active ticker super.lastActiveTicker++; if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { if (super.boundCARAntigensCount != 0) { @@ -78,7 +76,6 @@ public void step(SimState simstate) { super.activated = false; } - // Step metabolism process. super.processes.get(Domain.METABOLISM).step(simstate.random, sim); // Check energy status. If cell has less energy than threshold, it will @@ -102,10 +99,8 @@ public void step(SimState simstate) { } } - // Step inflammation process. super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); - // Change state from undefined. if (super.state == State.UNDEFINED || super.state == State.PAUSED) { if (divisions == 0) { if (simstate.random.nextDouble() > super.senescentFraction) { @@ -116,7 +111,6 @@ public void step(SimState simstate) { super.unbind(); this.activated = false; } else { - // Cell attempts to bind to a target PatchCellTissue target = super.bindTarget(sim, location, simstate.random); super.boundTarget = target; @@ -169,7 +163,6 @@ public void step(SimState simstate) { } } - // Step the module for the cell state. if (super.module != null) { super.module.step(simstate.random, sim); } diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index 8a42f68d2..109fd9b9a 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -26,15 +26,11 @@ public class PatchProcessInflammationCD8 extends PatchProcessInflammation { public PatchProcessInflammationCD8(PatchCellCART c) { super(c); - // Set parameters. Parameters parameters = cell.getParameters(); this.granz_synthesis_delay = parameters.getInt("inflammation/GRANZ_SYNTHESIS_DELAY"); this.priorIL2granz = 0; - // Initialize internal, external, and uptake concentration arrays. amts[GRANZYME] = 1; // [molecules] - - // Molecule names. names.add(GRANZYME, "granzyme"); } From 443b379bd0b0456acd31b543b4d2fa20843a7e9a Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 25 Feb 2025 22:20:35 +0000 Subject: [PATCH 157/185] adding javadoc and fixing variable name --- .../agent/process/PatchProcessInflammationCD8.java | 14 ++++++++++---- .../process/PatchProcessInflammationCD8Test.java | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index 109fd9b9a..f4f757a6c 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -6,12 +6,18 @@ import arcade.core.util.Parameters; import arcade.patch.agent.cell.PatchCellCART; +/** + * Extension of {@link PatchProcessInflammation} for CD8 CAR T-cells + * + *

      {@code InflammationCD8} determines granzyme amounts produced for cytotoxic effector functions + * as a function of IL-2 bound and antigen-induced activation state. + */ public class PatchProcessInflammationCD8 extends PatchProcessInflammation { /** Moles of granzyme produced per moles IL-2 [mol granzyme/mol IL-2]. */ private static final double GRANZ_PER_IL2 = 0.005; /** Delay in IL-2 synthesis after antigen-induced activation. */ - private final int granz_synthesis_delay; + private final int granzSynthesisDelay; /** Amount of IL-2 bound in past being used for current granzyme production calculation. */ private double priorIL2granz; @@ -27,7 +33,7 @@ public PatchProcessInflammationCD8(PatchCellCART c) { super(c); Parameters parameters = cell.getParameters(); - this.granz_synthesis_delay = parameters.getInt("inflammation/GRANZ_SYNTHESIS_DELAY"); + this.granzSynthesisDelay = parameters.getInt("inflammation/GRANZ_SYNTHESIS_DELAY"); this.priorIL2granz = 0; amts[GRANZYME] = 1; // [molecules] @@ -39,13 +45,13 @@ public void stepProcess(MersenneTwisterFast random, Simulation sim) { // Determine amount of granzyme production based on if cell is activated // as a function of IL-2 production. - int granzIndex = (iL2Ticker % boundArray.length) - granz_synthesis_delay; + int granzIndex = (iL2Ticker % boundArray.length) - granzSynthesisDelay; if (granzIndex < 0) { granzIndex += boundArray.length; } priorIL2granz = boundArray[granzIndex]; - if (active && activeTicker > granz_synthesis_delay) { + if (active && activeTicker > granzSynthesisDelay) { amts[GRANZYME] += GRANZ_PER_IL2 * (priorIL2granz / iL2Receptors); } diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java index bb62575b6..5d11314e4 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java @@ -58,7 +58,7 @@ public void constructor_setsParameters() throws NoSuchFieldException, IllegalAcc prior.setAccessible(true); assertEquals(0.0, prior.get(inflammation)); - Field delay = PatchProcessInflammationCD8.class.getDeclaredField("granz_synthesis_delay"); + Field delay = PatchProcessInflammationCD8.class.getDeclaredField("granzSynthesisDelay"); delay.setAccessible(true); assertEquals(1, delay.get(inflammation)); } From a14ef3e9fdb15ec98b6d547a001932e4e780d483 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Tue, 25 Feb 2025 23:18:09 +0000 Subject: [PATCH 158/185] adding tests for accessory methods in PatchCellCART --- .../patch/agent/cell/PatchCellCARTTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTTest.java b/test/arcade/patch/agent/cell/PatchCellCARTTest.java index 09afbb5df..241e65ab9 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTTest.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTTest.java @@ -199,4 +199,31 @@ public void getActivationStatus_called_returnsStatus() activation.set(patchCellCART, true); assertTrue(patchCellCART.getActivationStatus()); } + + @Test + public void getBoundTarget_called_returnsTarget() + throws NoSuchFieldException, IllegalAccessException { + Field target = PatchCellCART.class.getDeclaredField("boundTarget"); + target.setAccessible(true); + target.set(patchCellCART, tissueCell); + + PatchCell targetCell = patchCellCART.getBoundTarget(); + + assertEquals(targetCell, tissueCell); + } + + @Test + public void unbind_called_setsStateAndTarget() + throws NoSuchFieldException, IllegalAccessException { + patchCellCART.setBindingFlag(PatchEnums.AntigenFlag.BOUND_ANTIGEN); + Field target = PatchCellCART.class.getDeclaredField("boundTarget"); + target.setAccessible(true); + target.set(patchCellCART, tissueCell); + + patchCellCART.unbind(); + + PatchCell targetCell = patchCellCART.getBoundTarget(); + assertNull(targetCell); + assertEquals(PatchEnums.AntigenFlag.UNBOUND, patchCellCART.getBindingFlag()); + } } From 542f181e0ba960561e133a8e78ac9ab7e221e2e9 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 26 Feb 2025 00:01:13 +0000 Subject: [PATCH 159/185] refactoring cartcd8 tests --- .../agent/cell/PatchCellCARTCD8Test.java | 261 +++--------------- 1 file changed, 34 insertions(+), 227 deletions(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index f04103aa3..5d6f626fa 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -30,6 +30,7 @@ public class PatchCellCARTCD8Test { private Parameters parameters; private PatchLocation location; private PatchCellContainer container; + PatchSimulation sim; @BeforeEach public void setUp() throws NoSuchFieldException, IllegalAccessException { @@ -46,7 +47,6 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { double criticalVolume = randomDoubleBetween(100, 200); double criticalHeight = randomDoubleBetween(4, 10); State state = State.UNDEFINED; - ; container = new PatchCellContainer( @@ -60,11 +60,11 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { height, criticalVolume, criticalHeight); + doReturn(0.0).when(parameters).getDouble(any(String.class)); doReturn(0).when(parameters).getInt(any(String.class)); when(parameters.getDouble("HETEROGENEITY")).thenReturn(0.0); when(parameters.getDouble("ENERGY_THRESHOLD")).thenReturn(1.0); - when(parameters.getDouble("NECROTIC_FRACTION")) .thenReturn(randomIntBetween(40, 100) / 100.0); when(parameters.getDouble("EXHAU_FRAC")).thenReturn(randomIntBetween(40, 100) / 100.0); @@ -85,22 +85,12 @@ public void setUp() throws NoSuchFieldException, IllegalAccessException { when(parameters.getDouble("CONTACT_FRAC")).thenReturn(7.8E-6); when(parameters.getInt("MAX_ANTIGEN_BINDING")).thenReturn(10); when(parameters.getInt("CARS")).thenReturn(50000); - when(parameters.getInt("APOPTOSIS_AGE")).thenReturn(120960); + when(parameters.getDouble("APOPTOSIS_AGE")).thenReturn(120960.0); when(parameters.getInt("MAX_DENSITY")).thenReturn(54); cell = spy(new PatchCellCARTCD8(container, location, parameters)); - Field apoptosisAge = PatchCell.class.getDeclaredField("apoptosisAge"); - apoptosisAge.setAccessible(true); - apoptosisAge.set(cell, 120958); - - Field maxDensity = PatchCell.class.getDeclaredField("maxDensity"); - maxDensity.setAccessible(true); - maxDensity.set(cell, 54); - } - @Test - public void step_increasesAge() { - PatchSimulation sim = mock(PatchSimulation.class); + sim = mock(PatchSimulation.class); cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); @@ -122,37 +112,21 @@ public void step_increasesAge() { any(MersenneTwisterFast.class)); sim.random = random; cell.setState(State.UNDEFINED); + } + + @Test + public void step_called_increasesAge() { int initialAge = cell.getAge(); + cell.step(sim); + assertEquals(initialAge + 1, cell.getAge()); } @Test public void step_whenEnergyIsLow_setsStateToApoptotic() { - PatchSimulation sim = mock(PatchSimulation.class); - cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); - cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); - cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); - PatchModule module = mock(PatchModule.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - cell.module = module; - return null; - }) - .when(cell) - .setState(any(State.class)); - doReturn(new PatchCellTissue(container, location, parameters)) - .when(cell) - .bindTarget( - any(Simulation.class), - any(PatchLocation.class), - any(MersenneTwisterFast.class)); - sim.random = random; - cell.setState(State.UNDEFINED); - cell.setEnergy(-1 * randomIntBetween(2, 5)); + cell.step(sim); assertEquals(State.APOPTOTIC, cell.getState()); @@ -162,30 +136,8 @@ public void step_whenEnergyIsLow_setsStateToApoptotic() { @Test public void step_whenEnergyIsNegativeAndMoreThanThreshold_setsStateToStarved() { - PatchSimulation sim = mock(PatchSimulation.class); - cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); - cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); - cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); - PatchModule module = mock(PatchModule.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - cell.module = module; - return null; - }) - .when(cell) - .setState(any(State.class)); - doReturn(new PatchCellTissue(container, location, parameters)) - .when(cell) - .bindTarget( - any(Simulation.class), - any(PatchLocation.class), - any(MersenneTwisterFast.class)); - sim.random = random; - cell.setState(State.UNDEFINED); - cell.setEnergy(-0.5); + cell.step(sim); assertEquals(State.STARVED, cell.getState()); @@ -194,60 +146,19 @@ public void step_whenEnergyIsNegativeAndMoreThanThreshold_setsStateToStarved() { @Test public void step_whenEnergyIsNegativeAndMoreThanThreshold_setsStateToApoptotic() { - PatchSimulation sim = mock(PatchSimulation.class); - cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); - cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); - cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); - PatchModule module = mock(PatchModule.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - cell.module = module; - return null; - }) - .when(cell) - .setState(any(State.class)); - doReturn(new PatchCellTissue(container, location, parameters)) - .when(cell) - .bindTarget( - any(Simulation.class), - any(PatchLocation.class), - any(MersenneTwisterFast.class)); - sim.random = random; - cell.setState(State.UNDEFINED); - cell.setEnergy(-1.5); + cell.step(sim); assertEquals(State.APOPTOTIC, cell.getState()); } @Test - public void step_whenDivisionsAreZero_setsStateToSenescent() { - PatchSimulation sim = mock(PatchSimulation.class); - cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); - cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); - cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); - PatchModule module = mock(PatchModule.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - cell.divisions = 0; - cell.module = module; - return null; - }) - .when(cell) - .setState(any(State.class)); - doReturn(new PatchCellTissue(container, location, parameters)) - .when(cell) - .bindTarget( - any(Simulation.class), - any(PatchLocation.class), - any(MersenneTwisterFast.class)); - sim.random = random; - cell.setState(State.UNDEFINED); + public void step_whenDivisionsAreZero_setsStateToSenescent() + throws NoSuchFieldException, IllegalAccessException { + Field div = PatchCell.class.getDeclaredField("divisions"); + div.setAccessible(true); + div.set(cell, 0); cell.step(sim); @@ -258,30 +169,8 @@ public void step_whenDivisionsAreZero_setsStateToSenescent() { @Test public void step_whenBoundToBothAntigenAndSelf_setsStateToAnergic() { - PatchSimulation sim = mock(PatchSimulation.class); - cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); - cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); - cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); - PatchModule module = mock(PatchModule.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - cell.module = module; - return null; - }) - .when(cell) - .setState(any(State.class)); - doReturn(new PatchCellTissue(container, location, parameters)) - .when(cell) - .bindTarget( - any(Simulation.class), - any(PatchLocation.class), - any(MersenneTwisterFast.class)); - sim.random = random; - cell.setState(State.UNDEFINED); - cell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); + cell.step(sim); assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.ANERGIC); @@ -290,32 +179,12 @@ public void step_whenBoundToBothAntigenAndSelf_setsStateToAnergic() { } @Test - public void step_whenBoundToAntigen_setsStateToCytotoxic() { - PatchSimulation sim = mock(PatchSimulation.class); - cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); - cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); - cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); - PatchModule module = mock(PatchModule.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - cell.boundCARAntigensCount = 0; - cell.module = module; - return null; - }) - .when(cell) - .setState(any(State.class)); - doReturn(new PatchCellTissue(container, location, parameters)) - .when(cell) - .bindTarget( - any(Simulation.class), - any(PatchLocation.class), - any(MersenneTwisterFast.class)); - sim.random = random; - cell.setState(State.UNDEFINED); + public void step_whenBoundToAntigen_setsStateToCytotoxic() + throws NoSuchFieldException, IllegalAccessException { + Field boundAntigens = PatchCellCART.class.getDeclaredField("boundCARAntigensCount"); + boundAntigens.setAccessible(true); + boundAntigens.set(cell, 0); cell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); - Schedule schedule = mock(Schedule.class); doReturn(true).when(schedule).scheduleOnce(any(Steppable.class)); doReturn(schedule).when(sim).getSchedule(); @@ -326,30 +195,11 @@ public void step_whenBoundToAntigen_setsStateToCytotoxic() { } @Test - public void step_whenActivated_setsStateToProliferative() { - PatchSimulation sim = mock(PatchSimulation.class); - cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); - cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); - cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); - PatchModule module = mock(PatchModule.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - cell.activated = true; - cell.module = module; - return null; - }) - .when(cell) - .setState(any(State.class)); - doReturn(new PatchCellTissue(container, location, parameters)) - .when(cell) - .bindTarget( - any(Simulation.class), - any(PatchLocation.class), - any(MersenneTwisterFast.class)); - sim.random = random; - cell.setState(State.UNDEFINED); + public void step_whenActivated_setsStateToProliferative() + throws NoSuchFieldException, IllegalAccessException { + Field active = PatchCellCART.class.getDeclaredField("activated"); + active.setAccessible(true); + active.set(cell, true); cell.step(sim); @@ -358,60 +208,17 @@ public void step_whenActivated_setsStateToProliferative() { @Test public void step_whenNotActivated_setsStateToMigratory() { - PatchSimulation sim = mock(PatchSimulation.class); - cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); - cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); - cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); - PatchModule module = mock(PatchModule.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - cell.activated = false; - cell.module = module; - return null; - }) - .when(cell) - .setState(any(State.class)); - doReturn(new PatchCellTissue(container, location, parameters)) - .when(cell) - .bindTarget( - any(Simulation.class), - any(PatchLocation.class), - any(MersenneTwisterFast.class)); - sim.random = random; - cell.setState(State.UNDEFINED); - cell.step(sim); assertTrue(cell.getState() == State.MIGRATORY || cell.getState() == State.PROLIFERATIVE); } @Test - public void step_whenOverstimulated_setsStateToExhausted() { - PatchSimulation sim = mock(PatchSimulation.class); - cell.processes.put(Domain.METABOLISM, mock(PatchProcessMetabolism.class)); - cell.processes.put(Domain.SIGNALING, mock(PatchProcessSignaling.class)); - cell.processes.put(Domain.INFLAMMATION, mock(PatchProcessInflammation.class)); - PatchModule module = mock(PatchModule.class); - MersenneTwisterFast random = mock(MersenneTwisterFast.class); - doAnswer( - invocationOnMock -> { - cell.state = invocationOnMock.getArgument(0); - cell.boundCARAntigensCount = cell.maxAntigenBinding + 1; - cell.module = module; - return null; - }) - .when(cell) - .setState(any(State.class)); - doReturn(new PatchCellTissue(container, location, parameters)) - .when(cell) - .bindTarget( - any(Simulation.class), - any(PatchLocation.class), - any(MersenneTwisterFast.class)); - sim.random = random; - cell.setState(State.UNDEFINED); + public void step_whenOverstimulated_setsStateToExhausted() + throws NoSuchFieldException, IllegalAccessException { + Field boundAntigens = PatchCellCART.class.getDeclaredField("boundCARAntigensCount"); + boundAntigens.setAccessible(true); + boundAntigens.set(cell, cell.maxAntigenBinding + 1); cell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN); cell.step(sim); From 4f18a8ca02f60b65c734476d96b00e26b62ec2a4 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 26 Feb 2025 00:05:37 +0000 Subject: [PATCH 160/185] lintig the tests --- test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index 5d6f626fa..06314d212 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -27,13 +27,17 @@ public class PatchCellCARTCD8Test { private PatchCellCARTCD8 cell; + private Parameters parameters; + private PatchLocation location; + private PatchCellContainer container; + PatchSimulation sim; @BeforeEach - public void setUp() throws NoSuchFieldException, IllegalAccessException { + public final void setUp() throws NoSuchFieldException, IllegalAccessException { parameters = spy(new Parameters(new MiniBox(), null, null)); location = mock(PatchLocation.class); From 3406bd11cd99aae11ebe2a7225878301db5fc7b3 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 26 Feb 2025 00:09:55 +0000 Subject: [PATCH 161/185] linting --- .../agent/process/PatchProcessInflammationCD8Test.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java index 5d11314e4..3bc319452 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java @@ -20,14 +20,19 @@ public class PatchProcessInflammationCD8Test { private PatchProcessInflammationCD8 inflammation; + private PatchCellCART mockCell; + private Parameters mockParameters; + private Simulation mockSimulation; + private MersenneTwisterFast mockRandom; + private double cellVolume; @BeforeEach - public void setUp() { + public final void setUp() { mockCell = Mockito.mock(PatchCellCART.class); mockParameters = Mockito.mock(Parameters.class); mockSimulation = Mockito.mock(Simulation.class); From 8ff037d837ff9ffae269ac9b504a01e3d89d0660 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 26 Feb 2025 00:31:23 +0000 Subject: [PATCH 162/185] adding cytotoxic tests --- .../module/PatchModuleCytotoxicityTest.java | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 test/arcade/patch/agent/module/PatchModuleCytotoxicityTest.java diff --git a/test/arcade/patch/agent/module/PatchModuleCytotoxicityTest.java b/test/arcade/patch/agent/module/PatchModuleCytotoxicityTest.java new file mode 100644 index 000000000..f1fdc5973 --- /dev/null +++ b/test/arcade/patch/agent/module/PatchModuleCytotoxicityTest.java @@ -0,0 +1,75 @@ +package arcade.patch.agent.module; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import ec.util.MersenneTwisterFast; +import arcade.core.util.Parameters; +import arcade.patch.agent.cell.PatchCellCART; +import arcade.patch.agent.cell.PatchCellTissue; +import arcade.patch.agent.process.PatchProcessInflammation; +import arcade.patch.sim.PatchSimulation; +import arcade.patch.util.PatchEnums.State; +import static org.mockito.Mockito.*; + +public class PatchModuleCytotoxicityTest { + + private PatchCellCART mockCell; + + private PatchCellTissue mockTarget; + + private PatchProcessInflammation mockInflammation; + + private PatchModuleCytotoxicity action; + + private PatchSimulation sim; + + private MersenneTwisterFast randomMock; + + @BeforeEach + public void setUp() { + mockCell = mock(PatchCellCART.class); + mockTarget = mock(PatchCellTissue.class); + mockInflammation = mock(PatchProcessInflammation.class); + sim = mock(PatchSimulation.class); + randomMock = mock(MersenneTwisterFast.class); + Parameters parameters = mock(Parameters.class); + doReturn(0.0).when(parameters).getDouble(any(String.class)); + doReturn(0).when(parameters).getInt(any(String.class)); + + when(mockCell.getParameters()).thenReturn(parameters); + when(mockCell.getProcess(any())).thenReturn(mockInflammation); + when(mockInflammation.getInternal("granzyme")).thenReturn(1.0); + when(mockCell.getBoundTarget()).thenReturn(mockTarget); + + action = new PatchModuleCytotoxicity(mockCell); + } + + @Test + public void step_CARCellStopped_doesNotChangeCell() { + when(mockCell.isStopped()).thenReturn(true); + action.step(randomMock, sim); + + verify(mockTarget, never()).setState(any()); + } + + @Test + public void step_targetCellStopped_doesNotChangeCell() { + when(mockTarget.isStopped()).thenReturn(true); + action.step(randomMock, sim); + + verify(mockTarget, never()).setState(any()); + verify(mockCell).unbind(); + } + + @Test + public void step_killTargetCell_killsCellAndUsesGranzyme() { + when(mockCell.isStopped()).thenReturn(false); + when(mockTarget.isStopped()).thenReturn(false); + PatchModuleApoptosis mockProcess = mock(PatchModuleApoptosis.class); + when(mockTarget.getModule()).thenReturn(mockProcess); + action.step(randomMock, sim); + + verify(mockTarget).setState(State.APOPTOTIC); + verify(mockInflammation).setInternal("granzyme", 0.0); + } +} From 7fa6c4473d0af5dace41a49d4b50dd1c37b8d415 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 26 Feb 2025 00:35:35 +0000 Subject: [PATCH 163/185] adding final keyword --- test/arcade/patch/agent/module/PatchModuleCytotoxicityTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/arcade/patch/agent/module/PatchModuleCytotoxicityTest.java b/test/arcade/patch/agent/module/PatchModuleCytotoxicityTest.java index f1fdc5973..1c18e0a04 100644 --- a/test/arcade/patch/agent/module/PatchModuleCytotoxicityTest.java +++ b/test/arcade/patch/agent/module/PatchModuleCytotoxicityTest.java @@ -26,7 +26,7 @@ public class PatchModuleCytotoxicityTest { private MersenneTwisterFast randomMock; @BeforeEach - public void setUp() { + public final void setUp() { mockCell = mock(PatchCellCART.class); mockTarget = mock(PatchCellTissue.class); mockInflammation = mock(PatchProcessInflammation.class); From fad85751b8ecf5e538c86e47a0b7dcfa58d10f88 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Mar 2025 21:08:27 +0000 Subject: [PATCH 164/185] better variable names --- .../patch/agent/module/PatchModuleCytotoxicity.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java index 8d4699564..0ed332a32 100644 --- a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java +++ b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java @@ -42,15 +42,16 @@ public class PatchModuleCytotoxicity extends PatchModule { /** * Creates a {@code PatchActionKill} for the given {@link PatchCellCART}. * - * @param c the {@link PatchCell} the helper is associated with + * @param cell the {@link PatchCell} the helper is associated with */ - public PatchModuleCytotoxicity(PatchCell c) { - super(c); - this.target = (PatchCellTissue) ((PatchCellCART) c).getBoundTarget(); - this.inflammation = (PatchProcessInflammation) c.getProcess(PatchEnums.Domain.INFLAMMATION); + public PatchModuleCytotoxicity(PatchCell cell) { + super(cell); + this.target = (PatchCellTissue) ((PatchCellCART) cell).getBoundTarget(); + this.inflammation = + (PatchProcessInflammation) cell.getProcess(PatchEnums.Domain.INFLAMMATION); this.granzyme = inflammation.getInternal("granzyme"); - Parameters parameters = c.getParameters(); + Parameters parameters = cell.getParameters(); this.boundTime = parameters.getInt("BOUND_TIME"); this.boundRange = parameters.getInt("BOUND_RANGE"); this.timeDelay = 0; From 6842f1913f0f81f5bdf67155dac47724ad5d00fa Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Mar 2025 21:11:52 +0000 Subject: [PATCH 165/185] better variable names all around! --- .../agent/process/PatchProcessInflammation.java | 14 +++++++------- .../agent/process/PatchProcessInflammationCD4.java | 6 +++--- .../agent/process/PatchProcessInflammationCD8.java | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/arcade/patch/agent/process/PatchProcessInflammation.java b/src/arcade/patch/agent/process/PatchProcessInflammation.java index e8d4b2760..cefd90a79 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammation.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammation.java @@ -124,14 +124,14 @@ public abstract class PatchProcessInflammation extends PatchProcess { * bound and no three-chain receptors. Daughter cells split amounts of bound IL-2 and * three-chain receptors upon dividing. * - * @param c the {@link PatchCellCART} the module is associated with + * @param cell the {@link PatchCellCART} the module is associated with */ - public PatchProcessInflammation(PatchCellCART c) { - super(c); - this.loc = c.getLocation(); - this.cell = c; - this.pop = c.getPop(); - this.volume = c.getVolume(); + public PatchProcessInflammation(PatchCellCART cell) { + super(cell); + this.loc = cell.getLocation(); + this.cell = cell; + this.pop = cell.getPop(); + this.volume = cell.getVolume(); this.iL2Ticker = 0; this.activeTicker = 0; diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java index d76134f41..b97cdb102 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD4.java @@ -40,10 +40,10 @@ public class PatchProcessInflammationCD4 extends PatchProcessInflammation { * *

      IL-2 production rate parameters set. * - * @param c the {@link PatchCellCART} the module is associated with + * @param cell the {@link PatchCellCART} the module is associated with */ - public PatchProcessInflammationCD4(PatchCellCART c) { - super(c); + public PatchProcessInflammationCD4(PatchCellCART cell) { + super(cell); // Set parameters. Parameters parameters = cell.getParameters(); diff --git a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java index f4f757a6c..b0c751fc6 100644 --- a/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java +++ b/src/arcade/patch/agent/process/PatchProcessInflammationCD8.java @@ -27,10 +27,10 @@ public class PatchProcessInflammationCD8 extends PatchProcessInflammation { * *

      Initial amount of internal granzyme is set. Granzyme production parameters set. * - * @param c the {@link PatchCellCART} the module is associated with + * @param cell the {@link PatchCellCART} the module is associated with */ - public PatchProcessInflammationCD8(PatchCellCART c) { - super(c); + public PatchProcessInflammationCD8(PatchCellCART cell) { + super(cell); Parameters parameters = cell.getParameters(); this.granzSynthesisDelay = parameters.getInt("inflammation/GRANZ_SYNTHESIS_DELAY"); From f251b9880584a445da5e461cf0358fa4cb5ea9e6 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Mar 2025 21:40:37 +0000 Subject: [PATCH 166/185] just importing state and domain instead of entire patch enums --- .../patch/agent/module/PatchModuleCytotoxicity.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java index 0ed332a32..7a1526d74 100644 --- a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java +++ b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java @@ -7,7 +7,8 @@ import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.agent.cell.PatchCellTissue; import arcade.patch.agent.process.PatchProcessInflammation; -import arcade.patch.util.PatchEnums; +import static arcade.patch.util.PatchEnums.Domain; +import static arcade.patch.util.PatchEnums.State; /** * Implementation of {@link Module} for killing tissue agents. @@ -47,8 +48,7 @@ public class PatchModuleCytotoxicity extends PatchModule { public PatchModuleCytotoxicity(PatchCell cell) { super(cell); this.target = (PatchCellTissue) ((PatchCellCART) cell).getBoundTarget(); - this.inflammation = - (PatchProcessInflammation) cell.getProcess(PatchEnums.Domain.INFLAMMATION); + this.inflammation = (PatchProcessInflammation) cell.getProcess(Domain.INFLAMMATION); this.granzyme = inflammation.getInternal("granzyme"); Parameters parameters = cell.getParameters(); @@ -66,7 +66,7 @@ public void step(MersenneTwisterFast random, Simulation sim) { if (target.isStopped()) { ((PatchCellCART) cell).unbind(); - cell.setState(PatchEnums.State.UNDEFINED); + cell.setState(State.UNDEFINED); return; } @@ -75,13 +75,13 @@ public void step(MersenneTwisterFast random, Simulation sim) { (int) (boundTime + Math.round((boundRange * (2 * random.nextInt() - 1)))); if (granzyme >= 1) { PatchCellTissue tissueCell = (PatchCellTissue) target; - tissueCell.setState(PatchEnums.State.APOPTOTIC); + tissueCell.setState(State.APOPTOTIC); granzyme--; inflammation.setInternal("granzyme", granzyme); } } else if (ticker >= timeDelay) { ((PatchCellCART) cell).unbind(); - cell.setState(PatchEnums.State.UNDEFINED); + cell.setState(State.UNDEFINED); } ticker++; From e33fbc298745b0808293aaf12fd7959db307930b Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 10 Mar 2025 21:55:51 +0000 Subject: [PATCH 167/185] getting random double, not int for bound range --- src/arcade/patch/agent/module/PatchModuleCytotoxicity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java index 7a1526d74..3975095f5 100644 --- a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java +++ b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java @@ -72,7 +72,7 @@ public void step(MersenneTwisterFast random, Simulation sim) { if (ticker == 0) { this.timeDelay = - (int) (boundTime + Math.round((boundRange * (2 * random.nextInt() - 1)))); + (int) (boundTime + Math.round((boundRange * (2 * random.nextDouble() - 1)))); if (granzyme >= 1) { PatchCellTissue tissueCell = (PatchCellTissue) target; tissueCell.setState(State.APOPTOTIC); From 7c1f3d2fc9e52975680bf49d952777d039a2d27d Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 12 Mar 2025 18:36:55 +0000 Subject: [PATCH 168/185] I forgot to import the classes --- src/arcade/patch/agent/cell/PatchCell.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index d3e40e278..f0361ddf3 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -17,9 +17,7 @@ import arcade.core.util.GrabBag; import arcade.core.util.MiniBox; import arcade.core.util.Parameters; -import arcade.patch.agent.module.PatchModuleApoptosis; -import arcade.patch.agent.module.PatchModuleMigration; -import arcade.patch.agent.module.PatchModuleProliferation; +import arcade.patch.agent.module.*; import arcade.patch.agent.process.PatchProcessInflammation; import arcade.patch.agent.process.PatchProcessMetabolism; import arcade.patch.agent.process.PatchProcessSignaling; From b41493d299ef678065611add65c6506a5c47cf47 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 12 Mar 2025 19:32:16 +0000 Subject: [PATCH 169/185] editing tests --- .../agent/cell/PatchCellCARTCD8Test.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index 06314d212..4cd407c81 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -69,15 +69,11 @@ public final void setUp() throws NoSuchFieldException, IllegalAccessException { doReturn(0).when(parameters).getInt(any(String.class)); when(parameters.getDouble("HETEROGENEITY")).thenReturn(0.0); when(parameters.getDouble("ENERGY_THRESHOLD")).thenReturn(1.0); - when(parameters.getDouble("NECROTIC_FRACTION")) - .thenReturn(randomIntBetween(40, 100) / 100.0); - when(parameters.getDouble("EXHAU_FRAC")).thenReturn(randomIntBetween(40, 100) / 100.0); - when(parameters.getDouble("SENESCENT_FRACTION")) - .thenReturn(randomIntBetween(40, 100) / 100.0); - when(parameters.getDouble("ANERGIC_FRACTION")) - .thenReturn(randomIntBetween(40, 100) / 100.0); - when(parameters.getDouble("PROLIFERATIVE_FRACTION")) - .thenReturn(randomIntBetween(40, 100) / 100.0); + when(parameters.getDouble("NECROTIC_FRACTION")).thenReturn(0.5); + when(parameters.getDouble("EXHAUSTED_FRAC")).thenReturn(0.5); + when(parameters.getDouble("SENESCENT_FRACTION")).thenReturn(0.5); + when(parameters.getDouble("ANERGIC_FRACTION")).thenReturn(0.5); + when(parameters.getDouble("PROLIFERATIVE_FRACTION")).thenReturn(0.5); when(parameters.getInt("SELF_RECEPTORS")).thenReturn(randomIntBetween(100, 200)); when(parameters.getDouble("SEARCH_ABILITY")).thenReturn(1.0); when(parameters.getDouble("CAR_AFFINITY")).thenReturn(10 * Math.pow(10, -7)); @@ -114,6 +110,7 @@ public final void setUp() throws NoSuchFieldException, IllegalAccessException { any(Simulation.class), any(PatchLocation.class), any(MersenneTwisterFast.class)); + when(random.nextDouble()).thenReturn(0.49); sim.random = random; cell.setState(State.UNDEFINED); } @@ -163,10 +160,11 @@ public void step_whenDivisionsAreZero_setsStateToSenescent() Field div = PatchCell.class.getDeclaredField("divisions"); div.setAccessible(true); div.set(cell, 0); + when(sim.random.nextDouble()).thenReturn(0.51); cell.step(sim); - assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.SENESCENT); + assertTrue(cell.getState() == State.APOPTOTIC); assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); assertFalse(cell.getActivationStatus()); } @@ -177,7 +175,7 @@ public void step_whenBoundToBothAntigenAndSelf_setsStateToAnergic() { cell.step(sim); - assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.ANERGIC); + assertTrue(cell.getState() == State.ANERGIC); assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); assertFalse(cell.getActivationStatus()); } @@ -211,15 +209,22 @@ public void step_whenActivated_setsStateToProliferative() } @Test - public void step_whenNotActivated_setsStateToMigratory() { + public void step_whenNotActivated_setsStateToMigratory() + throws NoSuchFieldException, IllegalAccessException { + when(sim.random.nextDouble()).thenReturn(0.51); + Field active = PatchCellCART.class.getDeclaredField("activated"); + active.setAccessible(true); + active.set(cell, false); + cell.step(sim); - assertTrue(cell.getState() == State.MIGRATORY || cell.getState() == State.PROLIFERATIVE); + assertTrue(cell.getState() == State.MIGRATORY); } @Test public void step_whenOverstimulated_setsStateToExhausted() throws NoSuchFieldException, IllegalAccessException { + when(sim.random.nextDouble()).thenReturn(0.49); Field boundAntigens = PatchCellCART.class.getDeclaredField("boundCARAntigensCount"); boundAntigens.setAccessible(true); boundAntigens.set(cell, cell.maxAntigenBinding + 1); @@ -227,7 +232,7 @@ public void step_whenOverstimulated_setsStateToExhausted() cell.step(sim); - assertTrue(cell.getState() == State.APOPTOTIC || cell.getState() == State.EXHAUSTED); + assertTrue(cell.getState() == State.EXHAUSTED); assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); assertFalse(cell.getActivationStatus()); } From c5afd5ebec5185f70274df94638697ef8f808089 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 12 Mar 2025 20:08:27 +0000 Subject: [PATCH 170/185] changing bound time to uniform distribution over mean and range --- .../agent/module/PatchModuleCytotoxicity.java | 14 ++------------ src/arcade/patch/parameter.patch.xml | 1 + 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java index 3975095f5..cb7baca3a 100644 --- a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java +++ b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java @@ -28,18 +28,12 @@ public class PatchModuleCytotoxicity extends PatchModule { /** Amount of granzyme inside CAR T-cell. */ double granzyme; - /** Time delay before calling the action [min]. */ + /** Average time that T cell is bound to target [min]. */ private int timeDelay; /** Ticker to keep track of the time delay [min]. */ private int ticker; - /** Average time that T cell is bound to target [min]. */ - private double boundTime; - - /** Range in bound time [min]. */ - private double boundRange; - /** * Creates a {@code PatchActionKill} for the given {@link PatchCellCART}. * @@ -52,9 +46,7 @@ public PatchModuleCytotoxicity(PatchCell cell) { this.granzyme = inflammation.getInternal("granzyme"); Parameters parameters = cell.getParameters(); - this.boundTime = parameters.getInt("BOUND_TIME"); - this.boundRange = parameters.getInt("BOUND_RANGE"); - this.timeDelay = 0; + this.timeDelay = parameters.getInt("BOUND_TIME"); this.ticker = 0; } @@ -71,8 +63,6 @@ public void step(MersenneTwisterFast random, Simulation sim) { } if (ticker == 0) { - this.timeDelay = - (int) (boundTime + Math.round((boundRange * (2 * random.nextDouble() - 1)))); if (granzyme >= 1) { PatchCellTissue tissueCell = (PatchCellTissue) target; tissueCell.setState(State.APOPTOTIC); diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index 686994918..c3fdf8f8d 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -44,6 +44,7 @@ + From 731eb0aa9faaf03ce171f8fe186491fb8bd29bbc Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 12 Mar 2025 20:11:05 +0000 Subject: [PATCH 171/185] making boundTime final --- src/arcade/patch/agent/module/PatchModuleCytotoxicity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java index cb7baca3a..57224c9e9 100644 --- a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java +++ b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java @@ -29,7 +29,7 @@ public class PatchModuleCytotoxicity extends PatchModule { double granzyme; /** Average time that T cell is bound to target [min]. */ - private int timeDelay; + final private int timeDelay; /** Ticker to keep track of the time delay [min]. */ private int ticker; From 6bd992da49b4a12b4bfafc7a5d3168462a33fb93 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 12 Mar 2025 20:12:47 +0000 Subject: [PATCH 172/185] adding linting --- src/arcade/patch/agent/module/PatchModuleCytotoxicity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java index 57224c9e9..9423e69dd 100644 --- a/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java +++ b/src/arcade/patch/agent/module/PatchModuleCytotoxicity.java @@ -29,7 +29,7 @@ public class PatchModuleCytotoxicity extends PatchModule { double granzyme; /** Average time that T cell is bound to target [min]. */ - final private int timeDelay; + private final int timeDelay; /** Ticker to keep track of the time delay [min]. */ private int ticker; From 8ae58ae8b84300591586b54fa872da7a64da24cd Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 24 Mar 2025 17:04:14 +0000 Subject: [PATCH 173/185] patching up patch cell rules such that quiescent is properly handeled --- src/arcade/patch/agent/cell/PatchCell.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index d4597c0f4..a4fae080c 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -18,11 +18,13 @@ import arcade.core.util.MiniBox; import arcade.core.util.Parameters; import arcade.patch.agent.module.PatchModuleApoptosis; +import arcade.patch.agent.module.PatchModuleCytotoxicity; import arcade.patch.agent.module.PatchModuleMigration; import arcade.patch.agent.module.PatchModuleNecrosis; import arcade.patch.agent.module.PatchModuleProliferation; import arcade.patch.agent.module.PatchModuleQuiescence; import arcade.patch.agent.module.PatchModuleSenescence; +import arcade.patch.agent.module.PatchModuleStimulation; import arcade.patch.agent.process.PatchProcessInflammation; import arcade.patch.agent.process.PatchProcessMetabolism; import arcade.patch.agent.process.PatchProcessSignaling; @@ -371,7 +373,11 @@ public void setState(CellState state) { module = new PatchModuleNecrosis(this); break; case QUIESCENT: - module = new PatchModuleQuiescence(this); + if (this instanceof PatchCellCART) { + this.setState(State.UNDEFINED); + } else { + module = new PatchModuleQuiescence(this); + } break; case SENESCENT: module = new PatchModuleSenescence(this); @@ -382,11 +388,6 @@ public void setState(CellState state) { case CYTOTOXIC: module = new PatchModuleCytotoxicity(this); break; - case QUIESCENT: - if (this instanceof PatchCellCART) { - this.setState(State.UNDEFINED); - } - break; default: module = null; break; From 95b7c2e611d4a2dfcc60d782acfe703de6de1d85 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 24 Mar 2025 18:32:48 +0000 Subject: [PATCH 174/185] fixing setState such that CART cells cannot be quiescent --- src/arcade/patch/agent/cell/PatchCell.java | 3 ++- .../agent/module/PatchModuleProliferation.java | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index a4fae080c..559e3b161 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -374,7 +374,8 @@ public void setState(CellState state) { break; case QUIESCENT: if (this instanceof PatchCellCART) { - this.setState(State.UNDEFINED); + throw new UnsupportedOperationException( + "CART cells do not have corresponding state"); } else { module = new PatchModuleQuiescence(this); } diff --git a/src/arcade/patch/agent/module/PatchModuleProliferation.java b/src/arcade/patch/agent/module/PatchModuleProliferation.java index 572a6524f..e5134bf8b 100644 --- a/src/arcade/patch/agent/module/PatchModuleProliferation.java +++ b/src/arcade/patch/agent/module/PatchModuleProliferation.java @@ -8,6 +8,7 @@ import arcade.core.util.MiniBox; import arcade.core.util.Parameters; import arcade.patch.agent.cell.PatchCell; +import arcade.patch.agent.cell.PatchCellCART; import arcade.patch.agent.process.PatchProcess; import arcade.patch.env.grid.PatchGrid; import arcade.patch.env.location.PatchLocation; @@ -73,12 +74,20 @@ public void step(MersenneTwisterFast random, Simulation sim) { // space in neighborhood to divide into. Otherwise, check if double // volume has been reached, and if so, create a new cell. if (currentHeight > maxHeight) { - cell.setState(State.QUIESCENT); + if (cell instanceof PatchCellCART) { + cell.setState(State.PAUSED); + } else { + cell.setState(State.QUIESCENT); + } } else { PatchLocation newLocation = cell.selectBestLocation(sim, random); if (newLocation == null) { - cell.setState(State.QUIESCENT); + if (cell instanceof PatchCellCART) { + cell.setState(State.PAUSED); + } else { + cell.setState(State.QUIESCENT); + } } else if (cell.getVolume() >= targetVolume) { if (ticker > synthesisDuration) { From 6819e731e8147813e2678b237534eb60d507b0f5 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 24 Mar 2025 18:35:26 +0000 Subject: [PATCH 175/185] updating divisions to increment after #161 merge --- src/arcade/patch/agent/cell/PatchCellCARTCD4.java | 2 +- src/arcade/patch/agent/cell/PatchCellCARTCD8.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 2d2dafb54..8b3b48f86 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -40,7 +40,7 @@ public PatchCellCARTCD4( @Override public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFast random) { - divisions--; + divisions++; return new PatchCellContainer( newID, id, diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index 94f4daf9a..33402a99b 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -40,7 +40,7 @@ public PatchCellCARTCD8( @Override public PatchCellContainer make(int newID, CellState newState, MersenneTwisterFast random) { - divisions--; + divisions++; return new PatchCellContainer( newID, id, From 552d9167896a7cbb1e29dd81d80663650b5bafa8 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 24 Mar 2025 18:46:56 +0000 Subject: [PATCH 176/185] adding minutes in a day constant --- src/arcade/patch/agent/cell/PatchCellCART.java | 4 ++++ src/arcade/patch/agent/cell/PatchCellCARTCD4.java | 4 ++-- src/arcade/patch/agent/cell/PatchCellCARTCD8.java | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 23c205771..52dc5dab2 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -48,6 +48,10 @@ * parameter classes have support for loading in distributions to reflect heterogeneity. */ public abstract class PatchCellCART extends PatchCell { + + /** Constant for amount of minutes in a day. */ + public static final int DAYS_IN_MINUTES = 1440; + /** Cell activation flag. */ protected boolean activated; diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 8b3b48f86..196ac88b2 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -69,10 +69,10 @@ public void step(SimState simstate) { // Increase time since last active ticker super.lastActiveTicker++; - if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { + if (super.lastActiveTicker != 0 && super.lastActiveTicker % DAYS_IN_MINUTES == 0) { if (super.boundCARAntigensCount != 0) super.boundCARAntigensCount--; } - if (super.lastActiveTicker / 1440 >= 7) super.activated = false; + if (super.lastActiveTicker / DAYS_IN_MINUTES >= 7) super.activated = false; // Step metabolism process. super.processes.get(Domain.METABOLISM).step(simstate.random, sim); diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index 33402a99b..cf5ebf628 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -67,12 +67,12 @@ public void step(SimState simstate) { } super.lastActiveTicker++; - if (super.lastActiveTicker != 0 && super.lastActiveTicker % 1440 == 0) { + if (super.lastActiveTicker != 0 && super.lastActiveTicker % DAYS_IN_MINUTES == 0) { if (super.boundCARAntigensCount != 0) { super.boundCARAntigensCount--; } } - if (super.lastActiveTicker / 1440 > 7) { + if (super.lastActiveTicker / DAYS_IN_MINUTES >= 7) { super.activated = false; } From 589e5e73af3ec3a49ba3901d2a6176bcda1bf18a Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Mon, 24 Mar 2025 18:53:21 +0000 Subject: [PATCH 177/185] renaming constant bc its minutes in a day not the other way around --- src/arcade/patch/agent/cell/PatchCellCART.java | 2 +- src/arcade/patch/agent/cell/PatchCellCARTCD4.java | 4 ++-- src/arcade/patch/agent/cell/PatchCellCARTCD8.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCART.java b/src/arcade/patch/agent/cell/PatchCellCART.java index 52dc5dab2..25cc71835 100644 --- a/src/arcade/patch/agent/cell/PatchCellCART.java +++ b/src/arcade/patch/agent/cell/PatchCellCART.java @@ -50,7 +50,7 @@ public abstract class PatchCellCART extends PatchCell { /** Constant for amount of minutes in a day. */ - public static final int DAYS_IN_MINUTES = 1440; + public static final int MINUTES_IN_DAY = 1440; /** Cell activation flag. */ protected boolean activated; diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java index 196ac88b2..fb39f96a8 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD4.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD4.java @@ -69,10 +69,10 @@ public void step(SimState simstate) { // Increase time since last active ticker super.lastActiveTicker++; - if (super.lastActiveTicker != 0 && super.lastActiveTicker % DAYS_IN_MINUTES == 0) { + if (super.lastActiveTicker != 0 && super.lastActiveTicker % MINUTES_IN_DAY == 0) { if (super.boundCARAntigensCount != 0) super.boundCARAntigensCount--; } - if (super.lastActiveTicker / DAYS_IN_MINUTES >= 7) super.activated = false; + if (super.lastActiveTicker / MINUTES_IN_DAY >= 7) super.activated = false; // Step metabolism process. super.processes.get(Domain.METABOLISM).step(simstate.random, sim); diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index cf5ebf628..96c59bb14 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -67,12 +67,12 @@ public void step(SimState simstate) { } super.lastActiveTicker++; - if (super.lastActiveTicker != 0 && super.lastActiveTicker % DAYS_IN_MINUTES == 0) { + if (super.lastActiveTicker != 0 && super.lastActiveTicker % MINUTES_IN_DAY == 0) { if (super.boundCARAntigensCount != 0) { super.boundCARAntigensCount--; } } - if (super.lastActiveTicker / DAYS_IN_MINUTES >= 7) { + if (super.lastActiveTicker / MINUTES_IN_DAY >= 7) { super.activated = false; } From 34adb926ea91dc174082e0214ac697b846a29ad8 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 26 Mar 2025 04:28:39 +0000 Subject: [PATCH 178/185] removing frivolous else statement --- src/arcade/patch/agent/cell/PatchCell.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 559e3b161..0a8393249 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -376,9 +376,8 @@ public void setState(CellState state) { if (this instanceof PatchCellCART) { throw new UnsupportedOperationException( "CART cells do not have corresponding state"); - } else { - module = new PatchModuleQuiescence(this); } + module = new PatchModuleQuiescence(this); break; case SENESCENT: module = new PatchModuleSenescence(this); From 4622588a204810e82e5c5ee141554ee9fe7ca00c Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 26 Mar 2025 04:34:33 +0000 Subject: [PATCH 179/185] adding description for granzyme synthesis delay --- src/arcade/patch/parameter.patch.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index 9a8708f72..911bd65f6 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -94,7 +94,7 @@ - + From 09c64c21e6dbeef65fb43db722af5f4e167b1602 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 26 Mar 2025 04:36:22 +0000 Subject: [PATCH 180/185] making bound time a constant bc the range default was 0 --- src/arcade/patch/parameter.patch.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arcade/patch/parameter.patch.xml b/src/arcade/patch/parameter.patch.xml index 911bd65f6..7a6211c3d 100644 --- a/src/arcade/patch/parameter.patch.xml +++ b/src/arcade/patch/parameter.patch.xml @@ -43,7 +43,7 @@ - + From ca75c406c8c72a5a5c1cc58f9c145187a0aaa4f1 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 26 Mar 2025 17:29:42 +0000 Subject: [PATCH 181/185] deleting cell state exception --- src/arcade/patch/agent/cell/PatchCell.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCell.java b/src/arcade/patch/agent/cell/PatchCell.java index 0a8393249..1e6e71cac 100644 --- a/src/arcade/patch/agent/cell/PatchCell.java +++ b/src/arcade/patch/agent/cell/PatchCell.java @@ -373,10 +373,6 @@ public void setState(CellState state) { module = new PatchModuleNecrosis(this); break; case QUIESCENT: - if (this instanceof PatchCellCART) { - throw new UnsupportedOperationException( - "CART cells do not have corresponding state"); - } module = new PatchModuleQuiescence(this); break; case SENESCENT: From 7de24949af164a14f54af8e086c71554c8c4495b Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 26 Mar 2025 20:20:38 +0000 Subject: [PATCH 182/185] setting state to senescent when division potential is met --- src/arcade/patch/agent/cell/PatchCellCARTCD8.java | 2 +- test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java index 96c59bb14..708bd8682 100644 --- a/src/arcade/patch/agent/cell/PatchCellCARTCD8.java +++ b/src/arcade/patch/agent/cell/PatchCellCARTCD8.java @@ -102,7 +102,7 @@ public void step(SimState simstate) { super.processes.get(Domain.INFLAMMATION).step(simstate.random, sim); if (super.state == State.UNDEFINED || super.state == State.PAUSED) { - if (divisions == 0) { + if (divisions == divisionPotential) { if (simstate.random.nextDouble() > super.senescentFraction) { super.setState(State.APOPTOTIC); } else { diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index 4cd407c81..4ed0d5afc 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -87,6 +87,7 @@ public final void setUp() throws NoSuchFieldException, IllegalAccessException { when(parameters.getInt("CARS")).thenReturn(50000); when(parameters.getDouble("APOPTOSIS_AGE")).thenReturn(120960.0); when(parameters.getInt("MAX_DENSITY")).thenReturn(54); + when(parameters.getInt("DIVISION_POTENTIAL")).thenReturn(10); cell = spy(new PatchCellCARTCD8(container, location, parameters)); @@ -155,11 +156,11 @@ public void step_whenEnergyIsNegativeAndMoreThanThreshold_setsStateToApoptotic() } @Test - public void step_whenDivisionsAreZero_setsStateToSenescent() + public void step_whenDivisionPotentialMet_setsStateToSenescent() throws NoSuchFieldException, IllegalAccessException { Field div = PatchCell.class.getDeclaredField("divisions"); div.setAccessible(true); - div.set(cell, 0); + div.set(cell, cell.divisionPotential); when(sim.random.nextDouble()).thenReturn(0.51); cell.step(sim); From 32fb3ab376d2ac5a268da0b75780fd00268ad89d Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Wed, 26 Mar 2025 20:30:00 +0000 Subject: [PATCH 183/185] changing setup such that divisions count up --- test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index 4ed0d5afc..512808deb 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -45,7 +45,7 @@ public final void setUp() throws NoSuchFieldException, IllegalAccessException { int parentId = 1; int pop = 1; int age = randomIntBetween(1, 120950); - int divisions = 10; + int divisions = 0; double volume = randomDoubleBetween(100, 200); double height = randomDoubleBetween(4, 10); double criticalVolume = randomDoubleBetween(100, 200); From 20b9dce07a2703f4a467c428338f0455379aacf9 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 27 Mar 2025 00:05:05 +0000 Subject: [PATCH 184/185] adding test for BOTH senescence and apoptosis when division potential is met --- .../patch/agent/cell/PatchCellCARTCD8Test.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java index 512808deb..a28ec9bb5 100644 --- a/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java +++ b/test/arcade/patch/agent/cell/PatchCellCARTCD8Test.java @@ -156,7 +156,7 @@ public void step_whenEnergyIsNegativeAndMoreThanThreshold_setsStateToApoptotic() } @Test - public void step_whenDivisionPotentialMet_setsStateToSenescent() + public void step_whenDivisionPotentialMet_setsStateToApoptotic() throws NoSuchFieldException, IllegalAccessException { Field div = PatchCell.class.getDeclaredField("divisions"); div.setAccessible(true); @@ -170,6 +170,21 @@ public void step_whenDivisionPotentialMet_setsStateToSenescent() assertFalse(cell.getActivationStatus()); } + @Test + public void step_whenDivisionPotentialMet_setsStateToSenescent() + throws NoSuchFieldException, IllegalAccessException { + Field div = PatchCell.class.getDeclaredField("divisions"); + div.setAccessible(true); + div.set(cell, cell.divisionPotential); + when(sim.random.nextDouble()).thenReturn(0.49); + + cell.step(sim); + + assertTrue(cell.getState() == State.SENESCENT); + assertEquals(AntigenFlag.UNBOUND, cell.getBindingFlag()); + assertFalse(cell.getActivationStatus()); + } + @Test public void step_whenBoundToBothAntigenAndSelf_setsStateToAnergic() { cell.setBindingFlag(AntigenFlag.BOUND_ANTIGEN_CELL_RECEPTOR); From 1f6a2e6fe52f4aa8dcebb08ba442856e71870445 Mon Sep 17 00:00:00 2001 From: allison-li-1016 Date: Thu, 27 Mar 2025 20:25:36 +0000 Subject: [PATCH 185/185] renaming tests to match convention --- .../patch/agent/process/PatchProcessInflammationCD8Test.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java index 3bc319452..a6f7b4332 100644 --- a/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java +++ b/test/arcade/patch/agent/process/PatchProcessInflammationCD8Test.java @@ -53,7 +53,8 @@ public final void setUp() { } @Test - public void constructor_setsParameters() throws NoSuchFieldException, IllegalAccessException { + public void constructor_called_setsParameters() + throws NoSuchFieldException, IllegalAccessException { inflammation = new PatchProcessInflammationCD8(mockCell); assertNotNull(inflammation); @@ -69,7 +70,7 @@ public void constructor_setsParameters() throws NoSuchFieldException, IllegalAcc } @Test - public void stepProcess_updatesEnvironment() + public void stepProcess_called_updatesEnvironment() throws NoSuchFieldException, IllegalAccessException { inflammation = new PatchProcessInflammationCD8(mockCell); inflammation.active = true;