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/literature/pmc_client.py | filter_pmids | def filter_pmids(pmid_list, source_type):
"""Filter a list of PMIDs for ones with full text from PMC.
Parameters
----------
pmid_list : list of str
List of PMIDs to filter.
source_type : string
One of 'fulltext', 'oa_xml', 'oa_txt', or 'auth_xml'.
Returns
-------
list o... | python | def filter_pmids(pmid_list, source_type):
"""Filter a list of PMIDs for ones with full text from PMC.
Parameters
----------
pmid_list : list of str
List of PMIDs to filter.
source_type : string
One of 'fulltext', 'oa_xml', 'oa_txt', or 'auth_xml'.
Returns
-------
list o... | [
"def",
"filter_pmids",
"(",
"pmid_list",
",",
"source_type",
")",
":",
"global",
"pmids_fulltext_dict",
"if",
"source_type",
"not",
"in",
"(",
"'fulltext'",
",",
"'oa_xml'",
",",
"'oa_txt'",
",",
"'auth_xml'",
")",
":",
"raise",
"ValueError",
"(",
"\"source_type... | Filter a list of PMIDs for ones with full text from PMC.
Parameters
----------
pmid_list : list of str
List of PMIDs to filter.
source_type : string
One of 'fulltext', 'oa_xml', 'oa_txt', or 'auth_xml'.
Returns
-------
list of str
PMIDs available in the specified so... | [
"Filter",
"a",
"list",
"of",
"PMIDs",
"for",
"ones",
"with",
"full",
"text",
"from",
"PMC",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/pmc_client.py#L159-L188 | train |
sorgerlab/indra | indra/sources/cwms/util.py | get_example_extractions | def get_example_extractions(fname):
"Get extractions from one of the examples in `cag_examples`."
with open(fname, 'r') as f:
sentences = f.read().splitlines()
rdf_xml_dict = {}
for sentence in sentences:
logger.info("Reading \"%s\"..." % sentence)
html = tc.send_query(sentence, ... | python | def get_example_extractions(fname):
"Get extractions from one of the examples in `cag_examples`."
with open(fname, 'r') as f:
sentences = f.read().splitlines()
rdf_xml_dict = {}
for sentence in sentences:
logger.info("Reading \"%s\"..." % sentence)
html = tc.send_query(sentence, ... | [
"def",
"get_example_extractions",
"(",
"fname",
")",
":",
"\"Get extractions from one of the examples in `cag_examples`.\"",
"with",
"open",
"(",
"fname",
",",
"'r'",
")",
"as",
"f",
":",
"sentences",
"=",
"f",
".",
"read",
"(",
")",
".",
"splitlines",
"(",
")",... | Get extractions from one of the examples in `cag_examples`. | [
"Get",
"extractions",
"from",
"one",
"of",
"the",
"examples",
"in",
"cag_examples",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/cwms/util.py#L63-L77 | train |
sorgerlab/indra | indra/sources/cwms/util.py | make_example_graphs | def make_example_graphs():
"Make graphs from all the examples in cag_examples."
cag_example_rdfs = {}
for i, fname in enumerate(os.listdir('cag_examples')):
cag_example_rdfs[i+1] = get_example_extractions(fname)
return make_cag_graphs(cag_example_rdfs) | python | def make_example_graphs():
"Make graphs from all the examples in cag_examples."
cag_example_rdfs = {}
for i, fname in enumerate(os.listdir('cag_examples')):
cag_example_rdfs[i+1] = get_example_extractions(fname)
return make_cag_graphs(cag_example_rdfs) | [
"def",
"make_example_graphs",
"(",
")",
":",
"\"Make graphs from all the examples in cag_examples.\"",
"cag_example_rdfs",
"=",
"{",
"}",
"for",
"i",
",",
"fname",
"in",
"enumerate",
"(",
"os",
".",
"listdir",
"(",
"'cag_examples'",
")",
")",
":",
"cag_example_rdfs"... | Make graphs from all the examples in cag_examples. | [
"Make",
"graphs",
"from",
"all",
"the",
"examples",
"in",
"cag_examples",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/cwms/util.py#L80-L85 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _join_list | def _join_list(lst, oxford=False):
"""Join a list of words in a gramatically correct way."""
if len(lst) > 2:
s = ', '.join(lst[:-1])
if oxford:
s += ','
s += ' and ' + lst[-1]
elif len(lst) == 2:
s = lst[0] + ' and ' + lst[1]
elif len(lst) == 1:
s = l... | python | def _join_list(lst, oxford=False):
"""Join a list of words in a gramatically correct way."""
if len(lst) > 2:
s = ', '.join(lst[:-1])
if oxford:
s += ','
s += ' and ' + lst[-1]
elif len(lst) == 2:
s = lst[0] + ' and ' + lst[1]
elif len(lst) == 1:
s = l... | [
"def",
"_join_list",
"(",
"lst",
",",
"oxford",
"=",
"False",
")",
":",
"if",
"len",
"(",
"lst",
")",
">",
"2",
":",
"s",
"=",
"', '",
".",
"join",
"(",
"lst",
"[",
":",
"-",
"1",
"]",
")",
"if",
"oxford",
":",
"s",
"+=",
"','",
"s",
"+=",
... | Join a list of words in a gramatically correct way. | [
"Join",
"a",
"list",
"of",
"words",
"in",
"a",
"gramatically",
"correct",
"way",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L184-L197 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _assemble_activeform | def _assemble_activeform(stmt):
"""Assemble ActiveForm statements into text."""
subj_str = _assemble_agent_str(stmt.agent)
if stmt.is_active:
is_active_str = 'active'
else:
is_active_str = 'inactive'
if stmt.activity == 'activity':
stmt_str = subj_str + ' is ' + is_active_str... | python | def _assemble_activeform(stmt):
"""Assemble ActiveForm statements into text."""
subj_str = _assemble_agent_str(stmt.agent)
if stmt.is_active:
is_active_str = 'active'
else:
is_active_str = 'inactive'
if stmt.activity == 'activity':
stmt_str = subj_str + ' is ' + is_active_str... | [
"def",
"_assemble_activeform",
"(",
"stmt",
")",
":",
"subj_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"agent",
")",
"if",
"stmt",
".",
"is_active",
":",
"is_active_str",
"=",
"'active'",
"else",
":",
"is_active_str",
"=",
"'inactive'",
"if",
"stmt",
... | Assemble ActiveForm statements into text. | [
"Assemble",
"ActiveForm",
"statements",
"into",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L200-L219 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _assemble_modification | def _assemble_modification(stmt):
"""Assemble Modification statements into text."""
sub_str = _assemble_agent_str(stmt.sub)
if stmt.enz is not None:
enz_str = _assemble_agent_str(stmt.enz)
if _get_is_direct(stmt):
mod_str = ' ' + _mod_process_verb(stmt) + ' '
else:
... | python | def _assemble_modification(stmt):
"""Assemble Modification statements into text."""
sub_str = _assemble_agent_str(stmt.sub)
if stmt.enz is not None:
enz_str = _assemble_agent_str(stmt.enz)
if _get_is_direct(stmt):
mod_str = ' ' + _mod_process_verb(stmt) + ' '
else:
... | [
"def",
"_assemble_modification",
"(",
"stmt",
")",
":",
"sub_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"sub",
")",
"if",
"stmt",
".",
"enz",
"is",
"not",
"None",
":",
"enz_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"enz",
")",
"if",
"_... | Assemble Modification statements into text. | [
"Assemble",
"Modification",
"statements",
"into",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L222-L243 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _assemble_association | def _assemble_association(stmt):
"""Assemble Association statements into text."""
member_strs = [_assemble_agent_str(m.concept) for m in stmt.members]
stmt_str = member_strs[0] + ' is associated with ' + \
_join_list(member_strs[1:])
return _make_sentence(stmt_str) | python | def _assemble_association(stmt):
"""Assemble Association statements into text."""
member_strs = [_assemble_agent_str(m.concept) for m in stmt.members]
stmt_str = member_strs[0] + ' is associated with ' + \
_join_list(member_strs[1:])
return _make_sentence(stmt_str) | [
"def",
"_assemble_association",
"(",
"stmt",
")",
":",
"member_strs",
"=",
"[",
"_assemble_agent_str",
"(",
"m",
".",
"concept",
")",
"for",
"m",
"in",
"stmt",
".",
"members",
"]",
"stmt_str",
"=",
"member_strs",
"[",
"0",
"]",
"+",
"' is associated with '",... | Assemble Association statements into text. | [
"Assemble",
"Association",
"statements",
"into",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L246-L251 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _assemble_complex | def _assemble_complex(stmt):
"""Assemble Complex statements into text."""
member_strs = [_assemble_agent_str(m) for m in stmt.members]
stmt_str = member_strs[0] + ' binds ' + _join_list(member_strs[1:])
return _make_sentence(stmt_str) | python | def _assemble_complex(stmt):
"""Assemble Complex statements into text."""
member_strs = [_assemble_agent_str(m) for m in stmt.members]
stmt_str = member_strs[0] + ' binds ' + _join_list(member_strs[1:])
return _make_sentence(stmt_str) | [
"def",
"_assemble_complex",
"(",
"stmt",
")",
":",
"member_strs",
"=",
"[",
"_assemble_agent_str",
"(",
"m",
")",
"for",
"m",
"in",
"stmt",
".",
"members",
"]",
"stmt_str",
"=",
"member_strs",
"[",
"0",
"]",
"+",
"' binds '",
"+",
"_join_list",
"(",
"mem... | Assemble Complex statements into text. | [
"Assemble",
"Complex",
"statements",
"into",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L254-L258 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _assemble_autophosphorylation | def _assemble_autophosphorylation(stmt):
"""Assemble Autophosphorylation statements into text."""
enz_str = _assemble_agent_str(stmt.enz)
stmt_str = enz_str + ' phosphorylates itself'
if stmt.residue is not None:
if stmt.position is None:
mod_str = 'on ' + ist.amino_acids[stmt.residu... | python | def _assemble_autophosphorylation(stmt):
"""Assemble Autophosphorylation statements into text."""
enz_str = _assemble_agent_str(stmt.enz)
stmt_str = enz_str + ' phosphorylates itself'
if stmt.residue is not None:
if stmt.position is None:
mod_str = 'on ' + ist.amino_acids[stmt.residu... | [
"def",
"_assemble_autophosphorylation",
"(",
"stmt",
")",
":",
"enz_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"enz",
")",
"stmt_str",
"=",
"enz_str",
"+",
"' phosphorylates itself'",
"if",
"stmt",
".",
"residue",
"is",
"not",
"None",
":",
"if",
"stmt... | Assemble Autophosphorylation statements into text. | [
"Assemble",
"Autophosphorylation",
"statements",
"into",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L261-L273 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _assemble_regulate_activity | def _assemble_regulate_activity(stmt):
"""Assemble RegulateActivity statements into text."""
subj_str = _assemble_agent_str(stmt.subj)
obj_str = _assemble_agent_str(stmt.obj)
if stmt.is_activation:
rel_str = ' activates '
else:
rel_str = ' inhibits '
stmt_str = subj_str + rel_str... | python | def _assemble_regulate_activity(stmt):
"""Assemble RegulateActivity statements into text."""
subj_str = _assemble_agent_str(stmt.subj)
obj_str = _assemble_agent_str(stmt.obj)
if stmt.is_activation:
rel_str = ' activates '
else:
rel_str = ' inhibits '
stmt_str = subj_str + rel_str... | [
"def",
"_assemble_regulate_activity",
"(",
"stmt",
")",
":",
"subj_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"subj",
")",
"obj_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"obj",
")",
"if",
"stmt",
".",
"is_activation",
":",
"rel_str",
"=",
... | Assemble RegulateActivity statements into text. | [
"Assemble",
"RegulateActivity",
"statements",
"into",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L276-L285 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _assemble_regulate_amount | def _assemble_regulate_amount(stmt):
"""Assemble RegulateAmount statements into text."""
obj_str = _assemble_agent_str(stmt.obj)
if stmt.subj is not None:
subj_str = _assemble_agent_str(stmt.subj)
if isinstance(stmt, ist.IncreaseAmount):
rel_str = ' increases the amount of '
... | python | def _assemble_regulate_amount(stmt):
"""Assemble RegulateAmount statements into text."""
obj_str = _assemble_agent_str(stmt.obj)
if stmt.subj is not None:
subj_str = _assemble_agent_str(stmt.subj)
if isinstance(stmt, ist.IncreaseAmount):
rel_str = ' increases the amount of '
... | [
"def",
"_assemble_regulate_amount",
"(",
"stmt",
")",
":",
"obj_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"obj",
")",
"if",
"stmt",
".",
"subj",
"is",
"not",
"None",
":",
"subj_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"subj",
")",
"if"... | Assemble RegulateAmount statements into text. | [
"Assemble",
"RegulateAmount",
"statements",
"into",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L288-L303 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _assemble_translocation | def _assemble_translocation(stmt):
"""Assemble Translocation statements into text."""
agent_str = _assemble_agent_str(stmt.agent)
stmt_str = agent_str + ' translocates'
if stmt.from_location is not None:
stmt_str += ' from the ' + stmt.from_location
if stmt.to_location is not None:
s... | python | def _assemble_translocation(stmt):
"""Assemble Translocation statements into text."""
agent_str = _assemble_agent_str(stmt.agent)
stmt_str = agent_str + ' translocates'
if stmt.from_location is not None:
stmt_str += ' from the ' + stmt.from_location
if stmt.to_location is not None:
s... | [
"def",
"_assemble_translocation",
"(",
"stmt",
")",
":",
"agent_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"agent",
")",
"stmt_str",
"=",
"agent_str",
"+",
"' translocates'",
"if",
"stmt",
".",
"from_location",
"is",
"not",
"None",
":",
"stmt_str",
"+... | Assemble Translocation statements into text. | [
"Assemble",
"Translocation",
"statements",
"into",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L306-L314 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _assemble_gap | def _assemble_gap(stmt):
"""Assemble Gap statements into text."""
subj_str = _assemble_agent_str(stmt.gap)
obj_str = _assemble_agent_str(stmt.ras)
stmt_str = subj_str + ' is a GAP for ' + obj_str
return _make_sentence(stmt_str) | python | def _assemble_gap(stmt):
"""Assemble Gap statements into text."""
subj_str = _assemble_agent_str(stmt.gap)
obj_str = _assemble_agent_str(stmt.ras)
stmt_str = subj_str + ' is a GAP for ' + obj_str
return _make_sentence(stmt_str) | [
"def",
"_assemble_gap",
"(",
"stmt",
")",
":",
"subj_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"gap",
")",
"obj_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"ras",
")",
"stmt_str",
"=",
"subj_str",
"+",
"' is a GAP for '",
"+",
"obj_str",
"r... | Assemble Gap statements into text. | [
"Assemble",
"Gap",
"statements",
"into",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L317-L322 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _assemble_gef | def _assemble_gef(stmt):
"""Assemble Gef statements into text."""
subj_str = _assemble_agent_str(stmt.gef)
obj_str = _assemble_agent_str(stmt.ras)
stmt_str = subj_str + ' is a GEF for ' + obj_str
return _make_sentence(stmt_str) | python | def _assemble_gef(stmt):
"""Assemble Gef statements into text."""
subj_str = _assemble_agent_str(stmt.gef)
obj_str = _assemble_agent_str(stmt.ras)
stmt_str = subj_str + ' is a GEF for ' + obj_str
return _make_sentence(stmt_str) | [
"def",
"_assemble_gef",
"(",
"stmt",
")",
":",
"subj_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"gef",
")",
"obj_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"ras",
")",
"stmt_str",
"=",
"subj_str",
"+",
"' is a GEF for '",
"+",
"obj_str",
"r... | Assemble Gef statements into text. | [
"Assemble",
"Gef",
"statements",
"into",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L325-L330 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _assemble_conversion | def _assemble_conversion(stmt):
"""Assemble a Conversion statement into text."""
reactants = _join_list([_assemble_agent_str(r) for r in stmt.obj_from])
products = _join_list([_assemble_agent_str(r) for r in stmt.obj_to])
if stmt.subj is not None:
subj_str = _assemble_agent_str(stmt.subj)
... | python | def _assemble_conversion(stmt):
"""Assemble a Conversion statement into text."""
reactants = _join_list([_assemble_agent_str(r) for r in stmt.obj_from])
products = _join_list([_assemble_agent_str(r) for r in stmt.obj_to])
if stmt.subj is not None:
subj_str = _assemble_agent_str(stmt.subj)
... | [
"def",
"_assemble_conversion",
"(",
"stmt",
")",
":",
"reactants",
"=",
"_join_list",
"(",
"[",
"_assemble_agent_str",
"(",
"r",
")",
"for",
"r",
"in",
"stmt",
".",
"obj_from",
"]",
")",
"products",
"=",
"_join_list",
"(",
"[",
"_assemble_agent_str",
"(",
... | Assemble a Conversion statement into text. | [
"Assemble",
"a",
"Conversion",
"statement",
"into",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L333-L344 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _assemble_influence | def _assemble_influence(stmt):
"""Assemble an Influence statement into text."""
subj_str = _assemble_agent_str(stmt.subj.concept)
obj_str = _assemble_agent_str(stmt.obj.concept)
# Note that n is prepended to increase to make it "an increase"
if stmt.subj.delta['polarity'] is not None:
subj_... | python | def _assemble_influence(stmt):
"""Assemble an Influence statement into text."""
subj_str = _assemble_agent_str(stmt.subj.concept)
obj_str = _assemble_agent_str(stmt.obj.concept)
# Note that n is prepended to increase to make it "an increase"
if stmt.subj.delta['polarity'] is not None:
subj_... | [
"def",
"_assemble_influence",
"(",
"stmt",
")",
":",
"subj_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"subj",
".",
"concept",
")",
"obj_str",
"=",
"_assemble_agent_str",
"(",
"stmt",
".",
"obj",
".",
"concept",
")",
"if",
"stmt",
".",
"subj",
".",... | Assemble an Influence statement into text. | [
"Assemble",
"an",
"Influence",
"statement",
"into",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L347-L364 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _make_sentence | def _make_sentence(txt):
"""Make a sentence from a piece of text."""
#Make sure first letter is capitalized
txt = txt.strip(' ')
txt = txt[0].upper() + txt[1:] + '.'
return txt | python | def _make_sentence(txt):
"""Make a sentence from a piece of text."""
#Make sure first letter is capitalized
txt = txt.strip(' ')
txt = txt[0].upper() + txt[1:] + '.'
return txt | [
"def",
"_make_sentence",
"(",
"txt",
")",
":",
"txt",
"=",
"txt",
".",
"strip",
"(",
"' '",
")",
"txt",
"=",
"txt",
"[",
"0",
"]",
".",
"upper",
"(",
")",
"+",
"txt",
"[",
"1",
":",
"]",
"+",
"'.'",
"return",
"txt"
] | Make a sentence from a piece of text. | [
"Make",
"a",
"sentence",
"from",
"a",
"piece",
"of",
"text",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L367-L372 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | _get_is_hypothesis | def _get_is_hypothesis(stmt):
'''Returns true if there is evidence that the statement is only
hypothetical. If all of the evidences associated with the statement
indicate a hypothetical interaction then we assume the interaction
is hypothetical.'''
for ev in stmt.evidence:
if not ev.epistemi... | python | def _get_is_hypothesis(stmt):
'''Returns true if there is evidence that the statement is only
hypothetical. If all of the evidences associated with the statement
indicate a hypothetical interaction then we assume the interaction
is hypothetical.'''
for ev in stmt.evidence:
if not ev.epistemi... | [
"def",
"_get_is_hypothesis",
"(",
"stmt",
")",
":",
"for",
"ev",
"in",
"stmt",
".",
"evidence",
":",
"if",
"not",
"ev",
".",
"epistemics",
".",
"get",
"(",
"'hypothesis'",
")",
"is",
"True",
":",
"return",
"True",
"return",
"False"
] | Returns true if there is evidence that the statement is only
hypothetical. If all of the evidences associated with the statement
indicate a hypothetical interaction then we assume the interaction
is hypothetical. | [
"Returns",
"true",
"if",
"there",
"is",
"evidence",
"that",
"the",
"statement",
"is",
"only",
"hypothetical",
".",
"If",
"all",
"of",
"the",
"evidences",
"associated",
"with",
"the",
"statement",
"indicate",
"a",
"hypothetical",
"interaction",
"then",
"we",
"a... | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L394-L402 | train |
sorgerlab/indra | indra/assemblers/english/assembler.py | EnglishAssembler.make_model | def make_model(self):
"""Assemble text from the set of collected INDRA Statements.
Returns
-------
stmt_strs : str
Return the assembled text as unicode string. By default, the text
is a single string consisting of one or more sentences with
periods at... | python | def make_model(self):
"""Assemble text from the set of collected INDRA Statements.
Returns
-------
stmt_strs : str
Return the assembled text as unicode string. By default, the text
is a single string consisting of one or more sentences with
periods at... | [
"def",
"make_model",
"(",
"self",
")",
":",
"stmt_strs",
"=",
"[",
"]",
"for",
"stmt",
"in",
"self",
".",
"statements",
":",
"if",
"isinstance",
"(",
"stmt",
",",
"ist",
".",
"Modification",
")",
":",
"stmt_strs",
".",
"append",
"(",
"_assemble_modificat... | Assemble text from the set of collected INDRA Statements.
Returns
-------
stmt_strs : str
Return the assembled text as unicode string. By default, the text
is a single string consisting of one or more sentences with
periods at the end. | [
"Assemble",
"text",
"from",
"the",
"set",
"of",
"collected",
"INDRA",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L41-L82 | train |
sorgerlab/indra | indra/assemblers/sbgn/assembler.py | SBGNAssembler.add_statements | def add_statements(self, stmts):
"""Add INDRA Statements to the assembler's list of statements.
Parameters
----------
stmts : list[indra.statements.Statement]
A list of :py:class:`indra.statements.Statement`
to be added to the statement list of the assembler.
... | python | def add_statements(self, stmts):
"""Add INDRA Statements to the assembler's list of statements.
Parameters
----------
stmts : list[indra.statements.Statement]
A list of :py:class:`indra.statements.Statement`
to be added to the statement list of the assembler.
... | [
"def",
"add_statements",
"(",
"self",
",",
"stmts",
")",
":",
"for",
"stmt",
"in",
"stmts",
":",
"if",
"not",
"self",
".",
"statement_exists",
"(",
"stmt",
")",
":",
"self",
".",
"statements",
".",
"append",
"(",
"stmt",
")"
] | Add INDRA Statements to the assembler's list of statements.
Parameters
----------
stmts : list[indra.statements.Statement]
A list of :py:class:`indra.statements.Statement`
to be added to the statement list of the assembler. | [
"Add",
"INDRA",
"Statements",
"to",
"the",
"assembler",
"s",
"list",
"of",
"statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L58-L69 | train |
sorgerlab/indra | indra/assemblers/sbgn/assembler.py | SBGNAssembler.make_model | def make_model(self):
"""Assemble the SBGN model from the collected INDRA Statements.
This method assembles an SBGN model from the set of INDRA Statements.
The assembled model is set as the assembler's sbgn attribute (it is
represented as an XML ElementTree internally). The model is ret... | python | def make_model(self):
"""Assemble the SBGN model from the collected INDRA Statements.
This method assembles an SBGN model from the set of INDRA Statements.
The assembled model is set as the assembler's sbgn attribute (it is
represented as an XML ElementTree internally). The model is ret... | [
"def",
"make_model",
"(",
"self",
")",
":",
"ppa",
"=",
"PysbPreassembler",
"(",
"self",
".",
"statements",
")",
"ppa",
".",
"replace_activities",
"(",
")",
"self",
".",
"statements",
"=",
"ppa",
".",
"statements",
"self",
".",
"sbgn",
"=",
"emaker",
"."... | Assemble the SBGN model from the collected INDRA Statements.
This method assembles an SBGN model from the set of INDRA Statements.
The assembled model is set as the assembler's sbgn attribute (it is
represented as an XML ElementTree internally). The model is returned
as a serialized XML... | [
"Assemble",
"the",
"SBGN",
"model",
"from",
"the",
"collected",
"INDRA",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L71-L106 | train |
sorgerlab/indra | indra/assemblers/sbgn/assembler.py | SBGNAssembler.print_model | def print_model(self, pretty=True, encoding='utf8'):
"""Return the assembled SBGN model as an XML string.
Parameters
----------
pretty : Optional[bool]
If True, the SBGN string is formatted with indentation (for human
viewing) otherwise no indentation is used. De... | python | def print_model(self, pretty=True, encoding='utf8'):
"""Return the assembled SBGN model as an XML string.
Parameters
----------
pretty : Optional[bool]
If True, the SBGN string is formatted with indentation (for human
viewing) otherwise no indentation is used. De... | [
"def",
"print_model",
"(",
"self",
",",
"pretty",
"=",
"True",
",",
"encoding",
"=",
"'utf8'",
")",
":",
"return",
"lxml",
".",
"etree",
".",
"tostring",
"(",
"self",
".",
"sbgn",
",",
"pretty_print",
"=",
"pretty",
",",
"encoding",
"=",
"encoding",
",... | Return the assembled SBGN model as an XML string.
Parameters
----------
pretty : Optional[bool]
If True, the SBGN string is formatted with indentation (for human
viewing) otherwise no indentation is used. Default: True
Returns
-------
sbgn_str : ... | [
"Return",
"the",
"assembled",
"SBGN",
"model",
"as",
"an",
"XML",
"string",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L108-L123 | train |
sorgerlab/indra | indra/assemblers/sbgn/assembler.py | SBGNAssembler.save_model | def save_model(self, file_name='model.sbgn'):
"""Save the assembled SBGN model in a file.
Parameters
----------
file_name : Optional[str]
The name of the file to save the SBGN network to.
Default: model.sbgn
"""
model = self.print_model()
... | python | def save_model(self, file_name='model.sbgn'):
"""Save the assembled SBGN model in a file.
Parameters
----------
file_name : Optional[str]
The name of the file to save the SBGN network to.
Default: model.sbgn
"""
model = self.print_model()
... | [
"def",
"save_model",
"(",
"self",
",",
"file_name",
"=",
"'model.sbgn'",
")",
":",
"model",
"=",
"self",
".",
"print_model",
"(",
")",
"with",
"open",
"(",
"file_name",
",",
"'wb'",
")",
"as",
"fh",
":",
"fh",
".",
"write",
"(",
"model",
")"
] | Save the assembled SBGN model in a file.
Parameters
----------
file_name : Optional[str]
The name of the file to save the SBGN network to.
Default: model.sbgn | [
"Save",
"the",
"assembled",
"SBGN",
"model",
"in",
"a",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L125-L136 | train |
sorgerlab/indra | indra/assemblers/sbgn/assembler.py | SBGNAssembler._glyph_for_complex_pattern | def _glyph_for_complex_pattern(self, pattern):
"""Add glyph and member glyphs for a PySB ComplexPattern."""
# Make the main glyph for the agent
monomer_glyphs = []
for monomer_pattern in pattern.monomer_patterns:
glyph = self._glyph_for_monomer_pattern(monomer_pattern)
... | python | def _glyph_for_complex_pattern(self, pattern):
"""Add glyph and member glyphs for a PySB ComplexPattern."""
# Make the main glyph for the agent
monomer_glyphs = []
for monomer_pattern in pattern.monomer_patterns:
glyph = self._glyph_for_monomer_pattern(monomer_pattern)
... | [
"def",
"_glyph_for_complex_pattern",
"(",
"self",
",",
"pattern",
")",
":",
"monomer_glyphs",
"=",
"[",
"]",
"for",
"monomer_pattern",
"in",
"pattern",
".",
"monomer_patterns",
":",
"glyph",
"=",
"self",
".",
"_glyph_for_monomer_pattern",
"(",
"monomer_pattern",
"... | Add glyph and member glyphs for a PySB ComplexPattern. | [
"Add",
"glyph",
"and",
"member",
"glyphs",
"for",
"a",
"PySB",
"ComplexPattern",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L317-L335 | train |
sorgerlab/indra | indra/assemblers/sbgn/assembler.py | SBGNAssembler._glyph_for_monomer_pattern | def _glyph_for_monomer_pattern(self, pattern):
"""Add glyph for a PySB MonomerPattern."""
pattern.matches_key = lambda: str(pattern)
agent_id = self._make_agent_id(pattern)
# Handle sources and sinks
if pattern.monomer.name in ('__source', '__sink'):
return None
... | python | def _glyph_for_monomer_pattern(self, pattern):
"""Add glyph for a PySB MonomerPattern."""
pattern.matches_key = lambda: str(pattern)
agent_id = self._make_agent_id(pattern)
# Handle sources and sinks
if pattern.monomer.name in ('__source', '__sink'):
return None
... | [
"def",
"_glyph_for_monomer_pattern",
"(",
"self",
",",
"pattern",
")",
":",
"pattern",
".",
"matches_key",
"=",
"lambda",
":",
"str",
"(",
"pattern",
")",
"agent_id",
"=",
"self",
".",
"_make_agent_id",
"(",
"pattern",
")",
"if",
"pattern",
".",
"monomer",
... | Add glyph for a PySB MonomerPattern. | [
"Add",
"glyph",
"for",
"a",
"PySB",
"MonomerPattern",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L337-L372 | train |
sorgerlab/indra | indra/databases/go_client.py | load_go_graph | def load_go_graph(go_fname):
"""Load the GO data from an OWL file and parse into an RDF graph.
Parameters
----------
go_fname : str
Path to the GO OWL file. Can be downloaded from
http://geneontology.org/ontology/go.owl.
Returns
-------
rdflib.Graph
RDF graph contai... | python | def load_go_graph(go_fname):
"""Load the GO data from an OWL file and parse into an RDF graph.
Parameters
----------
go_fname : str
Path to the GO OWL file. Can be downloaded from
http://geneontology.org/ontology/go.owl.
Returns
-------
rdflib.Graph
RDF graph contai... | [
"def",
"load_go_graph",
"(",
"go_fname",
")",
":",
"global",
"_go_graph",
"if",
"_go_graph",
"is",
"None",
":",
"_go_graph",
"=",
"rdflib",
".",
"Graph",
"(",
")",
"logger",
".",
"info",
"(",
"\"Parsing GO OWL file\"",
")",
"_go_graph",
".",
"parse",
"(",
... | Load the GO data from an OWL file and parse into an RDF graph.
Parameters
----------
go_fname : str
Path to the GO OWL file. Can be downloaded from
http://geneontology.org/ontology/go.owl.
Returns
-------
rdflib.Graph
RDF graph containing GO data. | [
"Load",
"the",
"GO",
"data",
"from",
"an",
"OWL",
"file",
"and",
"parse",
"into",
"an",
"RDF",
"graph",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/go_client.py#L41-L60 | train |
sorgerlab/indra | indra/databases/go_client.py | update_id_mappings | def update_id_mappings(g):
"""Compile all ID->label mappings and save to a TSV file.
Parameters
----------
g : rdflib.Graph
RDF graph containing GO data.
"""
g = load_go_graph(go_owl_path)
query = _prefixes + """
SELECT ?id ?label
WHERE {
?class oboInOwl... | python | def update_id_mappings(g):
"""Compile all ID->label mappings and save to a TSV file.
Parameters
----------
g : rdflib.Graph
RDF graph containing GO data.
"""
g = load_go_graph(go_owl_path)
query = _prefixes + """
SELECT ?id ?label
WHERE {
?class oboInOwl... | [
"def",
"update_id_mappings",
"(",
"g",
")",
":",
"g",
"=",
"load_go_graph",
"(",
"go_owl_path",
")",
"query",
"=",
"_prefixes",
"+",
"logger",
".",
"info",
"(",
"\"Querying for GO ID mappings\"",
")",
"res",
"=",
"g",
".",
"query",
"(",
"query",
")",
"mapp... | Compile all ID->label mappings and save to a TSV file.
Parameters
----------
g : rdflib.Graph
RDF graph containing GO data. | [
"Compile",
"all",
"ID",
"-",
">",
"label",
"mappings",
"and",
"save",
"to",
"a",
"TSV",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/go_client.py#L80-L103 | train |
sorgerlab/indra | indra/databases/ndex_client.py | get_default_ndex_cred | def get_default_ndex_cred(ndex_cred):
"""Gets the NDEx credentials from the dict, or tries the environment if None"""
if ndex_cred:
username = ndex_cred.get('user')
password = ndex_cred.get('password')
if username is not None and password is not None:
return username, passwo... | python | def get_default_ndex_cred(ndex_cred):
"""Gets the NDEx credentials from the dict, or tries the environment if None"""
if ndex_cred:
username = ndex_cred.get('user')
password = ndex_cred.get('password')
if username is not None and password is not None:
return username, passwo... | [
"def",
"get_default_ndex_cred",
"(",
"ndex_cred",
")",
":",
"if",
"ndex_cred",
":",
"username",
"=",
"ndex_cred",
".",
"get",
"(",
"'user'",
")",
"password",
"=",
"ndex_cred",
".",
"get",
"(",
"'password'",
")",
"if",
"username",
"is",
"not",
"None",
"and"... | Gets the NDEx credentials from the dict, or tries the environment if None | [
"Gets",
"the",
"NDEx",
"credentials",
"from",
"the",
"dict",
"or",
"tries",
"the",
"environment",
"if",
"None"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/ndex_client.py#L17-L29 | train |
sorgerlab/indra | indra/databases/ndex_client.py | send_request | def send_request(ndex_service_url, params, is_json=True, use_get=False):
"""Send a request to the NDEx server.
Parameters
----------
ndex_service_url : str
The URL of the service to use for the request.
params : dict
A dictionary of parameters to send with the request. Parameter key... | python | def send_request(ndex_service_url, params, is_json=True, use_get=False):
"""Send a request to the NDEx server.
Parameters
----------
ndex_service_url : str
The URL of the service to use for the request.
params : dict
A dictionary of parameters to send with the request. Parameter key... | [
"def",
"send_request",
"(",
"ndex_service_url",
",",
"params",
",",
"is_json",
"=",
"True",
",",
"use_get",
"=",
"False",
")",
":",
"if",
"use_get",
":",
"res",
"=",
"requests",
".",
"get",
"(",
"ndex_service_url",
",",
"json",
"=",
"params",
")",
"else"... | Send a request to the NDEx server.
Parameters
----------
ndex_service_url : str
The URL of the service to use for the request.
params : dict
A dictionary of parameters to send with the request. Parameter keys
differ based on the type of request.
is_json : bool
True i... | [
"Send",
"a",
"request",
"to",
"the",
"NDEx",
"server",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/ndex_client.py#L32-L89 | train |
sorgerlab/indra | indra/databases/ndex_client.py | update_network | def update_network(cx_str, network_id, ndex_cred=None):
"""Update an existing CX network on NDEx with new CX content.
Parameters
----------
cx_str : str
String containing the CX content.
network_id : str
UUID of the network on NDEx.
ndex_cred : dict
A dictionary with the... | python | def update_network(cx_str, network_id, ndex_cred=None):
"""Update an existing CX network on NDEx with new CX content.
Parameters
----------
cx_str : str
String containing the CX content.
network_id : str
UUID of the network on NDEx.
ndex_cred : dict
A dictionary with the... | [
"def",
"update_network",
"(",
"cx_str",
",",
"network_id",
",",
"ndex_cred",
"=",
"None",
")",
":",
"server",
"=",
"'http://public.ndexbio.org'",
"username",
",",
"password",
"=",
"get_default_ndex_cred",
"(",
"ndex_cred",
")",
"nd",
"=",
"ndex2",
".",
"client",... | Update an existing CX network on NDEx with new CX content.
Parameters
----------
cx_str : str
String containing the CX content.
network_id : str
UUID of the network on NDEx.
ndex_cred : dict
A dictionary with the following entries:
'user': NDEx user name
'pas... | [
"Update",
"an",
"existing",
"CX",
"network",
"on",
"NDEx",
"with",
"new",
"CX",
"content",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/ndex_client.py#L134-L189 | train |
sorgerlab/indra | indra/databases/ndex_client.py | set_style | def set_style(network_id, ndex_cred=None, template_id=None):
"""Set the style of the network to a given template network's style
Parameters
----------
network_id : str
The UUID of the NDEx network whose style is to be changed.
ndex_cred : dict
A dictionary of NDEx credentials.
t... | python | def set_style(network_id, ndex_cred=None, template_id=None):
"""Set the style of the network to a given template network's style
Parameters
----------
network_id : str
The UUID of the NDEx network whose style is to be changed.
ndex_cred : dict
A dictionary of NDEx credentials.
t... | [
"def",
"set_style",
"(",
"network_id",
",",
"ndex_cred",
"=",
"None",
",",
"template_id",
"=",
"None",
")",
":",
"if",
"not",
"template_id",
":",
"template_id",
"=",
"\"ea4ea3b7-6903-11e7-961c-0ac135e8bacf\"",
"server",
"=",
"'http://public.ndexbio.org'",
"username",
... | Set the style of the network to a given template network's style
Parameters
----------
network_id : str
The UUID of the NDEx network whose style is to be changed.
ndex_cred : dict
A dictionary of NDEx credentials.
template_id : Optional[str]
The UUID of the NDEx network whos... | [
"Set",
"the",
"style",
"of",
"the",
"network",
"to",
"a",
"given",
"template",
"network",
"s",
"style"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/ndex_client.py#L192-L219 | train |
sorgerlab/indra | indra/assemblers/pysb/bmi_wrapper.py | BMIModel.initialize | def initialize(self, cfg_file=None, mode=None):
"""Initialize the model for simulation, possibly given a config file.
Parameters
----------
cfg_file : Optional[str]
The name of the configuration file to load, optional.
"""
self.sim = ScipyOdeSimulator(self.mo... | python | def initialize(self, cfg_file=None, mode=None):
"""Initialize the model for simulation, possibly given a config file.
Parameters
----------
cfg_file : Optional[str]
The name of the configuration file to load, optional.
"""
self.sim = ScipyOdeSimulator(self.mo... | [
"def",
"initialize",
"(",
"self",
",",
"cfg_file",
"=",
"None",
",",
"mode",
"=",
"None",
")",
":",
"self",
".",
"sim",
"=",
"ScipyOdeSimulator",
"(",
"self",
".",
"model",
")",
"self",
".",
"state",
"=",
"numpy",
".",
"array",
"(",
"copy",
".",
"c... | Initialize the model for simulation, possibly given a config file.
Parameters
----------
cfg_file : Optional[str]
The name of the configuration file to load, optional. | [
"Initialize",
"the",
"model",
"for",
"simulation",
"possibly",
"given",
"a",
"config",
"file",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L74-L85 | train |
sorgerlab/indra | indra/assemblers/pysb/bmi_wrapper.py | BMIModel.update | def update(self, dt=None):
"""Simulate the model for a given time interval.
Parameters
----------
dt : Optional[float]
The time step to simulate, if None, the default built-in time step
is used.
"""
# EMELI passes dt = -1 so we need to handle that... | python | def update(self, dt=None):
"""Simulate the model for a given time interval.
Parameters
----------
dt : Optional[float]
The time step to simulate, if None, the default built-in time step
is used.
"""
# EMELI passes dt = -1 so we need to handle that... | [
"def",
"update",
"(",
"self",
",",
"dt",
"=",
"None",
")",
":",
"dt",
"=",
"dt",
"if",
"(",
"dt",
"is",
"not",
"None",
"and",
"dt",
">",
"0",
")",
"else",
"self",
".",
"dt",
"tspan",
"=",
"[",
"0",
",",
"dt",
"]",
"res",
"=",
"self",
".",
... | Simulate the model for a given time interval.
Parameters
----------
dt : Optional[float]
The time step to simulate, if None, the default built-in time step
is used. | [
"Simulate",
"the",
"model",
"for",
"a",
"given",
"time",
"interval",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L87-L107 | train |
sorgerlab/indra | indra/assemblers/pysb/bmi_wrapper.py | BMIModel.set_value | def set_value(self, var_name, value):
"""Set the value of a given variable to a given value.
Parameters
----------
var_name : str
The name of the variable in the model whose value should be set.
value : float
The value the variable should be set to
... | python | def set_value(self, var_name, value):
"""Set the value of a given variable to a given value.
Parameters
----------
var_name : str
The name of the variable in the model whose value should be set.
value : float
The value the variable should be set to
... | [
"def",
"set_value",
"(",
"self",
",",
"var_name",
",",
"value",
")",
":",
"if",
"var_name",
"in",
"self",
".",
"outside_name_map",
":",
"var_name",
"=",
"self",
".",
"outside_name_map",
"[",
"var_name",
"]",
"print",
"(",
"'%s=%.5f'",
"%",
"(",
"var_name",... | Set the value of a given variable to a given value.
Parameters
----------
var_name : str
The name of the variable in the model whose value should be set.
value : float
The value the variable should be set to | [
"Set",
"the",
"value",
"of",
"a",
"given",
"variable",
"to",
"a",
"given",
"value",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L114-L131 | train |
sorgerlab/indra | indra/assemblers/pysb/bmi_wrapper.py | BMIModel.get_value | def get_value(self, var_name):
"""Return the value of a given variable.
Parameters
----------
var_name : str
The name of the variable whose value should be returned
Returns
-------
value : float
The value of the given variable in the curr... | python | def get_value(self, var_name):
"""Return the value of a given variable.
Parameters
----------
var_name : str
The name of the variable whose value should be returned
Returns
-------
value : float
The value of the given variable in the curr... | [
"def",
"get_value",
"(",
"self",
",",
"var_name",
")",
":",
"if",
"var_name",
"in",
"self",
".",
"outside_name_map",
":",
"var_name",
"=",
"self",
".",
"outside_name_map",
"[",
"var_name",
"]",
"species_idx",
"=",
"self",
".",
"species_name_map",
"[",
"var_n... | Return the value of a given variable.
Parameters
----------
var_name : str
The name of the variable whose value should be returned
Returns
-------
value : float
The value of the given variable in the current state | [
"Return",
"the",
"value",
"of",
"a",
"given",
"variable",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L147-L163 | train |
sorgerlab/indra | indra/assemblers/pysb/bmi_wrapper.py | BMIModel.get_input_var_names | def get_input_var_names(self):
"""Return a list of variables names that can be set as input.
Returns
-------
var_names : list[str]
A list of variable names that can be set from the outside
"""
in_vars = copy.copy(self.input_vars)
for idx, var in enume... | python | def get_input_var_names(self):
"""Return a list of variables names that can be set as input.
Returns
-------
var_names : list[str]
A list of variable names that can be set from the outside
"""
in_vars = copy.copy(self.input_vars)
for idx, var in enume... | [
"def",
"get_input_var_names",
"(",
"self",
")",
":",
"in_vars",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"input_vars",
")",
"for",
"idx",
",",
"var",
"in",
"enumerate",
"(",
"in_vars",
")",
":",
"if",
"self",
".",
"_map_in_out",
"(",
"var",
")",
"... | Return a list of variables names that can be set as input.
Returns
-------
var_names : list[str]
A list of variable names that can be set from the outside | [
"Return",
"a",
"list",
"of",
"variables",
"names",
"that",
"can",
"be",
"set",
"as",
"input",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L203-L215 | train |
sorgerlab/indra | indra/assemblers/pysb/bmi_wrapper.py | BMIModel.get_output_var_names | def get_output_var_names(self):
"""Return a list of variables names that can be read as output.
Returns
-------
var_names : list[str]
A list of variable names that can be read from the outside
"""
# Return all the variables that aren't input variables
... | python | def get_output_var_names(self):
"""Return a list of variables names that can be read as output.
Returns
-------
var_names : list[str]
A list of variable names that can be read from the outside
"""
# Return all the variables that aren't input variables
... | [
"def",
"get_output_var_names",
"(",
"self",
")",
":",
"all_vars",
"=",
"list",
"(",
"self",
".",
"species_name_map",
".",
"keys",
"(",
")",
")",
"output_vars",
"=",
"list",
"(",
"set",
"(",
"all_vars",
")",
"-",
"set",
"(",
"self",
".",
"input_vars",
"... | Return a list of variables names that can be read as output.
Returns
-------
var_names : list[str]
A list of variable names that can be read from the outside | [
"Return",
"a",
"list",
"of",
"variables",
"names",
"that",
"can",
"be",
"read",
"as",
"output",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L217-L232 | train |
sorgerlab/indra | indra/assemblers/pysb/bmi_wrapper.py | BMIModel.make_repository_component | def make_repository_component(self):
"""Return an XML string representing this BMI in a workflow.
This description is required by EMELI to discover and load models.
Returns
-------
xml : str
String serialized XML representation of the component in the
mo... | python | def make_repository_component(self):
"""Return an XML string representing this BMI in a workflow.
This description is required by EMELI to discover and load models.
Returns
-------
xml : str
String serialized XML representation of the component in the
mo... | [
"def",
"make_repository_component",
"(",
"self",
")",
":",
"component",
"=",
"etree",
".",
"Element",
"(",
"'component'",
")",
"comp_name",
"=",
"etree",
".",
"Element",
"(",
"'comp_name'",
")",
"comp_name",
".",
"text",
"=",
"self",
".",
"model",
".",
"na... | Return an XML string representing this BMI in a workflow.
This description is required by EMELI to discover and load models.
Returns
-------
xml : str
String serialized XML representation of the component in the
model repository. | [
"Return",
"an",
"XML",
"string",
"representing",
"this",
"BMI",
"in",
"a",
"workflow",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L336-L391 | train |
sorgerlab/indra | indra/assemblers/pysb/bmi_wrapper.py | BMIModel._map_in_out | def _map_in_out(self, inside_var_name):
"""Return the external name of a variable mapped from inside."""
for out_name, in_name in self.outside_name_map.items():
if inside_var_name == in_name:
return out_name
return None | python | def _map_in_out(self, inside_var_name):
"""Return the external name of a variable mapped from inside."""
for out_name, in_name in self.outside_name_map.items():
if inside_var_name == in_name:
return out_name
return None | [
"def",
"_map_in_out",
"(",
"self",
",",
"inside_var_name",
")",
":",
"for",
"out_name",
",",
"in_name",
"in",
"self",
".",
"outside_name_map",
".",
"items",
"(",
")",
":",
"if",
"inside_var_name",
"==",
"in_name",
":",
"return",
"out_name",
"return",
"None"
... | Return the external name of a variable mapped from inside. | [
"Return",
"the",
"external",
"name",
"of",
"a",
"variable",
"mapped",
"from",
"inside",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L417-L422 | train |
sorgerlab/indra | indra/tools/reading/pmid_reading/read_pmids.py | read_pmid | def read_pmid(pmid, source, cont_path, sparser_version, outbuf=None,
cleanup=True):
"Run sparser on a single pmid."
signal.signal(signal.SIGALRM, _timeout_handler)
signal.alarm(60)
try:
if (source is 'content_not_found'
or source.startswith('unhandled_content_type')
... | python | def read_pmid(pmid, source, cont_path, sparser_version, outbuf=None,
cleanup=True):
"Run sparser on a single pmid."
signal.signal(signal.SIGALRM, _timeout_handler)
signal.alarm(60)
try:
if (source is 'content_not_found'
or source.startswith('unhandled_content_type')
... | [
"def",
"read_pmid",
"(",
"pmid",
",",
"source",
",",
"cont_path",
",",
"sparser_version",
",",
"outbuf",
"=",
"None",
",",
"cleanup",
"=",
"True",
")",
":",
"\"Run sparser on a single pmid.\"",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGALRM",
",",
"_t... | Run sparser on a single pmid. | [
"Run",
"sparser",
"on",
"a",
"single",
"pmid",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/pmid_reading/read_pmids.py#L353-L402 | train |
sorgerlab/indra | indra/tools/reading/pmid_reading/read_pmids.py | get_stmts | def get_stmts(pmids_unread, cleanup=True, sparser_version=None):
"Run sparser on the pmids in pmids_unread."
if sparser_version is None:
sparser_version = sparser.get_version()
stmts = {}
now = datetime.now()
outbuf_fname = 'sparser_%s_%s.log' % (
now.strftime('%Y%m%d-%H%M%S'),
... | python | def get_stmts(pmids_unread, cleanup=True, sparser_version=None):
"Run sparser on the pmids in pmids_unread."
if sparser_version is None:
sparser_version = sparser.get_version()
stmts = {}
now = datetime.now()
outbuf_fname = 'sparser_%s_%s.log' % (
now.strftime('%Y%m%d-%H%M%S'),
... | [
"def",
"get_stmts",
"(",
"pmids_unread",
",",
"cleanup",
"=",
"True",
",",
"sparser_version",
"=",
"None",
")",
":",
"\"Run sparser on the pmids in pmids_unread.\"",
"if",
"sparser_version",
"is",
"None",
":",
"sparser_version",
"=",
"sparser",
".",
"get_version",
"... | Run sparser on the pmids in pmids_unread. | [
"Run",
"sparser",
"on",
"the",
"pmids",
"in",
"pmids_unread",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/pmid_reading/read_pmids.py#L405-L441 | train |
sorgerlab/indra | indra/tools/reading/pmid_reading/read_pmids.py | run_sparser | def run_sparser(pmid_list, tmp_dir, num_cores, start_index, end_index,
force_read, force_fulltext, cleanup=True, verbose=True):
'Run the sparser reader on the pmids in pmid_list.'
reader_version = sparser.get_version()
_, _, _, pmids_read, pmids_unread, _ =\
get_content_to_read(
... | python | def run_sparser(pmid_list, tmp_dir, num_cores, start_index, end_index,
force_read, force_fulltext, cleanup=True, verbose=True):
'Run the sparser reader on the pmids in pmid_list.'
reader_version = sparser.get_version()
_, _, _, pmids_read, pmids_unread, _ =\
get_content_to_read(
... | [
"def",
"run_sparser",
"(",
"pmid_list",
",",
"tmp_dir",
",",
"num_cores",
",",
"start_index",
",",
"end_index",
",",
"force_read",
",",
"force_fulltext",
",",
"cleanup",
"=",
"True",
",",
"verbose",
"=",
"True",
")",
":",
"'Run the sparser reader on the pmids in p... | Run the sparser reader on the pmids in pmid_list. | [
"Run",
"the",
"sparser",
"reader",
"on",
"the",
"pmids",
"in",
"pmid_list",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/pmid_reading/read_pmids.py#L452-L502 | train |
sorgerlab/indra | indra/statements/statements.py | get_all_descendants | def get_all_descendants(parent):
"""Get all the descendants of a parent class, recursively."""
children = parent.__subclasses__()
descendants = children[:]
for child in children:
descendants += get_all_descendants(child)
return descendants | python | def get_all_descendants(parent):
"""Get all the descendants of a parent class, recursively."""
children = parent.__subclasses__()
descendants = children[:]
for child in children:
descendants += get_all_descendants(child)
return descendants | [
"def",
"get_all_descendants",
"(",
"parent",
")",
":",
"children",
"=",
"parent",
".",
"__subclasses__",
"(",
")",
"descendants",
"=",
"children",
"[",
":",
"]",
"for",
"child",
"in",
"children",
":",
"descendants",
"+=",
"get_all_descendants",
"(",
"child",
... | Get all the descendants of a parent class, recursively. | [
"Get",
"all",
"the",
"descendants",
"of",
"a",
"parent",
"class",
"recursively",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L2454-L2460 | train |
sorgerlab/indra | indra/statements/statements.py | get_type_hierarchy | def get_type_hierarchy(s):
"""Get the sequence of parents from `s` to Statement.
Parameters
----------
s : a class or instance of a child of Statement
For example the statement `Phosphorylation(MEK(), ERK())` or just the
class `Phosphorylation`.
Returns
-------
parent_list ... | python | def get_type_hierarchy(s):
"""Get the sequence of parents from `s` to Statement.
Parameters
----------
s : a class or instance of a child of Statement
For example the statement `Phosphorylation(MEK(), ERK())` or just the
class `Phosphorylation`.
Returns
-------
parent_list ... | [
"def",
"get_type_hierarchy",
"(",
"s",
")",
":",
"tp",
"=",
"type",
"(",
"s",
")",
"if",
"not",
"isinstance",
"(",
"s",
",",
"type",
")",
"else",
"s",
"p_list",
"=",
"[",
"tp",
"]",
"for",
"p",
"in",
"tp",
".",
"__bases__",
":",
"if",
"p",
"is"... | Get the sequence of parents from `s` to Statement.
Parameters
----------
s : a class or instance of a child of Statement
For example the statement `Phosphorylation(MEK(), ERK())` or just the
class `Phosphorylation`.
Returns
-------
parent_list : list[types]
A list of th... | [
"Get",
"the",
"sequence",
"of",
"parents",
"from",
"s",
"to",
"Statement",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L2465-L2494 | train |
sorgerlab/indra | indra/statements/statements.py | get_statement_by_name | def get_statement_by_name(stmt_name):
"""Get a statement class given the name of the statement class."""
stmt_classes = get_all_descendants(Statement)
for stmt_class in stmt_classes:
if stmt_class.__name__.lower() == stmt_name.lower():
return stmt_class
raise NotAStatementName('\"%s\... | python | def get_statement_by_name(stmt_name):
"""Get a statement class given the name of the statement class."""
stmt_classes = get_all_descendants(Statement)
for stmt_class in stmt_classes:
if stmt_class.__name__.lower() == stmt_name.lower():
return stmt_class
raise NotAStatementName('\"%s\... | [
"def",
"get_statement_by_name",
"(",
"stmt_name",
")",
":",
"stmt_classes",
"=",
"get_all_descendants",
"(",
"Statement",
")",
"for",
"stmt_class",
"in",
"stmt_classes",
":",
"if",
"stmt_class",
".",
"__name__",
".",
"lower",
"(",
")",
"==",
"stmt_name",
".",
... | Get a statement class given the name of the statement class. | [
"Get",
"a",
"statement",
"class",
"given",
"the",
"name",
"of",
"the",
"statement",
"class",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L2501-L2508 | train |
sorgerlab/indra | indra/statements/statements.py | get_unresolved_support_uuids | def get_unresolved_support_uuids(stmts):
"""Get uuids unresolved in support from stmts from stmts_from_json."""
return {s.uuid for stmt in stmts for s in stmt.supports + stmt.supported_by
if isinstance(s, Unresolved)} | python | def get_unresolved_support_uuids(stmts):
"""Get uuids unresolved in support from stmts from stmts_from_json."""
return {s.uuid for stmt in stmts for s in stmt.supports + stmt.supported_by
if isinstance(s, Unresolved)} | [
"def",
"get_unresolved_support_uuids",
"(",
"stmts",
")",
":",
"return",
"{",
"s",
".",
"uuid",
"for",
"stmt",
"in",
"stmts",
"for",
"s",
"in",
"stmt",
".",
"supports",
"+",
"stmt",
".",
"supported_by",
"if",
"isinstance",
"(",
"s",
",",
"Unresolved",
")... | Get uuids unresolved in support from stmts from stmts_from_json. | [
"Get",
"uuids",
"unresolved",
"in",
"support",
"from",
"stmts",
"from",
"stmts_from_json",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L2516-L2519 | train |
sorgerlab/indra | indra/statements/statements.py | stmt_type | def stmt_type(obj, mk=True):
"""Return standardized, backwards compatible object type String.
This is a temporary solution to make sure type comparisons and
matches keys of Statements and related classes are backwards
compatible.
"""
if isinstance(obj, Statement) and mk:
return type(obj... | python | def stmt_type(obj, mk=True):
"""Return standardized, backwards compatible object type String.
This is a temporary solution to make sure type comparisons and
matches keys of Statements and related classes are backwards
compatible.
"""
if isinstance(obj, Statement) and mk:
return type(obj... | [
"def",
"stmt_type",
"(",
"obj",
",",
"mk",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"Statement",
")",
"and",
"mk",
":",
"return",
"type",
"(",
"obj",
")",
"else",
":",
"return",
"type",
"(",
"obj",
")",
".",
"__name__"
] | Return standardized, backwards compatible object type String.
This is a temporary solution to make sure type comparisons and
matches keys of Statements and related classes are backwards
compatible. | [
"Return",
"standardized",
"backwards",
"compatible",
"object",
"type",
"String",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L2522-L2532 | train |
sorgerlab/indra | indra/statements/statements.py | Statement.get_hash | def get_hash(self, shallow=True, refresh=False):
"""Get a hash for this Statement.
There are two types of hash, "shallow" and "full". A shallow hash is
as unique as the information carried by the statement, i.e. it is a hash
of the `matches_key`. This means that differences in source, e... | python | def get_hash(self, shallow=True, refresh=False):
"""Get a hash for this Statement.
There are two types of hash, "shallow" and "full". A shallow hash is
as unique as the information carried by the statement, i.e. it is a hash
of the `matches_key`. This means that differences in source, e... | [
"def",
"get_hash",
"(",
"self",
",",
"shallow",
"=",
"True",
",",
"refresh",
"=",
"False",
")",
":",
"if",
"shallow",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_shallow_hash'",
")",
"or",
"self",
".",
"_shallow_hash",
"is",
"None",
"or",
"refres... | Get a hash for this Statement.
There are two types of hash, "shallow" and "full". A shallow hash is
as unique as the information carried by the statement, i.e. it is a hash
of the `matches_key`. This means that differences in source, evidence,
and so on are not included. As such, it is ... | [
"Get",
"a",
"hash",
"for",
"this",
"Statement",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L269-L317 | train |
sorgerlab/indra | indra/statements/statements.py | Statement._tag_evidence | def _tag_evidence(self):
"""Set all the Evidence stmt_tag to my deep matches-key hash."""
h = self.get_hash(shallow=False)
for ev in self.evidence:
ev.stmt_tag = h
return | python | def _tag_evidence(self):
"""Set all the Evidence stmt_tag to my deep matches-key hash."""
h = self.get_hash(shallow=False)
for ev in self.evidence:
ev.stmt_tag = h
return | [
"def",
"_tag_evidence",
"(",
"self",
")",
":",
"h",
"=",
"self",
".",
"get_hash",
"(",
"shallow",
"=",
"False",
")",
"for",
"ev",
"in",
"self",
".",
"evidence",
":",
"ev",
".",
"stmt_tag",
"=",
"h",
"return"
] | Set all the Evidence stmt_tag to my deep matches-key hash. | [
"Set",
"all",
"the",
"Evidence",
"stmt_tag",
"to",
"my",
"deep",
"matches",
"-",
"key",
"hash",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L319-L324 | train |
sorgerlab/indra | indra/statements/statements.py | Statement.agent_list | def agent_list(self, deep_sorted=False):
"""Get the canonicallized agent list."""
ag_list = []
for ag_name in self._agent_order:
ag_attr = getattr(self, ag_name)
if isinstance(ag_attr, Concept) or ag_attr is None:
ag_list.append(ag_attr)
elif i... | python | def agent_list(self, deep_sorted=False):
"""Get the canonicallized agent list."""
ag_list = []
for ag_name in self._agent_order:
ag_attr = getattr(self, ag_name)
if isinstance(ag_attr, Concept) or ag_attr is None:
ag_list.append(ag_attr)
elif i... | [
"def",
"agent_list",
"(",
"self",
",",
"deep_sorted",
"=",
"False",
")",
":",
"ag_list",
"=",
"[",
"]",
"for",
"ag_name",
"in",
"self",
".",
"_agent_order",
":",
"ag_attr",
"=",
"getattr",
"(",
"self",
",",
"ag_name",
")",
"if",
"isinstance",
"(",
"ag_... | Get the canonicallized agent list. | [
"Get",
"the",
"canonicallized",
"agent",
"list",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L336-L354 | train |
sorgerlab/indra | indra/statements/statements.py | Statement.to_json | def to_json(self, use_sbo=False):
"""Return serialized Statement as a JSON dict.
Parameters
----------
use_sbo : Optional[bool]
If True, SBO annotations are added to each applicable element of
the JSON. Default: False
Returns
-------
json... | python | def to_json(self, use_sbo=False):
"""Return serialized Statement as a JSON dict.
Parameters
----------
use_sbo : Optional[bool]
If True, SBO annotations are added to each applicable element of
the JSON. Default: False
Returns
-------
json... | [
"def",
"to_json",
"(",
"self",
",",
"use_sbo",
"=",
"False",
")",
":",
"stmt_type",
"=",
"type",
"(",
"self",
")",
".",
"__name__",
"all_stmts",
"=",
"[",
"self",
"]",
"+",
"self",
".",
"supports",
"+",
"self",
".",
"supported_by",
"for",
"st",
"in",... | Return serialized Statement as a JSON dict.
Parameters
----------
use_sbo : Optional[bool]
If True, SBO annotations are added to each applicable element of
the JSON. Default: False
Returns
-------
json_dict : dict
The JSON-serialized ... | [
"Return",
"serialized",
"Statement",
"as",
"a",
"JSON",
"dict",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L421-L466 | train |
sorgerlab/indra | indra/statements/statements.py | Statement.to_graph | def to_graph(self):
"""Return Statement as a networkx graph."""
def json_node(graph, element, prefix):
if not element:
return None
node_id = '|'.join(prefix)
if isinstance(element, list):
graph.add_node(node_id, label='')
... | python | def to_graph(self):
"""Return Statement as a networkx graph."""
def json_node(graph, element, prefix):
if not element:
return None
node_id = '|'.join(prefix)
if isinstance(element, list):
graph.add_node(node_id, label='')
... | [
"def",
"to_graph",
"(",
"self",
")",
":",
"def",
"json_node",
"(",
"graph",
",",
"element",
",",
"prefix",
")",
":",
"if",
"not",
"element",
":",
"return",
"None",
"node_id",
"=",
"'|'",
".",
"join",
"(",
"prefix",
")",
"if",
"isinstance",
"(",
"elem... | Return Statement as a networkx graph. | [
"Return",
"Statement",
"as",
"a",
"networkx",
"graph",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L484-L523 | train |
sorgerlab/indra | indra/statements/statements.py | Statement.make_generic_copy | def make_generic_copy(self, deeply=False):
"""Make a new matching Statement with no provenance.
All agents and other attributes besides evidence, belief, supports, and
supported_by will be copied over, and a new uuid will be assigned.
Thus, the new Statement will satisfy `new_stmt.match... | python | def make_generic_copy(self, deeply=False):
"""Make a new matching Statement with no provenance.
All agents and other attributes besides evidence, belief, supports, and
supported_by will be copied over, and a new uuid will be assigned.
Thus, the new Statement will satisfy `new_stmt.match... | [
"def",
"make_generic_copy",
"(",
"self",
",",
"deeply",
"=",
"False",
")",
":",
"if",
"deeply",
":",
"kwargs",
"=",
"deepcopy",
"(",
"self",
".",
"__dict__",
")",
"else",
":",
"kwargs",
"=",
"self",
".",
"__dict__",
".",
"copy",
"(",
")",
"for",
"att... | Make a new matching Statement with no provenance.
All agents and other attributes besides evidence, belief, supports, and
supported_by will be copied over, and a new uuid will be assigned.
Thus, the new Statement will satisfy `new_stmt.matches(old_stmt)`.
If `deeply` is set to True, al... | [
"Make",
"a",
"new",
"matching",
"Statement",
"with",
"no",
"provenance",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L525-L553 | train |
sorgerlab/indra | indra/databases/lincs_client.py | load_lincs_csv | def load_lincs_csv(url):
"""Helper function to turn csv rows into dicts."""
resp = requests.get(url, params={'output_type': '.csv'}, timeout=120)
resp.raise_for_status()
if sys.version_info[0] < 3:
csv_io = BytesIO(resp.content)
else:
csv_io = StringIO(resp.text)
data_rows = list... | python | def load_lincs_csv(url):
"""Helper function to turn csv rows into dicts."""
resp = requests.get(url, params={'output_type': '.csv'}, timeout=120)
resp.raise_for_status()
if sys.version_info[0] < 3:
csv_io = BytesIO(resp.content)
else:
csv_io = StringIO(resp.text)
data_rows = list... | [
"def",
"load_lincs_csv",
"(",
"url",
")",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"params",
"=",
"{",
"'output_type'",
":",
"'.csv'",
"}",
",",
"timeout",
"=",
"120",
")",
"resp",
".",
"raise_for_status",
"(",
")",
"if",
"sys",
"."... | Helper function to turn csv rows into dicts. | [
"Helper",
"function",
"to",
"turn",
"csv",
"rows",
"into",
"dicts",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/lincs_client.py#L146-L157 | train |
sorgerlab/indra | indra/databases/lincs_client.py | LincsClient.get_small_molecule_name | def get_small_molecule_name(self, hms_lincs_id):
"""Get the name of a small molecule from the LINCS sm metadata.
Parameters
----------
hms_lincs_id : str
The HMS LINCS ID of the small molecule.
Returns
-------
str
The name of the small mo... | python | def get_small_molecule_name(self, hms_lincs_id):
"""Get the name of a small molecule from the LINCS sm metadata.
Parameters
----------
hms_lincs_id : str
The HMS LINCS ID of the small molecule.
Returns
-------
str
The name of the small mo... | [
"def",
"get_small_molecule_name",
"(",
"self",
",",
"hms_lincs_id",
")",
":",
"entry",
"=",
"self",
".",
"_get_entry_by_id",
"(",
"self",
".",
"_sm_data",
",",
"hms_lincs_id",
")",
"if",
"not",
"entry",
":",
"return",
"None",
"name",
"=",
"entry",
"[",
"'N... | Get the name of a small molecule from the LINCS sm metadata.
Parameters
----------
hms_lincs_id : str
The HMS LINCS ID of the small molecule.
Returns
-------
str
The name of the small molecule. | [
"Get",
"the",
"name",
"of",
"a",
"small",
"molecule",
"from",
"the",
"LINCS",
"sm",
"metadata",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/lincs_client.py#L35-L52 | train |
sorgerlab/indra | indra/databases/lincs_client.py | LincsClient.get_small_molecule_refs | def get_small_molecule_refs(self, hms_lincs_id):
"""Get the id refs of a small molecule from the LINCS sm metadata.
Parameters
----------
hms_lincs_id : str
The HMS LINCS ID of the small molecule.
Returns
-------
dict
A dictionary of refe... | python | def get_small_molecule_refs(self, hms_lincs_id):
"""Get the id refs of a small molecule from the LINCS sm metadata.
Parameters
----------
hms_lincs_id : str
The HMS LINCS ID of the small molecule.
Returns
-------
dict
A dictionary of refe... | [
"def",
"get_small_molecule_refs",
"(",
"self",
",",
"hms_lincs_id",
")",
":",
"refs",
"=",
"{",
"'HMS-LINCS'",
":",
"hms_lincs_id",
"}",
"entry",
"=",
"self",
".",
"_get_entry_by_id",
"(",
"self",
".",
"_sm_data",
",",
"hms_lincs_id",
")",
"if",
"not",
"entr... | Get the id refs of a small molecule from the LINCS sm metadata.
Parameters
----------
hms_lincs_id : str
The HMS LINCS ID of the small molecule.
Returns
-------
dict
A dictionary of references. | [
"Get",
"the",
"id",
"refs",
"of",
"a",
"small",
"molecule",
"from",
"the",
"LINCS",
"sm",
"metadata",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/lincs_client.py#L54-L80 | train |
sorgerlab/indra | indra/databases/lincs_client.py | LincsClient.get_protein_refs | def get_protein_refs(self, hms_lincs_id):
"""Get the refs for a protein from the LINCs protein metadata.
Parameters
----------
hms_lincs_id : str
The HMS LINCS ID for the protein
Returns
-------
dict
A dictionary of protein references.
... | python | def get_protein_refs(self, hms_lincs_id):
"""Get the refs for a protein from the LINCs protein metadata.
Parameters
----------
hms_lincs_id : str
The HMS LINCS ID for the protein
Returns
-------
dict
A dictionary of protein references.
... | [
"def",
"get_protein_refs",
"(",
"self",
",",
"hms_lincs_id",
")",
":",
"refs",
"=",
"{",
"'HMS-LINCS'",
":",
"hms_lincs_id",
"}",
"entry",
"=",
"self",
".",
"_get_entry_by_id",
"(",
"self",
".",
"_prot_data",
",",
"hms_lincs_id",
")",
"if",
"not",
"entry",
... | Get the refs for a protein from the LINCs protein metadata.
Parameters
----------
hms_lincs_id : str
The HMS LINCS ID for the protein
Returns
-------
dict
A dictionary of protein references. | [
"Get",
"the",
"refs",
"for",
"a",
"protein",
"from",
"the",
"LINCs",
"protein",
"metadata",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/lincs_client.py#L82-L106 | train |
sorgerlab/indra | indra/tools/gene_network.py | GeneNetwork.get_bel_stmts | def get_bel_stmts(self, filter=False):
"""Get relevant statements from the BEL large corpus.
Performs a series of neighborhood queries and then takes the union of
all the statements. Because the query process can take a long time for
large gene lists, the resulting list of statements ar... | python | def get_bel_stmts(self, filter=False):
"""Get relevant statements from the BEL large corpus.
Performs a series of neighborhood queries and then takes the union of
all the statements. Because the query process can take a long time for
large gene lists, the resulting list of statements ar... | [
"def",
"get_bel_stmts",
"(",
"self",
",",
"filter",
"=",
"False",
")",
":",
"if",
"self",
".",
"basename",
"is",
"not",
"None",
":",
"bel_stmt_path",
"=",
"'%s_bel_stmts.pkl'",
"%",
"self",
".",
"basename",
"if",
"self",
".",
"basename",
"is",
"not",
"No... | Get relevant statements from the BEL large corpus.
Performs a series of neighborhood queries and then takes the union of
all the statements. Because the query process can take a long time for
large gene lists, the resulting list of statements are cached in a
pickle file with the filenam... | [
"Get",
"relevant",
"statements",
"from",
"the",
"BEL",
"large",
"corpus",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/gene_network.py#L51-L94 | train |
sorgerlab/indra | indra/tools/gene_network.py | GeneNetwork.get_biopax_stmts | def get_biopax_stmts(self, filter=False, query='pathsbetween',
database_filter=None):
"""Get relevant statements from Pathway Commons.
Performs a "paths between" query for the genes in :py:attr:`gene_list`
and uses the results to build statements. This function caches t... | python | def get_biopax_stmts(self, filter=False, query='pathsbetween',
database_filter=None):
"""Get relevant statements from Pathway Commons.
Performs a "paths between" query for the genes in :py:attr:`gene_list`
and uses the results to build statements. This function caches t... | [
"def",
"get_biopax_stmts",
"(",
"self",
",",
"filter",
"=",
"False",
",",
"query",
"=",
"'pathsbetween'",
",",
"database_filter",
"=",
"None",
")",
":",
"if",
"self",
".",
"basename",
"is",
"not",
"None",
":",
"biopax_stmt_path",
"=",
"'%s_biopax_stmts.pkl'",
... | Get relevant statements from Pathway Commons.
Performs a "paths between" query for the genes in :py:attr:`gene_list`
and uses the results to build statements. This function caches two
files: the list of statements built from the query, which is cached in
`<basename>_biopax_stmts.pkl`, a... | [
"Get",
"relevant",
"statements",
"from",
"Pathway",
"Commons",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/gene_network.py#L96-L175 | train |
sorgerlab/indra | indra/tools/gene_network.py | GeneNetwork.get_statements | def get_statements(self, filter=False):
"""Return the combined list of statements from BEL and Pathway Commons.
Internally calls :py:meth:`get_biopax_stmts` and
:py:meth:`get_bel_stmts`.
Parameters
----------
filter : bool
If True, includes only those statem... | python | def get_statements(self, filter=False):
"""Return the combined list of statements from BEL and Pathway Commons.
Internally calls :py:meth:`get_biopax_stmts` and
:py:meth:`get_bel_stmts`.
Parameters
----------
filter : bool
If True, includes only those statem... | [
"def",
"get_statements",
"(",
"self",
",",
"filter",
"=",
"False",
")",
":",
"bp_stmts",
"=",
"self",
".",
"get_biopax_stmts",
"(",
"filter",
"=",
"filter",
")",
"bel_stmts",
"=",
"self",
".",
"get_bel_stmts",
"(",
"filter",
"=",
"filter",
")",
"return",
... | Return the combined list of statements from BEL and Pathway Commons.
Internally calls :py:meth:`get_biopax_stmts` and
:py:meth:`get_bel_stmts`.
Parameters
----------
filter : bool
If True, includes only those statements that exclusively mention
genes in ... | [
"Return",
"the",
"combined",
"list",
"of",
"statements",
"from",
"BEL",
"and",
"Pathway",
"Commons",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/gene_network.py#L177-L198 | train |
sorgerlab/indra | indra/tools/gene_network.py | GeneNetwork.run_preassembly | def run_preassembly(self, stmts, print_summary=True):
"""Run complete preassembly procedure on the given statements.
Results are returned as a dict and stored in the attribute
:py:attr:`results`. They are also saved in the pickle file
`<basename>_results.pkl`.
Parameters
... | python | def run_preassembly(self, stmts, print_summary=True):
"""Run complete preassembly procedure on the given statements.
Results are returned as a dict and stored in the attribute
:py:attr:`results`. They are also saved in the pickle file
`<basename>_results.pkl`.
Parameters
... | [
"def",
"run_preassembly",
"(",
"self",
",",
"stmts",
",",
"print_summary",
"=",
"True",
")",
":",
"pa1",
"=",
"Preassembler",
"(",
"hierarchies",
",",
"stmts",
")",
"logger",
".",
"info",
"(",
"\"Combining duplicates\"",
")",
"pa1",
".",
"combine_duplicates",
... | Run complete preassembly procedure on the given statements.
Results are returned as a dict and stored in the attribute
:py:attr:`results`. They are also saved in the pickle file
`<basename>_results.pkl`.
Parameters
----------
stmts : list of :py:class:`indra.statements.... | [
"Run",
"complete",
"preassembly",
"procedure",
"on",
"the",
"given",
"statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/gene_network.py#L200-L276 | train |
sorgerlab/indra | indra/sources/hume/processor.py | _get_grounding | def _get_grounding(entity):
"""Return Hume grounding."""
db_refs = {'TEXT': entity['text']}
groundings = entity.get('grounding')
if not groundings:
return db_refs
def get_ont_concept(concept):
"""Strip slash, replace spaces and remove example leafs."""
# In the WM context, g... | python | def _get_grounding(entity):
"""Return Hume grounding."""
db_refs = {'TEXT': entity['text']}
groundings = entity.get('grounding')
if not groundings:
return db_refs
def get_ont_concept(concept):
"""Strip slash, replace spaces and remove example leafs."""
# In the WM context, g... | [
"def",
"_get_grounding",
"(",
"entity",
")",
":",
"db_refs",
"=",
"{",
"'TEXT'",
":",
"entity",
"[",
"'text'",
"]",
"}",
"groundings",
"=",
"entity",
".",
"get",
"(",
"'grounding'",
")",
"if",
"not",
"groundings",
":",
"return",
"db_refs",
"def",
"get_on... | Return Hume grounding. | [
"Return",
"Hume",
"grounding",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L230-L277 | train |
sorgerlab/indra | indra/sources/hume/processor.py | HumeJsonLdProcessor._find_relations | def _find_relations(self):
"""Find all relevant relation elements and return them in a list."""
# Get all extractions
extractions = \
list(self.tree.execute("$.extractions[(@.@type is 'Extraction')]"))
# Get relations from extractions
relations = []
for e in ... | python | def _find_relations(self):
"""Find all relevant relation elements and return them in a list."""
# Get all extractions
extractions = \
list(self.tree.execute("$.extractions[(@.@type is 'Extraction')]"))
# Get relations from extractions
relations = []
for e in ... | [
"def",
"_find_relations",
"(",
"self",
")",
":",
"extractions",
"=",
"list",
"(",
"self",
".",
"tree",
".",
"execute",
"(",
"\"$.extractions[(@.@type is 'Extraction')]\"",
")",
")",
"relations",
"=",
"[",
"]",
"for",
"e",
"in",
"extractions",
":",
"label_set",... | Find all relevant relation elements and return them in a list. | [
"Find",
"all",
"relevant",
"relation",
"elements",
"and",
"return",
"them",
"in",
"a",
"list",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L68-L95 | train |
sorgerlab/indra | indra/sources/hume/processor.py | HumeJsonLdProcessor._get_documents | def _get_documents(self):
"""Populate sentences attribute with a dict keyed by document id."""
documents = self.tree.execute("$.documents")
for doc in documents:
sentences = {s['@id']: s['text'] for s in doc.get('sentences', [])}
self.document_dict[doc['@id']] = {'sentenc... | python | def _get_documents(self):
"""Populate sentences attribute with a dict keyed by document id."""
documents = self.tree.execute("$.documents")
for doc in documents:
sentences = {s['@id']: s['text'] for s in doc.get('sentences', [])}
self.document_dict[doc['@id']] = {'sentenc... | [
"def",
"_get_documents",
"(",
"self",
")",
":",
"documents",
"=",
"self",
".",
"tree",
".",
"execute",
"(",
"\"$.documents\"",
")",
"for",
"doc",
"in",
"documents",
":",
"sentences",
"=",
"{",
"s",
"[",
"'@id'",
"]",
":",
"s",
"[",
"'text'",
"]",
"fo... | Populate sentences attribute with a dict keyed by document id. | [
"Populate",
"sentences",
"attribute",
"with",
"a",
"dict",
"keyed",
"by",
"document",
"id",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L97-L103 | train |
sorgerlab/indra | indra/sources/hume/processor.py | HumeJsonLdProcessor._make_context | def _make_context(self, entity):
"""Get place and time info from the json for this entity."""
loc_context = None
time_context = None
# Look for time and place contexts.
for argument in entity["arguments"]:
if argument["type"] == "place":
entity_id = a... | python | def _make_context(self, entity):
"""Get place and time info from the json for this entity."""
loc_context = None
time_context = None
# Look for time and place contexts.
for argument in entity["arguments"]:
if argument["type"] == "place":
entity_id = a... | [
"def",
"_make_context",
"(",
"self",
",",
"entity",
")",
":",
"loc_context",
"=",
"None",
"time_context",
"=",
"None",
"for",
"argument",
"in",
"entity",
"[",
"\"arguments\"",
"]",
":",
"if",
"argument",
"[",
"\"type\"",
"]",
"==",
"\"place\"",
":",
"entit... | Get place and time info from the json for this entity. | [
"Get",
"place",
"and",
"time",
"info",
"from",
"the",
"json",
"for",
"this",
"entity",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L105-L139 | train |
sorgerlab/indra | indra/sources/hume/processor.py | HumeJsonLdProcessor._make_concept | def _make_concept(self, entity):
"""Return Concept from a Hume entity."""
# Use the canonical name as the name of the Concept by default
name = self._sanitize(entity['canonicalName'])
# But if there is a trigger head text, we prefer that since
# it almost always results in a clea... | python | def _make_concept(self, entity):
"""Return Concept from a Hume entity."""
# Use the canonical name as the name of the Concept by default
name = self._sanitize(entity['canonicalName'])
# But if there is a trigger head text, we prefer that since
# it almost always results in a clea... | [
"def",
"_make_concept",
"(",
"self",
",",
"entity",
")",
":",
"name",
"=",
"self",
".",
"_sanitize",
"(",
"entity",
"[",
"'canonicalName'",
"]",
")",
"db_refs",
"=",
"_get_grounding",
"(",
"entity",
")",
"concept",
"=",
"Concept",
"(",
"name",
",",
"db_r... | Return Concept from a Hume entity. | [
"Return",
"Concept",
"from",
"a",
"Hume",
"entity",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L141-L163 | train |
sorgerlab/indra | indra/sources/hume/processor.py | HumeJsonLdProcessor._get_event_and_context | def _get_event_and_context(self, event, arg_type):
"""Return an INDRA Event based on an event entry."""
eid = _choose_id(event, arg_type)
ev = self.concept_dict[eid]
concept, metadata = self._make_concept(ev)
ev_delta = {'adjectives': [],
'states': get_states(... | python | def _get_event_and_context(self, event, arg_type):
"""Return an INDRA Event based on an event entry."""
eid = _choose_id(event, arg_type)
ev = self.concept_dict[eid]
concept, metadata = self._make_concept(ev)
ev_delta = {'adjectives': [],
'states': get_states(... | [
"def",
"_get_event_and_context",
"(",
"self",
",",
"event",
",",
"arg_type",
")",
":",
"eid",
"=",
"_choose_id",
"(",
"event",
",",
"arg_type",
")",
"ev",
"=",
"self",
".",
"concept_dict",
"[",
"eid",
"]",
"concept",
",",
"metadata",
"=",
"self",
".",
... | Return an INDRA Event based on an event entry. | [
"Return",
"an",
"INDRA",
"Event",
"based",
"on",
"an",
"event",
"entry",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L165-L175 | train |
sorgerlab/indra | indra/sources/hume/processor.py | HumeJsonLdProcessor._get_evidence | def _get_evidence(self, event, adjectives):
"""Return the Evidence object for the INDRA Statement."""
provenance = event.get('provenance')
# First try looking up the full sentence through provenance
doc_id = provenance[0]['document']['@id']
sent_id = provenance[0]['sentence']
... | python | def _get_evidence(self, event, adjectives):
"""Return the Evidence object for the INDRA Statement."""
provenance = event.get('provenance')
# First try looking up the full sentence through provenance
doc_id = provenance[0]['document']['@id']
sent_id = provenance[0]['sentence']
... | [
"def",
"_get_evidence",
"(",
"self",
",",
"event",
",",
"adjectives",
")",
":",
"provenance",
"=",
"event",
".",
"get",
"(",
"'provenance'",
")",
"doc_id",
"=",
"provenance",
"[",
"0",
"]",
"[",
"'document'",
"]",
"[",
"'@id'",
"]",
"sent_id",
"=",
"pr... | Return the Evidence object for the INDRA Statement. | [
"Return",
"the",
"Evidence",
"object",
"for",
"the",
"INDRA",
"Statement",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L177-L199 | train |
sorgerlab/indra | indra/sources/medscan/processor.py | _is_statement_in_list | def _is_statement_in_list(new_stmt, old_stmt_list):
"""Return True of given statement is equivalent to on in a list
Determines whether the statement is equivalent to any statement in the
given list of statements, with equivalency determined by Statement's
equals method.
Parameters
----------
... | python | def _is_statement_in_list(new_stmt, old_stmt_list):
"""Return True of given statement is equivalent to on in a list
Determines whether the statement is equivalent to any statement in the
given list of statements, with equivalency determined by Statement's
equals method.
Parameters
----------
... | [
"def",
"_is_statement_in_list",
"(",
"new_stmt",
",",
"old_stmt_list",
")",
":",
"for",
"old_stmt",
"in",
"old_stmt_list",
":",
"if",
"old_stmt",
".",
"equals",
"(",
"new_stmt",
")",
":",
"return",
"True",
"elif",
"old_stmt",
".",
"evidence_equals",
"(",
"new_... | Return True of given statement is equivalent to on in a list
Determines whether the statement is equivalent to any statement in the
given list of statements, with equivalency determined by Statement's
equals method.
Parameters
----------
new_stmt : indra.statements.Statement
The statem... | [
"Return",
"True",
"of",
"given",
"statement",
"is",
"equivalent",
"to",
"on",
"in",
"a",
"list"
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L62-L145 | train |
sorgerlab/indra | indra/sources/medscan/processor.py | normalize_medscan_name | def normalize_medscan_name(name):
"""Removes the "complex" and "complex complex" suffixes from a medscan
agent name so that it better corresponds with the grounding map.
Parameters
----------
name: str
The Medscan agent name
Returns
-------
norm_name: str
The Medscan ag... | python | def normalize_medscan_name(name):
"""Removes the "complex" and "complex complex" suffixes from a medscan
agent name so that it better corresponds with the grounding map.
Parameters
----------
name: str
The Medscan agent name
Returns
-------
norm_name: str
The Medscan ag... | [
"def",
"normalize_medscan_name",
"(",
"name",
")",
":",
"suffix",
"=",
"' complex'",
"for",
"i",
"in",
"range",
"(",
"2",
")",
":",
"if",
"name",
".",
"endswith",
"(",
"suffix",
")",
":",
"name",
"=",
"name",
"[",
":",
"-",
"len",
"(",
"suffix",
")... | Removes the "complex" and "complex complex" suffixes from a medscan
agent name so that it better corresponds with the grounding map.
Parameters
----------
name: str
The Medscan agent name
Returns
-------
norm_name: str
The Medscan agent name with the "complex" and "complex ... | [
"Removes",
"the",
"complex",
"and",
"complex",
"complex",
"suffixes",
"from",
"a",
"medscan",
"agent",
"name",
"so",
"that",
"it",
"better",
"corresponds",
"with",
"the",
"grounding",
"map",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L893-L913 | train |
sorgerlab/indra | indra/sources/medscan/processor.py | _urn_to_db_refs | def _urn_to_db_refs(urn):
"""Converts a Medscan URN to an INDRA db_refs dictionary with grounding
information.
Parameters
----------
urn : str
A Medscan URN
Returns
-------
db_refs : dict
A dictionary with grounding information, mapping databases to database
ide... | python | def _urn_to_db_refs(urn):
"""Converts a Medscan URN to an INDRA db_refs dictionary with grounding
information.
Parameters
----------
urn : str
A Medscan URN
Returns
-------
db_refs : dict
A dictionary with grounding information, mapping databases to database
ide... | [
"def",
"_urn_to_db_refs",
"(",
"urn",
")",
":",
"if",
"urn",
"is",
"None",
":",
"return",
"{",
"}",
",",
"None",
"m",
"=",
"URN_PATT",
".",
"match",
"(",
"urn",
")",
"if",
"m",
"is",
"None",
":",
"return",
"None",
",",
"None",
"urn_type",
",",
"u... | Converts a Medscan URN to an INDRA db_refs dictionary with grounding
information.
Parameters
----------
urn : str
A Medscan URN
Returns
-------
db_refs : dict
A dictionary with grounding information, mapping databases to database
identifiers. If the Medscan URN is n... | [
"Converts",
"a",
"Medscan",
"URN",
"to",
"an",
"INDRA",
"db_refs",
"dictionary",
"with",
"grounding",
"information",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L976-L1079 | train |
sorgerlab/indra | indra/sources/medscan/processor.py | _untag_sentence | def _untag_sentence(tagged_sentence):
"""Removes all tags in the sentence, returning the original sentence
without Medscan annotations.
Parameters
----------
tagged_sentence : str
The tagged sentence
Returns
-------
untagged_sentence : str
Sentence with tags and annotat... | python | def _untag_sentence(tagged_sentence):
"""Removes all tags in the sentence, returning the original sentence
without Medscan annotations.
Parameters
----------
tagged_sentence : str
The tagged sentence
Returns
-------
untagged_sentence : str
Sentence with tags and annotat... | [
"def",
"_untag_sentence",
"(",
"tagged_sentence",
")",
":",
"untagged_sentence",
"=",
"TAG_PATT",
".",
"sub",
"(",
"'\\\\2'",
",",
"tagged_sentence",
")",
"clean_sentence",
"=",
"JUNK_PATT",
".",
"sub",
"(",
"''",
",",
"untagged_sentence",
")",
"return",
"clean_... | Removes all tags in the sentence, returning the original sentence
without Medscan annotations.
Parameters
----------
tagged_sentence : str
The tagged sentence
Returns
-------
untagged_sentence : str
Sentence with tags and annotations stripped out | [
"Removes",
"all",
"tags",
"in",
"the",
"sentence",
"returning",
"the",
"original",
"sentence",
"without",
"Medscan",
"annotations",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L1109-L1125 | train |
sorgerlab/indra | indra/sources/medscan/processor.py | _extract_sentence_tags | def _extract_sentence_tags(tagged_sentence):
"""Given a tagged sentence, extracts a dictionary mapping tags to the words
or phrases that they tag.
Parameters
----------
tagged_sentence : str
The sentence with Medscan annotations and tags
Returns
-------
tags : dict
A di... | python | def _extract_sentence_tags(tagged_sentence):
"""Given a tagged sentence, extracts a dictionary mapping tags to the words
or phrases that they tag.
Parameters
----------
tagged_sentence : str
The sentence with Medscan annotations and tags
Returns
-------
tags : dict
A di... | [
"def",
"_extract_sentence_tags",
"(",
"tagged_sentence",
")",
":",
"untagged_sentence",
"=",
"_untag_sentence",
"(",
"tagged_sentence",
")",
"decluttered_sentence",
"=",
"JUNK_PATT",
".",
"sub",
"(",
"''",
",",
"tagged_sentence",
")",
"tags",
"=",
"{",
"}",
"endpo... | Given a tagged sentence, extracts a dictionary mapping tags to the words
or phrases that they tag.
Parameters
----------
tagged_sentence : str
The sentence with Medscan annotations and tags
Returns
-------
tags : dict
A dictionary mapping tags to the words or phrases that t... | [
"Given",
"a",
"tagged",
"sentence",
"extracts",
"a",
"dictionary",
"mapping",
"tags",
"to",
"the",
"words",
"or",
"phrases",
"that",
"they",
"tag",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L1128-L1168 | train |
sorgerlab/indra | indra/sources/medscan/processor.py | ProteinSiteInfo.get_sites | def get_sites(self):
"""Parse the site-text string and return a list of sites.
Returns
-------
sites : list[Site]
A list of position-residue pairs corresponding to the site-text
"""
st = self.site_text
suffixes = [' residue', ' residues', ',', '/']
... | python | def get_sites(self):
"""Parse the site-text string and return a list of sites.
Returns
-------
sites : list[Site]
A list of position-residue pairs corresponding to the site-text
"""
st = self.site_text
suffixes = [' residue', ' residues', ',', '/']
... | [
"def",
"get_sites",
"(",
"self",
")",
":",
"st",
"=",
"self",
".",
"site_text",
"suffixes",
"=",
"[",
"' residue'",
",",
"' residues'",
",",
"','",
",",
"'/'",
"]",
"for",
"suffix",
"in",
"suffixes",
":",
"if",
"st",
".",
"endswith",
"(",
"suffix",
"... | Parse the site-text string and return a list of sites.
Returns
-------
sites : list[Site]
A list of position-residue pairs corresponding to the site-text | [
"Parse",
"the",
"site",
"-",
"text",
"string",
"and",
"return",
"a",
"list",
"of",
"sites",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L163-L190 | train |
sorgerlab/indra | indra/sources/medscan/processor.py | MedscanProcessor.process_csxml_file | def process_csxml_file(self, filename, interval=None, lazy=False):
"""Processes a filehandle to MedScan csxml input into INDRA
statements.
The CSXML format consists of a top-level `<batch>` root element
containing a series of `<doc>` (document) elements, in turn containing
`<sec... | python | def process_csxml_file(self, filename, interval=None, lazy=False):
"""Processes a filehandle to MedScan csxml input into INDRA
statements.
The CSXML format consists of a top-level `<batch>` root element
containing a series of `<doc>` (document) elements, in turn containing
`<sec... | [
"def",
"process_csxml_file",
"(",
"self",
",",
"filename",
",",
"interval",
"=",
"None",
",",
"lazy",
"=",
"False",
")",
":",
"if",
"interval",
"is",
"None",
":",
"interval",
"=",
"(",
"None",
",",
"None",
")",
"tmp_fname",
"=",
"tempfile",
".",
"mktem... | Processes a filehandle to MedScan csxml input into INDRA
statements.
The CSXML format consists of a top-level `<batch>` root element
containing a series of `<doc>` (document) elements, in turn containing
`<sec>` (section) elements, and in turn containing `<sent>` (sentence)
elem... | [
"Processes",
"a",
"filehandle",
"to",
"MedScan",
"csxml",
"input",
"into",
"INDRA",
"statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L328-L381 | train |
sorgerlab/indra | indra/tools/reading/util/script_tools.py | get_parser | def get_parser(description, input_desc):
"""Get a parser that is generic to reading scripts.
Parameters
----------
description : str
A description of the tool, usually about one line long.
input_desc: str
A string describing the nature of the input file used by the reading
t... | python | def get_parser(description, input_desc):
"""Get a parser that is generic to reading scripts.
Parameters
----------
description : str
A description of the tool, usually about one line long.
input_desc: str
A string describing the nature of the input file used by the reading
t... | [
"def",
"get_parser",
"(",
"description",
",",
"input_desc",
")",
":",
"parser",
"=",
"ArgumentParser",
"(",
"description",
"=",
"description",
")",
"parser",
".",
"add_argument",
"(",
"dest",
"=",
"'input_file'",
",",
"help",
"=",
"input_desc",
")",
"parser",
... | Get a parser that is generic to reading scripts.
Parameters
----------
description : str
A description of the tool, usually about one line long.
input_desc: str
A string describing the nature of the input file used by the reading
tool.
Returns
-------
parser : argpa... | [
"Get",
"a",
"parser",
"that",
"is",
"generic",
"to",
"reading",
"scripts",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/util/script_tools.py#L11-L76 | train |
sorgerlab/indra | indra/literature/newsapi_client.py | send_request | def send_request(endpoint, **kwargs):
"""Return the response to a query as JSON from the NewsAPI web service.
The basic API is limited to 100 results which is chosen unless explicitly
given as an argument. Beyond that, paging is supported through the "page"
argument, if needed.
Parameters
----... | python | def send_request(endpoint, **kwargs):
"""Return the response to a query as JSON from the NewsAPI web service.
The basic API is limited to 100 results which is chosen unless explicitly
given as an argument. Beyond that, paging is supported through the "page"
argument, if needed.
Parameters
----... | [
"def",
"send_request",
"(",
"endpoint",
",",
"**",
"kwargs",
")",
":",
"if",
"api_key",
"is",
"None",
":",
"logger",
".",
"error",
"(",
"'NewsAPI cannot be used without an API key'",
")",
"return",
"None",
"url",
"=",
"'%s/%s'",
"%",
"(",
"newsapi_url",
",",
... | Return the response to a query as JSON from the NewsAPI web service.
The basic API is limited to 100 results which is chosen unless explicitly
given as an argument. Beyond that, paging is supported through the "page"
argument, if needed.
Parameters
----------
endpoint : str
Endpoint to... | [
"Return",
"the",
"response",
"to",
"a",
"query",
"as",
"JSON",
"from",
"the",
"NewsAPI",
"web",
"service",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/newsapi_client.py#L29-L63 | train |
sorgerlab/indra | indra/sources/ndex_cx/api.py | process_cx_file | def process_cx_file(file_name, require_grounding=True):
"""Process a CX JSON file into Statements.
Parameters
----------
file_name : str
Path to file containing CX JSON.
require_grounding: bool
Whether network nodes lacking grounding information should be included
among the ... | python | def process_cx_file(file_name, require_grounding=True):
"""Process a CX JSON file into Statements.
Parameters
----------
file_name : str
Path to file containing CX JSON.
require_grounding: bool
Whether network nodes lacking grounding information should be included
among the ... | [
"def",
"process_cx_file",
"(",
"file_name",
",",
"require_grounding",
"=",
"True",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"'rt'",
")",
"as",
"fh",
":",
"json_list",
"=",
"json",
".",
"load",
"(",
"fh",
")",
"return",
"process_cx",
"(",
"json_li... | Process a CX JSON file into Statements.
Parameters
----------
file_name : str
Path to file containing CX JSON.
require_grounding: bool
Whether network nodes lacking grounding information should be included
among the extracted Statements (default is True).
Returns
------... | [
"Process",
"a",
"CX",
"JSON",
"file",
"into",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/api.py#L12-L30 | train |
sorgerlab/indra | indra/sources/ndex_cx/api.py | process_ndex_network | def process_ndex_network(network_id, username=None, password=None,
require_grounding=True):
"""Process an NDEx network into Statements.
Parameters
----------
network_id : str
NDEx network ID.
username : str
NDEx username.
password : str
NDEx pass... | python | def process_ndex_network(network_id, username=None, password=None,
require_grounding=True):
"""Process an NDEx network into Statements.
Parameters
----------
network_id : str
NDEx network ID.
username : str
NDEx username.
password : str
NDEx pass... | [
"def",
"process_ndex_network",
"(",
"network_id",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"require_grounding",
"=",
"True",
")",
":",
"nd",
"=",
"ndex2",
".",
"client",
".",
"Ndex2",
"(",
"username",
"=",
"username",
",",
"password... | Process an NDEx network into Statements.
Parameters
----------
network_id : str
NDEx network ID.
username : str
NDEx username.
password : str
NDEx password.
require_grounding: bool
Whether network nodes lacking grounding information should be included
amo... | [
"Process",
"an",
"NDEx",
"network",
"into",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/api.py#L33-L65 | train |
sorgerlab/indra | indra/sources/ndex_cx/api.py | process_cx | def process_cx(cx_json, summary=None, require_grounding=True):
"""Process a CX JSON object into Statements.
Parameters
----------
cx_json : list
CX JSON object.
summary : Optional[dict]
The network summary object which can be obtained via
get_network_summary through the web ... | python | def process_cx(cx_json, summary=None, require_grounding=True):
"""Process a CX JSON object into Statements.
Parameters
----------
cx_json : list
CX JSON object.
summary : Optional[dict]
The network summary object which can be obtained via
get_network_summary through the web ... | [
"def",
"process_cx",
"(",
"cx_json",
",",
"summary",
"=",
"None",
",",
"require_grounding",
"=",
"True",
")",
":",
"ncp",
"=",
"NdexCxProcessor",
"(",
"cx_json",
",",
"summary",
"=",
"summary",
",",
"require_grounding",
"=",
"require_grounding",
")",
"ncp",
... | Process a CX JSON object into Statements.
Parameters
----------
cx_json : list
CX JSON object.
summary : Optional[dict]
The network summary object which can be obtained via
get_network_summary through the web service. THis contains metadata
such as the owner and the crea... | [
"Process",
"a",
"CX",
"JSON",
"object",
"into",
"Statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/api.py#L68-L91 | train |
sorgerlab/indra | indra/tools/reading/read_files.py | read_files | def read_files(files, readers, **kwargs):
"""Read the files in `files` with the reader objects in `readers`.
Parameters
----------
files : list [str]
A list of file paths to be read by the readers. Supported files are
limited to text and nxml files.
readers : list [Reader instances]... | python | def read_files(files, readers, **kwargs):
"""Read the files in `files` with the reader objects in `readers`.
Parameters
----------
files : list [str]
A list of file paths to be read by the readers. Supported files are
limited to text and nxml files.
readers : list [Reader instances]... | [
"def",
"read_files",
"(",
"files",
",",
"readers",
",",
"**",
"kwargs",
")",
":",
"reading_content",
"=",
"[",
"Content",
".",
"from_file",
"(",
"filepath",
")",
"for",
"filepath",
"in",
"files",
"]",
"output_list",
"=",
"[",
"]",
"for",
"reader",
"in",
... | Read the files in `files` with the reader objects in `readers`.
Parameters
----------
files : list [str]
A list of file paths to be read by the readers. Supported files are
limited to text and nxml files.
readers : list [Reader instances]
A list of Reader objects to be used read... | [
"Read",
"the",
"files",
"in",
"files",
"with",
"the",
"reader",
"objects",
"in",
"readers",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/read_files.py#L30-L59 | train |
sorgerlab/indra | indra/tools/expand_families.py | Expander.expand_families | def expand_families(self, stmts):
"""Generate statements by expanding members of families and complexes.
"""
new_stmts = []
for stmt in stmts:
# Put together the lists of families, with their members. E.g.,
# for a statement involving RAF and MEK, should return a ... | python | def expand_families(self, stmts):
"""Generate statements by expanding members of families and complexes.
"""
new_stmts = []
for stmt in stmts:
# Put together the lists of families, with their members. E.g.,
# for a statement involving RAF and MEK, should return a ... | [
"def",
"expand_families",
"(",
"self",
",",
"stmts",
")",
":",
"new_stmts",
"=",
"[",
"]",
"for",
"stmt",
"in",
"stmts",
":",
"families_list",
"=",
"[",
"]",
"for",
"ag",
"in",
"stmt",
".",
"agent_list",
"(",
")",
":",
"ag_children",
"=",
"self",
"."... | Generate statements by expanding members of families and complexes. | [
"Generate",
"statements",
"by",
"expanding",
"members",
"of",
"families",
"and",
"complexes",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/expand_families.py#L22-L69 | train |
sorgerlab/indra | indra/preassembler/make_eidos_hume_ontologies.py | update_ontology | def update_ontology(ont_url, rdf_path):
"""Load an ontology formatted like Eidos' from github."""
yaml_root = load_yaml_from_url(ont_url)
G = rdf_graph_from_yaml(yaml_root)
save_hierarchy(G, rdf_path) | python | def update_ontology(ont_url, rdf_path):
"""Load an ontology formatted like Eidos' from github."""
yaml_root = load_yaml_from_url(ont_url)
G = rdf_graph_from_yaml(yaml_root)
save_hierarchy(G, rdf_path) | [
"def",
"update_ontology",
"(",
"ont_url",
",",
"rdf_path",
")",
":",
"yaml_root",
"=",
"load_yaml_from_url",
"(",
"ont_url",
")",
"G",
"=",
"rdf_graph_from_yaml",
"(",
"yaml_root",
")",
"save_hierarchy",
"(",
"G",
",",
"rdf_path",
")"
] | Load an ontology formatted like Eidos' from github. | [
"Load",
"an",
"ontology",
"formatted",
"like",
"Eidos",
"from",
"github",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/preassembler/make_eidos_hume_ontologies.py#L69-L73 | train |
sorgerlab/indra | indra/preassembler/make_eidos_hume_ontologies.py | rdf_graph_from_yaml | def rdf_graph_from_yaml(yaml_root):
"""Convert the YAML object into an RDF Graph object."""
G = Graph()
for top_entry in yaml_root:
assert len(top_entry) == 1
node = list(top_entry.keys())[0]
build_relations(G, node, top_entry[node], None)
return G | python | def rdf_graph_from_yaml(yaml_root):
"""Convert the YAML object into an RDF Graph object."""
G = Graph()
for top_entry in yaml_root:
assert len(top_entry) == 1
node = list(top_entry.keys())[0]
build_relations(G, node, top_entry[node], None)
return G | [
"def",
"rdf_graph_from_yaml",
"(",
"yaml_root",
")",
":",
"G",
"=",
"Graph",
"(",
")",
"for",
"top_entry",
"in",
"yaml_root",
":",
"assert",
"len",
"(",
"top_entry",
")",
"==",
"1",
"node",
"=",
"list",
"(",
"top_entry",
".",
"keys",
"(",
")",
")",
"... | Convert the YAML object into an RDF Graph object. | [
"Convert",
"the",
"YAML",
"object",
"into",
"an",
"RDF",
"Graph",
"object",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/preassembler/make_eidos_hume_ontologies.py#L76-L83 | train |
sorgerlab/indra | indra/preassembler/make_eidos_hume_ontologies.py | load_yaml_from_url | def load_yaml_from_url(ont_url):
"""Return a YAML object loaded from a YAML file URL."""
res = requests.get(ont_url)
if res.status_code != 200:
raise Exception('Could not load ontology from %s' % ont_url)
root = yaml.load(res.content)
return root | python | def load_yaml_from_url(ont_url):
"""Return a YAML object loaded from a YAML file URL."""
res = requests.get(ont_url)
if res.status_code != 200:
raise Exception('Could not load ontology from %s' % ont_url)
root = yaml.load(res.content)
return root | [
"def",
"load_yaml_from_url",
"(",
"ont_url",
")",
":",
"res",
"=",
"requests",
".",
"get",
"(",
"ont_url",
")",
"if",
"res",
".",
"status_code",
"!=",
"200",
":",
"raise",
"Exception",
"(",
"'Could not load ontology from %s'",
"%",
"ont_url",
")",
"root",
"=... | Return a YAML object loaded from a YAML file URL. | [
"Return",
"a",
"YAML",
"object",
"loaded",
"from",
"a",
"YAML",
"file",
"URL",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/preassembler/make_eidos_hume_ontologies.py#L86-L92 | train |
sorgerlab/indra | indra/sources/isi/preprocessor.py | IsiPreprocessor.register_preprocessed_file | def register_preprocessed_file(self, infile, pmid, extra_annotations):
"""Set up already preprocessed text file for reading with ISI reader.
This is essentially a mock function to "register" already preprocessed
files and get an IsiPreprocessor object that can be passed to
the IsiProces... | python | def register_preprocessed_file(self, infile, pmid, extra_annotations):
"""Set up already preprocessed text file for reading with ISI reader.
This is essentially a mock function to "register" already preprocessed
files and get an IsiPreprocessor object that can be passed to
the IsiProces... | [
"def",
"register_preprocessed_file",
"(",
"self",
",",
"infile",
",",
"pmid",
",",
"extra_annotations",
")",
":",
"infile_base",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"infile",
")",
"outfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
"."... | Set up already preprocessed text file for reading with ISI reader.
This is essentially a mock function to "register" already preprocessed
files and get an IsiPreprocessor object that can be passed to
the IsiProcessor.
Parameters
----------
infile : str
Path ... | [
"Set",
"up",
"already",
"preprocessed",
"text",
"file",
"for",
"reading",
"with",
"ISI",
"reader",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/preprocessor.py#L54-L80 | train |
sorgerlab/indra | indra/sources/isi/preprocessor.py | IsiPreprocessor.preprocess_plain_text_string | def preprocess_plain_text_string(self, text, pmid, extra_annotations):
"""Preprocess plain text string for use by ISI reader.
Preprocessing is done by tokenizing into sentences and writing
each sentence on its own line in a plain text file. All other
preprocessing functions ultimately c... | python | def preprocess_plain_text_string(self, text, pmid, extra_annotations):
"""Preprocess plain text string for use by ISI reader.
Preprocessing is done by tokenizing into sentences and writing
each sentence on its own line in a plain text file. All other
preprocessing functions ultimately c... | [
"def",
"preprocess_plain_text_string",
"(",
"self",
",",
"text",
",",
"pmid",
",",
"extra_annotations",
")",
":",
"output_file",
"=",
"'%s.txt'",
"%",
"self",
".",
"next_file_id",
"output_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"preproc... | Preprocess plain text string for use by ISI reader.
Preprocessing is done by tokenizing into sentences and writing
each sentence on its own line in a plain text file. All other
preprocessing functions ultimately call this one.
Parameters
----------
text : str
... | [
"Preprocess",
"plain",
"text",
"string",
"for",
"use",
"by",
"ISI",
"reader",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/preprocessor.py#L82-L120 | train |
sorgerlab/indra | indra/sources/isi/preprocessor.py | IsiPreprocessor.preprocess_plain_text_file | def preprocess_plain_text_file(self, filename, pmid, extra_annotations):
"""Preprocess a plain text file for use with ISI reder.
Preprocessing results in a new text file with one sentence
per line.
Parameters
----------
filename : str
The name of the plain t... | python | def preprocess_plain_text_file(self, filename, pmid, extra_annotations):
"""Preprocess a plain text file for use with ISI reder.
Preprocessing results in a new text file with one sentence
per line.
Parameters
----------
filename : str
The name of the plain t... | [
"def",
"preprocess_plain_text_file",
"(",
"self",
",",
"filename",
",",
"pmid",
",",
"extra_annotations",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"filename",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"content",
"=",
"f",
"."... | Preprocess a plain text file for use with ISI reder.
Preprocessing results in a new text file with one sentence
per line.
Parameters
----------
filename : str
The name of the plain text file
pmid : str
The PMID from which it comes, or None if not... | [
"Preprocess",
"a",
"plain",
"text",
"file",
"for",
"use",
"with",
"ISI",
"reder",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/preprocessor.py#L122-L142 | train |
sorgerlab/indra | indra/sources/isi/preprocessor.py | IsiPreprocessor.preprocess_nxml_file | def preprocess_nxml_file(self, filename, pmid, extra_annotations):
"""Preprocess an NXML file for use with the ISI reader.
Preprocessing is done by extracting plain text from NXML and then
creating a text file with one sentence per line.
Parameters
----------
filename :... | python | def preprocess_nxml_file(self, filename, pmid, extra_annotations):
"""Preprocess an NXML file for use with the ISI reader.
Preprocessing is done by extracting plain text from NXML and then
creating a text file with one sentence per line.
Parameters
----------
filename :... | [
"def",
"preprocess_nxml_file",
"(",
"self",
",",
"filename",
",",
"pmid",
",",
"extra_annotations",
")",
":",
"tmp_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"'indra_isi_nxml2txt_output'",
")",
"if",
"nxml2txt_path",
"is",
"None",
":",
"logger",
".",
"error",
... | Preprocess an NXML file for use with the ISI reader.
Preprocessing is done by extracting plain text from NXML and then
creating a text file with one sentence per line.
Parameters
----------
filename : str
Filename of an nxml file to process
pmid : str
... | [
"Preprocess",
"an",
"NXML",
"file",
"for",
"use",
"with",
"the",
"ISI",
"reader",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/preprocessor.py#L144-L202 | train |
sorgerlab/indra | indra/sources/isi/preprocessor.py | IsiPreprocessor.preprocess_abstract_list | def preprocess_abstract_list(self, abstract_list):
"""Preprocess abstracts in database pickle dump format for ISI reader.
For each abstract, creates a plain text file with one sentence per
line, and stores metadata to be included with each statement from
that abstract.
Paramete... | python | def preprocess_abstract_list(self, abstract_list):
"""Preprocess abstracts in database pickle dump format for ISI reader.
For each abstract, creates a plain text file with one sentence per
line, and stores metadata to be included with each statement from
that abstract.
Paramete... | [
"def",
"preprocess_abstract_list",
"(",
"self",
",",
"abstract_list",
")",
":",
"for",
"abstract_struct",
"in",
"abstract_list",
":",
"abs_format",
"=",
"abstract_struct",
"[",
"'format'",
"]",
"content_type",
"=",
"abstract_struct",
"[",
"'text_type'",
"]",
"conten... | Preprocess abstracts in database pickle dump format for ISI reader.
For each abstract, creates a plain text file with one sentence per
line, and stores metadata to be included with each statement from
that abstract.
Parameters
----------
abstract_list : list[dict]
... | [
"Preprocess",
"abstracts",
"in",
"database",
"pickle",
"dump",
"format",
"for",
"ISI",
"reader",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/preprocessor.py#L204-L234 | train |
sorgerlab/indra | indra/sources/geneways/api.py | process_geneways_files | def process_geneways_files(input_folder=data_folder, get_evidence=True):
"""Reads in Geneways data and returns a list of statements.
Parameters
----------
input_folder : Optional[str]
A folder in which to search for Geneways data. Looks for these
Geneways extraction data files: human_ac... | python | def process_geneways_files(input_folder=data_folder, get_evidence=True):
"""Reads in Geneways data and returns a list of statements.
Parameters
----------
input_folder : Optional[str]
A folder in which to search for Geneways data. Looks for these
Geneways extraction data files: human_ac... | [
"def",
"process_geneways_files",
"(",
"input_folder",
"=",
"data_folder",
",",
"get_evidence",
"=",
"True",
")",
":",
"gp",
"=",
"GenewaysProcessor",
"(",
"input_folder",
",",
"get_evidence",
")",
"return",
"gp"
] | Reads in Geneways data and returns a list of statements.
Parameters
----------
input_folder : Optional[str]
A folder in which to search for Geneways data. Looks for these
Geneways extraction data files: human_action.txt,
human_actionmention.txt, human_symbols.txt.
Omit this ... | [
"Reads",
"in",
"Geneways",
"data",
"and",
"returns",
"a",
"list",
"of",
"statements",
"."
] | 79a70415832c5702d7a820c7c9ccc8e25010124b | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/geneways/api.py#L24-L47 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.post_flag_create | def post_flag_create(self, post_id, reason):
"""Function to flag a post.
Parameters:
post_id (int): The id of the flagged post.
reason (str): The reason of the flagging.
"""
params = {'post_flag[post_id]': post_id, 'post_flag[reason]': reason}
return self... | python | def post_flag_create(self, post_id, reason):
"""Function to flag a post.
Parameters:
post_id (int): The id of the flagged post.
reason (str): The reason of the flagging.
"""
params = {'post_flag[post_id]': post_id, 'post_flag[reason]': reason}
return self... | [
"def",
"post_flag_create",
"(",
"self",
",",
"post_id",
",",
"reason",
")",
":",
"params",
"=",
"{",
"'post_flag[post_id]'",
":",
"post_id",
",",
"'post_flag[reason]'",
":",
"reason",
"}",
"return",
"self",
".",
"_get",
"(",
"'post_flags.json'",
",",
"params",... | Function to flag a post.
Parameters:
post_id (int): The id of the flagged post.
reason (str): The reason of the flagging. | [
"Function",
"to",
"flag",
"a",
"post",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L165-L173 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.post_versions_list | def post_versions_list(self, updater_name=None, updater_id=None,
post_id=None, start_id=None):
"""Get list of post versions.
Parameters:
updater_name (str):
updater_id (int):
post_id (int):
start_id (int):
"""
pa... | python | def post_versions_list(self, updater_name=None, updater_id=None,
post_id=None, start_id=None):
"""Get list of post versions.
Parameters:
updater_name (str):
updater_id (int):
post_id (int):
start_id (int):
"""
pa... | [
"def",
"post_versions_list",
"(",
"self",
",",
"updater_name",
"=",
"None",
",",
"updater_id",
"=",
"None",
",",
"post_id",
"=",
"None",
",",
"start_id",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'search[updater_name]'",
":",
"updater_name",
",",
"'search[... | Get list of post versions.
Parameters:
updater_name (str):
updater_id (int):
post_id (int):
start_id (int): | [
"Get",
"list",
"of",
"post",
"versions",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L210-L226 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.artist_list | def artist_list(self, query=None, artist_id=None, creator_name=None,
creator_id=None, is_active=None, is_banned=None,
empty_only=None, order=None):
"""Get an artist of a list of artists.
Parameters:
query (str):
This field has multiple... | python | def artist_list(self, query=None, artist_id=None, creator_name=None,
creator_id=None, is_active=None, is_banned=None,
empty_only=None, order=None):
"""Get an artist of a list of artists.
Parameters:
query (str):
This field has multiple... | [
"def",
"artist_list",
"(",
"self",
",",
"query",
"=",
"None",
",",
"artist_id",
"=",
"None",
",",
"creator_name",
"=",
"None",
",",
"creator_id",
"=",
"None",
",",
"is_active",
"=",
"None",
",",
"is_banned",
"=",
"None",
",",
"empty_only",
"=",
"None",
... | Get an artist of a list of artists.
Parameters:
query (str):
This field has multiple uses depending on what the query starts
with:
'http:desired_url':
Search for artist with this URL.
'name:desired_url':
... | [
"Get",
"an",
"artist",
"of",
"a",
"list",
"of",
"artists",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L496-L537 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.artist_commentary_list | def artist_commentary_list(self, text_matches=None, post_id=None,
post_tags_match=None, original_present=None,
translated_present=None):
"""list artist commentary.
Parameters:
text_matches (str):
post_id (int):
... | python | def artist_commentary_list(self, text_matches=None, post_id=None,
post_tags_match=None, original_present=None,
translated_present=None):
"""list artist commentary.
Parameters:
text_matches (str):
post_id (int):
... | [
"def",
"artist_commentary_list",
"(",
"self",
",",
"text_matches",
"=",
"None",
",",
"post_id",
"=",
"None",
",",
"post_tags_match",
"=",
"None",
",",
"original_present",
"=",
"None",
",",
"translated_present",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'se... | list artist commentary.
Parameters:
text_matches (str):
post_id (int):
post_tags_match (str): The commentary's post's tags match the
giventerms. Meta-tags not supported.
original_present (str): Can be: yes, no.
trans... | [
"list",
"artist",
"commentary",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L655-L675 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.artist_commentary_versions | def artist_commentary_versions(self, post_id, updater_id):
"""Return list of artist commentary versions.
Parameters:
updater_id (int):
post_id (int):
"""
params = {'search[updater_id]': updater_id, 'search[post_id]': post_id}
return self._get('artist_comm... | python | def artist_commentary_versions(self, post_id, updater_id):
"""Return list of artist commentary versions.
Parameters:
updater_id (int):
post_id (int):
"""
params = {'search[updater_id]': updater_id, 'search[post_id]': post_id}
return self._get('artist_comm... | [
"def",
"artist_commentary_versions",
"(",
"self",
",",
"post_id",
",",
"updater_id",
")",
":",
"params",
"=",
"{",
"'search[updater_id]'",
":",
"updater_id",
",",
"'search[post_id]'",
":",
"post_id",
"}",
"return",
"self",
".",
"_get",
"(",
"'artist_commentary_ver... | Return list of artist commentary versions.
Parameters:
updater_id (int):
post_id (int): | [
"Return",
"list",
"of",
"artist",
"commentary",
"versions",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L711-L719 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.note_list | def note_list(self, body_matches=None, post_id=None, post_tags_match=None,
creator_name=None, creator_id=None, is_active=None):
"""Return list of notes.
Parameters:
body_matches (str): The note's body matches the given terms.
post_id (int): A specific post.
... | python | def note_list(self, body_matches=None, post_id=None, post_tags_match=None,
creator_name=None, creator_id=None, is_active=None):
"""Return list of notes.
Parameters:
body_matches (str): The note's body matches the given terms.
post_id (int): A specific post.
... | [
"def",
"note_list",
"(",
"self",
",",
"body_matches",
"=",
"None",
",",
"post_id",
"=",
"None",
",",
"post_tags_match",
"=",
"None",
",",
"creator_name",
"=",
"None",
",",
"creator_id",
"=",
"None",
",",
"is_active",
"=",
"None",
")",
":",
"params",
"=",... | Return list of notes.
Parameters:
body_matches (str): The note's body matches the given terms.
post_id (int): A specific post.
post_tags_match (str): The note's post's tags match the given terms.
creator_name (str): The creator's name. Exact match.
cr... | [
"Return",
"list",
"of",
"notes",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L721-L741 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.note_versions | def note_versions(self, updater_id=None, post_id=None, note_id=None):
"""Get list of note versions.
Parameters:
updater_id (int):
post_id (int):
note_id (int):
"""
params = {
'search[updater_id]': updater_id,
'search[post_id]':... | python | def note_versions(self, updater_id=None, post_id=None, note_id=None):
"""Get list of note versions.
Parameters:
updater_id (int):
post_id (int):
note_id (int):
"""
params = {
'search[updater_id]': updater_id,
'search[post_id]':... | [
"def",
"note_versions",
"(",
"self",
",",
"updater_id",
"=",
"None",
",",
"post_id",
"=",
"None",
",",
"note_id",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'search[updater_id]'",
":",
"updater_id",
",",
"'search[post_id]'",
":",
"post_id",
",",
"'search[no... | Get list of note versions.
Parameters:
updater_id (int):
post_id (int):
note_id (int): | [
"Get",
"list",
"of",
"note",
"versions",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L817-L830 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.user_list | def user_list(self, name=None, name_matches=None, min_level=None,
max_level=None, level=None, user_id=None, order=None):
"""Function to get a list of users or a specific user.
Levels:
Users have a number attribute called level representing their role.
The curre... | python | def user_list(self, name=None, name_matches=None, min_level=None,
max_level=None, level=None, user_id=None, order=None):
"""Function to get a list of users or a specific user.
Levels:
Users have a number attribute called level representing their role.
The curre... | [
"def",
"user_list",
"(",
"self",
",",
"name",
"=",
"None",
",",
"name_matches",
"=",
"None",
",",
"min_level",
"=",
"None",
",",
"max_level",
"=",
"None",
",",
"level",
"=",
"None",
",",
"user_id",
"=",
"None",
",",
"order",
"=",
"None",
")",
":",
... | Function to get a list of users or a specific user.
Levels:
Users have a number attribute called level representing their role.
The current levels are:
Member 20, Gold 30, Platinum 31, Builder 32, Contributor 33,
Janitor 35, Moderator 40 and Admin 50.
P... | [
"Function",
"to",
"get",
"a",
"list",
"of",
"users",
"or",
"a",
"specific",
"user",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L832-L862 | train |
LuqueDaniel/pybooru | pybooru/api_danbooru.py | DanbooruApi_Mixin.pool_list | def pool_list(self, name_matches=None, pool_ids=None, category=None,
description_matches=None, creator_name=None, creator_id=None,
is_deleted=None, is_active=None, order=None):
"""Get a list of pools.
Parameters:
name_matches (str):
pool_ids (... | python | def pool_list(self, name_matches=None, pool_ids=None, category=None,
description_matches=None, creator_name=None, creator_id=None,
is_deleted=None, is_active=None, order=None):
"""Get a list of pools.
Parameters:
name_matches (str):
pool_ids (... | [
"def",
"pool_list",
"(",
"self",
",",
"name_matches",
"=",
"None",
",",
"pool_ids",
"=",
"None",
",",
"category",
"=",
"None",
",",
"description_matches",
"=",
"None",
",",
"creator_name",
"=",
"None",
",",
"creator_id",
"=",
"None",
",",
"is_deleted",
"="... | Get a list of pools.
Parameters:
name_matches (str):
pool_ids (str): Can search for multiple ID's at once, separated by
commas.
description_matches (str):
creator_name (str):
creator_id (int):
is_active (bool): C... | [
"Get",
"a",
"list",
"of",
"pools",
"."
] | 60cd5254684d293b308f0b11b8f4ac2dce101479 | https://github.com/LuqueDaniel/pybooru/blob/60cd5254684d293b308f0b11b8f4ac2dce101479/pybooru/api_danbooru.py#L872-L900 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.