_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q233900 | GroundingMapper.map_agent | train | def map_agent(self, agent, do_rename):
"""Return the given Agent with its grounding mapped.
This function grounds a single agent. It returns the new Agent object
(which might be a different object if we load a new agent state
from json) or the same object otherwise.
Parameters
... | python | {
"resource": ""
} |
q233901 | GroundingMapper.map_agents | train | def map_agents(self, stmts, do_rename=True):
"""Return a new list of statements whose agents have been mapped
Parameters
----------
stmts : list of :py:class:`indra.statements.Statement`
The statements whose agents need mapping
do_rename: Optional[bool]
I... | python | {
"resource": ""
} |
q233902 | GroundingMapper.rename_agents | train | def rename_agents(self, stmts):
"""Return a list of mapped statements with updated agent names.
Creates a new list of statements without modifying the original list.
The agents in a statement should be renamed if the grounding map has
updated their db_refs. If an agent contains a FamPl... | python | {
"resource": ""
} |
q233903 | HprdProcessor.get_complexes | train | def get_complexes(self, cplx_df):
"""Generate Complex Statements from the HPRD protein complexes data.
Parameters
----------
cplx_df : pandas.DataFrame
DataFrame loaded from the PROTEIN_COMPLEXES.txt file.
"""
# Group the agents for the complex
logg... | python | {
"resource": ""
} |
q233904 | HprdProcessor.get_ptms | train | def get_ptms(self, ptm_df):
"""Generate Modification statements from the HPRD PTM data.
Parameters
----------
ptm_df : pandas.DataFrame
DataFrame loaded from the POST_TRANSLATIONAL_MODIFICATIONS.txt file.
"""
logger.info('Processing PTMs...')
# Iterat... | python | {
"resource": ""
} |
q233905 | HprdProcessor.get_ppis | train | def get_ppis(self, ppi_df):
"""Generate Complex Statements from the HPRD PPI data.
Parameters
----------
ppi_df : pandas.DataFrame
DataFrame loaded from the BINARY_PROTEIN_PROTEIN_INTERACTIONS.txt
file.
"""
logger.info('Processing PPIs...')
... | python | {
"resource": ""
} |
q233906 | _build_verb_statement_mapping | train | def _build_verb_statement_mapping():
"""Build the mapping between ISI verb strings and INDRA statement classes.
Looks up the INDRA statement class name, if any, in a resource file,
and resolves this class name to a class.
Returns
-------
verb_to_statement_type : dict
Dictionary mapping... | python | {
"resource": ""
} |
q233907 | IsiProcessor.get_statements | train | def get_statements(self):
"""Process reader output to produce INDRA Statements."""
for k, v in self.reader_output.items():
for interaction in v['interactions']:
self._process_interaction(k, interaction, v['text'], self.pmid,
self.extr... | python | {
"resource": ""
} |
q233908 | IsiProcessor._process_interaction | train | def _process_interaction(self, source_id, interaction, text, pmid,
extra_annotations):
"""Process an interaction JSON tuple from the ISI output, and adds up
to one statement to the list of extracted statements.
Parameters
----------
source_id : str
... | python | {
"resource": ""
} |
q233909 | GenewaysActionMention.make_annotation | train | def make_annotation(self):
"""Returns a dictionary with all properties of the action mention."""
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 \
not inspect... | python | {
"resource": ""
} |
q233910 | _match_to_array | train | def _match_to_array(m):
""" Returns an array consisting of the elements obtained from a pattern
search cast into their appropriate classes. """
return [_cast_biopax_element(m.get(i)) for i in range(m.varSize())] | python | {
"resource": ""
} |
q233911 | _is_complex | train | def _is_complex(pe):
"""Return True if the physical entity is a complex"""
val = isinstance(pe, _bp('Complex')) or \
isinstance(pe, _bpimpl('Complex'))
return val | python | {
"resource": ""
} |
q233912 | _is_protein | train | def _is_protein(pe):
"""Return True if the element is a protein"""
val = isinstance(pe, _bp('Protein')) or \
isinstance(pe, _bpimpl('Protein')) or \
isinstance(pe, _bp('ProteinReference')) or \
isinstance(pe, _bpimpl('ProteinReference'))
return val | python | {
"resource": ""
} |
q233913 | _is_rna | train | def _is_rna(pe):
"""Return True if the element is an RNA"""
val = isinstance(pe, _bp('Rna')) or isinstance(pe, _bpimpl('Rna'))
return val | python | {
"resource": ""
} |
q233914 | _is_small_molecule | train | def _is_small_molecule(pe):
"""Return True if the element is a small molecule"""
val = isinstance(pe, _bp('SmallMolecule')) or \
isinstance(pe, _bpimpl('SmallMolecule')) or \
isinstance(pe, _bp('SmallMoleculeReference')) or \
isinstance(pe, _bpimpl('SmallMoleculeReference'))
... | python | {
"resource": ""
} |
q233915 | _is_physical_entity | train | def _is_physical_entity(pe):
"""Return True if the element is a physical entity"""
val = isinstance(pe, _bp('PhysicalEntity')) or \
isinstance(pe, _bpimpl('PhysicalEntity'))
return val | python | {
"resource": ""
} |
q233916 | _is_modification_or_activity | train | def _is_modification_or_activity(feature):
"""Return True if the feature is a modification"""
if not (isinstance(feature, _bp('ModificationFeature')) or \
isinstance(feature, _bpimpl('ModificationFeature'))):
return None
mf_type = feature.getModificationType()
if mf_type is None:
... | python | {
"resource": ""
} |
q233917 | _is_reference | train | def _is_reference(bpe):
"""Return True if the element is an entity reference."""
if isinstance(bpe, _bp('ProteinReference')) or \
isinstance(bpe, _bpimpl('ProteinReference')) or \
isinstance(bpe, _bp('SmallMoleculeReference')) or \
isinstance(bpe, _bpimpl('SmallMoleculeReference')) or \
... | python | {
"resource": ""
} |
q233918 | _is_entity | train | def _is_entity(bpe):
"""Return True if the element is a physical entity."""
if isinstance(bpe, _bp('Protein')) or \
isinstance(bpe, _bpimpl('Protein')) or \
isinstance(bpe, _bp('SmallMolecule')) or \
isinstance(bpe, _bpimpl('SmallMolecule')) or \
isinstance(bpe, _bp('Complex')) o... | python | {
"resource": ""
} |
q233919 | _is_catalysis | train | def _is_catalysis(bpe):
"""Return True if the element is Catalysis."""
if isinstance(bpe, _bp('Catalysis')) or \
isinstance(bpe, _bpimpl('Catalysis')):
return True
else:
return False | python | {
"resource": ""
} |
q233920 | BiopaxProcessor.print_statements | train | def print_statements(self):
"""Print all INDRA Statements collected by the processors."""
for i, stmt in enumerate(self.statements):
print("%s: %s" % (i, stmt)) | python | {
"resource": ""
} |
q233921 | BiopaxProcessor.save_model | train | def save_model(self, file_name=None):
"""Save the BioPAX model object in an OWL file.
Parameters
----------
file_name : Optional[str]
The name of the OWL file to save the model in.
"""
if file_name is None:
logger.error('Missing file name')
... | python | {
"resource": ""
} |
q233922 | BiopaxProcessor.eliminate_exact_duplicates | train | def eliminate_exact_duplicates(self):
"""Eliminate Statements that were extracted multiple times.
Due to the way the patterns are implemented, they can sometimes yield
the same Statement information multiple times, in which case,
we end up with redundant Statements that aren't from inde... | python | {
"resource": ""
} |
q233923 | BiopaxProcessor.get_complexes | train | def get_complexes(self):
"""Extract INDRA Complex Statements from the BioPAX model.
This method searches for org.biopax.paxtools.model.level3.Complex
objects which represent molecular complexes. It doesn't reuse
BioPAX Pattern's org.biopax.paxtools.pattern.PatternBox.inComplexWith
... | python | {
"resource": ""
} |
q233924 | BiopaxProcessor.get_modifications | train | def get_modifications(self):
"""Extract INDRA Modification Statements from the BioPAX model.
To extract Modifications, this method reuses the structure of
BioPAX Pattern's
org.biopax.paxtools.pattern.PatternBox.constrolsStateChange pattern
with additional constraints to specify ... | python | {
"resource": ""
} |
q233925 | BiopaxProcessor.get_activity_modification | train | def get_activity_modification(self):
"""Extract INDRA ActiveForm statements from the BioPAX model.
This method extracts ActiveForm Statements that are due to
protein modifications. This method reuses the structure of
BioPAX Pattern's
org.biopax.paxtools.pattern.PatternBox.constr... | python | {
"resource": ""
} |
q233926 | BiopaxProcessor.get_regulate_amounts | train | def get_regulate_amounts(self):
"""Extract INDRA RegulateAmount Statements from the BioPAX model.
This method extracts IncreaseAmount/DecreaseAmount Statements from
the BioPAX model. It fully reuses BioPAX Pattern's
org.biopax.paxtools.pattern.PatternBox.controlsExpressionWithTemplateRe... | python | {
"resource": ""
} |
q233927 | BiopaxProcessor.get_gef | train | def get_gef(self):
"""Extract Gef INDRA Statements from the BioPAX model.
This method uses a custom BioPAX Pattern
(one that is not implemented PatternBox) to query for controlled
BiochemicalReactions in which the same protein is in complex with
GDP on the left hand side and in ... | python | {
"resource": ""
} |
q233928 | BiopaxProcessor.get_gap | train | def get_gap(self):
"""Extract Gap INDRA Statements from the BioPAX model.
This method uses a custom BioPAX Pattern
(one that is not implemented PatternBox) to query for controlled
BiochemicalReactions in which the same protein is in complex with
GTP on the left hand side and in ... | python | {
"resource": ""
} |
q233929 | BiopaxProcessor._get_entity_mods | train | def _get_entity_mods(bpe):
"""Get all the modifications of an entity in INDRA format"""
if _is_entity(bpe):
features = bpe.getFeature().toArray()
else:
features = bpe.getEntityFeature().toArray()
mods = []
for feature in features:
if not _is_mo... | python | {
"resource": ""
} |
q233930 | BiopaxProcessor._get_generic_modification | train | def _get_generic_modification(self, mod_class):
"""Get all modification reactions given a Modification class."""
mod_type = modclass_to_modtype[mod_class]
if issubclass(mod_class, RemoveModification):
mod_gain_const = mcct.LOSS
mod_type = modtype_to_inverse[mod_type]
... | python | {
"resource": ""
} |
q233931 | BiopaxProcessor._construct_modification_pattern | train | def _construct_modification_pattern():
"""Construct the BioPAX pattern to extract modification reactions."""
# The following constraints were pieced together based on the
# following two higher level constrains: pb.controlsStateChange(),
# pb.controlsPhosphorylation().
p = _bpp('... | python | {
"resource": ""
} |
q233932 | BiopaxProcessor._extract_mod_from_feature | train | def _extract_mod_from_feature(mf):
"""Extract the type of modification and the position from
a ModificationFeature object in the INDRA format."""
# ModificationFeature / SequenceModificationVocabulary
mf_type = mf.getModificationType()
if mf_type is None:
return None
... | python | {
"resource": ""
} |
q233933 | BiopaxProcessor._get_entref | train | def _get_entref(bpe):
"""Returns the entity reference of an entity if it exists or
return the entity reference that was passed in as argument."""
if not _is_reference(bpe):
try:
er = bpe.getEntityReference()
except AttributeError:
return No... | python | {
"resource": ""
} |
q233934 | _stmt_location_to_agents | train | def _stmt_location_to_agents(stmt, location):
"""Apply an event location to the Agents in the corresponding Statement.
If a Statement is in a given location we represent that by requiring all
Agents in the Statement to be in that location.
"""
if location is None:
return
agents = stmt.a... | python | {
"resource": ""
} |
q233935 | TripsProcessor.get_all_events | train | def get_all_events(self):
"""Make a list of all events in the TRIPS EKB.
The events are stored in self.all_events.
"""
self.all_events = {}
events = self.tree.findall('EVENT')
events += self.tree.findall('CC')
for e in events:
event_id = e.attrib['id'... | python | {
"resource": ""
} |
q233936 | TripsProcessor.get_activations | train | def get_activations(self):
"""Extract direct Activation INDRA Statements."""
act_events = self.tree.findall("EVENT/[type='ONT::ACTIVATE']")
inact_events = self.tree.findall("EVENT/[type='ONT::DEACTIVATE']")
inact_events += self.tree.findall("EVENT/[type='ONT::INHIBIT']")
for even... | python | {
"resource": ""
} |
q233937 | TripsProcessor.get_activations_causal | train | def get_activations_causal(self):
"""Extract causal Activation INDRA Statements."""
# Search for causal connectives of type ONT::CAUSE
ccs = self.tree.findall("CC/[type='ONT::CAUSE']")
for cc in ccs:
factor = cc.find("arg/[@role=':FACTOR']")
outcome = cc.find("arg... | python | {
"resource": ""
} |
q233938 | TripsProcessor.get_activations_stimulate | train | def get_activations_stimulate(self):
"""Extract Activation INDRA Statements via stimulation."""
# TODO: extract to other patterns:
# - Stimulation by EGF activates ERK
# - Stimulation by EGF leads to ERK activation
# Search for stimulation event
stim_events = self.tree.fi... | python | {
"resource": ""
} |
q233939 | TripsProcessor.get_degradations | train | def get_degradations(self):
"""Extract Degradation INDRA Statements."""
deg_events = self.tree.findall("EVENT/[type='ONT::CONSUME']")
for event in deg_events:
if event.attrib['id'] in self._static_events:
continue
affected = event.find(".//*[@role=':AFFECT... | python | {
"resource": ""
} |
q233940 | TripsProcessor.get_complexes | train | def get_complexes(self):
"""Extract Complex INDRA Statements."""
bind_events = self.tree.findall("EVENT/[type='ONT::BIND']")
bind_events += self.tree.findall("EVENT/[type='ONT::INTERACT']")
for event in bind_events:
if event.attrib['id'] in self._static_events:
... | python | {
"resource": ""
} |
q233941 | TripsProcessor.get_modifications | train | def get_modifications(self):
"""Extract all types of Modification INDRA Statements."""
# Get all the specific mod types
mod_event_types = list(ont_to_mod_type.keys())
# Add ONT::PTMs as a special case
mod_event_types += ['ONT::PTM']
mod_events = []
for mod_event_t... | python | {
"resource": ""
} |
q233942 | TripsProcessor.get_modifications_indirect | train | def get_modifications_indirect(self):
"""Extract indirect Modification INDRA Statements."""
# Get all the specific mod types
mod_event_types = list(ont_to_mod_type.keys())
# Add ONT::PTMs as a special case
mod_event_types += ['ONT::PTM']
def get_increase_events(mod_event... | python | {
"resource": ""
} |
q233943 | TripsProcessor.get_agents | train | def get_agents(self):
"""Return list of INDRA Agents corresponding to TERMs in the EKB.
This is meant to be used when entities e.g. "phosphorylated ERK",
rather than events need to be extracted from processed natural
language. These entities with their respective states are represented
... | python | {
"resource": ""
} |
q233944 | TripsProcessor.get_term_agents | train | def get_term_agents(self):
"""Return dict of INDRA Agents keyed by corresponding TERMs in the EKB.
This is meant to be used when entities e.g. "phosphorylated ERK",
rather than events need to be extracted from processed natural
language. These entities with their respective states are r... | python | {
"resource": ""
} |
q233945 | TripsProcessor._get_evidence_text | train | def _get_evidence_text(self, event_tag):
"""Extract the evidence for an event.
Pieces of text linked to an EVENT are fragments of a sentence. The
EVENT refers to the paragraph ID and the "uttnum", which corresponds
to a sentence ID. Here we find and return the full sentence from which
... | python | {
"resource": ""
} |
q233946 | get_causal_edge | train | def get_causal_edge(stmt, activates):
"""Returns the causal, polar edge with the correct "contact"."""
any_contact = any(
evidence.epistemics.get('direct', False)
for evidence in stmt.evidence
)
if any_contact:
return pc.DIRECTLY_INCREASES if activates else pc.DIRECTLY_DECREASES
... | python | {
"resource": ""
} |
q233947 | PybelAssembler.to_database | train | def to_database(self, manager=None):
"""Send the model to the PyBEL database
This function wraps :py:func:`pybel.to_database`.
Parameters
----------
manager : Optional[pybel.manager.Manager]
A PyBEL database manager. If none, first checks the PyBEL
confi... | python | {
"resource": ""
} |
q233948 | get_binding_site_name | train | def get_binding_site_name(agent):
"""Return a binding site name from a given agent."""
# Try to construct a binding site name based on parent
grounding = agent.get_grounding()
if grounding != (None, None):
uri = hierarchies['entity'].get_uri(grounding[0], grounding[1])
# Get highest leve... | python | {
"resource": ""
} |
q233949 | get_mod_site_name | train | def get_mod_site_name(mod_condition):
"""Return site names for a modification."""
if mod_condition.residue is None:
mod_str = abbrevs[mod_condition.mod_type]
else:
mod_str = mod_condition.residue
mod_pos = mod_condition.position if \
mod_condition.position is not None else ''
... | python | {
"resource": ""
} |
q233950 | process_flat_files | train | def process_flat_files(id_mappings_file, complexes_file=None, ptm_file=None,
ppi_file=None, seq_file=None, motif_window=7):
"""Get INDRA Statements from HPRD data.
Of the arguments, `id_mappings_file` is required, and at least one of
`complexes_file`, `ptm_file`, and `ppi_file` must ... | python | {
"resource": ""
} |
q233951 | PysbPreassembler._gather_active_forms | train | def _gather_active_forms(self):
"""Collect all the active forms of each Agent in the Statements."""
for stmt in self.statements:
if isinstance(stmt, ActiveForm):
base_agent = self.agent_set.get_create_base_agent(stmt.agent)
# Handle the case where an activity ... | python | {
"resource": ""
} |
q233952 | PysbPreassembler.replace_activities | train | def replace_activities(self):
"""Replace ative flags with Agent states when possible."""
logger.debug('Running PySB Preassembler replace activities')
# TODO: handle activity hierarchies
new_stmts = []
def has_agent_activity(stmt):
"""Return True if any agents in the ... | python | {
"resource": ""
} |
q233953 | PysbPreassembler.add_reverse_effects | train | def add_reverse_effects(self):
"""Add Statements for the reverse effects of some Statements.
For instance, if a protein is phosphorylated but never dephosphorylated
in the model, we add a generic dephosphorylation here. This step is
usually optional in the assembly process.
"""
... | python | {
"resource": ""
} |
q233954 | _get_uniprot_id | train | def _get_uniprot_id(agent):
"""Return the UniProt ID for an agent, looking up in HGNC if necessary.
If the UniProt ID is a list then return the first ID by default.
"""
up_id = agent.db_refs.get('UP')
hgnc_id = agent.db_refs.get('HGNC')
if up_id is None:
if hgnc_id is None:
... | python | {
"resource": ""
} |
q233955 | SiteMapper.map_sites | train | def map_sites(self, stmts):
"""Check a set of statements for invalid modification sites.
Statements are checked against Uniprot reference sequences to determine
if residues referred to by post-translational modifications exist at
the given positions.
If there is nothing amiss w... | python | {
"resource": ""
} |
q233956 | SiteMapper._map_agent_sites | train | def _map_agent_sites(self, agent):
"""Check an agent for invalid sites and update if necessary.
Parameters
----------
agent : :py:class:`indra.statements.Agent`
Agent to check for invalid modification sites.
Returns
-------
tuple
The firs... | python | {
"resource": ""
} |
q233957 | SiteMapper._map_agent_mod | train | def _map_agent_mod(self, agent, mod_condition):
"""Map a single modification condition on an agent.
Parameters
----------
agent : :py:class:`indra.statements.Agent`
Agent to check for invalid modification sites.
mod_condition : :py:class:`indra.statements.ModConditio... | python | {
"resource": ""
} |
q233958 | _get_graph_reductions | train | def _get_graph_reductions(graph):
"""Return transitive reductions on a DAG.
This is used to reduce the set of activities of a BaseAgent to the most
specific one(s) possible. For instance, if a BaseAgent is know to have
'activity', 'catalytic' and 'kinase' activity, then this function will
return {'... | python | {
"resource": ""
} |
q233959 | MechLinker.gather_explicit_activities | train | def gather_explicit_activities(self):
"""Aggregate all explicit activities and active forms of Agents.
This function iterates over self.statements and extracts explicitly
stated activity types and active forms for Agents.
"""
for stmt in self.statements:
agents = stm... | python | {
"resource": ""
} |
q233960 | MechLinker.gather_implicit_activities | train | def gather_implicit_activities(self):
"""Aggregate all implicit activities and active forms of Agents.
Iterate over self.statements and collect the implied activities
and active forms of Agents that appear in the Statements.
Note that using this function to collect implied Agent activi... | python | {
"resource": ""
} |
q233961 | MechLinker.require_active_forms | train | def require_active_forms(self):
"""Rewrites Statements with Agents' active forms in active positions.
As an example, the enzyme in a Modification Statement can be expected
to be in an active state. Similarly, subjects of RegulateAmount and
RegulateActivity Statements can be expected to ... | python | {
"resource": ""
} |
q233962 | MechLinker.reduce_activities | train | def reduce_activities(self):
"""Rewrite the activity types referenced in Statements for consistency.
Activity types are reduced to the most specific form whenever possible.
For instance, if 'kinase' is the only specific activity type known
for the BaseAgent of BRAF, its generic 'activit... | python | {
"resource": ""
} |
q233963 | MechLinker.infer_complexes | train | def infer_complexes(stmts):
"""Return inferred Complex from Statements implying physical interaction.
Parameters
----------
stmts : list[indra.statements.Statement]
A list of Statements to infer Complexes from.
Returns
-------
linked_stmts : list[ind... | python | {
"resource": ""
} |
q233964 | MechLinker.infer_activations | train | def infer_activations(stmts):
"""Return inferred RegulateActivity from Modification + ActiveForm.
This function looks for combinations of Modification and ActiveForm
Statements and infers Activation/Inhibition Statements from them.
For example, if we know that A phosphorylates B, and th... | python | {
"resource": ""
} |
q233965 | MechLinker.infer_active_forms | train | def infer_active_forms(stmts):
"""Return inferred ActiveForm from RegulateActivity + Modification.
This function looks for combinations of Activation/Inhibition
Statements and Modification Statements, and infers an ActiveForm
from them. For example, if we know that A activates B and
... | python | {
"resource": ""
} |
q233966 | MechLinker.infer_modifications | train | def infer_modifications(stmts):
"""Return inferred Modification from RegulateActivity + ActiveForm.
This function looks for combinations of Activation/Inhibition Statements
and ActiveForm Statements that imply a Modification Statement.
For example, if we know that A activates B, and pho... | python | {
"resource": ""
} |
q233967 | MechLinker.replace_complexes | train | def replace_complexes(self, linked_stmts=None):
"""Remove Complex Statements that can be inferred out.
This function iterates over self.statements and looks for Complex
Statements that either match or are refined by inferred Complex
Statements that were linked (provided as the linked_st... | python | {
"resource": ""
} |
q233968 | MechLinker.replace_activations | train | def replace_activations(self, linked_stmts=None):
"""Remove RegulateActivity Statements that can be inferred out.
This function iterates over self.statements and looks for
RegulateActivity Statements that either match or are refined by
inferred RegulateActivity Statements that were link... | python | {
"resource": ""
} |
q233969 | BaseAgentSet.get_create_base_agent | train | def get_create_base_agent(self, agent):
"""Return BaseAgent from an Agent, creating it if needed.
Parameters
----------
agent : indra.statements.Agent
Returns
-------
base_agent : indra.mechlinker.BaseAgent
"""
try:
base_agent = self.... | python | {
"resource": ""
} |
q233970 | AgentState.apply_to | train | def apply_to(self, agent):
"""Apply this object's state to an Agent.
Parameters
----------
agent : indra.statements.Agent
The agent to which the state should be applied
"""
agent.bound_conditions = self.bound_conditions
agent.mods = self.mods
... | python | {
"resource": ""
} |
q233971 | submit_curation | train | def submit_curation():
"""Submit curations for a given corpus.
The submitted curations are handled to update the probability model but
there is no return value here. The update_belief function can be called
separately to calculate update belief scores.
Parameters
----------
corpus_id : str... | python | {
"resource": ""
} |
q233972 | update_beliefs | train | def update_beliefs():
"""Return updated beliefs based on current probability model."""
if request.json is None:
abort(Response('Missing application/json header.', 415))
# Get input parameters
corpus_id = request.json.get('corpus_id')
try:
belief_dict = curator.update_beliefs(corpus_i... | python | {
"resource": ""
} |
q233973 | LiveCurator.reset_scorer | train | def reset_scorer(self):
"""Reset the scorer used for couration."""
self.scorer = get_eidos_bayesian_scorer()
for corpus_id, corpus in self.corpora.items():
corpus.curations = {} | python | {
"resource": ""
} |
q233974 | LiveCurator.get_corpus | train | def get_corpus(self, corpus_id):
"""Return a corpus given an ID.
If the corpus ID cannot be found, an InvalidCorpusError is raised.
Parameters
----------
corpus_id : str
The ID of the corpus to return.
Returns
-------
Corpus
The ... | python | {
"resource": ""
} |
q233975 | LiveCurator.update_beliefs | train | def update_beliefs(self, corpus_id):
"""Return updated belief scores for a given corpus.
Parameters
----------
corpus_id : str
The ID of the corpus for which beliefs are to be updated.
Returns
-------
dict
A dictionary of belief scores wi... | python | {
"resource": ""
} |
q233976 | get_python_list | train | def get_python_list(scala_list):
"""Return list from elements of scala.collection.immutable.List"""
python_list = []
for i in range(scala_list.length()):
python_list.append(scala_list.apply(i))
return python_list | python | {
"resource": ""
} |
q233977 | get_python_dict | train | def get_python_dict(scala_map):
"""Return a dict from entries in a scala.collection.immutable.Map"""
python_dict = {}
keys = get_python_list(scala_map.keys().toList())
for key in keys:
python_dict[key] = scala_map.apply(key)
return python_dict | python | {
"resource": ""
} |
q233978 | get_python_json | train | def get_python_json(scala_json):
"""Return a JSON dict from a org.json4s.JsonAST"""
def convert_node(node):
if node.__class__.__name__ in ('org.json4s.JsonAST$JValue',
'org.json4s.JsonAST$JObject'):
# Make a dictionary and then convert each value
... | python | {
"resource": ""
} |
q233979 | get_heat_kernel | train | def get_heat_kernel(network_id):
"""Return the identifier of a heat kernel calculated for a given network.
Parameters
----------
network_id : str
The UUID of the network in NDEx.
Returns
-------
kernel_id : str
The identifier of the heat kernel calculated for the given netw... | python | {
"resource": ""
} |
q233980 | get_relevant_nodes | train | def get_relevant_nodes(network_id, query_nodes):
"""Return a set of network nodes relevant to a given query set.
A heat diffusion algorithm is used on a pre-computed heat kernel for the
given network which starts from the given query nodes. The nodes
in the network are ranked according to heat score wh... | python | {
"resource": ""
} |
q233981 | _get_belief_package | train | def _get_belief_package(stmt):
"""Return the belief packages of a given statement recursively."""
# This list will contain the belief packages for the given statement
belief_packages = []
# Iterate over all the support parents
for st in stmt.supports:
# Recursively get all the belief package... | python | {
"resource": ""
} |
q233982 | sample_statements | train | def sample_statements(stmts, seed=None):
"""Return statements sampled according to belief.
Statements are sampled independently according to their
belief scores. For instance, a Staement with a belief
score of 0.7 will end up in the returned Statement list
with probability 0.7.
Parameters
... | python | {
"resource": ""
} |
q233983 | evidence_random_noise_prior | train | def evidence_random_noise_prior(evidence, type_probs, subtype_probs):
"""Determines the random-noise prior probability for this evidence.
If the evidence corresponds to a subtype, and that subtype has a curated
prior noise probability, use that.
Otherwise, gives the random-noise prior for the overall ... | python | {
"resource": ""
} |
q233984 | tag_evidence_subtype | train | def tag_evidence_subtype(evidence):
"""Returns the type and subtype of an evidence object as a string,
typically the extraction rule or database from which the statement
was generated.
For biopax, this is just the database name.
Parameters
----------
statement: indra.statements.Evidence
... | python | {
"resource": ""
} |
q233985 | SimpleScorer.score_evidence_list | train | def score_evidence_list(self, evidences):
"""Return belief score given a list of supporting evidences."""
def _score(evidences):
if not evidences:
return 0
# Collect all unique sources
sources = [ev.source_api for ev in evidences]
uniq_sour... | python | {
"resource": ""
} |
q233986 | SimpleScorer.score_statement | train | def score_statement(self, st, extra_evidence=None):
"""Computes the prior belief probability for an INDRA Statement.
The Statement is assumed to be de-duplicated. In other words,
the Statement is assumed to have
a list of Evidence objects that supports it. The prior probability of
... | python | {
"resource": ""
} |
q233987 | SimpleScorer.check_prior_probs | train | def check_prior_probs(self, statements):
"""Throw Exception if BeliefEngine parameter is missing.
Make sure the scorer has all the information needed to compute
belief scores of each statement in the provided list, and raises an
exception otherwise.
Parameters
---------... | python | {
"resource": ""
} |
q233988 | BayesianScorer.update_probs | train | def update_probs(self):
"""Update the internal probability values given the counts."""
# We deal with the prior probsfirst
# This is a fixed assumed value for systematic error
syst_error = 0.05
prior_probs = {'syst': {}, 'rand': {}}
for source, (p, n) in self.prior_counts... | python | {
"resource": ""
} |
q233989 | BayesianScorer.update_counts | train | def update_counts(self, prior_counts, subtype_counts):
"""Update the internal counts based on given new counts.
Parameters
----------
prior_counts : dict
A dictionary of counts of the form [pos, neg] for
each source.
subtype_counts : dict
A di... | python | {
"resource": ""
} |
q233990 | BeliefEngine.set_prior_probs | train | def set_prior_probs(self, statements):
"""Sets the prior belief probabilities for a list of INDRA Statements.
The Statements are assumed to be de-duplicated. In other words,
each Statement in the list passed to this function is assumed to have
a list of Evidence objects that support it.... | python | {
"resource": ""
} |
q233991 | BeliefEngine.set_hierarchy_probs | train | def set_hierarchy_probs(self, statements):
"""Sets hierarchical belief probabilities for INDRA Statements.
The Statements are assumed to be in a hierarchical relation graph with
the supports and supported_by attribute of each Statement object having
been set.
The hierarchical be... | python | {
"resource": ""
} |
q233992 | BeliefEngine.set_linked_probs | train | def set_linked_probs(self, linked_statements):
"""Sets the belief probabilities for a list of linked INDRA Statements.
The list of LinkedStatement objects is assumed to come from the
MechanismLinker. The belief probability of the inferred Statement is
assigned the joint probability of i... | python | {
"resource": ""
} |
q233993 | RlimspProcessor.extract_statements | train | def extract_statements(self):
"""Extract the statements from the json."""
for p_info in self._json:
para = RlimspParagraph(p_info, self.doc_id_type)
self.statements.extend(para.get_statements())
return | python | {
"resource": ""
} |
q233994 | RlimspParagraph._get_agent | train | def _get_agent(self, entity_id):
"""Convert the entity dictionary into an INDRA Agent."""
if entity_id is None:
return None
entity_info = self._entity_dict.get(entity_id)
if entity_info is None:
logger.warning("Entity key did not resolve to entity.")
... | python | {
"resource": ""
} |
q233995 | RlimspParagraph._get_evidence | train | def _get_evidence(self, trigger_id, args, agent_coords, site_coords):
"""Get the evidence using the info in the trigger entity."""
trigger_info = self._entity_dict[trigger_id]
# Get the sentence index from the trigger word.
s_idx_set = {self._entity_dict[eid]['sentenceIndex']
... | python | {
"resource": ""
} |
q233996 | get_reader_classes | train | def get_reader_classes(parent=Reader):
"""Get all childless the descendants of a parent class, recursively."""
children = parent.__subclasses__()
descendants = children[:]
for child in children:
grandchildren = get_reader_classes(child)
if grandchildren:
descendants.remove(ch... | python | {
"resource": ""
} |
q233997 | get_reader_class | train | def get_reader_class(reader_name):
"""Get a particular reader class by name."""
for reader_class in get_reader_classes():
if reader_class.name.lower() == reader_name.lower():
return reader_class
else:
logger.error("No such reader: %s" % reader_name)
return None | python | {
"resource": ""
} |
q233998 | Content.from_file | train | def from_file(cls, file_path, compressed=False, encoded=False):
"""Create a content object from a file path."""
file_id = '.'.join(path.basename(file_path).split('.')[:-1])
file_format = file_path.split('.')[-1]
content = cls(file_id, file_format, compressed, encoded)
content.fil... | python | {
"resource": ""
} |
q233999 | Content.change_id | train | def change_id(self, new_id):
"""Change the id of this content."""
self._load_raw_content()
self._id = new_id
self.get_filename(renew=True)
self.get_filepath(renew=True)
return | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.