Ejemplo n.º 1
0
def test_respond_choose_nonsense():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE')
    msg_content.sets('ekb-term', ekb_from_text('bagel'))
    res = bs.respond_choose_sense(msg_content)
    print(res)
    assert res.head() == 'SUCCESS'
    assert res.get('agents')[0].gets('ont-type') is None
Ejemplo n.º 2
0
def test_choose_nonsense():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE')
    msg_content.sets('ekb-term', ekb_from_text('bagel'))
    res = bs.respond_choose_sense(msg_content)
    print(res)
    assert res.head() == 'SUCCESS'
    assert res.get('agents')[0].gets('ont-type') == None
Ejemplo n.º 3
0
def test_respond_choose_sense():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE')
    msg_content.set('agent', mek1)
    res = bs.respond_choose_sense(msg_content)
    agent_clj = res.get('agent')
    assert agent_clj
    agent = Bioagent.get_agent(agent_clj)
    assert agent.name == 'MAP2K1'
    assert agent.db_refs['HGNC'] == '6840'
Ejemplo n.º 4
0
def test_choose_sense_what_member():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE-WHAT-MEMBER')
    msg_content.sets('collection', mek_ekb)
    print(msg_content)
    res = bs.respond_choose_sense_what_member(msg_content)
    print(res)
    print(res.head)
    assert (res.head() == 'SUCCESS')
    assert (len(res.get('members')) == 2)
Ejemplo n.º 5
0
def test_choose_sense_category():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE-CATEGORY')
    msg_content.sets('ekb-term', mek1_ekb)
    msg_content.sets('category', 'kinase activity')
    res = bs.respond_choose_sense_category(msg_content)
    print(res)
    print(res.head)
    assert (res.head() == 'SUCCESS')
    assert (res.get('in-category') == 'TRUE')
Ejemplo n.º 6
0
def test_respond_choose_nonsense():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE')
    msg_content.set('agent', agent_clj_from_text('bagel'))
    res = bs.respond_choose_sense(msg_content)
    print(res)
    assert res.head() == 'SUCCESS'
    agents_clj = res.get('agent')
    agent = Bioagent.get_agent(agents_clj)
    assert agent.name == 'BAGEL'
    assert len(agent.db_refs) == 1
Ejemplo n.º 7
0
def test_respond_get_synonyms():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('GET-SYNONYMS')
    msg_content.sets('entity', mek1_ekb)
    res = bs.respond_get_synonyms(msg_content)
    assert res.head() == 'SUCCESS'
    syns = res.get('synonyms')
    syn_strs = [s.gets(':name') for s in syns]
    assert 'MAP2K1' in syn_strs
    assert 'MEK1' in syn_strs
    assert 'MKK1' in syn_strs
Ejemplo n.º 8
0
def test_respond_choose_sense_is_member():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE-IS-MEMBER')
    msg_content.set('ekb-term', mek1)
    msg_content.set('collection', mek)
    print(msg_content)
    res = bs.respond_choose_sense_is_member(msg_content)
    print(res)
    print(res.head())
    assert (res.head() == 'SUCCESS')
    assert (res.get('is-member') == 'TRUE')
Ejemplo n.º 9
0
def test_respond_choose_sense_is_member():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE-IS-MEMBER')
    msg_content.sets('ekb-term', mek1_ekb)
    msg_content.sets('collection', mek_ekb)
    print(msg_content)
    res = bs.respond_choose_sense_is_member(msg_content)
    print(res)
    print(res.head())
    assert(res.head() == 'SUCCESS')
    assert(res.get('is-member') == 'TRUE')
Ejemplo n.º 10
0
def test_respond_get_synonyms():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('GET-SYNONYMS')
    msg_content.set('entity', mek1)
    res = bs.respond_get_synonyms(msg_content)
    assert res.head() == 'SUCCESS'
    syns = res.get('synonyms')
    syn_strs = [s.gets(':name') for s in syns]
    assert 'MAP2K1' in syn_strs, syn_strs
    assert 'MEK1' in syn_strs, syn_strs
    assert 'MKK1' in syn_strs, syn_strs
    assert res.get('num_synonyms') == '23', res
Ejemplo n.º 11
0
def test_choose_sense():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE')
    msg_content.sets('ekb-term', mek1_ekb)
    res = bs.respond_choose_sense(msg_content)
    print(res)
    agents = res.get('agents')
    assert agents and agents.data
    agent = agents[0]
    name = agent.gets('name')
    assert name == 'MAP2K1'
    ont_type = agent.get('ont-type')
    assert ont_type == 'ONT::GENE'
