Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hub-courses
python_one_week_4_biologists_solutions
Commits
b47d896d
Commit
b47d896d
authored
Feb 18, 2016
by
Bertrand Néron
Browse files
fix space to be pep8 compliant
parent
c5f48a35
Changes
1
Hide whitespace changes
Inline
Side-by-side
source/_static/code/multiple_fasta_reader.py
View file @
b47d896d
from
collections
import
namedtuple
Sequence
=
namedtuple
(
"Sequence"
,
"id comment sequence"
)
Sequence
=
namedtuple
(
"Sequence"
,
"id comment sequence"
)
def
fasta_reader
(
fasta_path
):
"""
...
...
@@ -19,19 +19,18 @@ def fasta_reader(fasta_path):
# a new sequence begin
if
id_
!=
''
:
# a sequence was already parsed so add it to the list
sequences
.
append
(
Sequence
(
id_
,
comment
,
sequence
))
sequences
.
append
(
Sequence
(
id_
,
comment
,
sequence
))
sequence
=
''
header
=
line
.
split
()
id_
=
header
[
0
]
comment
=
' '
.
join
(
header
[
1
:])
else
:
sequence
+=
line
.
strip
()
sequences
.
append
(
Sequence
(
id_
,
comment
,
sequence
))
sequences
.
append
(
Sequence
(
id_
,
comment
,
sequence
))
return
sequences
# The problem with this implementation is that we have to load all
# sequences in memory before to start to work with
# it is better to return sequence one by one
# and treat them as they are loaded.
\ No newline at end of file
# and treat them as they are loaded.
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment