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
ef3842e6
Verified
Commit
ef3842e6
authored
6 years ago
by
Bertrand NÉRON
Browse files
Options
Downloads
Patches
Plain Diff
remove python2 specific code
parent
7e0b58e6
No related branches found
No related tags found
No related merge requests found
Pipeline
#10138
passed
6 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/Collection_Data_Types.rst
+15
-18
15 additions, 18 deletions
source/Collection_Data_Types.rst
with
15 additions
and
18 deletions
source/Collection_Data_Types.rst
+
15
−
18
View file @
ef3842e6
...
...
@@ -110,19 +110,16 @@ wihout using python shell, what is the results of the following statements:
x[3] = -4 # what is the value of x now ?
y = sum(x)/len(x) #what is the value of y ? why ?
y = 0
y = 0.5
.. warning::
because sum(x) is an integer, len(x) is also an integer so in python2.x the result is an integer,
all the digits after the periods are discarded.
In python3 we will obtain the expected result (see :ref:``)
Exercise
--------
In python2 the result is ::
y = 0
How to compute safely the average of a list? ::
because sum(x) is an integer, len(x) is also an integer so in python2.x the result is an integer,
all the digits after the periods are discarded.
float(sum(l)) / float(len(l))
Exercise
--------
...
...
@@ -206,9 +203,9 @@ first implementation:
second implementation:
""""""""""""""""""""""
Mathematically speaking the generation of all codons can be the cartesi
ens
product
Mathematically speaking the generation of all codons can be the cartesi
an
product
between 3 vectors 'acgt'.
In python there is a function to do that in ``itertools module``: `https://docs.python.org/
2
/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>`_
.. literalinclude:: _static/code/codons_itertools.py
...
...
@@ -274,7 +271,7 @@ So we can use the specifycity of set ::
Exercise
--------
We need to compute the occurence of all kmers of a given leng
h
t present in a sequence.
We need to compute the occur
r
ence of all kmers of a given lengt
h
present in a sequence.
Below we propose 2 algorithms.
...
...
@@ -378,8 +375,8 @@ bonus:
Print the kmers by ordered by occurences.
| see `https://docs.python.org/
2
/library/stdtypes.html#mutable-sequence-types <sort>`_
| see `https://docs.python.org/
2
/library/operator.html#operator.itemgetter <operator.itemgetter>`_
| 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>`_
.. literalinclude:: _static/code/kmer_2.py
...
...
@@ -475,7 +472,7 @@ Exercise
let the following enzymes collection: ::
import collections
RestrictEnzyme = collections.namedtuple("RestrictEnzyme", "name
comment
sequence
cut
end")
RestrictEnzyme = collections.namedtuple("RestrictEnzyme",
(
"name
", "
comment
", "
sequence
", "cut", "
end")
)
ecor1 = RestrictEnzyme("EcoRI", "Ecoli restriction enzime I", "gaattc", 1, "sticky")
ecor5 = RestrictEnzyme("EcoRV", "Ecoli restriction enzime V", "gatatc", 3, "blunt")
...
...
@@ -504,7 +501,7 @@ and the 2 dna fragments: ::
#. Write a function *seq_one_line* which take a multi lines sequence and return a sequence in one line.
#. Write a function *enz_filter* which take a sequence and a list of enzymes and return a new list containing
the enzymes which
ar
e a binding site in the sequence
the enzymes which
hav
e a binding site in the sequence
#. use the functions above to compute the enzymes which cut the dna_1
apply the same functions to compute the enzymes which cut the dna_2
compute the difference between the enzymes which cut the dna_1 and enzymes which cut the dna_2
...
...
@@ -532,7 +529,7 @@ with this algorithm we find if an enzyme cut the dna but we cannot find all cuts
for enz in enzymes:
print enz.name, dna_1.count(enz.sequence)
the latter algorithm display the number of occurence of each enzyme, But we cannot determine the position of every sites.
the latter algorithm display the number of occur
r
ence of each enzyme, But we cannot determine the position of every sites.
We will see how to do this later.
...
...
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