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
91d2239b
Commit
91d2239b
authored
14 years ago
by
Marco Biasini
Browse files
Options
Downloads
Patches
Plain Diff
robustify clustalw importer
parent
244a541b
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/clustal_io_handler.cc
+18
-6
18 additions, 6 deletions
modules/io/src/seq/clustal_io_handler.cc
with
18 additions
and
6 deletions
modules/io/src/seq/clustal_io_handler.cc
+
18
−
6
View file @
91d2239b
...
...
@@ -70,8 +70,8 @@ bool ClustalIOHandler::ProvidesExport(const boost::filesystem::path& loc,
void
ClustalIOHandler
::
Import
(
seq
::
SequenceList
&
aln
,
std
::
istream
&
instream
)
{
static
const
char
*
whitespace
=
"
\t
"
;
static
const
char
*
whitespace
=
"
\t
\r\n
"
;
int
line_num
=
0
;
String
line
;
typedef
std
::
map
<
String
,
seq
::
SequenceHandle
>
SeqMap
;
std
::
vector
<
seq
::
SequenceHandle
>
order
;
...
...
@@ -80,10 +80,20 @@ void ClustalIOHandler::Import(seq::SequenceList& aln,
throw
IOException
(
"Can't import CLUSTAL alignment. Inexisting file "
"or invalid stream."
);
}
if
(
!
std
::
getline
(
instream
,
line
)
||
line
.
find
(
"CLUSTAL"
)
!=
0
)
{
// skip empty lines
while
(
std
::
getline
(
instream
,
line
))
{
line_num
+=
1
;
size_t
pos
=
line
.
find_first_not_of
(
whitespace
);
if
(
pos
!=
String
::
npos
)
{
break
;
}
}
if
(
line
.
find
(
"CLUSTAL"
)
!=
0
)
{
throw
IOException
(
"bad CLUSTAL file. First line must contain CLUSTAL"
);
}
while
(
std
::
getline
(
instream
,
line
))
{
line_num
+=
1
;
size_t
pos
=
line
.
find_first_not_of
(
whitespace
);
if
(
pos
==
String
::
npos
)
{
continue
;
...
...
@@ -94,8 +104,10 @@ void ClustalIOHandler::Import(seq::SequenceList& aln,
}
size_t
seq_id_end
=
line
.
find_first_of
(
whitespace
);
if
(
seq_id_end
==
String
::
npos
)
{
throw
IOException
(
"Bad CLUSTAL file: Whitespace expected after"
" sequence name"
);
std
::
stringstream
ss
;
ss
<<
"Bad CLUSTAL file on line "
<<
line_num
<<
": Whitespace expected after sequence name"
;
throw
IOException
(
ss
.
str
());
}
String
seq_id
=
line
.
substr
(
0
,
seq_id_end
);
...
...
@@ -124,7 +136,7 @@ void ClustalIOHandler::Import(seq::SequenceList& aln,
void
ClustalIOHandler
::
Export
(
const
seq
::
ConstSequenceList
&
ent
,
std
::
ostream
&
ostream
)
const
{
throw
IOException
(
"Export of ClustalW al
n
gnments to stream is not supported"
);
throw
IOException
(
"Export of ClustalW al
i
gnments to stream is not supported"
);
}
}}
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