Skip to content
Snippets Groups Projects
Verified Commit 6c4218f1 authored by Bertrand  NÉRON's avatar Bertrand NÉRON
Browse files

Merge branch 'master' of gitlab.pasteur.fr:hub-courses/python_one_week_4_biologists_solutions

parents edb0e1b7 0a0f10a1
No related branches found
No related tags found
No related merge requests found
Pipeline #10309 passed
...@@ -424,7 +424,7 @@ pseudocode: ...@@ -424,7 +424,7 @@ pseudocode:
| *concatenate nt complement to rev_comp* | *concatenate nt complement to rev_comp*
| *return rev_comp* | *return rev_comp*
.. literalinclude:: _static/code/rev_comp2.py .. literalinclude:: _static/code/rev_comp.py
:linenos: :linenos:
:language: python :language: python
......
...@@ -5,13 +5,9 @@ def rev_comp(seq): ...@@ -5,13 +5,9 @@ def rev_comp(seq):
return the reverse complement of seq return the reverse complement of seq
the case is respect but if the sequence mix upper and lower case the function will failed the case is respect but if the sequence mix upper and lower case the function will failed
""" """
upper = seq.isupper()
reverse = seq[::-1] reverse = seq[::-1]
direct = 'acgt' direct = 'acgtATCG'
comp = 'tgca' comp = 'tgcaTGCA'
if upper: table = string.maketrans(direct, comp)
table = string.maketrans(direct.upper(), comp.upper())
else:
table = string.maketrans(direct, comp)
rev_comp = reverse.translate(table) rev_comp = reverse.translate(table)
return rev_comp return rev_comp
\ No newline at end of file
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