Skip to content

Commit

Permalink
Added first draft of custom pop output
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-noel committed Sep 4, 2024
1 parent 70e2337 commit 165101c
Show file tree
Hide file tree
Showing 12 changed files with 381 additions and 22 deletions.
76 changes: 76 additions & 0 deletions engine/examples/popmaboss/ICD_phenomenologicalPM.pbnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
node TumorCell
{
rate_up = 0.0;
rate_down = 0.0;
}

node DyingTumorCell
{
rate_up = TumorCell ? $chemotherapy : 0.0 ;
rate_down = 0.0;
}

node CALR
{
rate_up = DyingTumorCell ? $u_CALR : 0.0;
// rate_down = Death ? $d_CALR : 0.0 ;
rate_down = 0.0;
}

node ATP
{
rate_up = DyingTumorCell ? $u_ATP : 0.0 ;
rate_down = DyingTumorCell ? 0.0 : $d_ATP ;
}

node HMGB1
{
rate_up = DyingTumorCell ? $u_HMGB1 : 0.0 ;
rate_down = DyingTumorCell ? 0.0 : $d_HMGB1 ;
}

node DC
{
rate_up = 0.0;
rate_down = 0.0;
}

node ActDC
{
rate_up = DC ? ((#cell(CALR)/#cell(1)) * (#cell(ATP)/#cell(1)) *(#cell(HMGB1)/#cell(1))) : 0.0 ;
rate_down = 0.0;
}

node MigrDC
{
rate_up = ActDC ? $migrDC : 0.0;
rate_down = 0.0;
}

node LNodeDC
{
rate_up = MigrDC ? $lNodeDC : 0.0;
rate_down = 0.0;
}

node TCell
{
rate_up = LNodeDC ? $primingTCell : 0.0 ;
rate_down = 0.0 ;
}

node CTL
{
rate_up = TCell ? $activateCTL : 0.0 ;
rate_down = 0.0 ;
}

death
{
rate = (TumorCell ? (-log(1- (#cell(CTL)/#cell(1)))) : 0.0) + (CTL ? (-log(1- (#cell(TumorCell)/#cell(1)))) : 0.0) + (DyingTumorCell ? $deathChemotherapy : 0.0);
}

division
{
rate = (TumorCell ? $growthFactor : 0.0) + ((TCell & !(CTL)) ? (#cell(TumorCell)/#cell(1)*$clonalExpansion) : 0.0) ;
}
74 changes: 74 additions & 0 deletions engine/examples/popmaboss/ICD_phenomenological_TDC_ratio.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// MaBoSS 2.0 configuration template generated at Wed Nov 20 11:08:24 2019
//

// global configuration variables
time_tick = 1;
//max_time = 720;
max_time = 720;
//sample_count = 100000;
sample_count = 160000;
discrete_time = 0;
use_physrandgen = 0;
seed_pseudorandom = 0;
display_traj = 0;
statdist_traj_count = 0;
statdist_cluster_threshold = 1;
thread_count = 16;
statdist_similarity_cache_max_size = 20000;
// init_pop = 20;

// variables to be set in the configuration file or by using the --config-vars option
$u_CALR = 1/4;
$d_CALR = 50;
$u_ATP = 1/4;
$d_ATP = 50;
$u_HMGB1 = 1/6;
$d_HMGB1 = 50;
$migrDC = 1/(2*24);
$lNodeDC = 1/(3*24);
$activateCTL = 1/24;
$primingTCell = 1/(24);
$chemotherapy = .5;
$deathChemotherapy = 1/100;
$clonalExpansion = 1/12;
// $expCALR = 0; // define in upp
$growthFactor = 1/(240);
// $secrATP = 0; // define in upp
// $secrHMGB1 = 0; // defined in upp
$popCTL = 0; // defined in upp
// $popTumorCell = 0; // defined in upp
// set is_internal attribute value to 1 if node is an internal node
TumorCell.is_internal = 1;
DyingTumorCell.is_internal = 1;
CALR.is_internal = 1;
ATP.is_internal = 1;
HMGB1.is_internal = 1;
DC.is_internal = 0;
ActDC.is_internal = 1;
MigrDC.is_internal = 1;
LNodeDC.is_internal = 1;
TCell.is_internal = 0;
CTL.is_internal = 1;
// if NODE initial state is:
// - equals to 1: NODE.istate = 1;
// - equals to 0: NODE.istate = 0;
// - random: NODE.istate = -1; OR [NODE].istate = 0.5 [0], 0.5 [1]; OR skip NODE.istate declaration
// - weighted random: [NODE].istate = P0 [0], P1 [1]; where P0 and P1 are arithmetic expressions

[TumorCell,DC].pop_istate = 1.0 [{[1,0]:18} , {[0,1]:2}];

TumorCell.istate = 0;
DC.istate = 0;
DyingTumorCell.istate = 0;
CALR.istate = 0;
ATP.istate = 0;
HMGB1.istate = 0;
ActDC.istate = 0;
MigrDC.istate = 0;
LNodeDC.istate = 0;
TCell.istate = 0;
CTL.istate = 0;

custom_pop_output = #cell(DC) > 0 ? (#cell(DC -- TCell)+#cell(TCell))/#cell(DC) : 0.0;
// custom_pop_output = #cell(TCell);
94 changes: 94 additions & 0 deletions engine/src/BooleanNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,64 @@ namespace std {
};
}

class PopSize {
unsigned int size;
public:
PopSize(unsigned int size) : size(size) { }
PopSize() : size(0) { }
void set() {size = 0;}
unsigned int getSize() const {return size;}
static bool isPopState() {return false;}

// & operator for applying the mask
PopSize operator&(const NetworkState_Impl& mask) const {
return PopSize(size);
}

// & operator for applying the mask
PopSize operator&(const NetworkState& mask) const {
return PopSize(size);
}

PopSize applyMask(const PopSize& mask, std::map<unsigned int, unsigned int>& scale) const {
return PopSize(size);
}

bool operator==(const PopSize& pop_size) const {
return pop_size.getSize() == size;
}

bool operator<(const PopSize& pop_size) const {
return size < pop_size.getSize();
}

int hamming(Network* network, const NetworkState& state) const {
return 0;
}
std::set<NetworkState_Impl>* getNetworkStates() const {
return new std::set<NetworkState_Impl>();
}

std::string getName(Network * network, const std::string& sep=" -- ") const {
return std::to_string(size);
}

void displayOneLine(std::ostream& os, Network* network, const std::string& sep = " -- ") const {
os << getName(network, sep);
}


};

namespace std {
template <> struct hash<PopSize>
{
size_t operator()(const PopSize & x) const
{
return x.getSize();
}
};
}
// abstract base class used for expression evaluation
class Expression {

Expand Down Expand Up @@ -1426,6 +1484,42 @@ class NodeExpression : public Expression {
}
};


class StateExpression: public Expression {
NetworkState state;
Network* network;
public:
StateExpression(NetworkState state, Network* network) : state(state), network(network) { }

Expression* clone() const {return new StateExpression(state, network);}

double eval(const Node* this_node, const NetworkState& network_state) const {
return state.getState() == network_state.getState() ? 1.0 : 0.0;
}

double eval(const Node* this_node, const NetworkState& network_state, const PopNetworkState& pop_state) const {
return state.getState() == network_state.getState() ? 1.0 : 0.0;
}

bool hasCycle(Node* node) const {
return false;
}

void display(std::ostream& os) const {
state.displayOneLine(os, network);
}

bool isLogicalExpression() const {return true;}
std::vector<Node*> getNodes() const{
return std::vector<Node*>();
}

void generateLogicalExpression(LogicalExprGenContext& genctx) const {}

~StateExpression() {
}
};

class PopExpression : public Expression {
Expression* expr;

Expand Down
4 changes: 4 additions & 0 deletions engine/src/Cumulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,10 @@ class Cumulator {
this->output_mask = output_mask;
}

S getOutputMask() const {
return output_mask;
}

void setRefnodeMask(const NetworkState_Impl& refnode_mask) {
this->refnode_mask = refnode_mask;
}
Expand Down
Loading

0 comments on commit 165101c

Please sign in to comment.