def test_get_ids(): time.sleep(0.3) ids1 = pubmed_client.get_ids('JUN', use_text_word=False) ids2 = pubmed_client.get_ids('JUN', use_text_word=True) assert len(ids1) > len(ids2) assert unicode_strs(ids1) assert unicode_strs(ids2)
def test_pybel_neighborhood_query(): corpus = path_this + '/../../data/small_corpus.bel' bp = bel.process_pybel_neighborhood(['TP63'], corpus) assert bp.statements assert_pmids(bp.statements) unicode_strs(bp.statements) assert all([s.evidence[0].context.cell_line.name == 'MCF 10A' for s in bp.statements]) assert bp.statements[0].evidence[0].context.__repr__() == \ bp.statements[0].evidence[0].context.__str__() assert bp.statements[0].evidence[0].context == \ BioContext(location=RefContext(name="Cytoplasm", db_refs={'MESH': 'D003593'}), cell_line=RefContext(name="MCF 10A", db_refs={'EFO': '0001200'}), cell_type=RefContext(name="keratinocyte", db_refs={'CL': '0000312'}), organ=RefContext(name="colon", db_refs={'UBERON': '0001155'}), disease=RefContext(name="cancer", db_refs={'DOID': '162'}), species=RefContext(name="Rattus norvegicus", db_refs={'TAXONOMY': '10116'})) # Test annotation manager assert bp.annot_manager.get_mapping('Species', '9606') == \ 'H**o sapiens'
def test_get_children(): raf = 'http://identifiers.org/fplx/RAF' braf = 'http://identifiers.org/hgnc.symbol/BRAF' mapk = 'http://identifiers.org/fplx/MAPK' ampk = 'http://identifiers.org/fplx/AMPK' # Look up RAF rafs = ent_hierarchy.get_children(raf) # Should get three family members assert isinstance(rafs, list), rafs assert len(rafs) == 3 assert unicode_strs(rafs) # The lookup of a gene-level entity should not return any additional # entities brafs = ent_hierarchy.get_children(braf) assert isinstance(brafs, list) assert len(brafs) == 0 assert unicode_strs(brafs) mapks = ent_hierarchy.get_children(mapk) assert len(mapks) == 12 assert unicode_strs(mapks) # Make sure we can also do this in a case involving both family and complex # relationships ampks = ent_hierarchy.get_children(ampk) assert len(ampks) == 22 ag_none = '' none_children = ent_hierarchy.get_children('') assert isinstance(none_children, list) assert len(none_children) == 0
def test_parse_site_residue_only(): text = ['serine residue', 'serine', 'a serine site', 's', 'ser'] assert unicode_strs(text) for t in text: residue, site = ReachProcessor._parse_site_text(t) assert unicode_strs((residue, site)) assert(residue == 'S') assert(site is None)
def test_hierarchy_unicode(): # Test all the hierarchies except the comp_hierarchy, which is an # RDF graph assert unicode_strs((ent_hierarchy.isa_closure, ent_hierarchy.partof_closure)) assert unicode_strs((mod_hierarchy.isa_closure, mod_hierarchy.partof_closure)) assert unicode_strs((act_hierarchy.isa_closure, act_hierarchy.partof_closure))
def test_get_gz_object(): # Get XML key = 'papers/PMID27297883/fulltext/txt' obj = s3_client.get_gz_object(key) assert unicode_strs(obj) # Get reach output key = 'papers/PMID27297883/reach' obj = s3_client.get_gz_object(key) assert unicode_strs(obj)
def test_query_protein_deprecated(): g = uniprot_client.query_protein('Q8NHX1') assert g is not None gene_name = uniprot_client.get_gene_name('Q8NHX1') assert gene_name == 'MAPK3' assert unicode_strs(gene_name) gene_name = uniprot_client.get_gene_name('Q8NHX1', web_fallback=False) assert gene_name == 'MAPK3' assert unicode_strs(gene_name)
def test_parse_site_text(): text = ['threonine 185', 'thr 185', 'thr-185', 'threonine residue 185', 'T185'] assert unicode_strs(text) for t in text: residue, site = ReachProcessor._parse_site_text(t) assert(residue == 'T') assert(site == '185') assert unicode_strs((residue, site))
def test_check_pmid(): pmid = s3_client.check_pmid(12345) assert pmid == 'PMID12345' assert unicode_strs(pmid) pmid = s3_client.check_pmid('12345') assert pmid == 'PMID12345' assert unicode_strs(pmid) pmid = s3_client.check_pmid('PMID12345') assert pmid == 'PMID12345' assert unicode_strs(pmid)
def test_parse_site_residue_only(): text = ['serine residue', 'serine', 'a serine site', 's', 'ser'] assert unicode_strs(text) for t in text: sites = ReachProcessor._parse_site_text(t) assert len(sites) == 1 residue, site = sites[0] assert unicode_strs((residue, site)) assert residue == 'S' assert site is None
def test_parse_site_text(): text = ['threonine 185', 'thr 185', 'thr-185', 'threonine residue 185', 'T185'] assert unicode_strs(text) for t in text: sites = ReachProcessor._parse_site_text(t) assert len(sites) == 1 residue, site = sites[0] assert residue == 'T' assert site == '185' assert unicode_strs((residue, site))
def test_get_full_text(): (content, content_type) = s3_client.get_full_text('27297883') assert unicode_strs((content, content_type)) assert content_type == 'txt' (content, content_type) = s3_client.get_full_text('1001287') assert unicode_strs((content, content_type)) assert content_type == 'pmc_oa_xml' # TODO: Find a paper that has only abstract #(content, content_type) = s3_client.get_full_text('27653174') #assert unicode_strs((content, content_type)) #assert content_type == 'abstract' (content, content_type) = s3_client.get_full_text('000000') assert content is None and content_type is None
def test_get_children(): exp = ef.Expander(hierarchies) raf = Agent('RAF', db_refs={'FPLX':'RAF'}) braf = Agent('BRAF', db_refs={'HGNC':'1097'}) # Look up RAF rafs = exp.get_children(raf) # Should get three family members assert isinstance(rafs, list) assert len(rafs) == 3 assert unicode_strs(rafs) # The lookup of a gene-level entity should not return any additional # entities brafs = exp.get_children(braf) assert isinstance(brafs, list) assert len(brafs) == 0 assert unicode_strs(brafs) # The lookup for a top-level family (e.g., MAPK, which has as children # both the intermediate family ERK as well as all MAPK1-15 members) # should not return the intermediate families when a filter is applied. mapk = Agent('MAPK', db_refs={'FPLX':'MAPK'}) mapks = exp.get_children(mapk, ns_filter=None) assert len(mapks) == 12 assert ('HGNC', 'MAPK1') in mapks assert ('HGNC', 'MAPK9') in mapks assert ('FPLX', 'ERK') in mapks assert ('FPLX', 'JNK') in mapks assert unicode_strs(mapks) # Now do the same expansion with a namespace filter mapks = exp.get_children(mapk, ns_filter='HGNC') assert unicode_strs(mapks) assert len(mapks) == 9 assert ('HGNC', 'MAPK3') in mapks assert ('HGNC', 'MAPK10') in mapks assert ('FPLX', 'ERK') not in mapks # Make sure we can also do this in a case involving both family and complex # relationships ampk = Agent('AMPK', db_refs={'FPLX':'AMPK'}) ampks = exp.get_children(ampk, ns_filter=None) assert len(ampks) == 22 ampks = exp.get_children(ampk, ns_filter='HGNC') assert len(ampks) == 7 # Test that the default filter is HGNC ampks = exp.get_children(ampk) assert len(ampks) == 7 ag_none = None none_children = exp.get_children(ag_none) assert isinstance(none_children, list) assert len(none_children) == 0
def test_get_protein_expression(): res = context_client.get_protein_expression(['EGFR'], ['BT20_BREAST']) assert res is not None assert res.get('BT20_BREAST') is not None assert res['BT20_BREAST'].get('EGFR') is not None assert res['BT20_BREAST']['EGFR'] > 1000 assert unicode_strs(res)
def test_check_agent_mod(): mapk1_valid = Agent('MAPK1', mods=[ModCondition('phosphorylation', 'T', '185'), ModCondition('phosphorylation', 'Y', '187')], db_refs={'UP': 'P28482'}) mapped_sites_valid, _ = sm._map_agent_sites(mapk1_valid) assert not mapped_sites_valid, mapped_sites_valid mapk1_invalid = Agent('MAPK1', mods=[ModCondition('phosphorylation', 'T', '183'), ModCondition('phosphorylation', 'Y', '185')], db_refs={'UP': 'P28482'}) mapped_sites_invalid, new_agent = sm._map_agent_sites(mapk1_invalid) assert len(mapped_sites_invalid) == 2 assert isinstance(mapped_sites_invalid[0], MappedSite) map183 = mapped_sites_invalid[0] assert (map183.up_id, map183.orig_res, map183.orig_pos, map183.mapped_res, map183.mapped_pos) == \ ('P28482', 'T', '183', 'T', '185'), map183 map185 = mapped_sites_invalid[1] assert (map185.up_id, map185.orig_res, map185.orig_pos, map185.mapped_res, map185.mapped_pos) == \ ('P28482', 'Y', '185', 'Y', '187'), map183 assert len(new_agent.mods) == 2 assert new_agent.mods[0].matches(ModCondition('phosphorylation', 'T', '185')) assert new_agent.mods[1].matches(ModCondition('phosphorylation', 'Y', '187')) assert unicode_strs((mapk1_valid, mapk1_invalid, mapped_sites_invalid, mapped_sites_valid, map183, map185, new_agent))
def test_pathsfromto(): bp = biopax.process_pc_pathsfromto(['MAP2K1'], ['MAPK1']) bp.get_phosphorylation() assert_pmids(bp.statements) pre = Preassembler(hierarchies, bp.statements) pre.combine_related() assert unicode_strs(pre.unique_stmts)
def test_all_hgnc_ids(): for obj in bp.model.getObjects().toArray(): bpe = bpc._cast_biopax_element(obj) if bpc._is_protein(bpe): hgnc_id = bp._get_hgnc_id(bpe) if hgnc_id is not None: assert(unicode_strs(hgnc_id))
def check_validated_mapks(res, st1): """Validate that the invalid MAPKs have been fixed appropriately.""" assert len(res) == 2 valid_stmts = res[0] mapped_stmts = res[1] assert isinstance(valid_stmts, list) assert isinstance(mapped_stmts, list) assert len(valid_stmts) == 0 assert len(mapped_stmts) == 1 mapped_stmt = mapped_stmts[0] assert isinstance(mapped_stmt, MappedStatement) assert mapped_stmt.original_stmt == st1 assert isinstance(mapped_stmt.mapped_mods, list) assert len(mapped_stmt.mapped_mods) == 4 ms = mapped_stmt.mapped_stmt assert isinstance(ms, Statement) agents = ms.agent_list() assert len(agents) == 2 agent1 = agents[0] agent2 = agents[1] assert agent1.name == 'MAPK1' assert len(agent1.mods) == 2 assert agent1.mods[0].matches(ModCondition('phosphorylation', 'T', '185')) assert agent1.mods[1].matches(ModCondition('phosphorylation', 'Y', '187')) assert agent2.mods[0].matches(ModCondition('phosphorylation', 'T', '202')) assert agent2.mods[1].matches(ModCondition('phosphorylation', 'Y', '204')) assert unicode_strs((res, st1))
def test_get_mutations(): res = context_client.get_mutations('BRAF', 'A375_SKIN') assert(res is not None) assert(res.get('BRAF') is not None) assert(res['BRAF'].get('A375_SKIN') is not None) assert(res['BRAF']['A375_SKIN'] == 1.0) assert unicode_strs(res)
def test_get_fulltext_links(): links = crossref_client.get_fulltext_links(test_doi) assert(links[0]['content-type'] == 'text/xml') assert(links[1]['content-type'] == 'text/plain') assert unicode_strs(links) links = crossref_client.get_fulltext_links('xyz') assert(links is None)
def _from_json(cls, json_dict): position = json_dict.get('position') residue_from = json_dict.get('residue_from') residue_to = json_dict.get('residue_to') mc = cls(position, residue_from, residue_to) assert(unicode_strs(mc)) return mc
def test_pathsfromto(): bp = biopax.process_pc_pathsfromto(['MAP2K1'], ['MAPK1']) assert_pmids(bp.statements) assert_source_sub_id(bp.statements) assert unicode_strs(bp.statements) num_unique = len({s.get_hash(shallow=False) for s in bp.statements}) assert len(bp.statements) == num_unique
def test_reach_output(): # Test put_reach_output reach_data = {'foo': 1, 'bar':{'baz': 2}} pmid = 'PMID000test3' reach_version = '42' source_text = 'pmc_oa_txt' s3_client.put_reach_output(reach_data, pmid, reach_version, source_text) # Now get the data back retrieved_reach_data = s3_client.get_reach_output(pmid) assert retrieved_reach_data == reach_data assert unicode_strs(retrieved_reach_data) # Get the reach version of the key we created (ret_reach_version, ret_source_text) = s3_client.get_reach_metadata(pmid) assert ret_reach_version == reach_version assert ret_source_text == source_text assert unicode_strs(ret_reach_version)
def test_get_pmc_ids(): time.sleep(0.3) ids = pubmed_client.get_ids('braf', retmax=10, db='pmc') assert len(ids) == 10 assert len([i for i in ids if i.startswith('6') or i.startswith('5')]) == 10 assert unicode_strs(ids)
def test_get_mutations(): res = context_client.get_mutations(['BRAF'], ['A375_SKIN']) assert res is not None assert res.get('A375_SKIN') is not None assert res['A375_SKIN'].get('BRAF') is not None assert res['A375_SKIN']['BRAF'] == ['V600E'] assert unicode_strs(res)
def test_id_lookup_no_pmid(): """Look up a paper that has a PMCID and DOI but not PMID.""" res = id_lookup('10.1083/jcb.1974if', 'doi') assert res['pmcid'] == 'PMC3352949' res = id_lookup('PMC3352949', 'pmcid') assert res['doi'] == '10.1083/jcb.1974if' assert unicode_strs(res)
def test_get_fulltext_links(): links = crossref_client.get_fulltext_links(test_doi) content_types = [l.get('content-type') for l in links] assert 'text/plain' in content_types assert 'text/xml' in content_types assert unicode_strs(links) links = crossref_client.get_fulltext_links('xyz') assert links is None
def test_phosphorylate(): for offline in offline_modes: rp = reach.process_text('MEK1 phosphorylates ERK2.', offline=offline) assert(len(rp.statements) == 1) s = rp.statements[0] assert (s.enz.name == 'MAP2K1') assert (s.sub.name == 'MAPK1') assert unicode_strs(rp.statements)
def test_activate(): for offline in offline_modes: rp = reach.process_text('HRAS activates BRAF.', offline=offline) assert(len(rp.statements) == 1) s = rp.statements[0] assert (s.subj.name == 'HRAS') assert (s.obj.name == 'BRAF') assert unicode_strs(rp.statements)
def test_all_uniprot_ids(): for obj in bp.model.getObjects().toArray(): bpe = bpc._cast_biopax_element(obj) if bpc._is_protein(bpe): uniprot_id = bp._get_uniprot_id(bpe) if uniprot_id is not None: assert(not uniprot_client.is_secondary(uniprot_id)) assert(unicode_strs(uniprot_id))
def test_put_full_text(): full_text = 'test_put_full_text' pmid_test = 'PMID000test1' s3_client.put_full_text(pmid_test, full_text, full_text_type='pmc_oa_txt') # Get the full text back (content, content_type) = s3_client.get_full_text(pmid_test) assert content == full_text assert content_type == 'pmc_oa_txt' assert unicode_strs(content)
def test_save_sentences_unicode(): mek = Agent('MEK', db_refs={'TEXT': 'MAP2K1'}) ev = Evidence(source_api='reach', pmid='PMID000asdf', text='foo\U0001F4A9bar') st = Phosphorylation(None, mek, evidence=[ev]) sent = get_sentences_for_agent('MAP2K1', [st]) assert unicode_strs(sent) twg = agent_texts_with_grounding([st]) save_sentences(twg, [st], 'test_save_sentences.csv')
def test_put_abstract(): abstract = 'test_put_abstract' pmid_test = 'PMID000test2' s3_client.put_abstract(pmid_test, abstract) # Get the abstract back (content, content_type) = s3_client.get_full_text(pmid_test) assert content == abstract assert content_type == 'abstract' assert unicode_strs(content)
def test_be_grounding(): for offline in offline_modes: rp = reach.process_text('MEK activates ERK.', offline=offline) assert(len(rp.statements) == 1) assert unicode_strs(rp.statements) if offline is True: st = rp.statements[0] assert(st.subj.db_refs.get('FPLX') == 'MEK') assert(st.obj.db_refs.get('FPLX') == 'ERK')
def test_ubiquitination(): tp = trips.process_text('MDM2 ubiquitinates TP53.') assert (len(tp.statements) == 1) st = tp.statements[0] assert (isinstance(st, ist.Ubiquitination)) assert unicode_strs((tp, st)) assert_grounding_value_or_none(st) assert_if_hgnc_then_up(st) assert (st.evidence)
def test_simple_mapping(): akt = Agent('pkbA', db_refs={'TEXT': 'Akt', 'UP': 'XXXXXX'}) stmt = Phosphorylation(None, akt) mapped_stmts = gm.map_stmts([stmt]) assert len(mapped_stmts) == 1 mapped_akt = mapped_stmts[0].sub assert mapped_akt.db_refs['TEXT'] == 'Akt' assert mapped_akt.db_refs['FPLX'] == 'AKT' assert unicode_strs((akt, stmt, gm, mapped_akt))
def test_phosphorylate(): for offline in offline_modes: rp = reach.process_text('MEK1 phosphorylates ERK2.', offline=offline) assert rp is not None assert len(rp.statements) == 1 s = rp.statements[0] assert (s.enz.name == 'MAP2K1') assert (s.sub.name == 'MAPK1') assert unicode_strs(rp.statements)
def test_regulate_amount(): for offline in offline_modes: rp = reach.process_text('ERK increases the transcription of DUSP.', offline=offline) assert(len(rp.statements) == 1) s = rp.statements[0] assert(isinstance(s, IncreaseAmount)) assert (s.subj.name == 'ERK') assert (s.obj.name == 'DUSP') assert unicode_strs(rp.statements) rp = reach.process_text('ERK decreases the amount of DUSP.', offline=offline) assert(len(rp.statements) == 1) s = rp.statements[0] assert(isinstance(s, DecreaseAmount)) assert (s.subj.name == 'ERK') assert (s.obj.name == 'DUSP') assert unicode_strs(rp.statements)
def test_reach_output(): # Test put_reach_output reach_data = {'foo': 1, 'bar': {'baz': 2}} pmid = 'PMID000test3' reach_version = '42' source_text = 'pmc_oa_txt' s3_client.put_reader_output('reach', reach_data, pmid, reach_version, source_text) # Now get the data back retrieved_reach_data = s3_client.get_reader_output('reach', pmid) assert retrieved_reach_data == reach_data assert unicode_strs(retrieved_reach_data) # Get the reach version of the key we created ret_reach_version, ret_source_text = \ s3_client.get_reader_metadata('reach', pmid) assert ret_reach_version == reach_version assert ret_source_text == source_text assert unicode_strs(ret_reach_version)
def test_activate(): for offline in offline_modes: rp = reach.process_text('HRAS activates BRAF.', offline=offline) assert rp is not None assert len(rp.statements) == 1 s = rp.statements[0] assert (s.subj.name == 'HRAS') assert (s.obj.name == 'BRAF') assert unicode_strs(rp.statements)
def test_get_agent_up_from_hgnc(): hgnc_sym = 'MAPK1' concept = concept_prefix + hgnc_sym entity = entity_prefix + 'p_HGNC_' + hgnc_sym ag = BelProcessor.get_agent(concept, entity) assert ag.name == 'MAPK1' assert ag.db_refs.get('HGNC') == '6871' assert ag.db_refs.get('UP') == 'P28482' assert unicode_strs((concept, entity, ag))
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_reg_amount_complex_controller(): txt = 'The FOS-JUN complex increases the amount of ZEB2.' for offline in offline_modes: rp = reach.process_text(txt, offline=offline) assert len(rp.statements) == 2 cplx = [s for s in rp.statements if isinstance(s, Complex)][0] regam = [s for s in rp.statements if isinstance(s, IncreaseAmount)][0] assert {a.name for a in cplx.members} == {'FOS_family', 'JUN'} assert len(regam.subj.bound_conditions) == 1 assert unicode_strs(rp.statements)
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_agent_hgnc_up_from_egid(): entrez_id = '5594' concept = concept_prefix + entrez_id entity = entity_prefix + 'p_EGID_' + entrez_id ag = BelProcessor.get_agent(concept, entity) assert ag.name == 'MAPK1' assert ag.db_refs.get('EGID') == entrez_id assert ag.db_refs.get('HGNC') == '6871' assert ag.db_refs.get('UP') == 'P28482' assert unicode_strs((concept, entity, ag))
def test_degradation(): tp = trips.process_text('MDM2 degrades TP53.') assert len(tp.statements) == 1 st = tp.statements[0] assert isinstance(st, ist.DecreaseAmount) assert st.subj is not None assert st.obj is not None assert unicode_strs((tp, st)) assert_if_hgnc_then_up(st) assert_grounding_value_or_none(st) assert st.evidence
def test_phosphorylation_noresidue(): tp = trips.process_text('BRAF phosphorylates MEK1.') assert (len(tp.statements) == 1) st = tp.statements[0] assert (isinstance(st, ist.Phosphorylation)) assert (st.residue is None) assert (st.position is None) assert unicode_strs((tp, st)) assert_if_hgnc_then_up(st) assert_grounding_value_or_none(st) assert (st.evidence)
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
def test_phosphorylation_nosite(): tp = trips.process_text('BRAF phosphorylates MEK1 at Serine.') assert len(tp.statements) == 1 st = tp.statements[0] assert isinstance(st, ist.Phosphorylation) assert st.residue == 'S' assert st.position is None assert unicode_strs((tp, st)) assert_if_hgnc_then_up(st) assert_grounding_value_or_none(st) assert st.evidence
def test_synthesis(): tp = trips.process_text('NFKB transcribes IKB.') assert len(tp.statements) == 1 st = tp.statements[0] assert isinstance(st, ist.IncreaseAmount) assert st.subj is not None assert st.obj is not None assert unicode_strs((tp, st)) assert_if_hgnc_then_up(st) assert_grounding_value_or_none(st) assert st.evidence
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_actform_bound(): tp = trips.process_text('HRAS bound to GTP is activated.') assert len(tp.statements) == 1 st = tp.statements[0] assert isinstance(st, ist.ActiveForm) assert isinstance(st.agent.bound_conditions[0], ist.BoundCondition) assert st.agent.bound_conditions[0].agent.name == 'GTP' assert st.agent.bound_conditions[0].is_bound == True assert unicode_strs((tp, st)) assert_if_hgnc_then_up(st) assert_grounding_value_or_none(st) assert st.evidence
def test_mutation(): for offline in offline_modes: rp = reach.process_text('BRAF(V600E) phosphorylates MEK.', offline=offline) assert (len(rp.statements) == 1) braf = rp.statements[0].enz assert (braf.name == 'BRAF') assert (len(braf.mutations) == 1) assert (braf.mutations[0].position == '600') assert (braf.mutations[0].residue_from == 'V') assert (braf.mutations[0].residue_to == 'E') assert unicode_strs(rp.statements)
def test_phosphorylation(): tp = trips.process_text('BRAF phosphorylates MEK1 at Ser222.') assert len(tp.statements) == 1 st = tp.statements[0] assert isinstance(st, ist.Phosphorylation) assert st.residue == 'S' assert st.position == '222' assert st.evidence assert_if_hgnc_then_up(st) assert_grounding_value_or_none(st) assert st.sub.db_refs['TEXT'] == 'MEK1' assert unicode_strs((tp, st))
def get_invalid_mapks(): """A handy function for getting the invalid MAPK agents we want.""" mapk1_invalid = Agent('MAPK1', mods=[ModCondition('phosphorylation', 'T', '183'), ModCondition('phosphorylation', 'Y', '185')], db_refs={'UP': 'P28482'}) mapk3_invalid = Agent('MAPK3', mods=[ModCondition('phosphorylation', 'T', '201'), ModCondition('phosphorylation', 'Y', '203')], db_refs={'UP': 'P27361'}) assert unicode_strs((mapk1_invalid, mapk3_invalid)) return (mapk1_invalid, mapk3_invalid)
def test_actmods2(): tp = trips.process_text('BRAF phosphorylated at Ser536 binds MEK1.') assert len(tp.statements) == 1 st = tp.statements[0] assert isinstance(st, ist.Complex) braf = st.members[0] assert braf.mods[0].mod_type == 'phosphorylation' assert braf.mods[0].residue == 'S' assert braf.mods[0].position == '536' assert unicode_strs((tp, st, braf)) assert_if_hgnc_then_up(st) assert_grounding_value_or_none(st) assert st.evidence
def test_actmod(): tp = trips.process_text('MEK1 phosphorylated at Ser222 is activated.') assert len(tp.statements) == 1 st = tp.statements[0] assert isinstance(st, ist.ActiveForm) assert isinstance(st.agent.mods[0], ist.ModCondition) assert st.agent.mods[0].mod_type == 'phosphorylation' assert st.agent.mods[0].residue == 'S' assert st.agent.mods[0].position == '222' assert unicode_strs((tp, st)) assert_if_hgnc_then_up(st) assert_grounding_value_or_none(st) assert st.evidence
def test_simple_decrease(): tp = trips.process_text('Selumetinib decreases FOS.') assert len(tp.statements) == 1 st = tp.statements[0] assert isinstance(st, ist.DecreaseAmount) assert st.subj is not None assert st.obj is not None assert st.subj.name.upper() == 'SELUMETINIB' assert st.obj.name.upper() == 'FOS' assert unicode_strs((tp, st)) assert_if_hgnc_then_up(st) assert_grounding_value_or_none(st) assert st.evidence
def test_actform_muts(): tp = trips.process_text('BRAF V600E is activated.') assert len(tp.statements) == 1 st = tp.statements[0] assert isinstance(st, ist.ActiveForm) assert isinstance(st.agent.mutations[0], ist.MutCondition) assert st.agent.mutations[0].residue_from == 'V' assert st.agent.mutations[0].residue_to == 'E' assert st.agent.mutations[0].position == '600' assert unicode_strs((tp, st)) assert_if_hgnc_then_up(st) assert_grounding_value_or_none(st) assert st.evidence
def test_hgnc_from_up(): for offline in offline_modes: rp = reach.process_text('MEK1 phosphorylates ERK2.', offline=offline) assert len(rp.statements) == 1 st = rp.statements[0] (map2k1, mapk1) = st.agent_list() assert map2k1.name == 'MAP2K1' assert map2k1.db_refs['HGNC'] == '6840' assert map2k1.db_refs['UP'] == 'Q02750' assert mapk1.name == 'MAPK1' assert mapk1.db_refs['HGNC'] == '6871' assert mapk1.db_refs['UP'] == 'P28482' assert unicode_strs(rp.statements)