Esempio n. 1
0
def test_transcript_to_protein(accession, version, match_version, expected):
    """
    Get protein for transcript.

    Both the Entrez API and our cache are fixed with a set of
    transcript-protein links. This test is parametrized with a list of
    arguments for the :func:`ncbi.transcript_to_protein` function and the
    corresponding expected result (`None` if `NoLinkError` is expected to be
    raised).
    """
    if expected is None:
        with pytest.raises(ncbi.NoLinkError):
            ncbi.transcript_to_protein(accession, version, match_version)
    else:
        assert ncbi.transcript_to_protein(accession, version,
                                          match_version) == expected
Esempio n. 2
0
def test_transcript_to_protein(accession, version, match_version, expected):
    """
    Get protein for transcript.

    Both the Entrez API and our cache are fixed with a set of
    transcript-protein links. This test is parametrized with a list of
    arguments for the :func:`ncbi.transcript_to_protein` function and the
    corresponding expected result (`None` if `NoLinkError` is expected to be
    raised).
    """
    if expected is None:
        with pytest.raises(ncbi.NoLinkError):
            ncbi.transcript_to_protein(accession, version, match_version)
    else:
        assert ncbi.transcript_to_protein(
            accession, version, match_version) == expected
Esempio n. 3
0
def test_transcript_to_protein_cache(accession, version, match_version,
                                     expected_forward, expected_reverse):
    """
    Get protein for transcript and check the resulting cache state.
    """
    try:
        ncbi.transcript_to_protein(accession, version, match_version)
    except ncbi.NoLinkError:
        pass

    forward = [(key.split(':')[-1], redis.get(key) or None)
               for key in redis.keys('ncbi:transcript-to-protein:*')]
    assert sorted(forward) == sorted(expected_forward)

    reverse = [(redis.get(key) or None, key.split(':')[-1])
               for key in redis.keys('ncbi:protein-to-transcript:*')]
    assert sorted(reverse) == sorted(expected_reverse)
Esempio n. 4
0
def test_transcript_to_protein_cache(accession, version, match_version,
                                     expected_forward, expected_reverse):
    """
    Get protein for transcript and check the resulting cache state.
    """
    try:
        ncbi.transcript_to_protein(accession, version, match_version)
    except ncbi.NoLinkError:
        pass

    forward = [(key.split(':')[-1], redis.get(key) or None)
               for key in redis.keys('ncbi:transcript-to-protein:*')]
    assert sorted(forward) == sorted(expected_forward)

    reverse = [(redis.get(key) or None, key.split(':')[-1])
               for key in redis.keys('ncbi:protein-to-transcript:*')]
    assert sorted(reverse) == sorted(expected_reverse)