Example #1
0
def agent_from_obs(obs_name, model):
    db_refs = {}
    ag_name = None
    for ann in model.annotations:
        if ann.subject == obs_name:
            if ann.predicate == 'from_indra_agent':
                ag_name = ann.object
                break
    if ag_name:
        mon_name = _n(ag_name)
        for ann in model.annotations:
            if isinstance(ann.subject, Monomer) and \
                    ann.subject.name == mon_name and ann.predicate == 'is':
                db_name, db_ref = parse_identifiers_url(ann.object)
                db_refs[db_name] = db_ref
        ag = Agent(ag_name, db_refs=db_refs)
        return ag
Example #2
0
def test_parse_identifiers_url():
    url1 = 'http://identifiers.org/foo/bar'
    url2 = 'http://identifiers.org/hgnc/12345'
    url3 = 'http://identifiers.org/hgnc/HGNC:12345'
    url4 = 'http://identifiers.org/uniprot/12345'
    url5 = 'http://identifiers.org/chebi/12345'
    url6 = 'http://identifiers.org/interpro/12345'
    url7 = 'http://identifiers.org/pfam/12345'
    (ns, id) = pa.parse_identifiers_url(url1)
    assert ns is None and id is None
    (ns, id) = pa.parse_identifiers_url(url2)
    assert ns is None and id is None
    (ns, id) = pa.parse_identifiers_url(url3)
    assert ns == 'HGNC' and id == '12345'
    (ns, id) = pa.parse_identifiers_url(url4)
    assert ns == 'UP' and id == '12345'
    (ns, id) = pa.parse_identifiers_url(url5)
    assert ns == 'CHEBI' and id == '12345'
    (ns, id) = pa.parse_identifiers_url(url6)
    assert ns == 'IP' and id == '12345'
    (ns, id) = pa.parse_identifiers_url(url7)
    assert ns == 'XFAM' and id == '12345'
Example #3
0
def test_parse_identifiers_url():
    url1 = 'http://identifiers.org/foo/bar'
    url2 = 'http://identifiers.org/hgnc/12345'
    url3 = 'http://identifiers.org/hgnc/HGNC:12345'
    url4 = 'http://identifiers.org/uniprot/12345'
    url5 = 'http://identifiers.org/chebi/12345'
    url6 = 'http://identifiers.org/interpro/12345'
    url7 = 'http://identifiers.org/pfam/12345'
    (ns, id) = pa.parse_identifiers_url(url1)
    assert ns is None and id is None
    (ns, id) = pa.parse_identifiers_url(url2)
    assert ns is None and id is None
    (ns, id) = pa.parse_identifiers_url(url3)
    assert ns == 'HGNC' and id == '12345'
    (ns, id) = pa.parse_identifiers_url(url4)
    assert ns == 'UP' and id == '12345'
    (ns, id) = pa.parse_identifiers_url(url5)
    assert ns == 'CHEBI' and id == '12345'
    (ns, id) = pa.parse_identifiers_url(url6)
    assert ns == 'IP' and id == '12345'
    (ns, id) = pa.parse_identifiers_url(url7)
    assert ns == 'XFAM' and id == '12345'