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/sources/hume/visualize_causal.py
get_sourced_from
def get_sourced_from(entry): """Get a list of values from the source_from attribute""" sourced_from = 'http://worldmodelers.com/DataProvenance#sourced_from' if sourced_from in entry: values = entry[sourced_from] values = [i['@id'] for i in values] return values
python
def get_sourced_from(entry): """Get a list of values from the source_from attribute""" sourced_from = 'http://worldmodelers.com/DataProvenance#sourced_from' if sourced_from in entry: values = entry[sourced_from] values = [i['@id'] for i in values] return values
Get a list of values from the source_from attribute
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/visualize_causal.py#L127-L134
sorgerlab/indra
indra/sources/hume/visualize_causal.py
get_entry_compact_text_repr
def get_entry_compact_text_repr(entry, entries): """If the entry has a text value, return that. If the entry has a source_from value, return the text value of the source. Otherwise, return None.""" text = get_shortest_text_value(entry) if text is not None: return text else: sourc...
python
def get_entry_compact_text_repr(entry, entries): """If the entry has a text value, return that. If the entry has a source_from value, return the text value of the source. Otherwise, return None.""" text = get_shortest_text_value(entry) if text is not None: return text else: sourc...
If the entry has a text value, return that. If the entry has a source_from value, return the text value of the source. Otherwise, return None.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/visualize_causal.py#L137-L154
sorgerlab/indra
indra/sources/hume/visualize_causal.py
get_entity_type
def get_entity_type(entry): """Given a JSON-LD entry, returns the abbreviated @type and the text attribute that has the shortest length. Parameters ---------- entry: dict A JSON-LD entry parsed into a nested python dictionary via the json module Returns ------- short_ty...
python
def get_entity_type(entry): """Given a JSON-LD entry, returns the abbreviated @type and the text attribute that has the shortest length. Parameters ---------- entry: dict A JSON-LD entry parsed into a nested python dictionary via the json module Returns ------- short_ty...
Given a JSON-LD entry, returns the abbreviated @type and the text attribute that has the shortest length. Parameters ---------- entry: dict A JSON-LD entry parsed into a nested python dictionary via the json module Returns ------- short_type: str The shortest type ...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/hume/visualize_causal.py#L157-L177
sorgerlab/indra
indra/sources/sparser/api.py
process_text
def process_text(text, output_fmt='json', outbuf=None, cleanup=True, key='', **kwargs): """Return processor with Statements extracted by reading text with Sparser. Parameters ---------- text : str The text to be processed output_fmt: Optional[str] The output format ...
python
def process_text(text, output_fmt='json', outbuf=None, cleanup=True, key='', **kwargs): """Return processor with Statements extracted by reading text with Sparser. Parameters ---------- text : str The text to be processed output_fmt: Optional[str] The output format ...
Return processor with Statements extracted by reading text with Sparser. Parameters ---------- text : str The text to be processed output_fmt: Optional[str] The output format to obtain from Sparser, with the two options being 'json' and 'xml'. Default: 'json' outbuf : Option...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sparser/api.py#L31-L59
sorgerlab/indra
indra/sources/sparser/api.py
process_nxml_str
def process_nxml_str(nxml_str, output_fmt='json', outbuf=None, cleanup=True, key='', **kwargs): """Return processor with Statements extracted by reading an NXML string. Parameters ---------- nxml_str : str The string value of the NXML-formatted paper to be read. output_...
python
def process_nxml_str(nxml_str, output_fmt='json', outbuf=None, cleanup=True, key='', **kwargs): """Return processor with Statements extracted by reading an NXML string. Parameters ---------- nxml_str : str The string value of the NXML-formatted paper to be read. output_...
Return processor with Statements extracted by reading an NXML string. Parameters ---------- nxml_str : str The string value of the NXML-formatted paper to be read. output_fmt: Optional[str] The output format to obtain from Sparser, with the two options being 'json' and 'xml'. De...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sparser/api.py#L62-L97
sorgerlab/indra
indra/sources/sparser/api.py
process_nxml_file
def process_nxml_file(fname, output_fmt='json', outbuf=None, cleanup=True, **kwargs): """Return processor with Statements extracted by reading an NXML file. Parameters ---------- fname : str The path to the NXML file to be read. output_fmt: Optional[str] The ou...
python
def process_nxml_file(fname, output_fmt='json', outbuf=None, cleanup=True, **kwargs): """Return processor with Statements extracted by reading an NXML file. Parameters ---------- fname : str The path to the NXML file to be read. output_fmt: Optional[str] The ou...
Return processor with Statements extracted by reading an NXML file. Parameters ---------- fname : str The path to the NXML file to be read. output_fmt: Optional[str] The output format to obtain from Sparser, with the two options being 'json' and 'xml'. Default: 'json' outbuf...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sparser/api.py#L100-L134
sorgerlab/indra
indra/sources/sparser/api.py
process_sparser_output
def process_sparser_output(output_fname, output_fmt='json'): """Return a processor with Statements extracted from Sparser XML or JSON Parameters ---------- output_fname : str The path to the Sparser output file to be processed. The file can either be JSON or XML output from Sparser, wit...
python
def process_sparser_output(output_fname, output_fmt='json'): """Return a processor with Statements extracted from Sparser XML or JSON Parameters ---------- output_fname : str The path to the Sparser output file to be processed. The file can either be JSON or XML output from Sparser, wit...
Return a processor with Statements extracted from Sparser XML or JSON Parameters ---------- output_fname : str The path to the Sparser output file to be processed. The file can either be JSON or XML output from Sparser, with the output_fmt parameter defining what format is assumed t...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sparser/api.py#L137-L167
sorgerlab/indra
indra/sources/sparser/api.py
process_xml
def process_xml(xml_str): """Return processor with Statements extracted from a Sparser XML. Parameters ---------- xml_str : str The XML string obtained by reading content with Sparser, using the 'xml' output mode. Returns ------- sp : SparserXMLProcessor A SparserXM...
python
def process_xml(xml_str): """Return processor with Statements extracted from a Sparser XML. Parameters ---------- xml_str : str The XML string obtained by reading content with Sparser, using the 'xml' output mode. Returns ------- sp : SparserXMLProcessor A SparserXM...
Return processor with Statements extracted from a Sparser XML. Parameters ---------- xml_str : str The XML string obtained by reading content with Sparser, using the 'xml' output mode. Returns ------- sp : SparserXMLProcessor A SparserXMLProcessor which has extracted St...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sparser/api.py#L190-L212
sorgerlab/indra
indra/sources/sparser/api.py
run_sparser
def run_sparser(fname, output_fmt, outbuf=None, timeout=600): """Return the path to reading output after running Sparser reading. Parameters ---------- fname : str The path to an input file to be processed. Due to the Spaser executable's assumptions, the file name needs to start with PM...
python
def run_sparser(fname, output_fmt, outbuf=None, timeout=600): """Return the path to reading output after running Sparser reading. Parameters ---------- fname : str The path to an input file to be processed. Due to the Spaser executable's assumptions, the file name needs to start with PM...
Return the path to reading output after running Sparser reading. Parameters ---------- fname : str The path to an input file to be processed. Due to the Spaser executable's assumptions, the file name needs to start with PMC and should be an NXML formatted file. output_fmt : Opti...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sparser/api.py#L215-L287
sorgerlab/indra
indra/sources/sparser/api.py
get_version
def get_version(): """Return the version of the Sparser executable on the path. Returns ------- version : str The version of Sparser that is found on the Sparser path. """ assert sparser_path is not None, "Sparser path is not defined." with open(os.path.join(sparser_path, 'version.t...
python
def get_version(): """Return the version of the Sparser executable on the path. Returns ------- version : str The version of Sparser that is found on the Sparser path. """ assert sparser_path is not None, "Sparser path is not defined." with open(os.path.join(sparser_path, 'version.t...
Return the version of the Sparser executable on the path. Returns ------- version : str The version of Sparser that is found on the Sparser path.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sparser/api.py#L290-L301
sorgerlab/indra
indra/sources/sparser/api.py
make_nxml_from_text
def make_nxml_from_text(text): """Return raw text wrapped in NXML structure. Parameters ---------- text : str The raw text content to be wrapped in an NXML structure. Returns ------- nxml_str : str The NXML string wrapping the raw text input. """ text = _escape_xml(...
python
def make_nxml_from_text(text): """Return raw text wrapped in NXML structure. Parameters ---------- text : str The raw text content to be wrapped in an NXML structure. Returns ------- nxml_str : str The NXML string wrapping the raw text input. """ text = _escape_xml(...
Return raw text wrapped in NXML structure. Parameters ---------- text : str The raw text content to be wrapped in an NXML structure. Returns ------- nxml_str : str The NXML string wrapping the raw text input.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sparser/api.py#L304-L322
sorgerlab/indra
indra/databases/hgnc_client.py
get_hgnc_name
def get_hgnc_name(hgnc_id): """Return the HGNC symbol corresponding to the given HGNC ID. Parameters ---------- hgnc_id : str The HGNC ID to be converted. Returns ------- hgnc_name : str The HGNC symbol corresponding to the given HGNC ID. """ try: hgnc_name ...
python
def get_hgnc_name(hgnc_id): """Return the HGNC symbol corresponding to the given HGNC ID. Parameters ---------- hgnc_id : str The HGNC ID to be converted. Returns ------- hgnc_name : str The HGNC symbol corresponding to the given HGNC ID. """ try: hgnc_name ...
Return the HGNC symbol corresponding to the given HGNC ID. Parameters ---------- hgnc_id : str The HGNC ID to be converted. Returns ------- hgnc_name : str The HGNC symbol corresponding to the given HGNC ID.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/hgnc_client.py#L83-L107
sorgerlab/indra
indra/databases/hgnc_client.py
get_current_hgnc_id
def get_current_hgnc_id(hgnc_name): """Return the HGNC ID(s) corresponding to a current or outdate HGNC symbol. Parameters ---------- hgnc_name : str The HGNC symbol to be converted, possibly an outdated symbol. Returns ------- str or list of str or None If there is a singl...
python
def get_current_hgnc_id(hgnc_name): """Return the HGNC ID(s) corresponding to a current or outdate HGNC symbol. Parameters ---------- hgnc_name : str The HGNC symbol to be converted, possibly an outdated symbol. Returns ------- str or list of str or None If there is a singl...
Return the HGNC ID(s) corresponding to a current or outdate HGNC symbol. Parameters ---------- hgnc_name : str The HGNC symbol to be converted, possibly an outdated symbol. Returns ------- str or list of str or None If there is a single HGNC ID corresponding to the given curren...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/hgnc_client.py#L126-L147
sorgerlab/indra
indra/databases/hgnc_client.py
get_hgnc_entry
def get_hgnc_entry(hgnc_id): """Return the HGNC entry for the given HGNC ID from the web service. Parameters ---------- hgnc_id : str The HGNC ID to be converted. Returns ------- xml_tree : ElementTree The XML ElementTree corresponding to the entry for the given HGN...
python
def get_hgnc_entry(hgnc_id): """Return the HGNC entry for the given HGNC ID from the web service. Parameters ---------- hgnc_id : str The HGNC ID to be converted. Returns ------- xml_tree : ElementTree The XML ElementTree corresponding to the entry for the given HGN...
Return the HGNC entry for the given HGNC ID from the web service. Parameters ---------- hgnc_id : str The HGNC ID to be converted. Returns ------- xml_tree : ElementTree The XML ElementTree corresponding to the entry for the given HGNC ID.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/hgnc_client.py#L224-L244
sorgerlab/indra
indra/tools/reading/util/log_analysis_tools.py
analyze_reach_log
def analyze_reach_log(log_fname=None, log_str=None): """Return unifinished PMIDs given a log file name.""" assert bool(log_fname) ^ bool(log_str), 'Must specify log_fname OR log_str' started_patt = re.compile('Starting ([\d]+)') # TODO: it might be interesting to get the time it took to read # each ...
python
def analyze_reach_log(log_fname=None, log_str=None): """Return unifinished PMIDs given a log file name.""" assert bool(log_fname) ^ bool(log_str), 'Must specify log_fname OR log_str' started_patt = re.compile('Starting ([\d]+)') # TODO: it might be interesting to get the time it took to read # each ...
Return unifinished PMIDs given a log file name.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/util/log_analysis_tools.py#L6-L28
sorgerlab/indra
indra/tools/reading/util/log_analysis_tools.py
get_logs_from_db_reading
def get_logs_from_db_reading(job_prefix, reading_queue='run_db_reading_queue'): """Get the logs stashed on s3 for a particular reading.""" s3 = boto3.client('s3') gen_prefix = 'reading_results/%s/logs/%s' % (job_prefix, reading_queue) job_log_data = s3.list_objects_v2(Bucket='bigmech', ...
python
def get_logs_from_db_reading(job_prefix, reading_queue='run_db_reading_queue'): """Get the logs stashed on s3 for a particular reading.""" s3 = boto3.client('s3') gen_prefix = 'reading_results/%s/logs/%s' % (job_prefix, reading_queue) job_log_data = s3.list_objects_v2(Bucket='bigmech', ...
Get the logs stashed on s3 for a particular reading.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/util/log_analysis_tools.py#L36-L47
sorgerlab/indra
indra/tools/reading/util/log_analysis_tools.py
separate_reach_logs
def separate_reach_logs(log_str): """Get the list of reach logs from the overall logs.""" log_lines = log_str.splitlines() reach_logs = [] reach_lines = [] adding_reach_lines = False for l in log_lines[:]: if not adding_reach_lines and 'Beginning reach' in l: adding_reach_lin...
python
def separate_reach_logs(log_str): """Get the list of reach logs from the overall logs.""" log_lines = log_str.splitlines() reach_logs = [] reach_lines = [] adding_reach_lines = False for l in log_lines[:]: if not adding_reach_lines and 'Beginning reach' in l: adding_reach_lin...
Get the list of reach logs from the overall logs.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/util/log_analysis_tools.py#L50-L68
sorgerlab/indra
indra/tools/reading/util/log_analysis_tools.py
get_unyielding_tcids
def get_unyielding_tcids(log_str): """Extract the set of tcids for which no statements were created.""" tcid_strs = re.findall('INFO: \[.*?\].*? - Got no statements for (\d+).*', log_str) return {int(tcid_str) for tcid_str in tcid_strs}
python
def get_unyielding_tcids(log_str): """Extract the set of tcids for which no statements were created.""" tcid_strs = re.findall('INFO: \[.*?\].*? - Got no statements for (\d+).*', log_str) return {int(tcid_str) for tcid_str in tcid_strs}
Extract the set of tcids for which no statements were created.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/util/log_analysis_tools.py#L115-L119
sorgerlab/indra
indra/tools/reading/util/log_analysis_tools.py
analyze_db_reading
def analyze_db_reading(job_prefix, reading_queue='run_db_reading_queue'): """Run various analysis on a particular reading job.""" # Analyze reach failures log_strs = get_logs_from_db_reading(job_prefix, reading_queue) indra_log_strs = [] all_reach_logs = [] log_stats = [] for log_str in log_...
python
def analyze_db_reading(job_prefix, reading_queue='run_db_reading_queue'): """Run various analysis on a particular reading job.""" # Analyze reach failures log_strs = get_logs_from_db_reading(job_prefix, reading_queue) indra_log_strs = [] all_reach_logs = [] log_stats = [] for log_str in log_...
Run various analysis on a particular reading job.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/util/log_analysis_tools.py#L156-L195
sorgerlab/indra
indra/sources/biopax/api.py
process_pc_neighborhood
def process_pc_neighborhood(gene_names, neighbor_limit=1, database_filter=None): """Returns a BiopaxProcessor for a PathwayCommons neighborhood query. The neighborhood query finds the neighborhood around a set of source genes. http://www.pathwaycommons.org/pc2/#graph http:...
python
def process_pc_neighborhood(gene_names, neighbor_limit=1, database_filter=None): """Returns a BiopaxProcessor for a PathwayCommons neighborhood query. The neighborhood query finds the neighborhood around a set of source genes. http://www.pathwaycommons.org/pc2/#graph http:...
Returns a BiopaxProcessor for a PathwayCommons neighborhood query. The neighborhood query finds the neighborhood around a set of source genes. http://www.pathwaycommons.org/pc2/#graph http://www.pathwaycommons.org/pc2/#graph_kind Parameters ---------- gene_names : list A list of HGNC...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biopax/api.py#L8-L41
sorgerlab/indra
indra/sources/biopax/api.py
process_pc_pathsbetween
def process_pc_pathsbetween(gene_names, neighbor_limit=1, database_filter=None, block_size=None): """Returns a BiopaxProcessor for a PathwayCommons paths-between query. The paths-between query finds the paths between a set of genes. Here source gene names are given in a single l...
python
def process_pc_pathsbetween(gene_names, neighbor_limit=1, database_filter=None, block_size=None): """Returns a BiopaxProcessor for a PathwayCommons paths-between query. The paths-between query finds the paths between a set of genes. Here source gene names are given in a single l...
Returns a BiopaxProcessor for a PathwayCommons paths-between query. The paths-between query finds the paths between a set of genes. Here source gene names are given in a single list and all directions of paths between these genes are considered. http://www.pathwaycommons.org/pc2/#graph http://www...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biopax/api.py#L44-L101
sorgerlab/indra
indra/sources/biopax/api.py
process_pc_pathsfromto
def process_pc_pathsfromto(source_genes, target_genes, neighbor_limit=1, database_filter=None): """Returns a BiopaxProcessor for a PathwayCommons paths-from-to query. The paths-from-to query finds the paths from a set of source genes to a set of target genes. http://www.path...
python
def process_pc_pathsfromto(source_genes, target_genes, neighbor_limit=1, database_filter=None): """Returns a BiopaxProcessor for a PathwayCommons paths-from-to query. The paths-from-to query finds the paths from a set of source genes to a set of target genes. http://www.path...
Returns a BiopaxProcessor for a PathwayCommons paths-from-to query. The paths-from-to query finds the paths from a set of source genes to a set of target genes. http://www.pathwaycommons.org/pc2/#graph http://www.pathwaycommons.org/pc2/#graph_kind Parameters ---------- source_genes : lis...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biopax/api.py#L104-L143
sorgerlab/indra
indra/sources/biopax/api.py
process_model
def process_model(model): """Returns a BiopaxProcessor for a BioPAX model object. Parameters ---------- model : org.biopax.paxtools.model.Model A BioPAX model object. Returns ------- bp : BiopaxProcessor A BiopaxProcessor containing the obtained BioPAX model in bp.model. ...
python
def process_model(model): """Returns a BiopaxProcessor for a BioPAX model object. Parameters ---------- model : org.biopax.paxtools.model.Model A BioPAX model object. Returns ------- bp : BiopaxProcessor A BiopaxProcessor containing the obtained BioPAX model in bp.model. ...
Returns a BiopaxProcessor for a BioPAX model object. Parameters ---------- model : org.biopax.paxtools.model.Model A BioPAX model object. Returns ------- bp : BiopaxProcessor A BiopaxProcessor containing the obtained BioPAX model in bp.model.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biopax/api.py#L163-L186
sorgerlab/indra
indra/benchmarks/assembly_eval/batch4/assembly_eval.py
is_protein_or_chemical
def is_protein_or_chemical(agent): '''Return True if the agent is a protein/protein family or chemical.''' # Default is True if agent is None if agent is None: return True dbs = set(['UP', 'HGNC', 'CHEBI', 'PFAM-DEF', 'IP', 'INDRA', 'PUBCHEM', 'CHEMBL']) agent_refs = set(agent...
python
def is_protein_or_chemical(agent): '''Return True if the agent is a protein/protein family or chemical.''' # Default is True if agent is None if agent is None: return True dbs = set(['UP', 'HGNC', 'CHEBI', 'PFAM-DEF', 'IP', 'INDRA', 'PUBCHEM', 'CHEMBL']) agent_refs = set(agent...
Return True if the agent is a protein/protein family or chemical.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/benchmarks/assembly_eval/batch4/assembly_eval.py#L30-L40
sorgerlab/indra
indra/benchmarks/assembly_eval/batch4/assembly_eval.py
is_background_knowledge
def is_background_knowledge(stmt): '''Return True if Statement is only supported by background knowledge.''' any_background = False # Iterate over all evidence for the statement for ev in stmt.evidence: epi = ev.epistemics if epi is not None: sec = epi.get('section_type') ...
python
def is_background_knowledge(stmt): '''Return True if Statement is only supported by background knowledge.''' any_background = False # Iterate over all evidence for the statement for ev in stmt.evidence: epi = ev.epistemics if epi is not None: sec = epi.get('section_type') ...
Return True if Statement is only supported by background knowledge.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/benchmarks/assembly_eval/batch4/assembly_eval.py#L45-L66
sorgerlab/indra
indra/benchmarks/assembly_eval/batch4/assembly_eval.py
multiple_sources
def multiple_sources(stmt): '''Return True if statement is supported by multiple sources. Note: this is currently not used and replaced by BeliefEngine score cutoff ''' sources = list(set([e.source_api for e in stmt.evidence])) if len(sources) > 1: return True return False
python
def multiple_sources(stmt): '''Return True if statement is supported by multiple sources. Note: this is currently not used and replaced by BeliefEngine score cutoff ''' sources = list(set([e.source_api for e in stmt.evidence])) if len(sources) > 1: return True return False
Return True if statement is supported by multiple sources. Note: this is currently not used and replaced by BeliefEngine score cutoff
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/benchmarks/assembly_eval/batch4/assembly_eval.py#L68-L76
sorgerlab/indra
indra/benchmarks/assembly_eval/batch4/assembly_eval.py
run_assembly
def run_assembly(stmts, folder, pmcid, background_assertions=None): '''Run assembly on a list of statements, for a given PMCID.''' # Folder for index card output (scored submission) indexcard_prefix = folder + '/index_cards/' + pmcid # Folder for other outputs (for analysis, debugging) otherout_pref...
python
def run_assembly(stmts, folder, pmcid, background_assertions=None): '''Run assembly on a list of statements, for a given PMCID.''' # Folder for index card output (scored submission) indexcard_prefix = folder + '/index_cards/' + pmcid # Folder for other outputs (for analysis, debugging) otherout_pref...
Run assembly on a list of statements, for a given PMCID.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/benchmarks/assembly_eval/batch4/assembly_eval.py#L78-L205
sorgerlab/indra
indra/sources/geneways/symbols_parser.py
GenewaysSymbols.symbol_to_id
def symbol_to_id(self, symbol): """Returns the list of Entrez IDs for a given Geneways symbol (there may be more than one)""" if symbol not in self.symbols_to_ids: m = 'Could not look up Entrez ID for Geneways symbol ' + symbol raise Exception(m) return self.symb...
python
def symbol_to_id(self, symbol): """Returns the list of Entrez IDs for a given Geneways symbol (there may be more than one)""" if symbol not in self.symbols_to_ids: m = 'Could not look up Entrez ID for Geneways symbol ' + symbol raise Exception(m) return self.symb...
Returns the list of Entrez IDs for a given Geneways symbol (there may be more than one)
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/geneways/symbols_parser.py#L50-L57
sorgerlab/indra
indra/sources/geneways/symbols_parser.py
GenewaysSymbols.id_to_symbol
def id_to_symbol(self, entrez_id): """Gives the symbol for a given entrez id)""" entrez_id = str(entrez_id) if entrez_id not in self.ids_to_symbols: m = 'Could not look up symbol for Entrez ID ' + entrez_id raise Exception(m) return self.ids_to_symbols[entrez_id]
python
def id_to_symbol(self, entrez_id): """Gives the symbol for a given entrez id)""" entrez_id = str(entrez_id) if entrez_id not in self.ids_to_symbols: m = 'Could not look up symbol for Entrez ID ' + entrez_id raise Exception(m) return self.ids_to_symbols[entrez_id]
Gives the symbol for a given entrez id)
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/geneways/symbols_parser.py#L59-L66
sorgerlab/indra
indra/assemblers/tsv/assembler.py
_format_id
def _format_id(ns, id): """Format a namespace/ID pair for display and curation.""" label = '%s:%s' % (ns, id) label = label.replace(' ', '_') url = get_identifiers_url(ns, id) return (label, url)
python
def _format_id(ns, id): """Format a namespace/ID pair for display and curation.""" label = '%s:%s' % (ns, id) label = label.replace(' ', '_') url = get_identifiers_url(ns, id) return (label, url)
Format a namespace/ID pair for display and curation.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/tsv/assembler.py#L166-L171
sorgerlab/indra
indra/assemblers/tsv/assembler.py
TsvAssembler.make_model
def make_model(self, output_file, add_curation_cols=False, up_only=False): """Export the statements into a tab-separated text file. Parameters ---------- output_file : str Name of the output file. add_curation_cols : bool Whether to add columns to facilit...
python
def make_model(self, output_file, add_curation_cols=False, up_only=False): """Export the statements into a tab-separated text file. Parameters ---------- output_file : str Name of the output file. add_curation_cols : bool Whether to add columns to facilit...
Export the statements into a tab-separated text file. Parameters ---------- output_file : str Name of the output file. add_curation_cols : bool Whether to add columns to facilitate statement curation. Default is False (no additional columns). ...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/tsv/assembler.py#L109-L163
sorgerlab/indra
indra/assemblers/pysb/base_agents.py
BaseAgentSet.get_create_base_agent
def get_create_base_agent(self, agent): """Return base agent with given name, creating it if needed.""" try: base_agent = self.agents[_n(agent.name)] except KeyError: base_agent = BaseAgent(_n(agent.name)) self.agents[_n(agent.name)] = base_agent # If...
python
def get_create_base_agent(self, agent): """Return base agent with given name, creating it if needed.""" try: base_agent = self.agents[_n(agent.name)] except KeyError: base_agent = BaseAgent(_n(agent.name)) self.agents[_n(agent.name)] = base_agent # If...
Return base agent with given name, creating it if needed.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/base_agents.py#L13-L57
sorgerlab/indra
indra/assemblers/pysb/base_agents.py
BaseAgent.create_site
def create_site(self, site, states=None): """Create a new site on an agent if it doesn't already exist.""" if site not in self.sites: self.sites.append(site) if states is not None: self.site_states.setdefault(site, []) try: states = list(states...
python
def create_site(self, site, states=None): """Create a new site on an agent if it doesn't already exist.""" if site not in self.sites: self.sites.append(site) if states is not None: self.site_states.setdefault(site, []) try: states = list(states...
Create a new site on an agent if it doesn't already exist.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/base_agents.py#L90-L100
sorgerlab/indra
indra/assemblers/pysb/base_agents.py
BaseAgent.create_mod_site
def create_mod_site(self, mc): """Create modification site for the BaseAgent from a ModCondition.""" site_name = get_mod_site_name(mc) (unmod_site_state, mod_site_state) = states[mc.mod_type] self.create_site(site_name, (unmod_site_state, mod_site_state)) site_anns = [Annotation(...
python
def create_mod_site(self, mc): """Create modification site for the BaseAgent from a ModCondition.""" site_name = get_mod_site_name(mc) (unmod_site_state, mod_site_state) = states[mc.mod_type] self.create_site(site_name, (unmod_site_state, mod_site_state)) site_anns = [Annotation(...
Create modification site for the BaseAgent from a ModCondition.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/base_agents.py#L102-L113
sorgerlab/indra
indra/assemblers/pysb/base_agents.py
BaseAgent.add_site_states
def add_site_states(self, site, states): """Create new states on an agent site if the state doesn't exist.""" for state in states: if state not in self.site_states[site]: self.site_states[site].append(state)
python
def add_site_states(self, site, states): """Create new states on an agent site if the state doesn't exist.""" for state in states: if state not in self.site_states[site]: self.site_states[site].append(state)
Create new states on an agent site if the state doesn't exist.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/base_agents.py#L115-L119
sorgerlab/indra
indra/assemblers/pysb/base_agents.py
BaseAgent.add_activity_form
def add_activity_form(self, activity_pattern, is_active): """Adds the pattern as an active or inactive form to an Agent. Parameters ---------- activity_pattern : dict A dictionary of site names and their states. is_active : bool Is True if the given patte...
python
def add_activity_form(self, activity_pattern, is_active): """Adds the pattern as an active or inactive form to an Agent. Parameters ---------- activity_pattern : dict A dictionary of site names and their states. is_active : bool Is True if the given patte...
Adds the pattern as an active or inactive form to an Agent. Parameters ---------- activity_pattern : dict A dictionary of site names and their states. is_active : bool Is True if the given pattern corresponds to an active state.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/base_agents.py#L121-L136
sorgerlab/indra
indra/assemblers/pysb/base_agents.py
BaseAgent.add_activity_type
def add_activity_type(self, activity_type): """Adds an activity type to an Agent. Parameters ---------- activity_type : str The type of activity to add such as 'activity', 'kinase', 'gtpbound' """ if activity_type not in self.activity_types: ...
python
def add_activity_type(self, activity_type): """Adds an activity type to an Agent. Parameters ---------- activity_type : str The type of activity to add such as 'activity', 'kinase', 'gtpbound' """ if activity_type not in self.activity_types: ...
Adds an activity type to an Agent. Parameters ---------- activity_type : str The type of activity to add such as 'activity', 'kinase', 'gtpbound'
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/base_agents.py#L138-L148
sorgerlab/indra
indra/sources/geneways/action_parser.py
GenewaysAction.make_annotation
def make_annotation(self): """Returns a dictionary with all properties of the action and each of its action mentions.""" annotation = dict() # Put all properties of the action object into the annotation for item in dir(self): if len(item) > 0 and item[0] != '_' and \...
python
def make_annotation(self): """Returns a dictionary with all properties of the action and each of its action mentions.""" annotation = dict() # Put all properties of the action object into the annotation for item in dir(self): if len(item) > 0 and item[0] != '_' and \...
Returns a dictionary with all properties of the action and each of its action mentions.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/geneways/action_parser.py#L35-L52
sorgerlab/indra
indra/sources/geneways/action_parser.py
GenewaysActionParser._search_path
def _search_path(self, directory_name, filename): """Searches for a given file in the specified directory.""" full_path = path.join(directory_name, filename) if path.exists(full_path): return full_path # Could not find the requested file in any of the directories ret...
python
def _search_path(self, directory_name, filename): """Searches for a given file in the specified directory.""" full_path = path.join(directory_name, filename) if path.exists(full_path): return full_path # Could not find the requested file in any of the directories ret...
Searches for a given file in the specified directory.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/geneways/action_parser.py#L96-L103
sorgerlab/indra
indra/sources/geneways/action_parser.py
GenewaysActionParser._init_action_list
def _init_action_list(self, action_filename): """Parses the file and populates the data.""" self.actions = list() self.hiid_to_action_index = dict() f = codecs.open(action_filename, 'r', encoding='latin-1') first_line = True for line in f: line = line.rstrip...
python
def _init_action_list(self, action_filename): """Parses the file and populates the data.""" self.actions = list() self.hiid_to_action_index = dict() f = codecs.open(action_filename, 'r', encoding='latin-1') first_line = True for line in f: line = line.rstrip...
Parses the file and populates the data.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/geneways/action_parser.py#L105-L125
sorgerlab/indra
indra/sources/geneways/action_parser.py
GenewaysActionParser._link_to_action_mentions
def _link_to_action_mentions(self, actionmention_filename): """Add action mentions""" parser = GenewaysActionMentionParser(actionmention_filename) self.action_mentions = parser.action_mentions for action_mention in self.action_mentions: hiid = action_mention.hiid ...
python
def _link_to_action_mentions(self, actionmention_filename): """Add action mentions""" parser = GenewaysActionMentionParser(actionmention_filename) self.action_mentions = parser.action_mentions for action_mention in self.action_mentions: hiid = action_mention.hiid ...
Add action mentions
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/geneways/action_parser.py#L127-L140
sorgerlab/indra
indra/sources/geneways/action_parser.py
GenewaysActionParser._lookup_symbols
def _lookup_symbols(self, symbols_filename): """Look up symbols for actions and action mentions""" symbol_lookup = GenewaysSymbols(symbols_filename) for action in self.actions: action.up_symbol = symbol_lookup.id_to_symbol(action.up) action.dn_symbol = symbol_lookup.id_to...
python
def _lookup_symbols(self, symbols_filename): """Look up symbols for actions and action mentions""" symbol_lookup = GenewaysSymbols(symbols_filename) for action in self.actions: action.up_symbol = symbol_lookup.id_to_symbol(action.up) action.dn_symbol = symbol_lookup.id_to...
Look up symbols for actions and action mentions
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/geneways/action_parser.py#L142-L147
sorgerlab/indra
indra/sources/geneways/action_parser.py
GenewaysActionParser.get_top_n_action_types
def get_top_n_action_types(self, top_n): """Returns the top N actions by count.""" # Count action types action_type_to_counts = dict() for action in self.actions: actiontype = action.actiontype if actiontype not in action_type_to_counts: action_typ...
python
def get_top_n_action_types(self, top_n): """Returns the top N actions by count.""" # Count action types action_type_to_counts = dict() for action in self.actions: actiontype = action.actiontype if actiontype not in action_type_to_counts: action_typ...
Returns the top N actions by count.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/geneways/action_parser.py#L149-L188
sorgerlab/indra
indra/assemblers/graph/assembler.py
GraphAssembler.make_model
def make_model(self): """Assemble the graph from the assembler's list of INDRA Statements.""" # Assemble in two stages. # First, create the nodes of the graph for stmt in self.statements: # Skip SelfModification (self loops) -- has one node if isinstance(stmt, Sel...
python
def make_model(self): """Assemble the graph from the assembler's list of INDRA Statements.""" # Assemble in two stages. # First, create the nodes of the graph for stmt in self.statements: # Skip SelfModification (self loops) -- has one node if isinstance(stmt, Sel...
Assemble the graph from the assembler's list of INDRA Statements.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/graph/assembler.py#L105-L144
sorgerlab/indra
indra/assemblers/graph/assembler.py
GraphAssembler.get_string
def get_string(self): """Return the assembled graph as a string. Returns ------- graph_string : str The assembled graph as a string. """ graph_string = self.graph.to_string() graph_string = graph_string.replace('\\N', '\\n') return graph_strin...
python
def get_string(self): """Return the assembled graph as a string. Returns ------- graph_string : str The assembled graph as a string. """ graph_string = self.graph.to_string() graph_string = graph_string.replace('\\N', '\\n') return graph_strin...
Return the assembled graph as a string. Returns ------- graph_string : str The assembled graph as a string.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/graph/assembler.py#L146-L156
sorgerlab/indra
indra/assemblers/graph/assembler.py
GraphAssembler.save_dot
def save_dot(self, file_name='graph.dot'): """Save the graph in a graphviz dot file. Parameters ---------- file_name : Optional[str] The name of the file to save the graph dot string to. """ s = self.get_string() with open(file_name, 'wt') as fh: ...
python
def save_dot(self, file_name='graph.dot'): """Save the graph in a graphviz dot file. Parameters ---------- file_name : Optional[str] The name of the file to save the graph dot string to. """ s = self.get_string() with open(file_name, 'wt') as fh: ...
Save the graph in a graphviz dot file. Parameters ---------- file_name : Optional[str] The name of the file to save the graph dot string to.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/graph/assembler.py#L158-L168
sorgerlab/indra
indra/assemblers/graph/assembler.py
GraphAssembler.save_pdf
def save_pdf(self, file_name='graph.pdf', prog='dot'): """Draw the graph and save as an image or pdf file. Parameters ---------- file_name : Optional[str] The name of the file to save the graph as. Default: graph.pdf prog : Optional[str] The graphviz prog...
python
def save_pdf(self, file_name='graph.pdf', prog='dot'): """Draw the graph and save as an image or pdf file. Parameters ---------- file_name : Optional[str] The name of the file to save the graph as. Default: graph.pdf prog : Optional[str] The graphviz prog...
Draw the graph and save as an image or pdf file. Parameters ---------- file_name : Optional[str] The name of the file to save the graph as. Default: graph.pdf prog : Optional[str] The graphviz program to use for graph layout. Default: dot
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/graph/assembler.py#L170-L180
sorgerlab/indra
indra/assemblers/graph/assembler.py
GraphAssembler._add_edge
def _add_edge(self, source, target, **kwargs): """Add an edge to the graph.""" # Start with default edge properties edge_properties = self.edge_properties # Overwrite ones that are given in function call explicitly for k, v in kwargs.items(): edge_properties[k] = v ...
python
def _add_edge(self, source, target, **kwargs): """Add an edge to the graph.""" # Start with default edge properties edge_properties = self.edge_properties # Overwrite ones that are given in function call explicitly for k, v in kwargs.items(): edge_properties[k] = v ...
Add an edge to the graph.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/graph/assembler.py#L182-L189
sorgerlab/indra
indra/assemblers/graph/assembler.py
GraphAssembler._add_node
def _add_node(self, agent): """Add an Agent as a node to the graph.""" if agent is None: return node_label = _get_node_label(agent) if isinstance(agent, Agent) and agent.bound_conditions: bound_agents = [bc.agent for bc in agent.bound_conditions if ...
python
def _add_node(self, agent): """Add an Agent as a node to the graph.""" if agent is None: return node_label = _get_node_label(agent) if isinstance(agent, Agent) and agent.bound_conditions: bound_agents = [bc.agent for bc in agent.bound_conditions if ...
Add an Agent as a node to the graph.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/graph/assembler.py#L191-L212
sorgerlab/indra
indra/assemblers/graph/assembler.py
GraphAssembler._add_stmt_edge
def _add_stmt_edge(self, stmt): """Assemble a Modification statement.""" # Skip statements with None in the subject position source = _get_node_key(stmt.agent_list()[0]) target = _get_node_key(stmt.agent_list()[1]) edge_key = (source, target, stmt.__class__.__name__) if e...
python
def _add_stmt_edge(self, stmt): """Assemble a Modification statement.""" # Skip statements with None in the subject position source = _get_node_key(stmt.agent_list()[0]) target = _get_node_key(stmt.agent_list()[1]) edge_key = (source, target, stmt.__class__.__name__) if e...
Assemble a Modification statement.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/graph/assembler.py#L214-L234
sorgerlab/indra
indra/assemblers/graph/assembler.py
GraphAssembler._add_complex
def _add_complex(self, members, is_association=False): """Assemble a Complex statement.""" params = {'color': '#0000ff', 'arrowhead': 'dot', 'arrowtail': 'dot', 'dir': 'both'} for m1, m2 in itertools.combinations(members, 2): if s...
python
def _add_complex(self, members, is_association=False): """Assemble a Complex statement.""" params = {'color': '#0000ff', 'arrowhead': 'dot', 'arrowtail': 'dot', 'dir': 'both'} for m1, m2 in itertools.combinations(members, 2): if s...
Assemble a Complex statement.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/graph/assembler.py#L236-L255
sorgerlab/indra
indra/sources/signor/api.py
process_from_file
def process_from_file(signor_data_file, signor_complexes_file=None): """Process Signor interaction data from CSV files. Parameters ---------- signor_data_file : str Path to the Signor interaction data file in CSV format. signor_complexes_file : str Path to the Signor complexes data ...
python
def process_from_file(signor_data_file, signor_complexes_file=None): """Process Signor interaction data from CSV files. Parameters ---------- signor_data_file : str Path to the Signor interaction data file in CSV format. signor_complexes_file : str Path to the Signor complexes data ...
Process Signor interaction data from CSV files. Parameters ---------- signor_data_file : str Path to the Signor interaction data file in CSV format. signor_complexes_file : str Path to the Signor complexes data in CSV format. If unspecified, Signor complexes will not be expanded...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/signor/api.py#L47-L72
sorgerlab/indra
indra/sources/signor/api.py
_handle_response
def _handle_response(res, delimiter): """Get an iterator over the CSV data from the response.""" if res.status_code == 200: # Python 2 -- csv.reader will need bytes if sys.version_info[0] < 3: csv_io = BytesIO(res.content) # Python 3 -- csv.reader needs str else: ...
python
def _handle_response(res, delimiter): """Get an iterator over the CSV data from the response.""" if res.status_code == 200: # Python 2 -- csv.reader will need bytes if sys.version_info[0] < 3: csv_io = BytesIO(res.content) # Python 3 -- csv.reader needs str else: ...
Get an iterator over the CSV data from the response.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/signor/api.py#L89-L102
sorgerlab/indra
indra/databases/context_client.py
get_protein_expression
def get_protein_expression(gene_names, cell_types): """Return the protein expression levels of genes in cell types. Parameters ---------- gene_names : list HGNC gene symbols for which expression levels are queried. cell_types : list List of cell type names in which expression levels...
python
def get_protein_expression(gene_names, cell_types): """Return the protein expression levels of genes in cell types. Parameters ---------- gene_names : list HGNC gene symbols for which expression levels are queried. cell_types : list List of cell type names in which expression levels...
Return the protein expression levels of genes in cell types. Parameters ---------- gene_names : list HGNC gene symbols for which expression levels are queried. cell_types : list List of cell type names in which expression levels are queried. The cell type names follow the CCLE d...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/databases/context_client.py#L13-L44
sorgerlab/indra
indra/assemblers/cx/hub_layout.py
get_aspect
def get_aspect(cx, aspect_name): """Return an aspect given the name of the aspect""" if isinstance(cx, dict): return cx.get(aspect_name) for entry in cx: if list(entry.keys())[0] == aspect_name: return entry[aspect_name]
python
def get_aspect(cx, aspect_name): """Return an aspect given the name of the aspect""" if isinstance(cx, dict): return cx.get(aspect_name) for entry in cx: if list(entry.keys())[0] == aspect_name: return entry[aspect_name]
Return an aspect given the name of the aspect
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cx/hub_layout.py#L13-L19
sorgerlab/indra
indra/assemblers/cx/hub_layout.py
classify_nodes
def classify_nodes(graph, hub): """Classify each node based on its type and relationship to the hub.""" node_stats = defaultdict(lambda: defaultdict(list)) for u, v, data in graph.edges(data=True): # This means the node is downstream of the hub if hub == u: h, o = u, v ...
python
def classify_nodes(graph, hub): """Classify each node based on its type and relationship to the hub.""" node_stats = defaultdict(lambda: defaultdict(list)) for u, v, data in graph.edges(data=True): # This means the node is downstream of the hub if hub == u: h, o = u, v ...
Classify each node based on its type and relationship to the hub.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cx/hub_layout.py#L34-L67
sorgerlab/indra
indra/assemblers/cx/hub_layout.py
get_attributes
def get_attributes(aspect, id): """Return the attributes pointing to a given ID in a given aspect.""" attributes = {} for entry in aspect: if entry['po'] == id: attributes[entry['n']] = entry['v'] return attributes
python
def get_attributes(aspect, id): """Return the attributes pointing to a given ID in a given aspect.""" attributes = {} for entry in aspect: if entry['po'] == id: attributes[entry['n']] = entry['v'] return attributes
Return the attributes pointing to a given ID in a given aspect.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cx/hub_layout.py#L70-L76
sorgerlab/indra
indra/assemblers/cx/hub_layout.py
cx_to_networkx
def cx_to_networkx(cx): """Return a MultiDiGraph representation of a CX network.""" graph = networkx.MultiDiGraph() for node_entry in get_aspect(cx, 'nodes'): id = node_entry['@id'] attrs = get_attributes(get_aspect(cx, 'nodeAttributes'), id) attrs['n'] = node_entry['n'] grap...
python
def cx_to_networkx(cx): """Return a MultiDiGraph representation of a CX network.""" graph = networkx.MultiDiGraph() for node_entry in get_aspect(cx, 'nodes'): id = node_entry['@id'] attrs = get_attributes(get_aspect(cx, 'nodeAttributes'), id) attrs['n'] = node_entry['n'] grap...
Return a MultiDiGraph representation of a CX network.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cx/hub_layout.py#L79-L92
sorgerlab/indra
indra/assemblers/cx/hub_layout.py
get_quadrant_from_class
def get_quadrant_from_class(node_class): """Return the ID of the segment of the plane corresponding to a class.""" up, edge_type, _ = node_class if up == 0: return 0 if random.random() < 0.5 else 7 mappings = {(-1, 'modification'): 1, (-1, 'amount'): 2, (-1, 'acti...
python
def get_quadrant_from_class(node_class): """Return the ID of the segment of the plane corresponding to a class.""" up, edge_type, _ = node_class if up == 0: return 0 if random.random() < 0.5 else 7 mappings = {(-1, 'modification'): 1, (-1, 'amount'): 2, (-1, 'acti...
Return the ID of the segment of the plane corresponding to a class.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cx/hub_layout.py#L95-L106
sorgerlab/indra
indra/assemblers/cx/hub_layout.py
get_coordinates
def get_coordinates(node_class): """Generate coordinates for a node in a given class.""" quadrant_size = (2 * math.pi / 8.0) quadrant = get_quadrant_from_class(node_class) begin_angle = quadrant_size * quadrant r = 200 + 800*random.random() alpha = begin_angle + random.random() * quadrant_size ...
python
def get_coordinates(node_class): """Generate coordinates for a node in a given class.""" quadrant_size = (2 * math.pi / 8.0) quadrant = get_quadrant_from_class(node_class) begin_angle = quadrant_size * quadrant r = 200 + 800*random.random() alpha = begin_angle + random.random() * quadrant_size ...
Generate coordinates for a node in a given class.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cx/hub_layout.py#L109-L118
sorgerlab/indra
indra/assemblers/cx/hub_layout.py
get_layout_aspect
def get_layout_aspect(hub, node_classes): """Get the full layout aspect with coordinates for each node.""" aspect = [{'node': hub, 'x': 0.0, 'y': 0.0}] for node, node_class in node_classes.items(): if node == hub: continue x, y = get_coordinates(node_class) aspect.append(...
python
def get_layout_aspect(hub, node_classes): """Get the full layout aspect with coordinates for each node.""" aspect = [{'node': hub, 'x': 0.0, 'y': 0.0}] for node, node_class in node_classes.items(): if node == hub: continue x, y = get_coordinates(node_class) aspect.append(...
Get the full layout aspect with coordinates for each node.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cx/hub_layout.py#L121-L129
sorgerlab/indra
indra/assemblers/cx/hub_layout.py
get_node_by_name
def get_node_by_name(graph, name): """Return a node ID given its name.""" for id, attrs in graph.nodes(data=True): if attrs['n'] == name: return id
python
def get_node_by_name(graph, name): """Return a node ID given its name.""" for id, attrs in graph.nodes(data=True): if attrs['n'] == name: return id
Return a node ID given its name.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cx/hub_layout.py#L132-L136
sorgerlab/indra
indra/assemblers/cx/hub_layout.py
add_semantic_hub_layout
def add_semantic_hub_layout(cx, hub): """Attach a layout aspect to a CX network given a hub node.""" graph = cx_to_networkx(cx) hub_node = get_node_by_name(graph, hub) node_classes = classify_nodes(graph, hub_node) layout_aspect = get_layout_aspect(hub_node, node_classes) cx['cartesianLayout'] =...
python
def add_semantic_hub_layout(cx, hub): """Attach a layout aspect to a CX network given a hub node.""" graph = cx_to_networkx(cx) hub_node = get_node_by_name(graph, hub) node_classes = classify_nodes(graph, hub_node) layout_aspect = get_layout_aspect(hub_node, node_classes) cx['cartesianLayout'] =...
Attach a layout aspect to a CX network given a hub node.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cx/hub_layout.py#L139-L145
sorgerlab/indra
indra/literature/crossref_client.py
get_metadata
def get_metadata(doi): """Returns the metadata of an article given its DOI from CrossRef as a JSON dict""" url = crossref_url + 'works/' + doi res = requests.get(url) if res.status_code != 200: logger.info('Could not get CrossRef metadata for DOI %s, code %d' % (doi, res....
python
def get_metadata(doi): """Returns the metadata of an article given its DOI from CrossRef as a JSON dict""" url = crossref_url + 'works/' + doi res = requests.get(url) if res.status_code != 200: logger.info('Could not get CrossRef metadata for DOI %s, code %d' % (doi, res....
Returns the metadata of an article given its DOI from CrossRef as a JSON dict
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/crossref_client.py#L30-L41
sorgerlab/indra
indra/literature/crossref_client.py
get_fulltext_links
def get_fulltext_links(doi): """Return a list of links to the full text of an article given its DOI. Each list entry is a dictionary with keys: - URL: the URL to the full text - content-type: e.g. text/xml or text/plain - content-version - intended-application: e.g. text-mining """ metad...
python
def get_fulltext_links(doi): """Return a list of links to the full text of an article given its DOI. Each list entry is a dictionary with keys: - URL: the URL to the full text - content-type: e.g. text/xml or text/plain - content-version - intended-application: e.g. text-mining """ metad...
Return a list of links to the full text of an article given its DOI. Each list entry is a dictionary with keys: - URL: the URL to the full text - content-type: e.g. text/xml or text/plain - content-version - intended-application: e.g. text-mining
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/crossref_client.py#L43-L55
sorgerlab/indra
indra/literature/crossref_client.py
doi_query
def doi_query(pmid, search_limit=10): """Get the DOI for a PMID by matching CrossRef and Pubmed metadata. Searches CrossRef using the article title and then accepts search hits only if they have a matching journal ISSN and page number with what is obtained from the Pubmed database. """ # Get ar...
python
def doi_query(pmid, search_limit=10): """Get the DOI for a PMID by matching CrossRef and Pubmed metadata. Searches CrossRef using the article title and then accepts search hits only if they have a matching journal ISSN and page number with what is obtained from the Pubmed database. """ # Get ar...
Get the DOI for a PMID by matching CrossRef and Pubmed metadata. Searches CrossRef using the article title and then accepts search hits only if they have a matching journal ISSN and page number with what is obtained from the Pubmed database.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/crossref_client.py#L81-L177
sorgerlab/indra
indra/assemblers/pysb/assembler.py
get_agent_rule_str
def get_agent_rule_str(agent): """Construct a string from an Agent as part of a PySB rule name.""" rule_str_list = [_n(agent.name)] # If it's a molecular agent if isinstance(agent, ist.Agent): for mod in agent.mods: mstr = abbrevs[mod.mod_type] if mod.residue is not None:...
python
def get_agent_rule_str(agent): """Construct a string from an Agent as part of a PySB rule name.""" rule_str_list = [_n(agent.name)] # If it's a molecular agent if isinstance(agent, ist.Agent): for mod in agent.mods: mstr = abbrevs[mod.mod_type] if mod.residue is not None:...
Construct a string from an Agent as part of a PySB rule name.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L55-L90
sorgerlab/indra
indra/assemblers/pysb/assembler.py
add_rule_to_model
def add_rule_to_model(model, rule, annotations=None): """Add a Rule to a PySB model and handle duplicate component errors.""" try: model.add_component(rule) # If the rule was actually added, also add the annotations if annotations: model.annotations += annotations # If th...
python
def add_rule_to_model(model, rule, annotations=None): """Add a Rule to a PySB model and handle duplicate component errors.""" try: model.add_component(rule) # If the rule was actually added, also add the annotations if annotations: model.annotations += annotations # If th...
Add a Rule to a PySB model and handle duplicate component errors.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L93-L103
sorgerlab/indra
indra/assemblers/pysb/assembler.py
get_create_parameter
def get_create_parameter(model, param): """Return parameter with given name, creating it if needed. If unique is false and the parameter exists, the value is not changed; if it does not exist, it will be created. If unique is true then upon conflict a number is added to the end of the parameter name. ...
python
def get_create_parameter(model, param): """Return parameter with given name, creating it if needed. If unique is false and the parameter exists, the value is not changed; if it does not exist, it will be created. If unique is true then upon conflict a number is added to the end of the parameter name. ...
Return parameter with given name, creating it if needed. If unique is false and the parameter exists, the value is not changed; if it does not exist, it will be created. If unique is true then upon conflict a number is added to the end of the parameter name. Parameters ---------- model : pysb....
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L106-L138
sorgerlab/indra
indra/assemblers/pysb/assembler.py
get_uncond_agent
def get_uncond_agent(agent): """Construct the unconditional state of an Agent. The unconditional Agent is a copy of the original agent but without any bound conditions and modification conditions. Mutation conditions, however, are preserved since they are static. """ agent_uncond = ist.Agent(_n...
python
def get_uncond_agent(agent): """Construct the unconditional state of an Agent. The unconditional Agent is a copy of the original agent but without any bound conditions and modification conditions. Mutation conditions, however, are preserved since they are static. """ agent_uncond = ist.Agent(_n...
Construct the unconditional state of an Agent. The unconditional Agent is a copy of the original agent but without any bound conditions and modification conditions. Mutation conditions, however, are preserved since they are static.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L141-L149
sorgerlab/indra
indra/assemblers/pysb/assembler.py
grounded_monomer_patterns
def grounded_monomer_patterns(model, agent, ignore_activities=False): """Get monomer patterns for the agent accounting for grounding information. Parameters ---------- model : pysb.core.Model The model to search for MonomerPatterns matching the given Agent. agent : indra.statements.Agent ...
python
def grounded_monomer_patterns(model, agent, ignore_activities=False): """Get monomer patterns for the agent accounting for grounding information. Parameters ---------- model : pysb.core.Model The model to search for MonomerPatterns matching the given Agent. agent : indra.statements.Agent ...
Get monomer patterns for the agent accounting for grounding information. Parameters ---------- model : pysb.core.Model The model to search for MonomerPatterns matching the given Agent. agent : indra.statements.Agent The Agent to find matching MonomerPatterns for. ignore_activites : ...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L152-L281
sorgerlab/indra
indra/assemblers/pysb/assembler.py
get_monomer_pattern
def get_monomer_pattern(model, agent, extra_fields=None): """Construct a PySB MonomerPattern from an Agent.""" try: monomer = model.monomers[_n(agent.name)] except KeyError as e: logger.warning('Monomer with name %s not found in model' % _n(agent.name)) return ...
python
def get_monomer_pattern(model, agent, extra_fields=None): """Construct a PySB MonomerPattern from an Agent.""" try: monomer = model.monomers[_n(agent.name)] except KeyError as e: logger.warning('Monomer with name %s not found in model' % _n(agent.name)) return ...
Construct a PySB MonomerPattern from an Agent.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L293-L319
sorgerlab/indra
indra/assemblers/pysb/assembler.py
get_site_pattern
def get_site_pattern(agent): """Construct a dictionary of Monomer site states from an Agent. This crates the mapping to the associated PySB monomer from an INDRA Agent object.""" if not isinstance(agent, ist.Agent): return {} pattern = {} # Handle bound conditions for bc in agent.bo...
python
def get_site_pattern(agent): """Construct a dictionary of Monomer site states from an Agent. This crates the mapping to the associated PySB monomer from an INDRA Agent object.""" if not isinstance(agent, ist.Agent): return {} pattern = {} # Handle bound conditions for bc in agent.bo...
Construct a dictionary of Monomer site states from an Agent. This crates the mapping to the associated PySB monomer from an INDRA Agent object.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L322-L375
sorgerlab/indra
indra/assemblers/pysb/assembler.py
set_base_initial_condition
def set_base_initial_condition(model, monomer, value): """Set an initial condition for a monomer in its 'default' state.""" # Build up monomer pattern dict sites_dict = {} for site in monomer.sites: if site in monomer.site_states: if site == 'loc' and 'cytoplasm' in monomer.site_stat...
python
def set_base_initial_condition(model, monomer, value): """Set an initial condition for a monomer in its 'default' state.""" # Build up monomer pattern dict sites_dict = {} for site in monomer.sites: if site in monomer.site_states: if site == 'loc' and 'cytoplasm' in monomer.site_stat...
Set an initial condition for a monomer in its 'default' state.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L378-L398
sorgerlab/indra
indra/assemblers/pysb/assembler.py
get_annotation
def get_annotation(component, db_name, db_ref): """Construct model Annotations for each component. Annotation formats follow guidelines at http://identifiers.org/. """ url = get_identifiers_url(db_name, db_ref) if not url: return None subj = component ann = Annotation(subj, url, 'is...
python
def get_annotation(component, db_name, db_ref): """Construct model Annotations for each component. Annotation formats follow guidelines at http://identifiers.org/. """ url = get_identifiers_url(db_name, db_ref) if not url: return None subj = component ann = Annotation(subj, url, 'is...
Construct model Annotations for each component. Annotation formats follow guidelines at http://identifiers.org/.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L432-L442
sorgerlab/indra
indra/assemblers/pysb/assembler.py
parse_identifiers_url
def parse_identifiers_url(url): """Parse an identifiers.org URL into (namespace, ID) tuple.""" url_pattern = 'http://identifiers.org/([A-Za-z]+)/([A-Za-z0-9:]+)' match = re.match(url_pattern, url) if match is not None: g = match.groups() if not len(g) == 2: return (None, None...
python
def parse_identifiers_url(url): """Parse an identifiers.org URL into (namespace, ID) tuple.""" url_pattern = 'http://identifiers.org/([A-Za-z]+)/([A-Za-z0-9:]+)' match = re.match(url_pattern, url) if match is not None: g = match.groups() if not len(g) == 2: return (None, None...
Parse an identifiers.org URL into (namespace, ID) tuple.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L444-L467
sorgerlab/indra
indra/assemblers/pysb/assembler.py
complex_monomers_one_step
def complex_monomers_one_step(stmt, agent_set): """In this (very simple) implementation, proteins in a complex are each given site names corresponding to each of the other members of the complex (lower case). So the resulting complex can be "fully connected" in that each member can be bound to all t...
python
def complex_monomers_one_step(stmt, agent_set): """In this (very simple) implementation, proteins in a complex are each given site names corresponding to each of the other members of the complex (lower case). So the resulting complex can be "fully connected" in that each member can be bound to all t...
In this (very simple) implementation, proteins in a complex are each given site names corresponding to each of the other members of the complex (lower case). So the resulting complex can be "fully connected" in that each member can be bound to all the others.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L917-L932
sorgerlab/indra
indra/assemblers/pysb/assembler.py
PysbAssembler.make_model
def make_model(self, policies=None, initial_conditions=True, reverse_effects=False, model_name='indra_model'): """Assemble the PySB model from the collected INDRA Statements. This method assembles a PySB model from the set of INDRA Statements. The assembled model is both retu...
python
def make_model(self, policies=None, initial_conditions=True, reverse_effects=False, model_name='indra_model'): """Assemble the PySB model from the collected INDRA Statements. This method assembles a PySB model from the set of INDRA Statements. The assembled model is both retu...
Assemble the PySB model from the collected INDRA Statements. This method assembles a PySB model from the set of INDRA Statements. The assembled model is both returned and set as the assembler's model argument. Parameters ---------- policies : Optional[Union[str, dict]] ...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L546-L626
sorgerlab/indra
indra/assemblers/pysb/assembler.py
PysbAssembler.add_default_initial_conditions
def add_default_initial_conditions(self, value=None): """Set default initial conditions in the PySB model. Parameters ---------- value : Optional[float] Optionally a value can be supplied which will be the initial amount applied. Otherwise a built-in default is u...
python
def add_default_initial_conditions(self, value=None): """Set default initial conditions in the PySB model. Parameters ---------- value : Optional[float] Optionally a value can be supplied which will be the initial amount applied. Otherwise a built-in default is u...
Set default initial conditions in the PySB model. Parameters ---------- value : Optional[float] Optionally a value can be supplied which will be the initial amount applied. Otherwise a built-in default is used.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L628-L648
sorgerlab/indra
indra/assemblers/pysb/assembler.py
PysbAssembler.set_expression
def set_expression(self, expression_dict): """Set protein expression amounts as initial conditions Parameters ---------- expression_dict : dict A dictionary in which the keys are gene names and the values are numbers representing the absolute amount (...
python
def set_expression(self, expression_dict): """Set protein expression amounts as initial conditions Parameters ---------- expression_dict : dict A dictionary in which the keys are gene names and the values are numbers representing the absolute amount (...
Set protein expression amounts as initial conditions Parameters ---------- expression_dict : dict A dictionary in which the keys are gene names and the values are numbers representing the absolute amount (count per cell) of proteins expressed. Proteins that ...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L650-L694
sorgerlab/indra
indra/assemblers/pysb/assembler.py
PysbAssembler.set_context
def set_context(self, cell_type): """Set protein expression amounts from CCLE as initial conditions. This method uses :py:mod:`indra.databases.context_client` to get protein expression levels for a given cell type and set initial conditions for Monomers in the model accordingly. ...
python
def set_context(self, cell_type): """Set protein expression amounts from CCLE as initial conditions. This method uses :py:mod:`indra.databases.context_client` to get protein expression levels for a given cell type and set initial conditions for Monomers in the model accordingly. ...
Set protein expression amounts from CCLE as initial conditions. This method uses :py:mod:`indra.databases.context_client` to get protein expression levels for a given cell type and set initial conditions for Monomers in the model accordingly. Parameters ---------- cell_...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L696-L721
sorgerlab/indra
indra/assemblers/pysb/assembler.py
PysbAssembler.export_model
def export_model(self, format, file_name=None): """Save the assembled model in a modeling formalism other than PySB. For more details on exporting PySB models, see http://pysb.readthedocs.io/en/latest/modules/export/index.html Parameters ---------- format : str ...
python
def export_model(self, format, file_name=None): """Save the assembled model in a modeling formalism other than PySB. For more details on exporting PySB models, see http://pysb.readthedocs.io/en/latest/modules/export/index.html Parameters ---------- format : str ...
Save the assembled model in a modeling formalism other than PySB. For more details on exporting PySB models, see http://pysb.readthedocs.io/en/latest/modules/export/index.html Parameters ---------- format : str The format to export into, for instance "kappa", "bngl"...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L746-L789
sorgerlab/indra
indra/assemblers/pysb/assembler.py
PysbAssembler.save_rst
def save_rst(self, file_name='pysb_model.rst', module_name='pysb_module'): """Save the assembled model as an RST file for literate modeling. Parameters ---------- file_name : Optional[str] The name of the file to save the RST in. Default: pysb_model.rst m...
python
def save_rst(self, file_name='pysb_model.rst', module_name='pysb_module'): """Save the assembled model as an RST file for literate modeling. Parameters ---------- file_name : Optional[str] The name of the file to save the RST in. Default: pysb_model.rst m...
Save the assembled model as an RST file for literate modeling. Parameters ---------- file_name : Optional[str] The name of the file to save the RST in. Default: pysb_model.rst module_name : Optional[str] The name of the python function defining the mo...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L792-L812
sorgerlab/indra
indra/assemblers/pysb/assembler.py
PysbAssembler._dispatch
def _dispatch(self, stmt, stage, *args): """Construct and call an assembly function. This function constructs the name of the assembly function based on the type of statement, the corresponding policy and the stage of assembly. It then calls that function to perform the assembly ...
python
def _dispatch(self, stmt, stage, *args): """Construct and call an assembly function. This function constructs the name of the assembly function based on the type of statement, the corresponding policy and the stage of assembly. It then calls that function to perform the assembly ...
Construct and call an assembly function. This function constructs the name of the assembly function based on the type of statement, the corresponding policy and the stage of assembly. It then calls that function to perform the assembly task.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L814-L842
sorgerlab/indra
indra/assemblers/pysb/assembler.py
PysbAssembler._monomers
def _monomers(self): """Calls the appropriate monomers method based on policies.""" for stmt in self.statements: if _is_whitelisted(stmt): self._dispatch(stmt, 'monomers', self.agent_set)
python
def _monomers(self): """Calls the appropriate monomers method based on policies.""" for stmt in self.statements: if _is_whitelisted(stmt): self._dispatch(stmt, 'monomers', self.agent_set)
Calls the appropriate monomers method based on policies.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L844-L848
sorgerlab/indra
indra/assemblers/pysb/assembler.py
PysbAssembler._assemble
def _assemble(self): """Calls the appropriate assemble method based on policies.""" for stmt in self.statements: pol = self.processed_policies[stmt.uuid] if _is_whitelisted(stmt): self._dispatch(stmt, 'assemble', self.model, self.agent_set, ...
python
def _assemble(self): """Calls the appropriate assemble method based on policies.""" for stmt in self.statements: pol = self.processed_policies[stmt.uuid] if _is_whitelisted(stmt): self._dispatch(stmt, 'assemble', self.model, self.agent_set, ...
Calls the appropriate assemble method based on policies.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pysb/assembler.py#L850-L856
sorgerlab/indra
indra/sources/trips/client.py
send_query
def send_query(text, service_endpoint='drum', query_args=None): """Send a query to the TRIPS web service. Parameters ---------- text : str The text to be processed. service_endpoint : Optional[str] Selects the TRIPS/DRUM web service endpoint to use. Is a choice between "drum...
python
def send_query(text, service_endpoint='drum', query_args=None): """Send a query to the TRIPS web service. Parameters ---------- text : str The text to be processed. service_endpoint : Optional[str] Selects the TRIPS/DRUM web service endpoint to use. Is a choice between "drum...
Send a query to the TRIPS web service. Parameters ---------- text : str The text to be processed. service_endpoint : Optional[str] Selects the TRIPS/DRUM web service endpoint to use. Is a choice between "drum" (default), "drum-dev", a nightly build, and "cwms" for use with ...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/client.py#L15-L48
sorgerlab/indra
indra/sources/trips/client.py
get_xml
def get_xml(html, content_tag='ekb', fail_if_empty=False): """Extract the content XML from the HTML output of the TRIPS web service. Parameters ---------- html : str The HTML output from the TRIPS web service. content_tag : str The xml tag used to label the content. Default is 'ekb'...
python
def get_xml(html, content_tag='ekb', fail_if_empty=False): """Extract the content XML from the HTML output of the TRIPS web service. Parameters ---------- html : str The HTML output from the TRIPS web service. content_tag : str The xml tag used to label the content. Default is 'ekb'...
Extract the content XML from the HTML output of the TRIPS web service. Parameters ---------- html : str The HTML output from the TRIPS web service. content_tag : str The xml tag used to label the content. Default is 'ekb'. fail_if_empty : bool If True, and if the xml content...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/client.py#L51-L88
sorgerlab/indra
indra/sources/trips/client.py
save_xml
def save_xml(xml_str, file_name, pretty=True): """Save the TRIPS EKB XML in a file. Parameters ---------- xml_str : str The TRIPS EKB XML string to be saved. file_name : str The name of the file to save the result in. pretty : Optional[bool] If True, the XML is pretty pr...
python
def save_xml(xml_str, file_name, pretty=True): """Save the TRIPS EKB XML in a file. Parameters ---------- xml_str : str The TRIPS EKB XML string to be saved. file_name : str The name of the file to save the result in. pretty : Optional[bool] If True, the XML is pretty pr...
Save the TRIPS EKB XML in a file. Parameters ---------- xml_str : str The TRIPS EKB XML string to be saved. file_name : str The name of the file to save the result in. pretty : Optional[bool] If True, the XML is pretty printed.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/client.py#L91-L114
sorgerlab/indra
indra/sources/sofia/api.py
process_table
def process_table(fname): """Return processor by processing a given sheet of a spreadsheet file. Parameters ---------- fname : str The name of the Excel file (typically .xlsx extension) to process Returns ------- sp : indra.sources.sofia.processor.SofiaProcessor A SofiaProc...
python
def process_table(fname): """Return processor by processing a given sheet of a spreadsheet file. Parameters ---------- fname : str The name of the Excel file (typically .xlsx extension) to process Returns ------- sp : indra.sources.sofia.processor.SofiaProcessor A SofiaProc...
Return processor by processing a given sheet of a spreadsheet file. Parameters ---------- fname : str The name of the Excel file (typically .xlsx extension) to process Returns ------- sp : indra.sources.sofia.processor.SofiaProcessor A SofiaProcessor object which has a list of ...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sofia/api.py#L9-L32
sorgerlab/indra
indra/sources/sofia/api.py
process_text
def process_text(text, out_file='sofia_output.json', auth=None): """Return processor by processing text given as a string. Parameters ---------- text : str A string containing the text to be processed with Sofia. out_file : Optional[str] The path to a file to save the reader's outpu...
python
def process_text(text, out_file='sofia_output.json', auth=None): """Return processor by processing text given as a string. Parameters ---------- text : str A string containing the text to be processed with Sofia. out_file : Optional[str] The path to a file to save the reader's outpu...
Return processor by processing text given as a string. Parameters ---------- text : str A string containing the text to be processed with Sofia. out_file : Optional[str] The path to a file to save the reader's output into. Default: sofia_output.json auth : Optional[list] ...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/sofia/api.py#L35-L80
sorgerlab/indra
indra/sources/ndex_cx/processor.py
_get_dict_from_list
def _get_dict_from_list(dict_key, list_of_dicts): """Retrieve a specific dict from a list of dicts. Parameters ---------- dict_key : str The (single) key of the dict to be retrieved from the list. list_of_dicts : list The list of dicts to search for the specific dict. Returns ...
python
def _get_dict_from_list(dict_key, list_of_dicts): """Retrieve a specific dict from a list of dicts. Parameters ---------- dict_key : str The (single) key of the dict to be retrieved from the list. list_of_dicts : list The list of dicts to search for the specific dict. Returns ...
Retrieve a specific dict from a list of dicts. Parameters ---------- dict_key : str The (single) key of the dict to be retrieved from the list. list_of_dicts : list The list of dicts to search for the specific dict. Returns ------- dict value The value associated wi...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/processor.py#L22-L42
sorgerlab/indra
indra/sources/ndex_cx/processor.py
NdexCxProcessor._initialize_node_agents
def _initialize_node_agents(self): """Initialize internal dicts containing node information.""" nodes = _get_dict_from_list('nodes', self.cx) invalid_genes = [] for node in nodes: id = node['@id'] cx_db_refs = self.get_aliases(node) up_id = cx_db_refs....
python
def _initialize_node_agents(self): """Initialize internal dicts containing node information.""" nodes = _get_dict_from_list('nodes', self.cx) invalid_genes = [] for node in nodes: id = node['@id'] cx_db_refs = self.get_aliases(node) up_id = cx_db_refs....
Initialize internal dicts containing node information.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/processor.py#L78-L116
sorgerlab/indra
indra/sources/ndex_cx/processor.py
NdexCxProcessor.get_pmids
def get_pmids(self): """Get list of all PMIDs associated with edges in the network.""" pmids = [] for ea in self._edge_attributes.values(): edge_pmids = ea.get('pmids') if edge_pmids: pmids += edge_pmids return list(set(pmids))
python
def get_pmids(self): """Get list of all PMIDs associated with edges in the network.""" pmids = [] for ea in self._edge_attributes.values(): edge_pmids = ea.get('pmids') if edge_pmids: pmids += edge_pmids return list(set(pmids))
Get list of all PMIDs associated with edges in the network.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/processor.py#L166-L173
sorgerlab/indra
indra/sources/ndex_cx/processor.py
NdexCxProcessor.get_statements
def get_statements(self): """Convert network edges into Statements. Returns ------- list of Statements Converted INDRA Statements. """ edges = _get_dict_from_list('edges', self.cx) for edge in edges: edge_type = edge.get('i') i...
python
def get_statements(self): """Convert network edges into Statements. Returns ------- list of Statements Converted INDRA Statements. """ edges = _get_dict_from_list('edges', self.cx) for edge in edges: edge_type = edge.get('i') i...
Convert network edges into Statements. Returns ------- list of Statements Converted INDRA Statements.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/processor.py#L175-L204
sorgerlab/indra
indra/sources/ndex_cx/processor.py
NdexCxProcessor._create_evidence
def _create_evidence(self, edge_id): """Create Evidence object for a specific edge/Statement in the network. Parameters ---------- edge_id : int ID of the edge in the underlying NDEx network. """ pmids = None edge_attr = self._edge_attributes.get(edge...
python
def _create_evidence(self, edge_id): """Create Evidence object for a specific edge/Statement in the network. Parameters ---------- edge_id : int ID of the edge in the underlying NDEx network. """ pmids = None edge_attr = self._edge_attributes.get(edge...
Create Evidence object for a specific edge/Statement in the network. Parameters ---------- edge_id : int ID of the edge in the underlying NDEx network.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/ndex_cx/processor.py#L206-L230
sorgerlab/indra
indra/sources/tees/processor.py
TEESProcessor.node_has_edge_with_label
def node_has_edge_with_label(self, node_name, edge_label): """Looks for an edge from node_name to some other node with the specified label. Returns the node to which this edge points if it exists, or None if it doesn't. Parameters ---------- G : The graph obj...
python
def node_has_edge_with_label(self, node_name, edge_label): """Looks for an edge from node_name to some other node with the specified label. Returns the node to which this edge points if it exists, or None if it doesn't. Parameters ---------- G : The graph obj...
Looks for an edge from node_name to some other node with the specified label. Returns the node to which this edge points if it exists, or None if it doesn't. Parameters ---------- G : The graph object node_name : Node that the edge starts at ...
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L83-L104
sorgerlab/indra
indra/sources/tees/processor.py
TEESProcessor.general_node_label
def general_node_label(self, node): """Used for debugging - gives a short text description of a graph node.""" G = self.G if G.node[node]['is_event']: return 'event type=' + G.node[node]['type'] else: return 'entity text=' + G.node[node]['text']
python
def general_node_label(self, node): """Used for debugging - gives a short text description of a graph node.""" G = self.G if G.node[node]['is_event']: return 'event type=' + G.node[node]['type'] else: return 'entity text=' + G.node[node]['text']
Used for debugging - gives a short text description of a graph node.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L106-L113
sorgerlab/indra
indra/sources/tees/processor.py
TEESProcessor.print_parent_and_children_info
def print_parent_and_children_info(self, node): """Used for debugging - prints a short description of a a node, its children, its parents, and its parents' children.""" G = self.G parents = G.predecessors(node) children = G.successors(node) print(general_node_label(G, no...
python
def print_parent_and_children_info(self, node): """Used for debugging - prints a short description of a a node, its children, its parents, and its parents' children.""" G = self.G parents = G.predecessors(node) children = G.successors(node) print(general_node_label(G, no...
Used for debugging - prints a short description of a a node, its children, its parents, and its parents' children.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L115-L136
sorgerlab/indra
indra/sources/tees/processor.py
TEESProcessor.find_event_parent_with_event_child
def find_event_parent_with_event_child(self, parent_name, child_name): """Finds all event nodes (is_event node attribute is True) that are of the type parent_name, that have a child event node with the type child_name.""" G = self.G matches = [] for n in G.node.keys(): ...
python
def find_event_parent_with_event_child(self, parent_name, child_name): """Finds all event nodes (is_event node attribute is True) that are of the type parent_name, that have a child event node with the type child_name.""" G = self.G matches = [] for n in G.node.keys(): ...
Finds all event nodes (is_event node attribute is True) that are of the type parent_name, that have a child event node with the type child_name.
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L138-L152