Пример #1
0
def process_paper(model_name, pmid):
    json_path = os.path.join(model_name, 'jsons', 'PMID%s.json' % pmid)

    if pmid.startswith('api') or pmid.startswith('PMID'):
        logger.warning('Invalid PMID: %s' % pmid)
    # If the paper has been read, use the json output file
    if os.path.exists(json_path):
        rp = reach.process_json_file(json_path, citation=pmid)
        txt_format = 'existing_json'
    # If the paper has not been read, download the text and read
    else:
        try:
            txt, txt_format = get_full_text(pmid, 'pmid')
        except:
            return None, None

        if txt_format == 'pmc_oa_xml':
            rp = reach.process_nxml_str(txt, citation=pmid, offline=True)
            if os.path.exists('reach_output.json'):
                shutil.move('reach_output.json', json_path)
        elif txt_format == 'elsevier_xml':
            # Extract the raw text from the Elsevier XML
            txt = elsevier_client.extract_text(txt)
            rp = reach.process_text(txt, citation=pmid, offline=True)
            if os.path.exists('reach_output.json'):
                shutil.move('reach_output.json', json_path)
        elif txt_format == 'abstract':
            rp = reach.process_text(txt, citation=pmid, offline=True)
            if os.path.exists('reach_output.json'):
                shutil.move('reach_output.json', json_path)
        else:
            rp = None
    if rp is not None:
        check_pmids(rp.statements)
    return rp, txt_format
Пример #2
0
def process_paper(model_name, pmid):
    """Process a paper with the given pubmed identifier

    Parameters
    ----------
    model_name : str
        The directory for the INDRA machine
    pmid : str
        The PMID to process.

    Returns
    -------
    rp : ReachProcessor
        A ReachProcessor containing the extracted INDRA Statements
        in rp.statements.
    txt_format : str
        A string representing the format of the text
    """
    json_directory = os.path.join(model_name, 'jsons')
    json_path = os.path.join(json_directory, 'PMID%s.json' % pmid)

    if pmid.startswith('api') or pmid.startswith('PMID'):
        logger.warning('Invalid PMID: %s' % pmid)
    # If the paper has been read, use the json output file
    if os.path.exists(json_path):
        rp = reach.process_json_file(json_path, citation=pmid)
        txt_format = 'existing_json'
    # If the paper has not been read, download the text and read
    else:
        try:
            txt, txt_format = get_full_text(pmid, 'pmid')
        except Exception:
            return None, None

        if txt_format == 'pmc_oa_xml':
            rp = reach.process_nxml_str(txt,
                                        citation=pmid,
                                        offline=True,
                                        output_fname=json_path)
        elif txt_format == 'elsevier_xml':
            # Extract the raw text from the Elsevier XML
            txt = elsevier_client.extract_text(txt)
            rp = reach.process_text(txt,
                                    citation=pmid,
                                    offline=True,
                                    output_fname=json_path)
        elif txt_format == 'abstract':
            rp = reach.process_text(txt,
                                    citation=pmid,
                                    offline=True,
                                    output_fname=json_path)
        else:
            rp = None
    if rp is not None:
        check_pmids(rp.statements)
    return rp, txt_format
