_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q234100
process_text
train
def process_text(text, output_fmt='json', outbuf=None, cleanup=True, key='', **kwargs): """Return processor with Statements extracted by reading text with Sparser. Parameters ---------- text : str The text to be processed output_fmt: Optional[str] The output format ...
python
{ "resource": "" }
q234101
process_nxml_str
train
def process_nxml_str(nxml_str, output_fmt='json', outbuf=None, cleanup=True, key='', **kwargs): """Return processor with Statements extracted by reading an NXML string. Parameters ---------- nxml_str : str The string value of the NXML-formatted paper to be read. output_...
python
{ "resource": "" }
q234102
process_nxml_file
train
def process_nxml_file(fname, output_fmt='json', outbuf=None, cleanup=True, **kwargs): """Return processor with Statements extracted by reading an NXML file. Parameters ---------- fname : str The path to the NXML file to be read. output_fmt: Optional[str] The ou...
python
{ "resource": "" }
q234103
process_sparser_output
train
def process_sparser_output(output_fname, output_fmt='json'): """Return a processor with Statements extracted from Sparser XML or JSON Parameters ---------- output_fname : str The path to the Sparser output file to be processed. The file can either be JSON or XML output from Sparser, wit...
python
{ "resource": "" }
q234104
process_xml
train
def process_xml(xml_str): """Return processor with Statements extracted from a Sparser XML. Parameters ---------- xml_str : str The XML string obtained by reading content with Sparser, using the 'xml' output mode. Returns ------- sp : SparserXMLProcessor A SparserXM...
python
{ "resource": "" }
q234105
run_sparser
train
def run_sparser(fname, output_fmt, outbuf=None, timeout=600): """Return the path to reading output after running Sparser reading. Parameters ---------- fname : str The path to an input file to be processed. Due to the Spaser executable's assumptions, the file name needs to start with PM...
python
{ "resource": "" }
q234106
get_version
train
def get_version(): """Return the version of the Sparser executable on the path. Returns ------- version : str The version of Sparser that is found on the Sparser path. """ assert sparser_path is not None, "Sparser path is not defined." with open(os.path.join(sparser_path, 'version.t...
python
{ "resource": "" }
q234107
make_nxml_from_text
train
def make_nxml_from_text(text): """Return raw text wrapped in NXML structure. Parameters ---------- text : str The raw text content to be wrapped in an NXML structure. Returns ------- nxml_str : str The NXML string wrapping the raw text input. """ text = _escape_xml(...
python
{ "resource": "" }
q234108
get_hgnc_name
train
def get_hgnc_name(hgnc_id): """Return the HGNC symbol corresponding to the given HGNC ID. Parameters ---------- hgnc_id : str The HGNC ID to be converted. Returns ------- hgnc_name : str The HGNC symbol corresponding to the given HGNC ID. """ try: hgnc_name ...
python
{ "resource": "" }
q234109
get_hgnc_entry
train
def get_hgnc_entry(hgnc_id): """Return the HGNC entry for the given HGNC ID from the web service. Parameters ---------- hgnc_id : str The HGNC ID to be converted. Returns ------- xml_tree : ElementTree The XML ElementTree corresponding to the entry for the given HGN...
python
{ "resource": "" }
q234110
analyze_reach_log
train
def analyze_reach_log(log_fname=None, log_str=None): """Return unifinished PMIDs given a log file name.""" assert bool(log_fname) ^ bool(log_str), 'Must specify log_fname OR log_str' started_patt = re.compile('Starting ([\d]+)') # TODO: it might be interesting to get the time it took to read # each ...
python
{ "resource": "" }
q234111
get_logs_from_db_reading
train
def get_logs_from_db_reading(job_prefix, reading_queue='run_db_reading_queue'): """Get the logs stashed on s3 for a particular reading.""" s3 = boto3.client('s3') gen_prefix = 'reading_results/%s/logs/%s' % (job_prefix, reading_queue) job_log_data = s3.list_objects_v2(Bucket='bigmech', ...
python
{ "resource": "" }
q234112
separate_reach_logs
train
def separate_reach_logs(log_str): """Get the list of reach logs from the overall logs.""" log_lines = log_str.splitlines() reach_logs = [] reach_lines = [] adding_reach_lines = False for l in log_lines[:]: if not adding_reach_lines and 'Beginning reach' in l: adding_reach_lin...
python
{ "resource": "" }
q234113
get_unyielding_tcids
train
def get_unyielding_tcids(log_str): """Extract the set of tcids for which no statements were created.""" tcid_strs = re.findall('INFO: \[.*?\].*? - Got no statements for (\d+).*', log_str) return {int(tcid_str) for tcid_str in tcid_strs}
python
{ "resource": "" }
q234114
analyze_db_reading
train
def analyze_db_reading(job_prefix, reading_queue='run_db_reading_queue'): """Run various analysis on a particular reading job.""" # Analyze reach failures log_strs = get_logs_from_db_reading(job_prefix, reading_queue) indra_log_strs = [] all_reach_logs = [] log_stats = [] for log_str in log_...
python
{ "resource": "" }
q234115
process_pc_neighborhood
train
def process_pc_neighborhood(gene_names, neighbor_limit=1, database_filter=None): """Returns a BiopaxProcessor for a PathwayCommons neighborhood query. The neighborhood query finds the neighborhood around a set of source genes. http://www.pathwaycommons.org/pc2/#graph http:...
python
{ "resource": "" }
q234116
process_pc_pathsbetween
train
def process_pc_pathsbetween(gene_names, neighbor_limit=1, database_filter=None, block_size=None): """Returns a BiopaxProcessor for a PathwayCommons paths-between query. The paths-between query finds the paths between a set of genes. Here source gene names are given in a single l...
python
{ "resource": "" }
q234117
process_pc_pathsfromto
train
def process_pc_pathsfromto(source_genes, target_genes, neighbor_limit=1, database_filter=None): """Returns a BiopaxProcessor for a PathwayCommons paths-from-to query. The paths-from-to query finds the paths from a set of source genes to a set of target genes. http://www.path...
python
{ "resource": "" }
q234118
process_model
train
def process_model(model): """Returns a BiopaxProcessor for a BioPAX model object. Parameters ---------- model : org.biopax.paxtools.model.Model A BioPAX model object. Returns ------- bp : BiopaxProcessor A BiopaxProcessor containing the obtained BioPAX model in bp.model. ...
python
{ "resource": "" }
q234119
is_background_knowledge
train
def is_background_knowledge(stmt): '''Return True if Statement is only supported by background knowledge.''' any_background = False # Iterate over all evidence for the statement for ev in stmt.evidence: epi = ev.epistemics if epi is not None: sec = epi.get('section_type') ...
python
{ "resource": "" }
q234120
multiple_sources
train
def multiple_sources(stmt): '''Return True if statement is supported by multiple sources. Note: this is currently not used and replaced by BeliefEngine score cutoff ''' sources = list(set([e.source_api for e in stmt.evidence])) if len(sources) > 1: return True return False
python
{ "resource": "" }
q234121
GenewaysSymbols.id_to_symbol
train
def id_to_symbol(self, entrez_id): """Gives the symbol for a given entrez id)""" entrez_id = str(entrez_id) if entrez_id not in self.ids_to_symbols: m = 'Could not look up symbol for Entrez ID ' + entrez_id raise Exception(m) return self.ids_to_symbols[entrez_id]
python
{ "resource": "" }
q234122
TsvAssembler.make_model
train
def make_model(self, output_file, add_curation_cols=False, up_only=False): """Export the statements into a tab-separated text file. Parameters ---------- output_file : str Name of the output file. add_curation_cols : bool Whether to add columns to facilit...
python
{ "resource": "" }
q234123
BaseAgentSet.get_create_base_agent
train
def get_create_base_agent(self, agent): """Return base agent with given name, creating it if needed.""" try: base_agent = self.agents[_n(agent.name)] except KeyError: base_agent = BaseAgent(_n(agent.name)) self.agents[_n(agent.name)] = base_agent # If...
python
{ "resource": "" }
q234124
BaseAgent.create_site
train
def create_site(self, site, states=None): """Create a new site on an agent if it doesn't already exist.""" if site not in self.sites: self.sites.append(site) if states is not None: self.site_states.setdefault(site, []) try: states = list(states...
python
{ "resource": "" }
q234125
BaseAgent.create_mod_site
train
def create_mod_site(self, mc): """Create modification site for the BaseAgent from a ModCondition.""" site_name = get_mod_site_name(mc) (unmod_site_state, mod_site_state) = states[mc.mod_type] self.create_site(site_name, (unmod_site_state, mod_site_state)) site_anns = [Annotation(...
python
{ "resource": "" }
q234126
BaseAgent.add_site_states
train
def add_site_states(self, site, states): """Create new states on an agent site if the state doesn't exist.""" for state in states: if state not in self.site_states[site]: self.site_states[site].append(state)
python
{ "resource": "" }
q234127
BaseAgent.add_activity_form
train
def add_activity_form(self, activity_pattern, is_active): """Adds the pattern as an active or inactive form to an Agent. Parameters ---------- activity_pattern : dict A dictionary of site names and their states. is_active : bool Is True if the given patte...
python
{ "resource": "" }
q234128
BaseAgent.add_activity_type
train
def add_activity_type(self, activity_type): """Adds an activity type to an Agent. Parameters ---------- activity_type : str The type of activity to add such as 'activity', 'kinase', 'gtpbound' """ if activity_type not in self.activity_types: ...
python
{ "resource": "" }
q234129
GenewaysAction.make_annotation
train
def make_annotation(self): """Returns a dictionary with all properties of the action and each of its action mentions.""" annotation = dict() # Put all properties of the action object into the annotation for item in dir(self): if len(item) > 0 and item[0] != '_' and \...
python
{ "resource": "" }
q234130
GenewaysActionParser._search_path
train
def _search_path(self, directory_name, filename): """Searches for a given file in the specified directory.""" full_path = path.join(directory_name, filename) if path.exists(full_path): return full_path # Could not find the requested file in any of the directories ret...
python
{ "resource": "" }
q234131
GenewaysActionParser._init_action_list
train
def _init_action_list(self, action_filename): """Parses the file and populates the data.""" self.actions = list() self.hiid_to_action_index = dict() f = codecs.open(action_filename, 'r', encoding='latin-1') first_line = True for line in f: line = line.rstrip...
python
{ "resource": "" }
q234132
GenewaysActionParser._link_to_action_mentions
train
def _link_to_action_mentions(self, actionmention_filename): """Add action mentions""" parser = GenewaysActionMentionParser(actionmention_filename) self.action_mentions = parser.action_mentions for action_mention in self.action_mentions: hiid = action_mention.hiid ...
python
{ "resource": "" }
q234133
GenewaysActionParser._lookup_symbols
train
def _lookup_symbols(self, symbols_filename): """Look up symbols for actions and action mentions""" symbol_lookup = GenewaysSymbols(symbols_filename) for action in self.actions: action.up_symbol = symbol_lookup.id_to_symbol(action.up) action.dn_symbol = symbol_lookup.id_to...
python
{ "resource": "" }
q234134
GenewaysActionParser.get_top_n_action_types
train
def get_top_n_action_types(self, top_n): """Returns the top N actions by count.""" # Count action types action_type_to_counts = dict() for action in self.actions: actiontype = action.actiontype if actiontype not in action_type_to_counts: action_typ...
python
{ "resource": "" }
q234135
GraphAssembler.get_string
train
def get_string(self): """Return the assembled graph as a string. Returns ------- graph_string : str The assembled graph as a string. """ graph_string = self.graph.to_string() graph_string = graph_string.replace('\\N', '\\n') return graph_strin...
python
{ "resource": "" }
q234136
GraphAssembler.save_dot
train
def save_dot(self, file_name='graph.dot'): """Save the graph in a graphviz dot file. Parameters ---------- file_name : Optional[str] The name of the file to save the graph dot string to. """ s = self.get_string() with open(file_name, 'wt') as fh: ...
python
{ "resource": "" }
q234137
GraphAssembler.save_pdf
train
def save_pdf(self, file_name='graph.pdf', prog='dot'): """Draw the graph and save as an image or pdf file. Parameters ---------- file_name : Optional[str] The name of the file to save the graph as. Default: graph.pdf prog : Optional[str] The graphviz prog...
python
{ "resource": "" }
q234138
GraphAssembler._add_edge
train
def _add_edge(self, source, target, **kwargs): """Add an edge to the graph.""" # Start with default edge properties edge_properties = self.edge_properties # Overwrite ones that are given in function call explicitly for k, v in kwargs.items(): edge_properties[k] = v ...
python
{ "resource": "" }
q234139
GraphAssembler._add_node
train
def _add_node(self, agent): """Add an Agent as a node to the graph.""" if agent is None: return node_label = _get_node_label(agent) if isinstance(agent, Agent) and agent.bound_conditions: bound_agents = [bc.agent for bc in agent.bound_conditions if ...
python
{ "resource": "" }
q234140
GraphAssembler._add_stmt_edge
train
def _add_stmt_edge(self, stmt): """Assemble a Modification statement.""" # Skip statements with None in the subject position source = _get_node_key(stmt.agent_list()[0]) target = _get_node_key(stmt.agent_list()[1]) edge_key = (source, target, stmt.__class__.__name__) if e...
python
{ "resource": "" }
q234141
GraphAssembler._add_complex
train
def _add_complex(self, members, is_association=False): """Assemble a Complex statement.""" params = {'color': '#0000ff', 'arrowhead': 'dot', 'arrowtail': 'dot', 'dir': 'both'} for m1, m2 in itertools.combinations(members, 2): if s...
python
{ "resource": "" }
q234142
process_from_file
train
def process_from_file(signor_data_file, signor_complexes_file=None): """Process Signor interaction data from CSV files. Parameters ---------- signor_data_file : str Path to the Signor interaction data file in CSV format. signor_complexes_file : str Path to the Signor complexes data ...
python
{ "resource": "" }
q234143
_handle_response
train
def _handle_response(res, delimiter): """Get an iterator over the CSV data from the response.""" if res.status_code == 200: # Python 2 -- csv.reader will need bytes if sys.version_info[0] < 3: csv_io = BytesIO(res.content) # Python 3 -- csv.reader needs str else: ...
python
{ "resource": "" }
q234144
get_protein_expression
train
def get_protein_expression(gene_names, cell_types): """Return the protein expression levels of genes in cell types. Parameters ---------- gene_names : list HGNC gene symbols for which expression levels are queried. cell_types : list List of cell type names in which expression levels...
python
{ "resource": "" }
q234145
get_aspect
train
def get_aspect(cx, aspect_name): """Return an aspect given the name of the aspect""" if isinstance(cx, dict): return cx.get(aspect_name) for entry in cx: if list(entry.keys())[0] == aspect_name: return entry[aspect_name]
python
{ "resource": "" }
q234146
classify_nodes
train
def classify_nodes(graph, hub): """Classify each node based on its type and relationship to the hub.""" node_stats = defaultdict(lambda: defaultdict(list)) for u, v, data in graph.edges(data=True): # This means the node is downstream of the hub if hub == u: h, o = u, v ...
python
{ "resource": "" }
q234147
get_attributes
train
def get_attributes(aspect, id): """Return the attributes pointing to a given ID in a given aspect.""" attributes = {} for entry in aspect: if entry['po'] == id: attributes[entry['n']] = entry['v'] return attributes
python
{ "resource": "" }
q234148
cx_to_networkx
train
def cx_to_networkx(cx): """Return a MultiDiGraph representation of a CX network.""" graph = networkx.MultiDiGraph() for node_entry in get_aspect(cx, 'nodes'): id = node_entry['@id'] attrs = get_attributes(get_aspect(cx, 'nodeAttributes'), id) attrs['n'] = node_entry['n'] grap...
python
{ "resource": "" }
q234149
get_quadrant_from_class
train
def get_quadrant_from_class(node_class): """Return the ID of the segment of the plane corresponding to a class.""" up, edge_type, _ = node_class if up == 0: return 0 if random.random() < 0.5 else 7 mappings = {(-1, 'modification'): 1, (-1, 'amount'): 2, (-1, 'acti...
python
{ "resource": "" }
q234150
get_coordinates
train
def get_coordinates(node_class): """Generate coordinates for a node in a given class.""" quadrant_size = (2 * math.pi / 8.0) quadrant = get_quadrant_from_class(node_class) begin_angle = quadrant_size * quadrant r = 200 + 800*random.random() alpha = begin_angle + random.random() * quadrant_size ...
python
{ "resource": "" }
q234151
get_layout_aspect
train
def get_layout_aspect(hub, node_classes): """Get the full layout aspect with coordinates for each node.""" aspect = [{'node': hub, 'x': 0.0, 'y': 0.0}] for node, node_class in node_classes.items(): if node == hub: continue x, y = get_coordinates(node_class) aspect.append(...
python
{ "resource": "" }
q234152
get_node_by_name
train
def get_node_by_name(graph, name): """Return a node ID given its name.""" for id, attrs in graph.nodes(data=True): if attrs['n'] == name: return id
python
{ "resource": "" }
q234153
add_semantic_hub_layout
train
def add_semantic_hub_layout(cx, hub): """Attach a layout aspect to a CX network given a hub node.""" graph = cx_to_networkx(cx) hub_node = get_node_by_name(graph, hub) node_classes = classify_nodes(graph, hub_node) layout_aspect = get_layout_aspect(hub_node, node_classes) cx['cartesianLayout'] =...
python
{ "resource": "" }
q234154
get_metadata
train
def get_metadata(doi): """Returns the metadata of an article given its DOI from CrossRef as a JSON dict""" url = crossref_url + 'works/' + doi res = requests.get(url) if res.status_code != 200: logger.info('Could not get CrossRef metadata for DOI %s, code %d' % (doi, res....
python
{ "resource": "" }
q234155
doi_query
train
def doi_query(pmid, search_limit=10): """Get the DOI for a PMID by matching CrossRef and Pubmed metadata. Searches CrossRef using the article title and then accepts search hits only if they have a matching journal ISSN and page number with what is obtained from the Pubmed database. """ # Get ar...
python
{ "resource": "" }
q234156
get_agent_rule_str
train
def get_agent_rule_str(agent): """Construct a string from an Agent as part of a PySB rule name.""" rule_str_list = [_n(agent.name)] # If it's a molecular agent if isinstance(agent, ist.Agent): for mod in agent.mods: mstr = abbrevs[mod.mod_type] if mod.residue is not None:...
python
{ "resource": "" }
q234157
add_rule_to_model
train
def add_rule_to_model(model, rule, annotations=None): """Add a Rule to a PySB model and handle duplicate component errors.""" try: model.add_component(rule) # If the rule was actually added, also add the annotations if annotations: model.annotations += annotations # If th...
python
{ "resource": "" }
q234158
get_create_parameter
train
def get_create_parameter(model, param): """Return parameter with given name, creating it if needed. If unique is false and the parameter exists, the value is not changed; if it does not exist, it will be created. If unique is true then upon conflict a number is added to the end of the parameter name. ...
python
{ "resource": "" }
q234159
get_uncond_agent
train
def get_uncond_agent(agent): """Construct the unconditional state of an Agent. The unconditional Agent is a copy of the original agent but without any bound conditions and modification conditions. Mutation conditions, however, are preserved since they are static. """ agent_uncond = ist.Agent(_n...
python
{ "resource": "" }
q234160
grounded_monomer_patterns
train
def grounded_monomer_patterns(model, agent, ignore_activities=False): """Get monomer patterns for the agent accounting for grounding information. Parameters ---------- model : pysb.core.Model The model to search for MonomerPatterns matching the given Agent. agent : indra.statements.Agent ...
python
{ "resource": "" }
q234161
get_monomer_pattern
train
def get_monomer_pattern(model, agent, extra_fields=None): """Construct a PySB MonomerPattern from an Agent.""" try: monomer = model.monomers[_n(agent.name)] except KeyError as e: logger.warning('Monomer with name %s not found in model' % _n(agent.name)) return ...
python
{ "resource": "" }
q234162
get_site_pattern
train
def get_site_pattern(agent): """Construct a dictionary of Monomer site states from an Agent. This crates the mapping to the associated PySB monomer from an INDRA Agent object.""" if not isinstance(agent, ist.Agent): return {} pattern = {} # Handle bound conditions for bc in agent.bo...
python
{ "resource": "" }
q234163
set_base_initial_condition
train
def set_base_initial_condition(model, monomer, value): """Set an initial condition for a monomer in its 'default' state.""" # Build up monomer pattern dict sites_dict = {} for site in monomer.sites: if site in monomer.site_states: if site == 'loc' and 'cytoplasm' in monomer.site_stat...
python
{ "resource": "" }
q234164
get_annotation
train
def get_annotation(component, db_name, db_ref): """Construct model Annotations for each component. Annotation formats follow guidelines at http://identifiers.org/. """ url = get_identifiers_url(db_name, db_ref) if not url: return None subj = component ann = Annotation(subj, url, 'is...
python
{ "resource": "" }
q234165
PysbAssembler.make_model
train
def make_model(self, policies=None, initial_conditions=True, reverse_effects=False, model_name='indra_model'): """Assemble the PySB model from the collected INDRA Statements. This method assembles a PySB model from the set of INDRA Statements. The assembled model is both retu...
python
{ "resource": "" }
q234166
PysbAssembler.add_default_initial_conditions
train
def add_default_initial_conditions(self, value=None): """Set default initial conditions in the PySB model. Parameters ---------- value : Optional[float] Optionally a value can be supplied which will be the initial amount applied. Otherwise a built-in default is u...
python
{ "resource": "" }
q234167
PysbAssembler.set_expression
train
def set_expression(self, expression_dict): """Set protein expression amounts as initial conditions Parameters ---------- expression_dict : dict A dictionary in which the keys are gene names and the values are numbers representing the absolute amount (...
python
{ "resource": "" }
q234168
PysbAssembler.set_context
train
def set_context(self, cell_type): """Set protein expression amounts from CCLE as initial conditions. This method uses :py:mod:`indra.databases.context_client` to get protein expression levels for a given cell type and set initial conditions for Monomers in the model accordingly. ...
python
{ "resource": "" }
q234169
PysbAssembler.export_model
train
def export_model(self, format, file_name=None): """Save the assembled model in a modeling formalism other than PySB. For more details on exporting PySB models, see http://pysb.readthedocs.io/en/latest/modules/export/index.html Parameters ---------- format : str ...
python
{ "resource": "" }
q234170
PysbAssembler.save_rst
train
def save_rst(self, file_name='pysb_model.rst', module_name='pysb_module'): """Save the assembled model as an RST file for literate modeling. Parameters ---------- file_name : Optional[str] The name of the file to save the RST in. Default: pysb_model.rst m...
python
{ "resource": "" }
q234171
PysbAssembler._monomers
train
def _monomers(self): """Calls the appropriate monomers method based on policies.""" for stmt in self.statements: if _is_whitelisted(stmt): self._dispatch(stmt, 'monomers', self.agent_set)
python
{ "resource": "" }
q234172
send_query
train
def send_query(text, service_endpoint='drum', query_args=None): """Send a query to the TRIPS web service. Parameters ---------- text : str The text to be processed. service_endpoint : Optional[str] Selects the TRIPS/DRUM web service endpoint to use. Is a choice between "drum...
python
{ "resource": "" }
q234173
get_xml
train
def get_xml(html, content_tag='ekb', fail_if_empty=False): """Extract the content XML from the HTML output of the TRIPS web service. Parameters ---------- html : str The HTML output from the TRIPS web service. content_tag : str The xml tag used to label the content. Default is 'ekb'...
python
{ "resource": "" }
q234174
save_xml
train
def save_xml(xml_str, file_name, pretty=True): """Save the TRIPS EKB XML in a file. Parameters ---------- xml_str : str The TRIPS EKB XML string to be saved. file_name : str The name of the file to save the result in. pretty : Optional[bool] If True, the XML is pretty pr...
python
{ "resource": "" }
q234175
process_table
train
def process_table(fname): """Return processor by processing a given sheet of a spreadsheet file. Parameters ---------- fname : str The name of the Excel file (typically .xlsx extension) to process Returns ------- sp : indra.sources.sofia.processor.SofiaProcessor A SofiaProc...
python
{ "resource": "" }
q234176
process_text
train
def process_text(text, out_file='sofia_output.json', auth=None): """Return processor by processing text given as a string. Parameters ---------- text : str A string containing the text to be processed with Sofia. out_file : Optional[str] The path to a file to save the reader's outpu...
python
{ "resource": "" }
q234177
_get_dict_from_list
train
def _get_dict_from_list(dict_key, list_of_dicts): """Retrieve a specific dict from a list of dicts. Parameters ---------- dict_key : str The (single) key of the dict to be retrieved from the list. list_of_dicts : list The list of dicts to search for the specific dict. Returns ...
python
{ "resource": "" }
q234178
NdexCxProcessor._initialize_node_agents
train
def _initialize_node_agents(self): """Initialize internal dicts containing node information.""" nodes = _get_dict_from_list('nodes', self.cx) invalid_genes = [] for node in nodes: id = node['@id'] cx_db_refs = self.get_aliases(node) up_id = cx_db_refs....
python
{ "resource": "" }
q234179
NdexCxProcessor.get_pmids
train
def get_pmids(self): """Get list of all PMIDs associated with edges in the network.""" pmids = [] for ea in self._edge_attributes.values(): edge_pmids = ea.get('pmids') if edge_pmids: pmids += edge_pmids return list(set(pmids))
python
{ "resource": "" }
q234180
NdexCxProcessor.get_statements
train
def get_statements(self): """Convert network edges into Statements. Returns ------- list of Statements Converted INDRA Statements. """ edges = _get_dict_from_list('edges', self.cx) for edge in edges: edge_type = edge.get('i') i...
python
{ "resource": "" }
q234181
TEESProcessor.node_has_edge_with_label
train
def node_has_edge_with_label(self, node_name, edge_label): """Looks for an edge from node_name to some other node with the specified label. Returns the node to which this edge points if it exists, or None if it doesn't. Parameters ---------- G : The graph obj...
python
{ "resource": "" }
q234182
TEESProcessor.general_node_label
train
def general_node_label(self, node): """Used for debugging - gives a short text description of a graph node.""" G = self.G if G.node[node]['is_event']: return 'event type=' + G.node[node]['type'] else: return 'entity text=' + G.node[node]['text']
python
{ "resource": "" }
q234183
TEESProcessor.print_parent_and_children_info
train
def print_parent_and_children_info(self, node): """Used for debugging - prints a short description of a a node, its children, its parents, and its parents' children.""" G = self.G parents = G.predecessors(node) children = G.successors(node) print(general_node_label(G, no...
python
{ "resource": "" }
q234184
TEESProcessor.find_event_with_outgoing_edges
train
def find_event_with_outgoing_edges(self, event_name, desired_relations): """Gets a list of event nodes with the specified event_name and outgoing edges annotated with each of the specified relations. Parameters ---------- event_name : str Look for event nodes with th...
python
{ "resource": "" }
q234185
TEESProcessor.get_related_node
train
def get_related_node(self, node, relation): """Looks for an edge from node to some other node, such that the edge is annotated with the given relation. If there exists such an edge, returns the name of the node it points to. Otherwise, returns None.""" G = self.G for edge in G.ed...
python
{ "resource": "" }
q234186
TEESProcessor.get_entity_text_for_relation
train
def get_entity_text_for_relation(self, node, relation): """Looks for an edge from node to some other node, such that the edge is annotated with the given relation. If there exists such an edge, and the node at the other edge is an entity, return that entity's text. Otherwise, returns Non...
python
{ "resource": "" }
q234187
TEESProcessor.process_increase_expression_amount
train
def process_increase_expression_amount(self): """Looks for Positive_Regulation events with a specified Cause and a Gene_Expression theme, and processes them into INDRA statements. """ statements = [] pwcs = self.find_event_parent_with_event_child( 'Positive_regul...
python
{ "resource": "" }
q234188
TEESProcessor.process_phosphorylation_statements
train
def process_phosphorylation_statements(self): """Looks for Phosphorylation events in the graph and extracts them into INDRA statements. In particular, looks for a Positive_regulation event node with a child Phosphorylation event node. If Positive_regulation has an outgoing Caus...
python
{ "resource": "" }
q234189
TEESProcessor.process_binding_statements
train
def process_binding_statements(self): """Looks for Binding events in the graph and extracts them into INDRA statements. In particular, looks for a Binding event node with outgoing edges with relations Theme and Theme2 - the entities these edges point to are the two constituents ...
python
{ "resource": "" }
q234190
TEESProcessor.node_to_evidence
train
def node_to_evidence(self, entity_node, is_direct): """Computes an evidence object for a statement. We assume that the entire event happens within a single statement, and get the text of the sentence by getting the text of the sentence containing the provided node that corresponds to on...
python
{ "resource": "" }
q234191
TEESProcessor.connected_subgraph
train
def connected_subgraph(self, node): """Returns the subgraph containing the given node, its ancestors, and its descendants. Parameters ---------- node : str We want to create the subgraph containing this node. Returns ------- subgraph : networ...
python
{ "resource": "" }
q234192
process_text
train
def process_text(text, save_xml_name='trips_output.xml', save_xml_pretty=True, offline=False, service_endpoint='drum'): """Return a TripsProcessor by processing text. Parameters ---------- text : str The text to be processed. save_xml_name : Optional[str] The name o...
python
{ "resource": "" }
q234193
process_xml_file
train
def process_xml_file(file_name): """Return a TripsProcessor by processing a TRIPS EKB XML file. Parameters ---------- file_name : str Path to a TRIPS extraction knowledge base (EKB) file to be processed. Returns ------- tp : TripsProcessor A TripsProcessor containing the ex...
python
{ "resource": "" }
q234194
process_xml
train
def process_xml(xml_string): """Return a TripsProcessor by processing a TRIPS EKB XML string. Parameters ---------- xml_string : str A TRIPS extraction knowledge base (EKB) string to be processed. http://trips.ihmc.us/parser/api.html Returns ------- tp : TripsProcessor ...
python
{ "resource": "" }
q234195
load_eidos_curation_table
train
def load_eidos_curation_table(): """Return a pandas table of Eidos curation data.""" url = 'https://raw.githubusercontent.com/clulab/eidos/master/' + \ 'src/main/resources/org/clulab/wm/eidos/english/confidence/' + \ 'rule_summary.tsv' # Load the table of scores from the URL above into a dat...
python
{ "resource": "" }
q234196
get_eidos_bayesian_scorer
train
def get_eidos_bayesian_scorer(prior_counts=None): """Return a BayesianScorer based on Eidos curation counts.""" table = load_eidos_curation_table() subtype_counts = {'eidos': {r: [c, i] for r, c, i in zip(table['RULE'], table['Num correct'], ta...
python
{ "resource": "" }
q234197
get_eidos_scorer
train
def get_eidos_scorer(): """Return a SimpleScorer based on Eidos curated precision estimates.""" table = load_eidos_curation_table() # Get the overall precision total_num = table['COUNT of RULE'].sum() weighted_sum = table['COUNT of RULE'].dot(table['% correct']) precision = weighted_sum / total...
python
{ "resource": "" }
q234198
process_from_web
train
def process_from_web(): """Return a TrrustProcessor based on the online interaction table. Returns ------- TrrustProcessor A TrrustProcessor object that has a list of INDRA Statements in its statements attribute. """ logger.info('Downloading table from %s' % trrust_human_url) ...
python
{ "resource": "" }
q234199
process_from_webservice
train
def process_from_webservice(id_val, id_type='pmcid', source='pmc', with_grounding=True): """Return an output from RLIMS-p for the given PubMed ID or PMC ID. Parameters ---------- id_val : str A PMCID, with the prefix PMC, or pmid, with no prefix, of the paper to ...
python
{ "resource": "" }