Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
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
schwede
openstructure
Commits
0ad7712a
Commit
0ad7712a
authored
2 years ago
by
Studer Gabriel
Browse files
Options
Downloads
Patches
Plain Diff
throw error when trying to write empty sequence in FASTA file
parent
d4ee8867
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/io/src/seq/fasta_io_handler.cc
+11
-1
11 additions, 1 deletion
modules/io/src/seq/fasta_io_handler.cc
with
11 additions
and
1 deletion
modules/io/src/seq/fasta_io_handler.cc
+
11
−
1
View file @
0ad7712a
...
@@ -46,6 +46,12 @@ void FastaIOHandler::Import(seq::SequenceList& aln,
...
@@ -46,6 +46,12 @@ void FastaIOHandler::Import(seq::SequenceList& aln,
void
FastaIOHandler
::
Export
(
const
seq
::
ConstSequenceList
&
msa
,
void
FastaIOHandler
::
Export
(
const
seq
::
ConstSequenceList
&
msa
,
const
boost
::
filesystem
::
path
&
loc
)
const
{
const
boost
::
filesystem
::
path
&
loc
)
const
{
// deliberately check for valid sequences BEFORE file is created on disk
for
(
int
i
=
0
;
i
<
msa
.
GetCount
();
++
i
)
{
if
(
msa
[
i
].
GetString
().
empty
())
{
throw
IOException
(
"Cannot write FASTA file: Sequence is empty."
);
}
}
boost
::
filesystem
::
ofstream
outfile
(
loc
);
boost
::
filesystem
::
ofstream
outfile
(
loc
);
this
->
Export
(
msa
,
outfile
);
this
->
Export
(
msa
,
outfile
);
}
}
...
@@ -111,7 +117,8 @@ void FastaIOHandler::Import(seq::SequenceList& aln,
...
@@ -111,7 +117,8 @@ void FastaIOHandler::Import(seq::SequenceList& aln,
aln
.
AddSequence
(
seq
);
aln
.
AddSequence
(
seq
);
seq_count
+=
1
;
seq_count
+=
1
;
}
catch
(
seq
::
InvalidSequence
&
e
)
{
}
catch
(
seq
::
InvalidSequence
&
e
)
{
throw
seq
::
InvalidSequence
(
"Failed for sequence with name "
+
name
+
": "
+
e
.
what
());
throw
seq
::
InvalidSequence
(
"Failed for sequence
\"
"
+
name
+
"
\"
("
+
seq_string
.
str
()
+
"): "
+
e
.
what
());
}
}
}
else
{
}
else
{
throw
IOException
(
"Bad FASTA file: Sequence is empty."
);
throw
IOException
(
"Bad FASTA file: Sequence is empty."
);
...
@@ -127,6 +134,9 @@ void FastaIOHandler::Export(const seq::ConstSequenceList& seqs,
...
@@ -127,6 +134,9 @@ void FastaIOHandler::Export(const seq::ConstSequenceList& seqs,
std
::
ostream
&
ostream
)
const
std
::
ostream
&
ostream
)
const
{
{
for
(
int
i
=
0
;
i
<
seqs
.
GetCount
();
++
i
)
{
for
(
int
i
=
0
;
i
<
seqs
.
GetCount
();
++
i
)
{
if
(
seqs
[
i
].
GetString
().
empty
())
{
throw
IOException
(
"Cannot write FASTA file: Sequence is empty."
);
}
ostream
<<
">"
<<
seqs
[
i
].
GetName
()
<<
std
::
endl
;
ostream
<<
">"
<<
seqs
[
i
].
GetName
()
<<
std
::
endl
;
ostream
<<
seqs
[
i
].
GetString
()
<<
std
::
endl
;
ostream
<<
seqs
[
i
].
GetString
()
<<
std
::
endl
;
}
}
...
...
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