Skip to content

Commit

Permalink
Merge pull request #85 from sysbio-curie/update/physiboss
Browse files Browse the repository at this point in the history
Updating PhysiBoSS to 2.1.0
  • Loading branch information
MathCancer authored May 4, 2022
2 parents c085f90 + 77f6c40 commit 5608e8d
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 24 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/test-macosx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ on:
pull_request:

jobs:
build:
build_virus_macrophage:

runs-on: macos-latest
runs-on: macos-11

steps:
- uses: actions/checkout@v2
Expand All @@ -23,13 +23,23 @@ jobs:
- name: Run Virus Macrophage cell lines project
run: |
./virus-sample
build_physiboss_cell_lines:

runs-on: macos-11

steps:
- uses: actions/checkout@v2

- name: Install dependencies
run : brew install gcc@11

- name: Build PhysiBoSS cell lines project
run: |
make reset
make physiboss-cell-lines-sample
make clean
make PHYSICELL_CPP=g++-10
make PHYSICELL_CPP=g++-11
- name: Run PhysiBoSS cell lines project
run: |
Expand Down
9 changes: 9 additions & 0 deletions addons/PhysiBoSS/src/maboss_intracellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ MaBoSSIntracellular::MaBoSSIntracellular(MaBoSSIntracellular* copy)
discrete_time = copy->discrete_time;
time_tick = copy->time_tick;
scaling = copy->scaling;
time_stochasticity = copy->time_stochasticity;
initial_values = copy->initial_values;
mutations = copy->mutations;
parameters = copy->parameters;
Expand All @@ -35,6 +36,7 @@ MaBoSSIntracellular::MaBoSSIntracellular(MaBoSSIntracellular* copy)
maboss.set_update_time_step(copy->time_step);
maboss.set_discrete_time(copy->discrete_time, copy->time_tick);
maboss.set_scaling(copy->scaling);
maboss.set_time_stochasticity(copy->time_stochasticity);
maboss.restart_node_values();
//maboss.set_state(copy->maboss.get_maboss_state());
//std::cout << get_state();
Expand Down Expand Up @@ -124,6 +126,13 @@ void MaBoSSIntracellular::initialize_intracellular_from_pugixml(pugi::xml_node&
scaling = PhysiCell::xml_get_my_double_value( node_scaling );
maboss.set_scaling(scaling);
}

pugi::xml_node node_time_stochasticity = node.child( "time_stochasticity" );
if( node_time_stochasticity )
{
time_stochasticity = PhysiCell::xml_get_my_double_value( node_time_stochasticity );
maboss.set_time_stochasticity(time_stochasticity);
}
}

MaBoSSIntracellular* getMaBoSSModel(PhysiCell::Phenotype& phenotype) {
Expand Down
5 changes: 3 additions & 2 deletions addons/PhysiBoSS/src/maboss_intracellular.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "../../../modules/PhysiCell_pugixml.h"
#include "maboss_network.h"

static std::string PhysiBoSS_Version = "2.0.0";
static std::string PhysiBoSS_Version = "2.1.0";

class MaBoSSIntracellular : public PhysiCell::Intracellular {
private:
Expand All @@ -24,7 +24,8 @@ class MaBoSSIntracellular : public PhysiCell::Intracellular {
bool discrete_time = false;
double time_tick = 0.5;
double scaling = 1.0;

double time_stochasticity = 0.0;

std::map<std::string, double> initial_values;
std::map<std::string, double> mutations;
std::map<std::string, double> parameters;
Expand Down
37 changes: 26 additions & 11 deletions addons/PhysiBoSS/src/maboss_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@ void MaBoSSNetwork::init_maboss( std::string networkFile, std::string configFile
if (this->engine != NULL) {
delete this->engine;
}
// Initialize MaBoSS Objects for a model
this->network = new Network();
this->network->parse(networkFile.c_str());

this->config = new RunConfig();
this->config->parse(this->network, configFile.c_str());

try{
// Initialize MaBoSS Objects for a model
this->network = new Network();
this->network->parse(networkFile.c_str());

IStateGroup::checkAndComplete(this->network);
this->config = new RunConfig();
this->config->parse(this->network, configFile.c_str());

engine = new StochasticSimulationEngine(this->network, this->config, PhysiCell::UniformInt());
IStateGroup::checkAndComplete(this->network);

engine = new StochasticSimulationEngine(this->network, this->config, PhysiCell::UniformInt());

} catch (BNException e) {
std::cerr << "MaBoSS ERROR : " << e.getMessage() << std::endl;
exit(1);
}
this->update_time_step = this->config->getMaxTime();

// Building map of nodes for fast later access
Expand All @@ -47,7 +53,12 @@ void MaBoSSNetwork::init_maboss( std::string networkFile, std::string configFile
void MaBoSSNetwork::mutate(std::map<std::string, double> mutations)
{
for (auto mutation : mutations) {
nodesByName[mutation.first]->mutate(mutation.second);
if (nodesByName.find(mutation.first) != nodesByName.end())
nodesByName[mutation.first]->mutate(mutation.second);
else{
std::cerr << "Mutation set for unknown node : can't find node " << mutation.first << std::endl;
exit(1);
}
}
}

Expand Down Expand Up @@ -77,9 +88,13 @@ void MaBoSSNetwork::restart_node_values()
this->network->initStates(state, engine->random_generator);

for (auto initial_value : initial_values) {
state.setNodeState(nodesByName[initial_value.first], PhysiCell::UniformRandom() < initial_value.second);
if (nodesByName.find(initial_value.first) != nodesByName.end()) {
state.setNodeState(nodesByName[initial_value.first], PhysiCell::UniformRandom() < initial_value.second);
} else {
std::cerr << "Initial value set for unknown node : can't find node " << initial_value.first << std::endl;
exit(1);
}
}

this->set_time_to_update();
}

Expand Down
8 changes: 7 additions & 1 deletion addons/PhysiBoSS/src/maboss_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ class MaBoSSNetwork
/** \brief Real time to update, after applying noise */
double time_to_update;

/** \brief Scaling coefficient for time */
double scaling = 1.0;

/** \brief Noise coefficient for time to update */
double time_stochasticity = 0;

/** \brief Initial value probabilities, by node */
std::map< std::string, double > initial_values;

Expand All @@ -46,7 +50,7 @@ class MaBoSSNetwork
std::map< std::string, Node*> nodesByName;
std::map< std::string, const Symbol*> parametersByName;

inline void set_time_to_update(){this->time_to_update = this->get_update_time_step();}
inline void set_time_to_update(){this->time_to_update = ( 1 + (PhysiCell::UniformRandom()*2-1)*time_stochasticity ) * this->get_update_time_step();}


public:
Expand Down Expand Up @@ -130,6 +134,8 @@ class MaBoSSNetwork

inline void set_scaling(double scaling) { this->scaling = scaling; }

inline void set_time_stochasticity(double t_stochasticity) { this->time_stochasticity = t_stochasticity; }

/**
* \brief Print current state of all the nodes of the network
* \param node_values Boolean vector mapping a boolean network
Expand Down
5 changes: 3 additions & 2 deletions beta/setup_libmaboss.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@

if os_type.lower() == 'darwin':
mb_file = "libMaBoSS-osx64.tar.gz"
elif os_type.lower().startswith("win"):
elif os_type.lower().startswith("win") or os_type.lower().startswith("msys_nt") or os_type.lower().startswith("mingw64_nt"):
mb_file = "libMaBoSS-win64.tar.gz"
elif os_type.lower().startswith("linux"):
mb_file = "libMaBoSS-linux64.tar.gz"
else:
print("Your operating system seems to be unsupported. Please submit a ticket at https://sourceforge.net/p/physicell/tickets/ ")
sys.exit(1)

url = "http://maboss.curie.fr/pub/" + mb_file
url = "https://github.com/sysbio-curie/MaBoSS-env-2.0/releases/download/v2.4.1/" + mb_file

fname = mb_file

Expand Down Expand Up @@ -83,6 +83,7 @@ def download_cb(blocknum, blocksize, totalsize):
tar = tarfile.open(mb_file)
tar.extractall()
tar.close()
os.remove(mb_file)
except:
print('error untarring the file')
exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ PhysiCell_settings.o: ./modules/PhysiCell_settings.cpp

# user-defined PhysiCell modules

Compile_MaBoSS: MaBoSS
cd ./addons/PhysiBoSS/MaBoSS-env-2.0/engine/src;make install_alib;make clean; cd ../../../../..

MaBoSS:
ifeq ($(OS), Windows_NT)
python beta/setup_libmaboss.py
Expand Down Expand Up @@ -209,7 +212,7 @@ reset:
MaBoSS-clean:
rm -fr addons/PhysiBoSS/MaBoSS-env-2.0

clean: MaBoSS-clean
clean:
rm -f *.o
rm -f $(PROGRAM_NAME)*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@
<phenotype>
<cycle code="2" name="live">
<!-- using higher than normal significant digits to match divisions in default code -->
<transition_rates units="1/min">
<phase_transition_rates units="1/min">
<rate start_index="0" end_index="0" fixed_duration="true">0.0</rate>
</transition_rates>
</phase_transition_rates>
</cycle>

<death>
Expand Down

0 comments on commit 5608e8d

Please sign in to comment.