Mechanism Linker (indra.mechlinker)

class indra.mechlinker.AgentState(agent, evidence=None)[source]

A class representing Agent state without identifying a specific Agent.

bound_conditions
Type

list[indra.statements.BoundCondition]

mods
Type

list[indra.statements.ModCondition]

mutations
Type

list[indra.statements.Mutation]

location
Type

indra.statements.location

apply_to(agent)[source]

Apply this object’s state to an Agent.

Parameters

agent (indra.statements.Agent) – The agent to which the state should be applied

class indra.mechlinker.BaseAgent(name)[source]

Represents all activity types and active forms of an Agent.

Parameters
  • name (str) – The name of the BaseAgent

  • activity_types (list[str]) – A list of activity types that the Agent has

  • active_states (dict) – A dict of activity types and their associated Agent states

  • activity_reductions (dict) – A dict of activity types and the type they are reduced to by inference.

class indra.mechlinker.BaseAgentSet[source]

Container for a set of BaseAgents.

This class wraps a dict of BaseAgent instance and can be used to get and set BaseAgents.

get_create_base_agent(agent)[source]

Return BaseAgent from an Agent, creating it if needed.

Parameters

agent (indra.statements.Agent) –

Returns

base_agent

Return type

indra.mechlinker.BaseAgent

class indra.mechlinker.LinkedStatement(source_stmts, inferred_stmt)[source]

A tuple containing a list of source Statements and an inferred Statement.

The list of source Statements are the basis for the inferred Statement.

Parameters
  • source_stmts (list[indra.statements.Statement]) – A list of source Statements

  • inferred_stmts (indra.statements.Statement) – A Statement that was inferred from the source Statements.

class indra.mechlinker.MechLinker(stmts=None)[source]

Rewrite the activation pattern of Statements and derive new Statements.

The mechanism linker (MechLinker) traverses a corpus of Statements and uses various inference steps to make the activity types and active forms consistent among Statements.

add_statements(stmts)[source]

Add statements to the MechLinker.

Parameters

stmts (list[indra.statements.Statement]) – A list of Statements to add.

gather_explicit_activities()[source]

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.

gather_implicit_activities()[source]

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 activities can be risky. Assume, for instance, that a Statement from a reading system states that EGF bound to EGFR phosphorylates ERK. This would be interpreted as implicit evidence for the EGFR-bound form of EGF to have ‘kinase’ activity, which is clearly incorrect.

In contrast the alternative pair of this function: gather_explicit_activities collects only explicitly stated activities.

static infer_activations(stmts)[source]

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 the phosphorylated form of B is active, then we can infer that A activates B. This can also be viewed as having “explained” a given Activation/Inhibition Statement with a combination of more mechanistic Modification + ActiveForm Statements.

Parameters

stmts (list[indra.statements.Statement]) – A list of Statements to infer RegulateActivity from.

Returns

linked_stmts – A list of LinkedStatements representing the inferred Statements.

Return type

list[indra.mechlinker.LinkedStatement]

static infer_active_forms(stmts)[source]

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 A phosphorylates B, then we can infer that the phosphorylated form of B is active.

Parameters

stmts (list[indra.statements.Statement]) – A list of Statements to infer ActiveForms from.

Returns

linked_stmts – A list of LinkedStatements representing the inferred Statements.

Return type

list[indra.mechlinker.LinkedStatement]

static infer_complexes(stmts)[source]

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 – A list of LinkedStatements representing the inferred Statements.

Return type

list[indra.mechlinker.LinkedStatement]

static infer_modifications(stmts)[source]

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 phosphorylated B is active, then we can infer that A leads to the phosphorylation of B. An additional requirement when making this assumption is that the activity of B should only be dependent on the modified state and not other context - otherwise the inferred Modification is not necessarily warranted.

Parameters

stmts (list[indra.statements.Statement]) – A list of Statements to infer Modifications from.

Returns

linked_stmts – A list of LinkedStatements representing the inferred Statements.

Return type

list[indra.mechlinker.LinkedStatement]

reduce_activities()[source]

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 ‘activity’ forms are rewritten to ‘kinase’.

replace_activations(linked_stmts=None)[source]

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 linked (provided as the linked_stmts argument). It removes RegulateActivity Statements from self.statements that can be explained by the linked statements.

Parameters

linked_stmts (Optional[list[indra.mechlinker.LinkedStatement]]) – A list of linked statements, optionally passed from outside. If None is passed, the MechLinker runs self.infer_activations to infer RegulateActivities and obtain a list of LinkedStatements that are then used for removing existing Complexes in self.statements.

replace_complexes(linked_stmts=None)[source]

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_stmts argument). It removes Complex Statements from self.statements that can be explained by the linked statements.

Parameters

linked_stmts (Optional[list[indra.mechlinker.LinkedStatement]]) – A list of linked statements, optionally passed from outside. If None is passed, the MechLinker runs self.infer_complexes to infer Complexes and obtain a list of LinkedStatements that are then used for removing existing Complexes in self.statements.

require_active_forms()[source]

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 be in an active form. This function takes the collected active states of Agents in their corresponding BaseAgents and then rewrites other Statements to apply the active Agent states to them.

Returns

new_stmts – A list of Statements which includes the newly rewritten Statements. This list is also set as the internal Statement list of the MechLinker.

Return type

list[indra.statements.Statement]