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
ad4915a7
Commit
ad4915a7
authored
6 years ago
by
Blaise Li
Browse files
Options
Downloads
Patches
Plain Diff
Formatting.
parent
925f3c5e
No related branches found
Branches containing commit
Tags
v2.0.0-a.1
No related merge requests found
Pipeline
#10495
passed
6 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/Input_Output.rst
+12
-9
12 additions, 9 deletions
source/Input_Output.rst
with
12 additions
and
9 deletions
source/Input_Output.rst
+
12
−
9
View file @
ad4915a7
...
...
@@ -14,7 +14,7 @@ Exercise
--------
Write a function that takes the path of file as parameter
and display it's content on the screen.
and display
s
it's content on the screen.
We expect the same behavior as the shell ``cat`` command.
...
...
@@ -87,7 +87,7 @@ Write sequences with 80 aa/line
Exercise
--------
w
e ran a blast with the folowing command *blastall -p blastp -d uniprot_sprot -i query_seq.fasta -e 1e-05 -m 8 -o blast2.txt*
W
e ran a blast with the fol
l
owing command *blastall -p blastp -d uniprot_sprot -i query_seq.fasta -e 1e-05 -m 8 -o blast2.txt*
-m 8 is the tabular output. So each fields is separate to the following by a '\t'
...
...
@@ -120,7 +120,7 @@ Hint:
^^^^^
Use the module csv in python https://docs.python.org/3/library/csv.html#module-csv
u
se a reader
like be
low
::
U
se a reader
, as fol
low
s
::
>>> reader = csv.reader(input, quotechar='"')
...
...
@@ -140,6 +140,7 @@ use the file :download:`abcd.fasta <_static/data/abcd.fasta>` to test your code.
solution 1
^^^^^^^^^^
.. literalinclude:: _static/code/multiple_fasta_reader.py
:linenos:
:language: python
...
...
@@ -148,6 +149,7 @@ solution 1
solution 2
^^^^^^^^^^
.. literalinclude:: _static/code/multiple_fasta_reader2.py
:linenos:
:language: python
...
...
@@ -156,6 +158,7 @@ solution 2
solution 3
^^^^^^^^^^
.. literalinclude:: _static/code/fasta_iterator.py
:linenos:
:language: python
...
...
@@ -168,19 +171,19 @@ if the file is huge (>G0) it can be a problem.
The third version allow to red sequences one by one.
To do that we have to open the file outside the reader function
The fasta format is very convenient for human but not for parser.
The end of a sequence is indicated by the end of file or the begining of a new one.
The end of a sequence is indicated by the end of file or the begin
n
ing of a new one.
So with this version we have play with the cursor to place the cursor backward
when we encouter a new sequence.
t
hen the cursor is placed at the right place
when we encou
n
ter a new sequence.
T
hen the cursor is placed at the right place
for the next sequence.
The third version is an iterator and use generator.
g
enerators are functions which keep a state between to calls.
g
enerators do
es
not use return to return a value but the keyword yield.
Thus this implementation ret
r
un sequence by sequence without to play with the cursor.
G
enerators are functions which keep a state between to calls.
G
enerators do not use return to return a value but the keyword yield.
Thus this implementation retu
r
n sequence by sequence without to play with the cursor.
You can call this function and put in in a loop or call next.
Work with the sequence and pass to the next sequence on so on.
f
or instance which is a very convenient way to use it:
:
:
F
or instance which is a very convenient way to use it::
for seq in fasta_iter('my_fast_file.fasta'):
print seq
...
...
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