Ejemplo n.º 12
0
def test_respond_choose_sense():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE')
    msg_content.sets('ekb-term', mek1_ekb)
    res = bs.respond_choose_sense(msg_content)
    print(res)
    agents = res.get('agents')
    assert agents and agents.data
    agent = agents[0]
    name = agent.gets('name')
    assert name == 'MAP2K1'
    ont_type = agent.get('ont-type')
    assert ont_type == 'ONT::GENE'
Ejemplo n.º 13
0
def test_respond_choose_sense_what_member():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE-WHAT-MEMBER')
    msg_content.sets('collection', mek_ekb)
    print(msg_content)
    res = bs.respond_choose_sense_what_member(msg_content)
    print(res)
    print(res.head())
    assert(res.head() == 'SUCCESS')
    assert(len(res.get('members')) == 2)
    m1 = res.get('members')[0]
    m2 = res.get('members')[1]
    assert m1.gets('name') == 'MAP2K1', m1.gets('name')
    assert m2.gets('name') == 'MAP2K2', m2.gets('name')
Ejemplo n.º 14
0
def test_respond_choose_sense_what_member():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE-WHAT-MEMBER')
    msg_content.set('collection', mek)
    print(msg_content)
    res = bs.respond_choose_sense_what_member(msg_content)
    print(res)
    print(res.head())
    assert (res.head() == 'SUCCESS')
    assert (len(res.get('members')) == 2)
    m1 = res.get('members')[0]
    m2 = res.get('members')[1]
    a1 = Bioagent.get_agent(m1)
    a2 = Bioagent.get_agent(m2)
    assert a1.name == 'MAP2K1'
    assert a2.name == 'MAP2K2'
    assert a2.db_refs['HGNC'] == '6842'
    assert a1.db_refs['UP'] == 'Q02750'
Ejemplo n.º 15
0
def test_respond_choose_sense_category():
    bs = BioSense_Module(testing=True)
    cases = [(mek1, [('kinase activity', 'TRUE'), ('enzyme', 'TRUE'),
                     ('kinase', 'TRUE'), ('transcription-factor', 'FALSE'),
                     ('W::KINASE', 'TRUE'), ('phosphatase', 'FALSE')]),
             (dusp6, [('phosphatase', 'TRUE'), ('enzyme', 'TRUE')]),
             (braf, [('kinase', 'TRUE')])]
    for agent_clj, result_tuples in cases:
        msg_content = KQMLList('CHOOSE-SENSE-CATEGORY')
        msg_content.set('ekb-term', agent_clj)
        for cat, result in result_tuples:
            print('Testing: %s. Excpet result %s.' % (cat, result))
            msg_content.sets('category', cat)
            res = bs.respond_choose_sense_category(msg_content)
            print(res)
            print(res.head())
            assert (res.head() == 'SUCCESS')
            assert (res.get('in-category') == result)
Ejemplo n.º 16
0
def test_choose_sense_category():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE-CATEGORY')
    msg_content.sets('ekb-term', mek1_ekb)
    for cat, result in [('kinase activity', 'TRUE'), ('enzyme', 'TRUE'),
                        ('kinase', 'TRUE'), ('transcription-factor', 'FALSE'),
                        ('W::KINASE', 'TRUE'), ('phosphatase', 'FALSE')]:
        print('Testing: %s. Excpet result %s.' % (cat, result))
        msg_content.sets('category', cat)
        res = bs.respond_choose_sense_category(msg_content)
        print(res)
        print(res.head())
        assert (res.head() == 'SUCCESS')
        assert (res.get('in-category') == result)
    msg_content = KQMLList('CHOOSE-SENSE-CATEGORY')
    msg_content.sets('ekb-term', ekb_from_text('BRAF'))
    msg_content.sets('category', 'kinase')
    res = bs.respond_choose_sense_category(msg_content)
    print(res)
    assert res.head() == 'SUCCESS'
Ejemplo n.º 17
0
def test_respond_choose_sense_category():
    bs = BioSense_Module(testing=True)
    cases = [(mek1_ekb, [('kinase activity', 'TRUE'),
                         ('enzyme', 'TRUE'),
                         ('kinase', 'TRUE'),
                         ('transcription-factor', 'FALSE'),
                         ('W::KINASE', 'TRUE'),
                         ('phosphatase', 'FALSE')]),
             (dusp_ekb, [('phosphatase', 'TRUE'), ('enzyme', 'TRUE')]),
             (ekb_from_text('BRAF'), [('kinase', 'TRUE')])]
    for ekb, result_tuples in cases:
        msg_content = KQMLList('CHOOSE-SENSE-CATEGORY')
        msg_content.sets('ekb-term', ekb)
        for cat, result in result_tuples:
            print('Testing: %s. Excpet result %s.' % (cat, result))
            msg_content.sets('category', cat)
            res = bs.respond_choose_sense_category(msg_content)
            print(res)
            print(res.head())
            assert(res.head() == 'SUCCESS')
            assert(res.get('in-category') == result)