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
Pipeline #10309 passed with stages
in 51 seconds
......@@ -424,7 +424,7 @@ pseudocode:
| *concatenate nt complement to rev_comp*
| *return rev_comp*
.. literalinclude:: _static/code/rev_comp2.py
.. literalinclude:: _static/code/rev_comp.py
:linenos:
:language: python
......
......@@ -5,13 +5,9 @@ def rev_comp(seq):
return the reverse complement of seq
the case is respect but if the sequence mix upper and lower case the function will failed
"""
upper = seq.isupper()
reverse = seq[::-1]
direct = 'acgt'
comp = 'tgca'
if upper:
table = string.maketrans(direct.upper(), comp.upper())
else:
table = string.maketrans(direct, comp)
direct = 'acgtATCG'
comp = 'tgcaTGCA'
table = string.maketrans(direct, comp)
rev_comp = reverse.translate(table)
return rev_comp
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment