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

Typos.

parent 7bace4bf
No related branches found
No related tags found
No related merge requests found
Pipeline #83388 passed
...@@ -103,7 +103,7 @@ Exercise ...@@ -103,7 +103,7 @@ Exercise
.. note:: .. note::
``sum`` is a function that returns the sum of all the elements of a list. ``sum`` is a function that returns the sum of all the elements of a list.
Wihout using the Python shell, tell what are the effects of the following statements:: Without using the Python shell, tell what are the effects of the following statements::
x = [1, 2, 3, 4] x = [1, 2, 3, 4]
...@@ -175,7 +175,7 @@ Draw the representation in memory of the ``x`` and ``y`` variables when the foll ...@@ -175,7 +175,7 @@ Draw the representation in memory of the ``x`` and ``y`` variables when the foll
Exercise Exercise
-------- --------
from the list l = [1, 2, 3, 4, 5, 6, 7, 8, 9] generate 2 lists l1 containing all odd values, and l2 all even values.:: From the list l = [1, 2, 3, 4, 5, 6, 7, 8, 9] generate 2 lists l1 containing all odd values, and l2 all even values.::
l = [1, 2, 3, 4, 5, 6, 7, 8, 9] l = [1, 2, 3, 4, 5, 6, 7, 8, 9]
l1 = l[::2] l1 = l[::2]
...@@ -224,7 +224,7 @@ first implementation: ...@@ -224,7 +224,7 @@ first implementation:
second implementation: second implementation:
"""""""""""""""""""""" """"""""""""""""""""""
Mathematically speaking the generation of all codons can be the cartesian product Mathematically speaking the generation of all codons can be the Cartesian product
between 3 vectors 'acgt'. between 3 vectors 'acgt'.
In python there is a function to do that in ``itertools module``: `https://docs.python.org/3/library/itertools.html#itertools.product <product>`_ In python there is a function to do that in ``itertools module``: `https://docs.python.org/3/library/itertools.html#itertools.product <product>`_
...@@ -361,7 +361,7 @@ In the first algorithm. ...@@ -361,7 +361,7 @@ In the first algorithm.
| So the algorithm is in O(sequence length) | So the algorithm is in O(sequence length)
Compute the 6 mers occurences of the sequence above, and print each 6mer and it's occurence one per line. Compute the 6 mers occurrences of the sequence above, and print each 6mer and it's occurrence one per line.
.. literalinclude:: _static/code/kmer.py .. literalinclude:: _static/code/kmer.py
:linenos: :linenos:
...@@ -394,7 +394,7 @@ Compute the 6 mers occurences of the sequence above, and print each 6mer and it' ...@@ -394,7 +394,7 @@ Compute the 6 mers occurences of the sequence above, and print each 6mer and it'
bonus: bonus:
"""""" """"""
Print the kmers by ordered by occurences. Print the kmers by ordered by occurrences.
| see `https://docs.python.org/3/library/stdtypes.html#mutable-sequence-types <sort>`_ | see `https://docs.python.org/3/library/stdtypes.html#mutable-sequence-types <sort>`_
| see `https://docs.python.org/3/library/operator.html#operator.itemgetter <operator.itemgetter>`_ | see `https://docs.python.org/3/library/operator.html#operator.itemgetter <operator.itemgetter>`_
...@@ -463,12 +463,12 @@ other solution ...@@ -463,12 +463,12 @@ other solution
"""""""""""""" """"""""""""""
python provide an interesting method for our problem. python provide an interesting method for our problem.
The ``translate`` method work on string and need a parameter which is a object The ``translate`` method works on a string and needs a parameter which is an object
that can do the correspondance between characters in old string a the new one. that can do the correspondence between characters in the old string and the new one.
``maketrans`` is a function in module ``string`` that allow us to build this object. ``maketrans`` is a function in module ``string`` that allow us to build this object.
``maketrans`` take 2 arguments, two strings, the first string contains the characters ``maketrans`` take 2 arguments, two strings, the first string contains the characters
to change, the second string the corresponding characters in the new string. to change, the second string the corresponding characters in the new string.
Thus the two strings **must** have the same length. The correspondance between Thus the two strings **must** have the same length. The correspondence between
the characters to change and their new values is made in function of their position. the characters to change and their new values is made in function of their position.
the first character of the first string will be replaced by the first character of the second string, the first character of the first string will be replaced by the first character of the second string,
the second character of the first string will be replaced by the second character of the second string, on so on. the second character of the first string will be replaced by the second character of the second string, on so on.
...@@ -555,13 +555,13 @@ with this algorithm we find if an enzyme cut the dna but we cannot find all cuts ...@@ -555,13 +555,13 @@ with this algorithm we find if an enzyme cut the dna but we cannot find all cuts
for enz in enzymes: for enz in enzymes:
print enz.name, dna_1.count(enz.sequence) print enz.name, dna_1.count(enz.sequence)
the latter algorithm display the number of occurrence of each enzyme, But we cannot determine the position of every sites. The latter algorithm displays the number of occurrence of each enzyme, But we cannot determine the position of every sites.
We will see how to do this later. We will see how to do this later.
Bonus Bonus
^^^^^ ^^^^^
There is another kind of tuple which allow to access to itmes by index or name. There is another kind of tuple which allows to access to items by index or name.
This data collection is called NamedTuple. The NamedTuple are not accessible directly they are in `collections` package, This data collection is called NamedTuple. The NamedTuple are not accessible directly they are in `collections` package,
so we have to import it before to use it. so we have to import it before to use it.
We also have to define which name correspond to which item:: We also have to define which name correspond to which item::
...@@ -596,7 +596,7 @@ given the following dict : :: ...@@ -596,7 +596,7 @@ given the following dict : ::
d = {1 : 'a', 2 : 'b', 3 : 'c' , 4 : 'd'} d = {1 : 'a', 2 : 'b', 3 : 'c' , 4 : 'd'}
We want obtain a new dict with the keys and the values inverted so we will obtain: :: We want to obtain a new dict with the keys and the values inverted so we will obtain: ::
inverted_d {'a': 1, 'c': 3, 'b': 2, 'd': 4} inverted_d {'a': 1, 'c': 3, 'b': 2, 'd': 4}
......
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