sequence stringlengths 546 16.2k | code stringlengths 108 19.3k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_regulate_amounts; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 23; 5, 27; 5, 39; 5, 43; 5, 54; 5, 66; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, ide... | def get_regulate_amounts(self):
"""Extract RegulateAmount INDRA Statements."""
qstr = "$.events.frames[(@.type is 'transcription')]"
res = self.tree.execute(qstr)
all_res = []
if res is not None:
all_res += list(res)
qstr = "$.events.frames[(@.type is 'amount'... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_entity_coordinates; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:entity_term; 6, block; 6, 7; 6, 9; 6, 10; 6, 11; 6, 20; 6, 27; 6, 33; 6, 44; 6, 51; 6, 65; 6, 74; 6, 81; 6, 90; 6, 97; 6, 98; 6, 99; 6, 100; 6, 101; 6, 110; 6... | def _get_entity_coordinates(self, entity_term):
"""Return sentence coordinates for a given entity.
Given an entity term return the associated sentence coordinates as
a tuple of the form (int, int). Returns None if for any reason the
sentence coordinates cannot be found.
"""
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_evidence; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:relation; 6, block; 6, 7; 6, 9; 6, 18; 6, 19; 6, 23; 6, 27; 6, 219; 6, 234; 6, 257; 6, 261; 6, 270; 6, 279; 6, 288; 6, 306; 6, 307; 6, 324; 6, 345; 7, expression_stateme... | def get_evidence(self, relation):
"""Return the Evidence object for the INDRA Statment."""
provenance = relation.get('provenance')
# First try looking up the full sentence through provenance
text = None
context = None
if provenance:
sentence_tag = provenance[... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_groundings; 3, parameters; 3, 4; 4, identifier:entity; 5, block; 5, 6; 5, 8; 5, 80; 5, 81; 5, 90; 5, 99; 5, 105; 5, 165; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 12; 9, function_name:get_grounding_e... | def get_groundings(entity):
"""Return groundings as db_refs for an entity."""
def get_grounding_entries(grounding):
if not grounding:
return None
entries = []
values = grounding.get('values', [])
# Values could still have been a None entry... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:make_model; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:grounding_ontology; 7, string:'UN'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:grounding_threshold; 10, None; 11, block; 11,... | def make_model(self, grounding_ontology='UN', grounding_threshold=None):
"""Return a networkx MultiDiGraph representing a causal analysis graph.
Parameters
----------
grounding_ontology : Optional[str]
The ontology from which the grounding should be taken
(e.g. U... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:process_directory_statements_sorted_by_pmid; 3, parameters; 3, 4; 4, identifier:directory_name; 5, block; 5, 6; 5, 8; 5, 15; 5, 25; 5, 48; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10... | def process_directory_statements_sorted_by_pmid(directory_name):
"""Processes a directory filled with CSXML files, first normalizing the
character encoding to utf-8, and then processing into INDRA statements
sorted by pmid.
Parameters
----------
directory_name : str
The name of a direct... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:process_file_sorted_by_pmid; 3, parameters; 3, 4; 4, identifier:file_name; 5, block; 5, 6; 5, 8; 5, 15; 5, 25; 5, 48; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:s_dict; ... | def process_file_sorted_by_pmid(file_name):
"""Processes a file and returns a dictionary mapping pmids to a list of
statements corresponding to that pmid.
Parameters
----------
file_name : str
A csxml file to process
Returns
-------
s_dict : dict
Dictionary mapping pmid... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:extract_context; 3, parameters; 3, 4; 3, 5; 4, identifier:annotations; 5, identifier:annot_manager; 6, block; 6, 7; 6, 9; 6, 75; 6, 81; 6, 89; 6, 119; 6, 143; 6, 221; 6, 222; 6, 230; 7, expression_statement; 7, 8; 8, comment; 9, function_defini... | def extract_context(annotations, annot_manager):
"""Return a BioContext object extracted from the annotations.
The entries that are extracted into the BioContext are popped from the
annotations.
Parameters
----------
annotations : dict
PyBEL annotations dict
annot_manager : Annotat... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_format_evidence_text; 3, parameters; 3, 4; 4, identifier:stmt; 5, block; 5, 6; 5, 8; 5, 82; 5, 86; 5, 317; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 12; 9, function_name:get_role; 10, parameters; 10, 11... | def _format_evidence_text(stmt):
"""Returns evidence metadata with highlighted evidence text.
Parameters
----------
stmt : indra.Statement
The Statement with Evidence to be formatted.
Returns
-------
list of dicts
List of dictionaries cor... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_full_text; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:paper_id; 5, identifier:idtype; 6, default_parameter; 6, 7; 6, 8; 7, identifier:preferred_content_type; 8, string:'text/xml'; 9, block; 9, 10; 9, 12; 9, 28; 9, 36; 9, 45; 9, 54; 9, 6... | def get_full_text(paper_id, idtype, preferred_content_type='text/xml'):
"""Return the content and the content type of an article.
This function retreives the content of an article by its PubMed ID,
PubMed Central ID, or DOI. It prioritizes full text content when available
and returns an abstract from P... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:process_text; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:text; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pmid; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:python2_path; 10, None; 11, block; 11, 12; 11, 14; 11, 15; 11, 1... | def process_text(text, pmid=None, python2_path=None):
"""Processes the specified plain text with TEES and converts output to
supported INDRA statements. Check for the TEES installation is the
TEES_PATH environment variable, and configuration file; if not found,
checks candidate paths in tees_candidate_p... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:run_on_text; 3, parameters; 3, 4; 3, 5; 4, identifier:text; 5, identifier:python2_path; 6, block; 6, 7; 6, 9; 6, 16; 6, 144; 6, 145; 6, 161; 6, 162; 6, 166; 6, 167; 6, 168; 6, 169; 6, 180; 6, 195; 6, 399; 6, 400; 6, 407; 6, 414; 7, expression_s... | def run_on_text(text, python2_path):
"""Runs TEES on the given text in a temporary directory and returns a
temporary directory with TEES output.
The caller should delete this directory when done with it. This function
runs TEES and produces TEES output files but does not process TEES output
int... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:extract_output; 3, parameters; 3, 4; 4, identifier:output_dir; 5, block; 5, 6; 5, 8; 5, 9; 5, 10; 5, 22; 5, 31; 5, 32; 5, 61; 5, 62; 5, 68; 5, 97; 5, 98; 5, 99; 5, 110; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, comment; 10, expr... | def extract_output(output_dir):
"""Extract the text of the a1, a2, and sentence segmentation files from the
TEES output directory. These files are located within a compressed archive.
Parameters
----------
output_dir : str
Directory containing the output of the TEES system
Returns
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_drug_inhibition_stmts; 3, parameters; 3, 4; 4, identifier:drug; 5, block; 5, 6; 5, 8; 5, 19; 5, 30; 5, 63; 5, 73; 5, 89; 5, 96; 5, 102; 5, 109; 5, 117; 5, 124; 5, 140; 5, 144; 5, 272; 6, expression_statement; 6, 7; 7, comment; 8, expression... | def get_drug_inhibition_stmts(drug):
"""Query ChEMBL for kinetics data given drug as Agent get back statements
Parameters
----------
drug : Agent
Agent representing drug with MESH or CHEBI grounding
Returns
-------
stmts : list of INDRA statements
INDRA statements generated... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:merge_groundings; 3, parameters; 3, 4; 4, identifier:stmts_in; 5, block; 5, 6; 5, 8; 5, 121; 5, 306; 5, 310; 5, 336; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 12; 8, 13; 8, 14; 9, function_name:surface_g... | def merge_groundings(stmts_in):
"""Gather and merge original grounding information from evidences.
Each Statement's evidences are traversed to find original grounding
information. These groundings are then merged into an overall consensus
grounding dict with as much detail as possible.
The current... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:merge_deltas; 3, parameters; 3, 4; 4, identifier:stmts_in; 5, block; 5, 6; 5, 8; 5, 12; 5, 308; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:stmts_out; 11, list:[]; 12, fo... | def merge_deltas(stmts_in):
"""Gather and merge original Influence delta information from evidence.
This function is only applicable to Influence Statements that have
subj and obj deltas. All other statement types are passed through unchanged.
Polarities and adjectives for subjects and objects respect... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:map_sequence; 3, parameters; 3, 4; 3, 5; 4, identifier:stmts_in; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 19; 7, 31; 7, 38; 7, 60; 7, 71; 7, 75; 7, 108; 7, 114; 7, 126; 7, 135; 7, 144; 7, 146; 8, expres... | def map_sequence(stmts_in, **kwargs):
"""Map sequences using the SiteMapper.
Parameters
----------
stmts_in : list[indra.statements.Statement]
A list of statements to map.
do_methionine_offset : boolean
Whether to check for off-by-one errors in site position (possibly)
attri... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:filter_by_type; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:stmts_in; 5, identifier:stmt_type; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 21; 8, 41; 8, 76; 8, 88; 8, 97; 8, 106; 9, expression_statement... | def filter_by_type(stmts_in, stmt_type, **kwargs):
"""Filter to a given statement type.
Parameters
----------
stmts_in : list[indra.statements.Statement]
A list of statements to filter.
stmt_type : indra.statements.Statement
The class of the statement type to filter for.
Exa... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:filter_grounded_only; 3, parameters; 3, 4; 3, 5; 4, identifier:stmts_in; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 20; 7, 32; 7, 36; 7, 45; 7, 129; 7, 141; 7, 150; 7, 159; 8, expression_statement; 8, 9; ... | def filter_grounded_only(stmts_in, **kwargs):
"""Filter to statements that have grounded agents.
Parameters
----------
stmts_in : list[indra.statements.Statement]
A list of statements to filter.
score_threshold : Optional[float]
If scored groundings are available in a list and the h... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:filter_genes_only; 3, parameters; 3, 4; 3, 5; 4, identifier:stmts_in; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 20; 7, 29; 7, 41; 7, 45; 7, 122; 7, 134; 7, 143; 7, 152; 8, expression_statement; 8, 9; 9, ... | def filter_genes_only(stmts_in, **kwargs):
"""Filter to statements containing genes only.
Parameters
----------
stmts_in : list[indra.statements.Statement]
A list of statements to filter.
specific_only : Optional[bool]
If True, only elementary genes/proteins will be kept and familie... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:filter_gene_list; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:stmts_in; 5, identifier:gene_list; 6, identifier:policy; 7, default_parameter; 7, 8; 7, 9; 8, identifier:allow_families; 9, False; 10, dictionary_splat_pattern; 10, ... | def filter_gene_list(stmts_in, gene_list, policy, allow_families=False,
**kwargs):
"""Return statements that contain genes given in a list.
Parameters
----------
stmts_in : list[indra.statements.Statement]
A list of statements to filter.
gene_list : list[str]
A ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:filter_by_db_refs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:stmts_in; 5, identifier:namespace; 6, identifier:values; 7, identifier:policy; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 13; 10... | def filter_by_db_refs(stmts_in, namespace, values, policy, **kwargs):
"""Filter to Statements whose agents are grounded to a matching entry.
Statements are filtered so that the db_refs entry (of the given namespace)
of their Agent/Concept arguments take a value in the given list of values.
Parameters
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:filter_human_only; 3, parameters; 3, 4; 3, 5; 4, identifier:stmts_in; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 16; 7, 35; 7, 44; 7, 56; 7, 60; 7, 93; 7, 157; 7, 169; 7, 178; 8, expression_statement; 8, ... | def filter_human_only(stmts_in, **kwargs):
"""Filter out statements that are grounded, but not to a human gene.
Parameters
----------
stmts_in : list[indra.statements.Statement]
A list of statements to filter.
save : Optional[str]
The name of a pickle file to save the results (stmts... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:filter_direct; 3, parameters; 3, 4; 3, 5; 4, identifier:stmts_in; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 66; 7, 78; 7, 82; 7, 99; 7, 111; 7, 120; 7, 129; 8, expression_statement; 8, 9; 9, comment; 10,... | def filter_direct(stmts_in, **kwargs):
"""Filter to statements that are direct interactions
Parameters
----------
stmts_in : list[indra.statements.Statement]
A list of statements to filter.
save : Optional[str]
The name of a pickle file to save the results (stmts_out) into.
Ret... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:filter_evidence_source; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:stmts_in; 5, identifier:source_apis; 6, default_parameter; 6, 7; 6, 8; 7, identifier:policy; 8, string:'one'; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwarg... | def filter_evidence_source(stmts_in, source_apis, policy='one', **kwargs):
"""Filter to statements that have evidence from a given set of sources.
Parameters
----------
stmts_in : list[indra.statements.Statement]
A list of statements to filter.
source_apis : list[str]
A list of sour... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:filter_inconsequential_mods; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:stmts_in; 5, default_parameter; 5, 6; 5, 7; 6, identifier:whitelist; 7, None; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 13; 10, 2... | def filter_inconsequential_mods(stmts_in, whitelist=None, **kwargs):
"""Filter out Modifications that modify inconsequential sites
Inconsequential here means that the site is not mentioned / tested
in any other statement. In some cases specific sites should be
preserved, for instance, to be used as rea... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:filter_inconsequential_acts; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:stmts_in; 5, default_parameter; 5, 6; 5, 7; 6, identifier:whitelist; 7, None; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 13; 10, 2... | def filter_inconsequential_acts(stmts_in, whitelist=None, **kwargs):
"""Filter out Activations that modify inconsequential activities
Inconsequential here means that the site is not mentioned / tested
in any other statement. In some cases specific activity types should be
preserved, for instance, to be... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:render_stmt_graph; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:statements; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reduce; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:english; 10, False; 11, default_param... | def render_stmt_graph(statements, reduce=True, english=False, rankdir=None,
agent_style=None):
"""Render the statement hierarchy as a pygraphviz graph.
Parameters
----------
stmts : list of :py:class:`indra.statements.Statement`
A list of top-level statements with associat... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:flatten_stmts; 3, parameters; 3, 4; 4, identifier:stmts; 5, block; 5, 6; 5, 8; 5, 15; 5, 42; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:total_stmts; 11, call; 11, 12; 11... | def flatten_stmts(stmts):
"""Return the full set of unique stms in a pre-assembled stmt graph.
The flattened list of statements returned by this function can be
compared to the original set of unique statements to make sure no
statements have been lost during the preassembly process.
Parameters
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:combine_duplicate_stmts; 3, parameters; 3, 4; 4, identifier:stmts; 5, block; 5, 6; 5, 8; 5, 9; 5, 41; 5, 42; 5, 46; 5, 339; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, function_definition; 9, 10; 9, 11; 9, 13; 10, function_name:_e... | def combine_duplicate_stmts(stmts):
"""Combine evidence from duplicate Statements.
Statements are deemed to be duplicates if they have the same key
returned by the `matches_key()` method of the Statement class. This
generally means that statements must be identical in terms of their
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_get_stmt_by_group; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:stmt_type; 6, identifier:stmts_this_type; 7, identifier:eh; 8, block; 8, 9; 8, 11; 8, 12; 8, 22; 8, 23; 8, 33; 8, 34; 8, 44; 8, 45; 8, 55; 8, 56; 8, 57... | def _get_stmt_by_group(self, stmt_type, stmts_this_type, eh):
"""Group Statements of `stmt_type` by their hierarchical relations."""
# Dict of stmt group key tuples, indexed by their first Agent
stmt_by_first = collections.defaultdict(lambda: [])
# Dict of stmt group key tuples, indexed ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:combine_related; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:return_toplevel; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:poolsize; 10, None; 11, default_parameter; ... | def combine_related(self, return_toplevel=True, poolsize=None,
size_cutoff=100):
"""Connect related statements based on their refinement relationships.
This function takes as a starting point the unique statements (with
duplicates removed) and returns a modified flat lis... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:find_contradicts; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 17; 5, 27; 5, 52; 5, 53; 5, 61; 5, 71; 5, 77; 5, 83; 5, 87; 5, 195; 5, 196; 5, 202; 5, 252; 6, expression_statement; 6, 7; 7, comment; 8, expression_stat... | def find_contradicts(self):
"""Return pairs of contradicting Statements.
Returns
-------
contradicts : list(tuple(Statement, Statement))
A list of Statement pairs that are contradicting.
"""
eh = self.hierarchies['entity']
# Make a dict of Statement ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_text_content_for_pmids; 3, parameters; 3, 4; 4, identifier:pmids; 5, block; 5, 6; 5, 8; 5, 23; 5, 27; 5, 64; 5, 68; 5, 74; 5, 111; 5, 122; 5, 126; 5, 153; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignme... | def get_text_content_for_pmids(pmids):
"""Get text content for articles given a list of their pmids
Parameters
----------
pmids : list of str
Returns
-------
text_content : list of str
"""
pmc_pmids = set(pmc_client.filter_pmids(pmids, source_type='fulltext'))
pmc_ids = []
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:export_sbgn; 3, parameters; 3, 4; 4, identifier:model; 5, block; 5, 6; 5, 8; 5, 12; 5, 16; 5, 22; 5, 29; 5, 38; 5, 43; 5, 49; 5, 53; 5, 94; 5, 321; 5, 334; 6, expression_statement; 6, 7; 7, comment; 8, import_statement; 8, 9; 9, dotted_name; 9,... | def export_sbgn(model):
"""Return an SBGN model string corresponding to the PySB model.
This function first calls generate_equations on the PySB model to obtain
a reaction network (i.e. individual species, reactions). It then iterates
over each reaction and and instantiates its reactants, products, and... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_profile_data; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:study_id; 5, identifier:gene_list; 6, identifier:profile_filter; 7, default_parameter; 7, 8; 7, 9; 8, identifier:case_set_filter; 9, None; 10, block; 10, 11; 10, 13; 10, 21... | def get_profile_data(study_id, gene_list,
profile_filter, case_set_filter=None):
"""Return dict of cases and genes and their respective values.
Parameters
----------
study_id : str
The ID of the cBio study.
Example: 'cellline_ccle_broad' or 'paad_icgc'
gene_list... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:print_cx; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pretty; 7, True; 8, block; 8, 9; 8, 11; 8, 66; 8, 72; 8, 82; 8, 96; 8, 102; 8, 125; 8, 143; 8, 156; 8, 173; 8, 199; 9, expression_statement... | def print_cx(self, pretty=True):
"""Return the assembled CX network as a json string.
Parameters
----------
pretty : bool
If True, the CX string is formatted with indentation (for human
viewing) otherwise no indentation is used.
Returns
-------
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_context; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:cell_type; 6, block; 6, 7; 6, 9; 6, 23; 6, 34; 6, 45; 6, 54; 6, 63; 6, 81; 6, 99; 6, 107; 6, 124; 6, 128; 6, 243; 7, expression_statement; 7, 8; 8, comment; 9, expression... | def set_context(self, cell_type):
"""Set protein expression data and mutational status as node attribute
This method uses :py:mod:`indra.databases.context_client` to get
protein expression levels and mutational status for a given cell type
and set a node attribute for proteins according... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_ids; 3, parameters; 3, 4; 3, 5; 4, identifier:search_term; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 20; 7, 27; 7, 46; 7, 53; 7, 61; 7, 68; 7, 94; 7, 134; 7, 148; 7, 157; 7, 164; 7, 174; 7, 197; 8, e... | def get_ids(search_term, **kwargs):
"""Search Pubmed for paper IDs given a search term.
Search options can be passed as keyword arguments, some of which are
custom keywords identified by this function, while others are passed on
as parameters for the request to the PubMed web service
For details on... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_ids_for_gene; 3, parameters; 3, 4; 3, 5; 4, identifier:hgnc_name; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 11; 7, 20; 7, 30; 7, 31; 7, 40; 7, 50; 7, 51; 7, 64; 7, 71; 7, 79; 7, 86; 7, 112; 7, 113; 7... | def get_ids_for_gene(hgnc_name, **kwargs):
"""Get the curated set of articles for a gene in the Entrez database.
Search parameters for the Gene database query can be passed in as
keyword arguments.
Parameters
----------
hgnc_name : string
The HGNC name of the gene. This is used to obt... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_im; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:force_update; 7, False; 8, block; 8, 9; 8, 11; 8, 23; 8, 34; 8, 126; 8, 127; 8, 128; 8, 139; 8, 299; 8, 300; 8, 321; 8, 328; 8, 341; 8, 342; ... | def get_im(self, force_update=False):
"""Get the influence map for the model, generating it if necessary.
Parameters
----------
force_update : bool
Whether to generate the influence map when the function is called.
If False, returns the previously generated influ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:check_statement; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:stmt; 6, default_parameter; 6, 7; 6, 8; 7, identifier:max_paths; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:max_path_length; 11, in... | def check_statement(self, stmt, max_paths=1, max_path_length=5):
"""Check a single Statement against the model.
Parameters
----------
stmt : indra.statements.Statement
The Statement to check.
max_paths : Optional[int]
The maximum number of specific paths ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:score_paths; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:self; 5, identifier:paths; 6, identifier:agents_values; 7, default_parameter; 7, 8; 7, 9; 8, identifier:loss_of_function; 9, False; 10, default_parameter; 10, 11; ... | def score_paths(self, paths, agents_values, loss_of_function=False,
sigma=0.15, include_final_node=False):
"""Return scores associated with a given set of paths.
Parameters
----------
paths : list[list[tuple[str, int]]]
A list of paths obtained from path ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prune_influence_map; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 17; 5, 24; 5, 28; 5, 66; 5, 67; 5, 74; 5, 75; 5, 83; 5, 84; 5, 91; 5, 95; 5, 117; 5, 118; 5, 125; 5, 137; 5, 151; 5, 163; 5, 164; 5, 165; 5, 169; 5, 2... | def prune_influence_map(self):
"""Remove edges between rules causing problematic non-transitivity.
First, all self-loops are removed. After this initial step, edges are
removed between rules when they share *all* child nodes except for each
other; that is, they have a mutual relationshi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:send_request; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:ndex_service_url; 5, identifier:params; 6, default_parameter; 6, 7; 6, 8; 7, identifier:is_json; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:use_get; 11, False;... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_hash; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:shallow; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:refresh; 10, False; 11, block; 11, 12; 11, 14; 11, 116; 12, expre... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:to_json; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:use_sbo; 7, False; 8, block; 8, 9; 8, 11; 8, 20; 8, 21; 8, 34; 8, 58; 8, 59; 8, 68; 8, 76; 8, 101; 8, 111; 8, 133; 8, 155; 8, 204; 8, 224; 9... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:to_graph; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 230; 5, 238; 5, 246; 5, 258; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 14; 9, function_name:json_node; 10, parameters; 10, 11; ... | 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='')
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_bel_stmts; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:filter; 7, False; 8, block; 8, 9; 8, 11; 8, 26; 8, 27; 8, 126; 8, 127; 8, 153; 9, expression_statement; 9, 10; 10, comment; 11, if_sta... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_biopax_stmts; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:filter; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:query; 10, string:'pathsbetween'; 11, default_para... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:run_preassembly; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:stmts; 6, default_parameter; 6, 7; 6, 8; 7, identifier:print_summary; 8, True; 9, block; 9, 10; 9, 12; 9, 13; 9, 21; 9, 28; 9, 34; 9, 35; 9, 42; 9, 55; 9, 56; 9... | 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
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_grounding; 3, parameters; 3, 4; 4, identifier:entity; 5, block; 5, 6; 5, 8; 5, 17; 5, 26; 5, 32; 5, 109; 5, 110; 5, 127; 5, 128; 5, 129; 5, 133; 5, 158; 5, 159; 5, 160; 5, 161; 5, 162; 5, 163; 5, 164; 5, 204; 5, 205; 5, 206; 5, 215; 6, exp... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_is_statement_in_list; 3, parameters; 3, 4; 3, 5; 4, identifier:new_stmt; 5, identifier:old_stmt_list; 6, block; 6, 7; 6, 9; 6, 273; 7, expression_statement; 7, 8; 8, comment; 9, for_statement; 9, 10; 9, 11; 9, 12; 10, identifier:old_stmt; 11, ... | 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
----------
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_urn_to_db_refs; 3, parameters; 3, 4; 4, identifier:urn; 5, block; 5, 6; 5, 8; 5, 9; 5, 18; 5, 27; 5, 36; 5, 46; 5, 50; 5, 54; 5, 55; 5, 240; 5, 241; 5, 242; 5, 248; 5, 278; 5, 279; 5, 280; 5, 322; 5, 323; 5, 329; 5, 342; 5, 343; 5, 370; 6, exp... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:symmetricsys; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 4, default_parameter; 4, 5; 4, 6; 5, identifier:dep_tr; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:indep_tr; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:Su... | def symmetricsys(dep_tr=None, indep_tr=None, SuperClass=TransformedSys, **kwargs):
""" A factory function for creating symmetrically transformed systems.
Creates a new subclass which applies the same transformation for each dependent variable.
Parameters
----------
dep_tr : pair of callables (defa... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:from_other; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:ori; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 47; 8, 68; 8, 89; 8, 122; 8, 155; 8, 174; 8, 187; 8, 195; 8, 219; 9, expressio... | def from_other(cls, ori, **kwargs):
""" Creates a new instance with an existing one as a template.
Parameters
----------
ori : SymbolicSys instance
\\*\\*kwargs:
Keyword arguments used to create the new instance.
Returns
-------
A new instanc... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:from_linear_invariants; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:cls; 5, identifier:ori_sys; 6, default_parameter; 6, 7; 6, 8; 7, identifier:preferred; 8, None; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, block; ... | def from_linear_invariants(cls, ori_sys, preferred=None, **kwargs):
""" Reformulates the ODE system in fewer variables.
Given linear invariant equations one can always reduce the number
of dependent variables in the system by the rank of the matrix describing
this linear system.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:chained_parameter_variation; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:subject; 5, identifier:durations; 6, identifier:y0; 7, identifier:varied_params; 8, default_parameter; 8, 9; 8, 10; 9, identifi... | def chained_parameter_variation(subject, durations, y0, varied_params, default_params=None,
integrate_kwargs=None, x0=None, npoints=1, numpy=None):
""" Integrate an ODE-system for a serie of durations with some parameters changed in-between
Parameters
----------
subject ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:integrate; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 4, identifier:self; 5, identifier:x; 6, identifier:y0; 7, default_parameter; 7, 8; 7, 9; 8, identifier:params; 9, tuple; 10, default_parameter; 10, 11; 10, 12; 11, identifi... | def integrate(self, x, y0, params=(), atol=1e-8, rtol=1e-8, **kwargs):
""" Integrate the system of ordinary differential equations.
Solves the initial value problem (IVP).
Parameters
----------
x : array_like or pair (start and final time) or float
if float:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_data; 3, parameters; 3, 4; 3, 5; 4, identifier:data; 5, identifier:cols; 6, block; 6, 7; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, return_statement; 9, 10; 10, call; 10, 11; 10, 24; 11, attribute; 11, 12; 11, 23; 12, subscript; 1... | def sort_data(data, cols):
"""Sort `data` rows and order columns"""
return data.sort_values(cols)[cols + ['value']].reset_index(drop=True) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:filter_by_meta; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:data; 5, identifier:df; 6, default_parameter; 6, 7; 6, 8; 7, identifier:join_meta; 8, False; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, block; 11, 12; 11,... | def filter_by_meta(data, df, join_meta=False, **kwargs):
"""Filter by and join meta columns from an IamDataFrame to a pd.DataFrame
Parameters
----------
data: pd.DataFrame instance
DataFrame to which meta columns are to be joined,
index or columns must include `['model', 'scenario']`
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:append; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ignore_meta_conflict; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:inplace; 11, Fals... | def append(self, other, ignore_meta_conflict=False, inplace=False,
**kwargs):
"""Append any castable object to this IamDataFrame.
Columns in `other.meta` that are not in `self.meta` are always merged,
duplicate region-variable-unit-year rows raise a ValueError.
Parameters... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:pivot_table; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 4, identifier:self; 5, identifier:index; 6, identifier:columns; 7, default_parameter; 7, 8; 7, 9; 8, identifier:values; 9, string:'value'; 10, default_parameter; 10, 11; ... | def pivot_table(self, index, columns, values='value',
aggfunc='count', fill_value=None, style=None):
"""Returns a pivot table
Parameters
----------
index: str or list of strings
rows for Pivot table
columns: str or list of strings
colu... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:check_internal_consistency; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 14; 7, 70; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11... | def check_internal_consistency(self, **kwargs):
"""Check whether the database is internally consistent
We check that all variables are equal to the sum of their sectoral
components and that all the regions add up to the World total. If
the check is passed, None is returned, otherwise a ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_apply_filters; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:filters; 7, block; 7, 8; 7, 10; 7, 20; 7, 37; 7, 38; 7, 437; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10... | def _apply_filters(self, **filters):
"""Determine rows to keep in data for given set of filters
Parameters
----------
filters: dict
dictionary of filters ({col: values}}); uses a pseudo-regexp syntax
by default, but accepts `regexp: True` to use regexp directly
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:load_metadata; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 8; 4, identifier:self; 5, identifier:path; 6, list_splat_pattern; 6, 7; 7, identifier:args; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 13; 10, 33; 10, 98; ... | def load_metadata(self, path, *args, **kwargs):
"""Load metadata exported from `pyam.IamDataFrame` instance
Parameters
----------
path: string
xlsx file with metadata exported from `pyam.IamDataFrame` instance
"""
if not os.path.exists(path):
rais... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:assign_style_props; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:df; 5, default_parameter; 5, 6; 5, 7; 6, identifier:color; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:marker; 10, None; 11, default_parameter; 11, ... | def assign_style_props(df, color=None, marker=None, linestyle=None,
cmap=None):
"""Assign the style properties for a plot
Parameters
----------
df : pd.DataFrame
data to be used for style properties
"""
if color is None and cmap is not None:
raise ValueErr... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 38; 2, function_name:scatter; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 33; 3, 36; 4, identifier:df; 5, identifier:x; 6, identifier:y; 7, default_parameter; 7, 8; 7, 9; 8, identifier:ax; 9, None; 10, default_paramet... | def scatter(df, x, y, ax=None, legend=None, title=None,
color=None, marker='o', linestyle=None, cmap=None,
groupby=['model', 'scenario'], with_lines=False, **kwargs):
"""Plot data as a scatter chart.
Parameters
----------
df : pd.DataFrame
Data to plot as a long-form dat... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:config_create; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:kernel; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:label; 10, None; 11, default_para... | def config_create(self, kernel=None, label=None, devices=[], disks=[],
volumes=[], **kwargs):
"""
Creates a Linode Config with the given attributes.
:param kernel: The kernel to boot with.
:param label: The config label
:param disks: The list of disks, starting at sd... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:clone; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:to_linode; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:region; 10, None; 11, de... | def clone(self, to_linode=None, region=None, service=None, configs=[], disks=[],
label=None, group=None, with_backups=None):
""" Clones this linode into a new linode or into a new linode in the given region """
if to_linode and region:
raise ValueError('You may only specify one o... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_populate; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:json; 6, block; 6, 7; 6, 9; 6, 14; 6, 15; 6, 23; 6, 412; 6, 420; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 12; 10, not_operator; 10, 11; 11, ide... | def _populate(self, json):
"""
A helper method that, given a JSON object representing this object,
assigns values based on the properties dict and the attributes of
its Properties.
"""
if not json:
return
# hide the raw JSON away in case someone needs... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:_api_call; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:endpoint; 6, default_parameter; 6, 7; 6, 8; 7, identifier:model; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:method; 11, None; 12... | def _api_call(self, endpoint, model=None, method=None, data=None, filters=None):
"""
Makes a call to the linode api. Data should only be given if the method is
POST or PUT, and should be a dictionary
"""
if not self.token:
raise RuntimeError("You do not have an API t... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:tag_create; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:label; 6, default_parameter; 6, 7; 6, 8; 7, identifier:instances; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:domains; 11... | def tag_create(self, label, instances=None, domains=None, nodebalancers=None,
volumes=None, entities=[]):
"""
Creates a new Tag and optionally applies it to the given entities.
:param label: The label for the new Tag
:type label: str
:param entities: A list of... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:validate_anneal_schedule; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:anneal_schedule; 6, block; 6, 7; 6, 9; 6, 21; 6, 27; 6, 51; 6, 52; 6, 53; 6, 100; 6, 120; 6, 121; 6, 148; 6, 149; 6, 167; 6, 180; 6, 190; 6, 244; 6, 245; 6, ... | def validate_anneal_schedule(self, anneal_schedule):
"""Raise an exception if the specified schedule is invalid for the sampler.
Args:
anneal_schedule (list):
An anneal schedule variation is defined by a series of pairs of floating-point
numbers identifying p... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:target_to_source; 3, parameters; 3, 4; 3, 5; 4, identifier:target_adjacency; 5, identifier:embedding; 6, block; 6, 7; 6, 9; 6, 10; 6, 22; 6, 23; 6, 27; 6, 61; 6, 62; 6, 120; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, expression_... | def target_to_source(target_adjacency, embedding):
"""Derive the source adjacency from an embedding and target adjacency.
Args:
target_adjacency (dict/:class:`networkx.Graph`):
A dict of the form {v: Nv, ...} where v is a node in the target graph and Nv is the
neighbors of v as ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:insert_graph; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:cur; 5, identifier:nodelist; 6, identifier:edgelist; 7, default_parameter; 7, 8; 7, 9; 8, identifier:encoded_data; 9, None; 10, block; 10, 11; 10, 13; 10, 22; 10, 36; 10, 50; 1... | def insert_graph(cur, nodelist, edgelist, encoded_data=None):
"""Insert a graph into the cache.
A graph is stored by number of nodes, number of edges and a
json-encoded list of edges.
Args:
cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function
is meant to be run within a ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:draw_chimera_bqm; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:bqm; 5, default_parameter; 5, 6; 5, 7; 6, identifier:width; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:height; 10, None; 11, block; 11, 12; 11, 14; 11, 24; 11, 34;... | def draw_chimera_bqm(bqm, width=None, height=None):
"""Draws a Chimera Graph representation of a Binary Quadratic Model.
If cell width and height not provided assumes square cell dimensions.
Throws an error if drawing onto a Chimera graph of the given dimensions fails.
Args:
bqm (:obj:`dimod.B... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:embed_bqm; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:source_bqm; 5, identifier:embedding; 6, identifier:target_adjacency; 7, default_parameter; 7, 8; 7, 9; 8, identifier:chain_strength; 9, float:1.0; 10, default_parameter; 10... | def embed_bqm(source_bqm, embedding, target_adjacency, chain_strength=1.0,
smear_vartype=None):
"""Embed a binary quadratic model onto a target graph.
Args:
source_bqm (:obj:`.BinaryQuadraticModel`):
Binary quadratic model to embed.
embedding (dict):
Mappi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:embed_ising; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:source_h; 5, identifier:source_J; 6, identifier:embedding; 7, identifier:target_adjacency; 8, default_parameter; 8, 9; 8, 10; 9, identifier:chain_strength; 10, float:1.0; ... | def embed_ising(source_h, source_J, embedding, target_adjacency, chain_strength=1.0):
"""Embed an Ising problem onto a target graph.
Args:
source_h (dict[variable, bias]/list[bias]):
Linear biases of the Ising problem. If a list, the list's indices are used as
variable labels.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:unembed_sampleset; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:target_sampleset; 5, identifier:embedding; 6, identifier:source_bqm; 7, default_parameter; 7, 8; 7, 9; 8, identifier:chain_break_method; 9, None; 10, default_parame... | def unembed_sampleset(target_sampleset, embedding, source_bqm,
chain_break_method=None, chain_break_fraction=False):
"""Unembed the samples set.
Construct a sample set for the source binary quadratic model (BQM) by
unembedding the given samples from the target BQM.
Args:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:nativeCliqueEmbed; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:width; 6, block; 6, 7; 6, 9; 6, 13; 6, 25; 6, 29; 6, 33; 6, 37; 6, 157; 6, 161; 6, 197; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 1... | def nativeCliqueEmbed(self, width):
"""Compute a maximum-sized native clique embedding in an induced
subgraph of chimera with all chainlengths ``width+1``.
INPUTS:
width: width of the squares to search, also `chainlength`-1
OUTPUT:
score: the score for the retur... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:find_clique_embedding; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:k; 5, identifier:m; 6, default_parameter; 6, 7; 6, 8; 7, identifier:n; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:t; 11, None; 12, default_para... | def find_clique_embedding(k, m, n=None, t=None, target_edges=None):
"""Find an embedding for a clique in a Chimera graph.
Given a target :term:`Chimera` graph size, and a clique (fully connect graph),
attempts to find an embedding.
Args:
k (int/iterable):
Clique to embed. If k is a... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:find_grid_embedding; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:dim; 5, identifier:m; 6, default_parameter; 6, 7; 6, 8; 7, identifier:n; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:t; 11, integer:4; 12, block; 12, 13;... | def find_grid_embedding(dim, m, n=None, t=4):
"""Find an embedding for a grid in a Chimera graph.
Given a target :term:`Chimera` graph size, and grid dimensions, attempts to find an embedding.
Args:
dim (iterable[int]):
Sizes of each grid dimension. Length can be between 1 and 3.
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sample; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:bqm; 6, dictionary_splat_pattern; 6, 7; 7, identifier:parameters; 8, block; 8, 9; 8, 11; 8, 17; 8, 23; 8, 29; 8, 35; 8, 56; 8, 57; 8, 103; 8, 104; 8, 105; 8, 106; 8, 121... | def sample(self, bqm, **parameters):
"""Cutoff and sample from the provided binary quadratic model.
Removes interactions smaller than a given cutoff. Isolated
variables (after the cutoff) are also removed.
Note that if the problem had isolated variables before the cutoff, they
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sample_poly; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:poly; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 17; 8, 23; 8, 29; 8, 35; 8, 66; 8, 67; 8, 107; 8, 108; 8, 132; 8, 133; 8, 1... | def sample_poly(self, poly, **kwargs):
"""Cutoff and sample from the provided binary polynomial.
Removes interactions smaller than a given cutoff. Isolated
variables (after the cutoff) are also removed.
Note that if the problem had isolated variables before the cutoff, they
wil... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:diagnose_embedding; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:emb; 5, identifier:source; 6, identifier:target; 7, block; 7, 8; 7, 10; 7, 27; 7, 44; 7, 48; 7, 54; 7, 171; 7, 179; 7, 206; 8, expression_statement; 8, 9; 9, comment; 10, if_sta... | def diagnose_embedding(emb, source, target):
"""A detailed diagnostic for minor embeddings.
This diagnostic produces a generator, which lists all issues with `emb`. The errors
are yielded in the form
ExceptionClass, arg1, arg2,...
where the arguments following the class are used to construct ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:response; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 13; 3, 16; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:model; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:code; 10, attribute; 10, 11; 10, 12; 11, identifier:H... | def response(self, model=None, code=HTTPStatus.OK, description=None, **kwargs):
"""
Endpoint response OpenAPI documentation decorator.
It automatically documents HTTPError%(code)d responses with relevant
schemas.
Arguments:
model (flask_marshmallow.Schema) - it can ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:enrich_items; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:ocean_backend; 6, default_parameter; 6, 7; 6, 8; 7, identifier:events; 8, False; 9, block; 9, 10; 9, 12; 9, 20; 9, 24; 9, 28; 9, 32; 9, 40; 9, 44; 9, 54; 9, 70; 9,... | def enrich_items(self, ocean_backend, events=False):
""" A custom enrich items is needed because apart from the enriched
events from raw items, a image item with the last data for an image
must be created """
max_items = self.elastic.max_items_bulk
current = 0
total = 0
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:add_identity; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:cls; 5, identifier:db; 6, identifier:identity; 7, identifier:backend; 8, block; 8, 9; 8, 11; 8, 15; 8, 156; 8, 206; 9, expression_statement; 9, 10; 10, comment; 11, expression_s... | def add_identity(cls, db, identity, backend):
""" Load and identity list from backend in Sorting Hat """
uuid = None
try:
uuid = api.add_identity(db, backend, identity['email'],
identity['name'], identity['username'])
logger.debug("Ne... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:add_identities; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:cls; 5, identifier:db; 6, identifier:identities; 7, identifier:backend; 8, block; 8, 9; 8, 11; 8, 18; 8, 22; 8, 57; 9, expression_statement; 9, 10; 10, comment; 11, expression... | def add_identities(cls, db, identities, backend):
""" Load identities list from backend in Sorting Hat """
logger.info("Adding the identities to SortingHat")
total = 0
for identity in identities:
try:
cls.add_identity(db, identity, backend)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:remove_identity; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:sh_db; 6, identifier:ident_id; 7, block; 7, 8; 7, 10; 7, 14; 7, 53; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignment; ... | def remove_identity(cls, sh_db, ident_id):
"""Delete an identity from SortingHat.
:param sh_db: SortingHat database
:param ident_id: identity identifier
"""
success = False
try:
api.delete_identity(sh_db, ident_id)
logger.debug("Identity %s delete... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:remove_unique_identity; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:sh_db; 6, identifier:uuid; 7, block; 7, 8; 7, 10; 7, 14; 7, 53; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignmen... | def remove_unique_identity(cls, sh_db, uuid):
"""Delete a unique identity from SortingHat.
:param sh_db: SortingHat database
:param uuid: Unique identity identifier
"""
success = False
try:
api.delete_unique_identity(sh_db, uuid)
logger.debug("Uni... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:unique_identities; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:sh_db; 6, block; 6, 7; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, try_statement; 9, 10; 9, 23; 10, block; 10, 11; 11, for_statement; 11, 12; 11, 13; 11, 19;... | def unique_identities(cls, sh_db):
"""List the unique identities available in SortingHat.
:param sh_db: SortingHat database
"""
try:
for unique_identity in api.unique_identities(sh_db):
yield unique_identity
except Exception as e:
logger.d... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:refresh_identities; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:enrich_backend; 5, default_parameter; 5, 6; 5, 7; 6, identifier:author_field; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:author_values; 10, None; 11, block; 11, ... | def refresh_identities(enrich_backend, author_field=None, author_values=None):
"""Refresh identities in enriched index.
Retrieve items from the enriched index corresponding to enrich_backend,
and update their identities information, with fresh data from the
SortingHat database.
Instead of the whol... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:get_ocean_backend; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:backend_cmd; 5, identifier:enrich_backend; 6, identifier:no_incremental; 7, default_parameter; 7, 8; 7, 9; 8, identifier:filter_raw; 9, None; 10, default_parameter;... | def get_ocean_backend(backend_cmd, enrich_backend, no_incremental,
filter_raw=None, filter_raw_should=None):
""" Get the ocean backend configured to start from the last enriched date """
if no_incremental:
last_enrich = None
else:
last_enrich = get_last_enrich(backend_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:delete_orphan_unique_identities; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:es; 5, identifier:sortinghat_db; 6, identifier:current_data_source; 7, identifier:active_data_sources; 8, block; 8, 9; 8, 11; 8, 77; 8, 113; 8, 161; 8, 193; 8... | def delete_orphan_unique_identities(es, sortinghat_db, current_data_source, active_data_sources):
"""Delete all unique identities which appear in SortingHat, but not in the IDENTITIES_INDEX.
:param es: ElasticSearchDSL object
:param sortinghat_db: instance of the SortingHat database
:param current_data... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:delete_inactive_unique_identities; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:es; 5, identifier:sortinghat_db; 6, identifier:before_date; 7, block; 7, 8; 7, 10; 7, 42; 7, 48; 7, 56; 7, 71; 7, 75; 7, 147; 8, expression_statement; 8, 9; 9, co... | def delete_inactive_unique_identities(es, sortinghat_db, before_date):
"""Select the unique identities not seen before `before_date` and
delete them from SortingHat.
:param es: ElasticSearchDSL object
:param sortinghat_db: instance of the SortingHat database
:param before_date: datetime str to filt... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:retain_identities; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:retention_time; 5, identifier:es_enrichment_url; 6, identifier:sortinghat_db; 7, identifier:data_source; 8, identifier:active_data_sources; 9, block; 9, 10; 9, 12; 9,... | def retain_identities(retention_time, es_enrichment_url, sortinghat_db, data_source, active_data_sources):
"""Select the unique identities not seen before `retention_time` and
delete them from SortingHat. Furthermore, it deletes also the orphan unique identities,
those ones stored in SortingHat but not in I... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_review_sh; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:revision; 6, identifier:item; 7, block; 7, 8; 7, 10; 7, 19; 7, 34; 7, 44; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; 11, assignm... | def get_review_sh(self, revision, item):
""" Add sorting hat enrichment fields for the author of the revision """
identity = self.get_sh_identity(revision)
update = parser.parse(item[self.get_field_date()])
erevision = self.get_item_sh_fields(identity, update)
return erevision |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:get_item_sh; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:item; 6, default_parameter; 6, 7; 6, 8; 7, identifier:roles; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:date_field; 11, None; 12, block; 12,... | def get_item_sh(self, item, roles=None, date_field=None):
"""
Add sorting hat enrichment fields for different roles
If there are no roles, just add the author fields.
"""
eitem_sh = {} # Item enriched
author_field = self.get_field_author()
if not roles:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.