repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
sorgerlab/indra
indra/literature/pmc_client.py
id_lookup
def id_lookup(paper_id, idtype=None): """This function takes a Pubmed ID, Pubmed Central ID, or DOI and use the Pubmed ID mapping service and looks up all other IDs from one of these. The IDs are returned in a dictionary.""" if idtype is not None and idtype not in ('pmid', 'pmcid', 'doi'): r...
python
def id_lookup(paper_id, idtype=None): """This function takes a Pubmed ID, Pubmed Central ID, or DOI and use the Pubmed ID mapping service and looks up all other IDs from one of these. The IDs are returned in a dictionary.""" if idtype is not None and idtype not in ('pmid', 'pmcid', 'doi'): r...
[ "def", "id_lookup", "(", "paper_id", ",", "idtype", "=", "None", ")", ":", "if", "idtype", "is", "not", "None", "and", "idtype", "not", "in", "(", "'pmid'", ",", "'pmcid'", ",", "'doi'", ")", ":", "raise", "ValueError", "(", "\"Invalid idtype %s; must be '...
This function takes a Pubmed ID, Pubmed Central ID, or DOI and use the Pubmed ID mapping service and looks up all other IDs from one of these. The IDs are returned in a dictionary.
[ "This", "function", "takes", "a", "Pubmed", "ID", "Pubmed", "Central", "ID", "or", "DOI", "and", "use", "the", "Pubmed", "ID", "mapping", "service", "and", "looks", "up", "all", "other", "IDs", "from", "one", "of", "these", ".", "The", "IDs", "are", "r...
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/pmc_client.py#L40-L74
sorgerlab/indra
indra/literature/pmc_client.py
get_xml
def get_xml(pmc_id): """Returns XML for the article corresponding to a PMC ID.""" if pmc_id.upper().startswith('PMC'): pmc_id = pmc_id[3:] # Request params params = {} params['verb'] = 'GetRecord' params['identifier'] = 'oai:pubmedcentral.nih.gov:%s' % pmc_id params['metadataPrefix']...
python
def get_xml(pmc_id): """Returns XML for the article corresponding to a PMC ID.""" if pmc_id.upper().startswith('PMC'): pmc_id = pmc_id[3:] # Request params params = {} params['verb'] = 'GetRecord' params['identifier'] = 'oai:pubmedcentral.nih.gov:%s' % pmc_id params['metadataPrefix']...
[ "def", "get_xml", "(", "pmc_id", ")", ":", "if", "pmc_id", ".", "upper", "(", ")", ".", "startswith", "(", "'PMC'", ")", ":", "pmc_id", "=", "pmc_id", "[", "3", ":", "]", "# Request params", "params", "=", "{", "}", "params", "[", "'verb'", "]", "=...
Returns XML for the article corresponding to a PMC ID.
[ "Returns", "XML", "for", "the", "article", "corresponding", "to", "a", "PMC", "ID", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/pmc_client.py#L81-L109
sorgerlab/indra
indra/literature/pmc_client.py
extract_paragraphs
def extract_paragraphs(xml_string): """Returns list of paragraphs in an NLM XML. Parameters ---------- xml_string : str String containing valid NLM XML. Returns ------- list of str List of extracted paragraphs in an NLM XML """ tree = etree.fromstring(xml_string.enc...
python
def extract_paragraphs(xml_string): """Returns list of paragraphs in an NLM XML. Parameters ---------- xml_string : str String containing valid NLM XML. Returns ------- list of str List of extracted paragraphs in an NLM XML """ tree = etree.fromstring(xml_string.enc...
[ "def", "extract_paragraphs", "(", "xml_string", ")", ":", "tree", "=", "etree", ".", "fromstring", "(", "xml_string", ".", "encode", "(", "'utf-8'", ")", ")", "paragraphs", "=", "[", "]", "# In NLM xml, all plaintext is within <p> tags, and is the only thing", "# that...
Returns list of paragraphs in an NLM XML. Parameters ---------- xml_string : str String containing valid NLM XML. Returns ------- list of str List of extracted paragraphs in an NLM XML
[ "Returns", "list", "of", "paragraphs", "in", "an", "NLM", "XML", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/pmc_client.py#L132-L156
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", "# Check args", "if", "source_type", "not", "in", "(", "'fulltext'", ",", "'oa_xml'", ",", "'oa_txt'", ",", "'auth_xml'", ")", ":", "raise", "ValueError", "("...
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/pmc_client.py#L159-L188
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", ")", ":", "with", "open", "(", "fname", ",", "'r'", ")", "as", "f", ":", "sentences", "=", "f", ".", "read", "(", ")", ".", "splitlines", "(", ")", "rdf_xml_dict", "=", "{", "}", "for", "sentence", "in"...
Get extractions from one of the examples in `cag_examples`.
[ "Get", "extractions", "from", "one", "of", "the", "examples", "in", "cag_examples", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/cwms/util.py#L63-L77
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", "(", ")", ":", "cag_example_rdfs", "=", "{", "}", "for", "i", ",", "fname", "in", "enumerate", "(", "os", ".", "listdir", "(", "'cag_examples'", ")", ")", ":", "cag_example_rdfs", "[", "i", "+", "1", "]", "=", "get_example_e...
Make graphs from all the examples in cag_examples.
[ "Make", "graphs", "from", "all", "the", "examples", "in", "cag_examples", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/cwms/util.py#L80-L85
sorgerlab/indra
indra/assemblers/english/assembler.py
_assemble_agent_str
def _assemble_agent_str(agent): """Assemble an Agent object to text.""" agent_str = agent.name # Only do the more detailed assembly for molecular agents if not isinstance(agent, ist.Agent): return agent_str # Handle mutation conditions if agent.mutations: is_generic = False ...
python
def _assemble_agent_str(agent): """Assemble an Agent object to text.""" agent_str = agent.name # Only do the more detailed assembly for molecular agents if not isinstance(agent, ist.Agent): return agent_str # Handle mutation conditions if agent.mutations: is_generic = False ...
[ "def", "_assemble_agent_str", "(", "agent", ")", ":", "agent_str", "=", "agent", ".", "name", "# Only do the more detailed assembly for molecular agents", "if", "not", "isinstance", "(", "agent", ",", "ist", ".", "Agent", ")", ":", "return", "agent_str", "# Handle m...
Assemble an Agent object to text.
[ "Assemble", "an", "Agent", "object", "to", "text", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L85-L181
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L184-L197
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L200-L219
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L222-L243
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L246-L251
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L254-L258
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L261-L273
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L276-L285
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L288-L303
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L306-L314
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L317-L322
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L325-L330
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L333-L344
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", ")", "# Note that n is prepended to increase...
Assemble an Influence statement into text.
[ "Assemble", "an", "Influence", "statement", "into", "text", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L347-L364
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", ")", ":", "#Make sure first letter is capitalized", "txt", "=", "txt", ".", "strip", "(", "' '", ")", "txt", "=", "txt", "[", "0", "]", ".", "upper", "(", ")", "+", "txt", "[", "1", ":", "]", "+", "'.'", "return",...
Make a sentence from a piece of text.
[ "Make", "a", "sentence", "from", "a", "piece", "of", "text", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L367-L372
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...
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L394-L402
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/english/assembler.py#L41-L82
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L58-L69
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L71-L106
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L108-L123
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L125-L136
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", ")", ":", "# Make the main glyph for the agent", "monomer_glyphs", "=", "[", "]", "for", "monomer_pattern", "in", "pattern", ".", "monomer_patterns", ":", "glyph", "=", "self", ".", "_glyph_for_monomer_...
Add glyph and member glyphs for a PySB ComplexPattern.
[ "Add", "glyph", "and", "member", "glyphs", "for", "a", "PySB", "ComplexPattern", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L317-L335
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", ")", "# Handle sources and sinks", "if", ...
Add glyph for a PySB MonomerPattern.
[ "Add", "glyph", "for", "a", "PySB", "MonomerPattern", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L337-L372
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/go_client.py#L41-L60
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", "+", "\"\"\"\n SELECT ?id ?label\n WHERE {\n ?class oboInOwl:id ?id .\n ?class rdfs:label ?label\n }\n \"\"\""...
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/go_client.py#L80-L103
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" ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/ndex_client.py#L17-L29
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/ndex_client.py#L32-L89
sorgerlab/indra
indra/databases/ndex_client.py
create_network
def create_network(cx_str, ndex_cred=None, private=True): """Creates a new NDEx network of the assembled CX model. To upload the assembled CX model to NDEx, you need to have a registered account on NDEx (http://ndexbio.org/) and have the `ndex` python package installed. The uploaded network is priv...
python
def create_network(cx_str, ndex_cred=None, private=True): """Creates a new NDEx network of the assembled CX model. To upload the assembled CX model to NDEx, you need to have a registered account on NDEx (http://ndexbio.org/) and have the `ndex` python package installed. The uploaded network is priv...
[ "def", "create_network", "(", "cx_str", ",", "ndex_cred", "=", "None", ",", "private", "=", "True", ")", ":", "username", ",", "password", "=", "get_default_ndex_cred", "(", "ndex_cred", ")", "nd", "=", "ndex2", ".", "client", ".", "Ndex2", "(", "'http://p...
Creates a new NDEx network of the assembled CX model. To upload the assembled CX model to NDEx, you need to have a registered account on NDEx (http://ndexbio.org/) and have the `ndex` python package installed. The uploaded network is private by default. Parameters ---------- ndex_cred : di...
[ "Creates", "a", "new", "NDEx", "network", "of", "the", "assembled", "CX", "model", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/ndex_client.py#L92-L131
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/ndex_client.py#L134-L189
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" ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/ndex_client.py#L192-L219
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L74-L85
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", ")", ":", "# EMELI passes dt = -1 so we need to handle that here", "dt", "=", "dt", "if", "(", "dt", "is", "not", "None", "and", "dt", ">", "0", ")", "else", "self", ".", "dt", "tspan", "=", "[", "0...
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L87-L107
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L114-L131
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L147-L163
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L203-L215
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", ")", ":", "# Return all the variables that aren't input variables", "all_vars", "=", "list", "(", "self", ".", "species_name_map", ".", "keys", "(", ")", ")", "output_vars", "=", "list", "(", "set", "(", "all_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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L217-L232
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L336-L391
sorgerlab/indra
indra/assemblers/pysb/bmi_wrapper.py
BMIModel.export_into_python
def export_into_python(self): """Write the model into a pickle and create a module that loads it. The model basically exports itself as a pickle file and a Python file is then written which loads the pickle file. This allows importing the model in the simulation workflow. """ ...
python
def export_into_python(self): """Write the model into a pickle and create a module that loads it. The model basically exports itself as a pickle file and a Python file is then written which loads the pickle file. This allows importing the model in the simulation workflow. """ ...
[ "def", "export_into_python", "(", "self", ")", ":", "pkl_path", "=", "self", ".", "model", ".", "name", "+", "'.pkl'", "with", "open", "(", "pkl_path", ",", "'wb'", ")", "as", "fh", ":", "pickle", ".", "dump", "(", "self", ",", "fh", ",", "protocol",...
Write the model into a pickle and create a module that loads it. The model basically exports itself as a pickle file and a Python file is then written which loads the pickle file. This allows importing the model in the simulation workflow.
[ "Write", "the", "model", "into", "a", "pickle", "and", "create", "a", "module", "that", "loads", "it", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L393-L411
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/bmi_wrapper.py#L417-L422
sorgerlab/indra
indra/tools/reading/pmid_reading/read_pmids.py
join_json_files
def join_json_files(prefix): """Join different REACH output JSON files into a single JSON object. The output of REACH is broken into three files that need to be joined before processing. Specifically, there will be three files of the form: `<prefix>.uaz.<subcategory>.json`. Parameters --------...
python
def join_json_files(prefix): """Join different REACH output JSON files into a single JSON object. The output of REACH is broken into three files that need to be joined before processing. Specifically, there will be three files of the form: `<prefix>.uaz.<subcategory>.json`. Parameters --------...
[ "def", "join_json_files", "(", "prefix", ")", ":", "try", ":", "with", "open", "(", "prefix", "+", "'.uaz.entities.json'", ",", "'rt'", ")", "as", "f", ":", "entities", "=", "json", ".", "load", "(", "f", ")", "with", "open", "(", "prefix", "+", "'.u...
Join different REACH output JSON files into a single JSON object. The output of REACH is broken into three files that need to be joined before processing. Specifically, there will be three files of the form: `<prefix>.uaz.<subcategory>.json`. Parameters ---------- prefix : str The abso...
[ "Join", "different", "REACH", "output", "JSON", "files", "into", "a", "single", "JSON", "object", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/pmid_reading/read_pmids.py#L140-L170
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", ")", ":", "signal", ".", "signal", "(", "signal", ".", "SIGALRM", ",", "_timeout_handler", ")", "signal", "...
Run sparser on a single pmid.
[ "Run", "sparser", "on", "a", "single", "pmid", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/pmid_reading/read_pmids.py#L353-L402
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", ")", ":", "if", "sparser_version", "is", "None", ":", "sparser_version", "=", "sparser", ".", "get_version", "(", ")", "stmts", "=", "{", "}", "now",...
Run sparser on the pmids in pmids_unread.
[ "Run", "sparser", "on", "the", "pmids", "in", "pmids_unread", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/pmid_reading/read_pmids.py#L405-L441
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", ")", ":", "reader_version", "=", "sparser", "....
Run the sparser reader on the pmids in pmid_list.
[ "Run", "the", "sparser", "reader", "on", "the", "pmids", "in", "pmid_list", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/pmid_reading/read_pmids.py#L452-L502
sorgerlab/indra
indra/tools/reading/pmid_reading/read_pmids.py
upload_process_reach_files
def upload_process_reach_files(output_dir, pmid_info_dict, reader_version, num_cores): # At this point, we have a directory full of JSON files # Collect all the prefixes into a set, then iterate over the prefixes # Collect prefixes json_files = glob.glob(os.path.join(outp...
python
def upload_process_reach_files(output_dir, pmid_info_dict, reader_version, num_cores): # At this point, we have a directory full of JSON files # Collect all the prefixes into a set, then iterate over the prefixes # Collect prefixes json_files = glob.glob(os.path.join(outp...
[ "def", "upload_process_reach_files", "(", "output_dir", ",", "pmid_info_dict", ",", "reader_version", ",", "num_cores", ")", ":", "# At this point, we have a directory full of JSON files", "# Collect all the prefixes into a set, then iterate over the prefixes", "# Collect prefixes", "j...
logger.info('Uploaded REACH JSON for %d files to S3 (%d failures)' % (num_uploaded, num_failures)) failures_file = os.path.join(output_dir, 'failures.txt') with open(failures_file, 'wt') as f: for fail in failures: f.write('%s\n' % fail)
[ "logger", ".", "info", "(", "Uploaded", "REACH", "JSON", "for", "%d", "files", "to", "S3", "(", "%d", "failures", ")", "%", "(", "num_uploaded", "num_failures", "))", "failures_file", "=", "os", ".", "path", ".", "join", "(", "output_dir", "failures", "....
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/pmid_reading/read_pmids.py#L563-L612
sorgerlab/indra
indra/tools/reading/pmid_reading/read_pmids.py
run_reach
def run_reach(pmid_list, base_dir, num_cores, start_index, end_index, force_read, force_fulltext, cleanup=False, verbose=True): """Run reach on a list of pmids.""" logger.info('Running REACH with force_read=%s' % force_read) logger.info('Running REACH with force_fulltext=%s' % force_fulltext) ...
python
def run_reach(pmid_list, base_dir, num_cores, start_index, end_index, force_read, force_fulltext, cleanup=False, verbose=True): """Run reach on a list of pmids.""" logger.info('Running REACH with force_read=%s' % force_read) logger.info('Running REACH with force_fulltext=%s' % force_fulltext) ...
[ "def", "run_reach", "(", "pmid_list", ",", "base_dir", ",", "num_cores", ",", "start_index", ",", "end_index", ",", "force_read", ",", "force_fulltext", ",", "cleanup", "=", "False", ",", "verbose", "=", "True", ")", ":", "logger", ".", "info", "(", "'Runn...
Run reach on a list of pmids.
[ "Run", "reach", "on", "a", "list", "of", "pmids", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/pmid_reading/read_pmids.py#L615-L719
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L2454-L2460
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L2465-L2494
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L2501-L2508
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L2516-L2519
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L2522-L2532
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L269-L317
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L319-L324
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L336-L354
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__", "# Original comment: For backwards compatibility, could be removed later", "all_stmts", "=", "[", "self", "]", "+", "self", ".", "...
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L421-L466
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L484-L523
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/statements.py#L525-L553
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/lincs_client.py#L146-L157
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/lincs_client.py#L35-L52
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 there is no 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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/lincs_client.py#L54-L80
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", ")", ":", "# TODO: We could get phosphorylation states from the protein data.", "refs", "=", "{", "'HMS-LINCS'", ":", "hms_lincs_id", "}", "entry", "=", "self", ".", "_get_entry_by_id", "(", "self", ".", "_p...
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/lincs_client.py#L82-L106
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", "# Check for cached BEL stmt file", "if", "self", "."...
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/gene_network.py#L51-L94
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 we're using a cache, initialize the appropriate filenames", "if", "self", ".", "basename", "is", "not", "No...
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/gene_network.py#L96-L175
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/gene_network.py#L177-L198
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", ")", ":", "# First round of preassembly: remove duplicates before sitemapping", "pa1", "=", "Preassembler", "(", "hierarchies", ",", "stmts", ")", "logger", ".", "info", "(", "\"...
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/gene_network.py#L200-L276
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L230-L277
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", ")", ":", "# Get all extractions", "extractions", "=", "list", "(", "self", ".", "tree", ".", "execute", "(", "\"$.extractions[(@.@type is 'Extraction')]\"", ")", ")", "# Get relations from extractions", "relations", "=", "[", "]...
Find all relevant relation elements and return them in a list.
[ "Find", "all", "relevant", "relation", "elements", "and", "return", "them", "in", "a", "list", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L68-L95
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L97-L103
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", "# Look for time and place contexts.", "for", "argument", "in", "entity", "[", "\"arguments\"", "]", ":", "if", "argument", "[", "\"type\"", "]...
Get place and time info from the json for this entity.
[ "Get", "place", "and", "time", "info", "from", "the", "json", "for", "this", "entity", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L105-L139
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", ")", ":", "# 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...
Return Concept from a Hume entity.
[ "Return", "Concept", "from", "a", "Hume", "entity", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L141-L163
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L165-L175
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'", ")", "# First try looking up the full sentence through provenance", "doc_id", "=", "provenance", "[", "0", "]", "[", "'docu...
Return the Evidence object for the INDRA Statement.
[ "Return", "the", "Evidence", "object", "for", "the", "INDRA", "Statement", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/processor.py#L177-L199
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" ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L62-L145
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L893-L913
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", ")", ":", "# Convert a urn to a db_refs dictionary", "if", "urn", "is", "None", ":", "return", "{", "}", ",", "None", "m", "=", "URN_PATT", ".", "match", "(", "urn", ")", "if", "m", "is", "None", ":", "return", "None...
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L976-L1079
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L1109-L1125
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", "=", "{", "}", "# Ite...
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L1128-L1168
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L163-L190
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L328-L381
sorgerlab/indra
indra/sources/medscan/processor.py
MedscanProcessor.process_relation
def process_relation(self, relation, last_relation): """Process a relation into an INDRA statement. Parameters ---------- relation : MedscanRelation The relation to process (a CONTROL svo with normalized verb) last_relation : MedscanRelation The relation ...
python
def process_relation(self, relation, last_relation): """Process a relation into an INDRA statement. Parameters ---------- relation : MedscanRelation The relation to process (a CONTROL svo with normalized verb) last_relation : MedscanRelation The relation ...
[ "def", "process_relation", "(", "self", ",", "relation", ",", "last_relation", ")", ":", "subj_res", "=", "self", ".", "agent_from_entity", "(", "relation", ",", "relation", ".", "subj", ")", "obj_res", "=", "self", ".", "agent_from_entity", "(", "relation", ...
Process a relation into an INDRA statement. Parameters ---------- relation : MedscanRelation The relation to process (a CONTROL svo with normalized verb) last_relation : MedscanRelation The relation immediately proceding the relation to process within ...
[ "Process", "a", "relation", "into", "an", "INDRA", "statement", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L531-L681
sorgerlab/indra
indra/sources/medscan/processor.py
MedscanProcessor.agent_from_entity
def agent_from_entity(self, relation, entity_id): """Create a (potentially grounded) INDRA Agent object from a given Medscan entity describing the subject or object. Uses helper functions to convert a Medscan URN to an INDRA db_refs grounding dictionary. If the entity has prope...
python
def agent_from_entity(self, relation, entity_id): """Create a (potentially grounded) INDRA Agent object from a given Medscan entity describing the subject or object. Uses helper functions to convert a Medscan URN to an INDRA db_refs grounding dictionary. If the entity has prope...
[ "def", "agent_from_entity", "(", "self", ",", "relation", ",", "entity_id", ")", ":", "# Extract sentence tags mapping ids to the text. We refer to this", "# mapping only if the entity doesn't appear in the grounded entity", "# list", "tags", "=", "_extract_sentence_tags", "(", "re...
Create a (potentially grounded) INDRA Agent object from a given Medscan entity describing the subject or object. Uses helper functions to convert a Medscan URN to an INDRA db_refs grounding dictionary. If the entity has properties indicating that it is a protein with a mutation...
[ "Create", "a", "(", "potentially", "grounded", ")", "INDRA", "Agent", "object", "from", "a", "given", "Medscan", "entity", "describing", "the", "subject", "or", "object", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/processor.py#L683-L849
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/util/script_tools.py#L11-L76
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/newsapi_client.py#L29-L63
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/api.py#L12-L30
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/api.py#L33-L65
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/api.py#L68-L91
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", ...
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/read_files.py#L30-L59
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", ":", "# Put together the lists of families, with their members. E.g.,", "# for a statement involving RAF and MEK, should return a list of", "# tuples like [(...
Generate statements by expanding members of families and complexes.
[ "Generate", "statements", "by", "expanding", "members", "of", "families", "and", "complexes", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/expand_families.py#L22-L69
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/preassembler/make_eidos_hume_ontologies.py#L69-L73
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/preassembler/make_eidos_hume_ontologies.py#L76-L83
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/preassembler/make_eidos_hume_ontologies.py#L86-L92
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/preprocessor.py#L54-L80
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/preprocessor.py#L82-L120
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/preprocessor.py#L122-L142
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", ")", ":", "# Create a temporary directory", "tmp_dir", "=", "tempfile", ".", "mkdtemp", "(", "'indra_isi_nxml2txt_output'", ")", "# Run nxml2txt", "if", "nxml2txt_path", ...
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", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/preprocessor.py#L144-L202