Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom division #273

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions core/PhysiCell_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ Cell::Cell()

is_movable = true;
is_out_of_domain = false;
generation = 0;
parentID = -1; // overridden in create_cell() and divide()
displacement.resize(3,0.0); // state?

assign_orientation();
Expand Down Expand Up @@ -563,6 +565,13 @@ Cell* Cell::divide( )

Cell* child = create_cell(functions.instantiate_cell);
child->copy_data( this );
// lineage tracking
generation = generation + 1; // this (parent) cell has its generation incremented
child->generation = generation; // daughter cell has the same generation
// child->generation = generation + 1;
// child->parentID = parentID;
parentID = ID;
child->parentID = ID;
child->copy_function_pointers(this);
child->parameters = parameters;

Expand Down Expand Up @@ -649,6 +658,9 @@ Cell* Cell::divide( )
child->state.damage = 0.0;
child->state.total_attack_time = 0.0;

if( this->functions.cell_division_function )
{ this->functions.cell_division_function( this, child); }

return child;
}

Expand Down Expand Up @@ -1066,6 +1078,7 @@ Cell* create_cell( Cell* (*custom_instantiate)())
} else {
pNew = standard_instantiate_cell();
}
pNew->parentID = pNew->ID;

(*all_cells).push_back( pNew );
pNew->index=(*all_cells).size()-1;
Expand Down Expand Up @@ -1306,6 +1319,7 @@ void Cell::ingest_cell( Cell* pCell_to_eat )
pCell_to_eat->functions.custom_cell_rule = NULL;
pCell_to_eat->functions.update_phenotype = NULL;
pCell_to_eat->functions.contact_function = NULL;
pCell_to_eat->functions.cell_division_function = NULL;

// should set volume fuction to NULL too!
pCell_to_eat->functions.volume_update_function = NULL;
Expand Down Expand Up @@ -1531,6 +1545,7 @@ void Cell::fuse_cell( Cell* pCell_to_fuse )
pCell_to_fuse->functions.custom_cell_rule = NULL;
pCell_to_fuse->functions.update_phenotype = NULL;
pCell_to_fuse->functions.contact_function = NULL;
pCell_to_fuse->functions.cell_division_function = NULL;
pCell_to_fuse->functions.volume_update_function = NULL;

// remove all adhesions
Expand Down Expand Up @@ -1570,6 +1585,7 @@ void Cell::lyse_cell( void )
functions.custom_cell_rule = NULL;
functions.update_phenotype = NULL;
functions.contact_function = NULL;
functions.cell_division_function = NULL;

// remove all adhesions

Expand Down Expand Up @@ -1660,6 +1676,14 @@ void display_ptr_as_bool( void (*ptr)(Cell*,Phenotype&,Cell*,Phenotype&,double),
return;
}

void display_ptr_as_bool( void (*ptr)(Cell*,Cell*), std::ostream& os )
{
if( ptr )
{ os << "true"; return; }
os << "false";
return;
}

void display_cell_definitions( std::ostream& os )
{
for( int n=0; n < cell_definitions_by_index.size() ; n++ )
Expand Down Expand Up @@ -1743,6 +1767,8 @@ void display_cell_definitions( std::ostream& os )
os << std::endl;
os << "\t\t contact function: "; display_ptr_as_bool( pCF->contact_function , std::cout );
os << std::endl;
os << "\t\t cell division function: "; display_ptr_as_bool( pCF->cell_division_function , std::cout );
os << std::endl;

// summarize motility

Expand Down
3 changes: 3 additions & 0 deletions core/PhysiCell_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ class Cell : public Basic_Agent

bool is_out_of_domain;
bool is_movable;

int generation; // for lineage tracking
int parentID; // for lineage tracking

void flag_for_division( void ); // done
void flag_for_removal( void ); // done
Expand Down
2 changes: 2 additions & 0 deletions core/PhysiCell_phenotype.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ class Cell_Functions

void (*contact_function)(Cell* pMyself, Phenotype& my_phenotype,
Cell* pOther, Phenotype& other_phenotype, double dt );

void (*cell_division_function)(Cell* pCell1, Cell* pCell2 );

/* prototyping / beta in 1.5.0 */
/*
Expand Down
29 changes: 29 additions & 0 deletions modules/PhysiCell_MultiCellDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,29 @@ void add_PhysiCell_cells_to_open_xml_pugi_v2( pugi::xml_document& xml_dom, std::
data_start_indices.push_back( index );
cell_data_size += size;
index += size;

// generation
name = "generation";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when merging with dev-paul, will need (or maybe just want?) to update these with Paul's condensed version of this code there

size = 1;
units="none";
data_names.push_back( name );
data_units.push_back(units);
data_sizes.push_back( size );
data_start_indices.push_back( index );
cell_data_size += size;
index += size;

// parentID
name = "parentID";
size = 1;
units="none";
data_names.push_back( name );
data_units.push_back(units);
data_sizes.push_back( size );
data_start_indices.push_back( index );
cell_data_size += size;
index += size;

// <label index="1" size="3">position</label>
name = "position";
size = 3;
Expand Down Expand Up @@ -1754,6 +1777,12 @@ void add_PhysiCell_cells_to_open_xml_pugi_v2( pugi::xml_document& xml_dom, std::
// name = "ID";
dTemp = (double) pCell->ID;
std::fwrite( &( dTemp ) , sizeof(double) , 1 , fp );
// name = "generation";
dTemp = (double) pCell->generation;
std::fwrite( &( dTemp ) , sizeof(double) , 1 , fp );
// name = "parentID";
dTemp = (double) pCell->parentID;
std::fwrite( &( dTemp ) , sizeof(double) , 1 , fp );
// name = "position"; NOTE very different syntax for writing vectors!
std::fwrite( pCell->position.data() , sizeof(double) , 3 , fp );
// name = "total_volume";
Expand Down
11 changes: 10 additions & 1 deletion sample_projects/Makefile-default
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ name:
list-projects:
@echo "Sample projects: template biorobots-sample cancer-biorobots-sample cancer-immune-sample"
@echo " celltypes3-sample heterogeneity-sample pred-prey-farmer virus-macrophage-sample"
@echo " worm-sample interaction-sample mechano-sample rules-sample physimess-sample"
@echo " worm-sample interaction-sample mechano-sample rules-sample physimess-sample custom-division-sample"
@echo ""
@echo "Sample intracellular projects: template_BM ode-energy-sample physiboss-cell-lines-sample"
@echo " cancer-metabolism-sample physiboss-tutorial physiboss-tutorial-invasion"
Expand Down Expand Up @@ -198,6 +198,15 @@ physimess-sample:
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
cp -r ./sample_projects/physimess/config/* ./config/

custom-division-sample:
cp ./sample_projects/custom_division/custom_modules/* ./custom_modules/
touch main.cpp && cp main.cpp main-backup.cpp
cp ./sample_projects/custom_division/main.cpp ./main.cpp
cp Makefile Makefile-backup
cp ./sample_projects/custom_division/Makefile .
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
cp -r ./sample_projects/custom_division/config/* ./config/

# ---- intracellular projects
ode-energy-sample:
cp ./sample_projects_intracellular/ode/ode_energy/custom_modules/* ./custom_modules/
Expand Down
Loading
Loading