def test_find_drugs_for_genes(): # SearchTerm for SRC SRC = SearchTerm(type='gene', name='SRC', search_term='"SRC"', db_refs={'HGNC': '11283'}) # drugs targeting KRAS drug_terms = find_drugs_for_genes([SRC], [ Inhibition(Agent('Dasatinib', db_refs={'CHEBI': 'CHEBI:49375'}), Agent('SRC', db_refs={'HGNC': '11283'})), Inhibition(Agent('Ponatinib', db_refs={'CHEBI': 'CHEBI:78543'}), Agent('SRC', db_refs={'HGNC': '11283'})) ]) # make sure there are results assert drug_terms # make sure the result is a list of search terms assert all(isinstance(term, SearchTerm) for term in drug_terms) # test that some example drugs are included drug_names = set(term.name for term in drug_terms) assert drug_names == set(['Dasatinib', 'Ponatinib'])
def test_grounding_map_gilda_priority(): gm.gilda_mode = 'web' fetal_bovine_serum = Agent('FBS', db_refs={'TEXT': 'FBS'}) pmid = '28536624' stmt = Phosphorylation(None, fetal_bovine_serum, evidence=[Evidence(pmid=pmid, text_refs={'PMID': pmid})]) mapped_stmts = gm.map_stmts([stmt]) annotations = mapped_stmts[0].evidence[0].annotations # agents should not be in annotations if gilda is run. Second condition # added as future proofing in case some future change causes this mapping # to add agent annotations in the future. assert 'agents' not in annotations or \ 'gilda' not in annotations['agents']
def test_gilda_disambiguation_local(): gm.gilda_mode = 'local' er1 = Agent('NDR1', db_refs={'TEXT': 'NDR1'}) pmid1 = '18362890' stmt1 = Phosphorylation( None, er1, evidence=[Evidence(pmid=pmid1, text_refs={'PMID': pmid1})]) mapped_stmts1 = gm.map_stmts([stmt1]) annotations = mapped_stmts1[0].evidence[0].annotations assert annotations['agents']['gilda'][0] is None assert annotations['agents']['gilda'][1] is not None assert len(annotations['agents']['gilda'][1]) == 2, \ annotations # This is to make sure the to_json of the ScoredMatches works assert annotations['agents']['gilda'][1][0]['term']['db'] == 'HGNC'
def test_ground_gilda_source(): ev1 = Evidence(source_api='reach') ev2 = Evidence(source_api='sparser') ev3 = Evidence(source_api='trips') stmts = [Phosphorylation(None, Agent('x', db_refs={'TEXT': 'kras'}), evidence=ev) for ev in (ev1, ev2, ev3)] grounded_stmts = ground_statements(stmts, sources=['trips']) assert grounded_stmts[0].sub.name == 'x', stmts[0] assert grounded_stmts[1].sub.name == 'x' assert grounded_stmts[2].sub.name == 'KRAS' grounded_stmts = ground_statements(stmts, sources=['reach', 'sparser']) assert all(stmt.sub.name == 'KRAS' for stmt in grounded_stmts[:2])
def up_id_with_no_hgnc_id(): """Non human protein""" gag = Agent('Gag', db_refs={'TEXT': 'Gag'}) stmt = Phosphorylation(None, gag) g_map = {'Gag': {'TEXT': 'Gag', 'UP': 'P04585'}} gm = GroundingMapper(g_map) mapped_stmts = gm.map_agents([stmt]) assert len(mapped_stmts) == 1 mapped_gag = mapped_stmts[0].sub assert mapped_gag.name == 'gag-pol' assert mapped_gag.db_refs['TEXT'] == 'Gag' assert mapped_gag.db_refs.get('HGNC') == None assert mapped_gag.db_refs['UP'] == 'P04585' assert unicode_strs((gag, stmt, gm, mapped_stmts, mapped_gag))
def up_id_with_no_gene_name(): """Expect no HGNC entry; no error raised.""" no_gn = Agent('NoGNname', db_refs={'TEXT': 'NoGN'}) stmt = Phosphorylation(None, no_gn) g_map = {'NoGN': {'TEXT': 'NoGN', 'UP': 'A0K5Q6'}} gm = GroundingMapper(g_map) mapped_stmts = gm.map_agents([stmt]) assert len(mapped_stmts) == 1 mapped_ag = mapped_stmts[0].sub assert mapped_ag.name == 'NoGNname' assert mapped_ag.db_refs['TEXT'] == 'NoGN' assert mapped_ag.db_refs.get('HGNC') == None assert mapped_ag.db_refs['UP'] == 'A0K5Q6' assert unicode_strs((erk, stmt, gm, mapped_stmts, mapped_erk))
def test_deft_mapping(): er1 = Agent('ER', db_refs={'TEXT': 'ER'}) pmid1 = '30775882' stmt1 = Phosphorylation( None, er1, evidence=[Evidence(pmid=pmid1, text_refs={'PMID': pmid1})]) er2 = Agent('ER', db_refs={'TEXT': 'ER'}) pmid2 = '28369137' stmt2 = Inhibition( None, er2, evidence=[Evidence(pmid=pmid2, text_refs={'PMID': pmid2})]) gm = GroundingMapper(default_grounding_map, default_agent_map) mapped_stmts1 = gm.map_agents([stmt1]) assert mapped_stmts1[0].sub.name == 'ESR1' assert mapped_stmts1[0].sub.db_refs['HGNC'] == '3467' assert mapped_stmts1[0].sub.db_refs['UP'] == 'P03372' mapped_stmts2 = gm.map_agents([stmt2]) assert mapped_stmts2[0].obj.name == 'Endoplasmic Reticulum' assert mapped_stmts2[0].obj.db_refs['GO'] == '0005783' annotations = mapped_stmts2[0].evidence[0].annotations assert 'GO:0005783' in annotations['agents']['deft'][1]
def test_dynamic_property_to_json(): agent = Agent('EGFR', mods=[ModCondition('phosphorylation')], db_refs={'HGNC': '3236'}) query = DynamicProperty(agent, 'always_value', 'low', 'qualitative') json = query.to_json() assert json.get('type') == 'dynamic_property' entity = json.get('entity') assert entity.get('name') == 'EGFR' assert entity.get('db_refs') == {"HGNC": "3236"} assert json.get('pattern_type') == 'always_value' quantity = json.get('quantity') assert quantity.get('type') == 'qualitative' assert quantity.get('value') == 'low'
def _agent_from_ns_id(ag_ns, ag_id): ag_name = ag_id db_refs = {'TEXT': ag_name} if ag_ns == 'HGNC': hgnc_id = hgnc_client.get_hgnc_id(ag_id) if hgnc_id is not None: db_refs['HGNC'] = hgnc_id up_id = hgnc_client.get_uniprot_id(hgnc_id) if up_id is not None: db_refs['UP'] = up_id else: if ag_id is not None: db_refs[ag_ns] = ag_id return Agent(ag_name, db_refs=db_refs)
def get_gene_agents(gene_names): agents = [] for gn in gene_names: hgnc_id = hgnc_client.get_hgnc_id(gn) if not hgnc_id: logger.warning('Invalid HGNC gene symbol: %s' % gn) continue db_refs = {'HGNC': hgnc_id} up_id = hgnc_client.get_uniprot_id(hgnc_id) if up_id: db_refs['UP'] = up_id agent = Agent(gn, db_refs=db_refs) agents.append(agent) return agents
def test_get_statements_by_hash(): db = _get_test_db('stmt') # Put statements in the database model_id = 'test' date = '2021-01-01' stmts = [ Activation(Agent('A', db_refs={'HGNC': '1234'}), Agent('B', db_refs={'HGNC': '2345'}), evidence=[ Evidence(text='A activates B.', source_api='assertion', text_refs={'TRID': '1234'}), Evidence(text='A activates B.', source_api='assertion', text_refs={'TRID': '1235'}) ]), Phosphorylation(Agent('B', db_refs={'HGNC': '2345'}), Agent('C', db_refs={'HGNC': '3456'}), evidence=[ Evidence(text='B phosphorylates C.', source_api='assertion', text_refs={'TRID': '2345'}) ]) ] hash0 = stmts[0].get_hash() hash1 = stmts[1].get_hash() stmt_jsons = stmts_to_json(stmts) db.add_statements(model_id, date, stmt_jsons) # Load statements by hash stmts_loaded = db.get_statements_by_hash(model_id, date, [hash0, hash1]) assert len(stmts_loaded) == 2 assert stmts_loaded[0].get_hash() == hash0 assert stmts_loaded[1].get_hash() == hash1 stmts_loaded = db.get_statements_by_hash(model_id, date, [hash0]) assert len(stmts_loaded) == 1 assert stmts_loaded[0].get_hash() == hash0
def _make_path_stmts(self, stmts, merge=False): sentences = [] if merge: groups = group_and_sort_statements(stmts) for group in groups: group_stmts = group[-1] stmt_type = group[0][-1] agent_names = group[0][1] if len(agent_names) < 2: continue if stmt_type == 'Influence': stmt = get_class_from_name(stmt_type, Statement)( Event(Concept(agent_names[0])), Event(Concept(agent_names[1]))) elif stmt_type == 'Conversion': stmt = get_class_from_name(stmt_type, Statement)( Agent(agent_names[0]), [Agent(ag) for ag in agent_names[1]], [Agent(ag) for ag in agent_names[2]]) else: try: stmt = get_class_from_name(stmt_type, Statement)(Agent( agent_names[0]), Agent(agent_names[1])) except ValueError: stmt = get_class_from_name(stmt_type, Statement)( [Agent(ag_name) for ag_name in agent_names]) ea = EnglishAssembler([stmt]) sentence = ea.make_model() stmt_hashes = [gr_st.get_hash() for gr_st in group_stmts] url_param = parse.urlencode( { 'stmt_hash': stmt_hashes, 'source': 'model_statement', 'model': self.model.name }, doseq=True) link = f'/evidence?{url_param}' sentences.append((link, sentence, '')) else: for stmt in stmts: if isinstance(stmt, PybelEdge): sentence = pybel_edge_to_english(stmt) sentences.append(('', sentence, '')) else: ea = EnglishAssembler([stmt]) sentence = ea.make_model() stmt_hashes = [stmt.get_hash()] url_param = parse.urlencode( { 'stmt_hash': stmt_hashes, 'source': 'model_statement', 'model': self.model.name }, doseq=True) link = f'/evidence?{url_param}' sentences.append((link, sentence, '')) return sentences
def test_activating_substitution_refinement(): """Should only be refinement if entities are a refinement and all fields match.""" mc1 = MutCondition('12', 'G', 'D') mc2 = MutCondition('61', 'Q', 'L') nras1 = Agent('NRAS', mutations=[mc1], db_refs={'HGNC': '7989'}) nras2 = Agent('NRAS', mutations=[mc2], db_refs={'HGNC': '7989'}) ras = Agent('RAS', mutations=[mc1], db_refs={'FPLX': 'RAS'}) st1 = ActiveForm(ras, 'gtpbound', True, evidence=Evidence(text='bar')) st2 = ActiveForm(nras1, 'gtpbound', True, evidence=Evidence(text='foo')) st3 = ActiveForm(nras2, 'gtpbound', True, evidence=Evidence(text='bar')) st4 = ActiveForm(nras1, 'phosphatase', True, evidence=Evidence(text='bar')) st5 = ActiveForm(nras1, 'gtpbound', False, evidence=Evidence(text='bar')) assert st2.refinement_of(st1, hierarchies) assert not st3.refinement_of(st1, hierarchies) assert not st4.refinement_of(st1, hierarchies) assert not st5.refinement_of(st1, hierarchies) assert not st1.refinement_of(st2, hierarchies) assert not st3.refinement_of(st2, hierarchies) assert not st4.refinement_of(st2, hierarchies) assert not st5.refinement_of(st2, hierarchies) assert not st1.refinement_of(st3, hierarchies) assert not st2.refinement_of(st3, hierarchies) assert not st4.refinement_of(st3, hierarchies) assert not st5.refinement_of(st3, hierarchies) assert not st1.refinement_of(st4, hierarchies) assert not st2.refinement_of(st4, hierarchies) assert not st3.refinement_of(st4, hierarchies) assert not st5.refinement_of(st4, hierarchies) assert not st1.refinement_of(st5, hierarchies) assert not st2.refinement_of(st5, hierarchies) assert not st3.refinement_of(st5, hierarchies) assert not st4.refinement_of(st5, hierarchies)
def get_drug_agent(name, id): matches = gilda.ground(name) if matches: db_refs = {matches[0].term.db: matches[0].term.id} else: if not id or ':' not in id: db_refs = {} else: db_ns, db_id = id.split(':', maxsplit=1) if db_ns == 'drugbank': db_refs = {'DRUGBANK': db_id} ag = Agent(name, db_refs=db_refs) standardize_agent_name(ag, standardize_refs=True) return ag
def get_grounded_agent(gene_name): """Return a grounded Agent based on an HGNC symbol.""" db_refs = {'TEXT': gene_name} if gene_name in hgnc_map: gene_name = hgnc_map[gene_name] hgnc_id = hgnc_client.get_hgnc_id(gene_name) if not hgnc_id: hgnc_id = hgnc_client.get_current_hgnc_id(gene_name) if hgnc_id: db_refs['HGNC'] = hgnc_id up_id = hgnc_client.get_uniprot_id(hgnc_id) if up_id: db_refs['UP'] = up_id agent = Agent(gene_name, db_refs=db_refs) return agent
def get_genes_for_family(family_agent): """Return agents corresponding to specific genes in a given family agent""" from indra.tools.expand_families import Expander from indra.preassembler.grounding_mapper.standardize \ import standardize_agent_name expander = Expander() children = expander.get_children(family_agent, ns_filter='HGNC') child_agents = [] for _, hgnc_id in children: child_agent = Agent(None, db_refs={'HGNC': hgnc_id, 'TYPE': 'ONT::GENE-PROTEIN'}) standardize_agent_name(child_agent, standardize_refs=True) child_agents.append(child_agent) child_agents = sorted(child_agents, key=lambda x: x.name) return child_agents
def test_statements_from_neo4j(): user = os.environ.get('INDRA_NEO4J_USER') pw = os.environ.get('INDRA_NEO4J_PASSWORD') url = os.environ.get('INDRA_NEO4J_URL') config = 'neo4j:bolt://%s:%s@%s' % (user, pw, url) msa = MSA(corpus_config=config) kras = Agent('KRAS', db_refs={'HGNC': '6407'}) finder = msa.find_mechanisms('to_target', target=kras, verb='activate') res_stmts = finder.get_statements() assert len(res_stmts) > 1000 assert isinstance(res_stmts[0], Activation) finder = msa.find_mechanisms('from_source', source=kras, verb='activate') res_stmts = finder.get_statements() assert len(res_stmts) > 1000 assert isinstance(res_stmts[0], Activation)
def _construct_database(): db = get_temp_db(clear=True) db_builder = DbBuilder(db) db_builder.add_text_refs([('12345', 'PMC54321'), ('24680', 'PMC08642')]) db_builder.add_text_content([['pubmed-abs', 'pmc_oa'], ['pubmed-abs']]) db_builder.add_readings([['REACH'], ['REACH'], ['REACH', 'SPARSER']]) mek = Agent('MEK', db_refs={'FPLX': 'MEK'}) erk = Agent('ERK', db_refs={'FPLX': 'ERK'}) raf = Agent('RAF', db_refs={'FPLX': 'RAF'}) db_builder.add_raw_reading_statements( [[Phosphorylation(mek, erk), Complex([mek, erk])], [Phosphorylation(mek, erk)], [Activation(mek, erk)], [Complex([mek, erk]), Complex([raf, erk])]]) db_builder.add_databases(['signor']) db_builder.add_raw_database_statements([[Complex([raf, erk])]]) db_builder.add_pa_statements([(Phosphorylation(mek, erk), [0, 2]), (Complex([mek, erk]), [1, 4]), (Activation(mek, erk), [3]), (Complex([raf, erk]), [5, 6])]) return db
def test_db_ref_keys(): # test that expanded families get TEXT, UP, HGNC keys in their db_refs # Get the Expander exp = ef.Expander(hierarchies) # Declare some agents grb2 = Agent('GRB2', db_refs={ 'TEXT': 'Grb2', 'UP': 'P62993', 'HGNC': '4566' }) shc = Agent('SHC', db_refs={'BE': 'SHC'}) # Test case where one agent is a family and the other is a gene st = Activation(grb2, shc) expanded_stmts = exp.expand_families([st]) for st in expanded_stmts: for agent in st.agent_list(): if agent is not None: assert set(list(agent.db_refs)) == \ set(['TEXT','UP','HGNC']) # Test for case involving None for one of the agents st = Phosphorylation(None, shc) expanded_stmts = exp.expand_families([st]) for st in expanded_stmts: for agent in st.agent_list(): if agent is not None: assert set(list(agent.db_refs)) == \ set(['TEXT','UP','HGNC']) # Statement with two families: 4x4 SHC st = Activation(shc, shc) expanded_stmts = exp.expand_families([st]) for st in expanded_stmts: for agent in st.agent_list(): if agent is not None: assert set(list(agent.db_refs)) == \ set(['TEXT','UP','HGNC'])
def test_bound_condition_deep_refinement(): """A statement with more specific bound context should be supported by a less specific statement.""" src = Agent('SRC', db_refs={'HGNC': '11283'}) gtp1 = Agent('GTP', db_refs={'CHEBI': '15996'}) gtp2 = Agent('GTP', mods=[ModCondition('phosphorylation')], db_refs={'CHEBI': '15996'}) nrasgtp1 = Agent('NRAS', db_refs={'HGNC': '7989'}, bound_conditions=[BoundCondition(gtp1, True)]) nrasgtp2 = Agent('NRAS', db_refs={'HGNC': '7989'}, bound_conditions=[BoundCondition(gtp2, True)]) st1 = Phosphorylation(src, nrasgtp1, 'tyrosine', '32') st2 = Phosphorylation(src, nrasgtp2, 'tyrosine', '32') # The top-level list should contain only one statement, the more specific # modification, supported by the less-specific modification. pa = Preassembler(hierarchies, stmts=[st1, st2]) stmts = pa.combine_related() assert len(stmts) == 1 assert stmts[0].equals(st2) assert len(stmts[0].supported_by) == 1 assert stmts[0].supported_by[0].equals(st1)
def test_curations(): class Cur: pa_hash = 18316509602085006 source_hash = 7464387630796688426 tag = 'grounding' arr3 = Agent('ARR3', db_refs={'HGNC': '710'}) from bioagents.msa.msa import curs finder = ComplexOneSide(arr3) curs.append(Cur) stmts = finder.get_statements() stmt = stmts[0] names = {a.name for a in stmt.agent_list() if a is not None} assert 'RXR' not in names
def _agent_from_id(db_id): # There are some Ensembl protein IDs which we currently can't normalize # to anything else (unlike ENSG). if db_id.startswith('ENSP'): db_refs = {'ENSEMBL': db_id} name = db_id # All other entries are UniProt IDs else: name = uniprot_client.get_gene_name(db_id) if not name: return None db_refs = {'UP': db_id} hgnc_id = uniprot_client.get_hgnc_id(db_id) if hgnc_id: db_refs['HGNC'] = hgnc_id return Agent(name, db_refs=db_refs)
def applicable(model, test): """Return True of all test entities are in the set of model entities""" model_entities = model.entities test_entities = test.get_entities() test_entity_groups = [] for te in test_entities: te_group = [te] ns, gr = te.get_grounding() children = bio_ontology.get_children(ns, gr) for ns, gr in children: name = bio_ontology.get_name(ns, gr) ag = Agent(name, db_refs={ns: gr}) te_group.append(ag) test_entity_groups.append(te_group) return RefinementTestConnector._overlap(model_entities, test_entity_groups)
def test_to_target_agent_filter(): zeb1 = Agent('ZEB1', db_refs={'HGNC': '11642'}) finder = msa.ToTarget(zeb1, filter_agents=[_mek(), _braf(), _kras()]) stmts = finder.get_statements() assert len(stmts) exp_ags = {'MEK', 'BRAF', 'KRAS'} for stmt in stmts: ag_names = {ag.name for ag in stmt.agent_list() if ag is not None} assert ag_names & exp_ags, ag_names - exp_ags - {'ERK'} summ = finder.summarize() assert 'KRAS' in {a.name for a in summ['other_agents']}, summ desc = finder.describe() m = re.match(r'Overall, I found that (.*?) can affect ' r'ZEB1..*', desc) assert m is not None, desc assert "MEK" in m.group(0), m.group(0) assert "KRAS" in m.group(0), m.group(0)
def test_get_sign(): ag = Agent('EGFR', db_refs={'HGNC': '3236'}) # When entity role is object, sign is always 0 (sign of upstream node) query = OpenSearchQuery(ag, 'Inhibition', 'object', ['chebi']) for mc_type in ['pysb', 'pybel', 'signed_graph', 'unsigned_graph']: assert query.get_sign(mc_type) == 0 # Entity role is subject # Always 0 for unsigned graph query = OpenSearchQuery(ag, 'Inhibition', 'subject', ['chebi']) assert query.get_sign('unsigned_graph') == 0 # For others, depends on statement type for mc_type in ['pysb', 'pybel', 'signed_graph']: assert query.get_sign(mc_type) == 1 query = OpenSearchQuery(ag, 'Activation', 'subject', ['chebi']) for mc_type in ['pysb', 'pybel', 'signed_graph']: assert query.get_sign(mc_type) == 0
def suggest_relevant_relations(groundings): def make_nice_list(lst): if len(lst) == 1: return lst[0] pre = ', '.join(lst[:-1]) full = '%s, or %s' % (pre, lst[-1]) return full prefix1 = 'By the way, I recognized' prefix2 = 'I also recognized' msg_parts = [] for entity_txt, (dbn, dbi) in groundings.items(): if dbn == 'FPLX': ag = Agent(name=entity_txt, db_refs={dbn: dbi}) children = expander.get_children(ag) print(children) if not children: continue children_names = [ch[1] for ch in children] children_str = make_nice_list(children_names) prefix = prefix1 if not msg_parts else prefix2 msg = ('%s "%s" as a family or complex, ' 'you might be interested in asking about some of its ' 'specific members like %s.') % (prefix, entity_txt, children_str) msg_parts.append(msg) if dbn == 'HGNC': name = hgnc_client.get_hgnc_name(dbi) uri = expander.entities.get_uri(dbn, name) print(uri) parent_uris = expander.entities.get_parents(uri) parents = [ expand_families._agent_from_uri(uri) for uri in parent_uris ] print(parents) if not parents: continue parent_names = [p.name for p in parents] parents_str = make_nice_list(parent_names) prefix = prefix1 if not msg_parts else prefix2 msg = ('%s "%s" as a protein that is part of a family or complex, ' 'you might be interested in asking about some of those too ' 'like %s.') % (prefix, entity_txt, parents_str) msg_parts.append(msg) full_msg = ' '.join(msg_parts) return full_msg
def get_kinase_activities(): kinase_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../resources/kinases.tsv') kinases = [] with open(kinase_file, 'rt') as fh: lines = [l.strip() for l in fh.readlines()] for lin in lines[1:]: up_id, hgnc_name, _, _ = lin.split('\t') hgnc_id = hgnc_client.get_hgnc_id(hgnc_name) agent = Agent(hgnc_name, db_refs={'UP': up_id, 'HGNC': hgnc_id}) kinases.append(agent) kin_activities = [] from indra.statements import HasActivity for kin in kinases: stmt = HasActivity(kin, 'kinase', True) kin_activities.append(stmt) return kin_activities
def get_antibody_map(data): phos_ab_map = get_phospho_antibody_map() ab_map = {} for _, row in data['antibody'].iterrows(): ab_name = row['Protein Data ID'] if ab_name in phos_ab_map: continue upids = row['UniProt ID'].split(',') for upid in upids: hgnc_symbol = uniprot_client.get_gene_name(upid) hgnc_id = hgnc_client.get_hgnc_id(hgnc_symbol) target = Agent(hgnc_symbol, db_refs={'UP': upid, 'HGNC': hgnc_id}) try: ab_map[ab_name].append(target) except KeyError: ab_map[ab_name] = [target] ab_map.update(phos_ab_map) return ab_map
def test_filter_eidos_ungrounded(): stmts = [ # Grounded Eidos Activation(Agent('A', db_refs={'HGNC': '1097'}), Agent('B', db_refs={'HGNC': '6840'}), evidence=[ Evidence(text='A activates B.', source_api='eidos', text_refs={'TRID': '1234'}) ]), # Ungrounded Eidos Activation(Agent('B', db_refs={'TEXT': 'B'}), Agent('C', db_refs={'TEXT': 'C'}), evidence=[ Evidence(text='B activates C.', source_api='eidos', text_refs={'TRID': '2345'}) ]), # Grounded not Eidos Activation(Agent('C', db_refs={'HGNC': '1097'}), Agent('D', db_refs={'HGNC': '6840'}), evidence=[ Evidence(text='C activates D.', source_api='trips', text_refs={'TRID': '1234'}) ]), # Ungrounded not Eidos Activation(Agent('D', db_refs={'TEXT': 'D'}, activity=ActivityCondition('activity', True)), Agent('E', db_refs={'TEXT': 'E'}), evidence=[ Evidence(text='D activates E.', source_api='trips', text_refs={'TRID': '2345'}) ]) ] hashes = [stmt.get_hash() for stmt in stmts] filtered = filter_eidos_ungrounded(stmts) assert len(filtered) == 3 filtered_hashes = [stmt.get_hash() for stmt in filtered] assert set(hashes) - set(filtered_hashes) == {hashes[1]}
def test_find_contradicts_refinement(): ras = Agent('RAS', db_refs={'FPLX': 'RAS'}) kras = Agent('KRAS', db_refs={'HGNC': '6407'}) hras = Agent('HRAS', db_refs={'HGNC': '5173'}) st1 = Phosphorylation(Agent('x'), ras) st2 = Dephosphorylation(Agent('x'), kras) st3 = Dephosphorylation(Agent('x'), hras) pa = Preassembler(hierarchies, [st1, st2, st3]) contradicts = pa.find_contradicts() assert len(contradicts) == 2 for s1, s2 in contradicts: assert {s1.uuid, s2.uuid} in ({st1.uuid, st2.uuid}, {st1.uuid, st3.uuid})