def _agent_from_ns_id(ag_ns, ag_id): # Add the ID as a placeholder name agent = Agent(ag_id) # If we have a proper grounding, add to db_refs if ag_id is not None: agent.db_refs[ag_ns] = ag_id # Now standardize db_refs and set standardized name GroundingMapper.standardize_agent_name(agent, standardize_refs=True) agent.db_refs['TEXT'] = agent.name return agent
def get_agent(name): opts = {'text': name} indra_url = read_from_config('INDRA_GROUND_URL') res = requests.post(indra_url, json=opts) if res.status_code != 200 and not res.json(): return Agent(name, db_refs={'TEXT': name}) js = res.json() top_term = js[0]['term'] agent = Agent(name, db_refs={'TEXT': name, top_term['db']: top_term['id']}) GroundingMapper.standardize_agent_name(agent, standardize_refs=True) return agent
def test_name_standardize_hgnc_up(): a1 = Agent('x', db_refs={'HGNC': '9387'}) GroundingMapper.standardize_agent_name(a1, True) assert a1.name == 'PRKAG3' a1 = Agent('x', db_refs={'UP': 'Q9UGI9'}) GroundingMapper.standardize_agent_name(a1, True) assert a1.name == 'PRKAG3' a1 = Agent('x', db_refs={'UP': 'Q8BGM7'}) GroundingMapper.standardize_agent_name(a1, True) assert a1.name == 'Prkag3'
def get_channel_agent(channel): ag = Agent(channel, db_refs={'HGNC': hgnc_client.get_hgnc_id(channel)}) GroundingMapper.standardize_agent_name(ag, standardize_refs=True) return ag
def test_name_standardize_mesh(): a1 = Agent('x', db_refs={'MESH': 'D008545'}) GroundingMapper.standardize_agent_name(a1, False) assert a1.name == 'Melanoma', a1.name
def test_name_standardize_go(): a1 = Agent('x', db_refs={'GO': 'GO:0006915'}) GroundingMapper.standardize_agent_name(a1, False) assert a1.name == 'apoptotic process'
def test_name_standardize_chebi(): a1 = Agent('x', db_refs={'CHEBI': '15996'}) GroundingMapper.standardize_agent_name(a1, False) assert a1.name == 'GTP'