Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hub-courses
python_one_week_4_biologists_solutions
Commits
71ed45c0
Commit
71ed45c0
authored
Feb 19, 2016
by
Bertrand Néron
Browse files
mv solution of matrix in dive into function as in course
parent
555491c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
source/Dive_into_Functions.rst
View file @
71ed45c0
...
...
@@ -492,4 +492,36 @@ This function have to take the phase as parameter
:download:`translate.py <_static/code/translate.py>` .
\ No newline at end of file
.. _matrix_exercise:
Exercise
--------
Write a program that calculates the similarity of 2 RNA sequences.
* To compute the similarity you need to parse a file containing the :download:`similarity matrix <_static/data/similarity_matrix>`.
**Hint**: use the module containing the functions that handle a matrix from previous chapter.
put this matrix.py file in a directory named "my_python_lib" in your home or Desktop
and import it in your current program (the similarity script must be placed elsewhere).
* The similarity of the 2 sequences is the sum of base similarities.
so you have to compare the first base of two sequences and use the matrix to get the similarity
from the similarity table, on so on for all bases then sum these similarities.
First implementation
.. literalinclude:: _static/code/matrix.py
:linenos:
:language: python
:download:`matrix.py <_static/code/matrix.py>` .
Second implementation
.. literalinclude:: _static/code/matrix2.py
:linenos:
:language: python
:download:`matrix2.py <_static/code/matrix2.py>` .
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment