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

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
...@@ -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 takes 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 numbers 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 floats or integers and
returns the largest element? return the largest element.
Write the pseudocode before to propose an implementation. Write the pseudocode before proposing an implementation.
pseudocode pseudocode
^^^^^^^^^^ ^^^^^^^^^^
| *function my_max(l)* | *function my_max(l)*
| *max <- first elt of l* | *max <- first elt of l*
| *for each elts 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**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment