Skip to content
GitLab
Menu
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
0a0f10a1
Verified
Commit
0a0f10a1
authored
Mar 14, 2019
by
Bertrand NÉRON
Browse files
improve rev_comp2
parent
dd61ff44
Pipeline
#10239
passed with stages
in 22 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
source/_static/code/rev_comp2.py
View file @
0a0f10a1
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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