Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mutalyzer
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirrors
mutalyzer
Commits
7feaf889
Commit
7feaf889
authored
9 years ago
by
Vermaat
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for backtranslator module
parent
c942e006
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_backtranslator.py
+116
-0
116 additions, 0 deletions
tests/test_backtranslator.py
with
116 additions
and
0 deletions
tests/test_backtranslator.py
0 → 100644
+
116
−
0
View file @
7feaf889
"""
Tests for the mutalyzer.backtranslator module.
"""
from
__future__
import
unicode_literals
import
pytest
from
mutalyzer.backtranslator
import
backtranslate
import
mutalyzer.Retriever
from
fixtures
import
with_links
,
with_references
DIVERSIONS
=
{
'
NM_003002
'
:
'
NM_003002.2
'
}
@pytest.fixture
def
divert
(
monkeypatch
,
request
):
"""
Ad-hoc fixture diverting a retriever call for NM_003002 to NM_003002.2.
This is useful to mimic behaviour of the retriever for the accession
without version number, which we cannot do with a normal fixture (the
retriever does not support non-versioned references in the database).
"""
loadrecord
=
mutalyzer
.
Retriever
.
GenBankRetriever
.
loadrecord
def
mock_loadrecord
(
self
,
identifier
):
identifier
=
DIVERSIONS
.
get
(
identifier
,
identifier
)
return
loadrecord
(
self
,
identifier
)
monkeypatch
.
setattr
(
mutalyzer
.
Retriever
.
GenBankRetriever
,
'
loadrecord
'
,
mock_loadrecord
)
@with_references
(
'
NM_003002.2
'
)
def
test_nm
(
output
):
"""
Back translate on NM.
"""
variants
=
backtranslate
(
output
,
'
NM_003002.2:p.Asp92Tyr
'
)
assert
sorted
(
variants
)
==
[
'
NM_003002.2:c.274G>T
'
]
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WNOVERSION
'
))
==
0
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WNODNA
'
))
==
0
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WIMPROVE
'
))
==
0
@with_references
(
'
NM_003002.2
'
)
@pytest.mark.usefixtures
(
'
divert
'
)
def
test_nm_no_version
(
output
):
"""
Back translate on NM.
"""
variants
=
backtranslate
(
output
,
'
NM_003002:p.Asp92Tyr
'
)
assert
sorted
(
variants
)
==
[
'
NM_003002:c.274G>T
'
]
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WNOVERSION
'
))
==
0
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WNODNA
'
))
==
0
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WIMPROVE
'
))
==
0
@with_links
((
'
NM_003002.2
'
,
'
NP_002993.1
'
))
@with_references
(
'
NM_003002.2
'
)
def
test_np
(
output
):
"""
Back translate on NP.
"""
variants
=
backtranslate
(
output
,
'
NP_002993.1:p.Asp92Glu
'
)
assert
sorted
(
variants
)
==
[
'
NM_003002.2:c.276C>A
'
,
'
NM_003002.2:c.276C>G
'
]
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WNOVERSION
'
))
==
0
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WNODNA
'
))
==
0
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WIMPROVE
'
))
==
0
@with_links
((
'
NM_003002
'
,
'
NP_002993
'
))
@with_references
(
'
NM_003002.2
'
)
@pytest.mark.usefixtures
(
'
divert
'
)
def
test_np_no_version
(
output
):
"""
Back translate on NP.
"""
variants
=
backtranslate
(
output
,
'
NP_002993:p.Asp92Glu
'
)
assert
sorted
(
variants
)
==
[
'
NM_003002:c.276C>A
'
,
'
NM_003002:c.276C>G
'
]
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WNOVERSION
'
))
==
1
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WNODNA
'
))
==
0
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WIMPROVE
'
))
==
0
@with_links
((
None
,
'
NP_000000.0
'
))
def
test_np_no_nm
(
output
):
"""
Back translate on NP without NM.
"""
variants
=
backtranslate
(
output
,
'
NP_000000.0:p.Asp92Tyr
'
)
assert
sorted
(
variants
)
==
[
'
UNKNOWN:c.274G>T
'
]
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WNOVERSION
'
))
==
0
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WNODNA
'
))
==
1
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WIMPROVE
'
))
==
0
@with_links
((
None
,
'
NP_000000.0
'
))
def
test_np_no_nm_improvable
(
output
):
"""
Back translate on NP without NM improvable.
"""
variants
=
backtranslate
(
output
,
'
NP_000000.0:p.Leu92Phe
'
)
assert
sorted
(
variants
)
==
[
'
UNKNOWN:c.274C>T
'
,
'
UNKNOWN:c.276A>C
'
,
'
UNKNOWN:c.276A>T
'
,
'
UNKNOWN:c.276G>C
'
,
'
UNKNOWN:c.276G>T
'
]
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WNOVERSION
'
))
==
0
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WNODNA
'
))
==
1
assert
len
(
output
.
getMessagesWithErrorCode
(
'
WIMPROVE
'
))
==
1
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment