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
a8e86006
Commit
a8e86006
authored
3 years ago
by
Blaise Li
Browse files
Options
Downloads
Patches
Plain Diff
Syncing with exercises in the main course support.
parent
cd9954e0
No related branches found
No related tags found
No related merge requests found
Pipeline
#83438
passed
3 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/Control_Flow_Statements.rst
+55
-10
55 additions, 10 deletions
source/Control_Flow_Statements.rst
with
55 additions
and
10 deletions
source/Control_Flow_Statements.rst
+
55
−
10
View file @
a8e86006
...
@@ -18,7 +18,7 @@ The Fibonacci sequence are the numbers in the following integer sequence:
...
@@ -18,7 +18,7 @@ The Fibonacci sequence are the numbers in the following integer sequence:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
By definition, the first two numbers in the Fibonacci sequence are 0 and 1,
By definition, the first two numbers in the Fibonacci sequence are 0 and 1,
and each subsequent number is the sum of the previous two.
and each subsequent number is the sum of the previous two.
The Fibonacci suite can be defined as following:
The Fibonacci suite can be defined as following:
...
@@ -26,8 +26,8 @@ The Fibonacci suite can be defined as following:
...
@@ -26,8 +26,8 @@ The Fibonacci suite can be defined as following:
|
|
| F\ :sub:`n` = F\ :sub:`n-1` + F\ :sub:`n-2`
| F\ :sub:`n` = F\ :sub:`n-1` + F\ :sub:`n-2`
Write a function
which
take an integer ``n`` as parameter
Write a function
that
take
s
an integer ``n`` as parameter
and returns a list containing the ``n`` first number of the Fibonacci sequence.
and returns a list containing the ``n`` first number
s
of the Fibonacci sequence.
.. literalinclude:: _static/code/fibonacci_iteration.py
.. literalinclude:: _static/code/fibonacci_iteration.py
...
@@ -42,18 +42,18 @@ We will see another way more elegant to implement the Fibonacci suite in :ref:`A
...
@@ -42,18 +42,18 @@ We will see another way more elegant to implement the Fibonacci suite in :ref:`A
Exercise
Exercise
--------
--------
Reimplement your own function max
(
my_max).
Reimplement your own function
``
max
`` (call it ``
my_max
``
).
This function will take a list or tuple of float or integer and
This function will take a list or tuple of float
s
or integer
s
and
return
s
the largest element
?
return the largest element
.
Write the pseudocode before
to
propos
e
an implementation.
Write the pseudocode before propos
ing
an implementation.
pseudocode
pseudocode
^^^^^^^^^^
^^^^^^^^^^
| *function my_max(l)*
| *function my_max(l)*
| *max <- first elt of l*
| *max <- first elt of l*
| *for each elt
s
of l*
| *for each elt of l*
| *if elt is > max*
| *if elt is > max*
| *max <- elt*
| *max <- elt*
| *return max*
| *return max*
...
@@ -80,6 +80,51 @@ implementation
...
@@ -80,6 +80,51 @@ implementation
58
58
Exercise
--------
We want to create a "restriction map" of two sequences.
Create the following enzymes::
ecor1 = ("EcoRI", "Ecoli restriction enzime I", "gaattc", 1, "sticky")
ecor5 = ("EcoRV", "Ecoli restriction enzime V", "gatatc", 3, "blunt")
bamh1 = ("BamHI", "type II restriction endonuclease from Bacillus amyloliquefaciens", "ggatcc", 1, "sticky")
hind3 = ("HindIII", "type II site-specific nuclease from Haemophilus influenzae", "aagctt", 1, "sticky")
taq1 = ("TaqI", "Thermus aquaticus", "tcga", 1, "sticky")
not1 = ("NotI", "Nocardia otitidis", "gcggccgc", 2, "sticky")
sau3a1 = ("Sau3aI", "Staphylococcus aureus", "gatc", 0, "sticky")
hae3 = ("HaeIII", "Haemophilus aegyptius", "ggcc", 2, "blunt")
sma1 = ("SmaI", "Serratia marcescens", "cccggg", 3, "blunt")
Then create the following two DNA fragments::
dna_1 = """tcgcgcaacgtcgcctacatctcaagattcagcgccgagatccccgggggtt
gagcgatccccgtcagttggcgtgaattcagcagcagcgcaccccgggcgtagaattccagtt
gcagataatagctgatttagttaacttggatcacagaagcttccagaccaccgtatggatccc
aacgcactgttacggatccaattcgtacgtttggggtgatttgattcccgctgcctgccagg"""
dna_2 = """gagcatgagcggaattctgcatagcgcaagaatgcggccgcttagagcgatg
ctgccctaaactctatgcagcgggcgtgaggattcagtggcttcagaattcctcccgggagaa
gctgaatagtgaaacgattgaggtgttgtggtgaaccgagtaagagcagcttaaatcggagag
aattccatttactggccagggtaagagttttggtaaatatatagtgatatctggcttg"""
* In a file <my_file.py>
#. Create a function *one_line_dna* that transforms a multi-line sequence into a single-line DNA sequence.
#. Create a collection containing all enzymes
#. Create a function that takes two parameters:
#. a sequence of DNA
#. a list of enzyme
and returns a collection containing the enzymes which cut the DNA.
Which enzymes cut:
* ``dna_1``?
* ``dna_2``?
* ``dna_1`` but not ``dna_2``?
.. _enzyme_exercise:
.. _enzyme_exercise:
Exercise
Exercise
...
@@ -87,7 +132,7 @@ Exercise
...
@@ -87,7 +132,7 @@ Exercise
| We want to establish a restriction map of a sequence.
| We want to establish a restriction map of a sequence.
| But we will do this step by step,
| But we will do this step by step,
| and reuse the enzymes used in previous
chapter
:
| and reuse the enzymes used in
the
previous
exercise
:
* Create a function that takes a sequence and an enzyme as parameters, and returns
* Create a function that takes a sequence and an enzyme as parameters, and returns
the position of the first binding site.
the position of the first binding site.
...
@@ -97,7 +142,7 @@ Exercise
...
@@ -97,7 +142,7 @@ Exercise
| *function one_enz_binding_site(dna, enzyme)*
| *function one_enz_binding_site(dna, enzyme)*
| *if enzyme binding site is substring of dna*
| *if enzyme binding site is substring of dna*
| *return
of
first position of substring in dna*
| *return first position of substring in dna*
**implementation**
**implementation**
...
...
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