Пример #3
0
def process_paper(model_name, pmid):
    """Process a paper with the given pubmed identifier

    Parameters
    ----------
    model_name : str
        The directory for the INDRA machine
    pmid : str
        The PMID to process.

    Returns
    -------
    rp : ReachProcessor
        A ReachProcessor containing the extracted INDRA Statements
        in rp.statements.
    txt_format : str
        A string representing the format of the text
    """
    json_directory = os.path.join(model_name, 'jsons')
    json_path = os.path.join(json_directory, 'PMID%s.json' % pmid)

    if pmid.startswith('api') or pmid.startswith('PMID'):
        logger.warning('Invalid PMID: %s' % pmid)
    # If the paper has been read, use the json output file
    if os.path.exists(json_path):
        rp = reach.process_json_file(json_path, citation=pmid)
        txt_format = 'existing_json'
    # If the paper has not been read, download the text and read
    else:
        try:
            txt, txt_format = get_full_text(pmid, 'pmid')
        except Exception:
            return None, None

        if txt_format == 'pmc_oa_xml':
            rp = reach.process_nxml_str(txt, citation=pmid, offline=True,
                                        output_fname=json_path)
        elif txt_format == 'elsevier_xml':
            # Extract the raw text from the Elsevier XML
            txt = elsevier_client.extract_text(txt)
            rp = reach.process_text(txt, citation=pmid, offline=True,
                                    output_fname=json_path)
        elif txt_format == 'abstract':
            rp = reach.process_text(txt, citation=pmid, offline=True,
                                    output_fname=json_path)
        else:
            rp = None
    if rp is not None:
        check_pmids(rp.statements)
    return rp, txt_format
Пример #4
0
def run_reading(text_contents, cached=True):
    organism_preference = None
    stmts = {}
    for trid, text_content in text_contents.items():
        print('Reading %s' % trid)
        output_fname = os.path.join(NEW_REACH_PATH, '%s.json' % trid)
        if cached and os.path.exists(output_fname):
            rp = reach.process_json_file(output_fname)
            if rp is None:
                continue
        else:
            if text_content.startswith('<!DOCTYPE'):
                rp = reach.process_nxml_str(
                    text_content,
                    url=reach.local_nxml_url,
                    output_fname=output_fname,
                    organism_priority=organism_preference)
            else:
                rp = reach.process_text(text_content,
                                        url=reach.local_text_url,
                                        output_fname=output_fname,
                                        organism_priority=organism_preference)
        if rp is not None:
            stmts[trid] = rp.statements
    return stmts
Пример #5
0
def test_get_agent_coordinates_binding():
    test_case = 'Everyone has observed that MEK1 binds ERK2'
    for offline in offline_modes:
        rp = reach.process_text(test_case, offline=offline)
        stmt = rp.statements[0]
        annotations = stmt.evidence[0].annotations
        coords = [(27, 31), (38, 42)]
        assert annotations['agents']['coords'] == coords
Пример #6
0
def test_get_agent_coordinates_regulate_amount():
    test_case = 'ERK increases the transcription of DUSP'
    for offline in offline_modes:
        rp = reach.process_text(test_case, offline=offline)
        stmt = rp.statements[0]
        annotations = stmt.evidence[0].annotations
        coords = [(0, 3), (35, 39)]
        assert annotations['agents']['coords'] == coords
Пример #7
0
def test_get_agent_coordinates_activation():
    test_case = 'MEK1 activates ERK2'
    for offline in offline_modes:
        rp = reach.process_text(test_case, offline=offline)
        stmt = rp.statements[0]
        annotations = stmt.evidence[0].annotations
        coords = [(0, 4), (15, 19)]
        assert annotations['agents']['coords'] == coords
Пример #8
0
def test_get_agent_coordinates_regulate_amount():
    test_case = 'ERK increases the transcription of DUSP'
    for offline in offline_modes:
        rp = reach.process_text(test_case)
        stmt = rp.statements[0]
        annotations = stmt.evidence[0].annotations
        coords = [(0, 3), (35, 39)]
        assert annotations['agents']['coords'] == coords
Пример #9
0
def test_get_agent_coordinates_binding():
    test_case = 'Everyone has observed that MEK1 binds ERK2'
    for offline in offline_modes:
        rp = reach.process_text(test_case)
        stmt = rp.statements[0]
        annotations = stmt.evidence[0].annotations
        coords = [(27, 31), (38, 42)]
        assert annotations['agents']['coords'] == coords
Пример #10
0
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)
Пример #11
0
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)
Пример #12
0
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)
Пример #13
0
def test_get_agent_coordinates_activation():
    test_case = 'MEK1 activates ERK2'
    for offline in offline_modes:
        rp = reach.process_text(test_case)
        stmt = rp.statements[0]
        annotations = stmt.evidence[0].annotations
        coords = [(0, 4), (15, 19)]
        assert annotations['agents']['coords'] == coords
Пример #14
0
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)
Пример #15
0
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'
Пример #16
0
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)
Пример #17
0
def process_reach(txt):
    print('Using REACH')
    ts = time.time()
    rp = reach.process_text(txt, offline=False)
    for s in rp.statements:
        print('%s\t%s' % (s, s.evidence[0].text))
    te = time.time()
    print('Time taken: %.2fs' % (te-ts))
    return rp.statements
Пример #18
0
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)
Пример #19
0
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 == True:
            st = rp.statements[0]
            assert (st.subj.db_refs.get('BE') == 'MEK')
            assert (st.obj.db_refs.get('BE') == 'ERK')
Пример #20
0
def test_fplx_grounding():
    for offline in offline_modes:
        rp = reach.process_text('MEK activates ERK.', offline=offline)
        assert rp is not None
        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'
Пример #21
0
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)
Пример #22
0
def reach_process_text():
    """Process text with REACH and return INDRA Statements."""
    if request.method == 'OPTIONS':
        return {}
    response = request.body.read().decode('utf-8')
    body = json.loads(response)
    text = body.get('text')
    offline = True if body.get('offline') else False
    rp = reach.process_text(text, offline=offline)
    return _stmts_from_proc(rp)
Пример #23
0
def test_indirect_phosphorylate():
    txt = 'DUSP decreases the phosphorylation of ERK.'
    for offline in offline_modes:
        rp = reach.process_text(txt, offline=offline)
        assert len(rp.statements) == 1
        s = rp.statements[0]
        assert isinstance(s, Dephosphorylation)
        assert s.enz.name == 'DUSP'
        assert s.sub.name == 'ERK'
        assert s.evidence[0].epistemics.get('direct') is False
Пример #24
0
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)
Пример #25
0
def test_indirect_phosphorylate():
    txt = 'DUSP decreases the phosphorylation of ERK.'
    for offline in offline_modes:
        rp = reach.process_text(txt, offline=offline)
        assert len(rp.statements) == 1
        s = rp.statements[0]
        assert isinstance(s, Dephosphorylation)
        assert s.enz.name == 'DUSP'
        assert s.sub.name == 'ERK'
        assert s.evidence[0].epistemics.get('direct') == False
Пример #26
0
def reach_process_text():
    """Process text with REACH and return INDRA Statements."""
    if request.method == 'OPTIONS':
        return {}
    response = request.body.read().decode('utf-8')
    body = json.loads(response)
    text = body.get('text')
    offline = True if body.get('offline') else False
    rp = reach.process_text(text, offline=offline)
    return _stmts_from_proc(rp)
Пример #27
0
def test_get_agent_coordinates_phosphorylation():
    test_case = ('This sentence is filler. '
                 'Two filler sentences will work. '
                 'MEK that is phosphorylated phosphorylates ERK.')
    for offline in offline_modes:
        rp = reach.process_text(test_case)
        stmt = rp.statements[0]
        annotations = stmt.evidence[0].annotations

        coords = [(0, 3), (42, 45)]
        assert annotations['agents']['coords'] == coords
Пример #28
0
def test_get_agent_coordinates_phosphorylation():
    test_case = ('This sentence is filler. '
                 'Two filler sentences will work. '
                 'MEK that is phosphorylated phosphorylates ERK.')
    for offline in offline_modes:
        rp = reach.process_text(test_case, offline=offline)
        stmt = rp.statements[0]
        annotations = stmt.evidence[0].annotations

        coords = [(0, 3), (42, 45)]
        assert annotations['agents']['coords'] == coords
Пример #29
0
def test_get_agent_coordinates_translocation():
    test_case = ('The length of time that ERK phosphorylation '
                 'is sustained may determine whether active ERK '
                 'translocates to the nucleus promotes cell growth.')
    for offline in offline_modes:
        rp = reach.process_text(test_case, offline=offline)
        stmt = [stmt for stmt in rp.statements if
                isinstance(stmt, Translocation)][0]
        annotations = stmt.evidence[0].annotations
        coords = [(86, 89)]
        assert annotations['agents']['coords'] == coords
Пример #30
0
def test_multiple_enzymes():
    for offline in offline_modes:
        rp = reach.process_text('MEK1 and MEK2 phosphorylate ERK1.',
                                offline=offline)
        assert rp is not None
        assert len(rp.statements) == 2
        stmts = sorted(rp.statements, key=lambda x: x.enz.name)
        assert stmts[0].enz.name == 'MAP2K1', stmts
        assert stmts[1].enz.name == 'MAP2K2', stmts
        assert stmts[0].sub.name == 'MAPK3', stmts
        assert stmts[1].sub.name == 'MAPK3', stmts
Пример #31
0
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)
Пример #32
0
def test_get_agent_coordinates_phosphorylation_missing_controller():
    test_case = ('The ability of uPA and PAI-1 complex to induce '
                 'sustained ERK phosphorylation in MCF-7 cells '
                 'requires the recruitment of uPAR and VLDLr, which '
                 'function cooperatively')
    for offline in offline_modes:
        rp = reach.process_text(test_case, offline=offline)
        stmt = [stmt for stmt in rp.statements if
                isinstance(stmt, Phosphorylation)][0]
        annotations = stmt.evidence[0].annotations
        coords = [None, (57, 60)]
        assert annotations['agents']['coords'] == coords
Пример #33
0
def test_get_agent_coordinates_translocation():
    test_case = ('The length of time that ERK phosphorylation '
                 'is sustained may determine whether active ERK '
                 'translocates to the nucleus promotes cell growth.')
    for offline in offline_modes:
        rp = reach.process_text(test_case, offline=offline)
        assert rp is not None
        stmt = [stmt for stmt in rp.statements if
                isinstance(stmt, Translocation)][0]
        annotations = stmt.evidence[0].annotations
        coords = [(86, 89)]
        assert annotations['agents']['coords'] == coords
Пример #34
0
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)
Пример #35
0
def test_readme_using_indra3():
    from indra.sources import reach
    from indra.literature import pubmed_client
    # Search for 10 most recent abstracts in PubMed on 'BRAF'
    pmids = pubmed_client.get_ids('BRAF', retmax=10)
    all_statements = []
    for pmid in pmids:
        abs = pubmed_client.get_abstract(pmid)
        if abs is not None:
            reach_processor = reach.process_text(abs, url=reach.local_text_url)
            if reach_processor is not None:
                all_statements += reach_processor.statements
    assert len(all_statements) > 0
Пример #36
0
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)
Пример #37
0
def test_multiple_enzymes():
    for offline in offline_modes:
        rp = reach.process_text('MEK1 and MEK2 phosphorylate ERK1.',
                                offline=offline)
        assert len(rp.statements) == 2
        s = rp.statements[0]
        if s.enz.name == 'MAP2K1':
            assert rp.statements[1].enz.name == 'MAP2K2'
        else:
            assert rp.statements[1].enz.name == 'MAP2K1'
        assert (s.sub.name == 'MAPK3')
        s = rp.statements[1]
        assert (s.sub.name == 'MAPK3')
        assert unicode_strs(rp.statements)
Пример #38
0
def test_get_agent_coordinates_phosphorylation_missing_controller():
    test_case = ('The ability of uPA and PAI-1 complex to induce '
                 'sustained ERK phosphorylation in MCF-7 cells '
                 'requires the recruitment of uPAR and VLDLr, which '
                 'function cooperatively')
    for offline in offline_modes:
        rp = reach.process_text(test_case)
        stmt = [
            stmt for stmt in rp.statements
            if isinstance(stmt, Phosphorylation)
        ][0]
        annotations = stmt.evidence[0].annotations
        coords = [None, (57, 60)]
        assert annotations['agents']['coords'] == coords
Пример #39
0
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)
Пример #40
0
def test_multiple_enzymes():
    for offline in offline_modes:
        rp = reach.process_text('MEK1 and MEK2 phosphorylate ERK1.',
                                offline=offline)
        assert (len(rp.statements) == 2)
        s = rp.statements[0]
        if s.enz.name == 'MAP2K1':
            assert (rp.statements[1].enz.name == 'MAP2K2')
        else:
            assert (rp.statements[1].enz.name == 'MAP2K1')
        assert (s.sub.name == 'MAPK3')
        s = rp.statements[1]
        assert (s.sub.name == 'MAPK3')
        assert unicode_strs(rp.statements)
Пример #41
0
def reach_process_text():
    """Process text with REACH and return INDRA Statements."""
    if request.method == 'OPTIONS':
        return {}
    response = request.body.read().decode('utf-8')
    body = json.loads(response)
    text = body.get('text')
    offline = True if body.get('offline') else False
    rp = reach.process_text(text, offline=offline)
    if rp and rp.statements:
        stmts = stmts_to_json(rp.statements)
        res = {'statements': stmts}
        return res
    else:
        res = {'statements': []}
    return res
Пример #42
0
    def post(self):
        """Process text with REACH and return INDRA Statements.

        Parameters
        ----------
        text : str
            The text to be processed.

        offline : Optional[bool]
            If set to True, the REACH system is run offline via a JAR file.
            Otherwise (by default) the web service is called. Default: False

        url : Optional[str]
            URL for a REACH web service instance, which is used for reading if
            provided. If not provided but offline is set to False (its default
            value), REACH_TEXT_URL set in configuration will be used. If not
            provided in configuration, the Arizona REACH web service is called
            (http://agathon.sista.arizona.edu:8080/odinweb/api/help).
            Default: None

        Returns
        -------
        statements : list[indra.statements.Statement.to_json()]
            A list of extracted INDRA Statements.
        """
        args = request.json
        text = args.get('text')
        offline = True if args.get('offline') else False
        given_url = args.get('url')
        config_url = get_config('REACH_TEXT_URL', failure_ok=True)
        # Order: URL given as an explicit argument in the request. Then any URL
        # set in the configuration. Then, unless offline is set, use the
        # default REACH web service URL.
        if 'url' in args:  # This is to take None if explicitly given
            url = given_url
        elif config_url:
            url = config_url
        elif not offline:
            url = reach_text_url
        else:
            url = None
        # If a URL is set, prioritize it over the offline setting
        if url:
            offline = False
        rp = reach.process_text(text, offline=offline, url=url)
        return _stmts_from_proc(rp)
Пример #43
0
def test_process_mod_condition1():
    test_cases = [
        ('MEK1 activates ERK1 that is phosphorylated.',
         'phosphorylation', None, None, True),
        ('MEK1 activates ERK1 that is phosphorylated on tyrosine.',
         'phosphorylation', 'Y', None, True),
        ('MEK1 activates ERK1 that is phosphorylated on Y185.',
         'phosphorylation', 'Y', '185', True),
        ]
    for offline in offline_modes:
        for sentence, mod_type, residue, position, is_modified in test_cases:
            rp = reach.process_text(sentence, offline=offline)
            assert rp is not None
            assert len(rp.statements) == 1
            mcs = rp.statements[0].obj.mods
            assert len(mcs) == 1
            assert mcs[0].mod_type == mod_type
            assert mcs[0].residue == residue
            assert mcs[0].position == position
            assert mcs[0].is_modified == is_modified
