Skip to content
Snippets Groups Projects
Commit ad4915a7 authored by Blaise Li's avatar Blaise Li
Browse files

Formatting.

parent 925f3c5e
No related branches found
No related merge requests found
Pipeline #10495 passed
......@@ -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 displays 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
--------
we 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*
We ran a blast with the following 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
use a reader like below ::
Use a reader, as follows::
>>> 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 beginning 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. then the cursor is placed at the right place
when we encounter a new sequence. Then the cursor is placed at the right place
for the next sequence.
The third version is an iterator and use generator.
generators are functions which keep a state between to calls.
generators does not use return to return a value but the keyword yield.
Thus this implementation retrun sequence by sequence without to play with the cursor.
Generators are functions which keep a state between to calls.
Generators do not use return to return a value but the keyword yield.
Thus this implementation return 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.
for instance which is a very convenient way to use it: ::
For instance which is a very convenient way to use it::
for seq in fasta_iter('my_fast_file.fasta'):
print seq
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment