_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q234400
run_preassembly
train
def run_preassembly(): """Run preassembly on a list of INDRA Statements.""" 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('...
python
{ "resource": "" }
q234401
map_ontologies
train
def map_ontologies(): """Run ontology mapping on a list of INDRA Statements.""" 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 = OntologyMa...
python
{ "resource": "" }
q234402
filter_by_type
train
def filter_by_type(): """Filter to a given INDRA Statement 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....
python
{ "resource": "" }
q234403
filter_grounded_only
train
def filter_grounded_only(): """Filter to grounded Statements 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_thresh...
python
{ "resource": "" }
q234404
filter_belief
train
def filter_belief(): """Filter to beliefs above a given threshold.""" 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...
python
{ "resource": "" }
q234405
get_git_info
train
def get_git_info(): """Get a dict with useful 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+' ...
python
{ "resource": "" }
q234406
get_version
train
def get_version(with_git_hash=True, refresh_hash=False): """Get an indra version string, including a git hash.""" version = __version__ if with_git_hash: global INDRA_GITHASH if INDRA_GITHASH is None or refresh_hash: with open(devnull, 'w') as nul: try: ...
python
{ "resource": "" }
q234407
_fix_evidence_text
train
def _fix_evidence_text(txt): """Eliminate some symbols to have cleaner supporting text.""" 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('[\...
python
{ "resource": "" }
q234408
CxAssembler.make_model
train
def make_model(self, add_indra_json=True): """Assemble the CX network from the collected INDRA Statements. This method assembles a CX network from the set of INDRA Statements. The assembled network is set as the assembler's cx argument. Parameters ---------- add_indra_j...
python
{ "resource": "" }
q234409
CxAssembler.print_cx
train
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 ------- ...
python
{ "resource": "" }
q234410
CxAssembler.save_model
train
def save_model(self, file_name='model.cx'): """Save the assembled CX network in a file. Parameters ---------- file_name : Optional[str] The name of the file to save the CX network to. Default: model.cx """ with open(file_name, 'wt') as fh: cx_str ...
python
{ "resource": "" }
q234411
CxAssembler.set_context
train
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...
python
{ "resource": "" }
q234412
get_publications
train
def get_publications(gene_names, save_json_name=None): """Return evidence publications for interaction between the given genes. Parameters ---------- gene_names : list[str] A list of gene names (HGNC symbols) to query interactions between. Currently supports exactly two genes only. ...
python
{ "resource": "" }
q234413
_n
train
def _n(name): """Return valid PySB name.""" n = name.encode('ascii', errors='ignore').decode('ascii') n = re.sub('[^A-Za-z0-9_]', '_', n) n = re.sub(r'(^[0-9].*)', r'p\1', n) return n
python
{ "resource": "" }
q234414
IndraDBRestProcessor.get_hash_statements_dict
train
def get_hash_statements_dict(self): """Return a dict of Statements keyed by hashes.""" res = {stmt_hash: stmts_from_json([stmt])[0] for stmt_hash, stmt in self.__statement_jsons.items()} return res
python
{ "resource": "" }
q234415
IndraDBRestProcessor.merge_results
train
def merge_results(self, other_processor): """Merge the results of this processor with those of another.""" if not isinstance(other_processor, self.__class__): raise ValueError("Can only extend with another %s instance." % self.__class__.__name__) self.sta...
python
{ "resource": "" }
q234416
IndraDBRestProcessor.wait_until_done
train
def wait_until_done(self, timeout=None): """Wait for the background load to complete.""" start = datetime.now() if not self.__th: raise IndraDBRestResponseError("There is no thread waiting to " "complete.") self.__th.join(timeout) ...
python
{ "resource": "" }
q234417
IndraDBRestProcessor._merge_json
train
def _merge_json(self, stmt_json, ev_counts): """Merge these statement jsons with new jsons.""" # Where there is overlap, there _should_ be agreement. self.__evidence_counts.update(ev_counts) for k, sj in stmt_json.items(): if k not in self.__statement_jsons: ...
python
{ "resource": "" }
q234418
IndraDBRestProcessor._run_queries
train
def _run_queries(self, agent_strs, stmt_types, params, persist): """Use paging to get all statements requested.""" self._query_over_statement_types(agent_strs, stmt_types, params) assert len(self.__done_dict) == len(stmt_types) \ or None in self.__done_dict.keys(), \ "Do...
python
{ "resource": "" }
q234419
get_ids
train
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...
python
{ "resource": "" }
q234420
get_id_count
train
def get_id_count(search_term): """Get the number of citations in Pubmed for a search query. Parameters ---------- search_term : str A term for which the PubMed search should be performed. Returns ------- int or None The number of citations for the query, or None if the quer...
python
{ "resource": "" }
q234421
get_ids_for_gene
train
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...
python
{ "resource": "" }
q234422
get_article_xml
train
def get_article_xml(pubmed_id): """Get the XML metadata for a single article from the Pubmed database. """ if pubmed_id.upper().startswith('PMID'): pubmed_id = pubmed_id[4:] params = {'db': 'pubmed', 'retmode': 'xml', 'id': pubmed_id} tree = send_request(pubmed_fe...
python
{ "resource": "" }
q234423
get_abstract
train
def get_abstract(pubmed_id, prepend_title=True): """Get the abstract of an article in the Pubmed database.""" article = get_article_xml(pubmed_id) if article is None: return None return _abstract_from_article_element(article, prepend_title)
python
{ "resource": "" }
q234424
get_metadata_from_xml_tree
train
def get_metadata_from_xml_tree(tree, get_issns_from_nlm=False, get_abstracts=False, prepend_title=False, mesh_annotations=False): """Get metadata for an XML tree containing PubmedArticle elements. Documentation on the XML structure can be found at: ...
python
{ "resource": "" }
q234425
get_metadata_for_ids
train
def get_metadata_for_ids(pmid_list, get_issns_from_nlm=False, get_abstracts=False, prepend_title=False): """Get article metadata for up to 200 PMIDs from the Pubmed database. Parameters ---------- pmid_list : list of PMIDs as strings Can contain 1-200 PMIDs. get_iss...
python
{ "resource": "" }
q234426
get_issns_for_journal
train
def get_issns_for_journal(nlm_id): """Get a list of the ISSN numbers for a journal given its NLM ID. Information on NLM XML DTDs is available at https://www.nlm.nih.gov/databases/dtd/ """ params = {'db': 'nlmcatalog', 'retmode': 'xml', 'id': nlm_id} tree = send_reque...
python
{ "resource": "" }
q234427
remove_im_params
train
def remove_im_params(model, im): """Remove parameter nodes from the influence map. Parameters ---------- model : pysb.core.Model PySB model. im : networkx.MultiDiGraph Influence map. Returns ------- networkx.MultiDiGraph Influence map with the parameter nodes re...
python
{ "resource": "" }
q234428
_get_signed_predecessors
train
def _get_signed_predecessors(im, node, polarity): """Get upstream nodes in the influence map. Return the upstream nodes along with the overall polarity of the path to that node by account for the polarity of the path to the given node and the polarity of the edge between the given node and its immediat...
python
{ "resource": "" }
q234429
_get_edge_sign
train
def _get_edge_sign(im, edge): """Get the polarity of the influence by examining the edge sign.""" edge_data = im[edge[0]][edge[1]] # Handle possible multiple edges between nodes signs = list(set([v['sign'] for v in edge_data.values() if v.get('sign')])) if len(signs...
python
{ "resource": "" }
q234430
_add_modification_to_agent
train
def _add_modification_to_agent(agent, mod_type, residue, position): """Add a modification condition to an Agent.""" new_mod = ModCondition(mod_type, residue, position) # Check if this modification already exists for old_mod in agent.mods: if old_mod.equals(new_mod): return agent ...
python
{ "resource": "" }
q234431
_match_lhs
train
def _match_lhs(cp, rules): """Get rules with a left-hand side matching the given ComplexPattern.""" rule_matches = [] for rule in rules: reactant_pattern = rule.rule_expression.reactant_pattern for rule_cp in reactant_pattern.complex_patterns: if _cp_embeds_into(rule_cp, cp): ...
python
{ "resource": "" }
q234432
_cp_embeds_into
train
def _cp_embeds_into(cp1, cp2): """Check that any state in ComplexPattern2 is matched in ComplexPattern1. """ # Check that any state in cp2 is matched in cp1 # If the thing we're matching to is just a monomer pattern, that makes # things easier--we just need to find the corresponding monomer pattern ...
python
{ "resource": "" }
q234433
_mp_embeds_into
train
def _mp_embeds_into(mp1, mp2): """Check that conditions in MonomerPattern2 are met in MonomerPattern1.""" sc_matches = [] if mp1.monomer.name != mp2.monomer.name: return False # Check that all conditions in mp2 are met in mp1 for site_name, site_state in mp2.site_conditions.items(): ...
python
{ "resource": "" }
q234434
_monomer_pattern_label
train
def _monomer_pattern_label(mp): """Return a string label for a MonomerPattern.""" site_strs = [] for site, cond in mp.site_conditions.items(): if isinstance(cond, tuple) or isinstance(cond, list): assert len(cond) == 2 if cond[1] == WILD: site_str = '%s_%s' % ...
python
{ "resource": "" }
q234435
_stmt_from_rule
train
def _stmt_from_rule(model, rule_name, stmts): """Return the INDRA Statement corresponding to a given rule by name.""" stmt_uuid = None for ann in model.annotations: if ann.predicate == 'from_indra_statement': if ann.subject == rule_name: stmt_uuid = ann.object ...
python
{ "resource": "" }
q234436
ModelChecker.generate_im
train
def generate_im(self, model): """Return a graph representing the influence map generated by Kappa Parameters ---------- model : pysb.Model The PySB model whose influence map is to be generated Returns ------- graph : networkx.MultiDiGraph ...
python
{ "resource": "" }
q234437
ModelChecker.draw_im
train
def draw_im(self, fname): """Draw and save the influence map in a file. Parameters ---------- fname : str The name of the file to save the influence map in. The extension of the file will determine the file format, typically png or pdf. """ ...
python
{ "resource": "" }
q234438
ModelChecker.get_im
train
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...
python
{ "resource": "" }
q234439
ModelChecker.check_model
train
def check_model(self, max_paths=1, max_path_length=5): """Check all the statements added to the ModelChecker. Parameters ---------- max_paths : Optional[int] The maximum number of specific paths to return for each Statement to be explained. Default: 1 max...
python
{ "resource": "" }
q234440
ModelChecker.check_statement
train
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 ...
python
{ "resource": "" }
q234441
ModelChecker.score_paths
train
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 ...
python
{ "resource": "" }
q234442
ModelChecker.prune_influence_map
train
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...
python
{ "resource": "" }
q234443
ModelChecker.prune_influence_map_subj_obj
train
def prune_influence_map_subj_obj(self): """Prune influence map to include only edges where the object of the upstream rule matches the subject of the downstream rule.""" def get_rule_info(r): result = {} for ann in self.model.annotations: if ann.subject ==...
python
{ "resource": "" }
q234444
Reporter.add_section
train
def add_section(self, section_name): """Create a section of the report, to be headed by section_name Text and images can be added by using the `section` argument of the `add_text` and `add_image` methods. Sections can also be ordered by using the `set_section_order` method. By ...
python
{ "resource": "" }
q234445
Reporter.set_section_order
train
def set_section_order(self, section_name_list): """Set the order of the sections, which are by default unorderd. Any unlisted sections that exist will be placed at the end of the document in no particular order. """ self.section_headings = section_name_list[:] for sectio...
python
{ "resource": "" }
q234446
Reporter.add_text
train
def add_text(self, text, *args, **kwargs): """Add text to the document. Text is shown on the final document in the order it is added, either within the given section or as part of the un-sectioned list of content. Parameters ---------- text : str The text to...
python
{ "resource": "" }
q234447
Reporter.add_image
train
def add_image(self, image_path, width=None, height=None, section=None): """Add an image to the document. Images are shown on the final document in the order they are added, either within the given section or as part of the un-sectioned list of content. Parameters ------...
python
{ "resource": "" }
q234448
Reporter.make_report
train
def make_report(self, sections_first=True, section_header_params=None): """Create the pdf document with name `self.name + '.pdf'`. Parameters ---------- sections_first : bool If True (default), text and images with sections are presented first and un-sectioned co...
python
{ "resource": "" }
q234449
Reporter._make_sections
train
def _make_sections(self, **section_hdr_params): """Flatten the sections into a single story list.""" sect_story = [] if not self.section_headings and len(self.sections): self.section_headings = self.sections.keys() for section_name in self.section_headings: secti...
python
{ "resource": "" }
q234450
Reporter._preformat_text
train
def _preformat_text(self, text, style='Normal', space=None, fontsize=12, alignment='left'): """Format the text for addition to a story list.""" if space is None: space=(1,12) ptext = ('<para alignment=\"%s\"><font size=%d>%s</font></para>' % (...
python
{ "resource": "" }
q234451
get_mesh_name_from_web
train
def get_mesh_name_from_web(mesh_id): """Get the MESH label for the given MESH ID using the NLM REST API. Parameters ---------- mesh_id : str MESH Identifier, e.g. 'D003094'. Returns ------- str Label for the MESH ID, or None if the query failed or no label was found...
python
{ "resource": "" }
q234452
get_mesh_name
train
def get_mesh_name(mesh_id, offline=False): """Get the MESH label for the given MESH ID. Uses the mappings table in `indra/resources`; if the MESH ID is not listed there, falls back on the NLM REST API. Parameters ---------- mesh_id : str MESH Identifier, e.g. 'D003094'. offline : b...
python
{ "resource": "" }
q234453
get_mesh_id_name
train
def get_mesh_id_name(mesh_term, offline=False): """Get the MESH ID and name for the given MESH term. Uses the mappings table in `indra/resources`; if the MESH term is not listed there, falls back on the NLM REST API. Parameters ---------- mesh_term : str MESH Descriptor or Concept name...
python
{ "resource": "" }
q234454
make
train
def make(directory): """Makes a RAS Machine directory""" if os.path.exists(directory): if os.path.isdir(directory): click.echo('Directory already exists') else: click.echo('Path exists and is not a directory') sys.exit() os.makedirs(directory) os.mkdir(o...
python
{ "resource": "" }
q234455
run_with_search
train
def run_with_search(model_path, config, num_days): """Run with PubMed search for new papers.""" from indra.tools.machine.machine import run_with_search_helper run_with_search_helper(model_path, config, num_days=num_days)
python
{ "resource": "" }
q234456
run_with_pmids
train
def run_with_pmids(model_path, pmids): """Run with given list of PMIDs.""" from indra.tools.machine.machine import run_with_pmids_helper run_with_pmids_helper(model_path, pmids)
python
{ "resource": "" }
q234457
id_lookup
train
def id_lookup(paper_id, idtype=None): """This function takes a Pubmed ID, Pubmed Central ID, or DOI and use the Pubmed ID mapping service and looks up all other IDs from one of these. The IDs are returned in a dictionary.""" if idtype is not None and idtype not in ('pmid', 'pmcid', 'doi'): r...
python
{ "resource": "" }
q234458
get_xml
train
def get_xml(pmc_id): """Returns XML for the article corresponding to a PMC ID.""" if pmc_id.upper().startswith('PMC'): pmc_id = pmc_id[3:] # Request params params = {} params['verb'] = 'GetRecord' params['identifier'] = 'oai:pubmedcentral.nih.gov:%s' % pmc_id params['metadataPrefix']...
python
{ "resource": "" }
q234459
extract_paragraphs
train
def extract_paragraphs(xml_string): """Returns list of paragraphs in an NLM XML. Parameters ---------- xml_string : str String containing valid NLM XML. Returns ------- list of str List of extracted paragraphs in an NLM XML """ tree = etree.fromstring(xml_string.enc...
python
{ "resource": "" }
q234460
filter_pmids
train
def filter_pmids(pmid_list, source_type): """Filter a list of PMIDs for ones with full text from PMC. Parameters ---------- pmid_list : list of str List of PMIDs to filter. source_type : string One of 'fulltext', 'oa_xml', 'oa_txt', or 'auth_xml'. Returns ------- list o...
python
{ "resource": "" }
q234461
get_example_extractions
train
def get_example_extractions(fname): "Get extractions from one of the examples in `cag_examples`." with open(fname, 'r') as f: sentences = f.read().splitlines() rdf_xml_dict = {} for sentence in sentences: logger.info("Reading \"%s\"..." % sentence) html = tc.send_query(sentence, ...
python
{ "resource": "" }
q234462
make_example_graphs
train
def make_example_graphs(): "Make graphs from all the examples in cag_examples." cag_example_rdfs = {} for i, fname in enumerate(os.listdir('cag_examples')): cag_example_rdfs[i+1] = get_example_extractions(fname) return make_cag_graphs(cag_example_rdfs)
python
{ "resource": "" }
q234463
_join_list
train
def _join_list(lst, oxford=False): """Join a list of words in a gramatically correct way.""" if len(lst) > 2: s = ', '.join(lst[:-1]) if oxford: s += ',' s += ' and ' + lst[-1] elif len(lst) == 2: s = lst[0] + ' and ' + lst[1] elif len(lst) == 1: s = l...
python
{ "resource": "" }
q234464
_assemble_activeform
train
def _assemble_activeform(stmt): """Assemble ActiveForm statements into text.""" subj_str = _assemble_agent_str(stmt.agent) if stmt.is_active: is_active_str = 'active' else: is_active_str = 'inactive' if stmt.activity == 'activity': stmt_str = subj_str + ' is ' + is_active_str...
python
{ "resource": "" }
q234465
_assemble_modification
train
def _assemble_modification(stmt): """Assemble Modification statements into text.""" sub_str = _assemble_agent_str(stmt.sub) if stmt.enz is not None: enz_str = _assemble_agent_str(stmt.enz) if _get_is_direct(stmt): mod_str = ' ' + _mod_process_verb(stmt) + ' ' else: ...
python
{ "resource": "" }
q234466
_assemble_association
train
def _assemble_association(stmt): """Assemble Association statements into text.""" member_strs = [_assemble_agent_str(m.concept) for m in stmt.members] stmt_str = member_strs[0] + ' is associated with ' + \ _join_list(member_strs[1:]) return _make_sentence(stmt_str)
python
{ "resource": "" }
q234467
_assemble_complex
train
def _assemble_complex(stmt): """Assemble Complex statements into text.""" member_strs = [_assemble_agent_str(m) for m in stmt.members] stmt_str = member_strs[0] + ' binds ' + _join_list(member_strs[1:]) return _make_sentence(stmt_str)
python
{ "resource": "" }
q234468
_assemble_autophosphorylation
train
def _assemble_autophosphorylation(stmt): """Assemble Autophosphorylation statements into text.""" enz_str = _assemble_agent_str(stmt.enz) stmt_str = enz_str + ' phosphorylates itself' if stmt.residue is not None: if stmt.position is None: mod_str = 'on ' + ist.amino_acids[stmt.residu...
python
{ "resource": "" }
q234469
_assemble_regulate_activity
train
def _assemble_regulate_activity(stmt): """Assemble RegulateActivity statements into text.""" subj_str = _assemble_agent_str(stmt.subj) obj_str = _assemble_agent_str(stmt.obj) if stmt.is_activation: rel_str = ' activates ' else: rel_str = ' inhibits ' stmt_str = subj_str + rel_str...
python
{ "resource": "" }
q234470
_assemble_regulate_amount
train
def _assemble_regulate_amount(stmt): """Assemble RegulateAmount statements into text.""" obj_str = _assemble_agent_str(stmt.obj) if stmt.subj is not None: subj_str = _assemble_agent_str(stmt.subj) if isinstance(stmt, ist.IncreaseAmount): rel_str = ' increases the amount of ' ...
python
{ "resource": "" }
q234471
_assemble_translocation
train
def _assemble_translocation(stmt): """Assemble Translocation statements into text.""" agent_str = _assemble_agent_str(stmt.agent) stmt_str = agent_str + ' translocates' if stmt.from_location is not None: stmt_str += ' from the ' + stmt.from_location if stmt.to_location is not None: s...
python
{ "resource": "" }
q234472
_assemble_gap
train
def _assemble_gap(stmt): """Assemble Gap statements into text.""" subj_str = _assemble_agent_str(stmt.gap) obj_str = _assemble_agent_str(stmt.ras) stmt_str = subj_str + ' is a GAP for ' + obj_str return _make_sentence(stmt_str)
python
{ "resource": "" }
q234473
_assemble_gef
train
def _assemble_gef(stmt): """Assemble Gef statements into text.""" subj_str = _assemble_agent_str(stmt.gef) obj_str = _assemble_agent_str(stmt.ras) stmt_str = subj_str + ' is a GEF for ' + obj_str return _make_sentence(stmt_str)
python
{ "resource": "" }
q234474
_assemble_conversion
train
def _assemble_conversion(stmt): """Assemble a Conversion statement into text.""" reactants = _join_list([_assemble_agent_str(r) for r in stmt.obj_from]) products = _join_list([_assemble_agent_str(r) for r in stmt.obj_to]) if stmt.subj is not None: subj_str = _assemble_agent_str(stmt.subj) ...
python
{ "resource": "" }
q234475
_assemble_influence
train
def _assemble_influence(stmt): """Assemble an Influence statement into text.""" subj_str = _assemble_agent_str(stmt.subj.concept) obj_str = _assemble_agent_str(stmt.obj.concept) # Note that n is prepended to increase to make it "an increase" if stmt.subj.delta['polarity'] is not None: subj_...
python
{ "resource": "" }
q234476
_make_sentence
train
def _make_sentence(txt): """Make a sentence from a piece of text.""" #Make sure first letter is capitalized txt = txt.strip(' ') txt = txt[0].upper() + txt[1:] + '.' return txt
python
{ "resource": "" }
q234477
_get_is_hypothesis
train
def _get_is_hypothesis(stmt): '''Returns true if there is evidence that the statement is only hypothetical. If all of the evidences associated with the statement indicate a hypothetical interaction then we assume the interaction is hypothetical.''' for ev in stmt.evidence: if not ev.epistemi...
python
{ "resource": "" }
q234478
EnglishAssembler.make_model
train
def make_model(self): """Assemble text from the set of collected INDRA Statements. Returns ------- stmt_strs : str Return the assembled text as unicode string. By default, the text is a single string consisting of one or more sentences with periods at...
python
{ "resource": "" }
q234479
SBGNAssembler.add_statements
train
def add_statements(self, stmts): """Add INDRA Statements to the assembler's list of statements. Parameters ---------- stmts : list[indra.statements.Statement] A list of :py:class:`indra.statements.Statement` to be added to the statement list of the assembler. ...
python
{ "resource": "" }
q234480
SBGNAssembler.make_model
train
def make_model(self): """Assemble the SBGN model from the collected INDRA Statements. This method assembles an SBGN model from the set of INDRA Statements. The assembled model is set as the assembler's sbgn attribute (it is represented as an XML ElementTree internally). The model is ret...
python
{ "resource": "" }
q234481
SBGNAssembler.print_model
train
def print_model(self, pretty=True, encoding='utf8'): """Return the assembled SBGN model as an XML string. Parameters ---------- pretty : Optional[bool] If True, the SBGN string is formatted with indentation (for human viewing) otherwise no indentation is used. De...
python
{ "resource": "" }
q234482
SBGNAssembler.save_model
train
def save_model(self, file_name='model.sbgn'): """Save the assembled SBGN model in a file. Parameters ---------- file_name : Optional[str] The name of the file to save the SBGN network to. Default: model.sbgn """ model = self.print_model() ...
python
{ "resource": "" }
q234483
SBGNAssembler._glyph_for_complex_pattern
train
def _glyph_for_complex_pattern(self, pattern): """Add glyph and member glyphs for a PySB ComplexPattern.""" # Make the main glyph for the agent monomer_glyphs = [] for monomer_pattern in pattern.monomer_patterns: glyph = self._glyph_for_monomer_pattern(monomer_pattern) ...
python
{ "resource": "" }
q234484
SBGNAssembler._glyph_for_monomer_pattern
train
def _glyph_for_monomer_pattern(self, pattern): """Add glyph for a PySB MonomerPattern.""" pattern.matches_key = lambda: str(pattern) agent_id = self._make_agent_id(pattern) # Handle sources and sinks if pattern.monomer.name in ('__source', '__sink'): return None ...
python
{ "resource": "" }
q234485
load_go_graph
train
def load_go_graph(go_fname): """Load the GO data from an OWL file and parse into an RDF graph. Parameters ---------- go_fname : str Path to the GO OWL file. Can be downloaded from http://geneontology.org/ontology/go.owl. Returns ------- rdflib.Graph RDF graph contai...
python
{ "resource": "" }
q234486
update_id_mappings
train
def update_id_mappings(g): """Compile all ID->label mappings and save to a TSV file. Parameters ---------- g : rdflib.Graph RDF graph containing GO data. """ g = load_go_graph(go_owl_path) query = _prefixes + """ SELECT ?id ?label WHERE { ?class oboInOwl...
python
{ "resource": "" }
q234487
get_default_ndex_cred
train
def get_default_ndex_cred(ndex_cred): """Gets the NDEx credentials from the dict, or tries the environment if None""" if ndex_cred: username = ndex_cred.get('user') password = ndex_cred.get('password') if username is not None and password is not None: return username, passwo...
python
{ "resource": "" }
q234488
send_request
train
def send_request(ndex_service_url, params, is_json=True, use_get=False): """Send a request to the NDEx server. Parameters ---------- ndex_service_url : str The URL of the service to use for the request. params : dict A dictionary of parameters to send with the request. Parameter key...
python
{ "resource": "" }
q234489
update_network
train
def update_network(cx_str, network_id, ndex_cred=None): """Update an existing CX network on NDEx with new CX content. Parameters ---------- cx_str : str String containing the CX content. network_id : str UUID of the network on NDEx. ndex_cred : dict A dictionary with the...
python
{ "resource": "" }
q234490
set_style
train
def set_style(network_id, ndex_cred=None, template_id=None): """Set the style of the network to a given template network's style Parameters ---------- network_id : str The UUID of the NDEx network whose style is to be changed. ndex_cred : dict A dictionary of NDEx credentials. t...
python
{ "resource": "" }
q234491
BMIModel.initialize
train
def initialize(self, cfg_file=None, mode=None): """Initialize the model for simulation, possibly given a config file. Parameters ---------- cfg_file : Optional[str] The name of the configuration file to load, optional. """ self.sim = ScipyOdeSimulator(self.mo...
python
{ "resource": "" }
q234492
BMIModel.update
train
def update(self, dt=None): """Simulate the model for a given time interval. Parameters ---------- dt : Optional[float] The time step to simulate, if None, the default built-in time step is used. """ # EMELI passes dt = -1 so we need to handle that...
python
{ "resource": "" }
q234493
BMIModel.set_value
train
def set_value(self, var_name, value): """Set the value of a given variable to a given value. Parameters ---------- var_name : str The name of the variable in the model whose value should be set. value : float The value the variable should be set to ...
python
{ "resource": "" }
q234494
BMIModel.get_value
train
def get_value(self, var_name): """Return the value of a given variable. Parameters ---------- var_name : str The name of the variable whose value should be returned Returns ------- value : float The value of the given variable in the curr...
python
{ "resource": "" }
q234495
BMIModel.get_input_var_names
train
def get_input_var_names(self): """Return a list of variables names that can be set as input. Returns ------- var_names : list[str] A list of variable names that can be set from the outside """ in_vars = copy.copy(self.input_vars) for idx, var in enume...
python
{ "resource": "" }
q234496
BMIModel.get_output_var_names
train
def get_output_var_names(self): """Return a list of variables names that can be read as output. Returns ------- var_names : list[str] A list of variable names that can be read from the outside """ # Return all the variables that aren't input variables ...
python
{ "resource": "" }
q234497
BMIModel.make_repository_component
train
def make_repository_component(self): """Return an XML string representing this BMI in a workflow. This description is required by EMELI to discover and load models. Returns ------- xml : str String serialized XML representation of the component in the mo...
python
{ "resource": "" }
q234498
BMIModel._map_in_out
train
def _map_in_out(self, inside_var_name): """Return the external name of a variable mapped from inside.""" for out_name, in_name in self.outside_name_map.items(): if inside_var_name == in_name: return out_name return None
python
{ "resource": "" }
q234499
read_pmid
train
def read_pmid(pmid, source, cont_path, sparser_version, outbuf=None, cleanup=True): "Run sparser on a single pmid." signal.signal(signal.SIGALRM, _timeout_handler) signal.alarm(60) try: if (source is 'content_not_found' or source.startswith('unhandled_content_type') ...
python
{ "resource": "" }