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_documentation_string
stringlengths
1
47.2k
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...
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.
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']...
Returns XML for the article corresponding to a PMC ID.
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...
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
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...
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...
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, ...
Get extractions from one of the examples in `cag_examples`.
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)
Make graphs from all the examples in cag_examples.
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 ...
Assemble an Agent object to text.
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...
Join a list of words in a gramatically correct way.
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...
Assemble ActiveForm statements into text.
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: ...
Assemble Modification statements into text.
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)
Assemble Association statements into text.
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)
Assemble Complex statements into text.
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...
Assemble Autophosphorylation statements into text.
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...
Assemble RegulateActivity statements into text.
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 ' ...
Assemble RegulateAmount statements into text.
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...
Assemble Translocation statements into text.
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)
Assemble Gap statements into text.
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)
Assemble Gef statements into text.
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) ...
Assemble a Conversion statement into text.
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_...
Assemble an Influence statement into text.
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
Make a sentence from a piece of text.
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...
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.
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...
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.
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. ...
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.
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...
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...
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...
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 : ...
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() ...
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
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) ...
Add glyph and member glyphs for a PySB ComplexPattern.
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 ...
Add glyph for a PySB MonomerPattern.
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...
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.
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...
Compile all ID->label mappings and save to a TSV file. Parameters ---------- g : rdflib.Graph RDF graph containing GO data.
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...
Gets the NDEx credentials from the dict, or tries the environment if None
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...
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...
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...
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...
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...
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...
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...
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...
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...
Initialize the model for simulation, possibly given a config file. Parameters ---------- cfg_file : Optional[str] The name of the configuration file to load, optional.
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...
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.
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 ...
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
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...
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
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...
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
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 ...
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
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...
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.
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. """ ...
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.
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
Return the external name of a variable mapped from inside.
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 --------...
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...
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') ...
Run sparser on a single pmid.
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'), ...
Run sparser on the pmids in pmids_unread.
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( ...
Run the sparser reader on the pmids in pmid_list.
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...
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)
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) ...
Run reach on a list of pmids.
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
Get all the descendants of a parent class, recursively.
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 ...
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...
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\...
Get a statement class given the name of the statement class.
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)}
Get uuids unresolved in support from stmts from stmts_from_json.
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...
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.
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...
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 ...
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
Set all the Evidence stmt_tag to my deep matches-key hash.
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...
Get the canonicallized agent list.
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...
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 ...
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='') ...
Return Statement as a networkx graph.
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...
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...
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...
Helper function to turn csv rows into dicts.
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...
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.
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...
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.
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. ...
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.
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...
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...
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...
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...
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...
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 ...
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 ...
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....
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...
Return Hume grounding.
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 ...
Find all relevant relation elements and return them in a list.
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...
Populate sentences attribute with a dict keyed by document id.
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...
Get place and time info from the json for this entity.
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...
Return Concept from a Hume entity.
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(...
Return an INDRA Event based on an event entry.
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'] ...
Return the Evidence object for the INDRA Statement.
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 ---------- ...
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...
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...
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 ...
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...
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...
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...
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
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...
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...
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', ',', '/'] ...
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
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...
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...
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 ...
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 ...
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...
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...
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...
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...
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 ----...
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...
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 ...
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 ------...
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...
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...
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 ...
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...
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]...
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...
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 ...
Generate statements by expanding members of families and complexes.
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)
Load an ontology formatted like Eidos' from github.
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
Convert the YAML object into an RDF Graph object.
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
Return a YAML object loaded from a YAML file URL.
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...
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 ...
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...
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 ...
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...
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...
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 :...
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 ...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/isi/preprocessor.py#L144-L202