_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q234200 | process_from_json_file | train | def process_from_json_file(filename, doc_id_type=None):
"""Process RLIMSP extractions from a bulk-download JSON file.
Parameters
----------
filename : str
Path to the JSON file.
doc_id_type : Optional[str]
In some cases the RLIMS-P paragraph info doesn't contain 'pmid' or
'p... | python | {
"resource": ""
} |
q234201 | NestedDict.get | train | def get(self, key):
"Find the first value within the tree which has the key."
if key in self.keys():
return self[key]
else:
res = None
for v in self.values():
# This could get weird if the actual expected returned value
# is Non... | python | {
"resource": ""
} |
q234202 | NestedDict.get_path | train | def get_path(self, key):
"Like `get`, but also return the path taken to the value."
if key in self.keys():
return (key,), self[key]
else:
key_path, res = (None, None)
for sub_key, v in self.items():
if isinstance(v, self.__class__):
... | python | {
"resource": ""
} |
q234203 | NestedDict.gets | train | def gets(self, key):
"Like `get`, but return all matches, not just the first."
result_list = []
if key in self.keys():
result_list.append(self[key])
for v in self.values():
if isinstance(v, self.__class__):
sub_res_list = v.gets(key)
... | python | {
"resource": ""
} |
q234204 | NestedDict.get_paths | train | def get_paths(self, key):
"Like `gets`, but include the paths, like `get_path` for all matches."
result_list = []
if key in self.keys():
result_list.append(((key,), self[key]))
for sub_key, v in self.items():
if isinstance(v, self.__class__):
sub_r... | python | {
"resource": ""
} |
q234205 | NestedDict.get_leaves | train | def get_leaves(self):
"""Get the deepest entries as a flat set."""
ret_set = set()
for val in self.values():
if isinstance(val, self.__class__):
ret_set |= val.get_leaves()
elif isinstance(val, dict):
ret_set |= set(val.values())
... | python | {
"resource": ""
} |
q234206 | determine_reach_subtype | train | def determine_reach_subtype(event_name):
"""Returns the category of reach rule from the reach rule instance.
Looks at a list of regular
expressions corresponding to reach rule types, and returns the longest
regexp that matches, or None if none of them match.
Parameters
----------
evidence ... | python | {
"resource": ""
} |
q234207 | ReachProcessor.print_event_statistics | train | def print_event_statistics(self):
"""Print the number of events in the REACH output by type."""
logger.info('All events by type')
logger.info('-------------------')
for k, v in self.all_events.items():
logger.info('%s, %s' % (k, len(v)))
logger.info('-----------------... | python | {
"resource": ""
} |
q234208 | ReachProcessor.get_all_events | train | def get_all_events(self):
"""Gather all event IDs in the REACH output by type.
These IDs are stored in the self.all_events dict.
"""
self.all_events = {}
events = self.tree.execute("$.events.frames")
if events is None:
return
for e in events:
... | python | {
"resource": ""
} |
q234209 | ReachProcessor.get_modifications | train | def get_modifications(self):
"""Extract Modification INDRA Statements."""
# Find all event frames that are a type of protein modification
qstr = "$.events.frames[(@.type is 'protein-modification')]"
res = self.tree.execute(qstr)
if res is None:
return
# Extrac... | python | {
"resource": ""
} |
q234210 | ReachProcessor.get_regulate_amounts | train | def get_regulate_amounts(self):
"""Extract RegulateAmount INDRA Statements."""
qstr = "$.events.frames[(@.type is 'transcription')]"
res = self.tree.execute(qstr)
all_res = []
if res is not None:
all_res += list(res)
qstr = "$.events.frames[(@.type is 'amount'... | python | {
"resource": ""
} |
q234211 | ReachProcessor.get_complexes | train | def get_complexes(self):
"""Extract INDRA Complex Statements."""
qstr = "$.events.frames[@.type is 'complex-assembly']"
res = self.tree.execute(qstr)
if res is None:
return
for r in res:
epistemics = self._get_epistemics(r)
if epistemics.get('... | python | {
"resource": ""
} |
q234212 | ReachProcessor.get_activation | train | def get_activation(self):
"""Extract INDRA Activation Statements."""
qstr = "$.events.frames[@.type is 'activation']"
res = self.tree.execute(qstr)
if res is None:
return
for r in res:
epistemics = self._get_epistemics(r)
if epistemics.get('neg... | python | {
"resource": ""
} |
q234213 | ReachProcessor.get_translocation | train | def get_translocation(self):
"""Extract INDRA Translocation Statements."""
qstr = "$.events.frames[@.type is 'translocation']"
res = self.tree.execute(qstr)
if res is None:
return
for r in res:
epistemics = self._get_epistemics(r)
if epistemics... | python | {
"resource": ""
} |
q234214 | ReachProcessor._get_mod_conditions | train | def _get_mod_conditions(self, mod_term):
"""Return a list of ModConditions given a mod term dict."""
site = mod_term.get('site')
if site is not None:
mods = self._parse_site_text(site)
else:
mods = [Site(None, None)]
mcs = []
for mod in mods:
... | python | {
"resource": ""
} |
q234215 | ReachProcessor._get_entity_coordinates | train | def _get_entity_coordinates(self, entity_term):
"""Return sentence coordinates for a given entity.
Given an entity term return the associated sentence coordinates as
a tuple of the form (int, int). Returns None if for any reason the
sentence coordinates cannot be found.
"""
... | python | {
"resource": ""
} |
q234216 | ReachProcessor._get_section | train | def _get_section(self, event):
"""Get the section of the paper that the event is from."""
sentence_id = event.get('sentence')
section = None
if sentence_id:
qstr = "$.sentences.frames[(@.frame_id is \'%s\')]" % sentence_id
res = self.tree.execute(qstr)
... | python | {
"resource": ""
} |
q234217 | ReachProcessor._get_controller_agent | train | def _get_controller_agent(self, arg):
"""Return a single or a complex controller agent."""
controller_agent = None
controller = arg.get('arg')
# There is either a single controller here
if controller is not None:
controller_agent, coords = self._get_agent_from_entity(... | python | {
"resource": ""
} |
q234218 | _sanitize | train | def _sanitize(text):
"""Return sanitized Eidos text field for human readability."""
d = {'-LRB-': '(', '-RRB-': ')'}
return re.sub('|'.join(d.keys()), lambda m: d[m.group(0)], text) | python | {
"resource": ""
} |
q234219 | ref_context_from_geoloc | train | def ref_context_from_geoloc(geoloc):
"""Return a RefContext object given a geoloc entry."""
text = geoloc.get('text')
geoid = geoloc.get('geoID')
rc = RefContext(name=text, db_refs={'GEOID': geoid})
return rc | python | {
"resource": ""
} |
q234220 | time_context_from_timex | train | def time_context_from_timex(timex):
"""Return a TimeContext object given a timex entry."""
time_text = timex.get('text')
constraint = timex['intervals'][0]
start = _get_time_stamp(constraint.get('start'))
end = _get_time_stamp(constraint.get('end'))
duration = constraint['duration']
tc = Tim... | python | {
"resource": ""
} |
q234221 | find_args | train | def find_args(event, arg_type):
"""Return IDs of all arguments of a given type"""
args = event.get('arguments', {})
obj_tags = [arg for arg in args if arg['type'] == arg_type]
if obj_tags:
return [o['value']['@id'] for o in obj_tags]
else:
return [] | python | {
"resource": ""
} |
q234222 | EidosProcessor.extract_causal_relations | train | def extract_causal_relations(self):
"""Extract causal relations as Statements."""
# Get the extractions that are labeled as directed and causal
relations = [e for e in self.doc.extractions if
'DirectedRelation' in e['labels'] and
'Causal' in e['labels']]... | python | {
"resource": ""
} |
q234223 | EidosProcessor.get_evidence | train | def get_evidence(self, relation):
"""Return the Evidence object for the INDRA Statment."""
provenance = relation.get('provenance')
# First try looking up the full sentence through provenance
text = None
context = None
if provenance:
sentence_tag = provenance[... | python | {
"resource": ""
} |
q234224 | EidosProcessor.get_negation | train | def get_negation(event):
"""Return negation attached to an event.
Example: "states": [{"@type": "State", "type": "NEGATION",
"text": "n't"}]
"""
states = event.get('states', [])
if not states:
return []
negs = [state for state in ... | python | {
"resource": ""
} |
q234225 | EidosProcessor.get_hedging | train | def get_hedging(event):
"""Return hedging markers attached to an event.
Example: "states": [{"@type": "State", "type": "HEDGE",
"text": "could"}
"""
states = event.get('states', [])
if not states:
return []
hedgings = [state for s... | python | {
"resource": ""
} |
q234226 | EidosProcessor.get_groundings | train | def get_groundings(entity):
"""Return groundings as db_refs for an entity."""
def get_grounding_entries(grounding):
if not grounding:
return None
entries = []
values = grounding.get('values', [])
# Values could still have been a None entry... | python | {
"resource": ""
} |
q234227 | EidosProcessor.get_concept | train | def get_concept(entity):
"""Return Concept from an Eidos entity."""
# Use the canonical name as the name of the Concept
name = entity['canonicalName']
db_refs = EidosProcessor.get_groundings(entity)
concept = Concept(name, db_refs=db_refs)
return concept | python | {
"resource": ""
} |
q234228 | EidosProcessor.time_context_from_ref | train | def time_context_from_ref(self, timex):
"""Return a time context object given a timex reference entry."""
# If the timex has a value set, it means that it refers to a DCT or
# a TimeExpression e.g. "value": {"@id": "_:DCT_1"} and the parameters
# need to be taken from there
value... | python | {
"resource": ""
} |
q234229 | EidosProcessor.geo_context_from_ref | train | def geo_context_from_ref(self, ref):
"""Return a ref context object given a location reference entry."""
value = ref.get('value')
if value:
# Here we get the RefContext from the stashed geoloc dictionary
rc = self.doc.geolocs.get(value['@id'])
return rc
... | python | {
"resource": ""
} |
q234230 | EidosDocument.time_context_from_dct | train | def time_context_from_dct(dct):
"""Return a time context object given a DCT entry."""
time_text = dct.get('text')
start = _get_time_stamp(dct.get('start'))
end = _get_time_stamp(dct.get('end'))
duration = dct.get('duration')
tc = TimeContext(text=time_text, start=start, e... | python | {
"resource": ""
} |
q234231 | make_hash | train | def make_hash(s, n_bytes):
"""Make the hash from a matches key."""
raw_h = int(md5(s.encode('utf-8')).hexdigest()[:n_bytes], 16)
# Make it a signed int.
return 16**n_bytes//2 - raw_h | python | {
"resource": ""
} |
q234232 | parse_a1 | train | def parse_a1(a1_text):
"""Parses an a1 file, the file TEES outputs that lists the entities in
the extracted events.
Parameters
----------
a1_text : str
Text of the TEES a1 output file, specifying the entities
Returns
-------
entities : Dictionary mapping TEES identifiers to TEE... | python | {
"resource": ""
} |
q234233 | parse_output | train | def parse_output(a1_text, a2_text, sentence_segmentations):
"""Parses the output of the TEES reader and returns a networkx graph
with the event information.
Parameters
----------
a1_text : str
Contents of the TEES a1 output, specifying the entities
a1_text : str
Contents of the ... | python | {
"resource": ""
} |
q234234 | tees_parse_networkx_to_dot | train | def tees_parse_networkx_to_dot(G, output_file, subgraph_nodes):
"""Converts TEES extractions stored in a networkx graph into a graphviz
.dot file.
Parameters
----------
G : networkx.DiGraph
Graph with TEES extractions returned by run_and_parse_tees
output_file : str
Output file ... | python | {
"resource": ""
} |
q234235 | CWMSProcessor._get_event | train | def _get_event(self, event, find_str):
"""Get a concept referred from the event by the given string."""
# Get the term with the given element id
element = event.find(find_str)
if element is None:
return None
element_id = element.attrib.get('id')
element_term =... | python | {
"resource": ""
} |
q234236 | CAGAssembler.make_model | train | def make_model(self, grounding_ontology='UN', grounding_threshold=None):
"""Return a networkx MultiDiGraph representing a causal analysis graph.
Parameters
----------
grounding_ontology : Optional[str]
The ontology from which the grounding should be taken
(e.g. U... | python | {
"resource": ""
} |
q234237 | CAGAssembler.export_to_cytoscapejs | train | def export_to_cytoscapejs(self):
"""Return CAG in format readable by CytoscapeJS.
Return
------
dict
A JSON-like dict representing the graph for use with
CytoscapeJS.
"""
def _create_edge_data_dict(e):
"""Return a dict from a MultiDiGr... | python | {
"resource": ""
} |
q234238 | CAGAssembler.generate_jupyter_js | train | def generate_jupyter_js(self, cyjs_style=None, cyjs_layout=None):
"""Generate Javascript from a template to run in Jupyter notebooks.
Parameters
----------
cyjs_style : Optional[dict]
A dict that sets CytoscapeJS style as specified in
https://github.com/cytoscape... | python | {
"resource": ""
} |
q234239 | CAGAssembler._node_name | train | def _node_name(self, concept):
"""Return a standardized name for a node given a Concept."""
if (# grounding threshold is specified
self.grounding_threshold is not None
# The particular eidos ontology grounding (un/wdi/fao) is present
and concept.db_refs[self.grounding... | python | {
"resource": ""
} |
q234240 | term_from_uri | train | def term_from_uri(uri):
"""Removes prepended URI information from terms."""
if uri is None:
return None
# This insures that if we get a Literal with an integer value (as we
# do for modification positions), it will get converted to a string,
# not an integer.
if isinstance(uri, rdflib.Li... | python | {
"resource": ""
} |
q234241 | BelRdfProcessor.get_activating_mods | train | def get_activating_mods(self):
"""Extract INDRA ActiveForm Statements with a single mod from BEL.
The SPARQL pattern used for extraction from BEL looks for a
ModifiedProteinAbundance as subject and an Activiy of a
ProteinAbundance as object.
Examples:
proteinAbunda... | python | {
"resource": ""
} |
q234242 | BelRdfProcessor.get_complexes | train | def get_complexes(self):
"""Extract INDRA Complex Statements from BEL.
The SPARQL query used to extract Complexes looks for ComplexAbundance
terms and their constituents. This pattern is distinct from other
patterns in this processor in that it queries for terms, not
full statem... | python | {
"resource": ""
} |
q234243 | BelRdfProcessor.get_activating_subs | train | def get_activating_subs(self):
"""Extract INDRA ActiveForm Statements based on a mutation from BEL.
The SPARQL pattern used to extract ActiveForms due to mutations look
for a ProteinAbundance as a subject which has a child encoding the
amino acid substitution. The object of the statemen... | python | {
"resource": ""
} |
q234244 | BelRdfProcessor.get_conversions | train | def get_conversions(self):
"""Extract Conversion INDRA Statements from BEL.
The SPARQL query used to extract Conversions searches for
a subject (controller) which is an AbundanceActivity
which directlyIncreases a Reaction with a given list of
Reactants and Products.
Ex... | python | {
"resource": ""
} |
q234245 | BelRdfProcessor.get_degenerate_statements | train | def get_degenerate_statements(self):
"""Get all degenerate BEL statements.
Stores the results of the query in self.degenerate_stmts.
"""
logger.info("Checking for 'degenerate' statements...\n")
# Get rules of type protein X -> activity Y
q_stmts = prefixes + """
... | python | {
"resource": ""
} |
q234246 | BelRdfProcessor.print_statement_coverage | train | def print_statement_coverage(self):
"""Display how many of the direct statements have been converted.
Also prints how many are considered 'degenerate' and not converted."""
if not self.all_direct_stmts:
self.get_all_direct_statements()
if not self.degenerate_stmts:
... | python | {
"resource": ""
} |
q234247 | BelRdfProcessor.print_statements | train | def print_statements(self):
"""Print all extracted INDRA Statements."""
logger.info('--- Direct INDRA statements ----------')
for i, stmt in enumerate(self.statements):
logger.info("%s: %s" % (i, stmt))
logger.info('--- Indirect INDRA statements ----------')
for i, st... | python | {
"resource": ""
} |
q234248 | process_directory_statements_sorted_by_pmid | train | def process_directory_statements_sorted_by_pmid(directory_name):
"""Processes a directory filled with CSXML files, first normalizing the
character encoding to utf-8, and then processing into INDRA statements
sorted by pmid.
Parameters
----------
directory_name : str
The name of a direct... | python | {
"resource": ""
} |
q234249 | process_directory | train | def process_directory(directory_name, lazy=False):
"""Processes a directory filled with CSXML files, first normalizing the
character encodings to utf-8, and then processing into a list of INDRA
statements.
Parameters
----------
directory_name : str
The name of a directory filled with cs... | python | {
"resource": ""
} |
q234250 | process_file_sorted_by_pmid | train | def process_file_sorted_by_pmid(file_name):
"""Processes a file and returns a dictionary mapping pmids to a list of
statements corresponding to that pmid.
Parameters
----------
file_name : str
A csxml file to process
Returns
-------
s_dict : dict
Dictionary mapping pmid... | python | {
"resource": ""
} |
q234251 | process_file | train | def process_file(filename, interval=None, lazy=False):
"""Process a CSXML file for its relevant information.
Consider running the fix_csxml_character_encoding.py script in
indra/sources/medscan to fix any encoding issues in the input file before
processing.
Attributes
----------
filename :... | python | {
"resource": ""
} |
q234252 | stmts_from_path | train | def stmts_from_path(path, model, stmts):
"""Return source Statements corresponding to a path in a model.
Parameters
----------
path : list[tuple[str, int]]
A list of tuples where the first element of the tuple is the
name of a rule, and the second is the associated polarity along
... | python | {
"resource": ""
} |
q234253 | extract_context | train | def extract_context(annotations, annot_manager):
"""Return a BioContext object extracted from the annotations.
The entries that are extracted into the BioContext are popped from the
annotations.
Parameters
----------
annotations : dict
PyBEL annotations dict
annot_manager : Annotat... | python | {
"resource": ""
} |
q234254 | format_axis | train | def format_axis(ax, label_padding=2, tick_padding=0, yticks_position='left'):
"""Set standardized axis formatting for figure."""
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position(yticks_position)
ax.yaxis.set_tick_params(which='both', direction='out', labelsize=fontsize,
... | python | {
"resource": ""
} |
q234255 | HtmlAssembler.make_model | train | def make_model(self):
"""Return the assembled HTML content as a string.
Returns
-------
str
The assembled HTML as a string.
"""
stmts_formatted = []
stmt_rows = group_and_sort_statements(self.statements,
s... | python | {
"resource": ""
} |
q234256 | HtmlAssembler.append_warning | train | def append_warning(self, msg):
"""Append a warning message to the model to expose issues."""
assert self.model is not None, "You must already have run make_model!"
addendum = ('\t<span style="color:red;">(CAUTION: %s occurred when '
'creating this page.)</span>' % msg)
... | python | {
"resource": ""
} |
q234257 | HtmlAssembler.save_model | train | def save_model(self, fname):
"""Save the assembled HTML into a file.
Parameters
----------
fname : str
The path to the file to save the HTML into.
"""
if self.model is None:
self.make_model()
with open(fname, 'wb') as fh:
fh.w... | python | {
"resource": ""
} |
q234258 | HtmlAssembler._format_evidence_text | train | def _format_evidence_text(stmt):
"""Returns evidence metadata with highlighted evidence text.
Parameters
----------
stmt : indra.Statement
The Statement with Evidence to be formatted.
Returns
-------
list of dicts
List of dictionaries cor... | python | {
"resource": ""
} |
q234259 | process_pmc | train | def process_pmc(pmc_id, offline=False, output_fname=default_output_fname):
"""Return a ReachProcessor by processing a paper with a given PMC id.
Uses the PMC client to obtain the full text. If it's not available,
None is returned.
Parameters
----------
pmc_id : str
The ID of a PubmedCe... | python | {
"resource": ""
} |
q234260 | process_pubmed_abstract | train | def process_pubmed_abstract(pubmed_id, offline=False,
output_fname=default_output_fname, **kwargs):
"""Return a ReachProcessor by processing an abstract with a given Pubmed id.
Uses the Pubmed client to get the abstract. If that fails, None is
returned.
Parameters
-----... | python | {
"resource": ""
} |
q234261 | process_text | train | def process_text(text, citation=None, offline=False,
output_fname=default_output_fname, timeout=None):
"""Return a ReachProcessor by processing the given text.
Parameters
----------
text : str
The text to be processed.
citation : Optional[str]
A PubMed ID passed to ... | python | {
"resource": ""
} |
q234262 | process_nxml_str | train | def process_nxml_str(nxml_str, citation=None, offline=False,
output_fname=default_output_fname):
"""Return a ReachProcessor by processing the given NXML string.
NXML is the format used by PubmedCentral for papers in the open
access subset.
Parameters
----------
nxml_str : ... | python | {
"resource": ""
} |
q234263 | process_nxml_file | train | def process_nxml_file(file_name, citation=None, offline=False,
output_fname=default_output_fname):
"""Return a ReachProcessor by processing the given NXML file.
NXML is the format used by PubmedCentral for papers in the open
access subset.
Parameters
----------
file_name ... | python | {
"resource": ""
} |
q234264 | process_json_file | train | def process_json_file(file_name, citation=None):
"""Return a ReachProcessor by processing the given REACH json file.
The output from the REACH parser is in this json format. This function is
useful if the output is saved as a file and needs to be processed.
For more information on the format, see: http... | python | {
"resource": ""
} |
q234265 | process_json_str | train | def process_json_str(json_str, citation=None):
"""Return a ReachProcessor by processing the given REACH json string.
The output from the REACH parser is in this json format.
For more information on the format, see: https://github.com/clulab/reach
Parameters
----------
json_str : str
Th... | python | {
"resource": ""
} |
q234266 | make_parser | train | def make_parser():
"""Generate the parser for this script."""
parser = ArgumentParser(
'wait_for_complete.py',
usage='%(prog)s [-h] queue_name [options]',
description=('Wait for a set of batch jobs to complete, and monitor '
'them as they run.'),
epilog=('Job... | python | {
"resource": ""
} |
q234267 | id_lookup | train | def id_lookup(paper_id, idtype):
"""Take an ID of type PMID, PMCID, or DOI and lookup the other IDs.
If the DOI is not found in Pubmed, try to obtain the DOI by doing a
reverse-lookup of the DOI in CrossRef using article metadata.
Parameters
----------
paper_id : str
ID of the article.... | python | {
"resource": ""
} |
q234268 | get_full_text | train | def get_full_text(paper_id, idtype, preferred_content_type='text/xml'):
"""Return the content and the content type of an article.
This function retreives the content of an article by its PubMed ID,
PubMed Central ID, or DOI. It prioritizes full text content when available
and returns an abstract from P... | python | {
"resource": ""
} |
q234269 | ReachReader.get_api_ruler | train | def get_api_ruler(self):
"""Return the existing reader if it exists or launch a new one.
Returns
-------
api_ruler : org.clulab.reach.apis.ApiRuler
An instance of the REACH ApiRuler class (java object).
"""
if self.api_ruler is None:
try:
... | python | {
"resource": ""
} |
q234270 | _download_biogrid_data | train | def _download_biogrid_data(url):
"""Downloads zipped, tab-separated Biogrid data in .tab2 format.
Parameters:
-----------
url : str
URL of the BioGrid zip file.
Returns
-------
csv.reader
A csv.reader object for iterating over the rows (header has already
been skipp... | python | {
"resource": ""
} |
q234271 | BiogridProcessor._make_agent | train | def _make_agent(self, entrez_id, text_id):
"""Make an Agent object, appropriately grounded.
Parameters
----------
entrez_id : str
Entrez id number
text_id : str
A plain text systematic name, or None if not listed.
Returns
-------
... | python | {
"resource": ""
} |
q234272 | BiogridProcessor._make_db_refs | train | def _make_db_refs(self, entrez_id, text_id):
"""Looks up the HGNC ID and name, as well as the Uniprot ID.
Parameters
----------
entrez_id : str
Entrez gene ID.
text_id : str or None
A plain text systematic name, or None if not listed in the
B... | python | {
"resource": ""
} |
q234273 | KamiAssembler.make_model | train | def make_model(self, policies=None, initial_conditions=True,
reverse_effects=False):
"""Assemble the Kami model from the collected INDRA Statements.
This method assembles a Kami model from the set of INDRA Statements.
The assembled model is both returned and set as the assemb... | python | {
"resource": ""
} |
q234274 | Nugget.add_agent | train | def add_agent(self, agent):
"""Add an INDRA Agent and its conditions to the Nugget."""
agent_id = self.add_node(agent.name)
self.add_typing(agent_id, 'agent')
# Handle bound conditions
for bc in agent.bound_conditions:
# Here we make the assumption that the binding si... | python | {
"resource": ""
} |
q234275 | Nugget.add_node | train | def add_node(self, name_base, attrs=None):
"""Add a node with a given base name to the Nugget and return ID."""
if name_base not in self.counters:
node_id = name_base
else:
node_id = '%s_%d' % (name_base, self.counters[name_base])
node = {'id': node_id}
if... | python | {
"resource": ""
} |
q234276 | Nugget.get_nugget_dict | train | def get_nugget_dict(self):
"""Return the Nugget as a dictionary."""
nugget_dict = \
{'id': self.id,
'graph': {
'nodes': self.nodes,
'edges': self.edges
},
'attrs': {
'name': self.name,
... | python | {
"resource": ""
} |
q234277 | process_text | train | def process_text(text, pmid=None, python2_path=None):
"""Processes the specified plain text with TEES and converts output to
supported INDRA statements. Check for the TEES installation is the
TEES_PATH environment variable, and configuration file; if not found,
checks candidate paths in tees_candidate_p... | python | {
"resource": ""
} |
q234278 | run_on_text | train | def run_on_text(text, python2_path):
"""Runs TEES on the given text in a temporary directory and returns a
temporary directory with TEES output.
The caller should delete this directory when done with it. This function
runs TEES and produces TEES output files but does not process TEES output
int... | python | {
"resource": ""
} |
q234279 | extract_output | train | def extract_output(output_dir):
"""Extract the text of the a1, a2, and sentence segmentation files from the
TEES output directory. These files are located within a compressed archive.
Parameters
----------
output_dir : str
Directory containing the output of the TEES system
Returns
... | python | {
"resource": ""
} |
q234280 | _list_to_seq | train | def _list_to_seq(lst):
"""Return a scala.collection.Seq from a Python list."""
ml = autoclass('scala.collection.mutable.MutableList')()
for element in lst:
ml.appendElem(element)
return ml | python | {
"resource": ""
} |
q234281 | EidosReader.process_text | train | def process_text(self, text, format='json'):
"""Return a mentions JSON object given text.
Parameters
----------
text : str
Text to be processed.
format : str
The format of the output to produce, one of "json" or "json_ld".
Default: "json"
... | python | {
"resource": ""
} |
q234282 | process_text | train | def process_text(text, out_format='json_ld', save_json='eidos_output.json',
webservice=None):
"""Return an EidosProcessor by processing the given text.
This constructs a reader object via Java and extracts mentions
from the text. It then serializes the mentions into JSON and
processes ... | python | {
"resource": ""
} |
q234283 | process_json_file | train | def process_json_file(file_name):
"""Return an EidosProcessor by processing the given Eidos JSON-LD file.
This function is useful if the output from Eidos is saved as a file and
needs to be processed.
Parameters
----------
file_name : str
The name of the JSON-LD file to be processed.
... | python | {
"resource": ""
} |
q234284 | process_json | train | def process_json(json_dict):
"""Return an EidosProcessor by processing a Eidos JSON-LD dict.
Parameters
----------
json_dict : dict
The JSON-LD dict to be processed.
Returns
-------
ep : EidosProcessor
A EidosProcessor containing the extracted INDRA Statements
in it... | python | {
"resource": ""
} |
q234285 | get_drug_inhibition_stmts | train | def get_drug_inhibition_stmts(drug):
"""Query ChEMBL for kinetics data given drug as Agent get back statements
Parameters
----------
drug : Agent
Agent representing drug with MESH or CHEBI grounding
Returns
-------
stmts : list of INDRA statements
INDRA statements generated... | python | {
"resource": ""
} |
q234286 | send_query | train | def send_query(query_dict):
"""Query ChEMBL API
Parameters
----------
query_dict : dict
'query' : string of the endpoint to query
'params' : dict of params for the query
Returns
-------
js : dict
dict parsed from json that is unique to the submitted query
"""
... | python | {
"resource": ""
} |
q234287 | query_target | train | def query_target(target_chembl_id):
"""Query ChEMBL API target by id
Parameters
----------
target_chembl_id : str
Returns
-------
target : dict
dict parsed from json that is unique for the target
"""
query_dict = {'query': 'target',
'params': {'target_chem... | python | {
"resource": ""
} |
q234288 | activities_by_target | train | def activities_by_target(activities):
"""Get back lists of activities in a dict keyed by ChEMBL target id
Parameters
----------
activities : list
response from a query returning activities for a drug
Returns
-------
targ_act_dict : dict
dictionary keyed to ChEMBL target ids... | python | {
"resource": ""
} |
q234289 | get_protein_targets_only | train | def get_protein_targets_only(target_chembl_ids):
"""Given list of ChEMBL target ids, return dict of SINGLE PROTEIN targets
Parameters
----------
target_chembl_ids : list
list of chembl_ids as strings
Returns
-------
protein_targets : dict
dictionary keyed to ChEMBL target i... | python | {
"resource": ""
} |
q234290 | get_evidence | train | def get_evidence(assay):
"""Given an activity, return an INDRA Evidence object.
Parameters
----------
assay : dict
an activity from the activities list returned by a query to the API
Returns
-------
ev : :py:class:`Evidence`
an :py:class:`Evidence` object containing the kin... | python | {
"resource": ""
} |
q234291 | get_kinetics | train | def get_kinetics(assay):
"""Given an activity, return its kinetics values.
Parameters
----------
assay : dict
an activity from the activities list returned by a query to the API
Returns
-------
kin : dict
dictionary of values with units keyed to value types 'IC50', 'EC50',
... | python | {
"resource": ""
} |
q234292 | get_pmid | train | def get_pmid(doc_id):
"""Get PMID from document_chembl_id
Parameters
----------
doc_id : str
Returns
-------
pmid : str
"""
url_pmid = 'https://www.ebi.ac.uk/chembl/api/data/document.json'
params = {'document_chembl_id': doc_id}
res = requests.get(url_pmid, params=params)
... | python | {
"resource": ""
} |
q234293 | get_target_chemblid | train | def get_target_chemblid(target_upid):
"""Get ChEMBL ID from UniProt upid
Parameters
----------
target_upid : str
Returns
-------
target_chembl_id : str
"""
url = 'https://www.ebi.ac.uk/chembl/api/data/target.json'
params = {'target_components__accession': target_upid}
r = r... | python | {
"resource": ""
} |
q234294 | get_mesh_id | train | def get_mesh_id(nlm_mesh):
"""Get MESH ID from NLM MESH
Parameters
----------
nlm_mesh : str
Returns
-------
mesh_id : str
"""
url_nlm2mesh = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi'
params = {'db': 'mesh', 'term': nlm_mesh, 'retmode': 'JSON'}
r = request... | python | {
"resource": ""
} |
q234295 | get_pcid | train | def get_pcid(mesh_id):
"""Get PC ID from MESH ID
Parameters
----------
mesh : str
Returns
-------
pcid : str
"""
url_mesh2pcid = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi'
params = {'dbfrom': 'mesh', 'id': mesh_id,
'db': 'pccompound', 'retmode': 'JS... | python | {
"resource": ""
} |
q234296 | get_chembl_id | train | def get_chembl_id(nlm_mesh):
"""Get ChEMBL ID from NLM MESH
Parameters
----------
nlm_mesh : str
Returns
-------
chembl_id : str
"""
mesh_id = get_mesh_id(nlm_mesh)
pcid = get_pcid(mesh_id)
url_mesh2pcid = 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/' + \
... | python | {
"resource": ""
} |
q234297 | FullTextMention.get_sentences | train | def get_sentences(self, root_element, block_tags):
"""Returns a list of plain-text sentences by iterating through
XML tags except for those listed in block_tags."""
sentences = []
for element in root_element:
if not self.any_ends_with(block_tags, element.tag):
... | python | {
"resource": ""
} |
q234298 | FullTextMention.any_ends_with | train | def any_ends_with(self, string_list, pattern):
"""Returns true iff one of the strings in string_list ends in
pattern."""
try:
s_base = basestring
except:
s_base = str
is_string = isinstance(pattern, s_base)
if not is_string:
return Fal... | python | {
"resource": ""
} |
q234299 | FullTextMention.get_tag_names | train | def get_tag_names(self):
"""Returns the set of tag names present in the XML."""
root = etree.fromstring(self.xml_full_text.encode('utf-8'))
return self.get_children_tag_names(root) | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.