def test_process_pmc(): for offline in offline_modes: rp = reach.process_pmc('PMC4338247', offline=offline) assert rp is not None for stmt in rp.statements: assert_pmid(stmt) assert unicode_strs(rp.statements)
def reach_process_pmc(): """Process PubMedCentral article and return INDRA Statements.""" if request.method == 'OPTIONS': return {} response = request.body.read().decode('utf-8') body = json.loads(response) pmcid = body.get('pmcid') rp = reach.process_pmc(pmcid) return _stmts_from_proc(rp)
def post(self): """Process PubMedCentral article and return INDRA Statements. Parameters ---------- pmc_id : str The ID of a PubmedCentral article. The string may start with PMC but passing just the ID also works. Examples: 8511698, PMC8511698 https://www.ncbi.nlm.nih.gov/pmc/ 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_NXML_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 pmcid = args.get('pmc_id') offline = True if args.get('offline') else False given_url = args.get('url') config_url = get_config('REACH_NXML_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_nxml_url else: url = None # If a URL is set, prioritize it over the offline setting if url: offline = False rp = reach.process_pmc(pmcid, offline=offline, url=url) return _stmts_from_proc(rp)
def reach_process_pmc(): """Process PubMedCentral article and return INDRA Statements.""" if request.method == 'OPTIONS': return {} response = request.body.read().decode('utf-8') body = json.loads(response) pmcid = body.get('pmcid') rp = reach.process_pmc(pmcid) if rp and rp.statements: stmts = stmts_to_json(rp.statements) res = {'statements': stmts} return res else: res = {'statements': []} return res
def test_readme_using_indra2(): from indra.sources import reach reach_processor = reach.process_pmc('3717945', url=reach.local_nxml_url) assert reach_processor.statements
def test_getting_started4(): # Chunk 4 from indra.sources import reach reach_processor = reach.process_pmc('3717945') assert reach_processor.statements
covidMetaDataFN = '2020-03-13/all_sources_metadata_2020-03-13.csv' pmcids = [] with open(covidMetaDataFN) as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') line_count = 0 for row in csv_reader: if line_count == 0: print(f'Column names are {", ".join(row)}') line_count += 1 if line_count == 1: pmc = f'{row[4]}' pmc = pmc.replace('PMC', '', 1) if ((pmc != '') & (pmc != 'pmcid')): pmcids.append(pmc) #line_count += 1 #reach_processor = reach.process_pmc(pmc) # print(f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.') #print(f'Processed {line_count} lines.') reach_processor = reach.process_pmc('1054884') # print(reach_processor) #line_count = 0 #for pmcid in pmcids: # if line_count == 0: # print(pmcid) # reach_processor = reach.process_pmc(pmcid) # print(reach_processor.print_event_statistics()) # line_count += 1 # print(reach_processor.get_all_events())
from indra.tools import assemble_corpus as ac from indra.statements import stmts_to_json_file from indra.assemblers.html import HtmlAssembler from indra.sources import reach tp = reach.process_pmc('PMC4455820', url=reach.local_nxml_url) if tp: stmts = tp.statements print(stmts) stmts = ac.filter_grounded_only(stmts) # Filter out ungrounded agents stmts = ac.run_preassembly( stmts, # Run preassembly return_toplevel=False, normalize_equivalences= True, # Optional: rewrite equivalent groundings to one standard normalize_opposites= True, # Optional: rewrite opposite groundings to one standard normalize_ns='WM' ) # Use 'WM' namespace to normalize equivalences and opposites stmts = ac.filter_belief(stmts, 0.8) # Apply belief cutoff of e.g., 0.8 stmts_to_json_file(stmts, 'PMC4455820.json') ha = HtmlAssembler(stmts) ha.save_model('PMC4455820.html') # # # #
#attempt to combine many statements from indra.tools import assemble_corpus as ac from indra.statements import stmts_to_json_file from indra.assemblers.html import HtmlAssembler from indra.sources import reach pmcids = ["PMC3717945", "PMC5906628"] stmts = [] for pmcid in pmcids: tp = reach.process_pmc(pmcid) stmts += tp.statements stmts = ac.filter_grounded_only(stmts) # Filter out ungrounded agents stmts = ac.run_preassembly( stmts, # Run preassembly return_toplevel=False, normalize_equivalences= True, # Optional: rewrite equivalent groundings to one standard normalize_opposites= True, # Optional: rewrite opposite groundings to one standard normalize_ns='WM' ) # Use 'WM' namespace to normalize equivalences and opposites stmts = ac.filter_belief(stmts, 0.8) # Apply belief cutoff of e.g., 0.8 stmts_to_json_file(stmts, 'bigresults.json') ha = HtmlAssembler(stmts) ha.save_model('bigresults.html')
def test_process_pmc(): for offline in offline_modes: rp = reach.process_pmc('PMC4338247', offline=offline) for stmt in rp.statements: assert_pmid(stmt) assert unicode_strs(rp.statements)