Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aevol-eukaryotes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LUISELLI Juliette
aevol-eukaryotes
Commits
b6dfac80
Commit
b6dfac80
authored
1 year ago
by
David Parsons
Browse files
Options
Downloads
Patches
Plain Diff
read sequence from ifstream into string
parent
ef4b1cc8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/aevol_create.cpp
+13
-18
13 additions, 18 deletions
src/aevol_create.cpp
with
13 additions
and
18 deletions
src/aevol_create.cpp
+
13
−
18
View file @
b6dfac80
...
...
@@ -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
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment