Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def _any_bound_condition_fails_criterion(agent, criterion):
bc_agents = [bc.agent for bc in agent.bound_conditions]
for b in bc_agents:
if not criterion(b):
return True
return False | [
"Returns True if any bound condition fails to meet the specified\n criterion.\n\n Parameters\n ----------\n agent: Agent\n The agent whose bound conditions we evaluate\n criterion: function\n Evaluates criterion(a) for each a in a bound condition and returns True\n if any agents ... |
Please provide a description of the function:def filter_grounded_only(stmts_in, **kwargs):
remove_bound = kwargs.get('remove_bound', False)
logger.info('Filtering %d statements for grounded agents...' %
len(stmts_in))
stmts_out = []
score_threshold = kwargs.get('score_threshold')
... | [
"Filter to statements that have grounded agents.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to filter.\n score_threshold : Optional[float]\n If scored groundings are available in a list and the highest score\n if below this thres... |
Please provide a description of the function:def _agent_is_gene(agent, specific_only):
if not specific_only:
if not(agent.db_refs.get('HGNC') or \
agent.db_refs.get('UP') or \
agent.db_refs.get('FPLX')):
return False
else:
if not(agent.db_refs.get('... | [
"Returns whether an agent is for a gene.\n\n Parameters\n ----------\n agent: Agent\n The agent to evaluate\n specific_only : Optional[bool]\n If True, only elementary genes/proteins evaluate as genes and families\n will be filtered out. If False, families are also included.\n\n ... |
Please provide a description of the function:def filter_genes_only(stmts_in, **kwargs):
remove_bound = 'remove_bound' in kwargs and kwargs['remove_bound']
specific_only = kwargs.get('specific_only')
logger.info('Filtering %d statements for ones containing genes only...' %
len(stmts_in... | [
"Filter to statements containing genes only.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to filter.\n specific_only : Optional[bool]\n If True, only elementary genes/proteins will be kept and families\n will be filtered out. If Fa... |
Please provide a description of the function:def filter_belief(stmts_in, belief_cutoff, **kwargs):
dump_pkl = kwargs.get('save')
logger.info('Filtering %d statements to above %f belief' %
(len(stmts_in), belief_cutoff))
# The first round of filtering is in the top-level list
stmts_o... | [
"Filter to statements with belief above a given cutoff.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to filter.\n belief_cutoff : float\n Only statements with belief above the belief_cutoff will be returned.\n Here 0 < belief_cutof... |
Please provide a description of the function:def filter_gene_list(stmts_in, gene_list, policy, allow_families=False,
**kwargs):
invert = kwargs.get('invert', False)
remove_bound = kwargs.get('remove_bound', False)
if policy not in ('one', 'all'):
logger.error('Policy %s is... | [
"Return statements that contain genes given in a list.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to filter.\n gene_list : list[str]\n A list of gene symbols to filter for.\n policy : str\n The policy to apply when filtering f... |
Please provide a description of the function:def filter_concept_names(stmts_in, name_list, policy, **kwargs):
invert = kwargs.get('invert', False)
if policy not in ('one', 'all'):
logger.error('Policy %s is invalid, not applying filter.' % policy)
else:
name_str = ', '.join(name_list)
... | [
"Return Statements that refer to concepts/agents given as a list of names.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of Statements to filter.\n name_list : list[str]\n A list of concept/agent names to filter for.\n policy : str\n The polic... |
Please provide a description of the function:def filter_by_db_refs(stmts_in, namespace, values, policy, **kwargs):
invert = kwargs.get('invert', False)
match_suffix = kwargs.get('match_suffix', False)
if policy not in ('one', 'all'):
logger.error('Policy %s is invalid, not applying filter.' % ... | [
"Filter to Statements whose agents are grounded to a matching entry.\n\n Statements are filtered so that the db_refs entry (of the given namespace)\n of their Agent/Concept arguments take a value in the given list of values.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n ... |
Please provide a description of the function:def filter_human_only(stmts_in, **kwargs):
from indra.databases import uniprot_client
if 'remove_bound' in kwargs and kwargs['remove_bound']:
remove_bound = True
else:
remove_bound = False
dump_pkl = kwargs.get('save')
logger.info('F... | [
"Filter out statements that are grounded, but not to a human gene.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to filter.\n save : Optional[str]\n The name of a pickle file to save the results (stmts_out) into.\n remove_bound: Optiona... |
Please provide a description of the function:def filter_direct(stmts_in, **kwargs):
def get_is_direct(stmt):
any_indirect = False
for ev in stmt.evidence:
if ev.epistemics.get('direct') is True:
return True
elif ev.epistemics.get('direct') is Fal... | [
"Filter to statements that are direct interactions\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to filter.\n save : Optional[str]\n The name of a pickle file to save the results (stmts_out) into.\n\n Returns\n -------\n stmts_out... |
Please provide a description of the function:def filter_no_hypothesis(stmts_in, **kwargs):
logger.info('Filtering %d statements to no hypothesis...' % len(stmts_in))
stmts_out = []
for st in stmts_in:
all_hypotheses = True
ev = None
for ev in st.evidence:
if not ev.e... | [
"Filter to statements that are not marked as hypothesis in epistemics.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to filter.\n save : Optional[str]\n The name of a pickle file to save the results (stmts_out) into.\n\n Returns\n --... |
Please provide a description of the function:def filter_evidence_source(stmts_in, source_apis, policy='one', **kwargs):
logger.info('Filtering %d statements to evidence source "%s" of: %s...' %
(len(stmts_in), policy, ', '.join(source_apis)))
stmts_out = []
for st in stmts_in:
s... | [
"Filter to statements that have evidence from a given set of sources.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to filter.\n source_apis : list[str]\n A list of sources to filter for. Examples: biopax, bel, reach\n policy : Optional... |
Please provide a description of the function:def filter_top_level(stmts_in, **kwargs):
logger.info('Filtering %d statements for top-level...' % len(stmts_in))
stmts_out = [st for st in stmts_in if not st.supports]
logger.info('%d statements after filter...' % len(stmts_out))
dump_pkl = kwargs.get('... | [
"Filter to statements that are at the top-level of the hierarchy.\n\n Here top-level statements correspond to most specific ones.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to filter.\n save : Optional[str]\n The name of a pickle fil... |
Please provide a description of the function:def filter_inconsequential_mods(stmts_in, whitelist=None, **kwargs):
if whitelist is None:
whitelist = {}
logger.info('Filtering %d statements to remove' % len(stmts_in) +
' inconsequential modifications...')
states_used = whitelist
... | [
"Filter out Modifications that modify inconsequential sites\n\n Inconsequential here means that the site is not mentioned / tested\n in any other statement. In some cases specific sites should be\n preserved, for instance, to be used as readouts in a model.\n In this case, the given sites can be passed ... |
Please provide a description of the function:def filter_inconsequential_acts(stmts_in, whitelist=None, **kwargs):
if whitelist is None:
whitelist = {}
logger.info('Filtering %d statements to remove' % len(stmts_in) +
' inconsequential activations...')
states_used = whitelist
... | [
"Filter out Activations that modify inconsequential activities\n\n Inconsequential here means that the site is not mentioned / tested\n in any other statement. In some cases specific activity types should be\n preserved, for instance, to be used as readouts in a model.\n In this case, the given activiti... |
Please provide a description of the function:def filter_mutation_status(stmts_in, mutations, deletions, **kwargs):
if 'remove_bound' in kwargs and kwargs['remove_bound']:
remove_bound = True
else:
remove_bound = False
def criterion(agent):
if agent is not None and agent.name i... | [
"Filter statements based on existing mutations/deletions\n\n This filter helps to contextualize a set of statements to a given\n cell type. Given a list of deleted genes, it removes statements that refer\n to these genes. It also takes a list of mutations and removes statements\n that refer to mutations... |
Please provide a description of the function:def filter_enzyme_kinase(stmts_in, **kwargs):
logger.info('Filtering %d statements to remove ' % len(stmts_in) +
'phosphorylation by non-kinases...')
path = os.path.dirname(os.path.abspath(__file__))
kinase_table = read_unicode_csv(path + '/.... | [
"Filter Phosphorylations to ones where the enzyme is a known kinase.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to filter.\n save : Optional[str]\n The name of a pickle file to save the results (stmts_out) into.\n\n Returns\n ----... |
Please provide a description of the function:def filter_transcription_factor(stmts_in, **kwargs):
logger.info('Filtering %d statements to remove ' % len(stmts_in) +
'amount regulations by non-transcription-factors...')
path = os.path.dirname(os.path.abspath(__file__))
tf_table = \
... | [
"Filter out RegulateAmounts where subject is not a transcription factor.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to filter.\n save : Optional[str]\n The name of a pickle file to save the results (stmts_out) into.\n\n Returns\n ... |
Please provide a description of the function:def filter_uuid_list(stmts_in, uuids, **kwargs):
invert = kwargs.get('invert', False)
logger.info('Filtering %d statements for %d UUID%s...' %
(len(stmts_in), len(uuids), 's' if len(uuids) > 1 else ''))
stmts_out = []
for st in stmts_in:
... | [
"Filter to Statements corresponding to given UUIDs\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to filter.\n uuids : list[str]\n A list of UUIDs to filter for.\n save : Optional[str]\n The name of a pickle file to save the resul... |
Please provide a description of the function:def expand_families(stmts_in, **kwargs):
from indra.tools.expand_families import Expander
logger.info('Expanding families on %d statements...' % len(stmts_in))
expander = Expander(hierarchies)
stmts_out = expander.expand_families(stmts_in)
logger.inf... | [
"Expand FamPlex Agents to individual genes.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to expand.\n save : Optional[str]\n The name of a pickle file to save the results (stmts_out) into.\n\n Returns\n -------\n stmts_out : list... |
Please provide a description of the function:def reduce_activities(stmts_in, **kwargs):
logger.info('Reducing activities on %d statements...' % len(stmts_in))
stmts_out = [deepcopy(st) for st in stmts_in]
ml = MechLinker(stmts_out)
ml.gather_explicit_activities()
ml.reduce_activities()
stmt... | [
"Reduce the activity types in a list of statements\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to reduce activity types in.\n save : Optional[str]\n The name of a pickle file to save the results (stmts_out) into.\n\n Returns\n ----... |
Please provide a description of the function:def strip_agent_context(stmts_in, **kwargs):
logger.info('Stripping agent context on %d statements...' % len(stmts_in))
stmts_out = []
for st in stmts_in:
new_st = deepcopy(st)
for agent in new_st.agent_list():
if agent is None:
... | [
"Strip any context on agents within each statement.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements whose agent context should be stripped.\n save : Optional[str]\n The name of a pickle file to save the results (stmts_out) into.\n\n Retur... |
Please provide a description of the function:def standardize_names_groundings(stmts):
print('Standardize names to groundings')
for stmt in stmts:
for concept in stmt.agent_list():
db_ns, db_id = concept.get_grounding()
if db_id is not None:
if isinstance(db_i... | [
"Standardize the names of Concepts with respect to an ontology.\n\n NOTE: this function is currently optimized for Influence Statements\n obtained from Eidos, Hume, Sofia and CWMS. It will possibly yield\n unexpected results for biology-specific Statements.\n "
] |
Please provide a description of the function:def dump_stmt_strings(stmts, fname):
with open(fname, 'wb') as fh:
for st in stmts:
fh.write(('%s\n' % st).encode('utf-8')) | [
"Save printed statements in a file.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements to save in a text file.\n fname : Optional[str]\n The name of a text file to save the printed statements into.\n "
] |
Please provide a description of the function:def rename_db_ref(stmts_in, ns_from, ns_to, **kwargs):
logger.info('Remapping "%s" to "%s" in db_refs on %d statements...' %
(ns_from, ns_to, len(stmts_in)))
stmts_out = [deepcopy(st) for st in stmts_in]
for stmt in stmts_out:
for age... | [
"Rename an entry in the db_refs of each Agent.\n\n This is particularly useful when old Statements in pickle files\n need to be updated after a namespace was changed such as\n 'BE' to 'FPLX'.\n\n Parameters\n ----------\n stmts_in : list[indra.statements.Statement]\n A list of statements wh... |
Please provide a description of the function:def align_statements(stmts1, stmts2, keyfun=None):
def name_keyfun(stmt):
return tuple(a.name if a is not None else None for
a in stmt.agent_list())
if not keyfun:
keyfun = name_keyfun
matches = []
keys1 = [keyfun(s) ... | [
"Return alignment of two lists of statements by key.\n\n Parameters\n ----------\n stmts1 : list[indra.statements.Statement]\n A list of INDRA Statements to align\n stmts2 : list[indra.statements.Statement]\n A list of INDRA Statements to align\n keyfun : Optional[function]\n A f... |
Please provide a description of the function:def submit_query_request(end_point, *args, **kwargs):
ev_limit = kwargs.pop('ev_limit', 10)
best_first = kwargs.pop('best_first', True)
tries = kwargs.pop('tries', 2)
# This isn't handled by requests because of the multiple identical agent
# keys, e.... | [
"Low level function to format the query string."
] |
Please provide a description of the function:def submit_statement_request(meth, end_point, query_str='', data=None,
tries=2, **params):
full_end_point = 'statements/' + end_point.lstrip('/')
return make_db_rest_request(meth, full_end_point, query_str, data, params, tries) | [
"Even lower level function to make the request."
] |
Please provide a description of the function:def render_stmt_graph(statements, reduce=True, english=False, rankdir=None,
agent_style=None):
from indra.assemblers.english import EnglishAssembler
# Set the default agent formatting properties
if agent_style is None:
agent_sty... | [
"Render the statement hierarchy as a pygraphviz graph.\n\n Parameters\n ----------\n stmts : list of :py:class:`indra.statements.Statement`\n A list of top-level statements with associated supporting statements\n resulting from building a statement hierarchy with\n :py:meth:`combine_re... |
Please provide a description of the function:def flatten_stmts(stmts):
total_stmts = set(stmts)
for stmt in stmts:
if stmt.supported_by:
children = flatten_stmts(stmt.supported_by)
total_stmts = total_stmts.union(children)
return list(total_stmts) | [
"Return the full set of unique stms in a pre-assembled stmt graph.\n\n The flattened list of statements returned by this function can be\n compared to the original set of unique statements to make sure no\n statements have been lost during the preassembly process.\n\n Parameters\n ----------\n stm... |
Please provide a description of the function:def flatten_evidence(stmts, collect_from=None):
if collect_from is None:
collect_from = 'supported_by'
if collect_from not in ('supports', 'supported_by'):
raise ValueError('collect_from must be one of "supports", '
'"sup... | [
"Add evidence from *supporting* stmts to evidence for *supported* stmts.\n\n Parameters\n ----------\n stmts : list of :py:class:`indra.statements.Statement`\n A list of top-level statements with associated supporting statements\n resulting from building a statement hierarchy with\n :p... |
Please provide a description of the function:def combine_duplicates(self):
if self.unique_stmts is None:
self.unique_stmts = self.combine_duplicate_stmts(self.stmts)
return self.unique_stmts | [
"Combine duplicates among `stmts` and save result in `unique_stmts`.\n\n A wrapper around the static method :py:meth:`combine_duplicate_stmts`.\n "
] |
Please provide a description of the function:def _get_stmt_matching_groups(stmts):
def match_func(x): return x.matches_key()
# Remove exact duplicates using a set() call, then make copies:
logger.debug('%d statements before removing object duplicates.' %
len(stmts)... | [
"Use the matches_key method to get sets of matching statements."
] |
Please provide a description of the function:def combine_duplicate_stmts(stmts):
# Helper function to get a list of evidence matches keys
def _ev_keys(sts):
ev_keys = []
for stmt in sts:
for ev in stmt.evidence:
ev_keys.append(ev.match... | [
"Combine evidence from duplicate Statements.\n\n Statements are deemed to be duplicates if they have the same key\n returned by the `matches_key()` method of the Statement class. This\n generally means that statements must be identical in terms of their\n arguments and can differ only in... |
Please provide a description of the function:def _get_stmt_by_group(self, stmt_type, stmts_this_type, eh):
# Dict of stmt group key tuples, indexed by their first Agent
stmt_by_first = collections.defaultdict(lambda: [])
# Dict of stmt group key tuples, indexed by their second Agent
... | [
"Group Statements of `stmt_type` by their hierarchical relations."
] |
Please provide a description of the function:def _generate_id_maps(self, unique_stmts, poolsize=None,
size_cutoff=100, split_idx=None):
# Check arguments relating to multiprocessing
if poolsize is None:
logger.debug('combine_related: poolsize not set, '
... | [
"Connect statements using their refinement relationships."
] |
Please provide a description of the function:def combine_related(self, return_toplevel=True, poolsize=None,
size_cutoff=100):
if self.related_stmts is not None:
if return_toplevel:
return self.related_stmts
else:
assert sel... | [
"Connect related statements based on their refinement relationships.\n\n This function takes as a starting point the unique statements (with\n duplicates removed) and returns a modified flat list of statements\n containing only those statements which do not represent a refinement of\n ot... |
Please provide a description of the function:def find_contradicts(self):
eh = self.hierarchies['entity']
# Make a dict of Statement by type
stmts_by_type = collections.defaultdict(lambda: [])
for idx, stmt in enumerate(self.stmts):
stmts_by_type[indra_stmt_type(stmt... | [
"Return pairs of contradicting Statements.\n\n Returns\n -------\n contradicts : list(tuple(Statement, Statement))\n A list of Statement pairs that are contradicting.\n "
] |
Please provide a description of the function:def get_text_content_for_pmids(pmids):
pmc_pmids = set(pmc_client.filter_pmids(pmids, source_type='fulltext'))
pmc_ids = []
for pmid in pmc_pmids:
pmc_id = pmc_client.id_lookup(pmid, idtype='pmid')['pmcid']
if pmc_id:
pmc_ids.app... | [
"Get text content for articles given a list of their pmids\n\n Parameters\n ----------\n pmids : list of str\n\n Returns\n -------\n text_content : list of str\n "
] |
Please provide a description of the function:def universal_extract_paragraphs(xml):
try:
paragraphs = elsevier_client.extract_paragraphs(xml)
except Exception:
paragraphs = None
if paragraphs is None:
try:
paragraphs = pmc_client.extract_paragraphs(xml)
excep... | [
"Extract paragraphs from xml that could be from different sources\n\n First try to parse the xml as if it came from elsevier. if we do not\n have valid elsevier xml this will throw an exception. the text extraction\n function in the pmc client may not throw an exception when parsing elsevier\n xml, sil... |
Please provide a description of the function:def filter_paragraphs(paragraphs, contains=None):
if contains is None:
pattern = ''
else:
if isinstance(contains, str):
contains = [contains]
pattern = '|'.join(r'[^\w]%s[^\w]' % shortform
for shortf... | [
"Filter paragraphs to only those containing one of a list of strings\n\n Parameters\n ----------\n paragraphs : list of str\n List of plaintext paragraphs from an article\n\n contains : str or list of str\n Exclude paragraphs not containing this string as a token, or\n at least one ... |
Please provide a description of the function:def get_valid_residue(residue):
if residue is not None and amino_acids.get(residue) is None:
res = amino_acids_reverse.get(residue.lower())
if res is None:
raise InvalidResidueError(residue)
else:
return res
return... | [
"Check if the given string represents a valid amino acid residue."
] |
Please provide a description of the function:def get_valid_location(location):
# If we're given None, return None
if location is not None and cellular_components.get(location) is None:
loc = cellular_components_reverse.get(location)
if loc is None:
raise InvalidLocationError(loc... | [
"Check if the given location represents a valid cellular component."
] |
Please provide a description of the function:def _read_activity_types():
this_dir = os.path.dirname(os.path.abspath(__file__))
ac_file = os.path.join(this_dir, os.pardir, 'resources',
'activity_hierarchy.rdf')
g = rdflib.Graph()
with open(ac_file, 'r'):
g.parse(ac... | [
"Read types of valid activities from a resource file."
] |
Please provide a description of the function:def _read_cellular_components():
# Here we load a patch file in addition to the current cellular components
# file to make sure we don't error with InvalidLocationError with some
# deprecated cellular location names
this_dir = os.path.dirname(os.path.abs... | [
"Read cellular components from a resource file."
] |
Please provide a description of the function:def _read_amino_acids():
this_dir = os.path.dirname(os.path.abspath(__file__))
aa_file = os.path.join(this_dir, os.pardir, 'resources', 'amino_acids.tsv')
amino_acids = {}
amino_acids_reverse = {}
with open(aa_file, 'rt') as fh:
lines = fh.re... | [
"Read the amino acid information from a resource file."
] |
Please provide a description of the function:def export_sbgn(model):
import lxml.etree
import lxml.builder
from pysb.bng import generate_equations
from indra.assemblers.sbgn import SBGNAssembler
logger.info('Generating reaction network with BNG for SBGN export. ' +
'This could ... | [
"Return an SBGN model string corresponding to the PySB model.\n\n This function first calls generate_equations on the PySB model to obtain\n a reaction network (i.e. individual species, reactions). It then iterates\n over each reaction and and instantiates its reactants, products, and the\n process itse... |
Please provide a description of the function:def export_kappa_im(model, fname=None):
from .kappa_util import im_json_to_graph
kappa = _prepare_kappa(model)
imap = kappa.analyses_influence_map()
im = im_json_to_graph(imap)
for param in model.parameters:
try:
im.remove_node(pa... | [
"Return a networkx graph representing the model's Kappa influence map.\n\n Parameters\n ----------\n model : pysb.core.Model\n A PySB model to be exported into a Kappa IM.\n fname : Optional[str]\n A file name, typically with .png or .pdf extension in which\n the IM is rendered usin... |
Please provide a description of the function:def export_kappa_cm(model, fname=None):
from .kappa_util import cm_json_to_graph
kappa = _prepare_kappa(model)
cmap = kappa.analyses_contact_map()
cm = cm_json_to_graph(cmap)
if fname:
cm.draw(fname, prog='dot')
return cm | [
"Return a networkx graph representing the model's Kappa contact map.\n\n Parameters\n ----------\n model : pysb.core.Model\n A PySB model to be exported into a Kappa CM.\n fname : Optional[str]\n A file name, typically with .png or .pdf extension in which\n the CM is rendered using ... |
Please provide a description of the function:def _prepare_kappa(model):
import kappy
kappa = kappy.KappaStd()
model_str = export(model, 'kappa')
kappa.add_model_string(model_str)
kappa.project_parse()
return kappa | [
"Return a Kappa STD with the model loaded."
] |
Please provide a description of the function:def send_request(**kwargs):
skiprows = kwargs.pop('skiprows', None)
res = requests.get(cbio_url, params=kwargs)
if res.status_code == 200:
# Adaptively skip rows based on number of comment lines
if skiprows == -1:
lines = res.text... | [
"Return a data frame from a web service request to cBio portal.\n\n Sends a web service requrest to the cBio portal with arguments given in\n the dictionary data and returns a Pandas data frame on success.\n\n More information about the service here:\n http://www.cbioportal.org/web_api.jsp\n\n Parame... |
Please provide a description of the function:def get_mutations(study_id, gene_list, mutation_type=None,
case_id=None):
genetic_profile = get_genetic_profiles(study_id, 'mutation')[0]
gene_list_str = ','.join(gene_list)
data = {'cmd': 'getMutationData',
'case_set_id': stud... | [
"Return mutations as a list of genes and list of amino acid changes.\n\n Parameters\n ----------\n study_id : str\n The ID of the cBio study.\n Example: 'cellline_ccle_broad' or 'paad_icgc'\n gene_list : list[str]\n A list of genes with their HGNC symbols.\n Example: ['BRAF',... |
Please provide a description of the function:def get_case_lists(study_id):
data = {'cmd': 'getCaseLists',
'cancer_study_id': study_id}
df = send_request(**data)
case_set_ids = df['case_list_id'].tolist()
return case_set_ids | [
"Return a list of the case set ids for a particular study.\n\n TAKE NOTE the \"case_list_id\" are the same thing as \"case_set_id\"\n Within the data, this string is referred to as a \"case_list_id\".\n Within API calls it is referred to as a 'case_set_id'.\n The documentation does not make this explici... |
Please provide a description of the function:def get_profile_data(study_id, gene_list,
profile_filter, case_set_filter=None):
genetic_profiles = get_genetic_profiles(study_id, profile_filter)
if genetic_profiles:
genetic_profile = genetic_profiles[0]
else:
return {}... | [
"Return dict of cases and genes and their respective values.\n\n Parameters\n ----------\n study_id : str\n The ID of the cBio study.\n Example: 'cellline_ccle_broad' or 'paad_icgc'\n gene_list : list[str]\n A list of genes with their HGNC symbols.\n Example: ['BRAF', 'KRAS']... |
Please provide a description of the function:def get_num_sequenced(study_id):
data = {'cmd': 'getCaseLists',
'cancer_study_id': study_id}
df = send_request(**data)
if df.empty:
return 0
row_filter = df['case_list_id'].str.contains('sequenced', case=False)
num_case = len(df[r... | [
"Return number of sequenced tumors for given study.\n\n This is useful for calculating mutation statistics in terms of the\n prevalence of certain mutations within a type of cancer.\n\n Parameters\n ----------\n study_id : str\n The ID of the cBio study.\n Example: 'paad_icgc'\n\n Re... |
Please provide a description of the function:def get_genetic_profiles(study_id, profile_filter=None):
data = {'cmd': 'getGeneticProfiles',
'cancer_study_id': study_id}
df = send_request(**data)
res = _filter_data_frame(df, ['genetic_profile_id'],
'genetic_altera... | [
"Return all the genetic profiles (data sets) for a given study.\n\n Genetic profiles are different types of data for a given study. For\n instance the study 'cellline_ccle_broad' has profiles such as\n 'cellline_ccle_broad_mutations' for mutations, 'cellline_ccle_broad_CNA'\n for copy number alterations... |
Please provide a description of the function:def get_cancer_studies(study_filter=None):
data = {'cmd': 'getCancerStudies'}
df = send_request(**data)
res = _filter_data_frame(df, ['cancer_study_id'],
'cancer_study_id', study_filter)
study_ids = list(res['cancer_study_id'... | [
"Return a list of cancer study identifiers, optionally filtered.\n\n There are typically multiple studies for a given type of cancer and\n a filter can be used to constrain the returned list.\n\n Parameters\n ----------\n study_filter : Optional[str]\n A string used to filter the study IDs to ... |
Please provide a description of the function:def get_cancer_types(cancer_filter=None):
data = {'cmd': 'getTypesOfCancer'}
df = send_request(**data)
res = _filter_data_frame(df, ['type_of_cancer_id'], 'name', cancer_filter)
type_ids = list(res['type_of_cancer_id'].values())
return type_ids | [
"Return a list of cancer types, optionally filtered.\n\n Parameters\n ----------\n cancer_filter : Optional[str]\n A string used to filter cancer types. Its value is the name or\n part of the name of a type of cancer. Example: \"melanoma\",\n \"pancreatic\", \"non-small cell lung\"\n\n... |
Please provide a description of the function:def get_ccle_mutations(gene_list, cell_lines, mutation_type=None):
mutations = {cl: {g: [] for g in gene_list} for cl in cell_lines}
for cell_line in cell_lines:
mutations_cl = get_mutations(ccle_study, gene_list,
mut... | [
"Return a dict of mutations in given genes and cell lines from CCLE.\n\n This is a specialized call to get_mutations tailored to CCLE cell lines.\n\n Parameters\n ----------\n gene_list : list[str]\n A list of HGNC gene symbols to get mutations in\n cell_lines : list[str]\n A list of CC... |
Please provide a description of the function:def get_ccle_lines_for_mutation(gene, amino_acid_change):
data = {'cmd': 'getMutationData',
'case_set_id': ccle_study,
'genetic_profile_id': ccle_study + '_mutations',
'gene_list': gene,
'skiprows': 1}
df = send_re... | [
"Return cell lines with a given point mutation in a given gene.\n\n Checks which cell lines in CCLE have a particular point mutation\n in a given gene and return their names in a list.\n\n Parameters\n ----------\n gene : str\n The HGNC symbol of the mutated gene in whose product the amino\n ... |
Please provide a description of the function:def get_ccle_cna(gene_list, cell_lines):
profile_data = get_profile_data(ccle_study, gene_list,
'COPY_NUMBER_ALTERATION', 'all')
profile_data = dict((key, value) for key, value in profile_data.items()
i... | [
"Return a dict of CNAs in given genes and cell lines from CCLE.\n\n CNA values correspond to the following alterations\n\n -2 = homozygous deletion\n\n -1 = hemizygous deletion\n\n 0 = neutral / no change\n\n 1 = gain\n\n 2 = high level amplification\n\n Parameters\n ----------\n gene_lis... |
Please provide a description of the function:def get_ccle_mrna(gene_list, cell_lines):
gene_list_str = ','.join(gene_list)
data = {'cmd': 'getProfileData',
'case_set_id': ccle_study + '_mrna',
'genetic_profile_id': ccle_study + '_mrna',
'gene_list': gene_list_str,
... | [
"Return a dict of mRNA amounts in given genes and cell lines from CCLE.\n\n Parameters\n ----------\n gene_list : list[str]\n A list of HGNC gene symbols to get mRNA amounts for.\n cell_lines : list[str]\n A list of CCLE cell line names to get mRNA amounts for.\n\n Returns\n -------\... |
Please provide a description of the function:def _filter_data_frame(df, data_col, filter_col, filter_str=None):
if filter_str is not None:
relevant_cols = data_col + [filter_col]
df.dropna(inplace=True, subset=relevant_cols)
row_filter = df[filter_col].str.contains(filter_str, case=Fals... | [
"Return a filtered data frame as a dictionary."
] |
Please provide a description of the function:def allow_cors(func):
def wrapper(*args, **kwargs):
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = \
'PUT, GET, POST, DELETE, OPTIONS'
response.headers['Access-Control-Allo... | [
"This is a decorator which enable CORS for the specified endpoint."
] |
Please provide a description of the function:def trips_process_text():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
text = body.get('text')
tp = trips.process_text(text)
return _stmts_from_proc(tp) | [
"Process text with TRIPS and return INDRA Statements."
] |
Please provide a description of the function:def trips_process_xml():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
xml_str = body.get('xml_str')
tp = trips.process_xml(xml_str)
return _stmts_from_proc(tp) | [
"Process TRIPS EKB XML and return INDRA Statements."
] |
Please provide a description of the function:def reach_process_text():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
text = body.get('text')
offline = True if body.get('offline') else False
rp = reach.process_tex... | [
"Process text with REACH and return INDRA Statements."
] |
Please provide a description of the function:def reach_process_json():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
json_str = body.get('json')
rp = reach.process_json_str(json_str)
return _stmts_from_proc(rp) | [
"Process REACH json and return INDRA Statements."
] |
Please provide a description of the function:def reach_process_pmc():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
pmcid = body.get('pmcid')
rp = reach.process_pmc(pmcid)
return _stmts_from_proc(rp) | [
"Process PubMedCentral article and return INDRA Statements."
] |
Please provide a description of the function:def bel_process_pybel_neighborhood():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
genes = body.get('genes')
bp = bel.process_pybel_neighborhood(genes)
return _stmts_... | [
"Process BEL Large Corpus neighborhood and return INDRA Statements."
] |
Please provide a description of the function:def bel_process_belrdf():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
belrdf = body.get('belrdf')
bp = bel.process_belrdf(belrdf)
return _stmts_from_proc(bp) | [
"Process BEL RDF and return INDRA Statements."
] |
Please provide a description of the function:def biopax_process_pc_pathsbetween():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
genes = body.get('genes')
bp = biopax.process_pc_pathsbetween(genes)
return _stmts_... | [
"Process PathwayCommons paths between genes, return INDRA Statements."
] |
Please provide a description of the function:def biopax_process_pc_pathsfromto():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
source = body.get('source')
target = body.get('target')
bp = biopax.process_pc_paths... | [
"Process PathwayCommons paths from-to genes, return INDRA Statements."
] |
Please provide a description of the function:def biopax_process_pc_neighborhood():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
genes = body.get('genes')
bp = biopax.process_pc_neighborhood(genes)
return _stmts_... | [
"Process PathwayCommons neighborhood, return INDRA Statements."
] |
Please provide a description of the function:def eidos_process_text():
if request.method == 'OPTIONS':
return {}
req = request.body.read().decode('utf-8')
body = json.loads(req)
text = body.get('text')
webservice = body.get('webservice')
if not webservice:
response.status = ... | [
"Process text with EIDOS and return INDRA Statements."
] |
Please provide a description of the function:def eidos_process_jsonld():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
eidos_json = body.get('jsonld')
ep = eidos.process_json_str(eidos_json)
return _stmts_from_pr... | [
"Process an EIDOS JSON-LD and return INDRA Statements."
] |
Please provide a description of the function:def cwms_process_text():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
text = body.get('text')
cp = cwms.process_text(text)
return _stmts_from_proc(cp) | [
"Process text with CWMS and return INDRA Statements."
] |
Please provide a description of the function:def hume_process_jsonld():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
jsonld_str = body.get('jsonld')
jsonld = json.loads(jsonld_str)
hp = hume.process_jsonld(jsonl... | [
"Process Hume JSON-LD and return INDRA Statements."
] |
Please provide a description of the function:def sofia_process_text():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
text = body.get('text')
auth = body.get('auth')
sp = sofia.process_text(text, auth=auth)
re... | [
"Process text with Sofia and return INDRA Statements."
] |
Please provide a description of the function:def assemble_pysb():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
stmts_json = body.get('statements')
export_format = body.get('export_format')
stmts = stmts_from_jso... | [
"Assemble INDRA Statements and return PySB model string."
] |
Please provide a description of the function:def assemble_cx():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
stmts_json = body.get('statements')
stmts = stmts_from_json(stmts_json)
ca = CxAssembler(stmts)
mo... | [
"Assemble INDRA Statements and return CX network json."
] |
Please provide a description of the function:def share_model_ndex():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
stmts_str = body.get('stmts')
stmts_json = json.loads(stmts_str)
stmts = stmts_from_json(stmts_js... | [
"Upload the model to NDEX"
] |
Please provide a description of the function:def fetch_model_ndex():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
network_id = body.get('network_id')
cx = process_ndex_network(network_id)
network_attr = [x for x... | [
"Download model and associated pieces from NDEX"
] |
Please provide a description of the function:def assemble_graph():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
stmts_json = body.get('statements')
stmts = stmts_from_json(stmts_json)
ga = GraphAssembler(stmts)
... | [
"Assemble INDRA Statements and return Graphviz graph dot string."
] |
Please provide a description of the function:def assemble_cyjs():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
stmts_json = body.get('statements')
stmts = stmts_from_json(stmts_json)
cja = CyJSAssembler()
cj... | [
"Assemble INDRA Statements and return Cytoscape JS network."
] |
Please provide a description of the function:def assemble_english():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
stmts_json = body.get('statements')
stmts = stmts_from_json(stmts_json)
sentences = {}
for st... | [
"Assemble each statement into "
] |
Please provide a description of the function:def assemble_loopy():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
stmts_json = body.get('statements')
stmts = stmts_from_json(stmts_json)
sa = SifAssembler(stmts)
... | [
"Assemble INDRA Statements into a Loopy model using SIF Assembler."
] |
Please provide a description of the function:def get_ccle_mrna_levels():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
gene_list = body.get('gene_list')
cell_lines = body.get('cell_lines')
mrna_amounts = cbio_cli... | [
"Get CCLE mRNA amounts using cBioClient"
] |
Please provide a description of the function:def get_ccle_cna():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
gene_list = body.get('gene_list')
cell_lines = body.get('cell_lines')
cna = cbio_client.get_ccle_cna(... | [
"Get CCLE CNA\n -2 = homozygous deletion\n -1 = hemizygous deletion\n 0 = neutral / no change\n 1 = gain\n 2 = high level amplification\n "
] |
Please provide a description of the function:def get_ccle_mutations():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
gene_list = body.get('gene_list')
cell_lines = body.get('cell_lines')
mutations = cbio_client.g... | [
"Get CCLE mutations\n returns the amino acid changes for a given list of genes and cell lines\n "
] |
Please provide a description of the function:def map_grounding():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
stmts_json = body.get('statements')
stmts = stmts_from_json(stmts_json)
stmts_out = ac.map_grounding... | [
"Map grounding on a list of INDRA Statements."
] |
Please provide a description of the function:def run_preassembly():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
stmts_json = body.get('statements')
stmts = stmts_from_json(stmts_json)
scorer = body.get('scorer'... | [
"Run preassembly on a list of INDRA Statements."
] |
Please provide a description of the function:def map_ontologies():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
stmts_json = body.get('statements')
stmts = stmts_from_json(stmts_json)
om = OntologyMapper(stmts, ... | [
"Run ontology mapping on a list of INDRA Statements."
] |
Please provide a description of the function:def filter_by_type():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
stmts_json = body.get('statements')
stmt_type_str = body.get('type')
stmt_type_str = stmt_type_str.... | [
"Filter to a given INDRA Statement type."
] |
Please provide a description of the function:def filter_grounded_only():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
stmts_json = body.get('statements')
score_threshold = body.get('score_threshold')
if score_th... | [
"Filter to grounded Statements only."
] |
Please provide a description of the function:def filter_belief():
if request.method == 'OPTIONS':
return {}
response = request.body.read().decode('utf-8')
body = json.loads(response)
stmts_json = body.get('statements')
belief_cutoff = body.get('belief_cutoff')
if belief_cutoff is no... | [
"Filter to beliefs above a given threshold."
] |
Please provide a description of the function:def get_git_info():
start_dir = abspath(curdir)
try:
chdir(dirname(abspath(__file__)))
re_patt_str = (r'commit\s+(?P<commit_hash>\w+).*?Author:\s+'
r'(?P<author_name>.*?)\s+<(?P<author_email>.*?)>\s+Date:\s+'
... | [
"Get a dict with useful git info."
] |
Please provide a description of the function:def get_version(with_git_hash=True, refresh_hash=False):
version = __version__
if with_git_hash:
global INDRA_GITHASH
if INDRA_GITHASH is None or refresh_hash:
with open(devnull, 'w') as nul:
try:
r... | [
"Get an indra version string, including a git hash."
] |
Please provide a description of the function:def get_upload_content(pmid, force_fulltext_lookup=False):
# Make sure that the PMID doesn't start with PMID so that it doesn't
# screw up the literature clients
if pmid.startswith('PMID'):
pmid = pmid[4:]
# First, check S3:
(ft_content_s3, f... | [
"Get full text and/or abstract for paper and upload to S3."
] |
Please provide a description of the function:def _fix_evidence_text(txt):
txt = re.sub('[ ]?\( xref \)', '', txt)
# This is to make [ xref ] become [] to match the two readers
txt = re.sub('\[ xref \]', '[]', txt)
txt = re.sub('[\(]?XREF_BIBR[\)]?[,]?', '', txt)
txt = re.sub('[\(]?XREF_FIG[\)]?... | [
"Eliminate some symbols to have cleaner supporting text."
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.