<commit_before>from __future__ import absolute_import, print_function, unicode_literals
from builtins import dict, str
from indra.statements import Agent
from indra.databases import chembl_client
from indra.util import unicode_strs

vem = Agent('VEMURAFENIB', db_refs={'CHEBI': '63637', 'TEXT': 'VEMURAFENIB'})
az628 = Agent('AZ628', db_refs={'CHEBI': '91354'})
braf = Agent('BRAF', db_refs={'HGNC': '1097', 'NCIT': 'C51194',
                              'TEXT': 'BRAF', 'UP': 'P15056'})

def test_get_inhibitions():
    stmt = chembl_client.get_inhibition(vem, braf)
    assert(stmt is not None)
    assert(unicode_strs(stmt))
    assert(len(stmt.evidence) > 5)
    for ev in stmt.evidence:
        assert(ev.pmid)
        assert(ev.annotations)
        assert(ev.source_api == 'chembl')
        assert(ev.source_id)


def test_get_drug_inhibition_stmts_vem():
    stmts = chembl_client.get_drug_inhibition_stmts(vem)
    assert(len(stmts) > 0)
    for st in stmts:
        assert(unicode_strs(st))
        assert(len(st.evidence) >= 1)
        for ev in st.evidence:
            assert(ev.pmid)
            assert(ev.annotations)
            assert(ev.source_api == 'chembl')
            assert(ev.source_id)


def test_get_drug_inhibition_stmts_az628():
    stmts = chembl_client.get_drug_inhibition_stmts(az628)
    assert(len(stmts) > 0)
    for st in stmts:
        assert(unicode_strs(st))
        assert(len(st.evidence) >= 1)
        for ev in st.evidence:
            assert(ev.pmid)
            assert(ev.annotations)
            assert(ev.source_api == 'chembl')
            assert(ev.source_id)<commit_msg>Test send_query using activity endpoint<commit_after>from __future__ import absolute_import, print_function, unicode_literals
from builtins import dict, str
from indra.statements import Agent
from indra.databases import chembl_client
from indra.util import unicode_strs

vem = Agent('VEMURAFENIB', db_refs={'CHEBI': '63637', 'TEXT': 'VEMURAFENIB'})
az628 = Agent('AZ628', db_refs={'CHEBI': '91354'})
braf = Agent('BRAF', db_refs={'HGNC': '1097', 'NCIT': 'C51194',
                              'TEXT': 'BRAF', 'UP': 'P15056'})
braf_chembl_id = 'CHEMBL1229517'
query_dict_BRAF_activity = {'query': 'activity',
                            'params': {'molecule_chembl_id': braf_chembl_id,
                                       'limit': 10000}}

def test_get_inhibitions():
    stmt = chembl_client.get_inhibition(vem, braf)
    assert(stmt is not None)
    assert(unicode_strs(stmt))
    assert(len(stmt.evidence) > 5)
    for ev in stmt.evidence:
        assert(ev.pmid)
        assert(ev.annotations)
        assert(ev.source_api == 'chembl')
        assert(ev.source_id)


def test_activity_query():
    res = chembl_client.send_query(query_dict_BRAF_activity)
    assert(res['page_meta']['total_count'] == len(res['activities']))
    assay_types = list(set([x['standard_type'] for x in res['activities']]))
    expected_types = ['IC50', 'EC50', 'INH', 'Potency', 'Kd']
    for e_t in expected_types:
        assert(e_t in assay_types)


def test_get_drug_inhibition_stmts_vem():
    stmts = chembl_client.get_drug_inhibition_stmts(vem)
    assert(len(stmts) > 0)
    for st in stmts:
        assert(unicode_strs(st))
        assert(len(st.evidence) >= 1)
        for ev in st.evidence:
            assert(ev.pmid)
            assert(ev.annotations)
            assert(ev.source_api == 'chembl')
            assert(ev.source_id)


def test_get_drug_inhibition_stmts_az628():
    stmts = chembl_client.get_drug_inhibition_stmts(az628)
    assert(len(stmts) > 0)
    for st in stmts:
        assert(unicode_strs(st))
        assert(len(st.evidence) >= 1)
        for ev in st.evidence:
            assert(ev.pmid)
            assert(ev.annotations)
            assert(ev.source_api == 'chembl')
            assert(ev.source_id)
{'fraction_non_alphanumeric': 0.12428497139885596, 'fraction_numerical': 0.02548101924076963, 'mean_word_length': 3.0665961945031714, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '907881', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1332, 'n_words': 254}