Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python_one_week_4_biologists_solutions
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
hub-courses
python_one_week_4_biologists_solutions
Commits
b47d896d
Commit
b47d896d
authored
9 years ago
by
Bertrand Néron
Browse files
Options
Downloads
Patches
Plain Diff
fix space to be pep8 compliant
parent
c5f48a35
No related branches found
Branches containing commit
Tags
v0.2.64
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/_static/code/multiple_fasta_reader.py
+4
-5
4 additions, 5 deletions
source/_static/code/multiple_fasta_reader.py
with
4 additions
and
5 deletions
source/_static/code/multiple_fasta_reader.py
+
4
−
5
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
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