Skip to content

Commit ae0c2b7

Browse files
committed
copy files with default name to output as well
- default names: - config: PhysiCell_settings.xml - rules: cell_rules.csv - ic cells: cells.csv - ic substrates: substrates.csv or substrates.mat
1 parent 0c7b54b commit ae0c2b7

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

core/PhysiCell_rules.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,8 +1934,10 @@ void parse_rules_from_pugixml( void )
19341934
if( done == false )
19351935
{ std::cout << "\tWarning: Ruleset had unknown format (" << format << "). Skipping!" << std::endl; }
19361936
else
1937-
{ copy_file_to_output( input_filename ); }
1938-
1937+
{
1938+
std::string default_basename = "cell_rules.csv";
1939+
copy_file_to_output(input_filename, default_basename);
1940+
}
19391941
}
19401942
else
19411943
{ std::cout << "\tRuleset disabled ... " << std::endl; }

core/PhysiCell_utilities.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ int choose_event( std::vector<double>& probabilities )
365365
return probabilities.size();
366366
}
367367

368-
void copy_file_to_output(std::string filename)
368+
void copy_file_to_output(const std::string &filename, const std::string &default_basename)
369369
{
370370
std::cout << "Copying " << filename << " to output folder." << std::endl;
371371
// copy the file to the output folder
@@ -381,8 +381,17 @@ void copy_file_to_output(std::string filename)
381381
// copy filename to output_filename
382382
char copy_command[1024];
383383
sprintf(copy_command, "cp %s %s", filename.c_str(), output_filename.c_str());
384-
std::cout << "Copy command: " << copy_command << std::endl;
385384
(void)system(copy_command); // make it explicit that we are ignoring the return value
385+
386+
if (default_basename.empty() || default_basename == basename) {
387+
return;
388+
}
389+
390+
// copy the file to the output folder with the default basename
391+
std::string default_output_filename = PhysiCell_settings.folder + "/" + default_basename;
392+
sprintf(copy_command, "cp %s %s", filename.c_str(), default_output_filename.c_str());
393+
(void)system(copy_command); // make it explicit that we are ignoring the return value
394+
return;
386395
}
387396

388397
};

core/PhysiCell_utilities.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void add_software_citation( std::string name , std::string version, std::string
111111

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

114-
void copy_file_to_output( std::string filename );
114+
void copy_file_to_output(const std::string &filename, const std::string &default_basename = "");
115115
};
116116

117117
#endif

modules/PhysiCell_geometry.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ bool load_cells_from_pugixml( pugi::xml_node root )
395395
exit(-1);
396396
}
397397

398-
copy_file_to_output(input_filename);
398+
std::string default_basename = "cells.csv";
399+
copy_file_to_output(input_filename, default_basename);
399400
return true;
400401
}
401402

modules/PhysiCell_settings.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ bool load_PhysiCell_config_file( std::string filename )
119119

120120
create_output_directory( PhysiCell_settings.folder );
121121

122-
copy_file_to_output( filename );
122+
std::string default_basename = "PhysiCell_settings.xml";
123+
copy_file_to_output( filename, default_basename ); // copy the settings file to the output folder
123124

124125
return true;
125126
}
@@ -963,7 +964,8 @@ bool setup_microenvironment_from_XML( pugi::xml_node root_node )
963964
default_microenvironment_options.initial_condition_file_type = node.attribute("type").as_string();
964965
default_microenvironment_options.initial_condition_file = xml_get_string_value(node, "filename");
965966

966-
copy_file_to_output(default_microenvironment_options.initial_condition_file);
967+
std::string default_basename = default_microenvironment_options.initial_condition_file_type == "matlab" ? "substrates.mat" : "substrates.csv"; // when loading the file, we check that it is one of these two types
968+
copy_file_to_output(default_microenvironment_options.initial_condition_file, default_basename);
967969
}
968970
}
969971

0 commit comments

Comments
 (0)