Exemple #1
0
def test_similarities__filebased_badid(empty_hits_df):
    queries = pd.Series(['foo-bar'])

    with pytest.raises(IncompleteHits) as e:
        similarities(queries, 'data/similarities.h5', 0.55, 1)

    assert_frame_equal(e.value.hits, empty_hits_df)
    assert e.value.absent_identifiers == ['foo-bar']
Exemple #2
0
def test_similarities__filebased_badid(empty_hits_df):
    queries = pd.Series(['foo-bar'])

    with pytest.raises(IncompleteHits) as e:
        similarities(queries, 'data/similarities.h5', 0.55, 1)

    assert_frame_equal(e.value.hits, empty_hits_df)
    assert e.value.absent_identifiers == ['foo-bar']
Exemple #3
0
def test_similarities__filebased_partbadid():
    queries = pd.Series(['3j7u_NDP_frag24', 'foo-bar'])

    with pytest.raises(IncompleteHits) as e:
        similarities(queries, 'data/similarities.h5', 0.55, 1)

    expected = [
        {'query_frag_id': '3j7u_NDP_frag24', 'hit_frag_id': '3j7u_NDP_frag23', 'score': 0.8991},
    ]
    assert_frame_equal(e.value.hits, pd.DataFrame(expected, columns=['query_frag_id', 'hit_frag_id', 'score']))
    assert e.value.absent_identifiers == ['foo-bar']
Exemple #4
0
def test_similarities__webbased_badid(base_url, empty_hits_df):
    queries = pd.Series(['foo-bar'])

    with requests_mock.mock() as m:
        url = base_url + '/fragments/' + 'foo-bar' + '/similar?cutoff=0.55'
        m.get(url, status_code=404)

        with pytest.raises(IncompleteHits) as e:
            similarities(queries, base_url, 0.55)

    assert_frame_equal(e.value.hits, pd.DataFrame(empty_hits_df))
    assert e.value.absent_identifiers == ['foo-bar']
Exemple #5
0
def test_similarities__webbased_badid(base_url, empty_hits_df):
    queries = pd.Series(['foo-bar'])

    with requests_mock.mock() as m:
        url = base_url + '/fragments/' + 'foo-bar' + '/similar?cutoff=0.55'
        m.get(url, status_code=404)

        with pytest.raises(IncompleteHits) as e:
            similarities(queries, base_url, 0.55)

    assert_frame_equal(e.value.hits, pd.DataFrame(empty_hits_df))
    assert e.value.absent_identifiers == ['foo-bar']
Exemple #6
0
def test_similarities__webbased_partbadid(base_url):
    queries = pd.Series(['3j7u_NDP_frag24', 'foo-bar'])
    body = [
        {'query_frag_id': '3j7u_NDP_frag24', 'hit_frag_id': '3j7u_NDP_frag23', 'score': 0.8991},
    ]

    with requests_mock.mock() as m:
        m.get(base_url + '/fragments/' + 'foo-bar' + '/similar?cutoff=0.55', status_code=404)
        url = base_url + '/fragments/' + '3j7u_NDP_frag24' + '/similar?cutoff=0.55'
        m.get(url, json=body)

        with pytest.raises(IncompleteHits) as e:
            similarities(queries, base_url, 0.55)

    assert_frame_equal(e.value.hits, pd.DataFrame(body, columns=['query_frag_id', 'hit_frag_id', 'score']))
    assert e.value.absent_identifiers == ['foo-bar']
Exemple #7
0
def test_similarities_limitof1():
    queries = pd.Series(['3j7u_NDP_frag24'])

    result = similarities(queries, 'data/similarities.h5', 0.55, 1)

    expected = [
        {'query_frag_id': '3j7u_NDP_frag24', 'hit_frag_id': '3j7u_NDP_frag23', 'score': 0.8991},
    ]
    assert_frame_equal(result, pd.DataFrame(expected, columns=['query_frag_id', 'hit_frag_id', 'score']))
Exemple #8
0
def test_similarities__filebased_partbadid():
    queries = pd.Series(['3j7u_NDP_frag24', 'foo-bar'])

    with pytest.raises(IncompleteHits) as e:
        similarities(queries, 'data/similarities.h5', 0.55, 1)

    expected = [
        {
            'query_frag_id': '3j7u_NDP_frag24',
            'hit_frag_id': '3j7u_NDP_frag23',
            'score': 0.8991
        },
    ]
    assert_frame_equal(
        e.value.hits,
        pd.DataFrame(expected,
                     columns=['query_frag_id', 'hit_frag_id', 'score']))
    assert e.value.absent_identifiers == ['foo-bar']
Exemple #9
0
def test_similarities__webbased_partbadid(base_url):
    queries = pd.Series(['3j7u_NDP_frag24', 'foo-bar'])
    body = [
        {
            'query_frag_id': '3j7u_NDP_frag24',
            'hit_frag_id': '3j7u_NDP_frag23',
            'score': 0.8991
        },
    ]

    with requests_mock.mock() as m:
        m.get(base_url + '/fragments/' + 'foo-bar' + '/similar?cutoff=0.55',
              status_code=404)
        url = base_url + '/fragments/' + '3j7u_NDP_frag24' + '/similar?cutoff=0.55'
        m.get(url, json=body)

        with pytest.raises(IncompleteHits) as e:
            similarities(queries, base_url, 0.55)

    assert_frame_equal(
        e.value.hits,
        pd.DataFrame(body, columns=['query_frag_id', 'hit_frag_id', 'score']))
    assert e.value.absent_identifiers == ['foo-bar']
Exemple #10
0
def test_similarities_limitof1():
    queries = pd.Series(['3j7u_NDP_frag24'])

    result = similarities(queries, 'data/similarities.h5', 0.55, 1)

    expected = [
        {
            'query_frag_id': '3j7u_NDP_frag24',
            'hit_frag_id': '3j7u_NDP_frag23',
            'score': 0.8991
        },
    ]
    assert_frame_equal(
        result,
        pd.DataFrame(expected,
                     columns=['query_frag_id', 'hit_frag_id', 'score']))
from kripodb.canned import similarities

# Map options to kripo arguments
query_column = options['fragment_id_column']
similarity_matrix = options['matrix']
cutoff = options['cutoff']
limit = options['limit']

# Select input column
queries = input_table[query_column]

# Fetch similarities
output_table = similarities(queries,
                            similarity_matrix,
                            cutoff,
                            limit)