Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bioseq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armin Sobhani
bioseq
Commits
37ef59a2
Commit
37ef59a2
authored
7 years ago
by
Armin Sobhani
Browse files
Options
Downloads
Patches
Plain Diff
update fasta_format::do_scan() to read sequence portion of fasta file
parent
4e1f1720
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/boost/bioseq/io_formats/fasta.hpp
+26
-1
26 additions, 1 deletion
include/boost/bioseq/io_formats/fasta.hpp
test/test_io_fasta.cpp
+10
-1
10 additions, 1 deletion
test/test_io_fasta.cpp
with
36 additions
and
2 deletions
include/boost/bioseq/io_formats/fasta.hpp
+
26
−
1
View file @
37ef59a2
...
...
@@ -10,6 +10,8 @@
#ifndef BOOST_BIOSEQ_IO_FORMATS_FASTA_HPP
#define BOOST_BIOSEQ_IO_FORMATS_FASTA_HPP
#include
<iostream>
namespace
boost
{
namespace
bioseq
{
...
...
@@ -35,8 +37,31 @@ private:
virtual
void
do_scan
(
std
::
basic_istream
<
CharT
,
Traits
>&
in
,
SeqT
&
s
)
{
auto
c
=
in
.
peek
();
if
(
c
!=
'>'
)
{
in
.
setstate
(
std
::
ios
::
failbit
);
return
;
}
std
::
basic_string
<
CharT
,
Traits
>
line
;
line
.
reserve
(
71
);
std
::
getline
(
in
,
line
);
std
::
list
<
std
::
basic_string
<
CharT
,
Traits
>>
lines
;
c
=
in
.
peek
();
while
(
c
!=
'>'
&&
std
::
getline
(
in
,
line
))
{
lines
.
push_back
(
std
::
move
(
line
));
c
=
in
.
peek
();
}
std
::
cout
<<
"Number of lines: "
<<
lines
.
size
()
<<
std
::
endl
;
for
(
auto
line
:
lines
)
s
.
insert
(
s
.
end
(),
line
.
begin
(),
line
.
end
());
std
::
cout
<<
"Sequence Size: "
<<
s
.
size
()
<<
std
::
endl
;
// s.insert(0, "ACGT");
s
.
insert
(
s
.
begin
(),
'A'
);
//
s.insert(s.begin(), 'A');
}
};
...
...
This diff is collapsed.
Click to expand it.
test/test_io_fasta.cpp
+
10
−
1
View file @
37ef59a2
...
...
@@ -26,16 +26,19 @@
namespace
bioseq
=
boost
::
bioseq
;
// preparing str_seq type
template
<
class
CharT
,
class
AllocatorT
>
using
bs_string
=
std
::
basic_string
<
CharT
,
std
::
char_traits
<
CharT
>
,
AllocatorT
>
;
typedef
bioseq
::
sequence_host
<
char
,
std
::
allocator
,
bs_string
>
str_seq
;
typedef
bioseq
::
ioformat
<
char
,
std
::
char_traits
<
char
>
,
str_seq
,
bioseq
::
fasta_format
>
frmt1
;
template
<
>
struct
bioseq
::
io_format_traits
<
str_seq
>
{
typedef
frmt1
type
;
};
// preparing vec_seq type
typedef
bioseq
::
sequence_host
<
char
,
std
::
allocator
,
std
::
vector
>
vec_seq
;
typedef
bioseq
::
ioformat
<
char
,
std
::
char_traits
<
char
>
,
vec_seq
,
bioseq
::
fasta_format
>
frmt2
;
template
<
>
struct
bioseq
::
io_format_traits
<
vec_seq
>
{
typedef
frmt2
type
;
};
// adding sequence types to the test list
typedef
boost
::
mpl
::
list
<
vec_seq
,
str_seq
>
seq_types
;
BOOST_AUTO_TEST_CASE_TEMPLATE
(
read_single_fasta
,
T
,
seq_types
)
...
...
@@ -44,7 +47,13 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(read_single_fasta, T, seq_types)
T
mt
;
in
>>
mt
;
BOOST_CHECK_EQUAL
(
mt
[
0
],
'A'
);
BOOST_CHECK_EQUAL
(
mt
[
0
],
'G'
);
BOOST_CHECK_EQUAL
(
mt
[
1
],
'A'
);
BOOST_CHECK_EQUAL
(
mt
[
69
],
'G'
);
BOOST_CHECK_EQUAL
(
mt
[
139
],
'C'
);
BOOST_CHECK_EQUAL
(
mt
[
16566
],
'A'
);
BOOST_CHECK_EQUAL
(
mt
[
16567
],
'T'
);
BOOST_CHECK_EQUAL
(
mt
[
16568
],
'G'
);
// BOOST_CHECK( mt == "ACGT" );
...
...
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