Skip to content

Commit

Permalink
Merge pull request MathCancer#276 from drbergman/copy-inputs-to-outpu…
Browse files Browse the repository at this point in the history
…t-folder

copy cell ic file and substrate ic file to output
  • Loading branch information
MathCancer authored Oct 11, 2024
2 parents 7cc61b1 + d190cd7 commit 8c400bb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 36 deletions.
25 changes: 0 additions & 25 deletions core/PhysiCell_rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1940,31 +1940,6 @@ void parse_rules_from_pugixml( void )
node = node.next_sibling( "ruleset");
}
return;

exit(0);

// enabled?
if( node.attribute("enabled").as_bool() == false )
{ return; }

// get filename

std::string folder = xml_get_string_value( node, "folder" );
std::string filename = xml_get_string_value( node, "filename" );
std::string input_filename = folder + "/" + filename;

std::string filetype = node.attribute("type").value() ;

// what kind?
if( filetype == "csv" || filetype == "CSV" )
{
std::cout << "Loading rules from CSV file " << input_filename << " ... " << std::endl;
// load_cells_csv( input_filename );
parse_csv_rules_v0( input_filename );
return;
}

return;
}

void parse_rules_from_parameters_v0( void )
Expand Down
20 changes: 20 additions & 0 deletions core/PhysiCell_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,24 @@ int choose_event( std::vector<double>& probabilities )
return probabilities.size();
}

void copy_file_to_output(std::string filename)
{
std::cout << "Copying " << filename << " to output folder." << std::endl;
// copy the file to the output folder
std::string basename = filename;
size_t found = basename.find_last_of("/"); // find the end of the path
if (found != std::string::npos)
{
basename = basename.substr(found + 1);
}

std::string output_filename = PhysiCell_settings.folder + "/" + basename;

// copy filename to output_filename
char copy_command[1024];
sprintf(copy_command, "cp %s %s", filename.c_str(), output_filename.c_str());
std::cout << "Copy command: " << copy_command << std::endl;
system(copy_command);
}

};
1 change: 1 addition & 0 deletions core/PhysiCell_utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ void add_software_citation( std::string name , std::string version, std::string

int choose_event( std::vector<double>& probabilities );

void copy_file_to_output( std::string filename );
};

#endif
21 changes: 10 additions & 11 deletions modules/PhysiCell_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,31 +373,30 @@ bool load_cells_from_pugixml( pugi::xml_node root )
std::cout << "Loading cells from CSV file " << input_filename << " ... " << std::endl;
load_cells_csv( input_filename );
system("sleep 1");
return true;
}
if( filetype == "matlab" || filetype == "mat" || filetype == "MAT" )
else if( filetype == "matlab" || filetype == "mat" || filetype == "MAT" )
{
std::cout << "Error: Load cell positions from matlab not yet supported. Try CSV." << std::endl;
exit(-1);
std::cout << "Loading cells from matlab file " << input_filename << " ... " << std::endl;
return false;
}
if( filetype == "scene" )
else if( filetype == "scene" )
{
std::cout << "Error: load cell positions from scene not yet supported. Try CSV." << std::endl;
exit(-1);
std::cout << "Loading cells from scene file " << input_filename << " ... " << std::endl;
return false;
}
if( filetype == "physicell" || filetype == "PhysiCell" )
else if( filetype == "physicell" || filetype == "PhysiCell" )
{
std::cout << "Error: load cell positions from PhysiCell snapshot not yet supported. Try CSV." << std::endl;
exit(-1);
std::cout << "Loading cells from PhysiCell file " << input_filename << " ... " << std::endl;
return false;
}
else
{
std::cout << "Error: Unknown cell position filetype " << filetype << " in XML. Try CSV." << std::endl;
exit(-1);
}

return false;
copy_file_to_output(input_filename);
return true;
}

bool load_cells_from_pugixml( void )
Expand Down
2 changes: 2 additions & 0 deletions modules/PhysiCell_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,8 @@ bool setup_microenvironment_from_XML( pugi::xml_node root_node )
{
default_microenvironment_options.initial_condition_file_type = node.attribute("type").as_string();
default_microenvironment_options.initial_condition_file = xml_get_string_value(node, "filename");

copy_file_to_output(default_microenvironment_options.initial_condition_file);
}
}

Expand Down

0 comments on commit 8c400bb

Please sign in to comment.