Skip to content

Commit c3e43a5

Browse files
authored
Merge pull request #9 from drbergman/my-physicell-rules-upgrade
rules upgrade
2 parents e266474 + 5f415b3 commit c3e43a5

File tree

103 files changed

+6773
-542
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+6773
-542
lines changed

Makefile

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ BioFVM_utilities.o BioFVM_basic_agent.o BioFVM_MultiCellDS.o BioFVM_agent_contai
4242

4343
PhysiCell_core_OBJECTS := PhysiCell_phenotype.o PhysiCell_cell_container.o PhysiCell_standard_models.o \
4444
PhysiCell_cell.o PhysiCell_custom.o PhysiCell_utilities.o PhysiCell_constants.o PhysiCell_basic_signaling.o \
45-
PhysiCell_signal_behavior.o PhysiCell_rules.o
45+
PhysiCell_signal_behavior.o PhysiCell_rules_extended.o
4646

4747
PhysiCell_module_OBJECTS := PhysiCell_SVG.o PhysiCell_pathology.o PhysiCell_MultiCellDS.o PhysiCell_various_outputs.o \
4848
PhysiCell_pugixml.o PhysiCell_settings.o PhysiCell_geometry.o
@@ -71,11 +71,11 @@ name:
7171

7272
# sample projects
7373
list-projects:
74-
@echo "Sample projects: template template-ecm template-xml-rules biorobots-sample cancer-biorobots-sample cancer-immune-sample"
74+
@echo "Sample projects: template biorobots-sample cancer-biorobots-sample cancer-immune-sample"
7575
@echo " celltypes3-sample heterogeneity-sample pred-prey-farmer virus-macrophage-sample"
7676
@echo " worm-sample interaction-sample mechano-sample rules-sample physimess-sample custom-division-sample"
7777
@echo " asymmetric-division-sample immune-function-sample episode-sample"
78-
@echo " template-xml-rules template-ecm"
78+
@echo " template-ecm template-xml-rules template-xml-rules-extended"
7979
@echo ""
8080
@echo "Sample intracellular projects: template_BM ode-energy-sample physiboss-cell-lines-sample"
8181
@echo " cancer-metabolism-sample physiboss-tutorial physiboss-tutorial-invasion"
@@ -90,6 +90,15 @@ template:
9090
cp ./sample_projects/template/Makefile .
9191
cp -r ./sample_projects/template/config/* ./config
9292

93+
template-ecm:
94+
cp -r ./sample_projects/template-ecm/custom_modules/* ./custom_modules/
95+
touch main.cpp && cp main.cpp main-backup.cpp
96+
cp ./sample_projects/template-ecm/main.cpp ./main.cpp
97+
cp Makefile Makefile-backup
98+
cp ./sample_projects/template-ecm/Makefile .
99+
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
100+
cp -r ./sample_projects/template-ecm/config/* ./config/
101+
93102
template-xml-rules:
94103
cp -r ./sample_projects/template_xml_rules/custom_modules/* ./custom_modules/
95104
touch main.cpp && cp main.cpp main-backup.cpp
@@ -99,15 +108,15 @@ template-xml-rules:
99108
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
100109
cp -r ./sample_projects/template_xml_rules/config/* ./config/
101110

102-
template-ecm:
103-
cp -r ./sample_projects/template-ecm/custom_modules/* ./custom_modules/
111+
template-xml-rules-extended:
112+
cp -r ./sample_projects/template_xml_rules_extended/custom_modules/* ./custom_modules/
104113
touch main.cpp && cp main.cpp main-backup.cpp
105-
cp ./sample_projects/template-ecm/main.cpp ./main.cpp
114+
cp ./sample_projects/template_xml_rules_extended/main.cpp ./main.cpp
106115
cp Makefile Makefile-backup
107-
cp ./sample_projects/template-ecm/Makefile .
116+
cp ./sample_projects/template_xml_rules_extended/Makefile .
108117
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
109-
cp -r ./sample_projects/template-ecm/config/* ./config/
110-
118+
cp -r ./sample_projects/template_xml_rules_extended/config/* ./config/
119+
111120
# sample projects
112121

113122
# ---- non-intracellular projects
@@ -466,8 +475,8 @@ PhysiCell_constants.o: ./core/PhysiCell_constants.cpp
466475
PhysiCell_signal_behavior.o: ./core/PhysiCell_signal_behavior.cpp
467476
$(COMPILE_COMMAND) -c ./core/PhysiCell_signal_behavior.cpp
468477

469-
PhysiCell_rules.o: ./core/PhysiCell_rules.cpp
470-
$(COMPILE_COMMAND) -c ./core/PhysiCell_rules.cpp
478+
PhysiCell_rules_extended.o: ./core/PhysiCell_rules_extended.cpp
479+
$(COMPILE_COMMAND) -c ./core/PhysiCell_rules_extended.cpp
471480

472481
# BioFVM core components (needed by PhysiCell)
473482

core/PhysiCell.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,6 @@ static std::string PhysiCell_DOI = "10.1371/journal.pcbi.1005991";
8686
#include "PhysiCell_utilities.h"
8787
#include "PhysiCell_constants.h"
8888

89-
#include "PhysiCell_rules.h"
89+
#include "PhysiCell_rules_extended.h"
9090

9191
#endif

core/PhysiCell_cell.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ void Cell::advance_bundled_phenotype_functions( double dt_ )
326326
// New March 2023 in Version 1.12.0
327327
// call the rules-based code to update the phenotype
328328
if( PhysiCell_settings.rules_enabled )
329-
{ apply_ruleset( this ); }
329+
{ apply_behavior_ruleset( this ); }
330330
if( get_single_signal(this,"necrotic") > 0.5 )
331331
{
332332
double rupture = this->phenotype.volume.rupture_volume;

core/PhysiCell_cell.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
#include "../modules/PhysiCell_settings.h"
7979

8080
#include "./PhysiCell_standard_models.h"
81-
#include "./PhysiCell_rules.h"
81+
#include "./PhysiCell_rules_extended.h"
8282

8383
#ifdef ADDON_PHYSIECM
8484
#include "../addons/PhysiECM/cell_ecm_interactions.h"

core/PhysiCell_rules.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ void Hypothesis_Rule::sync_to_cell_definition( Cell_Definition* pCD )
406406
return;
407407
}
408408

409+
409410
void Hypothesis_Rule::sync_to_cell_definition( std::string cell_name )
410411
{ return sync_to_cell_definition( find_cell_definition(cell_name) ); }
411412

@@ -722,6 +723,7 @@ Hypothesis_Ruleset::Hypothesis_Ruleset()
722723
return;
723724
}
724725

726+
725727
void Hypothesis_Ruleset::display( std::ostream& os )
726728
{
727729
os << "Behavioral rules for cell type " << cell_type << ":" << std::endl;
@@ -742,7 +744,6 @@ void Hypothesis_Ruleset::detailed_display( std::ostream& os )
742744
return;
743745
}
744746

745-
746747
void Hypothesis_Ruleset::sync_to_cell_definition( Cell_Definition* pCD )
747748
{
748749
pCell_Definition = pCD;
@@ -800,13 +801,18 @@ Hypothesis_Rule* Hypothesis_Ruleset::add_behavior( std::string behavior , double
800801
return pHR;
801802
}
802803

804+
805+
806+
803807
Hypothesis_Rule* Hypothesis_Ruleset::add_behavior( std::string behavior )
804808
{
805809
double min_behavior = 9e99; // Min behaviour high value
806810
double max_behavior = -9e99; // Max behaviour low value
807811
return Hypothesis_Ruleset::add_behavior( behavior, min_behavior, max_behavior );
808812
}
809813

814+
815+
810816
void Hypothesis_Ruleset::sync_to_cell_definition( std::string cell_name )
811817
{ return sync_to_cell_definition( find_cell_definition(cell_name) ); }
812818

@@ -1911,7 +1917,7 @@ void process_signals(pugi::xml_node response_node, std::string cell_type, std::s
19111917
std::vector<std::string> signals_set;
19121918

19131919
std::vector<std::string> input;
1914-
input.resize(8);
1920+
input.resize(9);
19151921
input[0] = cell_type;
19161922
input[2] = response;
19171923
input[3] = behavior;
@@ -1937,6 +1943,7 @@ void process_signals(pugi::xml_node response_node, std::string cell_type, std::s
19371943
input[5] = signal_node.child_value("half_max");
19381944
input[6] = signal_node.child_value("hill_power");
19391945
input[7] = signal_node.child_value("applies_to_dead");
1946+
input[8] = signal_node.attribute("type").value();
19401947
process_signal(input);
19411948

19421949
signal_node = signal_node.next_sibling("signal");
@@ -1985,6 +1992,7 @@ void process_signal(std::vector<std::string> input)
19851992
std::string signal = input[1];
19861993
std::string response = input[2];
19871994
std::string behavior = input[3];
1995+
std::string signal_type = input[8];
19881996

19891997
// numeric portions of the rule
19901998
// double min_value = std::atof( input[2].c_str() );
@@ -1995,16 +2003,22 @@ void process_signal(std::vector<std::string> input)
19952003
// hmm from here
19962004
// double max_value = std::atof( input[4].c_str() );
19972005

1998-
double half_max = std::atof( input[5].c_str() );
1999-
double hill_power = std::atof( input[6].c_str() );
2000-
bool use_for_dead = (bool) std::atof( input[7].c_str() );
2001-
20022006
std::cout << "Adding rule for " << cell_type << " cells:\n\t";
20032007
std::cout << temp << std::endl;
20042008

20052009
// add_rule(cell_type,signal,behavior,response);
2010+
bool use_for_dead = (bool)std::atof(input[7].c_str());
20062011
add_rule(cell_type,signal,behavior,response,use_for_dead);
2007-
set_hypothesis_parameters(cell_type,signal,behavior,half_max,hill_power);
2012+
switch (0)
2013+
{
2014+
case 0: // Hill type
2015+
{
2016+
double half_max = std::atof(input[5].c_str());
2017+
double hill_power = std::atof(input[6].c_str());
2018+
set_hypothesis_parameters(cell_type, signal, behavior, half_max, hill_power);
2019+
}
2020+
}
2021+
20082022

20092023
return;
20102024
}
@@ -2066,7 +2080,6 @@ void parse_rules_from_pugixml( void )
20662080
return;
20672081
}
20682082

2069-
20702083
void parse_rules_from_file(std::string path_to_file, std::string format, std::string protocol, double version) // see PhysiCell_rules.h for default values of format, protocol, and version
20712084
{
20722085
std::cout << "\tProcessing ruleset in " << path_to_file << " ... " << std::endl;
@@ -2082,7 +2095,7 @@ void parse_rules_from_file(std::string path_to_file, std::string format, std::st
20822095
}
20832096
if (version == -1.0)
20842097
{
2085-
version = 2.0; // default version (at least for CSVs)
2098+
version = 3.0; // default version (at least for CSVs)
20862099
}
20872100

20882101
if (format == "CSV" || format == "csv")
@@ -2096,21 +2109,20 @@ void parse_rules_from_file(std::string path_to_file, std::string format, std::st
20962109
}
20972110

20982111
parse_csv_rules_v3(path_to_file); // parse all rules in a CSV file
2099-
PhysiCell_settings.rules_enabled = true;
21002112
}
21012113
else if (format == "XML" || format == "xml")
21022114
{
21032115
std::cout << "\tFormat: XML" << std::endl;
21042116
parse_xml_rules(path_to_file);
2105-
PhysiCell_settings.rules_enabled = true;
21062117
}
21072118
else
21082119
{
2109-
std::cout << "\tError: Unknown format (" << format << ") for ruleset " << path_to_file << ". Skipping!" << std::endl;
2120+
std::cerr << "\tError: Unknown format (" << format << ") for ruleset " << path_to_file << ". Quitting!" << std::endl;
21102121
exit(-1);
21112122
}
21122123
PhysiCell_settings.rules_enabled = true;
21132124
copy_file_to_output( path_to_file );
2125+
return;
21142126
}
21152127

21162128
void parse_rules_from_parameters_v0( void )
@@ -2161,7 +2173,6 @@ int Parameters<T>::find_index( std::string search_name )
21612173
}
21622174
21632175
*/
2164-
21652176
void stream_annotated_English_rules( std::ostream& os )
21662177
{
21672178
os << "Cell Hypothesis Rules" << std::endl << std::endl;

0 commit comments

Comments
 (0)