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/mechlinker/__init__.py | MechLinker.gather_implicit_activities | def gather_implicit_activities(self):
"""Aggregate all implicit activities and active forms of Agents.
Iterate over self.statements and collect the implied activities
and active forms of Agents that appear in the Statements.
Note that using this function to collect implied Agent activi... | python | def gather_implicit_activities(self):
"""Aggregate all implicit activities and active forms of Agents.
Iterate over self.statements and collect the implied activities
and active forms of Agents that appear in the Statements.
Note that using this function to collect implied Agent activi... | [
"def",
"gather_implicit_activities",
"(",
"self",
")",
":",
"for",
"stmt",
"in",
"self",
".",
"statements",
":",
"if",
"isinstance",
"(",
"stmt",
",",
"Phosphorylation",
")",
"or",
"isinstance",
"(",
"stmt",
",",
"Transphosphorylation",
")",
"or",
"isinstance"... | Aggregate all implicit activities and active forms of Agents.
Iterate over self.statements and collect the implied activities
and active forms of Agents that appear in the Statements.
Note that using this function to collect implied Agent activities can
be risky. Assume, for instance, ... | [
"Aggregate",
"all",
"implicit",
"activities",
"and",
"active",
"forms",
"of",
"Agents",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/mechlinker/__init__.py#L68-L127 | train |
sorgerlab/indra | indra/mechlinker/__init__.py | MechLinker.require_active_forms | def require_active_forms(self):
"""Rewrites Statements with Agents' active forms in active positions.
As an example, the enzyme in a Modification Statement can be expected
to be in an active state. Similarly, subjects of RegulateAmount and
RegulateActivity Statements can be expected to ... | python | def require_active_forms(self):
"""Rewrites Statements with Agents' active forms in active positions.
As an example, the enzyme in a Modification Statement can be expected
to be in an active state. Similarly, subjects of RegulateAmount and
RegulateActivity Statements can be expected to ... | [
"def",
"require_active_forms",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Setting required active forms on %d statements...'",
"%",
"len",
"(",
"self",
".",
"statements",
")",
")",
"new_stmts",
"=",
"[",
"]",
"for",
"stmt",
"in",
"self",
".",
"statem... | Rewrites Statements with Agents' active forms in active positions.
As an example, the enzyme in a Modification Statement can be expected
to be in an active state. Similarly, subjects of RegulateAmount and
RegulateActivity Statements can be expected to be in an active form.
This function... | [
"Rewrites",
"Statements",
"with",
"Agents",
"active",
"forms",
"in",
"active",
"positions",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/mechlinker/__init__.py#L166-L221 | train |
sorgerlab/indra | indra/mechlinker/__init__.py | MechLinker.reduce_activities | def reduce_activities(self):
"""Rewrite the activity types referenced in Statements for consistency.
Activity types are reduced to the most specific form whenever possible.
For instance, if 'kinase' is the only specific activity type known
for the BaseAgent of BRAF, its generic 'activit... | python | def reduce_activities(self):
"""Rewrite the activity types referenced in Statements for consistency.
Activity types are reduced to the most specific form whenever possible.
For instance, if 'kinase' is the only specific activity type known
for the BaseAgent of BRAF, its generic 'activit... | [
"def",
"reduce_activities",
"(",
"self",
")",
":",
"for",
"stmt",
"in",
"self",
".",
"statements",
":",
"agents",
"=",
"stmt",
".",
"agent_list",
"(",
")",
"for",
"agent",
"in",
"agents",
":",
"if",
"agent",
"is",
"not",
"None",
"and",
"agent",
".",
... | Rewrite the activity types referenced in Statements for consistency.
Activity types are reduced to the most specific form whenever possible.
For instance, if 'kinase' is the only specific activity type known
for the BaseAgent of BRAF, its generic 'activity' forms are rewritten
to 'kinas... | [
"Rewrite",
"the",
"activity",
"types",
"referenced",
"in",
"Statements",
"for",
"consistency",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/mechlinker/__init__.py#L223-L251 | train |
sorgerlab/indra | indra/mechlinker/__init__.py | MechLinker.infer_complexes | def infer_complexes(stmts):
"""Return inferred Complex from Statements implying physical interaction.
Parameters
----------
stmts : list[indra.statements.Statement]
A list of Statements to infer Complexes from.
Returns
-------
linked_stmts : list[ind... | python | def infer_complexes(stmts):
"""Return inferred Complex from Statements implying physical interaction.
Parameters
----------
stmts : list[indra.statements.Statement]
A list of Statements to infer Complexes from.
Returns
-------
linked_stmts : list[ind... | [
"def",
"infer_complexes",
"(",
"stmts",
")",
":",
"interact_stmts",
"=",
"_get_statements_by_type",
"(",
"stmts",
",",
"Modification",
")",
"linked_stmts",
"=",
"[",
"]",
"for",
"mstmt",
"in",
"interact_stmts",
":",
"if",
"mstmt",
".",
"enz",
"is",
"None",
"... | Return inferred Complex from Statements implying physical interaction.
Parameters
----------
stmts : list[indra.statements.Statement]
A list of Statements to infer Complexes from.
Returns
-------
linked_stmts : list[indra.mechlinker.LinkedStatement]
... | [
"Return",
"inferred",
"Complex",
"from",
"Statements",
"implying",
"physical",
"interaction",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/mechlinker/__init__.py#L254-L274 | train |
sorgerlab/indra | indra/mechlinker/__init__.py | MechLinker.infer_activations | def infer_activations(stmts):
"""Return inferred RegulateActivity from Modification + ActiveForm.
This function looks for combinations of Modification and ActiveForm
Statements and infers Activation/Inhibition Statements from them.
For example, if we know that A phosphorylates B, and th... | python | def infer_activations(stmts):
"""Return inferred RegulateActivity from Modification + ActiveForm.
This function looks for combinations of Modification and ActiveForm
Statements and infers Activation/Inhibition Statements from them.
For example, if we know that A phosphorylates B, and th... | [
"def",
"infer_activations",
"(",
"stmts",
")",
":",
"linked_stmts",
"=",
"[",
"]",
"af_stmts",
"=",
"_get_statements_by_type",
"(",
"stmts",
",",
"ActiveForm",
")",
"mod_stmts",
"=",
"_get_statements_by_type",
"(",
"stmts",
",",
"Modification",
")",
"for",
"af_s... | Return inferred RegulateActivity from Modification + ActiveForm.
This function looks for combinations of Modification and ActiveForm
Statements and infers Activation/Inhibition Statements from them.
For example, if we know that A phosphorylates B, and the
phosphorylated form of B is act... | [
"Return",
"inferred",
"RegulateActivity",
"from",
"Modification",
"+",
"ActiveForm",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/mechlinker/__init__.py#L277-L328 | train |
sorgerlab/indra | indra/mechlinker/__init__.py | MechLinker.infer_active_forms | def infer_active_forms(stmts):
"""Return inferred ActiveForm from RegulateActivity + Modification.
This function looks for combinations of Activation/Inhibition
Statements and Modification Statements, and infers an ActiveForm
from them. For example, if we know that A activates B and
... | python | def infer_active_forms(stmts):
"""Return inferred ActiveForm from RegulateActivity + Modification.
This function looks for combinations of Activation/Inhibition
Statements and Modification Statements, and infers an ActiveForm
from them. For example, if we know that A activates B and
... | [
"def",
"infer_active_forms",
"(",
"stmts",
")",
":",
"linked_stmts",
"=",
"[",
"]",
"for",
"act_stmt",
"in",
"_get_statements_by_type",
"(",
"stmts",
",",
"RegulateActivity",
")",
":",
"# TODO: revise the conditions here",
"if",
"not",
"(",
"act_stmt",
".",
"subj"... | Return inferred ActiveForm from RegulateActivity + Modification.
This function looks for combinations of Activation/Inhibition
Statements and Modification Statements, and infers an ActiveForm
from them. For example, if we know that A activates B and
A phosphorylates B, then we can infer... | [
"Return",
"inferred",
"ActiveForm",
"from",
"RegulateActivity",
"+",
"Modification",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/mechlinker/__init__.py#L331-L385 | train |
sorgerlab/indra | indra/mechlinker/__init__.py | MechLinker.infer_modifications | def infer_modifications(stmts):
"""Return inferred Modification from RegulateActivity + ActiveForm.
This function looks for combinations of Activation/Inhibition Statements
and ActiveForm Statements that imply a Modification Statement.
For example, if we know that A activates B, and pho... | python | def infer_modifications(stmts):
"""Return inferred Modification from RegulateActivity + ActiveForm.
This function looks for combinations of Activation/Inhibition Statements
and ActiveForm Statements that imply a Modification Statement.
For example, if we know that A activates B, and pho... | [
"def",
"infer_modifications",
"(",
"stmts",
")",
":",
"linked_stmts",
"=",
"[",
"]",
"for",
"act_stmt",
"in",
"_get_statements_by_type",
"(",
"stmts",
",",
"RegulateActivity",
")",
":",
"for",
"af_stmt",
"in",
"_get_statements_by_type",
"(",
"stmts",
",",
"Activ... | Return inferred Modification from RegulateActivity + ActiveForm.
This function looks for combinations of Activation/Inhibition Statements
and ActiveForm Statements that imply a Modification Statement.
For example, if we know that A activates B, and phosphorylated B is
active, then we ca... | [
"Return",
"inferred",
"Modification",
"from",
"RegulateActivity",
"+",
"ActiveForm",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/mechlinker/__init__.py#L388-L441 | train |
sorgerlab/indra | indra/mechlinker/__init__.py | MechLinker.replace_complexes | def replace_complexes(self, linked_stmts=None):
"""Remove Complex Statements that can be inferred out.
This function iterates over self.statements and looks for Complex
Statements that either match or are refined by inferred Complex
Statements that were linked (provided as the linked_st... | python | def replace_complexes(self, linked_stmts=None):
"""Remove Complex Statements that can be inferred out.
This function iterates over self.statements and looks for Complex
Statements that either match or are refined by inferred Complex
Statements that were linked (provided as the linked_st... | [
"def",
"replace_complexes",
"(",
"self",
",",
"linked_stmts",
"=",
"None",
")",
":",
"if",
"linked_stmts",
"is",
"None",
":",
"linked_stmts",
"=",
"self",
".",
"infer_complexes",
"(",
"self",
".",
"statements",
")",
"new_stmts",
"=",
"[",
"]",
"for",
"stmt... | Remove Complex Statements that can be inferred out.
This function iterates over self.statements and looks for Complex
Statements that either match or are refined by inferred Complex
Statements that were linked (provided as the linked_stmts argument).
It removes Complex Statements from s... | [
"Remove",
"Complex",
"Statements",
"that",
"can",
"be",
"inferred",
"out",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/mechlinker/__init__.py#L443-L475 | train |
sorgerlab/indra | indra/mechlinker/__init__.py | MechLinker.replace_activations | def replace_activations(self, linked_stmts=None):
"""Remove RegulateActivity Statements that can be inferred out.
This function iterates over self.statements and looks for
RegulateActivity Statements that either match or are refined by
inferred RegulateActivity Statements that were link... | python | def replace_activations(self, linked_stmts=None):
"""Remove RegulateActivity Statements that can be inferred out.
This function iterates over self.statements and looks for
RegulateActivity Statements that either match or are refined by
inferred RegulateActivity Statements that were link... | [
"def",
"replace_activations",
"(",
"self",
",",
"linked_stmts",
"=",
"None",
")",
":",
"if",
"linked_stmts",
"is",
"None",
":",
"linked_stmts",
"=",
"self",
".",
"infer_activations",
"(",
"self",
".",
"statements",
")",
"new_stmts",
"=",
"[",
"]",
"for",
"... | Remove RegulateActivity Statements that can be inferred out.
This function iterates over self.statements and looks for
RegulateActivity Statements that either match or are refined by
inferred RegulateActivity Statements that were linked
(provided as the linked_stmts argument).
I... | [
"Remove",
"RegulateActivity",
"Statements",
"that",
"can",
"be",
"inferred",
"out",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/mechlinker/__init__.py#L477-L514 | train |
sorgerlab/indra | indra/mechlinker/__init__.py | BaseAgentSet.get_create_base_agent | def get_create_base_agent(self, agent):
"""Return BaseAgent from an Agent, creating it if needed.
Parameters
----------
agent : indra.statements.Agent
Returns
-------
base_agent : indra.mechlinker.BaseAgent
"""
try:
base_agent = self.... | python | def get_create_base_agent(self, agent):
"""Return BaseAgent from an Agent, creating it if needed.
Parameters
----------
agent : indra.statements.Agent
Returns
-------
base_agent : indra.mechlinker.BaseAgent
"""
try:
base_agent = self.... | [
"def",
"get_create_base_agent",
"(",
"self",
",",
"agent",
")",
":",
"try",
":",
"base_agent",
"=",
"self",
".",
"agents",
"[",
"agent",
".",
"name",
"]",
"except",
"KeyError",
":",
"base_agent",
"=",
"BaseAgent",
"(",
"agent",
".",
"name",
")",
"self",
... | Return BaseAgent from an Agent, creating it if needed.
Parameters
----------
agent : indra.statements.Agent
Returns
-------
base_agent : indra.mechlinker.BaseAgent | [
"Return",
"BaseAgent",
"from",
"an",
"Agent",
"creating",
"it",
"if",
"needed",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/mechlinker/__init__.py#L540-L557 | train |
sorgerlab/indra | indra/mechlinker/__init__.py | AgentState.apply_to | def apply_to(self, agent):
"""Apply this object's state to an Agent.
Parameters
----------
agent : indra.statements.Agent
The agent to which the state should be applied
"""
agent.bound_conditions = self.bound_conditions
agent.mods = self.mods
... | python | def apply_to(self, agent):
"""Apply this object's state to an Agent.
Parameters
----------
agent : indra.statements.Agent
The agent to which the state should be applied
"""
agent.bound_conditions = self.bound_conditions
agent.mods = self.mods
... | [
"def",
"apply_to",
"(",
"self",
",",
"agent",
")",
":",
"agent",
".",
"bound_conditions",
"=",
"self",
".",
"bound_conditions",
"agent",
".",
"mods",
"=",
"self",
".",
"mods",
"agent",
".",
"mutations",
"=",
"self",
".",
"mutations",
"agent",
".",
"locat... | Apply this object's state to an Agent.
Parameters
----------
agent : indra.statements.Agent
The agent to which the state should be applied | [
"Apply",
"this",
"object",
"s",
"state",
"to",
"an",
"Agent",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/mechlinker/__init__.py#L713-L725 | train |
sorgerlab/indra | indra/tools/live_curation.py | submit_curation | def submit_curation():
"""Submit curations for a given corpus.
The submitted curations are handled to update the probability model but
there is no return value here. The update_belief function can be called
separately to calculate update belief scores.
Parameters
----------
corpus_id : str... | python | def submit_curation():
"""Submit curations for a given corpus.
The submitted curations are handled to update the probability model but
there is no return value here. The update_belief function can be called
separately to calculate update belief scores.
Parameters
----------
corpus_id : str... | [
"def",
"submit_curation",
"(",
")",
":",
"if",
"request",
".",
"json",
"is",
"None",
":",
"abort",
"(",
"Response",
"(",
"'Missing application/json header.'",
",",
"415",
")",
")",
"# Get input parameters",
"corpus_id",
"=",
"request",
".",
"json",
".",
"get",... | Submit curations for a given corpus.
The submitted curations are handled to update the probability model but
there is no return value here. The update_belief function can be called
separately to calculate update belief scores.
Parameters
----------
corpus_id : str
The ID of the corpus ... | [
"Submit",
"curations",
"for",
"a",
"given",
"corpus",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/live_curation.py#L239-L265 | train |
sorgerlab/indra | indra/tools/live_curation.py | update_beliefs | def update_beliefs():
"""Return updated beliefs based on current probability model."""
if request.json is None:
abort(Response('Missing application/json header.', 415))
# Get input parameters
corpus_id = request.json.get('corpus_id')
try:
belief_dict = curator.update_beliefs(corpus_i... | python | def update_beliefs():
"""Return updated beliefs based on current probability model."""
if request.json is None:
abort(Response('Missing application/json header.', 415))
# Get input parameters
corpus_id = request.json.get('corpus_id')
try:
belief_dict = curator.update_beliefs(corpus_i... | [
"def",
"update_beliefs",
"(",
")",
":",
"if",
"request",
".",
"json",
"is",
"None",
":",
"abort",
"(",
"Response",
"(",
"'Missing application/json header.'",
",",
"415",
")",
")",
"# Get input parameters",
"corpus_id",
"=",
"request",
".",
"json",
".",
"get",
... | Return updated beliefs based on current probability model. | [
"Return",
"updated",
"beliefs",
"based",
"on",
"current",
"probability",
"model",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/live_curation.py#L269-L280 | train |
sorgerlab/indra | indra/tools/live_curation.py | LiveCurator.reset_scorer | def reset_scorer(self):
"""Reset the scorer used for couration."""
self.scorer = get_eidos_bayesian_scorer()
for corpus_id, corpus in self.corpora.items():
corpus.curations = {} | python | def reset_scorer(self):
"""Reset the scorer used for couration."""
self.scorer = get_eidos_bayesian_scorer()
for corpus_id, corpus in self.corpora.items():
corpus.curations = {} | [
"def",
"reset_scorer",
"(",
"self",
")",
":",
"self",
".",
"scorer",
"=",
"get_eidos_bayesian_scorer",
"(",
")",
"for",
"corpus_id",
",",
"corpus",
"in",
"self",
".",
"corpora",
".",
"items",
"(",
")",
":",
"corpus",
".",
"curations",
"=",
"{",
"}"
] | Reset the scorer used for couration. | [
"Reset",
"the",
"scorer",
"used",
"for",
"couration",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/live_curation.py#L95-L99 | train |
sorgerlab/indra | indra/tools/live_curation.py | LiveCurator.get_corpus | def get_corpus(self, corpus_id):
"""Return a corpus given an ID.
If the corpus ID cannot be found, an InvalidCorpusError is raised.
Parameters
----------
corpus_id : str
The ID of the corpus to return.
Returns
-------
Corpus
The ... | python | def get_corpus(self, corpus_id):
"""Return a corpus given an ID.
If the corpus ID cannot be found, an InvalidCorpusError is raised.
Parameters
----------
corpus_id : str
The ID of the corpus to return.
Returns
-------
Corpus
The ... | [
"def",
"get_corpus",
"(",
"self",
",",
"corpus_id",
")",
":",
"try",
":",
"corpus",
"=",
"self",
".",
"corpora",
"[",
"corpus_id",
"]",
"return",
"corpus",
"except",
"KeyError",
":",
"raise",
"InvalidCorpusError"
] | Return a corpus given an ID.
If the corpus ID cannot be found, an InvalidCorpusError is raised.
Parameters
----------
corpus_id : str
The ID of the corpus to return.
Returns
-------
Corpus
The corpus with the given ID. | [
"Return",
"a",
"corpus",
"given",
"an",
"ID",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/live_curation.py#L101-L120 | train |
sorgerlab/indra | indra/tools/live_curation.py | LiveCurator.update_beliefs | def update_beliefs(self, corpus_id):
"""Return updated belief scores for a given corpus.
Parameters
----------
corpus_id : str
The ID of the corpus for which beliefs are to be updated.
Returns
-------
dict
A dictionary of belief scores wi... | python | def update_beliefs(self, corpus_id):
"""Return updated belief scores for a given corpus.
Parameters
----------
corpus_id : str
The ID of the corpus for which beliefs are to be updated.
Returns
-------
dict
A dictionary of belief scores wi... | [
"def",
"update_beliefs",
"(",
"self",
",",
"corpus_id",
")",
":",
"corpus",
"=",
"self",
".",
"get_corpus",
"(",
"corpus_id",
")",
"be",
"=",
"BeliefEngine",
"(",
"self",
".",
"scorer",
")",
"stmts",
"=",
"list",
"(",
"corpus",
".",
"statements",
".",
... | Return updated belief scores for a given corpus.
Parameters
----------
corpus_id : str
The ID of the corpus for which beliefs are to be updated.
Returns
-------
dict
A dictionary of belief scores with keys corresponding to Statement
U... | [
"Return",
"updated",
"belief",
"scores",
"for",
"a",
"given",
"corpus",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/live_curation.py#L174-L200 | train |
sorgerlab/indra | indra/sources/eidos/scala_utils.py | get_python_list | def get_python_list(scala_list):
"""Return list from elements of scala.collection.immutable.List"""
python_list = []
for i in range(scala_list.length()):
python_list.append(scala_list.apply(i))
return python_list | python | def get_python_list(scala_list):
"""Return list from elements of scala.collection.immutable.List"""
python_list = []
for i in range(scala_list.length()):
python_list.append(scala_list.apply(i))
return python_list | [
"def",
"get_python_list",
"(",
"scala_list",
")",
":",
"python_list",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"scala_list",
".",
"length",
"(",
")",
")",
":",
"python_list",
".",
"append",
"(",
"scala_list",
".",
"apply",
"(",
"i",
")",
")",
"... | Return list from elements of scala.collection.immutable.List | [
"Return",
"list",
"from",
"elements",
"of",
"scala",
".",
"collection",
".",
"immutable",
".",
"List"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/scala_utils.py#L7-L12 | train |
sorgerlab/indra | indra/sources/eidos/scala_utils.py | get_python_dict | def get_python_dict(scala_map):
"""Return a dict from entries in a scala.collection.immutable.Map"""
python_dict = {}
keys = get_python_list(scala_map.keys().toList())
for key in keys:
python_dict[key] = scala_map.apply(key)
return python_dict | python | def get_python_dict(scala_map):
"""Return a dict from entries in a scala.collection.immutable.Map"""
python_dict = {}
keys = get_python_list(scala_map.keys().toList())
for key in keys:
python_dict[key] = scala_map.apply(key)
return python_dict | [
"def",
"get_python_dict",
"(",
"scala_map",
")",
":",
"python_dict",
"=",
"{",
"}",
"keys",
"=",
"get_python_list",
"(",
"scala_map",
".",
"keys",
"(",
")",
".",
"toList",
"(",
")",
")",
"for",
"key",
"in",
"keys",
":",
"python_dict",
"[",
"key",
"]",
... | Return a dict from entries in a scala.collection.immutable.Map | [
"Return",
"a",
"dict",
"from",
"entries",
"in",
"a",
"scala",
".",
"collection",
".",
"immutable",
".",
"Map"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/scala_utils.py#L15-L21 | train |
sorgerlab/indra | indra/sources/eidos/scala_utils.py | get_python_json | def get_python_json(scala_json):
"""Return a JSON dict from a org.json4s.JsonAST"""
def convert_node(node):
if node.__class__.__name__ in ('org.json4s.JsonAST$JValue',
'org.json4s.JsonAST$JObject'):
# Make a dictionary and then convert each value
... | python | def get_python_json(scala_json):
"""Return a JSON dict from a org.json4s.JsonAST"""
def convert_node(node):
if node.__class__.__name__ in ('org.json4s.JsonAST$JValue',
'org.json4s.JsonAST$JObject'):
# Make a dictionary and then convert each value
... | [
"def",
"get_python_json",
"(",
"scala_json",
")",
":",
"def",
"convert_node",
"(",
"node",
")",
":",
"if",
"node",
".",
"__class__",
".",
"__name__",
"in",
"(",
"'org.json4s.JsonAST$JValue'",
",",
"'org.json4s.JsonAST$JObject'",
")",
":",
"# Make a dictionary and th... | Return a JSON dict from a org.json4s.JsonAST | [
"Return",
"a",
"JSON",
"dict",
"from",
"a",
"org",
".",
"json4s",
".",
"JsonAST"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/scala_utils.py#L24-L69 | train |
sorgerlab/indra | indra/databases/relevance_client.py | get_heat_kernel | def get_heat_kernel(network_id):
"""Return the identifier of a heat kernel calculated for a given network.
Parameters
----------
network_id : str
The UUID of the network in NDEx.
Returns
-------
kernel_id : str
The identifier of the heat kernel calculated for the given netw... | python | def get_heat_kernel(network_id):
"""Return the identifier of a heat kernel calculated for a given network.
Parameters
----------
network_id : str
The UUID of the network in NDEx.
Returns
-------
kernel_id : str
The identifier of the heat kernel calculated for the given netw... | [
"def",
"get_heat_kernel",
"(",
"network_id",
")",
":",
"url",
"=",
"ndex_relevance",
"+",
"'/%s/generate_ndex_heat_kernel'",
"%",
"network_id",
"res",
"=",
"ndex_client",
".",
"send_request",
"(",
"url",
",",
"{",
"}",
",",
"is_json",
"=",
"True",
",",
"use_ge... | Return the identifier of a heat kernel calculated for a given network.
Parameters
----------
network_id : str
The UUID of the network in NDEx.
Returns
-------
kernel_id : str
The identifier of the heat kernel calculated for the given network. | [
"Return",
"the",
"identifier",
"of",
"a",
"heat",
"kernel",
"calculated",
"for",
"a",
"given",
"network",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/relevance_client.py#L17-L40 | train |
sorgerlab/indra | indra/databases/relevance_client.py | get_relevant_nodes | def get_relevant_nodes(network_id, query_nodes):
"""Return a set of network nodes relevant to a given query set.
A heat diffusion algorithm is used on a pre-computed heat kernel for the
given network which starts from the given query nodes. The nodes
in the network are ranked according to heat score wh... | python | def get_relevant_nodes(network_id, query_nodes):
"""Return a set of network nodes relevant to a given query set.
A heat diffusion algorithm is used on a pre-computed heat kernel for the
given network which starts from the given query nodes. The nodes
in the network are ranked according to heat score wh... | [
"def",
"get_relevant_nodes",
"(",
"network_id",
",",
"query_nodes",
")",
":",
"url",
"=",
"ndex_relevance",
"+",
"'/rank_entities'",
"kernel_id",
"=",
"get_heat_kernel",
"(",
"network_id",
")",
"if",
"kernel_id",
"is",
"None",
":",
"return",
"None",
"if",
"isins... | Return a set of network nodes relevant to a given query set.
A heat diffusion algorithm is used on a pre-computed heat kernel for the
given network which starts from the given query nodes. The nodes
in the network are ranked according to heat score which is a measure
of relevance with respect to the qu... | [
"Return",
"a",
"set",
"of",
"network",
"nodes",
"relevant",
"to",
"a",
"given",
"query",
"set",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/relevance_client.py#L43-L79 | train |
sorgerlab/indra | indra/belief/__init__.py | _get_belief_package | def _get_belief_package(stmt):
"""Return the belief packages of a given statement recursively."""
# This list will contain the belief packages for the given statement
belief_packages = []
# Iterate over all the support parents
for st in stmt.supports:
# Recursively get all the belief package... | python | def _get_belief_package(stmt):
"""Return the belief packages of a given statement recursively."""
# This list will contain the belief packages for the given statement
belief_packages = []
# Iterate over all the support parents
for st in stmt.supports:
# Recursively get all the belief package... | [
"def",
"_get_belief_package",
"(",
"stmt",
")",
":",
"# This list will contain the belief packages for the given statement",
"belief_packages",
"=",
"[",
"]",
"# Iterate over all the support parents",
"for",
"st",
"in",
"stmt",
".",
"supports",
":",
"# Recursively get all the b... | Return the belief packages of a given statement recursively. | [
"Return",
"the",
"belief",
"packages",
"of",
"a",
"given",
"statement",
"recursively",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L415-L431 | train |
sorgerlab/indra | indra/belief/__init__.py | sample_statements | def sample_statements(stmts, seed=None):
"""Return statements sampled according to belief.
Statements are sampled independently according to their
belief scores. For instance, a Staement with a belief
score of 0.7 will end up in the returned Statement list
with probability 0.7.
Parameters
... | python | def sample_statements(stmts, seed=None):
"""Return statements sampled according to belief.
Statements are sampled independently according to their
belief scores. For instance, a Staement with a belief
score of 0.7 will end up in the returned Statement list
with probability 0.7.
Parameters
... | [
"def",
"sample_statements",
"(",
"stmts",
",",
"seed",
"=",
"None",
")",
":",
"if",
"seed",
":",
"numpy",
".",
"random",
".",
"seed",
"(",
"seed",
")",
"new_stmts",
"=",
"[",
"]",
"r",
"=",
"numpy",
".",
"random",
".",
"rand",
"(",
"len",
"(",
"s... | Return statements sampled according to belief.
Statements are sampled independently according to their
belief scores. For instance, a Staement with a belief
score of 0.7 will end up in the returned Statement list
with probability 0.7.
Parameters
----------
stmts : list[indra.statements.Sta... | [
"Return",
"statements",
"sampled",
"according",
"to",
"belief",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L434-L462 | train |
sorgerlab/indra | indra/belief/__init__.py | evidence_random_noise_prior | def evidence_random_noise_prior(evidence, type_probs, subtype_probs):
"""Determines the random-noise prior probability for this evidence.
If the evidence corresponds to a subtype, and that subtype has a curated
prior noise probability, use that.
Otherwise, gives the random-noise prior for the overall ... | python | def evidence_random_noise_prior(evidence, type_probs, subtype_probs):
"""Determines the random-noise prior probability for this evidence.
If the evidence corresponds to a subtype, and that subtype has a curated
prior noise probability, use that.
Otherwise, gives the random-noise prior for the overall ... | [
"def",
"evidence_random_noise_prior",
"(",
"evidence",
",",
"type_probs",
",",
"subtype_probs",
")",
":",
"(",
"stype",
",",
"subtype",
")",
"=",
"tag_evidence_subtype",
"(",
"evidence",
")",
"# Get the subtype, if available",
"# Return the subtype random noise prior, if av... | Determines the random-noise prior probability for this evidence.
If the evidence corresponds to a subtype, and that subtype has a curated
prior noise probability, use that.
Otherwise, gives the random-noise prior for the overall rule type. | [
"Determines",
"the",
"random",
"-",
"noise",
"prior",
"probability",
"for",
"this",
"evidence",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L465-L483 | train |
sorgerlab/indra | indra/belief/__init__.py | tag_evidence_subtype | def tag_evidence_subtype(evidence):
"""Returns the type and subtype of an evidence object as a string,
typically the extraction rule or database from which the statement
was generated.
For biopax, this is just the database name.
Parameters
----------
statement: indra.statements.Evidence
... | python | def tag_evidence_subtype(evidence):
"""Returns the type and subtype of an evidence object as a string,
typically the extraction rule or database from which the statement
was generated.
For biopax, this is just the database name.
Parameters
----------
statement: indra.statements.Evidence
... | [
"def",
"tag_evidence_subtype",
"(",
"evidence",
")",
":",
"source_api",
"=",
"evidence",
".",
"source_api",
"annotations",
"=",
"evidence",
".",
"annotations",
"if",
"source_api",
"==",
"'biopax'",
":",
"subtype",
"=",
"annotations",
".",
"get",
"(",
"'source_su... | Returns the type and subtype of an evidence object as a string,
typically the extraction rule or database from which the statement
was generated.
For biopax, this is just the database name.
Parameters
----------
statement: indra.statements.Evidence
The statement which we wish to subtyp... | [
"Returns",
"the",
"type",
"and",
"subtype",
"of",
"an",
"evidence",
"object",
"as",
"a",
"string",
"typically",
"the",
"extraction",
"rule",
"or",
"database",
"from",
"which",
"the",
"statement",
"was",
"generated",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L486-L528 | train |
sorgerlab/indra | indra/belief/__init__.py | SimpleScorer.score_evidence_list | def score_evidence_list(self, evidences):
"""Return belief score given a list of supporting evidences."""
def _score(evidences):
if not evidences:
return 0
# Collect all unique sources
sources = [ev.source_api for ev in evidences]
uniq_sour... | python | def score_evidence_list(self, evidences):
"""Return belief score given a list of supporting evidences."""
def _score(evidences):
if not evidences:
return 0
# Collect all unique sources
sources = [ev.source_api for ev in evidences]
uniq_sour... | [
"def",
"score_evidence_list",
"(",
"self",
",",
"evidences",
")",
":",
"def",
"_score",
"(",
"evidences",
")",
":",
"if",
"not",
"evidences",
":",
"return",
"0",
"# Collect all unique sources",
"sources",
"=",
"[",
"ev",
".",
"source_api",
"for",
"ev",
"in",... | Return belief score given a list of supporting evidences. | [
"Return",
"belief",
"score",
"given",
"a",
"list",
"of",
"supporting",
"evidences",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L110-L154 | train |
sorgerlab/indra | indra/belief/__init__.py | SimpleScorer.score_statement | def score_statement(self, st, extra_evidence=None):
"""Computes the prior belief probability for an INDRA Statement.
The Statement is assumed to be de-duplicated. In other words,
the Statement is assumed to have
a list of Evidence objects that supports it. The prior probability of
... | python | def score_statement(self, st, extra_evidence=None):
"""Computes the prior belief probability for an INDRA Statement.
The Statement is assumed to be de-duplicated. In other words,
the Statement is assumed to have
a list of Evidence objects that supports it. The prior probability of
... | [
"def",
"score_statement",
"(",
"self",
",",
"st",
",",
"extra_evidence",
"=",
"None",
")",
":",
"if",
"extra_evidence",
"is",
"None",
":",
"extra_evidence",
"=",
"[",
"]",
"all_evidence",
"=",
"st",
".",
"evidence",
"+",
"extra_evidence",
"return",
"self",
... | Computes the prior belief probability for an INDRA Statement.
The Statement is assumed to be de-duplicated. In other words,
the Statement is assumed to have
a list of Evidence objects that supports it. The prior probability of
the Statement is calculated based on the number of Evidences... | [
"Computes",
"the",
"prior",
"belief",
"probability",
"for",
"an",
"INDRA",
"Statement",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L156-L182 | train |
sorgerlab/indra | indra/belief/__init__.py | SimpleScorer.check_prior_probs | def check_prior_probs(self, statements):
"""Throw Exception if BeliefEngine parameter is missing.
Make sure the scorer has all the information needed to compute
belief scores of each statement in the provided list, and raises an
exception otherwise.
Parameters
---------... | python | def check_prior_probs(self, statements):
"""Throw Exception if BeliefEngine parameter is missing.
Make sure the scorer has all the information needed to compute
belief scores of each statement in the provided list, and raises an
exception otherwise.
Parameters
---------... | [
"def",
"check_prior_probs",
"(",
"self",
",",
"statements",
")",
":",
"sources",
"=",
"set",
"(",
")",
"for",
"stmt",
"in",
"statements",
":",
"sources",
"|=",
"set",
"(",
"[",
"ev",
".",
"source_api",
"for",
"ev",
"in",
"stmt",
".",
"evidence",
"]",
... | Throw Exception if BeliefEngine parameter is missing.
Make sure the scorer has all the information needed to compute
belief scores of each statement in the provided list, and raises an
exception otherwise.
Parameters
----------
statements : list[indra.statements.Stateme... | [
"Throw",
"Exception",
"if",
"BeliefEngine",
"parameter",
"is",
"missing",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L184-L204 | train |
sorgerlab/indra | indra/belief/__init__.py | BayesianScorer.update_probs | def update_probs(self):
"""Update the internal probability values given the counts."""
# We deal with the prior probsfirst
# This is a fixed assumed value for systematic error
syst_error = 0.05
prior_probs = {'syst': {}, 'rand': {}}
for source, (p, n) in self.prior_counts... | python | def update_probs(self):
"""Update the internal probability values given the counts."""
# We deal with the prior probsfirst
# This is a fixed assumed value for systematic error
syst_error = 0.05
prior_probs = {'syst': {}, 'rand': {}}
for source, (p, n) in self.prior_counts... | [
"def",
"update_probs",
"(",
"self",
")",
":",
"# We deal with the prior probsfirst",
"# This is a fixed assumed value for systematic error",
"syst_error",
"=",
"0.05",
"prior_probs",
"=",
"{",
"'syst'",
":",
"{",
"}",
",",
"'rand'",
":",
"{",
"}",
"}",
"for",
"sourc... | Update the internal probability values given the counts. | [
"Update",
"the",
"internal",
"probability",
"values",
"given",
"the",
"counts",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L232-L258 | train |
sorgerlab/indra | indra/belief/__init__.py | BayesianScorer.update_counts | def update_counts(self, prior_counts, subtype_counts):
"""Update the internal counts based on given new counts.
Parameters
----------
prior_counts : dict
A dictionary of counts of the form [pos, neg] for
each source.
subtype_counts : dict
A di... | python | def update_counts(self, prior_counts, subtype_counts):
"""Update the internal counts based on given new counts.
Parameters
----------
prior_counts : dict
A dictionary of counts of the form [pos, neg] for
each source.
subtype_counts : dict
A di... | [
"def",
"update_counts",
"(",
"self",
",",
"prior_counts",
",",
"subtype_counts",
")",
":",
"for",
"source",
",",
"(",
"pos",
",",
"neg",
")",
"in",
"prior_counts",
".",
"items",
"(",
")",
":",
"if",
"source",
"not",
"in",
"self",
".",
"prior_counts",
"... | Update the internal counts based on given new counts.
Parameters
----------
prior_counts : dict
A dictionary of counts of the form [pos, neg] for
each source.
subtype_counts : dict
A dictionary of counts of the form [pos, neg] for
each sub... | [
"Update",
"the",
"internal",
"counts",
"based",
"on",
"given",
"new",
"counts",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L260-L285 | train |
sorgerlab/indra | indra/belief/__init__.py | BeliefEngine.set_prior_probs | def set_prior_probs(self, statements):
"""Sets the prior belief probabilities for a list of INDRA Statements.
The Statements are assumed to be de-duplicated. In other words,
each Statement in the list passed to this function is assumed to have
a list of Evidence objects that support it.... | python | def set_prior_probs(self, statements):
"""Sets the prior belief probabilities for a list of INDRA Statements.
The Statements are assumed to be de-duplicated. In other words,
each Statement in the list passed to this function is assumed to have
a list of Evidence objects that support it.... | [
"def",
"set_prior_probs",
"(",
"self",
",",
"statements",
")",
":",
"self",
".",
"scorer",
".",
"check_prior_probs",
"(",
"statements",
")",
"for",
"st",
"in",
"statements",
":",
"st",
".",
"belief",
"=",
"self",
".",
"scorer",
".",
"score_statement",
"(",... | Sets the prior belief probabilities for a list of INDRA Statements.
The Statements are assumed to be de-duplicated. In other words,
each Statement in the list passed to this function is assumed to have
a list of Evidence objects that support it. The prior probability of
each Statement i... | [
"Sets",
"the",
"prior",
"belief",
"probabilities",
"for",
"a",
"list",
"of",
"INDRA",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L311-L329 | train |
sorgerlab/indra | indra/belief/__init__.py | BeliefEngine.set_hierarchy_probs | def set_hierarchy_probs(self, statements):
"""Sets hierarchical belief probabilities for INDRA Statements.
The Statements are assumed to be in a hierarchical relation graph with
the supports and supported_by attribute of each Statement object having
been set.
The hierarchical be... | python | def set_hierarchy_probs(self, statements):
"""Sets hierarchical belief probabilities for INDRA Statements.
The Statements are assumed to be in a hierarchical relation graph with
the supports and supported_by attribute of each Statement object having
been set.
The hierarchical be... | [
"def",
"set_hierarchy_probs",
"(",
"self",
",",
"statements",
")",
":",
"def",
"build_hierarchy_graph",
"(",
"stmts",
")",
":",
"\"\"\"Return a DiGraph based on matches keys and Statement supports\"\"\"",
"g",
"=",
"networkx",
".",
"DiGraph",
"(",
")",
"for",
"st1",
"... | Sets hierarchical belief probabilities for INDRA Statements.
The Statements are assumed to be in a hierarchical relation graph with
the supports and supported_by attribute of each Statement object having
been set.
The hierarchical belief probability of each Statement is calculated
... | [
"Sets",
"hierarchical",
"belief",
"probabilities",
"for",
"INDRA",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L331-L391 | train |
sorgerlab/indra | indra/belief/__init__.py | BeliefEngine.set_linked_probs | def set_linked_probs(self, linked_statements):
"""Sets the belief probabilities for a list of linked INDRA Statements.
The list of LinkedStatement objects is assumed to come from the
MechanismLinker. The belief probability of the inferred Statement is
assigned the joint probability of i... | python | def set_linked_probs(self, linked_statements):
"""Sets the belief probabilities for a list of linked INDRA Statements.
The list of LinkedStatement objects is assumed to come from the
MechanismLinker. The belief probability of the inferred Statement is
assigned the joint probability of i... | [
"def",
"set_linked_probs",
"(",
"self",
",",
"linked_statements",
")",
":",
"for",
"st",
"in",
"linked_statements",
":",
"source_probs",
"=",
"[",
"s",
".",
"belief",
"for",
"s",
"in",
"st",
".",
"source_stmts",
"]",
"st",
".",
"inferred_stmt",
".",
"belie... | Sets the belief probabilities for a list of linked INDRA Statements.
The list of LinkedStatement objects is assumed to come from the
MechanismLinker. The belief probability of the inferred Statement is
assigned the joint probability of its source Statements.
Parameters
--------... | [
"Sets",
"the",
"belief",
"probabilities",
"for",
"a",
"list",
"of",
"linked",
"INDRA",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/__init__.py#L393-L409 | train |
sorgerlab/indra | indra/sources/rlimsp/processor.py | RlimspProcessor.extract_statements | def extract_statements(self):
"""Extract the statements from the json."""
for p_info in self._json:
para = RlimspParagraph(p_info, self.doc_id_type)
self.statements.extend(para.get_statements())
return | python | def extract_statements(self):
"""Extract the statements from the json."""
for p_info in self._json:
para = RlimspParagraph(p_info, self.doc_id_type)
self.statements.extend(para.get_statements())
return | [
"def",
"extract_statements",
"(",
"self",
")",
":",
"for",
"p_info",
"in",
"self",
".",
"_json",
":",
"para",
"=",
"RlimspParagraph",
"(",
"p_info",
",",
"self",
".",
"doc_id_type",
")",
"self",
".",
"statements",
".",
"extend",
"(",
"para",
".",
"get_st... | Extract the statements from the json. | [
"Extract",
"the",
"statements",
"from",
"the",
"json",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/rlimsp/processor.py#L19-L24 | train |
sorgerlab/indra | indra/sources/rlimsp/processor.py | RlimspParagraph._get_agent | def _get_agent(self, entity_id):
"""Convert the entity dictionary into an INDRA Agent."""
if entity_id is None:
return None
entity_info = self._entity_dict.get(entity_id)
if entity_info is None:
logger.warning("Entity key did not resolve to entity.")
... | python | def _get_agent(self, entity_id):
"""Convert the entity dictionary into an INDRA Agent."""
if entity_id is None:
return None
entity_info = self._entity_dict.get(entity_id)
if entity_info is None:
logger.warning("Entity key did not resolve to entity.")
... | [
"def",
"_get_agent",
"(",
"self",
",",
"entity_id",
")",
":",
"if",
"entity_id",
"is",
"None",
":",
"return",
"None",
"entity_info",
"=",
"self",
".",
"_entity_dict",
".",
"get",
"(",
"entity_id",
")",
"if",
"entity_info",
"is",
"None",
":",
"logger",
".... | Convert the entity dictionary into an INDRA Agent. | [
"Convert",
"the",
"entity",
"dictionary",
"into",
"an",
"INDRA",
"Agent",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/rlimsp/processor.py#L49-L58 | train |
sorgerlab/indra | indra/sources/rlimsp/processor.py | RlimspParagraph._get_evidence | def _get_evidence(self, trigger_id, args, agent_coords, site_coords):
"""Get the evidence using the info in the trigger entity."""
trigger_info = self._entity_dict[trigger_id]
# Get the sentence index from the trigger word.
s_idx_set = {self._entity_dict[eid]['sentenceIndex']
... | python | def _get_evidence(self, trigger_id, args, agent_coords, site_coords):
"""Get the evidence using the info in the trigger entity."""
trigger_info = self._entity_dict[trigger_id]
# Get the sentence index from the trigger word.
s_idx_set = {self._entity_dict[eid]['sentenceIndex']
... | [
"def",
"_get_evidence",
"(",
"self",
",",
"trigger_id",
",",
"args",
",",
"agent_coords",
",",
"site_coords",
")",
":",
"trigger_info",
"=",
"self",
".",
"_entity_dict",
"[",
"trigger_id",
"]",
"# Get the sentence index from the trigger word.",
"s_idx_set",
"=",
"{"... | Get the evidence using the info in the trigger entity. | [
"Get",
"the",
"evidence",
"using",
"the",
"info",
"in",
"the",
"trigger",
"entity",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/rlimsp/processor.py#L84-L115 | train |
sorgerlab/indra | indra/tools/reading/readers.py | get_reader_classes | def get_reader_classes(parent=Reader):
"""Get all childless the descendants of a parent class, recursively."""
children = parent.__subclasses__()
descendants = children[:]
for child in children:
grandchildren = get_reader_classes(child)
if grandchildren:
descendants.remove(ch... | python | def get_reader_classes(parent=Reader):
"""Get all childless the descendants of a parent class, recursively."""
children = parent.__subclasses__()
descendants = children[:]
for child in children:
grandchildren = get_reader_classes(child)
if grandchildren:
descendants.remove(ch... | [
"def",
"get_reader_classes",
"(",
"parent",
"=",
"Reader",
")",
":",
"children",
"=",
"parent",
".",
"__subclasses__",
"(",
")",
"descendants",
"=",
"children",
"[",
":",
"]",
"for",
"child",
"in",
"children",
":",
"grandchildren",
"=",
"get_reader_classes",
... | Get all childless the descendants of a parent class, recursively. | [
"Get",
"all",
"childless",
"the",
"descendants",
"of",
"a",
"parent",
"class",
"recursively",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L761-L770 | train |
sorgerlab/indra | indra/tools/reading/readers.py | get_reader_class | def get_reader_class(reader_name):
"""Get a particular reader class by name."""
for reader_class in get_reader_classes():
if reader_class.name.lower() == reader_name.lower():
return reader_class
else:
logger.error("No such reader: %s" % reader_name)
return None | python | def get_reader_class(reader_name):
"""Get a particular reader class by name."""
for reader_class in get_reader_classes():
if reader_class.name.lower() == reader_name.lower():
return reader_class
else:
logger.error("No such reader: %s" % reader_name)
return None | [
"def",
"get_reader_class",
"(",
"reader_name",
")",
":",
"for",
"reader_class",
"in",
"get_reader_classes",
"(",
")",
":",
"if",
"reader_class",
".",
"name",
".",
"lower",
"(",
")",
"==",
"reader_name",
".",
"lower",
"(",
")",
":",
"return",
"reader_class",
... | Get a particular reader class by name. | [
"Get",
"a",
"particular",
"reader",
"class",
"by",
"name",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L773-L780 | train |
sorgerlab/indra | indra/tools/reading/readers.py | Content.from_file | def from_file(cls, file_path, compressed=False, encoded=False):
"""Create a content object from a file path."""
file_id = '.'.join(path.basename(file_path).split('.')[:-1])
file_format = file_path.split('.')[-1]
content = cls(file_id, file_format, compressed, encoded)
content.fil... | python | def from_file(cls, file_path, compressed=False, encoded=False):
"""Create a content object from a file path."""
file_id = '.'.join(path.basename(file_path).split('.')[:-1])
file_format = file_path.split('.')[-1]
content = cls(file_id, file_format, compressed, encoded)
content.fil... | [
"def",
"from_file",
"(",
"cls",
",",
"file_path",
",",
"compressed",
"=",
"False",
",",
"encoded",
"=",
"False",
")",
":",
"file_id",
"=",
"'.'",
".",
"join",
"(",
"path",
".",
"basename",
"(",
"file_path",
")",
".",
"split",
"(",
"'.'",
")",
"[",
... | Create a content object from a file path. | [
"Create",
"a",
"content",
"object",
"from",
"a",
"file",
"path",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L100-L107 | train |
sorgerlab/indra | indra/tools/reading/readers.py | Content.change_id | def change_id(self, new_id):
"""Change the id of this content."""
self._load_raw_content()
self._id = new_id
self.get_filename(renew=True)
self.get_filepath(renew=True)
return | python | def change_id(self, new_id):
"""Change the id of this content."""
self._load_raw_content()
self._id = new_id
self.get_filename(renew=True)
self.get_filepath(renew=True)
return | [
"def",
"change_id",
"(",
"self",
",",
"new_id",
")",
":",
"self",
".",
"_load_raw_content",
"(",
")",
"self",
".",
"_id",
"=",
"new_id",
"self",
".",
"get_filename",
"(",
"renew",
"=",
"True",
")",
"self",
".",
"get_filepath",
"(",
"renew",
"=",
"True"... | Change the id of this content. | [
"Change",
"the",
"id",
"of",
"this",
"content",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L123-L129 | train |
sorgerlab/indra | indra/tools/reading/readers.py | Content.change_format | def change_format(self, new_format):
"""Change the format label of this content.
Note that this does NOT actually alter the format of the content, only
the label.
"""
self._load_raw_content()
self._format = new_format
self.get_filename(renew=True)
self.ge... | python | def change_format(self, new_format):
"""Change the format label of this content.
Note that this does NOT actually alter the format of the content, only
the label.
"""
self._load_raw_content()
self._format = new_format
self.get_filename(renew=True)
self.ge... | [
"def",
"change_format",
"(",
"self",
",",
"new_format",
")",
":",
"self",
".",
"_load_raw_content",
"(",
")",
"self",
".",
"_format",
"=",
"new_format",
"self",
".",
"get_filename",
"(",
"renew",
"=",
"True",
")",
"self",
".",
"get_filepath",
"(",
"renew",... | Change the format label of this content.
Note that this does NOT actually alter the format of the content, only
the label. | [
"Change",
"the",
"format",
"label",
"of",
"this",
"content",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L131-L141 | train |
sorgerlab/indra | indra/tools/reading/readers.py | Content.get_text | def get_text(self):
"""Get the loaded, decompressed, and decoded text of this content."""
self._load_raw_content()
if self._text is None:
assert self._raw_content is not None
ret_cont = self._raw_content
if self.compressed:
ret_cont = zlib.deco... | python | def get_text(self):
"""Get the loaded, decompressed, and decoded text of this content."""
self._load_raw_content()
if self._text is None:
assert self._raw_content is not None
ret_cont = self._raw_content
if self.compressed:
ret_cont = zlib.deco... | [
"def",
"get_text",
"(",
"self",
")",
":",
"self",
".",
"_load_raw_content",
"(",
")",
"if",
"self",
".",
"_text",
"is",
"None",
":",
"assert",
"self",
".",
"_raw_content",
"is",
"not",
"None",
"ret_cont",
"=",
"self",
".",
"_raw_content",
"if",
"self",
... | Get the loaded, decompressed, and decoded text of this content. | [
"Get",
"the",
"loaded",
"decompressed",
"and",
"decoded",
"text",
"of",
"this",
"content",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L164-L176 | train |
sorgerlab/indra | indra/tools/reading/readers.py | Content.get_filename | def get_filename(self, renew=False):
"""Get the filename of this content.
If the file name doesn't already exist, we created it as {id}.{format}.
"""
if self._fname is None or renew:
self._fname = '%s.%s' % (self._id, self._format)
return self._fname | python | def get_filename(self, renew=False):
"""Get the filename of this content.
If the file name doesn't already exist, we created it as {id}.{format}.
"""
if self._fname is None or renew:
self._fname = '%s.%s' % (self._id, self._format)
return self._fname | [
"def",
"get_filename",
"(",
"self",
",",
"renew",
"=",
"False",
")",
":",
"if",
"self",
".",
"_fname",
"is",
"None",
"or",
"renew",
":",
"self",
".",
"_fname",
"=",
"'%s.%s'",
"%",
"(",
"self",
".",
"_id",
",",
"self",
".",
"_format",
")",
"return"... | Get the filename of this content.
If the file name doesn't already exist, we created it as {id}.{format}. | [
"Get",
"the",
"filename",
"of",
"this",
"content",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L178-L185 | train |
sorgerlab/indra | indra/tools/reading/readers.py | Content.get_filepath | def get_filepath(self, renew=False):
"""Get the file path, joining the name and location for this file.
If no location is given, it is assumed to be "here", e.g. ".".
"""
if self._location is None or renew:
self._location = '.'
return path.join(self._location, self.g... | python | def get_filepath(self, renew=False):
"""Get the file path, joining the name and location for this file.
If no location is given, it is assumed to be "here", e.g. ".".
"""
if self._location is None or renew:
self._location = '.'
return path.join(self._location, self.g... | [
"def",
"get_filepath",
"(",
"self",
",",
"renew",
"=",
"False",
")",
":",
"if",
"self",
".",
"_location",
"is",
"None",
"or",
"renew",
":",
"self",
".",
"_location",
"=",
"'.'",
"return",
"path",
".",
"join",
"(",
"self",
".",
"_location",
",",
"self... | Get the file path, joining the name and location for this file.
If no location is given, it is assumed to be "here", e.g. ".". | [
"Get",
"the",
"file",
"path",
"joining",
"the",
"name",
"and",
"location",
"for",
"this",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L187-L194 | train |
sorgerlab/indra | indra/tools/reading/readers.py | ReadingData.get_statements | def get_statements(self, reprocess=False):
"""General method to create statements."""
if self._statements is None or reprocess:
# Handle the case that there is no content.
if self.content is None:
self._statements = []
return []
# Map ... | python | def get_statements(self, reprocess=False):
"""General method to create statements."""
if self._statements is None or reprocess:
# Handle the case that there is no content.
if self.content is None:
self._statements = []
return []
# Map ... | [
"def",
"get_statements",
"(",
"self",
",",
"reprocess",
"=",
"False",
")",
":",
"if",
"self",
".",
"_statements",
"is",
"None",
"or",
"reprocess",
":",
"# Handle the case that there is no content.",
"if",
"self",
".",
"content",
"is",
"None",
":",
"self",
".",... | General method to create statements. | [
"General",
"method",
"to",
"create",
"statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L241-L282 | train |
sorgerlab/indra | indra/tools/reading/readers.py | Reader.add_result | def add_result(self, content_id, content, **kwargs):
""""Add a result to the list of results."""
result_object = self.ResultClass(content_id, self.name, self.version,
formats.JSON, content, **kwargs)
self.results.append(result_object)
return | python | def add_result(self, content_id, content, **kwargs):
""""Add a result to the list of results."""
result_object = self.ResultClass(content_id, self.name, self.version,
formats.JSON, content, **kwargs)
self.results.append(result_object)
return | [
"def",
"add_result",
"(",
"self",
",",
"content_id",
",",
"content",
",",
"*",
"*",
"kwargs",
")",
":",
"result_object",
"=",
"self",
".",
"ResultClass",
"(",
"content_id",
",",
"self",
".",
"name",
",",
"self",
".",
"version",
",",
"formats",
".",
"JS... | Add a result to the list of results. | [
"Add",
"a",
"result",
"to",
"the",
"list",
"of",
"results",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L316-L321 | train |
sorgerlab/indra | indra/tools/reading/readers.py | Reader._check_content | def _check_content(self, content_str):
"""Check if the content is likely to be successfully read."""
if self.do_content_check:
space_ratio = float(content_str.count(' '))/len(content_str)
if space_ratio > self.max_space_ratio:
return "space-ratio: %f > %f" % (spac... | python | def _check_content(self, content_str):
"""Check if the content is likely to be successfully read."""
if self.do_content_check:
space_ratio = float(content_str.count(' '))/len(content_str)
if space_ratio > self.max_space_ratio:
return "space-ratio: %f > %f" % (spac... | [
"def",
"_check_content",
"(",
"self",
",",
"content_str",
")",
":",
"if",
"self",
".",
"do_content_check",
":",
"space_ratio",
"=",
"float",
"(",
"content_str",
".",
"count",
"(",
"' '",
")",
")",
"/",
"len",
"(",
"content_str",
")",
"if",
"space_ratio",
... | Check if the content is likely to be successfully read. | [
"Check",
"if",
"the",
"content",
"is",
"likely",
"to",
"be",
"successfully",
"read",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L323-L333 | train |
sorgerlab/indra | indra/tools/reading/readers.py | ReachReader._check_reach_env | def _check_reach_env():
"""Check that the environment supports runnig reach."""
# Get the path to the REACH JAR
path_to_reach = get_config('REACHPATH')
if path_to_reach is None:
path_to_reach = environ.get('REACHPATH', None)
if path_to_reach is None or not path.exists... | python | def _check_reach_env():
"""Check that the environment supports runnig reach."""
# Get the path to the REACH JAR
path_to_reach = get_config('REACHPATH')
if path_to_reach is None:
path_to_reach = environ.get('REACHPATH', None)
if path_to_reach is None or not path.exists... | [
"def",
"_check_reach_env",
"(",
")",
":",
"# Get the path to the REACH JAR",
"path_to_reach",
"=",
"get_config",
"(",
"'REACHPATH'",
")",
"if",
"path_to_reach",
"is",
"None",
":",
"path_to_reach",
"=",
"environ",
".",
"get",
"(",
"'REACHPATH'",
",",
"None",
")",
... | Check that the environment supports runnig reach. | [
"Check",
"that",
"the",
"environment",
"supports",
"runnig",
"reach",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L409-L433 | train |
sorgerlab/indra | indra/tools/reading/readers.py | ReachReader.prep_input | def prep_input(self, read_list):
"""Apply the readers to the content."""
logger.info("Prepping input.")
i = 0
for content in read_list:
# Check the quality of the text, and skip if there are any issues.
quality_issue = self._check_content(content.get_text())
... | python | def prep_input(self, read_list):
"""Apply the readers to the content."""
logger.info("Prepping input.")
i = 0
for content in read_list:
# Check the quality of the text, and skip if there are any issues.
quality_issue = self._check_content(content.get_text())
... | [
"def",
"prep_input",
"(",
"self",
",",
"read_list",
")",
":",
"logger",
".",
"info",
"(",
"\"Prepping input.\"",
")",
"i",
"=",
"0",
"for",
"content",
"in",
"read_list",
":",
"# Check the quality of the text, and skip if there are any issues.",
"quality_issue",
"=",
... | Apply the readers to the content. | [
"Apply",
"the",
"readers",
"to",
"the",
"content",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L440-L466 | train |
sorgerlab/indra | indra/tools/reading/readers.py | ReachReader.get_output | def get_output(self):
"""Get the output of a reading job as a list of filenames."""
logger.info("Getting outputs.")
# Get the set of prefixes (each will correspond to three json files.)
json_files = glob.glob(path.join(self.output_dir, '*.json'))
json_prefixes = set()
for... | python | def get_output(self):
"""Get the output of a reading job as a list of filenames."""
logger.info("Getting outputs.")
# Get the set of prefixes (each will correspond to three json files.)
json_files = glob.glob(path.join(self.output_dir, '*.json'))
json_prefixes = set()
for... | [
"def",
"get_output",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Getting outputs.\"",
")",
"# Get the set of prefixes (each will correspond to three json files.)",
"json_files",
"=",
"glob",
".",
"glob",
"(",
"path",
".",
"join",
"(",
"self",
".",
"output_... | Get the output of a reading job as a list of filenames. | [
"Get",
"the",
"output",
"of",
"a",
"reading",
"job",
"as",
"a",
"list",
"of",
"filenames",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L468-L494 | train |
sorgerlab/indra | indra/tools/reading/readers.py | ReachReader.read | def read(self, read_list, verbose=False, log=False):
"""Read the content, returning a list of ReadingData objects."""
ret = []
mem_tot = _get_mem_total()
if mem_tot is not None and mem_tot <= self.REACH_MEM + self.MEM_BUFFER:
logger.error(
"Too little memory t... | python | def read(self, read_list, verbose=False, log=False):
"""Read the content, returning a list of ReadingData objects."""
ret = []
mem_tot = _get_mem_total()
if mem_tot is not None and mem_tot <= self.REACH_MEM + self.MEM_BUFFER:
logger.error(
"Too little memory t... | [
"def",
"read",
"(",
"self",
",",
"read_list",
",",
"verbose",
"=",
"False",
",",
"log",
"=",
"False",
")",
":",
"ret",
"=",
"[",
"]",
"mem_tot",
"=",
"_get_mem_total",
"(",
")",
"if",
"mem_tot",
"is",
"not",
"None",
"and",
"mem_tot",
"<=",
"self",
... | Read the content, returning a list of ReadingData objects. | [
"Read",
"the",
"content",
"returning",
"a",
"list",
"of",
"ReadingData",
"objects",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L505-L549 | train |
sorgerlab/indra | indra/tools/reading/readers.py | SparserReader.prep_input | def prep_input(self, read_list):
"Prepare the list of files or text content objects to be read."
logger.info('Prepping input for sparser.')
self.file_list = []
for content in read_list:
quality_issue = self._check_content(content.get_text())
if quality_issue is ... | python | def prep_input(self, read_list):
"Prepare the list of files or text content objects to be read."
logger.info('Prepping input for sparser.')
self.file_list = []
for content in read_list:
quality_issue = self._check_content(content.get_text())
if quality_issue is ... | [
"def",
"prep_input",
"(",
"self",
",",
"read_list",
")",
":",
"logger",
".",
"info",
"(",
"'Prepping input for sparser.'",
")",
"self",
".",
"file_list",
"=",
"[",
"]",
"for",
"content",
"in",
"read_list",
":",
"quality_issue",
"=",
"self",
".",
"_check_cont... | Prepare the list of files or text content objects to be read. | [
"Prepare",
"the",
"list",
"of",
"files",
"or",
"text",
"content",
"objects",
"to",
"be",
"read",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L567-L598 | train |
sorgerlab/indra | indra/tools/reading/readers.py | SparserReader.get_output | def get_output(self, output_files, clear=True):
"Get the output files as an id indexed dict."
patt = re.compile(r'(.*?)-semantics.*?')
for outpath in output_files:
if outpath is None:
logger.warning("Found outpath with value None. Skipping.")
continue
... | python | def get_output(self, output_files, clear=True):
"Get the output files as an id indexed dict."
patt = re.compile(r'(.*?)-semantics.*?')
for outpath in output_files:
if outpath is None:
logger.warning("Found outpath with value None. Skipping.")
continue
... | [
"def",
"get_output",
"(",
"self",
",",
"output_files",
",",
"clear",
"=",
"True",
")",
":",
"patt",
"=",
"re",
".",
"compile",
"(",
"r'(.*?)-semantics.*?'",
")",
"for",
"outpath",
"in",
"output_files",
":",
"if",
"outpath",
"is",
"None",
":",
"logger",
"... | Get the output files as an id indexed dict. | [
"Get",
"the",
"output",
"files",
"as",
"an",
"id",
"indexed",
"dict",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L600-L639 | train |
sorgerlab/indra | indra/tools/reading/readers.py | SparserReader.read_some | def read_some(self, fpath_list, outbuf=None, verbose=False):
"Perform a few readings."
outpath_list = []
for fpath in fpath_list:
output, outbuf = self.read_one(fpath, outbuf, verbose)
if output is not None:
outpath_list.append(output)
return outpa... | python | def read_some(self, fpath_list, outbuf=None, verbose=False):
"Perform a few readings."
outpath_list = []
for fpath in fpath_list:
output, outbuf = self.read_one(fpath, outbuf, verbose)
if output is not None:
outpath_list.append(output)
return outpa... | [
"def",
"read_some",
"(",
"self",
",",
"fpath_list",
",",
"outbuf",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"outpath_list",
"=",
"[",
"]",
"for",
"fpath",
"in",
"fpath_list",
":",
"output",
",",
"outbuf",
"=",
"self",
".",
"read_one",
"(",
... | Perform a few readings. | [
"Perform",
"a",
"few",
"readings",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L662-L669 | train |
sorgerlab/indra | indra/tools/reading/readers.py | SparserReader.read | def read(self, read_list, verbose=False, log=False, n_per_proc=None):
"Perform the actual reading."
ret = []
self.prep_input(read_list)
L = len(self.file_list)
if L == 0:
return ret
logger.info("Beginning to run sparser.")
output_file_list = []
... | python | def read(self, read_list, verbose=False, log=False, n_per_proc=None):
"Perform the actual reading."
ret = []
self.prep_input(read_list)
L = len(self.file_list)
if L == 0:
return ret
logger.info("Beginning to run sparser.")
output_file_list = []
... | [
"def",
"read",
"(",
"self",
",",
"read_list",
",",
"verbose",
"=",
"False",
",",
"log",
"=",
"False",
",",
"n_per_proc",
"=",
"None",
")",
":",
"ret",
"=",
"[",
"]",
"self",
".",
"prep_input",
"(",
"read_list",
")",
"L",
"=",
"len",
"(",
"self",
... | Perform the actual reading. | [
"Perform",
"the",
"actual",
"reading",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/readers.py#L671-L733 | train |
sorgerlab/indra | indra/sources/isi/api.py | process_text | def process_text(text, pmid=None, cleanup=True, add_grounding=True):
"""Process a string using the ISI reader and extract INDRA statements.
Parameters
----------
text : str
A text string to process
pmid : Optional[str]
The PMID associated with this text (or None if not specified)
... | python | def process_text(text, pmid=None, cleanup=True, add_grounding=True):
"""Process a string using the ISI reader and extract INDRA statements.
Parameters
----------
text : str
A text string to process
pmid : Optional[str]
The PMID associated with this text (or None if not specified)
... | [
"def",
"process_text",
"(",
"text",
",",
"pmid",
"=",
"None",
",",
"cleanup",
"=",
"True",
",",
"add_grounding",
"=",
"True",
")",
":",
"# Create a temporary directory to store the proprocessed input",
"pp_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"'indra_isi_pp_o... | Process a string using the ISI reader and extract INDRA statements.
Parameters
----------
text : str
A text string to process
pmid : Optional[str]
The PMID associated with this text (or None if not specified)
cleanup : Optional[bool]
If True, the temporary folders created fo... | [
"Process",
"a",
"string",
"using",
"the",
"ISI",
"reader",
"and",
"extract",
"INDRA",
"statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/api.py#L17-L55 | train |
sorgerlab/indra | indra/sources/isi/api.py | process_nxml | def process_nxml(nxml_filename, pmid=None, extra_annotations=None,
cleanup=True, add_grounding=True):
"""Process an NXML file using the ISI reader
First converts NXML to plain text and preprocesses it, then runs the ISI
reader, and processes the output to extract INDRA Statements.
Par... | python | def process_nxml(nxml_filename, pmid=None, extra_annotations=None,
cleanup=True, add_grounding=True):
"""Process an NXML file using the ISI reader
First converts NXML to plain text and preprocesses it, then runs the ISI
reader, and processes the output to extract INDRA Statements.
Par... | [
"def",
"process_nxml",
"(",
"nxml_filename",
",",
"pmid",
"=",
"None",
",",
"extra_annotations",
"=",
"None",
",",
"cleanup",
"=",
"True",
",",
"add_grounding",
"=",
"True",
")",
":",
"if",
"extra_annotations",
"is",
"None",
":",
"extra_annotations",
"=",
"{... | Process an NXML file using the ISI reader
First converts NXML to plain text and preprocesses it, then runs the ISI
reader, and processes the output to extract INDRA Statements.
Parameters
----------
nxml_filename : str
nxml file to process
pmid : Optional[str]
pmid of this nxml... | [
"Process",
"an",
"NXML",
"file",
"using",
"the",
"ISI",
"reader"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/api.py#L58-L109 | train |
sorgerlab/indra | indra/sources/isi/api.py | process_output_folder | def process_output_folder(folder_path, pmids=None, extra_annotations=None,
add_grounding=True):
"""Recursively extracts statements from all ISI output files in the
given directory and subdirectories.
Parameters
----------
folder_path : str
The directory to traverse... | python | def process_output_folder(folder_path, pmids=None, extra_annotations=None,
add_grounding=True):
"""Recursively extracts statements from all ISI output files in the
given directory and subdirectories.
Parameters
----------
folder_path : str
The directory to traverse... | [
"def",
"process_output_folder",
"(",
"folder_path",
",",
"pmids",
"=",
"None",
",",
"extra_annotations",
"=",
"None",
",",
"add_grounding",
"=",
"True",
")",
":",
"pmids",
"=",
"pmids",
"if",
"pmids",
"is",
"not",
"None",
"else",
"{",
"}",
"extra_annotations... | Recursively extracts statements from all ISI output files in the
given directory and subdirectories.
Parameters
----------
folder_path : str
The directory to traverse
pmids : Optional[str]
PMID mapping to be added to the Evidence of the extracted INDRA
Statements
extra_a... | [
"Recursively",
"extracts",
"statements",
"from",
"all",
"ISI",
"output",
"files",
"in",
"the",
"given",
"directory",
"and",
"subdirectories",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/api.py#L196-L237 | train |
sorgerlab/indra | indra/sources/isi/api.py | process_json_file | def process_json_file(file_path, pmid=None, extra_annotations=None,
add_grounding=True):
"""Extracts statements from the given ISI output file.
Parameters
----------
file_path : str
The ISI output file from which to extract statements
pmid : int
The PMID of the... | python | def process_json_file(file_path, pmid=None, extra_annotations=None,
add_grounding=True):
"""Extracts statements from the given ISI output file.
Parameters
----------
file_path : str
The ISI output file from which to extract statements
pmid : int
The PMID of the... | [
"def",
"process_json_file",
"(",
"file_path",
",",
"pmid",
"=",
"None",
",",
"extra_annotations",
"=",
"None",
",",
"add_grounding",
"=",
"True",
")",
":",
"logger",
".",
"info",
"(",
"'Extracting from %s'",
"%",
"file_path",
")",
"with",
"open",
"(",
"file_... | Extracts statements from the given ISI output file.
Parameters
----------
file_path : str
The ISI output file from which to extract statements
pmid : int
The PMID of the document being preprocessed, or None if not
specified
extra_annotations : dict
Extra annotations ... | [
"Extracts",
"statements",
"from",
"the",
"given",
"ISI",
"output",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/api.py#L240-L264 | train |
sorgerlab/indra | indra/sources/cwms/api.py | process_text | def process_text(text, save_xml='cwms_output.xml'):
"""Processes text using the CWMS web service.
Parameters
----------
text : str
Text to process
Returns
-------
cp : indra.sources.cwms.CWMSProcessor
A CWMSProcessor, which contains a list of INDRA statements in its
... | python | def process_text(text, save_xml='cwms_output.xml'):
"""Processes text using the CWMS web service.
Parameters
----------
text : str
Text to process
Returns
-------
cp : indra.sources.cwms.CWMSProcessor
A CWMSProcessor, which contains a list of INDRA statements in its
... | [
"def",
"process_text",
"(",
"text",
",",
"save_xml",
"=",
"'cwms_output.xml'",
")",
":",
"xml",
"=",
"client",
".",
"send_query",
"(",
"text",
",",
"'cwmsreader'",
")",
"# There are actually two EKBs in the xml document. Extract the second.",
"first_end",
"=",
"xml",
... | Processes text using the CWMS web service.
Parameters
----------
text : str
Text to process
Returns
-------
cp : indra.sources.cwms.CWMSProcessor
A CWMSProcessor, which contains a list of INDRA statements in its
statements attribute. | [
"Processes",
"text",
"using",
"the",
"CWMS",
"web",
"service",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/cwms/api.py#L11-L35 | train |
sorgerlab/indra | indra/sources/cwms/api.py | process_ekb_file | def process_ekb_file(fname):
"""Processes an EKB file produced by CWMS.
Parameters
----------
fname : str
Path to the EKB file to process.
Returns
-------
cp : indra.sources.cwms.CWMSProcessor
A CWMSProcessor, which contains a list of INDRA statements in its
stateme... | python | def process_ekb_file(fname):
"""Processes an EKB file produced by CWMS.
Parameters
----------
fname : str
Path to the EKB file to process.
Returns
-------
cp : indra.sources.cwms.CWMSProcessor
A CWMSProcessor, which contains a list of INDRA statements in its
stateme... | [
"def",
"process_ekb_file",
"(",
"fname",
")",
":",
"# Process EKB XML file into statements",
"with",
"open",
"(",
"fname",
",",
"'rb'",
")",
"as",
"fh",
":",
"ekb_str",
"=",
"fh",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"return",
"proces... | Processes an EKB file produced by CWMS.
Parameters
----------
fname : str
Path to the EKB file to process.
Returns
-------
cp : indra.sources.cwms.CWMSProcessor
A CWMSProcessor, which contains a list of INDRA statements in its
statements attribute. | [
"Processes",
"an",
"EKB",
"file",
"produced",
"by",
"CWMS",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/cwms/api.py#L38-L55 | train |
sorgerlab/indra | indra/assemblers/pysb/kappa_util.py | im_json_to_graph | def im_json_to_graph(im_json):
"""Return networkx graph from Kappy's influence map JSON.
Parameters
----------
im_json : dict
A JSON dict which contains an influence map generated by Kappy.
Returns
-------
graph : networkx.MultiDiGraph
A graph representing the influence map... | python | def im_json_to_graph(im_json):
"""Return networkx graph from Kappy's influence map JSON.
Parameters
----------
im_json : dict
A JSON dict which contains an influence map generated by Kappy.
Returns
-------
graph : networkx.MultiDiGraph
A graph representing the influence map... | [
"def",
"im_json_to_graph",
"(",
"im_json",
")",
":",
"imap_data",
"=",
"im_json",
"[",
"'influence map'",
"]",
"[",
"'map'",
"]",
"# Initialize the graph",
"graph",
"=",
"MultiDiGraph",
"(",
")",
"id_node_dict",
"=",
"{",
"}",
"# Add each node to the graph",
"for"... | Return networkx graph from Kappy's influence map JSON.
Parameters
----------
im_json : dict
A JSON dict which contains an influence map generated by Kappy.
Returns
-------
graph : networkx.MultiDiGraph
A graph representing the influence map. | [
"Return",
"networkx",
"graph",
"from",
"Kappy",
"s",
"influence",
"map",
"JSON",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/kappa_util.py#L7-L57 | train |
sorgerlab/indra | indra/assemblers/pysb/kappa_util.py | cm_json_to_graph | def cm_json_to_graph(im_json):
"""Return pygraphviz Agraph from Kappy's contact map JSON.
Parameters
----------
im_json : dict
A JSON dict which contains a contact map generated by Kappy.
Returns
-------
graph : pygraphviz.Agraph
A graph representing the contact map.
""... | python | def cm_json_to_graph(im_json):
"""Return pygraphviz Agraph from Kappy's contact map JSON.
Parameters
----------
im_json : dict
A JSON dict which contains a contact map generated by Kappy.
Returns
-------
graph : pygraphviz.Agraph
A graph representing the contact map.
""... | [
"def",
"cm_json_to_graph",
"(",
"im_json",
")",
":",
"cmap_data",
"=",
"im_json",
"[",
"'contact map'",
"]",
"[",
"'map'",
"]",
"# Initialize the graph",
"graph",
"=",
"AGraph",
"(",
")",
"# In this loop we add sites as nodes and clusters around sites to the",
"# graph. W... | Return pygraphviz Agraph from Kappy's contact map JSON.
Parameters
----------
im_json : dict
A JSON dict which contains a contact map generated by Kappy.
Returns
-------
graph : pygraphviz.Agraph
A graph representing the contact map. | [
"Return",
"pygraphviz",
"Agraph",
"from",
"Kappy",
"s",
"contact",
"map",
"JSON",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/kappa_util.py#L60-L104 | train |
sorgerlab/indra | indra/tools/machine/gmail_client.py | fetch_email | def fetch_email(M, msg_id):
"""Returns the given email message as a unicode string."""
res, data = M.fetch(msg_id, '(RFC822)')
if res == 'OK':
# Data here is a list with 1 element containing a tuple
# whose 2nd element is a long string containing the email
# The content is a bytes th... | python | def fetch_email(M, msg_id):
"""Returns the given email message as a unicode string."""
res, data = M.fetch(msg_id, '(RFC822)')
if res == 'OK':
# Data here is a list with 1 element containing a tuple
# whose 2nd element is a long string containing the email
# The content is a bytes th... | [
"def",
"fetch_email",
"(",
"M",
",",
"msg_id",
")",
":",
"res",
",",
"data",
"=",
"M",
".",
"fetch",
"(",
"msg_id",
",",
"'(RFC822)'",
")",
"if",
"res",
"==",
"'OK'",
":",
"# Data here is a list with 1 element containing a tuple",
"# whose 2nd element is a long st... | Returns the given email message as a unicode string. | [
"Returns",
"the",
"given",
"email",
"message",
"as",
"a",
"unicode",
"string",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/machine/gmail_client.py#L28-L47 | train |
sorgerlab/indra | indra/tools/machine/gmail_client.py | get_headers | def get_headers(msg):
"""Takes email.message.Message object initialized from unicode string,
returns dict with header fields."""
headers = {}
for k in msg.keys():
# decode_header decodes header but does not convert charset, so these
# may still be bytes, even in Python 3. However, if it'... | python | def get_headers(msg):
"""Takes email.message.Message object initialized from unicode string,
returns dict with header fields."""
headers = {}
for k in msg.keys():
# decode_header decodes header but does not convert charset, so these
# may still be bytes, even in Python 3. However, if it'... | [
"def",
"get_headers",
"(",
"msg",
")",
":",
"headers",
"=",
"{",
"}",
"for",
"k",
"in",
"msg",
".",
"keys",
"(",
")",
":",
"# decode_header decodes header but does not convert charset, so these",
"# may still be bytes, even in Python 3. However, if it's ASCII",
"# only (hen... | Takes email.message.Message object initialized from unicode string,
returns dict with header fields. | [
"Takes",
"email",
".",
"message",
".",
"Message",
"object",
"initialized",
"from",
"unicode",
"string",
"returns",
"dict",
"with",
"header",
"fields",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/machine/gmail_client.py#L49-L62 | train |
sorgerlab/indra | indra/config.py | populate_config_dict | def populate_config_dict(config_path):
"""Load the configuration file into the config_file dictionary
A ConfigParser-style configuration file can have multiple sections, but
we ignore the section distinction and load the key/value pairs from all
sections into a single key/value list.
"""
try:
... | python | def populate_config_dict(config_path):
"""Load the configuration file into the config_file dictionary
A ConfigParser-style configuration file can have multiple sections, but
we ignore the section distinction and load the key/value pairs from all
sections into a single key/value list.
"""
try:
... | [
"def",
"populate_config_dict",
"(",
"config_path",
")",
":",
"try",
":",
"config_dict",
"=",
"{",
"}",
"parser",
"=",
"RawConfigParser",
"(",
")",
"parser",
".",
"optionxform",
"=",
"lambda",
"x",
":",
"x",
"parser",
".",
"read",
"(",
"config_path",
")",
... | Load the configuration file into the config_file dictionary
A ConfigParser-style configuration file can have multiple sections, but
we ignore the section distinction and load the key/value pairs from all
sections into a single key/value list. | [
"Load",
"the",
"configuration",
"file",
"into",
"the",
"config_file",
"dictionary"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/config.py#L31-L58 | train |
sorgerlab/indra | indra/config.py | get_config | def get_config(key, failure_ok=True):
"""Get value by key from config file or environment.
Returns the configuration value, first checking the environment
variables and then, if it's not present there, checking the configuration
file.
Parameters
----------
key : str
The key for the... | python | def get_config(key, failure_ok=True):
"""Get value by key from config file or environment.
Returns the configuration value, first checking the environment
variables and then, if it's not present there, checking the configuration
file.
Parameters
----------
key : str
The key for the... | [
"def",
"get_config",
"(",
"key",
",",
"failure_ok",
"=",
"True",
")",
":",
"err_msg",
"=",
"\"Key %s not in environment or config file.\"",
"%",
"key",
"if",
"key",
"in",
"os",
".",
"environ",
":",
"return",
"os",
".",
"environ",
"[",
"key",
"]",
"elif",
"... | Get value by key from config file or environment.
Returns the configuration value, first checking the environment
variables and then, if it's not present there, checking the configuration
file.
Parameters
----------
key : str
The key for the configuration value to fetch
failure_ok ... | [
"Get",
"value",
"by",
"key",
"from",
"config",
"file",
"or",
"environment",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/config.py#L85-L122 | train |
sorgerlab/indra | indra/util/__init__.py | read_unicode_csv_fileobj | def read_unicode_csv_fileobj(fileobj, delimiter=',', quotechar='"',
quoting=csv.QUOTE_MINIMAL, lineterminator='\n',
encoding='utf-8', skiprows=0):
"""fileobj can be a StringIO in Py3, but should be a BytesIO in Py2."""
# Python 3 version
if sys.versi... | python | def read_unicode_csv_fileobj(fileobj, delimiter=',', quotechar='"',
quoting=csv.QUOTE_MINIMAL, lineterminator='\n',
encoding='utf-8', skiprows=0):
"""fileobj can be a StringIO in Py3, but should be a BytesIO in Py2."""
# Python 3 version
if sys.versi... | [
"def",
"read_unicode_csv_fileobj",
"(",
"fileobj",
",",
"delimiter",
"=",
"','",
",",
"quotechar",
"=",
"'\"'",
",",
"quoting",
"=",
"csv",
".",
"QUOTE_MINIMAL",
",",
"lineterminator",
"=",
"'\\n'",
",",
"encoding",
"=",
"'utf-8'",
",",
"skiprows",
"=",
"0",... | fileobj can be a StringIO in Py3, but should be a BytesIO in Py2. | [
"fileobj",
"can",
"be",
"a",
"StringIO",
"in",
"Py3",
"but",
"should",
"be",
"a",
"BytesIO",
"in",
"Py2",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/__init__.py#L113-L141 | train |
sorgerlab/indra | indra/util/__init__.py | fast_deepcopy | def fast_deepcopy(obj):
"""This is a faster implementation of deepcopy via pickle.
It is meant primarily for sets of Statements with complex hierarchies
but can be used for any object.
"""
with BytesIO() as buf:
pickle.dump(obj, buf)
buf.seek(0)
obj_new = pickle.load(buf)
... | python | def fast_deepcopy(obj):
"""This is a faster implementation of deepcopy via pickle.
It is meant primarily for sets of Statements with complex hierarchies
but can be used for any object.
"""
with BytesIO() as buf:
pickle.dump(obj, buf)
buf.seek(0)
obj_new = pickle.load(buf)
... | [
"def",
"fast_deepcopy",
"(",
"obj",
")",
":",
"with",
"BytesIO",
"(",
")",
"as",
"buf",
":",
"pickle",
".",
"dump",
"(",
"obj",
",",
"buf",
")",
"buf",
".",
"seek",
"(",
"0",
")",
"obj_new",
"=",
"pickle",
".",
"load",
"(",
"buf",
")",
"return",
... | This is a faster implementation of deepcopy via pickle.
It is meant primarily for sets of Statements with complex hierarchies
but can be used for any object. | [
"This",
"is",
"a",
"faster",
"implementation",
"of",
"deepcopy",
"via",
"pickle",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/__init__.py#L198-L208 | train |
sorgerlab/indra | indra/util/__init__.py | batch_iter | def batch_iter(iterator, batch_size, return_func=None, padding=None):
"""Break an iterable into batches of size batch_size
Note that `padding` should be set to something (anything) which is NOT a
valid member of the iterator. For example, None works for [0,1,2,...10], but
not for ['a', None, 'c', 'd'].... | python | def batch_iter(iterator, batch_size, return_func=None, padding=None):
"""Break an iterable into batches of size batch_size
Note that `padding` should be set to something (anything) which is NOT a
valid member of the iterator. For example, None works for [0,1,2,...10], but
not for ['a', None, 'c', 'd'].... | [
"def",
"batch_iter",
"(",
"iterator",
",",
"batch_size",
",",
"return_func",
"=",
"None",
",",
"padding",
"=",
"None",
")",
":",
"for",
"batch",
"in",
"zip_longest",
"(",
"*",
"[",
"iter",
"(",
"iterator",
")",
"]",
"*",
"batch_size",
",",
"fillvalue",
... | Break an iterable into batches of size batch_size
Note that `padding` should be set to something (anything) which is NOT a
valid member of the iterator. For example, None works for [0,1,2,...10], but
not for ['a', None, 'c', 'd'].
Parameters
----------
iterator : iterable
A python obje... | [
"Break",
"an",
"iterable",
"into",
"batches",
"of",
"size",
"batch_size"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/__init__.py#L227-L256 | train |
sorgerlab/indra | indra/tools/reading/run_drum_reading.py | read_pmid_sentences | def read_pmid_sentences(pmid_sentences, **drum_args):
"""Read sentences from a PMID-keyed dictonary and return all Statements
Parameters
----------
pmid_sentences : dict[str, list[str]]
A dictonary where each key is a PMID pointing to a list of sentences
to be read.
**drum_args
... | python | def read_pmid_sentences(pmid_sentences, **drum_args):
"""Read sentences from a PMID-keyed dictonary and return all Statements
Parameters
----------
pmid_sentences : dict[str, list[str]]
A dictonary where each key is a PMID pointing to a list of sentences
to be read.
**drum_args
... | [
"def",
"read_pmid_sentences",
"(",
"pmid_sentences",
",",
"*",
"*",
"drum_args",
")",
":",
"def",
"_set_pmid",
"(",
"statements",
",",
"pmid",
")",
":",
"for",
"stmt",
"in",
"statements",
":",
"for",
"evidence",
"in",
"stmt",
".",
"evidence",
":",
"evidenc... | Read sentences from a PMID-keyed dictonary and return all Statements
Parameters
----------
pmid_sentences : dict[str, list[str]]
A dictonary where each key is a PMID pointing to a list of sentences
to be read.
**drum_args
Keyword arguments passed directly to the DrumReader. Typ... | [
"Read",
"sentences",
"from",
"a",
"PMID",
"-",
"keyed",
"dictonary",
"and",
"return",
"all",
"Statements"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/run_drum_reading.py#L14-L86 | train |
sorgerlab/indra | indra/sources/biopax/pathway_commons_client.py | graph_query | def graph_query(kind, source, target=None, neighbor_limit=1,
database_filter=None):
"""Perform a graph query on PathwayCommons.
For more information on these queries, see
http://www.pathwaycommons.org/pc2/#graph
Parameters
----------
kind : str
The kind of graph query t... | python | def graph_query(kind, source, target=None, neighbor_limit=1,
database_filter=None):
"""Perform a graph query on PathwayCommons.
For more information on these queries, see
http://www.pathwaycommons.org/pc2/#graph
Parameters
----------
kind : str
The kind of graph query t... | [
"def",
"graph_query",
"(",
"kind",
",",
"source",
",",
"target",
"=",
"None",
",",
"neighbor_limit",
"=",
"1",
",",
"database_filter",
"=",
"None",
")",
":",
"default_databases",
"=",
"[",
"'wp'",
",",
"'smpdb'",
",",
"'reconx'",
",",
"'reactome'",
",",
... | Perform a graph query on PathwayCommons.
For more information on these queries, see
http://www.pathwaycommons.org/pc2/#graph
Parameters
----------
kind : str
The kind of graph query to perform. Currently 3 options are
implemented, 'neighborhood', 'pathsbetween' and 'pathsfromto'.
... | [
"Perform",
"a",
"graph",
"query",
"on",
"PathwayCommons",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biopax/pathway_commons_client.py#L17-L99 | train |
sorgerlab/indra | indra/sources/biopax/pathway_commons_client.py | owl_str_to_model | def owl_str_to_model(owl_str):
"""Return a BioPAX model object from an OWL string.
Parameters
----------
owl_str : str
The model as an OWL string.
Returns
-------
biopax_model : org.biopax.paxtools.model.Model
A BioPAX model object (java object).
"""
io_class = auto... | python | def owl_str_to_model(owl_str):
"""Return a BioPAX model object from an OWL string.
Parameters
----------
owl_str : str
The model as an OWL string.
Returns
-------
biopax_model : org.biopax.paxtools.model.Model
A BioPAX model object (java object).
"""
io_class = auto... | [
"def",
"owl_str_to_model",
"(",
"owl_str",
")",
":",
"io_class",
"=",
"autoclass",
"(",
"'org.biopax.paxtools.io.SimpleIOHandler'",
")",
"io",
"=",
"io_class",
"(",
"autoclass",
"(",
"'org.biopax.paxtools.model.BioPAXLevel'",
")",
".",
"L3",
")",
"bais",
"=",
"autoc... | Return a BioPAX model object from an OWL string.
Parameters
----------
owl_str : str
The model as an OWL string.
Returns
-------
biopax_model : org.biopax.paxtools.model.Model
A BioPAX model object (java object). | [
"Return",
"a",
"BioPAX",
"model",
"object",
"from",
"an",
"OWL",
"string",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biopax/pathway_commons_client.py#L101-L121 | train |
sorgerlab/indra | indra/sources/biopax/pathway_commons_client.py | owl_to_model | def owl_to_model(fname):
"""Return a BioPAX model object from an OWL file.
Parameters
----------
fname : str
The name of the OWL file containing the model.
Returns
-------
biopax_model : org.biopax.paxtools.model.Model
A BioPAX model object (java object).
"""
io_cla... | python | def owl_to_model(fname):
"""Return a BioPAX model object from an OWL file.
Parameters
----------
fname : str
The name of the OWL file containing the model.
Returns
-------
biopax_model : org.biopax.paxtools.model.Model
A BioPAX model object (java object).
"""
io_cla... | [
"def",
"owl_to_model",
"(",
"fname",
")",
":",
"io_class",
"=",
"autoclass",
"(",
"'org.biopax.paxtools.io.SimpleIOHandler'",
")",
"io",
"=",
"io_class",
"(",
"autoclass",
"(",
"'org.biopax.paxtools.model.BioPAXLevel'",
")",
".",
"L3",
")",
"try",
":",
"file_is",
... | Return a BioPAX model object from an OWL file.
Parameters
----------
fname : str
The name of the OWL file containing the model.
Returns
-------
biopax_model : org.biopax.paxtools.model.Model
A BioPAX model object (java object). | [
"Return",
"a",
"BioPAX",
"model",
"object",
"from",
"an",
"OWL",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biopax/pathway_commons_client.py#L123-L153 | train |
sorgerlab/indra | indra/sources/biopax/pathway_commons_client.py | model_to_owl | def model_to_owl(model, fname):
"""Save a BioPAX model object as an OWL file.
Parameters
----------
model : org.biopax.paxtools.model.Model
A BioPAX model object (java object).
fname : str
The name of the OWL file to save the model in.
"""
io_class = autoclass('org.biopax.pa... | python | def model_to_owl(model, fname):
"""Save a BioPAX model object as an OWL file.
Parameters
----------
model : org.biopax.paxtools.model.Model
A BioPAX model object (java object).
fname : str
The name of the OWL file to save the model in.
"""
io_class = autoclass('org.biopax.pa... | [
"def",
"model_to_owl",
"(",
"model",
",",
"fname",
")",
":",
"io_class",
"=",
"autoclass",
"(",
"'org.biopax.paxtools.io.SimpleIOHandler'",
")",
"io",
"=",
"io_class",
"(",
"autoclass",
"(",
"'org.biopax.paxtools.model.BioPAXLevel'",
")",
".",
"L3",
")",
"try",
":... | Save a BioPAX model object as an OWL file.
Parameters
----------
model : org.biopax.paxtools.model.Model
A BioPAX model object (java object).
fname : str
The name of the OWL file to save the model in. | [
"Save",
"a",
"BioPAX",
"model",
"object",
"as",
"an",
"OWL",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biopax/pathway_commons_client.py#L155-L179 | train |
sorgerlab/indra | indra/assemblers/cyjs/assembler.py | CyJSAssembler.make_model | def make_model(self, *args, **kwargs):
"""Assemble a Cytoscape JS network from INDRA Statements.
This method assembles a Cytoscape JS network from the set of INDRA
Statements added to the assembler.
Parameters
----------
grouping : bool
If True, the nodes wi... | python | def make_model(self, *args, **kwargs):
"""Assemble a Cytoscape JS network from INDRA Statements.
This method assembles a Cytoscape JS network from the set of INDRA
Statements added to the assembler.
Parameters
----------
grouping : bool
If True, the nodes wi... | [
"def",
"make_model",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"stmt",
"in",
"self",
".",
"statements",
":",
"if",
"isinstance",
"(",
"stmt",
",",
"RegulateActivity",
")",
":",
"self",
".",
"_add_regulate_activity",
"(",
... | Assemble a Cytoscape JS network from INDRA Statements.
This method assembles a Cytoscape JS network from the set of INDRA
Statements added to the assembler.
Parameters
----------
grouping : bool
If True, the nodes with identical incoming and outgoing edges
... | [
"Assemble",
"a",
"Cytoscape",
"JS",
"network",
"from",
"INDRA",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cyjs/assembler.py#L69-L107 | train |
sorgerlab/indra | indra/assemblers/cyjs/assembler.py | CyJSAssembler.get_gene_names | def get_gene_names(self):
"""Gather gene names of all nodes and node members"""
# Collect all gene names in network
gene_names = []
for node in self._nodes:
members = node['data'].get('members')
if members:
gene_names += list(members.keys())
... | python | def get_gene_names(self):
"""Gather gene names of all nodes and node members"""
# Collect all gene names in network
gene_names = []
for node in self._nodes:
members = node['data'].get('members')
if members:
gene_names += list(members.keys())
... | [
"def",
"get_gene_names",
"(",
"self",
")",
":",
"# Collect all gene names in network",
"gene_names",
"=",
"[",
"]",
"for",
"node",
"in",
"self",
".",
"_nodes",
":",
"members",
"=",
"node",
"[",
"'data'",
"]",
".",
"get",
"(",
"'members'",
")",
"if",
"membe... | Gather gene names of all nodes and node members | [
"Gather",
"gene",
"names",
"of",
"all",
"nodes",
"and",
"node",
"members"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cyjs/assembler.py#L109-L121 | train |
sorgerlab/indra | indra/assemblers/cyjs/assembler.py | CyJSAssembler.set_CCLE_context | def set_CCLE_context(self, cell_types):
"""Set context of all nodes and node members from CCLE."""
self.get_gene_names()
# Get expression and mutations from context client
exp_values = \
context_client.get_protein_expression(self._gene_names, cell_types)
mut_values =... | python | def set_CCLE_context(self, cell_types):
"""Set context of all nodes and node members from CCLE."""
self.get_gene_names()
# Get expression and mutations from context client
exp_values = \
context_client.get_protein_expression(self._gene_names, cell_types)
mut_values =... | [
"def",
"set_CCLE_context",
"(",
"self",
",",
"cell_types",
")",
":",
"self",
".",
"get_gene_names",
"(",
")",
"# Get expression and mutations from context client",
"exp_values",
"=",
"context_client",
".",
"get_protein_expression",
"(",
"self",
".",
"_gene_names",
",",
... | Set context of all nodes and node members from CCLE. | [
"Set",
"context",
"of",
"all",
"nodes",
"and",
"node",
"members",
"from",
"CCLE",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cyjs/assembler.py#L123-L177 | train |
sorgerlab/indra | indra/assemblers/cyjs/assembler.py | CyJSAssembler.print_cyjs_graph | def print_cyjs_graph(self):
"""Return the assembled Cytoscape JS network as a json string.
Returns
-------
cyjs_str : str
A json string representation of the Cytoscape JS network.
"""
cyjs_dict = {'edges': self._edges, 'nodes': self._nodes}
cyjs_str =... | python | def print_cyjs_graph(self):
"""Return the assembled Cytoscape JS network as a json string.
Returns
-------
cyjs_str : str
A json string representation of the Cytoscape JS network.
"""
cyjs_dict = {'edges': self._edges, 'nodes': self._nodes}
cyjs_str =... | [
"def",
"print_cyjs_graph",
"(",
"self",
")",
":",
"cyjs_dict",
"=",
"{",
"'edges'",
":",
"self",
".",
"_edges",
",",
"'nodes'",
":",
"self",
".",
"_nodes",
"}",
"cyjs_str",
"=",
"json",
".",
"dumps",
"(",
"cyjs_dict",
",",
"indent",
"=",
"1",
",",
"s... | Return the assembled Cytoscape JS network as a json string.
Returns
-------
cyjs_str : str
A json string representation of the Cytoscape JS network. | [
"Return",
"the",
"assembled",
"Cytoscape",
"JS",
"network",
"as",
"a",
"json",
"string",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cyjs/assembler.py#L179-L189 | train |
sorgerlab/indra | indra/assemblers/cyjs/assembler.py | CyJSAssembler.print_cyjs_context | def print_cyjs_context(self):
"""Return a list of node names and their respective context.
Returns
-------
cyjs_str_context : str
A json string of the context dictionary. e.g. -
{'CCLE' : {'bin_expression' : {'cell_line1' : {'gene1':'val1'} },
'bin_ex... | python | def print_cyjs_context(self):
"""Return a list of node names and their respective context.
Returns
-------
cyjs_str_context : str
A json string of the context dictionary. e.g. -
{'CCLE' : {'bin_expression' : {'cell_line1' : {'gene1':'val1'} },
'bin_ex... | [
"def",
"print_cyjs_context",
"(",
"self",
")",
":",
"context",
"=",
"self",
".",
"_context",
"context_str",
"=",
"json",
".",
"dumps",
"(",
"context",
",",
"indent",
"=",
"1",
",",
"sort_keys",
"=",
"True",
")",
"return",
"context_str"
] | Return a list of node names and their respective context.
Returns
-------
cyjs_str_context : str
A json string of the context dictionary. e.g. -
{'CCLE' : {'bin_expression' : {'cell_line1' : {'gene1':'val1'} },
'bin_expression' : {'cell_line' : {'gene1':'val1... | [
"Return",
"a",
"list",
"of",
"node",
"names",
"and",
"their",
"respective",
"context",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cyjs/assembler.py#L191-L204 | train |
sorgerlab/indra | indra/assemblers/cyjs/assembler.py | CyJSAssembler.save_json | def save_json(self, fname_prefix='model'):
"""Save the assembled Cytoscape JS network in a json file.
This method saves two files based on the file name prefix given.
It saves one json file with the graph itself, and another json
file with the context.
Parameters
------... | python | def save_json(self, fname_prefix='model'):
"""Save the assembled Cytoscape JS network in a json file.
This method saves two files based on the file name prefix given.
It saves one json file with the graph itself, and another json
file with the context.
Parameters
------... | [
"def",
"save_json",
"(",
"self",
",",
"fname_prefix",
"=",
"'model'",
")",
":",
"cyjs_str",
"=",
"self",
".",
"print_cyjs_graph",
"(",
")",
"# outputs the graph",
"with",
"open",
"(",
"fname_prefix",
"+",
"'.json'",
",",
"'wb'",
")",
"as",
"fh",
":",
"fh",... | Save the assembled Cytoscape JS network in a json file.
This method saves two files based on the file name prefix given.
It saves one json file with the graph itself, and another json
file with the context.
Parameters
----------
fname_prefix : Optional[str]
... | [
"Save",
"the",
"assembled",
"Cytoscape",
"JS",
"network",
"in",
"a",
"json",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cyjs/assembler.py#L206-L227 | train |
sorgerlab/indra | indra/assemblers/cyjs/assembler.py | CyJSAssembler.save_model | def save_model(self, fname='model.js'):
"""Save the assembled Cytoscape JS network in a js file.
Parameters
----------
file_name : Optional[str]
The name of the file to save the Cytoscape JS network to.
Default: model.js
"""
exp_colorscale_str = j... | python | def save_model(self, fname='model.js'):
"""Save the assembled Cytoscape JS network in a js file.
Parameters
----------
file_name : Optional[str]
The name of the file to save the Cytoscape JS network to.
Default: model.js
"""
exp_colorscale_str = j... | [
"def",
"save_model",
"(",
"self",
",",
"fname",
"=",
"'model.js'",
")",
":",
"exp_colorscale_str",
"=",
"json",
".",
"dumps",
"(",
"self",
".",
"_exp_colorscale",
")",
"mut_colorscale_str",
"=",
"json",
".",
"dumps",
"(",
"self",
".",
"_mut_colorscale",
")",... | Save the assembled Cytoscape JS network in a js file.
Parameters
----------
file_name : Optional[str]
The name of the file to save the Cytoscape JS network to.
Default: model.js | [
"Save",
"the",
"assembled",
"Cytoscape",
"JS",
"network",
"in",
"a",
"js",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cyjs/assembler.py#L229-L250 | train |
sorgerlab/indra | indra/assemblers/cyjs/assembler.py | CyJSAssembler._get_edge_dict | def _get_edge_dict(self):
"""Return a dict of edges.
Keyed tuples of (i, source, target, polarity)
with lists of edge ids [id1, id2, ...]
"""
edge_dict = collections.defaultdict(lambda: [])
if len(self._edges) > 0:
for e in self._edges:
data =... | python | def _get_edge_dict(self):
"""Return a dict of edges.
Keyed tuples of (i, source, target, polarity)
with lists of edge ids [id1, id2, ...]
"""
edge_dict = collections.defaultdict(lambda: [])
if len(self._edges) > 0:
for e in self._edges:
data =... | [
"def",
"_get_edge_dict",
"(",
"self",
")",
":",
"edge_dict",
"=",
"collections",
".",
"defaultdict",
"(",
"lambda",
":",
"[",
"]",
")",
"if",
"len",
"(",
"self",
".",
"_edges",
")",
">",
"0",
":",
"for",
"e",
"in",
"self",
".",
"_edges",
":",
"data... | Return a dict of edges.
Keyed tuples of (i, source, target, polarity)
with lists of edge ids [id1, id2, ...] | [
"Return",
"a",
"dict",
"of",
"edges",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cyjs/assembler.py#L282-L295 | train |
sorgerlab/indra | indra/assemblers/cyjs/assembler.py | CyJSAssembler._get_node_key | def _get_node_key(self, node_dict_item):
"""Return a tuple of sorted sources and targets given a node dict."""
s = tuple(sorted(node_dict_item['sources']))
t = tuple(sorted(node_dict_item['targets']))
return (s, t) | python | def _get_node_key(self, node_dict_item):
"""Return a tuple of sorted sources and targets given a node dict."""
s = tuple(sorted(node_dict_item['sources']))
t = tuple(sorted(node_dict_item['targets']))
return (s, t) | [
"def",
"_get_node_key",
"(",
"self",
",",
"node_dict_item",
")",
":",
"s",
"=",
"tuple",
"(",
"sorted",
"(",
"node_dict_item",
"[",
"'sources'",
"]",
")",
")",
"t",
"=",
"tuple",
"(",
"sorted",
"(",
"node_dict_item",
"[",
"'targets'",
"]",
")",
")",
"r... | Return a tuple of sorted sources and targets given a node dict. | [
"Return",
"a",
"tuple",
"of",
"sorted",
"sources",
"and",
"targets",
"given",
"a",
"node",
"dict",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cyjs/assembler.py#L360-L364 | train |
sorgerlab/indra | indra/assemblers/cyjs/assembler.py | CyJSAssembler._get_node_groups | def _get_node_groups(self):
"""Return a list of node id lists that are topologically identical.
First construct a node_dict which is keyed to the node id and
has a value which is a dict with keys 'sources' and 'targets'.
The 'sources' and 'targets' each contain a list of tuples
... | python | def _get_node_groups(self):
"""Return a list of node id lists that are topologically identical.
First construct a node_dict which is keyed to the node id and
has a value which is a dict with keys 'sources' and 'targets'.
The 'sources' and 'targets' each contain a list of tuples
... | [
"def",
"_get_node_groups",
"(",
"self",
")",
":",
"node_dict",
"=",
"{",
"node",
"[",
"'data'",
"]",
"[",
"'id'",
"]",
":",
"{",
"'sources'",
":",
"[",
"]",
",",
"'targets'",
":",
"[",
"]",
"}",
"for",
"node",
"in",
"self",
".",
"_nodes",
"}",
"f... | Return a list of node id lists that are topologically identical.
First construct a node_dict which is keyed to the node id and
has a value which is a dict with keys 'sources' and 'targets'.
The 'sources' and 'targets' each contain a list of tuples
(i, polarity, source) edge of the node.... | [
"Return",
"a",
"list",
"of",
"node",
"id",
"lists",
"that",
"are",
"topologically",
"identical",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cyjs/assembler.py#L366-L396 | train |
sorgerlab/indra | indra/assemblers/cyjs/assembler.py | CyJSAssembler._group_edges | def _group_edges(self):
"""Group all edges that are topologically identical.
This means that (i, source, target, polarity) are the same, then sets
edges on parent (i.e. - group) nodes to 'Virtual' and creates a new
edge to represent all of them.
"""
# edit edges on paren... | python | def _group_edges(self):
"""Group all edges that are topologically identical.
This means that (i, source, target, polarity) are the same, then sets
edges on parent (i.e. - group) nodes to 'Virtual' and creates a new
edge to represent all of them.
"""
# edit edges on paren... | [
"def",
"_group_edges",
"(",
"self",
")",
":",
"# edit edges on parent nodes and make new edges for them",
"edges_to_add",
"=",
"[",
"[",
"]",
",",
"[",
"]",
"]",
"# [group_edges, uuid_lists]",
"for",
"e",
"in",
"self",
".",
"_edges",
":",
"new_edge",
"=",
"deepcop... | Group all edges that are topologically identical.
This means that (i, source, target, polarity) are the same, then sets
edges on parent (i.e. - group) nodes to 'Virtual' and creates a new
edge to represent all of them. | [
"Group",
"all",
"edges",
"that",
"are",
"topologically",
"identical",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cyjs/assembler.py#L398-L442 | train |
sorgerlab/indra | indra/sources/trrust/processor.py | make_stmt | def make_stmt(stmt_cls, tf_agent, target_agent, pmid):
"""Return a Statement based on its type, agents, and PMID."""
ev = Evidence(source_api='trrust', pmid=pmid)
return stmt_cls(deepcopy(tf_agent), deepcopy(target_agent),
evidence=[ev]) | python | def make_stmt(stmt_cls, tf_agent, target_agent, pmid):
"""Return a Statement based on its type, agents, and PMID."""
ev = Evidence(source_api='trrust', pmid=pmid)
return stmt_cls(deepcopy(tf_agent), deepcopy(target_agent),
evidence=[ev]) | [
"def",
"make_stmt",
"(",
"stmt_cls",
",",
"tf_agent",
",",
"target_agent",
",",
"pmid",
")",
":",
"ev",
"=",
"Evidence",
"(",
"source_api",
"=",
"'trrust'",
",",
"pmid",
"=",
"pmid",
")",
"return",
"stmt_cls",
"(",
"deepcopy",
"(",
"tf_agent",
")",
",",
... | Return a Statement based on its type, agents, and PMID. | [
"Return",
"a",
"Statement",
"based",
"on",
"its",
"type",
"agents",
"and",
"PMID",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trrust/processor.py#L37-L41 | train |
sorgerlab/indra | indra/sources/trrust/processor.py | get_grounded_agent | def get_grounded_agent(gene_name):
"""Return a grounded Agent based on an HGNC symbol."""
db_refs = {'TEXT': gene_name}
if gene_name in hgnc_map:
gene_name = hgnc_map[gene_name]
hgnc_id = hgnc_client.get_hgnc_id(gene_name)
if hgnc_id:
db_refs['HGNC'] = hgnc_id
up_id = hgnc_cl... | python | def get_grounded_agent(gene_name):
"""Return a grounded Agent based on an HGNC symbol."""
db_refs = {'TEXT': gene_name}
if gene_name in hgnc_map:
gene_name = hgnc_map[gene_name]
hgnc_id = hgnc_client.get_hgnc_id(gene_name)
if hgnc_id:
db_refs['HGNC'] = hgnc_id
up_id = hgnc_cl... | [
"def",
"get_grounded_agent",
"(",
"gene_name",
")",
":",
"db_refs",
"=",
"{",
"'TEXT'",
":",
"gene_name",
"}",
"if",
"gene_name",
"in",
"hgnc_map",
":",
"gene_name",
"=",
"hgnc_map",
"[",
"gene_name",
"]",
"hgnc_id",
"=",
"hgnc_client",
".",
"get_hgnc_id",
"... | Return a grounded Agent based on an HGNC symbol. | [
"Return",
"a",
"grounded",
"Agent",
"based",
"on",
"an",
"HGNC",
"symbol",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trrust/processor.py#L44-L56 | train |
sorgerlab/indra | indra/sources/trrust/processor.py | TrrustProcessor.extract_statements | def extract_statements(self):
"""Process the table to extract Statements."""
for _, (tf, target, effect, refs) in self.df.iterrows():
tf_agent = get_grounded_agent(tf)
target_agent = get_grounded_agent(target)
if effect == 'Activation':
stmt_cls = Incr... | python | def extract_statements(self):
"""Process the table to extract Statements."""
for _, (tf, target, effect, refs) in self.df.iterrows():
tf_agent = get_grounded_agent(tf)
target_agent = get_grounded_agent(target)
if effect == 'Activation':
stmt_cls = Incr... | [
"def",
"extract_statements",
"(",
"self",
")",
":",
"for",
"_",
",",
"(",
"tf",
",",
"target",
",",
"effect",
",",
"refs",
")",
"in",
"self",
".",
"df",
".",
"iterrows",
"(",
")",
":",
"tf_agent",
"=",
"get_grounded_agent",
"(",
"tf",
")",
"target_ag... | Process the table to extract Statements. | [
"Process",
"the",
"table",
"to",
"extract",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trrust/processor.py#L20-L34 | train |
sorgerlab/indra | indra/tools/machine/machine.py | process_paper | def process_paper(model_name, pmid):
"""Process a paper with the given pubmed identifier
Parameters
----------
model_name : str
The directory for the INDRA machine
pmid : str
The PMID to process.
Returns
-------
rp : ReachProcessor
A ReachProcessor containing th... | python | def process_paper(model_name, pmid):
"""Process a paper with the given pubmed identifier
Parameters
----------
model_name : str
The directory for the INDRA machine
pmid : str
The PMID to process.
Returns
-------
rp : ReachProcessor
A ReachProcessor containing th... | [
"def",
"process_paper",
"(",
"model_name",
",",
"pmid",
")",
":",
"json_directory",
"=",
"os",
".",
"path",
".",
"join",
"(",
"model_name",
",",
"'jsons'",
")",
"json_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"json_directory",
",",
"'PMID%s.json'",
... | Process a paper with the given pubmed identifier
Parameters
----------
model_name : str
The directory for the INDRA machine
pmid : str
The PMID to process.
Returns
-------
rp : ReachProcessor
A ReachProcessor containing the extracted INDRA Statements
in rp.s... | [
"Process",
"a",
"paper",
"with",
"the",
"given",
"pubmed",
"identifier"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/machine/machine.py#L91-L140 | train |
sorgerlab/indra | indra/tools/machine/machine.py | process_paper_helper | def process_paper_helper(model_name, pmid, start_time_local):
"""Wraps processing a paper by either a local or remote service
and caches any uncaught exceptions"""
try:
if not aws_available:
rp, txt_format = process_paper(model_name, pmid)
else:
rp, txt_format = proce... | python | def process_paper_helper(model_name, pmid, start_time_local):
"""Wraps processing a paper by either a local or remote service
and caches any uncaught exceptions"""
try:
if not aws_available:
rp, txt_format = process_paper(model_name, pmid)
else:
rp, txt_format = proce... | [
"def",
"process_paper_helper",
"(",
"model_name",
",",
"pmid",
",",
"start_time_local",
")",
":",
"try",
":",
"if",
"not",
"aws_available",
":",
"rp",
",",
"txt_format",
"=",
"process_paper",
"(",
"model_name",
",",
"pmid",
")",
"else",
":",
"rp",
",",
"tx... | Wraps processing a paper by either a local or remote service
and caches any uncaught exceptions | [
"Wraps",
"processing",
"a",
"paper",
"by",
"either",
"a",
"local",
"or",
"remote",
"service",
"and",
"caches",
"any",
"uncaught",
"exceptions"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/machine/machine.py#L196-L208 | train |
sorgerlab/indra | indra/sources/tas/api.py | _load_data | def _load_data():
"""Load the data from the csv in data.
The "gene_id" is the Entrez gene id, and the "approved_symbol" is the
standard gene symbol. The "hms_id" is the LINCS ID for the drug.
Returns
-------
data : list[dict]
A list of dicts of row values keyed by the column headers ex... | python | def _load_data():
"""Load the data from the csv in data.
The "gene_id" is the Entrez gene id, and the "approved_symbol" is the
standard gene symbol. The "hms_id" is the LINCS ID for the drug.
Returns
-------
data : list[dict]
A list of dicts of row values keyed by the column headers ex... | [
"def",
"_load_data",
"(",
")",
":",
"# Get the cwv reader object.",
"csv_path",
"=",
"path",
".",
"join",
"(",
"HERE",
",",
"path",
".",
"pardir",
",",
"path",
".",
"pardir",
",",
"'resources'",
",",
"DATAFILE_NAME",
")",
"data_iter",
"=",
"list",
"(",
"re... | Load the data from the csv in data.
The "gene_id" is the Entrez gene id, and the "approved_symbol" is the
standard gene symbol. The "hms_id" is the LINCS ID for the drug.
Returns
-------
data : list[dict]
A list of dicts of row values keyed by the column headers extracted from
the ... | [
"Load",
"the",
"data",
"from",
"the",
"csv",
"in",
"data",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tas/api.py#L15-L39 | train |
sorgerlab/indra | indra/sources/eidos/cli.py | run_eidos | def run_eidos(endpoint, *args):
"""Run a given enpoint of Eidos through the command line.
Parameters
----------
endpoint : str
The class within the Eidos package to run, for instance
'apps.ExtractFromDirectory' will run
'org.clulab.wm.eidos.apps.ExtractFromDirectory'
*args
... | python | def run_eidos(endpoint, *args):
"""Run a given enpoint of Eidos through the command line.
Parameters
----------
endpoint : str
The class within the Eidos package to run, for instance
'apps.ExtractFromDirectory' will run
'org.clulab.wm.eidos.apps.ExtractFromDirectory'
*args
... | [
"def",
"run_eidos",
"(",
"endpoint",
",",
"*",
"args",
")",
":",
"# Make the full path to the class that should be used",
"call_class",
"=",
"'%s.%s'",
"%",
"(",
"eidos_package",
",",
"endpoint",
")",
"# Assemble the command line command and append optonal args",
"cmd",
"="... | Run a given enpoint of Eidos through the command line.
Parameters
----------
endpoint : str
The class within the Eidos package to run, for instance
'apps.ExtractFromDirectory' will run
'org.clulab.wm.eidos.apps.ExtractFromDirectory'
*args
Any further arguments to be pass... | [
"Run",
"a",
"given",
"enpoint",
"of",
"Eidos",
"through",
"the",
"command",
"line",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/cli.py#L20-L38 | train |
sorgerlab/indra | indra/sources/eidos/cli.py | extract_from_directory | def extract_from_directory(path_in, path_out):
"""Run Eidos on a set of text files in a folder.
The output is produced in the specified output folder but
the output files aren't processed by this function.
Parameters
----------
path_in : str
Path to an input folder with some text files... | python | def extract_from_directory(path_in, path_out):
"""Run Eidos on a set of text files in a folder.
The output is produced in the specified output folder but
the output files aren't processed by this function.
Parameters
----------
path_in : str
Path to an input folder with some text files... | [
"def",
"extract_from_directory",
"(",
"path_in",
",",
"path_out",
")",
":",
"path_in",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"path_in",
")",
")",
"path_out",
"=",
"os",
".",
"path",
".",
"realpath",
"(... | Run Eidos on a set of text files in a folder.
The output is produced in the specified output folder but
the output files aren't processed by this function.
Parameters
----------
path_in : str
Path to an input folder with some text files
path_out : str
Path to an output folder i... | [
"Run",
"Eidos",
"on",
"a",
"set",
"of",
"text",
"files",
"in",
"a",
"folder",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/cli.py#L41-L58 | train |
sorgerlab/indra | indra/sources/eidos/cli.py | extract_and_process | def extract_and_process(path_in, path_out):
"""Run Eidos on a set of text files and process output with INDRA.
The output is produced in the specified output folder but
the output files aren't processed by this function.
Parameters
----------
path_in : str
Path to an input folder with ... | python | def extract_and_process(path_in, path_out):
"""Run Eidos on a set of text files and process output with INDRA.
The output is produced in the specified output folder but
the output files aren't processed by this function.
Parameters
----------
path_in : str
Path to an input folder with ... | [
"def",
"extract_and_process",
"(",
"path_in",
",",
"path_out",
")",
":",
"path_in",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"path_in",
")",
")",
"path_out",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
... | Run Eidos on a set of text files and process output with INDRA.
The output is produced in the specified output folder but
the output files aren't processed by this function.
Parameters
----------
path_in : str
Path to an input folder with some text files
path_out : str
Path to ... | [
"Run",
"Eidos",
"on",
"a",
"set",
"of",
"text",
"files",
"and",
"process",
"output",
"with",
"INDRA",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/cli.py#L61-L91 | train |
sorgerlab/indra | indra/sources/indra_db_rest/api.py | get_statements | def get_statements(subject=None, object=None, agents=None, stmt_type=None,
use_exact_type=False, persist=True, timeout=None,
simple_response=False, ev_limit=10, best_first=True, tries=2,
max_stmts=None):
"""Get a processor for the INDRA DB web API matching gi... | python | def get_statements(subject=None, object=None, agents=None, stmt_type=None,
use_exact_type=False, persist=True, timeout=None,
simple_response=False, ev_limit=10, best_first=True, tries=2,
max_stmts=None):
"""Get a processor for the INDRA DB web API matching gi... | [
"def",
"get_statements",
"(",
"subject",
"=",
"None",
",",
"object",
"=",
"None",
",",
"agents",
"=",
"None",
",",
"stmt_type",
"=",
"None",
",",
"use_exact_type",
"=",
"False",
",",
"persist",
"=",
"True",
",",
"timeout",
"=",
"None",
",",
"simple_respo... | Get a processor for the INDRA DB web API matching given agents and type.
There are two types of responses available. You can just get a list of
INDRA Statements, or you can get an IndraDBRestProcessor object, which allow
Statements to be loaded in a background thread, providing a sample of the
best* co... | [
"Get",
"a",
"processor",
"for",
"the",
"INDRA",
"DB",
"web",
"API",
"matching",
"given",
"agents",
"and",
"type",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/indra_db_rest/api.py#L15-L116 | train |
sorgerlab/indra | indra/sources/indra_db_rest/api.py | get_statements_by_hash | def get_statements_by_hash(hash_list, ev_limit=100, best_first=True, tries=2):
"""Get fully formed statements from a list of hashes.
Parameters
----------
hash_list : list[int or str]
A list of statement hashes.
ev_limit : int or None
Limit the amount of evidence returned per Statem... | python | def get_statements_by_hash(hash_list, ev_limit=100, best_first=True, tries=2):
"""Get fully formed statements from a list of hashes.
Parameters
----------
hash_list : list[int or str]
A list of statement hashes.
ev_limit : int or None
Limit the amount of evidence returned per Statem... | [
"def",
"get_statements_by_hash",
"(",
"hash_list",
",",
"ev_limit",
"=",
"100",
",",
"best_first",
"=",
"True",
",",
"tries",
"=",
"2",
")",
":",
"if",
"not",
"isinstance",
"(",
"hash_list",
",",
"list",
")",
":",
"raise",
"ValueError",
"(",
"\"The `hash_l... | Get fully formed statements from a list of hashes.
Parameters
----------
hash_list : list[int or str]
A list of statement hashes.
ev_limit : int or None
Limit the amount of evidence returned per Statement. Default is 100.
best_first : bool
If True, the preassembled statement... | [
"Get",
"fully",
"formed",
"statements",
"from",
"a",
"list",
"of",
"hashes",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/indra_db_rest/api.py#L120-L154 | train |
sorgerlab/indra | indra/sources/indra_db_rest/api.py | get_statements_for_paper | def get_statements_for_paper(ids, ev_limit=10, best_first=True, tries=2,
max_stmts=None):
"""Get the set of raw Statements extracted from a paper given by the id.
Parameters
----------
ids : list[(<id type>, <id value>)]
A list of tuples with ids and their type. The... | python | def get_statements_for_paper(ids, ev_limit=10, best_first=True, tries=2,
max_stmts=None):
"""Get the set of raw Statements extracted from a paper given by the id.
Parameters
----------
ids : list[(<id type>, <id value>)]
A list of tuples with ids and their type. The... | [
"def",
"get_statements_for_paper",
"(",
"ids",
",",
"ev_limit",
"=",
"10",
",",
"best_first",
"=",
"True",
",",
"tries",
"=",
"2",
",",
"max_stmts",
"=",
"None",
")",
":",
"id_l",
"=",
"[",
"{",
"'id'",
":",
"id_val",
",",
"'type'",
":",
"id_type",
"... | Get the set of raw Statements extracted from a paper given by the id.
Parameters
----------
ids : list[(<id type>, <id value>)]
A list of tuples with ids and their type. The type can be any one of
'pmid', 'pmcid', 'doi', 'pii', 'manuscript id', or 'trid', which is the
primary key id... | [
"Get",
"the",
"set",
"of",
"raw",
"Statements",
"extracted",
"from",
"a",
"paper",
"given",
"by",
"the",
"id",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/indra_db_rest/api.py#L158-L194 | train |
sorgerlab/indra | indra/sources/indra_db_rest/api.py | submit_curation | def submit_curation(hash_val, tag, curator, text=None,
source='indra_rest_client', ev_hash=None, is_test=False):
"""Submit a curation for the given statement at the relevant level.
Parameters
----------
hash_val : int
The hash corresponding to the statement.
tag : str
... | python | def submit_curation(hash_val, tag, curator, text=None,
source='indra_rest_client', ev_hash=None, is_test=False):
"""Submit a curation for the given statement at the relevant level.
Parameters
----------
hash_val : int
The hash corresponding to the statement.
tag : str
... | [
"def",
"submit_curation",
"(",
"hash_val",
",",
"tag",
",",
"curator",
",",
"text",
"=",
"None",
",",
"source",
"=",
"'indra_rest_client'",
",",
"ev_hash",
"=",
"None",
",",
"is_test",
"=",
"False",
")",
":",
"data",
"=",
"{",
"'tag'",
":",
"tag",
",",... | Submit a curation for the given statement at the relevant level.
Parameters
----------
hash_val : int
The hash corresponding to the statement.
tag : str
A very short phrase categorizing the error or type of curation,
e.g. "grounding" for a grounding error, or "correct" if you ar... | [
"Submit",
"a",
"curation",
"for",
"the",
"given",
"statement",
"at",
"the",
"relevant",
"level",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/indra_db_rest/api.py#L197-L231 | train |
sorgerlab/indra | indra/sources/indra_db_rest/api.py | get_statement_queries | def get_statement_queries(stmts, **params):
"""Get queries used to search based on a statement.
In addition to the stmts, you can enter any parameters standard to the
query. See https://github.com/indralab/indra_db/rest_api for a full list.
Parameters
----------
stmts : list[Statement]
... | python | def get_statement_queries(stmts, **params):
"""Get queries used to search based on a statement.
In addition to the stmts, you can enter any parameters standard to the
query. See https://github.com/indralab/indra_db/rest_api for a full list.
Parameters
----------
stmts : list[Statement]
... | [
"def",
"get_statement_queries",
"(",
"stmts",
",",
"*",
"*",
"params",
")",
":",
"def",
"pick_ns",
"(",
"ag",
")",
":",
"for",
"ns",
"in",
"[",
"'HGNC'",
",",
"'FPLX'",
",",
"'CHEMBL'",
",",
"'CHEBI'",
",",
"'GO'",
",",
"'MESH'",
"]",
":",
"if",
"n... | Get queries used to search based on a statement.
In addition to the stmts, you can enter any parameters standard to the
query. See https://github.com/indralab/indra_db/rest_api for a full list.
Parameters
----------
stmts : list[Statement]
A list of INDRA statements. | [
"Get",
"queries",
"used",
"to",
"search",
"based",
"on",
"a",
"statement",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/indra_db_rest/api.py#L234-L274 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.