Mentions légales du service

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

read sequence from ifstream into string

parent ef4b1cc8
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,9 @@ const char* DEFAULT_PARAM_FILE_NAME = "param.in";
#include <getopt.h>
#include <fstream>
#include <sstream>
#include <string>
#include "legacy/ExpManager.h"
#include "aevol_version.h"
......@@ -70,35 +72,28 @@ int main(int argc, char* argv[]) {
// Initialize the experiment manager
exp_manager = new ExpManager();
// Initialize the simulation from the parameter file
int32_t lchromosome = -1;
char* chromosome = nullptr;
std::string chromosome;
if (chromosome_file_name != nullptr) {
const int max_input_chrom_size = 1000000;
char raw_chromosome[max_input_chrom_size];
FILE* chromosome_file = fopen(chromosome_file_name, "r");
if (chromosome_file == nullptr) {
std::ifstream chromosome_file(chromosome_file_name);
if (not chromosome_file) {
Utils::ExitWithUsrMsg(std::string("failed to open source chromosome file ") + chromosome_file_name);
}
if (fgets(raw_chromosome, max_input_chrom_size, chromosome_file) == nullptr)
{
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);
}
lchromosome = strlen(raw_chromosome) - 1;
chromosome = new char[lchromosome + 1];
strncpy(chromosome, raw_chromosome, lchromosome + 1);
printf("Loading chromosome from text file %s (%" PRId32 " base pairs) \n",
chromosome_file_name, lchromosome);
std::cout << "Loading chromosome from text file " << chromosome_file_name << " (" << chromosome.length()
<< " base pairs)" << std::endl;
delete [] chromosome_file_name;
fclose(chromosome_file);
}
if(param_file_name != nullptr) {
if (lchromosome > -1) {
ParamLoader::load(param_values, exp_manager, true, chromosome, lchromosome);
delete chromosome;
if (chromosome.length() != 0) {
ParamLoader::load(param_values, exp_manager, true, chromosome.c_str(), chromosome.length());
} else {
ParamLoader::load(param_values, exp_manager, true);
}
......
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