Skip to content

Commit

Permalink
move step() down to TissueCell
Browse files Browse the repository at this point in the history
  • Loading branch information
allison-li-1016 committed Oct 23, 2023
1 parent 5476c24 commit 7ddfb2c
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 56 deletions.
61 changes: 5 additions & 56 deletions src/arcade/patch/agent/cell/PatchCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
58 changes: 58 additions & 0 deletions src/arcade/patch/agent/cell/PatchCellTissue.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import arcade.core.env.location.Location;
import arcade.core.util.MiniBox;

import sim.engine.SimState;

Check failure on line 8 in src/arcade/patch/agent/cell/PatchCellTissue.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/patch/agent/cell/PatchCellTissue.java#L8 <com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck>

Extra separation in import group before 'sim.engine.SimState'
Raw output
/github/workspace/./src/arcade/patch/agent/cell/PatchCellTissue.java:8:1: error: Extra separation in import group before 'sim.engine.SimState' (com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck)

Check failure on line 8 in src/arcade/patch/agent/cell/PatchCellTissue.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/patch/agent/cell/PatchCellTissue.java#L8 <com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck>

Wrong order for 'sim.engine.SimState' import.
Raw output
/github/workspace/./src/arcade/patch/agent/cell/PatchCellTissue.java:8:1: error: Wrong order for 'sim.engine.SimState' import. (com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck)
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.
*/
Expand Down Expand Up @@ -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

Check failure on line 59 in src/arcade/patch/agent/cell/PatchCellTissue.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/patch/agent/cell/PatchCellTissue.java#L59 <com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck>

Comment matches to-do format 'TODO:'.
Raw output
/github/workspace/./src/arcade/patch/agent/cell/PatchCellTissue.java:59:11: error: Comment matches to-do format 'TODO:'. (com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck)

// 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);
}
}
}
23 changes: 23 additions & 0 deletions test/arcade/patch/util/PatchEnumsTest.java
Original file line number Diff line number Diff line change
@@ -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;

Check failure on line 8 in test/arcade/patch/util/PatchEnumsTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] test/arcade/patch/util/PatchEnumsTest.java#L8 <com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck>

Extra separation in import group before 'arcade.patch.util.PatchEnums.Category'
Raw output
/github/workspace/./test/arcade/patch/util/PatchEnumsTest.java:8:1: error: Extra separation in import group before 'arcade.patch.util.PatchEnums.Category' (com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck)
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;

Check failure on line 13 in test/arcade/patch/util/PatchEnumsTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] test/arcade/patch/util/PatchEnumsTest.java#L13 <com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck>

Wrong order for 'ec.util.MersenneTwisterFast' import.
Raw output
/github/workspace/./test/arcade/patch/util/PatchEnumsTest.java:13:1: error: Wrong order for 'ec.util.MersenneTwisterFast' import. (com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck)
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
Expand Down Expand Up @@ -101,4 +108,20 @@ public void Category_random_returnsCategory() {
EnumSet<Category> enumSetRandom = EnumSet.copyOf(enumRandom);
assertEquals(enumSet, enumSetRandom);
}

@Test
public void Ordering_in_expected_order() {
// Create list of all values.
ArrayList<Ordering> enumList = new ArrayList<Ordering>(Arrays.asList(Ordering.values()));

int n = -1;
int verify = -2;
// Grabbing order of items in enum
for (Ordering x: enumList){

Check failure on line 120 in test/arcade/patch/util/PatchEnumsTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] test/arcade/patch/util/PatchEnumsTest.java#L120 <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck>

'{' is not preceded with whitespace.
Raw output
/github/workspace/./test/arcade/patch/util/PatchEnumsTest.java:120:35: error: '{' is not preceded with whitespace. (com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck)
verify = x.ordinal();
n++;
// Verify order of enum
assertEquals(n, verify);
}
}
}

0 comments on commit 7ddfb2c

Please sign in to comment.