Пример #44
0
def test_process_mod_condition1():
    test_cases = [
        ('MEK1 activates ERK1 that is phosphorylated.',
         'phosphorylation', None, None, True),
        ('MEK1 activates ERK1 that is phosphorylated on tyrosine.',
         'phosphorylation', 'Y', None, True),
        ('MEK1 activates ERK1 that is phosphorylated on Y185.',
         'phosphorylation', 'Y', '185', True),
        ]
    for offline in offline_modes:
        for sentence, mod_type, residue, position, is_modified in test_cases:
            rp = reach.process_text(sentence)
            assert rp is not None
            assert len(rp.statements) == 1
            mcs = rp.statements[0].obj.mods
            assert len(mcs) == 1
            assert mcs[0].mod_type == mod_type
            assert mcs[0].residue == residue
            assert mcs[0].position == position
            assert mcs[0].is_modified == is_modified
Пример #45
0
def test_process_mod_condition1():
    test_cases = [
        ('phosphorylated MEK1 activates ERK1.',
         'phosphorylation', None, None, True),
        ('MEK1 that is phosphorylated on serine activates ERK1.',
         'phosphorylation', 'S', None, True),
        ('MEK1 that is phosphorylated on S222 activates ERK1.',
         'phosphorylation', 'S', '222', True),
        ]
    for offline in offline_modes:
        for sentence, mod_type, residue, position, is_modified in test_cases:
            rp = reach.process_text(sentence, offline=offline)
            assert rp is not None
            assert len(rp.statements) == 1
            mcs = rp.statements[0].subj.mods
            assert len(mcs) == 1, 'No mods for %s' % sentence
            assert mcs[0].mod_type == mod_type, mcs
            assert mcs[0].residue == residue, mcs
            assert mcs[0].position == position, mcs
            assert mcs[0].is_modified == is_modified, mcs
def filter_to_sars_cov_2(stmts):
    return list(filter(lambda x: x.obj.name == 'SARS-CoV-2', stmts))


def map_readout(stmts):
    for stmt in stmts:
        db_refs = {'TEXT': stmt.obj.db_refs['TEXT'], 'MESH': 'D014779'}
        stmt.obj.name, stmt.obj.db_refs = \
            standardize_name_db_refs(db_refs)
    return stmts


if __name__ == '__main__':
    # Note that REACH needs to be running locally for this to work
    reader = lambda txt: reach.process_text(txt, url=reach.local_text_url)
    # Access to the INDRA group needs to be available and configured for
    # this to work
    hp = hypothesis.process_annotations(reader=reader)
    print(f'{len(hp.statements)} statements from Hypothes.is.')
    # Filter to sources
    test_stmts = filter_by_tag(hp.statements, has={'test', 'covid19'})
    test_stmts = filter_to_sars_cov_2(test_stmts)
    test_stmts = map_readout(test_stmts)
    print(f'{len(test_stmts)} statements that will be used as tests.')

    scts = [StatementCheckingTest(stmt) for stmt in test_stmts]
    name = 'Literature-curated drug screening'
    description = 'A set of statements derived from literature-reported drug ' \
                  'screening hits for SARS-CoV-2.'
    tests = {
Пример #47
0
def test_process_unicode():
    for offline in offline_modes:
        rp = reach.process_text('MEK1 binds ERK2\U0001F4A9.', offline=offline)
        assert unicode_strs(rp.statements)
Пример #48
0
def test_activity():
    for offline in offline_modes:
        rp = reach.process_text('MEK1 activates ERK2.', offline=offline)
        assert (len(rp.statements) == 1)
        assert unicode_strs(rp.statements)
Пример #49
0
def test_activity():
    for offline in offline_modes:
        rp = reach.process_text('MEK1 activates ERK2.', offline=offline)
        assert len(rp.statements) == 1
        assert unicode_strs(rp.statements)
Пример #50
0
def test_process_unicode():
    for offline in offline_modes:
        rp = reach.process_text('MEK1 binds ERK2\U0001F4A9.', offline=offline)
        assert unicode_strs(rp.statements)