repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
sorgerlab/indra | indra/assemblers/pysb/assembler.py | grounded_monomer_patterns | def grounded_monomer_patterns(model, agent, ignore_activities=False):
"""Get monomer patterns for the agent accounting for grounding information.
Parameters
----------
model : pysb.core.Model
The model to search for MonomerPatterns matching the given Agent.
agent : indra.statements.Agent
... | python | def grounded_monomer_patterns(model, agent, ignore_activities=False):
"""Get monomer patterns for the agent accounting for grounding information.
Parameters
----------
model : pysb.core.Model
The model to search for MonomerPatterns matching the given Agent.
agent : indra.statements.Agent
... | [
"def",
"grounded_monomer_patterns",
"(",
"model",
",",
"agent",
",",
"ignore_activities",
"=",
"False",
")",
":",
"# If it's not a molecular agent",
"if",
"not",
"isinstance",
"(",
"agent",
",",
"ist",
".",
"Agent",
")",
":",
"monomer",
"=",
"model",
".",
"mon... | Get monomer patterns for the agent accounting for grounding information.
Parameters
----------
model : pysb.core.Model
The model to search for MonomerPatterns matching the given Agent.
agent : indra.statements.Agent
The Agent to find matching MonomerPatterns for.
ignore_activites : ... | [
"Get",
"monomer",
"patterns",
"for",
"the",
"agent",
"accounting",
"for",
"grounding",
"information",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L152-L281 | train |
sorgerlab/indra | indra/assemblers/pysb/assembler.py | get_monomer_pattern | def get_monomer_pattern(model, agent, extra_fields=None):
"""Construct a PySB MonomerPattern from an Agent."""
try:
monomer = model.monomers[_n(agent.name)]
except KeyError as e:
logger.warning('Monomer with name %s not found in model' %
_n(agent.name))
return ... | python | def get_monomer_pattern(model, agent, extra_fields=None):
"""Construct a PySB MonomerPattern from an Agent."""
try:
monomer = model.monomers[_n(agent.name)]
except KeyError as e:
logger.warning('Monomer with name %s not found in model' %
_n(agent.name))
return ... | [
"def",
"get_monomer_pattern",
"(",
"model",
",",
"agent",
",",
"extra_fields",
"=",
"None",
")",
":",
"try",
":",
"monomer",
"=",
"model",
".",
"monomers",
"[",
"_n",
"(",
"agent",
".",
"name",
")",
"]",
"except",
"KeyError",
"as",
"e",
":",
"logger",
... | Construct a PySB MonomerPattern from an Agent. | [
"Construct",
"a",
"PySB",
"MonomerPattern",
"from",
"an",
"Agent",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L293-L319 | train |
sorgerlab/indra | indra/assemblers/pysb/assembler.py | get_site_pattern | def get_site_pattern(agent):
"""Construct a dictionary of Monomer site states from an Agent.
This crates the mapping to the associated PySB monomer from an
INDRA Agent object."""
if not isinstance(agent, ist.Agent):
return {}
pattern = {}
# Handle bound conditions
for bc in agent.bo... | python | def get_site_pattern(agent):
"""Construct a dictionary of Monomer site states from an Agent.
This crates the mapping to the associated PySB monomer from an
INDRA Agent object."""
if not isinstance(agent, ist.Agent):
return {}
pattern = {}
# Handle bound conditions
for bc in agent.bo... | [
"def",
"get_site_pattern",
"(",
"agent",
")",
":",
"if",
"not",
"isinstance",
"(",
"agent",
",",
"ist",
".",
"Agent",
")",
":",
"return",
"{",
"}",
"pattern",
"=",
"{",
"}",
"# Handle bound conditions",
"for",
"bc",
"in",
"agent",
".",
"bound_conditions",
... | Construct a dictionary of Monomer site states from an Agent.
This crates the mapping to the associated PySB monomer from an
INDRA Agent object. | [
"Construct",
"a",
"dictionary",
"of",
"Monomer",
"site",
"states",
"from",
"an",
"Agent",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L322-L375 | train |
sorgerlab/indra | indra/assemblers/pysb/assembler.py | set_base_initial_condition | def set_base_initial_condition(model, monomer, value):
"""Set an initial condition for a monomer in its 'default' state."""
# Build up monomer pattern dict
sites_dict = {}
for site in monomer.sites:
if site in monomer.site_states:
if site == 'loc' and 'cytoplasm' in monomer.site_stat... | python | def set_base_initial_condition(model, monomer, value):
"""Set an initial condition for a monomer in its 'default' state."""
# Build up monomer pattern dict
sites_dict = {}
for site in monomer.sites:
if site in monomer.site_states:
if site == 'loc' and 'cytoplasm' in monomer.site_stat... | [
"def",
"set_base_initial_condition",
"(",
"model",
",",
"monomer",
",",
"value",
")",
":",
"# Build up monomer pattern dict",
"sites_dict",
"=",
"{",
"}",
"for",
"site",
"in",
"monomer",
".",
"sites",
":",
"if",
"site",
"in",
"monomer",
".",
"site_states",
":"... | Set an initial condition for a monomer in its 'default' state. | [
"Set",
"an",
"initial",
"condition",
"for",
"a",
"monomer",
"in",
"its",
"default",
"state",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L378-L398 | train |
sorgerlab/indra | indra/assemblers/pysb/assembler.py | get_annotation | def get_annotation(component, db_name, db_ref):
"""Construct model Annotations for each component.
Annotation formats follow guidelines at http://identifiers.org/.
"""
url = get_identifiers_url(db_name, db_ref)
if not url:
return None
subj = component
ann = Annotation(subj, url, 'is... | python | def get_annotation(component, db_name, db_ref):
"""Construct model Annotations for each component.
Annotation formats follow guidelines at http://identifiers.org/.
"""
url = get_identifiers_url(db_name, db_ref)
if not url:
return None
subj = component
ann = Annotation(subj, url, 'is... | [
"def",
"get_annotation",
"(",
"component",
",",
"db_name",
",",
"db_ref",
")",
":",
"url",
"=",
"get_identifiers_url",
"(",
"db_name",
",",
"db_ref",
")",
"if",
"not",
"url",
":",
"return",
"None",
"subj",
"=",
"component",
"ann",
"=",
"Annotation",
"(",
... | Construct model Annotations for each component.
Annotation formats follow guidelines at http://identifiers.org/. | [
"Construct",
"model",
"Annotations",
"for",
"each",
"component",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L432-L442 | train |
sorgerlab/indra | indra/assemblers/pysb/assembler.py | PysbAssembler.make_model | def make_model(self, policies=None, initial_conditions=True,
reverse_effects=False, model_name='indra_model'):
"""Assemble the PySB model from the collected INDRA Statements.
This method assembles a PySB model from the set of INDRA Statements.
The assembled model is both retu... | python | def make_model(self, policies=None, initial_conditions=True,
reverse_effects=False, model_name='indra_model'):
"""Assemble the PySB model from the collected INDRA Statements.
This method assembles a PySB model from the set of INDRA Statements.
The assembled model is both retu... | [
"def",
"make_model",
"(",
"self",
",",
"policies",
"=",
"None",
",",
"initial_conditions",
"=",
"True",
",",
"reverse_effects",
"=",
"False",
",",
"model_name",
"=",
"'indra_model'",
")",
":",
"ppa",
"=",
"PysbPreassembler",
"(",
"self",
".",
"statements",
"... | Assemble the PySB model from the collected INDRA Statements.
This method assembles a PySB model from the set of INDRA Statements.
The assembled model is both returned and set as the assembler's
model argument.
Parameters
----------
policies : Optional[Union[str, dict]]
... | [
"Assemble",
"the",
"PySB",
"model",
"from",
"the",
"collected",
"INDRA",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L546-L626 | train |
sorgerlab/indra | indra/assemblers/pysb/assembler.py | PysbAssembler.add_default_initial_conditions | def add_default_initial_conditions(self, value=None):
"""Set default initial conditions in the PySB model.
Parameters
----------
value : Optional[float]
Optionally a value can be supplied which will be the initial
amount applied. Otherwise a built-in default is u... | python | def add_default_initial_conditions(self, value=None):
"""Set default initial conditions in the PySB model.
Parameters
----------
value : Optional[float]
Optionally a value can be supplied which will be the initial
amount applied. Otherwise a built-in default is u... | [
"def",
"add_default_initial_conditions",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"try",
":",
"value_num",
"=",
"float",
"(",
"value",
")",
"except",
"ValueError",
":",
"logger",
".",
"error",
"(",
"'Inva... | Set default initial conditions in the PySB model.
Parameters
----------
value : Optional[float]
Optionally a value can be supplied which will be the initial
amount applied. Otherwise a built-in default is used. | [
"Set",
"default",
"initial",
"conditions",
"in",
"the",
"PySB",
"model",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L628-L648 | train |
sorgerlab/indra | indra/assemblers/pysb/assembler.py | PysbAssembler.set_expression | def set_expression(self, expression_dict):
"""Set protein expression amounts as initial conditions
Parameters
----------
expression_dict : dict
A dictionary in which the keys are gene names and the
values are numbers representing the absolute amount
(... | python | def set_expression(self, expression_dict):
"""Set protein expression amounts as initial conditions
Parameters
----------
expression_dict : dict
A dictionary in which the keys are gene names and the
values are numbers representing the absolute amount
(... | [
"def",
"set_expression",
"(",
"self",
",",
"expression_dict",
")",
":",
"if",
"self",
".",
"model",
"is",
"None",
":",
"return",
"monomers_found",
"=",
"[",
"]",
"monomers_notfound",
"=",
"[",
"]",
"# Iterate over all the monomers",
"for",
"m",
"in",
"self",
... | Set protein expression amounts as initial conditions
Parameters
----------
expression_dict : dict
A dictionary in which the keys are gene names and the
values are numbers representing the absolute amount
(count per cell) of proteins expressed. Proteins that
... | [
"Set",
"protein",
"expression",
"amounts",
"as",
"initial",
"conditions"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L650-L694 | train |
sorgerlab/indra | indra/assemblers/pysb/assembler.py | PysbAssembler.set_context | def set_context(self, cell_type):
"""Set protein expression amounts from CCLE as initial conditions.
This method uses :py:mod:`indra.databases.context_client` to get
protein expression levels for a given cell type and set initial
conditions for Monomers in the model accordingly.
... | python | def set_context(self, cell_type):
"""Set protein expression amounts from CCLE as initial conditions.
This method uses :py:mod:`indra.databases.context_client` to get
protein expression levels for a given cell type and set initial
conditions for Monomers in the model accordingly.
... | [
"def",
"set_context",
"(",
"self",
",",
"cell_type",
")",
":",
"if",
"self",
".",
"model",
"is",
"None",
":",
"return",
"monomer_names",
"=",
"[",
"m",
".",
"name",
"for",
"m",
"in",
"self",
".",
"model",
".",
"monomers",
"]",
"res",
"=",
"context_cl... | Set protein expression amounts from CCLE as initial conditions.
This method uses :py:mod:`indra.databases.context_client` to get
protein expression levels for a given cell type and set initial
conditions for Monomers in the model accordingly.
Parameters
----------
cell_... | [
"Set",
"protein",
"expression",
"amounts",
"from",
"CCLE",
"as",
"initial",
"conditions",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L696-L721 | train |
sorgerlab/indra | indra/assemblers/pysb/assembler.py | PysbAssembler.export_model | def export_model(self, format, file_name=None):
"""Save the assembled model in a modeling formalism other than PySB.
For more details on exporting PySB models, see
http://pysb.readthedocs.io/en/latest/modules/export/index.html
Parameters
----------
format : str
... | python | def export_model(self, format, file_name=None):
"""Save the assembled model in a modeling formalism other than PySB.
For more details on exporting PySB models, see
http://pysb.readthedocs.io/en/latest/modules/export/index.html
Parameters
----------
format : str
... | [
"def",
"export_model",
"(",
"self",
",",
"format",
",",
"file_name",
"=",
"None",
")",
":",
"# Handle SBGN as special case",
"if",
"format",
"==",
"'sbgn'",
":",
"exp_str",
"=",
"export_sbgn",
"(",
"self",
".",
"model",
")",
"elif",
"format",
"==",
"'kappa_i... | Save the assembled model in a modeling formalism other than PySB.
For more details on exporting PySB models, see
http://pysb.readthedocs.io/en/latest/modules/export/index.html
Parameters
----------
format : str
The format to export into, for instance "kappa", "bngl"... | [
"Save",
"the",
"assembled",
"model",
"in",
"a",
"modeling",
"formalism",
"other",
"than",
"PySB",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L746-L789 | train |
sorgerlab/indra | indra/assemblers/pysb/assembler.py | PysbAssembler.save_rst | def save_rst(self, file_name='pysb_model.rst', module_name='pysb_module'):
"""Save the assembled model as an RST file for literate modeling.
Parameters
----------
file_name : Optional[str]
The name of the file to save the RST in.
Default: pysb_model.rst
m... | python | def save_rst(self, file_name='pysb_model.rst', module_name='pysb_module'):
"""Save the assembled model as an RST file for literate modeling.
Parameters
----------
file_name : Optional[str]
The name of the file to save the RST in.
Default: pysb_model.rst
m... | [
"def",
"save_rst",
"(",
"self",
",",
"file_name",
"=",
"'pysb_model.rst'",
",",
"module_name",
"=",
"'pysb_module'",
")",
":",
"if",
"self",
".",
"model",
"is",
"not",
"None",
":",
"with",
"open",
"(",
"file_name",
",",
"'wt'",
")",
"as",
"fh",
":",
"f... | Save the assembled model as an RST file for literate modeling.
Parameters
----------
file_name : Optional[str]
The name of the file to save the RST in.
Default: pysb_model.rst
module_name : Optional[str]
The name of the python function defining the mo... | [
"Save",
"the",
"assembled",
"model",
"as",
"an",
"RST",
"file",
"for",
"literate",
"modeling",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L792-L812 | train |
sorgerlab/indra | indra/assemblers/pysb/assembler.py | PysbAssembler._monomers | def _monomers(self):
"""Calls the appropriate monomers method based on policies."""
for stmt in self.statements:
if _is_whitelisted(stmt):
self._dispatch(stmt, 'monomers', self.agent_set) | python | def _monomers(self):
"""Calls the appropriate monomers method based on policies."""
for stmt in self.statements:
if _is_whitelisted(stmt):
self._dispatch(stmt, 'monomers', self.agent_set) | [
"def",
"_monomers",
"(",
"self",
")",
":",
"for",
"stmt",
"in",
"self",
".",
"statements",
":",
"if",
"_is_whitelisted",
"(",
"stmt",
")",
":",
"self",
".",
"_dispatch",
"(",
"stmt",
",",
"'monomers'",
",",
"self",
".",
"agent_set",
")"
] | Calls the appropriate monomers method based on policies. | [
"Calls",
"the",
"appropriate",
"monomers",
"method",
"based",
"on",
"policies",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L844-L848 | train |
sorgerlab/indra | indra/sources/trips/client.py | send_query | def send_query(text, service_endpoint='drum', query_args=None):
"""Send a query to the TRIPS web service.
Parameters
----------
text : str
The text to be processed.
service_endpoint : Optional[str]
Selects the TRIPS/DRUM web service endpoint to use. Is a choice between
"drum... | python | def send_query(text, service_endpoint='drum', query_args=None):
"""Send a query to the TRIPS web service.
Parameters
----------
text : str
The text to be processed.
service_endpoint : Optional[str]
Selects the TRIPS/DRUM web service endpoint to use. Is a choice between
"drum... | [
"def",
"send_query",
"(",
"text",
",",
"service_endpoint",
"=",
"'drum'",
",",
"query_args",
"=",
"None",
")",
":",
"if",
"service_endpoint",
"in",
"[",
"'drum'",
",",
"'drum-dev'",
",",
"'cwms'",
",",
"'cwmsreader'",
"]",
":",
"url",
"=",
"base_url",
"+",... | Send a query to the TRIPS web service.
Parameters
----------
text : str
The text to be processed.
service_endpoint : Optional[str]
Selects the TRIPS/DRUM web service endpoint to use. Is a choice between
"drum" (default), "drum-dev", a nightly build, and "cwms" for use with
... | [
"Send",
"a",
"query",
"to",
"the",
"TRIPS",
"web",
"service",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/client.py#L15-L48 | train |
sorgerlab/indra | indra/sources/trips/client.py | get_xml | def get_xml(html, content_tag='ekb', fail_if_empty=False):
"""Extract the content XML from the HTML output of the TRIPS web service.
Parameters
----------
html : str
The HTML output from the TRIPS web service.
content_tag : str
The xml tag used to label the content. Default is 'ekb'... | python | def get_xml(html, content_tag='ekb', fail_if_empty=False):
"""Extract the content XML from the HTML output of the TRIPS web service.
Parameters
----------
html : str
The HTML output from the TRIPS web service.
content_tag : str
The xml tag used to label the content. Default is 'ekb'... | [
"def",
"get_xml",
"(",
"html",
",",
"content_tag",
"=",
"'ekb'",
",",
"fail_if_empty",
"=",
"False",
")",
":",
"cont",
"=",
"re",
".",
"findall",
"(",
"r'<%(tag)s(.*?)>(.*?)</%(tag)s>'",
"%",
"{",
"'tag'",
":",
"content_tag",
"}",
",",
"html",
",",
"re",
... | Extract the content XML from the HTML output of the TRIPS web service.
Parameters
----------
html : str
The HTML output from the TRIPS web service.
content_tag : str
The xml tag used to label the content. Default is 'ekb'.
fail_if_empty : bool
If True, and if the xml content... | [
"Extract",
"the",
"content",
"XML",
"from",
"the",
"HTML",
"output",
"of",
"the",
"TRIPS",
"web",
"service",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/client.py#L51-L88 | train |
sorgerlab/indra | indra/sources/trips/client.py | save_xml | def save_xml(xml_str, file_name, pretty=True):
"""Save the TRIPS EKB XML in a file.
Parameters
----------
xml_str : str
The TRIPS EKB XML string to be saved.
file_name : str
The name of the file to save the result in.
pretty : Optional[bool]
If True, the XML is pretty pr... | python | def save_xml(xml_str, file_name, pretty=True):
"""Save the TRIPS EKB XML in a file.
Parameters
----------
xml_str : str
The TRIPS EKB XML string to be saved.
file_name : str
The name of the file to save the result in.
pretty : Optional[bool]
If True, the XML is pretty pr... | [
"def",
"save_xml",
"(",
"xml_str",
",",
"file_name",
",",
"pretty",
"=",
"True",
")",
":",
"try",
":",
"fh",
"=",
"open",
"(",
"file_name",
",",
"'wt'",
")",
"except",
"IOError",
":",
"logger",
".",
"error",
"(",
"'Could not open %s for writing.'",
"%",
... | Save the TRIPS EKB XML in a file.
Parameters
----------
xml_str : str
The TRIPS EKB XML string to be saved.
file_name : str
The name of the file to save the result in.
pretty : Optional[bool]
If True, the XML is pretty printed. | [
"Save",
"the",
"TRIPS",
"EKB",
"XML",
"in",
"a",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/client.py#L91-L114 | train |
sorgerlab/indra | indra/sources/sofia/api.py | process_table | def process_table(fname):
"""Return processor by processing a given sheet of a spreadsheet file.
Parameters
----------
fname : str
The name of the Excel file (typically .xlsx extension) to process
Returns
-------
sp : indra.sources.sofia.processor.SofiaProcessor
A SofiaProc... | python | def process_table(fname):
"""Return processor by processing a given sheet of a spreadsheet file.
Parameters
----------
fname : str
The name of the Excel file (typically .xlsx extension) to process
Returns
-------
sp : indra.sources.sofia.processor.SofiaProcessor
A SofiaProc... | [
"def",
"process_table",
"(",
"fname",
")",
":",
"book",
"=",
"openpyxl",
".",
"load_workbook",
"(",
"fname",
",",
"read_only",
"=",
"True",
")",
"try",
":",
"rel_sheet",
"=",
"book",
"[",
"'Relations'",
"]",
"except",
"Exception",
"as",
"e",
":",
"rel_sh... | Return processor by processing a given sheet of a spreadsheet file.
Parameters
----------
fname : str
The name of the Excel file (typically .xlsx extension) to process
Returns
-------
sp : indra.sources.sofia.processor.SofiaProcessor
A SofiaProcessor object which has a list of ... | [
"Return",
"processor",
"by",
"processing",
"a",
"given",
"sheet",
"of",
"a",
"spreadsheet",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sofia/api.py#L9-L32 | train |
sorgerlab/indra | indra/sources/sofia/api.py | process_text | def process_text(text, out_file='sofia_output.json', auth=None):
"""Return processor by processing text given as a string.
Parameters
----------
text : str
A string containing the text to be processed with Sofia.
out_file : Optional[str]
The path to a file to save the reader's outpu... | python | def process_text(text, out_file='sofia_output.json', auth=None):
"""Return processor by processing text given as a string.
Parameters
----------
text : str
A string containing the text to be processed with Sofia.
out_file : Optional[str]
The path to a file to save the reader's outpu... | [
"def",
"process_text",
"(",
"text",
",",
"out_file",
"=",
"'sofia_output.json'",
",",
"auth",
"=",
"None",
")",
":",
"text_json",
"=",
"{",
"'text'",
":",
"text",
"}",
"if",
"not",
"auth",
":",
"user",
",",
"password",
"=",
"_get_sofia_auth",
"(",
")",
... | Return processor by processing text given as a string.
Parameters
----------
text : str
A string containing the text to be processed with Sofia.
out_file : Optional[str]
The path to a file to save the reader's output into.
Default: sofia_output.json
auth : Optional[list]
... | [
"Return",
"processor",
"by",
"processing",
"text",
"given",
"as",
"a",
"string",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sofia/api.py#L35-L80 | train |
sorgerlab/indra | indra/sources/ndex_cx/processor.py | _get_dict_from_list | def _get_dict_from_list(dict_key, list_of_dicts):
"""Retrieve a specific dict from a list of dicts.
Parameters
----------
dict_key : str
The (single) key of the dict to be retrieved from the list.
list_of_dicts : list
The list of dicts to search for the specific dict.
Returns
... | python | def _get_dict_from_list(dict_key, list_of_dicts):
"""Retrieve a specific dict from a list of dicts.
Parameters
----------
dict_key : str
The (single) key of the dict to be retrieved from the list.
list_of_dicts : list
The list of dicts to search for the specific dict.
Returns
... | [
"def",
"_get_dict_from_list",
"(",
"dict_key",
",",
"list_of_dicts",
")",
":",
"the_dict",
"=",
"[",
"cur_dict",
"for",
"cur_dict",
"in",
"list_of_dicts",
"if",
"cur_dict",
".",
"get",
"(",
"dict_key",
")",
"]",
"if",
"not",
"the_dict",
":",
"raise",
"ValueE... | Retrieve a specific dict from a list of dicts.
Parameters
----------
dict_key : str
The (single) key of the dict to be retrieved from the list.
list_of_dicts : list
The list of dicts to search for the specific dict.
Returns
-------
dict value
The value associated wi... | [
"Retrieve",
"a",
"specific",
"dict",
"from",
"a",
"list",
"of",
"dicts",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/processor.py#L22-L42 | train |
sorgerlab/indra | indra/sources/ndex_cx/processor.py | NdexCxProcessor._initialize_node_agents | def _initialize_node_agents(self):
"""Initialize internal dicts containing node information."""
nodes = _get_dict_from_list('nodes', self.cx)
invalid_genes = []
for node in nodes:
id = node['@id']
cx_db_refs = self.get_aliases(node)
up_id = cx_db_refs.... | python | def _initialize_node_agents(self):
"""Initialize internal dicts containing node information."""
nodes = _get_dict_from_list('nodes', self.cx)
invalid_genes = []
for node in nodes:
id = node['@id']
cx_db_refs = self.get_aliases(node)
up_id = cx_db_refs.... | [
"def",
"_initialize_node_agents",
"(",
"self",
")",
":",
"nodes",
"=",
"_get_dict_from_list",
"(",
"'nodes'",
",",
"self",
".",
"cx",
")",
"invalid_genes",
"=",
"[",
"]",
"for",
"node",
"in",
"nodes",
":",
"id",
"=",
"node",
"[",
"'@id'",
"]",
"cx_db_ref... | Initialize internal dicts containing node information. | [
"Initialize",
"internal",
"dicts",
"containing",
"node",
"information",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/processor.py#L78-L116 | train |
sorgerlab/indra | indra/sources/ndex_cx/processor.py | NdexCxProcessor.get_pmids | def get_pmids(self):
"""Get list of all PMIDs associated with edges in the network."""
pmids = []
for ea in self._edge_attributes.values():
edge_pmids = ea.get('pmids')
if edge_pmids:
pmids += edge_pmids
return list(set(pmids)) | python | def get_pmids(self):
"""Get list of all PMIDs associated with edges in the network."""
pmids = []
for ea in self._edge_attributes.values():
edge_pmids = ea.get('pmids')
if edge_pmids:
pmids += edge_pmids
return list(set(pmids)) | [
"def",
"get_pmids",
"(",
"self",
")",
":",
"pmids",
"=",
"[",
"]",
"for",
"ea",
"in",
"self",
".",
"_edge_attributes",
".",
"values",
"(",
")",
":",
"edge_pmids",
"=",
"ea",
".",
"get",
"(",
"'pmids'",
")",
"if",
"edge_pmids",
":",
"pmids",
"+=",
"... | Get list of all PMIDs associated with edges in the network. | [
"Get",
"list",
"of",
"all",
"PMIDs",
"associated",
"with",
"edges",
"in",
"the",
"network",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/processor.py#L166-L173 | train |
sorgerlab/indra | indra/sources/ndex_cx/processor.py | NdexCxProcessor.get_statements | def get_statements(self):
"""Convert network edges into Statements.
Returns
-------
list of Statements
Converted INDRA Statements.
"""
edges = _get_dict_from_list('edges', self.cx)
for edge in edges:
edge_type = edge.get('i')
i... | python | def get_statements(self):
"""Convert network edges into Statements.
Returns
-------
list of Statements
Converted INDRA Statements.
"""
edges = _get_dict_from_list('edges', self.cx)
for edge in edges:
edge_type = edge.get('i')
i... | [
"def",
"get_statements",
"(",
"self",
")",
":",
"edges",
"=",
"_get_dict_from_list",
"(",
"'edges'",
",",
"self",
".",
"cx",
")",
"for",
"edge",
"in",
"edges",
":",
"edge_type",
"=",
"edge",
".",
"get",
"(",
"'i'",
")",
"if",
"not",
"edge_type",
":",
... | Convert network edges into Statements.
Returns
-------
list of Statements
Converted INDRA Statements. | [
"Convert",
"network",
"edges",
"into",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/processor.py#L175-L204 | train |
sorgerlab/indra | indra/sources/tees/processor.py | TEESProcessor.node_has_edge_with_label | def node_has_edge_with_label(self, node_name, edge_label):
"""Looks for an edge from node_name to some other node with the specified
label. Returns the node to which this edge points if it exists, or None
if it doesn't.
Parameters
----------
G :
The graph obj... | python | def node_has_edge_with_label(self, node_name, edge_label):
"""Looks for an edge from node_name to some other node with the specified
label. Returns the node to which this edge points if it exists, or None
if it doesn't.
Parameters
----------
G :
The graph obj... | [
"def",
"node_has_edge_with_label",
"(",
"self",
",",
"node_name",
",",
"edge_label",
")",
":",
"G",
"=",
"self",
".",
"G",
"for",
"edge",
"in",
"G",
".",
"edges",
"(",
"node_name",
")",
":",
"to",
"=",
"edge",
"[",
"1",
"]",
"relation_name",
"=",
"G"... | Looks for an edge from node_name to some other node with the specified
label. Returns the node to which this edge points if it exists, or None
if it doesn't.
Parameters
----------
G :
The graph object
node_name :
Node that the edge starts at
... | [
"Looks",
"for",
"an",
"edge",
"from",
"node_name",
"to",
"some",
"other",
"node",
"with",
"the",
"specified",
"label",
".",
"Returns",
"the",
"node",
"to",
"which",
"this",
"edge",
"points",
"if",
"it",
"exists",
"or",
"None",
"if",
"it",
"doesn",
"t",
... | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L83-L104 | train |
sorgerlab/indra | indra/sources/tees/processor.py | TEESProcessor.general_node_label | def general_node_label(self, node):
"""Used for debugging - gives a short text description of a
graph node."""
G = self.G
if G.node[node]['is_event']:
return 'event type=' + G.node[node]['type']
else:
return 'entity text=' + G.node[node]['text'] | python | def general_node_label(self, node):
"""Used for debugging - gives a short text description of a
graph node."""
G = self.G
if G.node[node]['is_event']:
return 'event type=' + G.node[node]['type']
else:
return 'entity text=' + G.node[node]['text'] | [
"def",
"general_node_label",
"(",
"self",
",",
"node",
")",
":",
"G",
"=",
"self",
".",
"G",
"if",
"G",
".",
"node",
"[",
"node",
"]",
"[",
"'is_event'",
"]",
":",
"return",
"'event type='",
"+",
"G",
".",
"node",
"[",
"node",
"]",
"[",
"'type'",
... | Used for debugging - gives a short text description of a
graph node. | [
"Used",
"for",
"debugging",
"-",
"gives",
"a",
"short",
"text",
"description",
"of",
"a",
"graph",
"node",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L106-L113 | train |
sorgerlab/indra | indra/sources/tees/processor.py | TEESProcessor.print_parent_and_children_info | def print_parent_and_children_info(self, node):
"""Used for debugging - prints a short description of a a node, its
children, its parents, and its parents' children."""
G = self.G
parents = G.predecessors(node)
children = G.successors(node)
print(general_node_label(G, no... | python | def print_parent_and_children_info(self, node):
"""Used for debugging - prints a short description of a a node, its
children, its parents, and its parents' children."""
G = self.G
parents = G.predecessors(node)
children = G.successors(node)
print(general_node_label(G, no... | [
"def",
"print_parent_and_children_info",
"(",
"self",
",",
"node",
")",
":",
"G",
"=",
"self",
".",
"G",
"parents",
"=",
"G",
".",
"predecessors",
"(",
"node",
")",
"children",
"=",
"G",
".",
"successors",
"(",
"node",
")",
"print",
"(",
"general_node_la... | Used for debugging - prints a short description of a a node, its
children, its parents, and its parents' children. | [
"Used",
"for",
"debugging",
"-",
"prints",
"a",
"short",
"description",
"of",
"a",
"a",
"node",
"its",
"children",
"its",
"parents",
"and",
"its",
"parents",
"children",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L115-L136 | train |
sorgerlab/indra | indra/sources/tees/processor.py | TEESProcessor.find_event_with_outgoing_edges | def find_event_with_outgoing_edges(self, event_name, desired_relations):
"""Gets a list of event nodes with the specified event_name and
outgoing edges annotated with each of the specified relations.
Parameters
----------
event_name : str
Look for event nodes with th... | python | def find_event_with_outgoing_edges(self, event_name, desired_relations):
"""Gets a list of event nodes with the specified event_name and
outgoing edges annotated with each of the specified relations.
Parameters
----------
event_name : str
Look for event nodes with th... | [
"def",
"find_event_with_outgoing_edges",
"(",
"self",
",",
"event_name",
",",
"desired_relations",
")",
":",
"G",
"=",
"self",
".",
"G",
"desired_relations",
"=",
"set",
"(",
"desired_relations",
")",
"desired_event_nodes",
"=",
"[",
"]",
"for",
"node",
"in",
... | Gets a list of event nodes with the specified event_name and
outgoing edges annotated with each of the specified relations.
Parameters
----------
event_name : str
Look for event nodes with this name
desired_relations : list[str]
Look for event nodes with ... | [
"Gets",
"a",
"list",
"of",
"event",
"nodes",
"with",
"the",
"specified",
"event_name",
"and",
"outgoing",
"edges",
"annotated",
"with",
"each",
"of",
"the",
"specified",
"relations",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L154-L186 | train |
sorgerlab/indra | indra/sources/tees/processor.py | TEESProcessor.get_related_node | def get_related_node(self, node, relation):
"""Looks for an edge from node to some other node, such that the edge
is annotated with the given relation. If there exists such an edge,
returns the name of the node it points to. Otherwise, returns None."""
G = self.G
for edge in G.ed... | python | def get_related_node(self, node, relation):
"""Looks for an edge from node to some other node, such that the edge
is annotated with the given relation. If there exists such an edge,
returns the name of the node it points to. Otherwise, returns None."""
G = self.G
for edge in G.ed... | [
"def",
"get_related_node",
"(",
"self",
",",
"node",
",",
"relation",
")",
":",
"G",
"=",
"self",
".",
"G",
"for",
"edge",
"in",
"G",
".",
"edges",
"(",
"node",
")",
":",
"to",
"=",
"edge",
"[",
"1",
"]",
"to_relation",
"=",
"G",
".",
"edges",
... | Looks for an edge from node to some other node, such that the edge
is annotated with the given relation. If there exists such an edge,
returns the name of the node it points to. Otherwise, returns None. | [
"Looks",
"for",
"an",
"edge",
"from",
"node",
"to",
"some",
"other",
"node",
"such",
"that",
"the",
"edge",
"is",
"annotated",
"with",
"the",
"given",
"relation",
".",
"If",
"there",
"exists",
"such",
"an",
"edge",
"returns",
"the",
"name",
"of",
"the",
... | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L188-L199 | train |
sorgerlab/indra | indra/sources/tees/processor.py | TEESProcessor.get_entity_text_for_relation | def get_entity_text_for_relation(self, node, relation):
"""Looks for an edge from node to some other node, such that the edge is
annotated with the given relation. If there exists such an edge, and
the node at the other edge is an entity, return that entity's text.
Otherwise, returns Non... | python | def get_entity_text_for_relation(self, node, relation):
"""Looks for an edge from node to some other node, such that the edge is
annotated with the given relation. If there exists such an edge, and
the node at the other edge is an entity, return that entity's text.
Otherwise, returns Non... | [
"def",
"get_entity_text_for_relation",
"(",
"self",
",",
"node",
",",
"relation",
")",
":",
"G",
"=",
"self",
".",
"G",
"related_node",
"=",
"self",
".",
"get_related_node",
"(",
"node",
",",
"relation",
")",
"if",
"related_node",
"is",
"not",
"None",
":",... | Looks for an edge from node to some other node, such that the edge is
annotated with the given relation. If there exists such an edge, and
the node at the other edge is an entity, return that entity's text.
Otherwise, returns None. | [
"Looks",
"for",
"an",
"edge",
"from",
"node",
"to",
"some",
"other",
"node",
"such",
"that",
"the",
"edge",
"is",
"annotated",
"with",
"the",
"given",
"relation",
".",
"If",
"there",
"exists",
"such",
"an",
"edge",
"and",
"the",
"node",
"at",
"the",
"o... | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L201-L215 | train |
sorgerlab/indra | indra/sources/tees/processor.py | TEESProcessor.process_increase_expression_amount | def process_increase_expression_amount(self):
"""Looks for Positive_Regulation events with a specified Cause
and a Gene_Expression theme, and processes them into INDRA statements.
"""
statements = []
pwcs = self.find_event_parent_with_event_child(
'Positive_regul... | python | def process_increase_expression_amount(self):
"""Looks for Positive_Regulation events with a specified Cause
and a Gene_Expression theme, and processes them into INDRA statements.
"""
statements = []
pwcs = self.find_event_parent_with_event_child(
'Positive_regul... | [
"def",
"process_increase_expression_amount",
"(",
"self",
")",
":",
"statements",
"=",
"[",
"]",
"pwcs",
"=",
"self",
".",
"find_event_parent_with_event_child",
"(",
"'Positive_regulation'",
",",
"'Gene_expression'",
")",
"for",
"pair",
"in",
"pwcs",
":",
"pos_reg",... | Looks for Positive_Regulation events with a specified Cause
and a Gene_Expression theme, and processes them into INDRA statements. | [
"Looks",
"for",
"Positive_Regulation",
"events",
"with",
"a",
"specified",
"Cause",
"and",
"a",
"Gene_Expression",
"theme",
"and",
"processes",
"them",
"into",
"INDRA",
"statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L217-L239 | train |
sorgerlab/indra | indra/sources/tees/processor.py | TEESProcessor.process_phosphorylation_statements | def process_phosphorylation_statements(self):
"""Looks for Phosphorylation events in the graph and extracts them into
INDRA statements.
In particular, looks for a Positive_regulation event node with a child
Phosphorylation event node.
If Positive_regulation has an outgoing Caus... | python | def process_phosphorylation_statements(self):
"""Looks for Phosphorylation events in the graph and extracts them into
INDRA statements.
In particular, looks for a Positive_regulation event node with a child
Phosphorylation event node.
If Positive_regulation has an outgoing Caus... | [
"def",
"process_phosphorylation_statements",
"(",
"self",
")",
":",
"G",
"=",
"self",
".",
"G",
"statements",
"=",
"[",
"]",
"pwcs",
"=",
"self",
".",
"find_event_parent_with_event_child",
"(",
"'Positive_regulation'",
",",
"'Phosphorylation'",
")",
"for",
"pair",... | Looks for Phosphorylation events in the graph and extracts them into
INDRA statements.
In particular, looks for a Positive_regulation event node with a child
Phosphorylation event node.
If Positive_regulation has an outgoing Cause edge, that's the subject
If Phosphorylation has... | [
"Looks",
"for",
"Phosphorylation",
"events",
"in",
"the",
"graph",
"and",
"extracts",
"them",
"into",
"INDRA",
"statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L265-L309 | train |
sorgerlab/indra | indra/sources/tees/processor.py | TEESProcessor.process_binding_statements | def process_binding_statements(self):
"""Looks for Binding events in the graph and extracts them into INDRA
statements.
In particular, looks for a Binding event node with outgoing edges
with relations Theme and Theme2 - the entities these edges point to
are the two constituents ... | python | def process_binding_statements(self):
"""Looks for Binding events in the graph and extracts them into INDRA
statements.
In particular, looks for a Binding event node with outgoing edges
with relations Theme and Theme2 - the entities these edges point to
are the two constituents ... | [
"def",
"process_binding_statements",
"(",
"self",
")",
":",
"G",
"=",
"self",
".",
"G",
"statements",
"=",
"[",
"]",
"binding_nodes",
"=",
"self",
".",
"find_event_with_outgoing_edges",
"(",
"'Binding'",
",",
"[",
"'Theme'",
",",
"'Theme2'",
"]",
")",
"for",... | Looks for Binding events in the graph and extracts them into INDRA
statements.
In particular, looks for a Binding event node with outgoing edges
with relations Theme and Theme2 - the entities these edges point to
are the two constituents of the Complex INDRA statement. | [
"Looks",
"for",
"Binding",
"events",
"in",
"the",
"graph",
"and",
"extracts",
"them",
"into",
"INDRA",
"statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L311-L338 | train |
sorgerlab/indra | indra/sources/tees/processor.py | TEESProcessor.node_to_evidence | def node_to_evidence(self, entity_node, is_direct):
"""Computes an evidence object for a statement.
We assume that the entire event happens within a single statement, and
get the text of the sentence by getting the text of the sentence
containing the provided node that corresponds to on... | python | def node_to_evidence(self, entity_node, is_direct):
"""Computes an evidence object for a statement.
We assume that the entire event happens within a single statement, and
get the text of the sentence by getting the text of the sentence
containing the provided node that corresponds to on... | [
"def",
"node_to_evidence",
"(",
"self",
",",
"entity_node",
",",
"is_direct",
")",
":",
"# We assume that the entire event is within a single sentence, and",
"# get this sentence by getting the sentence containing one of the",
"# entities",
"sentence_text",
"=",
"self",
".",
"G",
... | Computes an evidence object for a statement.
We assume that the entire event happens within a single statement, and
get the text of the sentence by getting the text of the sentence
containing the provided node that corresponds to one of the entities
participanting in the event.
... | [
"Computes",
"an",
"evidence",
"object",
"for",
"a",
"statement",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L340-L375 | train |
sorgerlab/indra | indra/sources/tees/processor.py | TEESProcessor.connected_subgraph | def connected_subgraph(self, node):
"""Returns the subgraph containing the given node, its ancestors, and
its descendants.
Parameters
----------
node : str
We want to create the subgraph containing this node.
Returns
-------
subgraph : networ... | python | def connected_subgraph(self, node):
"""Returns the subgraph containing the given node, its ancestors, and
its descendants.
Parameters
----------
node : str
We want to create the subgraph containing this node.
Returns
-------
subgraph : networ... | [
"def",
"connected_subgraph",
"(",
"self",
",",
"node",
")",
":",
"G",
"=",
"self",
".",
"G",
"subgraph_nodes",
"=",
"set",
"(",
")",
"subgraph_nodes",
".",
"add",
"(",
"node",
")",
"subgraph_nodes",
".",
"update",
"(",
"dag",
".",
"ancestors",
"(",
"G"... | Returns the subgraph containing the given node, its ancestors, and
its descendants.
Parameters
----------
node : str
We want to create the subgraph containing this node.
Returns
-------
subgraph : networkx.DiGraph
The subgraph containing ... | [
"Returns",
"the",
"subgraph",
"containing",
"the",
"given",
"node",
"its",
"ancestors",
"and",
"its",
"descendants",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L377-L412 | train |
sorgerlab/indra | indra/sources/trips/api.py | process_text | def process_text(text, save_xml_name='trips_output.xml', save_xml_pretty=True,
offline=False, service_endpoint='drum'):
"""Return a TripsProcessor by processing text.
Parameters
----------
text : str
The text to be processed.
save_xml_name : Optional[str]
The name o... | python | def process_text(text, save_xml_name='trips_output.xml', save_xml_pretty=True,
offline=False, service_endpoint='drum'):
"""Return a TripsProcessor by processing text.
Parameters
----------
text : str
The text to be processed.
save_xml_name : Optional[str]
The name o... | [
"def",
"process_text",
"(",
"text",
",",
"save_xml_name",
"=",
"'trips_output.xml'",
",",
"save_xml_pretty",
"=",
"True",
",",
"offline",
"=",
"False",
",",
"service_endpoint",
"=",
"'drum'",
")",
":",
"if",
"not",
"offline",
":",
"html",
"=",
"client",
".",... | Return a TripsProcessor by processing text.
Parameters
----------
text : str
The text to be processed.
save_xml_name : Optional[str]
The name of the file to save the returned TRIPS extraction knowledge
base XML. Default: trips_output.xml
save_xml_pretty : Optional[bool]
... | [
"Return",
"a",
"TripsProcessor",
"by",
"processing",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/api.py#L18-L80 | train |
sorgerlab/indra | indra/sources/trips/api.py | process_xml_file | def process_xml_file(file_name):
"""Return a TripsProcessor by processing a TRIPS EKB XML file.
Parameters
----------
file_name : str
Path to a TRIPS extraction knowledge base (EKB) file to be processed.
Returns
-------
tp : TripsProcessor
A TripsProcessor containing the ex... | python | def process_xml_file(file_name):
"""Return a TripsProcessor by processing a TRIPS EKB XML file.
Parameters
----------
file_name : str
Path to a TRIPS extraction knowledge base (EKB) file to be processed.
Returns
-------
tp : TripsProcessor
A TripsProcessor containing the ex... | [
"def",
"process_xml_file",
"(",
"file_name",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"'rb'",
")",
"as",
"fh",
":",
"ekb",
"=",
"fh",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"return",
"process_xml",
"(",
"ekb",
")"
] | Return a TripsProcessor by processing a TRIPS EKB XML file.
Parameters
----------
file_name : str
Path to a TRIPS extraction knowledge base (EKB) file to be processed.
Returns
-------
tp : TripsProcessor
A TripsProcessor containing the extracted INDRA Statements
in tp.s... | [
"Return",
"a",
"TripsProcessor",
"by",
"processing",
"a",
"TRIPS",
"EKB",
"XML",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/api.py#L83-L99 | train |
sorgerlab/indra | indra/sources/trips/api.py | process_xml | def process_xml(xml_string):
"""Return a TripsProcessor by processing a TRIPS EKB XML string.
Parameters
----------
xml_string : str
A TRIPS extraction knowledge base (EKB) string to be processed.
http://trips.ihmc.us/parser/api.html
Returns
-------
tp : TripsProcessor
... | python | def process_xml(xml_string):
"""Return a TripsProcessor by processing a TRIPS EKB XML string.
Parameters
----------
xml_string : str
A TRIPS extraction knowledge base (EKB) string to be processed.
http://trips.ihmc.us/parser/api.html
Returns
-------
tp : TripsProcessor
... | [
"def",
"process_xml",
"(",
"xml_string",
")",
":",
"tp",
"=",
"TripsProcessor",
"(",
"xml_string",
")",
"if",
"tp",
".",
"tree",
"is",
"None",
":",
"return",
"None",
"tp",
".",
"get_modifications_indirect",
"(",
")",
"tp",
".",
"get_activations_causal",
"(",... | Return a TripsProcessor by processing a TRIPS EKB XML string.
Parameters
----------
xml_string : str
A TRIPS extraction knowledge base (EKB) string to be processed.
http://trips.ihmc.us/parser/api.html
Returns
-------
tp : TripsProcessor
A TripsProcessor containing the ... | [
"Return",
"a",
"TripsProcessor",
"by",
"processing",
"a",
"TRIPS",
"EKB",
"XML",
"string",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/api.py#L102-L134 | train |
sorgerlab/indra | indra/belief/wm_scorer.py | load_eidos_curation_table | def load_eidos_curation_table():
"""Return a pandas table of Eidos curation data."""
url = 'https://raw.githubusercontent.com/clulab/eidos/master/' + \
'src/main/resources/org/clulab/wm/eidos/english/confidence/' + \
'rule_summary.tsv'
# Load the table of scores from the URL above into a dat... | python | def load_eidos_curation_table():
"""Return a pandas table of Eidos curation data."""
url = 'https://raw.githubusercontent.com/clulab/eidos/master/' + \
'src/main/resources/org/clulab/wm/eidos/english/confidence/' + \
'rule_summary.tsv'
# Load the table of scores from the URL above into a dat... | [
"def",
"load_eidos_curation_table",
"(",
")",
":",
"url",
"=",
"'https://raw.githubusercontent.com/clulab/eidos/master/'",
"+",
"'src/main/resources/org/clulab/wm/eidos/english/confidence/'",
"+",
"'rule_summary.tsv'",
"# Load the table of scores from the URL above into a data frame",
"res... | Return a pandas table of Eidos curation data. | [
"Return",
"a",
"pandas",
"table",
"of",
"Eidos",
"curation",
"data",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/wm_scorer.py#L11-L21 | train |
sorgerlab/indra | indra/belief/wm_scorer.py | get_eidos_bayesian_scorer | def get_eidos_bayesian_scorer(prior_counts=None):
"""Return a BayesianScorer based on Eidos curation counts."""
table = load_eidos_curation_table()
subtype_counts = {'eidos': {r: [c, i] for r, c, i in
zip(table['RULE'], table['Num correct'],
ta... | python | def get_eidos_bayesian_scorer(prior_counts=None):
"""Return a BayesianScorer based on Eidos curation counts."""
table = load_eidos_curation_table()
subtype_counts = {'eidos': {r: [c, i] for r, c, i in
zip(table['RULE'], table['Num correct'],
ta... | [
"def",
"get_eidos_bayesian_scorer",
"(",
"prior_counts",
"=",
"None",
")",
":",
"table",
"=",
"load_eidos_curation_table",
"(",
")",
"subtype_counts",
"=",
"{",
"'eidos'",
":",
"{",
"r",
":",
"[",
"c",
",",
"i",
"]",
"for",
"r",
",",
"c",
",",
"i",
"in... | Return a BayesianScorer based on Eidos curation counts. | [
"Return",
"a",
"BayesianScorer",
"based",
"on",
"Eidos",
"curation",
"counts",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/wm_scorer.py#L24-L35 | train |
sorgerlab/indra | indra/belief/wm_scorer.py | get_eidos_scorer | def get_eidos_scorer():
"""Return a SimpleScorer based on Eidos curated precision estimates."""
table = load_eidos_curation_table()
# Get the overall precision
total_num = table['COUNT of RULE'].sum()
weighted_sum = table['COUNT of RULE'].dot(table['% correct'])
precision = weighted_sum / total... | python | def get_eidos_scorer():
"""Return a SimpleScorer based on Eidos curated precision estimates."""
table = load_eidos_curation_table()
# Get the overall precision
total_num = table['COUNT of RULE'].sum()
weighted_sum = table['COUNT of RULE'].dot(table['% correct'])
precision = weighted_sum / total... | [
"def",
"get_eidos_scorer",
"(",
")",
":",
"table",
"=",
"load_eidos_curation_table",
"(",
")",
"# Get the overall precision",
"total_num",
"=",
"table",
"[",
"'COUNT of RULE'",
"]",
".",
"sum",
"(",
")",
"weighted_sum",
"=",
"table",
"[",
"'COUNT of RULE'",
"]",
... | Return a SimpleScorer based on Eidos curated precision estimates. | [
"Return",
"a",
"SimpleScorer",
"based",
"on",
"Eidos",
"curated",
"precision",
"estimates",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/wm_scorer.py#L38-L57 | train |
sorgerlab/indra | indra/sources/trrust/api.py | process_from_web | def process_from_web():
"""Return a TrrustProcessor based on the online interaction table.
Returns
-------
TrrustProcessor
A TrrustProcessor object that has a list of INDRA Statements in its
statements attribute.
"""
logger.info('Downloading table from %s' % trrust_human_url)
... | python | def process_from_web():
"""Return a TrrustProcessor based on the online interaction table.
Returns
-------
TrrustProcessor
A TrrustProcessor object that has a list of INDRA Statements in its
statements attribute.
"""
logger.info('Downloading table from %s' % trrust_human_url)
... | [
"def",
"process_from_web",
"(",
")",
":",
"logger",
".",
"info",
"(",
"'Downloading table from %s'",
"%",
"trrust_human_url",
")",
"res",
"=",
"requests",
".",
"get",
"(",
"trrust_human_url",
")",
"res",
".",
"raise_for_status",
"(",
")",
"df",
"=",
"pandas",
... | Return a TrrustProcessor based on the online interaction table.
Returns
-------
TrrustProcessor
A TrrustProcessor object that has a list of INDRA Statements in its
statements attribute. | [
"Return",
"a",
"TrrustProcessor",
"based",
"on",
"the",
"online",
"interaction",
"table",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trrust/api.py#L18-L33 | train |
sorgerlab/indra | indra/sources/rlimsp/api.py | process_from_webservice | def process_from_webservice(id_val, id_type='pmcid', source='pmc',
with_grounding=True):
"""Return an output from RLIMS-p for the given PubMed ID or PMC ID.
Parameters
----------
id_val : str
A PMCID, with the prefix PMC, or pmid, with no prefix, of the paper to
... | python | def process_from_webservice(id_val, id_type='pmcid', source='pmc',
with_grounding=True):
"""Return an output from RLIMS-p for the given PubMed ID or PMC ID.
Parameters
----------
id_val : str
A PMCID, with the prefix PMC, or pmid, with no prefix, of the paper to
... | [
"def",
"process_from_webservice",
"(",
"id_val",
",",
"id_type",
"=",
"'pmcid'",
",",
"source",
"=",
"'pmc'",
",",
"with_grounding",
"=",
"True",
")",
":",
"if",
"with_grounding",
":",
"fmt",
"=",
"'%s.normed/%s/%s'",
"else",
":",
"fmt",
"=",
"'%s/%s/%s'",
"... | Return an output from RLIMS-p for the given PubMed ID or PMC ID.
Parameters
----------
id_val : str
A PMCID, with the prefix PMC, or pmid, with no prefix, of the paper to
be "read".
id_type : str
Either 'pmid' or 'pmcid'. The default is 'pmcid'.
source : str
Either '... | [
"Return",
"an",
"output",
"from",
"RLIMS",
"-",
"p",
"for",
"the",
"given",
"PubMed",
"ID",
"or",
"PMC",
"ID",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/rlimsp/api.py#L21-L59 | train |
sorgerlab/indra | indra/sources/rlimsp/api.py | process_from_json_file | 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 | 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... | [
"def",
"process_from_json_file",
"(",
"filename",
",",
"doc_id_type",
"=",
"None",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'rt'",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"readlines",
"(",
")",
"json_list",
"=",
"[",
"]",
"for",
"line",
... | 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
'pmcid' explicitly, instead if contains a 'docId' key. This param... | [
"Process",
"RLIMSP",
"extractions",
"from",
"a",
"bulk",
"-",
"download",
"JSON",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/rlimsp/api.py#L62-L88 | train |
sorgerlab/indra | indra/util/nested_dict.py | NestedDict.get | 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 | 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... | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"keys",
"(",
")",
":",
"return",
"self",
"[",
"key",
"]",
"else",
":",
"res",
"=",
"None",
"for",
"v",
"in",
"self",
".",
"values",
"(",
")",
":",
"# This could ge... | Find the first value within the tree which has the key. | [
"Find",
"the",
"first",
"value",
"within",
"the",
"tree",
"which",
"has",
"the",
"key",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/nested_dict.py#L58-L72 | train |
sorgerlab/indra | indra/util/nested_dict.py | NestedDict.get_path | 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 | 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__):
... | [
"def",
"get_path",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"keys",
"(",
")",
":",
"return",
"(",
"key",
",",
")",
",",
"self",
"[",
"key",
"]",
"else",
":",
"key_path",
",",
"res",
"=",
"(",
"None",
",",
"None",
")"... | Like `get`, but also return the path taken to the value. | [
"Like",
"get",
"but",
"also",
"return",
"the",
"path",
"taken",
"to",
"the",
"value",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/nested_dict.py#L74-L89 | train |
sorgerlab/indra | indra/util/nested_dict.py | NestedDict.gets | 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 | 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)
... | [
"def",
"gets",
"(",
"self",
",",
"key",
")",
":",
"result_list",
"=",
"[",
"]",
"if",
"key",
"in",
"self",
".",
"keys",
"(",
")",
":",
"result_list",
".",
"append",
"(",
"self",
"[",
"key",
"]",
")",
"for",
"v",
"in",
"self",
".",
"values",
"("... | Like `get`, but return all matches, not just the first. | [
"Like",
"get",
"but",
"return",
"all",
"matches",
"not",
"just",
"the",
"first",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/nested_dict.py#L91-L104 | train |
sorgerlab/indra | indra/util/nested_dict.py | NestedDict.get_paths | 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 | 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... | [
"def",
"get_paths",
"(",
"self",
",",
"key",
")",
":",
"result_list",
"=",
"[",
"]",
"if",
"key",
"in",
"self",
".",
"keys",
"(",
")",
":",
"result_list",
".",
"append",
"(",
"(",
"(",
"key",
",",
")",
",",
"self",
"[",
"key",
"]",
")",
")",
... | Like `gets`, but include the paths, like `get_path` for all matches. | [
"Like",
"gets",
"but",
"include",
"the",
"paths",
"like",
"get_path",
"for",
"all",
"matches",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/nested_dict.py#L106-L119 | train |
sorgerlab/indra | indra/util/nested_dict.py | NestedDict.get_leaves | 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 | 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())
... | [
"def",
"get_leaves",
"(",
"self",
")",
":",
"ret_set",
"=",
"set",
"(",
")",
"for",
"val",
"in",
"self",
".",
"values",
"(",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"self",
".",
"__class__",
")",
":",
"ret_set",
"|=",
"val",
".",
"get_leaves... | Get the deepest entries as a flat set. | [
"Get",
"the",
"deepest",
"entries",
"as",
"a",
"flat",
"set",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/nested_dict.py#L121-L135 | train |
sorgerlab/indra | indra/sources/reach/processor.py | determine_reach_subtype | 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 | 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 ... | [
"def",
"determine_reach_subtype",
"(",
"event_name",
")",
":",
"best_match_length",
"=",
"None",
"best_match",
"=",
"None",
"for",
"ss",
"in",
"reach_rule_regexps",
":",
"if",
"re",
".",
"search",
"(",
"ss",
",",
"event_name",
")",
":",
"if",
"best_match",
"... | 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 : indra.statements.Evidence
A reach evid... | [
"Returns",
"the",
"category",
"of",
"reach",
"rule",
"from",
"the",
"reach",
"rule",
"instance",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L835-L862 | train |
sorgerlab/indra | indra/sources/reach/processor.py | ReachProcessor.print_event_statistics | 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 | 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('-----------------... | [
"def",
"print_event_statistics",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'All events by type'",
")",
"logger",
".",
"info",
"(",
"'-------------------'",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"all_events",
".",
"items",
"(",
")",
":",
... | Print the number of events in the REACH output by type. | [
"Print",
"the",
"number",
"of",
"events",
"in",
"the",
"REACH",
"output",
"by",
"type",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L52-L58 | train |
sorgerlab/indra | indra/sources/reach/processor.py | ReachProcessor.get_all_events | 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 | 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:
... | [
"def",
"get_all_events",
"(",
"self",
")",
":",
"self",
".",
"all_events",
"=",
"{",
"}",
"events",
"=",
"self",
".",
"tree",
".",
"execute",
"(",
"\"$.events.frames\"",
")",
"if",
"events",
"is",
"None",
":",
"return",
"for",
"e",
"in",
"events",
":",... | Gather all event IDs in the REACH output by type.
These IDs are stored in the self.all_events dict. | [
"Gather",
"all",
"event",
"IDs",
"in",
"the",
"REACH",
"output",
"by",
"type",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L60-L75 | train |
sorgerlab/indra | indra/sources/reach/processor.py | ReachProcessor.get_modifications | 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 | 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... | [
"def",
"get_modifications",
"(",
"self",
")",
":",
"# 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",
"i... | Extract Modification INDRA Statements. | [
"Extract",
"Modification",
"INDRA",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L87-L173 | train |
sorgerlab/indra | indra/sources/reach/processor.py | ReachProcessor.get_regulate_amounts | 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 | 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'... | [
"def",
"get_regulate_amounts",
"(",
"self",
")",
":",
"qstr",
"=",
"\"$.events.frames[(@.type is 'transcription')]\"",
"res",
"=",
"self",
".",
"tree",
".",
"execute",
"(",
"qstr",
")",
"all_res",
"=",
"[",
"]",
"if",
"res",
"is",
"not",
"None",
":",
"all_re... | Extract RegulateAmount INDRA Statements. | [
"Extract",
"RegulateAmount",
"INDRA",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L175-L224 | train |
sorgerlab/indra | indra/sources/reach/processor.py | ReachProcessor.get_complexes | 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 | 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('... | [
"def",
"get_complexes",
"(",
"self",
")",
":",
"qstr",
"=",
"\"$.events.frames[@.type is 'complex-assembly']\"",
"res",
"=",
"self",
".",
"tree",
".",
"execute",
"(",
"qstr",
")",
"if",
"res",
"is",
"None",
":",
"return",
"for",
"r",
"in",
"res",
":",
"epi... | Extract INDRA Complex Statements. | [
"Extract",
"INDRA",
"Complex",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L226-L258 | train |
sorgerlab/indra | indra/sources/reach/processor.py | ReachProcessor.get_activation | 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 | 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... | [
"def",
"get_activation",
"(",
"self",
")",
":",
"qstr",
"=",
"\"$.events.frames[@.type is 'activation']\"",
"res",
"=",
"self",
".",
"tree",
".",
"execute",
"(",
"qstr",
")",
"if",
"res",
"is",
"None",
":",
"return",
"for",
"r",
"in",
"res",
":",
"epistemi... | Extract INDRA Activation Statements. | [
"Extract",
"INDRA",
"Activation",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L260-L292 | train |
sorgerlab/indra | indra/sources/reach/processor.py | ReachProcessor.get_translocation | 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 | 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... | [
"def",
"get_translocation",
"(",
"self",
")",
":",
"qstr",
"=",
"\"$.events.frames[@.type is 'translocation']\"",
"res",
"=",
"self",
".",
"tree",
".",
"execute",
"(",
"qstr",
")",
"if",
"res",
"is",
"None",
":",
"return",
"for",
"r",
"in",
"res",
":",
"ep... | Extract INDRA Translocation Statements. | [
"Extract",
"INDRA",
"Translocation",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L294-L324 | train |
sorgerlab/indra | indra/sources/reach/processor.py | ReachProcessor._get_mod_conditions | 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 | 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:
... | [
"def",
"_get_mod_conditions",
"(",
"self",
",",
"mod_term",
")",
":",
"site",
"=",
"mod_term",
".",
"get",
"(",
"'site'",
")",
"if",
"site",
"is",
"not",
"None",
":",
"mods",
"=",
"self",
".",
"_parse_site_text",
"(",
"site",
")",
"else",
":",
"mods",
... | Return a list of ModConditions given a mod term dict. | [
"Return",
"a",
"list",
"of",
"ModConditions",
"given",
"a",
"mod",
"term",
"dict",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L469-L489 | train |
sorgerlab/indra | indra/sources/reach/processor.py | ReachProcessor._get_entity_coordinates | 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 | 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.
"""
... | [
"def",
"_get_entity_coordinates",
"(",
"self",
",",
"entity_term",
")",
":",
"# The following lines get the starting coordinate of the sentence",
"# containing the entity.",
"sent_id",
"=",
"entity_term",
".",
"get",
"(",
"'sentence'",
")",
"if",
"sent_id",
"is",
"None",
... | 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. | [
"Return",
"sentence",
"coordinates",
"for",
"a",
"given",
"entity",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L491-L529 | train |
sorgerlab/indra | indra/sources/reach/processor.py | ReachProcessor._get_section | 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 | 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)
... | [
"def",
"_get_section",
"(",
"self",
",",
"event",
")",
":",
"sentence_id",
"=",
"event",
".",
"get",
"(",
"'sentence'",
")",
"section",
"=",
"None",
"if",
"sentence_id",
":",
"qstr",
"=",
"\"$.sentences.frames[(@.frame_id is \\'%s\\')]\"",
"%",
"sentence_id",
"r... | Get the section of the paper that the event is from. | [
"Get",
"the",
"section",
"of",
"the",
"paper",
"that",
"the",
"event",
"is",
"from",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L610-L644 | train |
sorgerlab/indra | indra/sources/reach/processor.py | ReachProcessor._get_controller_agent | 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 | 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(... | [
"def",
"_get_controller_agent",
"(",
"self",
",",
"arg",
")",
":",
"controller_agent",
"=",
"None",
"controller",
"=",
"arg",
".",
"get",
"(",
"'arg'",
")",
"# There is either a single controller here",
"if",
"controller",
"is",
"not",
"None",
":",
"controller_age... | Return a single or a complex controller agent. | [
"Return",
"a",
"single",
"or",
"a",
"complex",
"controller",
"agent",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L646-L663 | train |
sorgerlab/indra | indra/sources/eidos/processor.py | _sanitize | 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 | 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) | [
"def",
"_sanitize",
"(",
"text",
")",
":",
"d",
"=",
"{",
"'-LRB-'",
":",
"'('",
",",
"'-RRB-'",
":",
"')'",
"}",
"return",
"re",
".",
"sub",
"(",
"'|'",
".",
"join",
"(",
"d",
".",
"keys",
"(",
")",
")",
",",
"lambda",
"m",
":",
"d",
"[",
... | Return sanitized Eidos text field for human readability. | [
"Return",
"sanitized",
"Eidos",
"text",
"field",
"for",
"human",
"readability",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L380-L383 | train |
sorgerlab/indra | indra/sources/eidos/processor.py | ref_context_from_geoloc | 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 | 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 | [
"def",
"ref_context_from_geoloc",
"(",
"geoloc",
")",
":",
"text",
"=",
"geoloc",
".",
"get",
"(",
"'text'",
")",
"geoid",
"=",
"geoloc",
".",
"get",
"(",
"'geoID'",
")",
"rc",
"=",
"RefContext",
"(",
"name",
"=",
"text",
",",
"db_refs",
"=",
"{",
"'... | Return a RefContext object given a geoloc entry. | [
"Return",
"a",
"RefContext",
"object",
"given",
"a",
"geoloc",
"entry",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L401-L406 | train |
sorgerlab/indra | indra/sources/eidos/processor.py | time_context_from_timex | 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 | 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... | [
"def",
"time_context_from_timex",
"(",
"timex",
")",
":",
"time_text",
"=",
"timex",
".",
"get",
"(",
"'text'",
")",
"constraint",
"=",
"timex",
"[",
"'intervals'",
"]",
"[",
"0",
"]",
"start",
"=",
"_get_time_stamp",
"(",
"constraint",
".",
"get",
"(",
... | Return a TimeContext object given a timex entry. | [
"Return",
"a",
"TimeContext",
"object",
"given",
"a",
"timex",
"entry",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L409-L418 | train |
sorgerlab/indra | indra/sources/eidos/processor.py | find_args | 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 | 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 [] | [
"def",
"find_args",
"(",
"event",
",",
"arg_type",
")",
":",
"args",
"=",
"event",
".",
"get",
"(",
"'arguments'",
",",
"{",
"}",
")",
"obj_tags",
"=",
"[",
"arg",
"for",
"arg",
"in",
"args",
"if",
"arg",
"[",
"'type'",
"]",
"==",
"arg_type",
"]",
... | Return IDs of all arguments of a given type | [
"Return",
"IDs",
"of",
"all",
"arguments",
"of",
"a",
"given",
"type"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L430-L437 | train |
sorgerlab/indra | indra/sources/eidos/processor.py | EidosProcessor.extract_causal_relations | 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 | 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']]... | [
"def",
"extract_causal_relations",
"(",
"self",
")",
":",
"# Get the extractions that are labeled as directed and causal",
"relations",
"=",
"[",
"e",
"for",
"e",
"in",
"self",
".",
"doc",
".",
"extractions",
"if",
"'DirectedRelation'",
"in",
"e",
"[",
"'labels'",
"... | Extract causal relations as Statements. | [
"Extract",
"causal",
"relations",
"as",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L27-L38 | train |
sorgerlab/indra | indra/sources/eidos/processor.py | EidosProcessor.get_evidence | 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 | 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[... | [
"def",
"get_evidence",
"(",
"self",
",",
"relation",
")",
":",
"provenance",
"=",
"relation",
".",
"get",
"(",
"'provenance'",
")",
"# First try looking up the full sentence through provenance",
"text",
"=",
"None",
"context",
"=",
"None",
"if",
"provenance",
":",
... | Return the Evidence object for the INDRA Statment. | [
"Return",
"the",
"Evidence",
"object",
"for",
"the",
"INDRA",
"Statment",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L119-L181 | train |
sorgerlab/indra | indra/sources/eidos/processor.py | EidosProcessor.get_negation | 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 | 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 ... | [
"def",
"get_negation",
"(",
"event",
")",
":",
"states",
"=",
"event",
".",
"get",
"(",
"'states'",
",",
"[",
"]",
")",
"if",
"not",
"states",
":",
"return",
"[",
"]",
"negs",
"=",
"[",
"state",
"for",
"state",
"in",
"states",
"if",
"state",
".",
... | Return negation attached to an event.
Example: "states": [{"@type": "State", "type": "NEGATION",
"text": "n't"}] | [
"Return",
"negation",
"attached",
"to",
"an",
"event",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L184-L196 | train |
sorgerlab/indra | indra/sources/eidos/processor.py | EidosProcessor.get_hedging | 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 | 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... | [
"def",
"get_hedging",
"(",
"event",
")",
":",
"states",
"=",
"event",
".",
"get",
"(",
"'states'",
",",
"[",
"]",
")",
"if",
"not",
"states",
":",
"return",
"[",
"]",
"hedgings",
"=",
"[",
"state",
"for",
"state",
"in",
"states",
"if",
"state",
"."... | Return hedging markers attached to an event.
Example: "states": [{"@type": "State", "type": "HEDGE",
"text": "could"} | [
"Return",
"hedging",
"markers",
"attached",
"to",
"an",
"event",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L199-L211 | train |
sorgerlab/indra | indra/sources/eidos/processor.py | EidosProcessor.get_groundings | 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 | 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... | [
"def",
"get_groundings",
"(",
"entity",
")",
":",
"def",
"get_grounding_entries",
"(",
"grounding",
")",
":",
"if",
"not",
"grounding",
":",
"return",
"None",
"entries",
"=",
"[",
"]",
"values",
"=",
"grounding",
".",
"get",
"(",
"'values'",
",",
"[",
"]... | Return groundings as db_refs for an entity. | [
"Return",
"groundings",
"as",
"db_refs",
"for",
"an",
"entity",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L243-L276 | train |
sorgerlab/indra | indra/sources/eidos/processor.py | EidosProcessor.get_concept | 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 | 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 | [
"def",
"get_concept",
"(",
"entity",
")",
":",
"# Use the canonical name as the name of the Concept",
"name",
"=",
"entity",
"[",
"'canonicalName'",
"]",
"db_refs",
"=",
"EidosProcessor",
".",
"get_groundings",
"(",
"entity",
")",
"concept",
"=",
"Concept",
"(",
"na... | Return Concept from an Eidos entity. | [
"Return",
"Concept",
"from",
"an",
"Eidos",
"entity",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L279-L285 | train |
sorgerlab/indra | indra/sources/eidos/processor.py | EidosProcessor.time_context_from_ref | 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 | 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... | [
"def",
"time_context_from_ref",
"(",
"self",
",",
"timex",
")",
":",
"# 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",
"=",
"timex",
".",
"get"... | Return a time context object given a timex reference entry. | [
"Return",
"a",
"time",
"context",
"object",
"given",
"a",
"timex",
"reference",
"entry",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L287-L298 | train |
sorgerlab/indra | indra/sources/eidos/processor.py | EidosProcessor.geo_context_from_ref | 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 | 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
... | [
"def",
"geo_context_from_ref",
"(",
"self",
",",
"ref",
")",
":",
"value",
"=",
"ref",
".",
"get",
"(",
"'value'",
")",
"if",
"value",
":",
"# Here we get the RefContext from the stashed geoloc dictionary",
"rc",
"=",
"self",
".",
"doc",
".",
"geolocs",
".",
"... | Return a ref context object given a location reference entry. | [
"Return",
"a",
"ref",
"context",
"object",
"given",
"a",
"location",
"reference",
"entry",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L300-L307 | train |
sorgerlab/indra | indra/sources/eidos/processor.py | EidosDocument.time_context_from_dct | 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 | 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... | [
"def",
"time_context_from_dct",
"(",
"dct",
")",
":",
"time_text",
"=",
"dct",
".",
"get",
"(",
"'text'",
")",
"start",
"=",
"_get_time_stamp",
"(",
"dct",
".",
"get",
"(",
"'start'",
")",
")",
"end",
"=",
"_get_time_stamp",
"(",
"dct",
".",
"get",
"("... | Return a time context object given a DCT entry. | [
"Return",
"a",
"time",
"context",
"object",
"given",
"a",
"DCT",
"entry",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L369-L377 | train |
sorgerlab/indra | indra/statements/util.py | make_hash | 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 | 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 | [
"def",
"make_hash",
"(",
"s",
",",
"n_bytes",
")",
":",
"raw_h",
"=",
"int",
"(",
"md5",
"(",
"s",
".",
"encode",
"(",
"'utf-8'",
")",
")",
".",
"hexdigest",
"(",
")",
"[",
":",
"n_bytes",
"]",
",",
"16",
")",
"# Make it a signed int.",
"return",
"... | Make the hash from a matches key. | [
"Make",
"the",
"hash",
"from",
"a",
"matches",
"key",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/util.py#L12-L16 | train |
sorgerlab/indra | indra/sources/tees/parse_tees.py | parse_a1 | 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 | 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... | [
"def",
"parse_a1",
"(",
"a1_text",
")",
":",
"entities",
"=",
"{",
"}",
"for",
"line",
"in",
"a1_text",
".",
"split",
"(",
"'\\n'",
")",
":",
"if",
"len",
"(",
"line",
")",
"==",
"0",
":",
"continue",
"tokens",
"=",
"line",
".",
"rstrip",
"(",
")... | 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 TEESEntity objects
descri... | [
"Parses",
"an",
"a1",
"file",
"the",
"file",
"TEES",
"outputs",
"that",
"lists",
"the",
"entities",
"in",
"the",
"extracted",
"events",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/parse_tees.py#L71-L115 | train |
sorgerlab/indra | indra/sources/tees/parse_tees.py | parse_output | 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 | 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 ... | [
"def",
"parse_output",
"(",
"a1_text",
",",
"a2_text",
",",
"sentence_segmentations",
")",
":",
"# Parse the sentence segmentation document",
"tees_sentences",
"=",
"TEESSentences",
"(",
"sentence_segmentations",
")",
"# Parse the a1 (entities) file",
"entities",
"=",
"parse_... | 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 TEES a2 output, specifying the event graph
sentence_segmentatio... | [
"Parses",
"the",
"output",
"of",
"the",
"TEES",
"reader",
"and",
"returns",
"a",
"networkx",
"graph",
"with",
"the",
"event",
"information",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/parse_tees.py#L272-L301 | train |
sorgerlab/indra | indra/sources/tees/parse_tees.py | tees_parse_networkx_to_dot | 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 | 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 ... | [
"def",
"tees_parse_networkx_to_dot",
"(",
"G",
",",
"output_file",
",",
"subgraph_nodes",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"output_file",
",",
"'w'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"'digraph teesP... | 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 to which to write .dot file
subgraph_nodes : list[str]
Only... | [
"Converts",
"TEES",
"extractions",
"stored",
"in",
"a",
"networkx",
"graph",
"into",
"a",
"graphviz",
".",
"dot",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/parse_tees.py#L303-L354 | train |
sorgerlab/indra | indra/sources/cwms/processor.py | CWMSProcessor._get_event | 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 | 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 =... | [
"def",
"_get_event",
"(",
"self",
",",
"event",
",",
"find_str",
")",
":",
"# Get the term with the given element id",
"element",
"=",
"event",
".",
"find",
"(",
"find_str",
")",
"if",
"element",
"is",
"None",
":",
"return",
"None",
"element_id",
"=",
"element... | Get a concept referred from the event by the given string. | [
"Get",
"a",
"concept",
"referred",
"from",
"the",
"event",
"by",
"the",
"given",
"string",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/cwms/processor.py#L115-L152 | train |
sorgerlab/indra | indra/assemblers/cag/assembler.py | CAGAssembler.make_model | 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 | 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... | [
"def",
"make_model",
"(",
"self",
",",
"grounding_ontology",
"=",
"'UN'",
",",
"grounding_threshold",
"=",
"None",
")",
":",
"if",
"grounding_threshold",
"is",
"not",
"None",
":",
"self",
".",
"grounding_threshold",
"=",
"grounding_threshold",
"self",
".",
"grou... | 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. UN, FAO)
grounding_threshold : Optional[float]
Minimum threshold ... | [
"Return",
"a",
"networkx",
"MultiDiGraph",
"representing",
"a",
"causal",
"analysis",
"graph",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cag/assembler.py#L49-L124 | train |
sorgerlab/indra | indra/assemblers/cag/assembler.py | CAGAssembler.export_to_cytoscapejs | 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 | 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... | [
"def",
"export_to_cytoscapejs",
"(",
"self",
")",
":",
"def",
"_create_edge_data_dict",
"(",
"e",
")",
":",
"\"\"\"Return a dict from a MultiDiGraph edge for CytoscapeJS export.\"\"\"",
"# A hack to get rid of the redundant 'Provenance' label.",
"if",
"e",
"[",
"3",
"]",
".",
... | Return CAG in format readable by CytoscapeJS.
Return
------
dict
A JSON-like dict representing the graph for use with
CytoscapeJS. | [
"Return",
"CAG",
"in",
"format",
"readable",
"by",
"CytoscapeJS",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cag/assembler.py#L203-L248 | train |
sorgerlab/indra | indra/assemblers/cag/assembler.py | CAGAssembler.generate_jupyter_js | 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 | 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... | [
"def",
"generate_jupyter_js",
"(",
"self",
",",
"cyjs_style",
"=",
"None",
",",
"cyjs_layout",
"=",
"None",
")",
":",
"# First, export the CAG to CyJS",
"cyjs_elements",
"=",
"self",
".",
"export_to_cytoscapejs",
"(",
")",
"# Load the Javascript template",
"tempf",
"=... | 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/cytoscape.js/blob/master/documentation/md/style.md.
cyjs_layout : O... | [
"Generate",
"Javascript",
"from",
"a",
"template",
"to",
"run",
"in",
"Jupyter",
"notebooks",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cag/assembler.py#L250-L289 | train |
sorgerlab/indra | indra/assemblers/cag/assembler.py | CAGAssembler._node_name | 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 | 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... | [
"def",
"_node_name",
"(",
"self",
",",
"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",
"["... | Return a standardized name for a node given a Concept. | [
"Return",
"a",
"standardized",
"name",
"for",
"a",
"node",
"given",
"a",
"Concept",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cag/assembler.py#L291-L303 | train |
sorgerlab/indra | indra/sources/bel/rdf_processor.py | term_from_uri | 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 | 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... | [
"def",
"term_from_uri",
"(",
"uri",
")",
":",
"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",
... | Removes prepended URI information from terms. | [
"Removes",
"prepended",
"URI",
"information",
"from",
"terms",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L37-L66 | train |
sorgerlab/indra | indra/sources/bel/rdf_processor.py | BelRdfProcessor.get_activating_mods | 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 | 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... | [
"def",
"get_activating_mods",
"(",
"self",
")",
":",
"q_mods",
"=",
"prefixes",
"+",
"\"\"\"\n SELECT ?speciesName ?actType ?mod ?pos ?rel ?stmt ?species\n WHERE {\n ?stmt a belvoc:Statement .\n ?stmt belvoc:hasRelationship ?rel .\n ... | 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:
proteinAbundance(HGNC:INSR,proteinModification(P,Y))
... | [
"Extract",
"INDRA",
"ActiveForm",
"Statements",
"with",
"a",
"single",
"mod",
"from",
"BEL",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L225-L279 | train |
sorgerlab/indra | indra/sources/bel/rdf_processor.py | BelRdfProcessor.get_complexes | 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 | 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... | [
"def",
"get_complexes",
"(",
"self",
")",
":",
"q_cmplx",
"=",
"prefixes",
"+",
"\"\"\"\n SELECT ?complexTerm ?childName ?child ?stmt\n WHERE {\n {\n {?stmt belvoc:hasSubject ?complexTerm}\n UNION\n {?stmt belvoc:h... | 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 statements.
Examples:
... | [
"Extract",
"INDRA",
"Complex",
"Statements",
"from",
"BEL",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L281-L344 | train |
sorgerlab/indra | indra/sources/bel/rdf_processor.py | BelRdfProcessor.get_activating_subs | 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 | 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... | [
"def",
"get_activating_subs",
"(",
"self",
")",
":",
"q_mods",
"=",
"prefixes",
"+",
"\"\"\"\n SELECT ?enzyme_name ?sub_label ?act_type ?rel ?stmt ?subject\n WHERE {\n ?stmt a belvoc:Statement .\n ?stmt belvoc:hasRelationship ?rel .\n ... | 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 statement is an
ActivityType of the same P... | [
"Extract",
"INDRA",
"ActiveForm",
"Statements",
"based",
"on",
"a",
"mutation",
"from",
"BEL",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L346-L421 | train |
sorgerlab/indra | indra/sources/bel/rdf_processor.py | BelRdfProcessor.get_conversions | 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 | 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... | [
"def",
"get_conversions",
"(",
"self",
")",
":",
"query",
"=",
"prefixes",
"+",
"\"\"\"\n SELECT DISTINCT ?controller ?controllerName ?controllerActivity\n ?product ?productName ?reactant ?reactantName ?stmt\n WHERE {\n ?stmt a belvoc:Statement... | 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.
Examples:
catalyticActivity... | [
"Extract",
"Conversion",
"INDRA",
"Statements",
"from",
"BEL",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L654-L725 | train |
sorgerlab/indra | indra/sources/bel/rdf_processor.py | BelRdfProcessor.get_degenerate_statements | 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 | 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 + """
... | [
"def",
"get_degenerate_statements",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Checking for 'degenerate' statements...\\n\"",
")",
"# Get rules of type protein X -> activity Y",
"q_stmts",
"=",
"prefixes",
"+",
"\"\"\"\n SELECT ?stmt\n WHERE {\n ... | Get all degenerate BEL statements.
Stores the results of the query in self.degenerate_stmts. | [
"Get",
"all",
"degenerate",
"BEL",
"statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L774-L827 | train |
sorgerlab/indra | indra/sources/bel/rdf_processor.py | BelRdfProcessor.print_statement_coverage | 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 | 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:
... | [
"def",
"print_statement_coverage",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"all_direct_stmts",
":",
"self",
".",
"get_all_direct_statements",
"(",
")",
"if",
"not",
"self",
".",
"degenerate_stmts",
":",
"self",
".",
"get_degenerate_statements",
"(",
")"... | Display how many of the direct statements have been converted.
Also prints how many are considered 'degenerate' and not converted. | [
"Display",
"how",
"many",
"of",
"the",
"direct",
"statements",
"have",
"been",
"converted",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L829-L871 | train |
sorgerlab/indra | indra/sources/bel/rdf_processor.py | BelRdfProcessor.print_statements | 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 | 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... | [
"def",
"print_statements",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'--- Direct INDRA statements ----------'",
")",
"for",
"i",
",",
"stmt",
"in",
"enumerate",
"(",
"self",
".",
"statements",
")",
":",
"logger",
".",
"info",
"(",
"\"%s: %s\"",
"%"... | Print all extracted INDRA Statements. | [
"Print",
"all",
"extracted",
"INDRA",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L873-L880 | train |
sorgerlab/indra | indra/sources/medscan/api.py | process_directory_statements_sorted_by_pmid | 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 | 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... | [
"def",
"process_directory_statements_sorted_by_pmid",
"(",
"directory_name",
")",
":",
"s_dict",
"=",
"defaultdict",
"(",
"list",
")",
"mp",
"=",
"process_directory",
"(",
"directory_name",
",",
"lazy",
"=",
"True",
")",
"for",
"statement",
"in",
"mp",
".",
"ite... | 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 directory filled with csxml files to process
Returns
-------
pmid... | [
"Processes",
"a",
"directory",
"filled",
"with",
"CSXML",
"files",
"first",
"normalizing",
"the",
"character",
"encoding",
"to",
"utf",
"-",
"8",
"and",
"then",
"processing",
"into",
"INDRA",
"statements",
"sorted",
"by",
"pmid",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/api.py#L9-L30 | train |
sorgerlab/indra | indra/sources/medscan/api.py | process_directory | 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 | 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... | [
"def",
"process_directory",
"(",
"directory_name",
",",
"lazy",
"=",
"False",
")",
":",
"# Parent Medscan processor containing extractions from all files",
"mp",
"=",
"MedscanProcessor",
"(",
")",
"mp",
".",
"process_directory",
"(",
"directory_name",
",",
"lazy",
")",
... | 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 csxml files to process
lazy : bool
If True, the ... | [
"Processes",
"a",
"directory",
"filled",
"with",
"CSXML",
"files",
"first",
"normalizing",
"the",
"character",
"encodings",
"to",
"utf",
"-",
"8",
"and",
"then",
"processing",
"into",
"a",
"list",
"of",
"INDRA",
"statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/api.py#L33-L58 | train |
sorgerlab/indra | indra/sources/medscan/api.py | process_file_sorted_by_pmid | 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 | 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... | [
"def",
"process_file_sorted_by_pmid",
"(",
"file_name",
")",
":",
"s_dict",
"=",
"defaultdict",
"(",
"list",
")",
"mp",
"=",
"process_file",
"(",
"file_name",
",",
"lazy",
"=",
"True",
")",
"for",
"statement",
"in",
"mp",
".",
"iter_statements",
"(",
")",
... | 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 pmids to a list of statements corresponding to
... | [
"Processes",
"a",
"file",
"and",
"returns",
"a",
"dictionary",
"mapping",
"pmids",
"to",
"a",
"list",
"of",
"statements",
"corresponding",
"to",
"that",
"pmid",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/api.py#L61-L81 | train |
sorgerlab/indra | indra/sources/medscan/api.py | process_file | 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 | 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 :... | [
"def",
"process_file",
"(",
"filename",
",",
"interval",
"=",
"None",
",",
"lazy",
"=",
"False",
")",
":",
"mp",
"=",
"MedscanProcessor",
"(",
")",
"mp",
".",
"process_csxml_file",
"(",
"filename",
",",
"interval",
",",
"lazy",
")",
"return",
"mp"
] | 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 : str
The csxml file, containing Medscan XML, to proces... | [
"Process",
"a",
"CSXML",
"file",
"for",
"its",
"relevant",
"information",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/api.py#L84-L114 | train |
sorgerlab/indra | indra/explanation/reporting.py | stmts_from_path | 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 | 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
... | [
"def",
"stmts_from_path",
"(",
"path",
",",
"model",
",",
"stmts",
")",
":",
"path_stmts",
"=",
"[",
"]",
"for",
"path_rule",
",",
"sign",
"in",
"path",
":",
"for",
"rule",
"in",
"model",
".",
"rules",
":",
"if",
"rule",
".",
"name",
"==",
"path_rule... | 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
a path.
model : pysb.core.Model
A ... | [
"Return",
"source",
"Statements",
"corresponding",
"to",
"a",
"path",
"in",
"a",
"model",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/explanation/reporting.py#L3-L29 | train |
sorgerlab/indra | indra/sources/bel/processor.py | extract_context | 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 | 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... | [
"def",
"extract_context",
"(",
"annotations",
",",
"annot_manager",
")",
":",
"def",
"get_annot",
"(",
"annotations",
",",
"key",
")",
":",
"\"\"\"Return a specific annotation given a key.\"\"\"",
"val",
"=",
"annotations",
".",
"pop",
"(",
"key",
",",
"None",
")"... | 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 : AnnotationManager
An annotation manager to get name/db ... | [
"Return",
"a",
"BioContext",
"object",
"extracted",
"from",
"the",
"annotations",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/processor.py#L492-L549 | train |
sorgerlab/indra | indra/util/plot_formatting.py | format_axis | 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 | 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,
... | [
"def",
"format_axis",
"(",
"ax",
",",
"label_padding",
"=",
"2",
",",
"tick_padding",
"=",
"0",
",",
"yticks_position",
"=",
"'left'",
")",
":",
"ax",
".",
"xaxis",
".",
"set_ticks_position",
"(",
"'bottom'",
")",
"ax",
".",
"yaxis",
".",
"set_ticks_positi... | Set standardized axis formatting for figure. | [
"Set",
"standardized",
"axis",
"formatting",
"for",
"figure",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/plot_formatting.py#L17-L28 | train |
sorgerlab/indra | indra/assemblers/html/assembler.py | HtmlAssembler.make_model | 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 | 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... | [
"def",
"make_model",
"(",
"self",
")",
":",
"stmts_formatted",
"=",
"[",
"]",
"stmt_rows",
"=",
"group_and_sort_statements",
"(",
"self",
".",
"statements",
",",
"self",
".",
"ev_totals",
"if",
"self",
".",
"ev_totals",
"else",
"None",
")",
"for",
"key",
"... | Return the assembled HTML content as a string.
Returns
-------
str
The assembled HTML as a string. | [
"Return",
"the",
"assembled",
"HTML",
"content",
"as",
"a",
"string",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/html/assembler.py#L99-L142 | train |
sorgerlab/indra | indra/assemblers/html/assembler.py | HtmlAssembler.append_warning | 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 | 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)
... | [
"def",
"append_warning",
"(",
"self",
",",
"msg",
")",
":",
"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.)</sp... | Append a warning message to the model to expose issues. | [
"Append",
"a",
"warning",
"message",
"to",
"the",
"model",
"to",
"expose",
"issues",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/html/assembler.py#L144-L150 | train |
sorgerlab/indra | indra/assemblers/html/assembler.py | HtmlAssembler.save_model | 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 | 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... | [
"def",
"save_model",
"(",
"self",
",",
"fname",
")",
":",
"if",
"self",
".",
"model",
"is",
"None",
":",
"self",
".",
"make_model",
"(",
")",
"with",
"open",
"(",
"fname",
",",
"'wb'",
")",
"as",
"fh",
":",
"fh",
".",
"write",
"(",
"self",
".",
... | Save the assembled HTML into a file.
Parameters
----------
fname : str
The path to the file to save the HTML into. | [
"Save",
"the",
"assembled",
"HTML",
"into",
"a",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/html/assembler.py#L152-L164 | train |
sorgerlab/indra | indra/assemblers/html/assembler.py | HtmlAssembler._format_evidence_text | 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 | 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... | [
"def",
"_format_evidence_text",
"(",
"stmt",
")",
":",
"def",
"get_role",
"(",
"ag_ix",
")",
":",
"if",
"isinstance",
"(",
"stmt",
",",
"Complex",
")",
"or",
"isinstance",
"(",
"stmt",
",",
"SelfModification",
")",
"or",
"isinstance",
"(",
"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 corresponding to each Evidence object in the
... | [
"Returns",
"evidence",
"metadata",
"with",
"highlighted",
"evidence",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/html/assembler.py#L167-L241 | train |
sorgerlab/indra | indra/sources/reach/api.py | process_pmc | 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 | 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... | [
"def",
"process_pmc",
"(",
"pmc_id",
",",
"offline",
"=",
"False",
",",
"output_fname",
"=",
"default_output_fname",
")",
":",
"xml_str",
"=",
"pmc_client",
".",
"get_xml",
"(",
"pmc_id",
")",
"if",
"xml_str",
"is",
"None",
":",
"return",
"None",
"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 PubmedCentral article. The string may start with PMC but
passing just the ID also ... | [
"Return",
"a",
"ReachProcessor",
"by",
"processing",
"a",
"paper",
"with",
"a",
"given",
"PMC",
"id",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/api.py#L41-L74 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.