Skip to content
Snippets Groups Projects
Commit 471608be authored by Vermaat's avatar Vermaat
Browse files

Merge pull request #81 from mutalyzer/fix-transcript-protein-link-query

Fix transcript protein link query
parents ba859618 38b8eff4
No related branches found
No related tags found
No related merge requests found
......@@ -87,17 +87,13 @@ def get_transcript_protein_link(accession, reverse=False):
# Lookup by protein accession instead of transcript accession.
query_column, other_column = other_column, query_column
return TranscriptProteinLink.query \
.filter_by(transcript_accession=accession) \
.filter(
query_column == accession,
or_(
and_(other_column.isnot(None),
TranscriptProteinLink.added >= link_datetime),
and_(other_column.is_(None),
TranscriptProteinLink.added >= negative_link_datetime))
) \
.first()
return TranscriptProteinLink.query.filter(
query_column == accession,
or_(and_(other_column.isnot(None),
TranscriptProteinLink.added >= link_datetime),
and_(other_column.is_(None),
TranscriptProteinLink.added >= negative_link_datetime))
).first()
def update_transcript_protein_link(transcript_accession=None,
......
"""
Tests for the mutalyzer.db.queries module.
"""
from __future__ import unicode_literals
#import logging; logging.basicConfig()
from mutalyzer.db import queries
from fixtures import database, cache
from utils import MutalyzerTest
from utils import fix
class TestMutator(MutalyzerTest):
"""
Test the queries module.
"""
fixtures = (database, )
def setup(self):
super(TestMutator, self).setup()
@fix(cache('MARK1'))
def test_get_transcript_protein_link(self):
"""
Query a transcript-protein link by transcript.
"""
link = queries.get_transcript_protein_link('NM_018650')
assert link.transcript_accession == 'NM_018650'
assert link.protein_accession == 'NP_061120'
@fix(cache('MARK1'))
def test_get_transcript_protein_link_negative(self):
"""
Query a negative transcript-protein link by transcript.
"""
link = queries.get_transcript_protein_link('XM_005273133')
assert link.transcript_accession == 'XM_005273133'
assert link.protein_accession is None
@fix(cache('MARK1'))
def test_get_transcript_protein_link_missing(self):
"""
Query a missing transcript-protein link by transcript.
"""
link = queries.get_transcript_protein_link('NM_123456')
assert link is None
@fix(cache('MARK1'))
def test_get_transcript_protein_link_reverse(self):
"""
Query a transcript-protein link by protein.
"""
link = queries.get_transcript_protein_link('NP_061120', reverse=True)
assert link.transcript_accession == 'NM_018650'
assert link.protein_accession == 'NP_061120'
@fix(cache('MARK1'))
def test_get_transcript_protein_link_reverse_missing(self):
"""
Query a missing transcript-protein link by protein.
"""
link = queries.get_transcript_protein_link('NP_123456')
assert link is None
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