Commit 2ddd4ad0 authored by Arnau Montagud's avatar Arnau Montagud
Browse files

Merge branch 'development'

parents f4003e08 ad9fbe09
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
math/~$derlying assumptions.docx
.DS_Store
PhysiCell/.DS_Store
......@@ -24,6 +24,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;
......@@ -36,6 +37,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();
......@@ -45,6 +47,8 @@ MaBoSSIntracellular::MaBoSSIntracellular(MaBoSSIntracellular* copy)
MaBoSSIntracellular::MaBoSSIntracellular(std::vector<char>& buffer, int& len_buffer, int& position)
{
intracellular_type = "maboss";
// double len_str = 0;
int temp_int;
double temp_double;
......@@ -70,6 +74,7 @@ MaBoSSIntracellular::MaBoSSIntracellular(std::vector<char>& buffer, int& len_buf
MPI_Unpack(&buffer[0], len_buffer, &position, &(this->time_tick), 1, MPI_DOUBLE, MPI_COMM_WORLD);
MPI_Unpack(&buffer[0], len_buffer, &position, &(this->scaling), 1, MPI_DOUBLE, MPI_COMM_WORLD);
MPI_Unpack(&buffer[0], len_buffer, &position, &(this->time_stochasticity), 1, MPI_DOUBLE, MPI_COMM_WORLD);
this->maboss.init_maboss(this->bnd_filename, this->cfg_filename);
......@@ -124,9 +129,6 @@ MaBoSSIntracellular::MaBoSSIntracellular(std::vector<char>& buffer, int& len_buf
this->maboss.state.setNodeState(t_nodes[i], t_node == 1?true:false);
}
/* The following is an extra change that Vincent has done */
/* From here */
MPI_Unpack(&buffer[0], len_buffer, &position, &temp_int, 1, MPI_INT, MPI_COMM_WORLD);
SymbolTable* symbol_table = this->maboss.getNetwork()->getSymbolTable();
......@@ -137,8 +139,6 @@ MaBoSSIntracellular::MaBoSSIntracellular(std::vector<char>& buffer, int& len_buf
symbol_table->setSymbolValue(symbol_table->getSymbol(symbol_table->getSymbolsNames()[i]), t_parameter);
}
/* To here */
}
void MaBoSSIntracellular::pack(std::vector<char>& buffer, int& len_buffer, int& position)
......@@ -183,6 +183,10 @@ void MaBoSSIntracellular::pack(std::vector<char>& buffer, int& len_buffer, int&
buffer.resize(len_buffer);
MPI_Pack(&(this->scaling), 1, MPI_DOUBLE, &buffer[0], len_buffer, &position, MPI_COMM_WORLD);
len_buffer = position + sizeof(double);
buffer.resize(len_buffer);
MPI_Pack(&(this->time_stochasticity), 1, MPI_DOUBLE, &buffer[0], len_buffer, &position, MPI_COMM_WORLD);
// Mutations
len_buffer = position + sizeof(int);
buffer.resize(len_buffer);
......@@ -258,6 +262,9 @@ void MaBoSSIntracellular::pack(std::vector<char>& buffer, int& len_buffer, int&
MPI_Pack(&(temp_double), 1, MPI_DOUBLE, &buffer[0], len_buffer, &position, MPI_COMM_WORLD);
// this->maboss.set_time_to_update(time_to_update);
// This is the part which might only need to be sent :
// The present state of the model
// This will be improved by sending vectors of unsigned long long
std::vector<Node*> t_nodes = this->maboss.getNetwork()->getNodes();
len_buffer = position + sizeof(int);
buffer.resize(len_buffer);
......@@ -287,8 +294,7 @@ void MaBoSSIntracellular::pack(std::vector<char>& buffer, int& len_buffer, int&
temp_double = symbol_table->getSymbolValue(symbol_table->getSymbol(symbol_table->getSymbolsNames()[i]));
MPI_Pack(&(temp_double), 1, MPI_DOUBLE, &buffer[0], len_buffer, &position, MPI_COMM_WORLD);
}
}
void MaBoSSIntracellular::initialize_intracellular_from_pugixml(pugi::xml_node& node)
......@@ -374,6 +380,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) {
......
......@@ -24,6 +24,7 @@ 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;
......
#ifndef _MaBoSS_Net_h_
#define _MaBoSS_Net_h_
#include "StochasticSimulationEngine.h"
#include "BooleanNetwork.h"
#include "RunConfig.h"
#include "utils.h"
#include "../../../core/PhysiCell_utilities.h"
/**
* \class MaBoSSNetwork
* \brief Interface with MaBoSS software
*
* \details The MaBOSS network class contains network configs to handel the initialization and run the simulations given an input.
*
* \date 06/08/2020
* \author Gaelle Letort, Institut Curie
* \author Gerard Pradas, BSC-CNS
*/
class MaBoSSNetwork
{
private:
/** \brief MaBoSS instances: network */
Network* network;
/** \brief MaBoSS instances: configurations */
RunConfig* config;
StochasticSimulationEngine* engine;
//NetworkState state; <--- Gaurav Saxena is making this public again so that we cast test code
NetworkState output_mask;
/** \brief Time step between each MaBoSS simulation */
double update_time_step = 12.0;
/** \brief Real time to update, after applying noise */
double time_to_update;
double scaling = 1.0;
/** \brief Initial value probabilities, by node */
std::map< std::string, double > initial_values;
/** \brief Mutations to apply to the network */
std::map< std::string, double > mutations;
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();}
public:
NetworkState state;
/** Constructor */
MaBoSSNetwork() {
network = NULL;
config = NULL;
engine = NULL;
this->nodesByName.clear();
}
/** Desctructor */
~MaBoSSNetwork() {
delete this->engine;
this->engine = NULL;
delete this->network;
this->network = NULL;
delete this->config;
this->config = NULL;
}
/**
* \brief Class initializer
* \param networkFile,configFile MaBoSS configutation files
*/
void init_maboss( std::string networkFile, std::string configFile);
bool has_init() const { return network != NULL && config != NULL; }
void mutate(std::map<std::string, double> mutations);
void set_initial_values(std::map<std::string, double> initial_values)
{ this->initial_values = initial_values; }
void set_parameters(std::map<std::string, double> parameters);
double get_parameter_value(std::string name);
void set_parameter_value(std::string name, double value);
//The next 2 functions possibly aid in packing/unpacking
Network* getNetwork() { return network; }
NetworkState getState() { return state; }
/**
* \brief Restart a vector of bools, to the init values of the network
* \param node_values Vector of bools to write an initial state of the network
*/
void restart_node_values();
/**
* \brief Run the current network
* \param node_values Vector mapping a boolean network to run a simulation
*/
void run_simulation();
/** \brief Return node of given name current value
*
* Return -1 if node doesn't exit \n
* Return 0 if node is 0 \n
* Return 1 if node is 1 */
// int get_maboss_node_index( std::string name );
bool has_node( std::string name );
void set_node_value(std::string name, bool value);
bool get_node_value(std::string name);
std::string get_state();
/** \brief Return update time value */
inline double get_update_time_step(){ return this->update_time_step; }
/**
* \brief Set update time step
* \param time_step Time step between each MaBoSS simulation
*/
inline void set_update_time_step(double time_step) { this->update_time_step = time_step;}
/** \brief Get time to update*/
inline double get_time_to_update() {return this->time_to_update;}
inline void set_time_to_update(double time) { this->time_to_update = time; }
/** \brief Change simulation mode */
inline void set_discrete_time(bool discrete_time, double time_tick) {
this->engine->setDiscreteTime(discrete_time); this->engine->setTimeTick(time_tick);
}
inline void set_scaling(double scaling) { this->scaling = scaling; }
/**
* \brief Print current state of all the nodes of the network
* \param node_values Boolean vector mapping a boolean network
*/
void print_nodes();
void set_state(NetworkState _state) { state = NetworkState(_state.getState()); }
NetworkState get_maboss_state() { return state;}
};
#endif
#ifndef _MaBoSS_Net_h_
#define _MaBoSS_Net_h_
#include "StochasticSimulationEngine.h"
#include "BooleanNetwork.h"
#include "RunConfig.h"
#include "utils.h"
#include "../../../core/PhysiCell_utilities.h"
/**
* \class MaBoSSNetwork
* \brief Interface with MaBoSS software
*
* \details The MaBOSS network class contains network configs to handel the initialization and run the simulations given an input.
*
* \date 06/08/2020
* \author Gaelle Letort, Institut Curie
* \author Gerard Pradas, BSC-CNS
*/
class MaBoSSNetwork
{
private:
/** \brief MaBoSS instances: network */
Network* network;
/** \brief MaBoSS instances: configurations */
RunConfig* config;
StochasticSimulationEngine* engine;
//NetworkState state; <--- Gaurav Saxena is making this public again so that we cast test code
NetworkState output_mask;
/** \brief Time step between each MaBoSS simulation */
double update_time_step = 12.0;
/** \brief Real time to update, after applying noise */
double time_to_update;
double time_stochasticity = 0;
double scaling = 1.0;
/** \brief Initial value probabilities, by node */
std::map< std::string, double > initial_values;
/** \brief Mutations to apply to the network */
std::map< std::string, double > mutations;
std::map< std::string, Node*> nodesByName;
std::map< std::string, const Symbol*> parametersByName;
inline void set_time_to_update(){this->time_to_update = PhysiCell::LogNormalRandom( this->get_update_time_step() , time_stochasticity );}
public:
NetworkState state;
/** Constructor */
MaBoSSNetwork() {
network = NULL;
config = NULL;
engine = NULL;
this->nodesByName.clear();
}
/** Desctructor */
~MaBoSSNetwork() {
delete this->engine;
this->engine = NULL;
delete this->network;
this->network = NULL;
delete this->config;
this->config = NULL;
}
/**
* \brief Class initializer
* \param networkFile,configFile MaBoSS configutation files
*/
void init_maboss( std::string networkFile, std::string configFile);
bool has_init() const { return network != NULL && config != NULL; }
void mutate(std::map<std::string, double> mutations);
void set_initial_values(std::map<std::string, double> initial_values)
{ this->initial_values = initial_values; }
void set_parameters(std::map<std::string, double> parameters);
double get_parameter_value(std::string name);
void set_parameter_value(std::string name, double value);
//The next 2 functions possibly aid in packing/unpacking
Network* getNetwork() { return network; }
NetworkState getState() { return state; }
/**
* \brief Restart a vector of bools, to the init values of the network
* \param node_values Vector of bools to write an initial state of the network
*/
void restart_node_values();
/**
* \brief Run the current network
* \param node_values Vector mapping a boolean network to run a simulation
*/
void run_simulation();
/** \brief Return node of given name current value
*
* Return -1 if node doesn't exit \n
* Return 0 if node is 0 \n
* Return 1 if node is 1 */
// int get_maboss_node_index( std::string name );
bool has_node( std::string name );
void set_node_value(std::string name, bool value);
bool get_node_value(std::string name);
std::string get_state();
/** \brief Return update time value */
inline double get_update_time_step(){ return this->update_time_step; }
/**
* \brief Set update time step
* \param time_step Time step between each MaBoSS simulation
*/
inline void set_update_time_step(double time_step) { this->update_time_step = time_step;}
/** \brief Get time to update*/
inline double get_time_to_update() {return this->time_to_update;}
inline void set_time_to_update(double time) { this->time_to_update = ( 1 + (PhysiCell::UniformRandom()*2-1)*time_stochasticity ) * time; }
/** \brief Change simulation mode */
inline void set_discrete_time(bool discrete_time, double time_tick) {
this->engine->setDiscreteTime(discrete_time); this->engine->setTimeTick(time_tick);
}
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
*/
void print_nodes();
void set_state(NetworkState _state) { state = NetworkState(_state.getState()); }
NetworkState get_maboss_state() { return state;}
};
#endif
This diff is collapsed.
/*
###############################################################################
# If you use PhysiCell in your project, please cite PhysiCell and the version #
# number, such as below: #
# #
# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. #
# #
# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, #
# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- #
# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 #
# DOI: 10.1371/journal.pcbi.1005991 #
# #
# See VERSION.txt or call get_PhysiCell_version() to get the current version #
# x.y.z. Call display_citations() to get detailed information on all cite-#
# able software used in your PhysiCell application. #
# #
# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM #
# as below: #
# #
# We implemented and solved the model using PhysiCell (Version x.y.z) [1], #
# with BioFVM [2] to solve the transport equations. #
# #
# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, #
# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- #
# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 #
# DOI: 10.1371/journal.pcbi.1005991 #
# #
# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- #
# llelized diffusive transport solver for 3-D biological simulations, #
# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 #
# #
###############################################################################
# #
# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) #
# #
# Copyright (c) 2015-2018, Paul Macklin and the PhysiCell Project #
# All rights reserved. #
# #
# Redistribution and use in source and binary forms, with or without #
# modification, are permitted provided that the following conditions are met: #
# #
# 1. Redistributions of source code must retain the above copyright notice, #
# this list of conditions and the following disclaimer. #
# #
# 2. Redistributions in binary form must reproduce the above copyright #
# notice, this list of conditions and the following disclaimer in the #
# documentation and/or other materials provided with the distribution. #
# #
# 3. Neither the name of the copyright holder nor the names of its #
# contributors may be used to endorse or promote products derived from this #
# software without specific prior written permission. #
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" #
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE #
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE #
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE #
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR #
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF #
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS #
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN #
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) #
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE #
# POSSIBILITY OF SUCH DAMAGE. #
# #
###############################################################################
*/
#ifndef __PhysiCell_utilities_h__
#define __PhysiCell_utilities_h__
#include <iostream>
#include <ctime>
#include <cmath>
#include <string>
#include <vector>
#include <random>
#include <chrono>
namespace PhysiCell{
long SeedRandom( long input );
long SeedRandom( void );
double UniformRandom( void );
int UniformInt( void );
double NormalRandom( double mean, double standard_deviation );
std::vector<double> UniformOnUnitSphere( void );
std::vector<double> UniformOnUnitCircle( void );
std::vector<double> LegacyRandomOnUnitSphere( void );
double dist_squared(std::vector<double> p1, std::vector<double> p2);
double dist(std::vector<double> p1, std::vector<double> p2);
std::string get_PhysiCell_version( void );
void get_PhysiCell_version( std::string& pString );
void display_citations( std::ostream& os );
void display_citations( void );
void add_software_citation( std::string name , std::string version, std::string DOI, std::string URL );
int choose_event( std::vector<double>& probabilities );
};
#endif
/*
###############################################################################
# If you use PhysiCell in your project, please cite PhysiCell and the version #
# number, such as below: #
# #
# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. #
# #
# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, #
# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- #
# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 #
# DOI: 10.1371/journal.pcbi.1005991 #
# #
# See VERSION.txt or call get_PhysiCell_version() to get the current version #
# x.y.z. Call display_citations() to get detailed information on all cite-#
# able software used in your PhysiCell application. #
# #
# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM #
# as below: #
# #
# We implemented and solved the model using PhysiCell (Version x.y.z) [1], #
# with BioFVM [2] to solve the transport equations. #
# #
# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, #
# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- #
# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 #
# DOI: 10.1371/journal.pcbi.1005991 #
# #
# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- #
# llelized diffusive transport solver for 3-D biological simulations, #
# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 #
# #
###############################################################################
# #
# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) #
# #
# Copyright (c) 2015-2018, Paul Macklin and the PhysiCell Project #
# All rights reserved. #
# #
# Redistribution and use in source and binary forms, with or without #
# modification, are permitted provided that the following conditions are met: #
# #
# 1. Redistributions of source code must retain the above copyright notice, #
# this list of conditions and the following disclaimer. #
# #
# 2. Redistributions in binary form must reproduce the above copyright #
# notice, this list of conditions and the following disclaimer in the #
# documentation and/or other materials provided with the distribution. #
# #
# 3. Neither the name of the copyright holder nor the names of its #
# contributors may be used to endorse or promote products derived from this #
# software without specific prior written permission. #
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" #
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE #
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE #
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE #
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR #
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF #
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS #
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN #
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) #
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE #
# POSSIBILITY OF SUCH DAMAGE. #