Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a6d053c6 authored by David Parsons's avatar David Parsons
Browse files

extract fn read_sequence_file

parent a25a7553
No related branches found
No related tags found
No related merge requests found
...@@ -48,6 +48,7 @@ using namespace aevol; ...@@ -48,6 +48,7 @@ using namespace aevol;
// Helper functions // Helper functions
void print_help(char* prog_path); void print_help(char* prog_path);
void interpret_cmd_line_options(int argc, char* argv[]); void interpret_cmd_line_options(int argc, char* argv[]);
std::list<std::string> read_sequence_file(const std::string& chromosome_file_name);
// Command-line option variables // Command-line option variables
static std::string param_file_name; static std::string param_file_name;
...@@ -65,27 +66,16 @@ int main(int argc, char* argv[]) { ...@@ -65,27 +66,16 @@ int main(int argc, char* argv[]) {
// Initialize the experiment manager // Initialize the experiment manager
exp_manager = new ExpManager(); exp_manager = new ExpManager();
// Initialize the simulation from the parameter file // Initialize the simulation from the parameter file (and the provided sequences if any)
std::list<std::string> chromosomes;
if (chromosome_file_name.length() != 0) { if (chromosome_file_name.length() != 0) {
std::ifstream chromosome_file(chromosome_file_name); auto chromosomes = read_sequence_file(chromosome_file_name);
if (not chromosome_file) {
Utils::ExitWithUsrMsg(std::string("failed to open source chromosome file ") + chromosome_file_name);
}
std::string chromosome;
std::getline(chromosome_file, chromosome);
if (not chromosome_file or chromosome.length() == 0) {
Utils::ExitWithUsrMsg(std::string("failed to read from chromosome file ") + chromosome_file_name);
}
chromosomes.push_back(std::move(chromosome));
std::cout << "Loading chromosome from text file " << chromosome_file_name << " (" << chromosomes.front().length() std::cout << "Loading chromosome from text file " << chromosome_file_name << " (" << chromosomes.front().length()
<< " base pairs)" << std::endl; << " base pairs)" << std::endl;
ParamLoader::load(param_values, exp_manager, chromosomes, true);
}
else {
ParamLoader::load(param_values, exp_manager, true);
} }
ParamLoader::load(param_values, exp_manager, chromosomes, true);
// 8) Save the experiment // 8) Save the experiment
exp_manager->Save(true); exp_manager->Save(true);
...@@ -185,3 +175,23 @@ void interpret_cmd_line_options(int argc, char* argv[]) { ...@@ -185,3 +175,23 @@ void interpret_cmd_line_options(int argc, char* argv[]) {
param_file_name = DEFAULT_PARAM_FILE_NAME; param_file_name = DEFAULT_PARAM_FILE_NAME;
} }
} }
std::list<std::string> read_sequence_file(const std::string& chromosome_file_name) {
assert(chromosome_file_name.length() != 0);
std::list<std::string> chromosomes;
std::ifstream chromosome_file(chromosome_file_name);
if (not chromosome_file) {
Utils::ExitWithUsrMsg(std::string("failed to open source chromosome file ") + chromosome_file_name);
}
std::string chromosome;
std::getline(chromosome_file, chromosome);
if (not chromosome_file or chromosome.length() == 0) {
Utils::ExitWithUsrMsg(std::string("failed to read from chromosome file ") + chromosome_file_name);
}
chromosomes.push_back(std::move(chromosome));
return chromosomes;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment