Pathfinding (indra_network_search.pathfinding.pathfinding)

Pathfinding algorithms local to this repository

indra_network_search.pathfinding.pathfinding.direct_multi_interactors(graph, nodes, downstream, allowed_ns=None, stmt_types=None, source_filter=None, max_results=50, hash_blacklist=None, node_blacklist=None, belief_cutoff=0.0, curated_db_only=False)[source]

Find up- or downstream common nodes from a list of nodes

Parameters:
  • graph (DiGraph) – The graph to look in

  • nodes (List[Union[str, Tuple[str, int]]]) – The starting nodes

  • downstream (bool) – If True, look for shared targets, otherwise look for shared regulators

  • allowed_ns (Optional[List[str]]) – A list of allowed node namespaces

  • stmt_types (Optional[List[str]]) – A list of allowed statemtent types

  • source_filter (Optional[List[str]]) – A list of valid sources

  • max_results (int) – The maximum number of results to return

  • hash_blacklist (Optional[Set[int]]) – A list of hashes to blacklist

  • node_blacklist (Optional[List[str]]) – A list of node names to blacklist

  • belief_cutoff (float) – If set, an edge will not be allowed if all its supporting statements have belief scores below this value

  • curated_db_only (bool) – If True, only allow edge that have support from curated databases

Return type:

Iterator[Union[str, Tuple[str, int]]]

Returns:

An Iterator of the resulting nodes

indra_network_search.pathfinding.pathfinding.get_subgraph_edges(graph, nodes)[source]

Get the subgraph connecting the provided nodes

Parameters:
  • graph (DiGraph) – Graph to look for in and out edges in

  • nodes (List[Dict[str, str]]) – List of dicts of Node instances to look for neighbors in

Return type:

Iterator[Tuple[str, str]]

Returns:

A dict keyed by each of the input node names that were present in the graph. For each node, two lists are provided for in-edges and out-edges respectively

indra_network_search.pathfinding.pathfinding.shared_interactors(graph, source, target, allowed_ns=None, stmt_types=None, source_filter=None, max_results=50, regulators=False, sign=None, hash_blacklist=None, node_blacklist=None, belief_cutoff=0.0, curated_db_only=False)[source]

Get shared regulators or targets and filter them based on sign

Closely resembles get_st and get_sr from depmap_analysis.scripts.depmap_script_expl_funcs

Parameters:
  • graph (DiGraph) – The graph to perform the search in

  • source (Union[str, Tuple[str, int]]) – Node to look for common up- or downstream neighbors from with target

  • target (Union[str, Tuple[str, int]]) – Node to look for common up- or downstream neighbors from with source

  • allowed_ns (Optional[List[str]]) – If provided, filter common nodes to these namespaces

  • stmt_types (Optional[List[str]]) – If provided, filter the statements in the supporting edges to these statement types

  • source_filter (Optional[List[str]]) – If provided, filter the statements in the supporting edges to those with these sources

  • max_results (int) – The maximum number of results to return

  • regulators (bool) – If True, do shared regulator search (upstream), otherwise do shared target search (downstream). Default False.

  • sign (Optional[int]) –

    If provided, match edges to sign:
    • positive: edges must have same sign

    • negative: edges must have opposite sign

  • hash_blacklist (Optional[Set[str]]) – A list of hashes to exclude from the edges

  • node_blacklist (Optional[List[str]]) – A list of node names to exclude

  • belief_cutoff (float) – Exclude statements that are below the cutoff. Default: 0.0 (no cutoff)

  • curated_db_only (bool) – If True, exclude statements in edge support that only have readers in their sources. Default: False.

Return type:

Iterator[Tuple[List[Union[str, Tuple[str, int]]], List[Union[str, Tuple[str, int]]]]]

Returns:

An iterator of regulators or targets to source and target as edges

indra_network_search.pathfinding.pathfinding.shared_parents(source_ns, source_id, target_ns, target_id, immediate_only=False, is_a_part_of=None, max_paths=50)[source]

Get shared ontological parents of source and target

Parameters:
  • source_ns (str) – Namespace of source

  • source_id (str) – Identifier of source

  • target_ns (str) – Namespace of target

  • target_id (str) – Identifier of target

  • immediate_only (bool) – Determines if all or just the immediate parents should be returned. Default: False, i.e. all parents.

  • is_a_part_of (Optional[Set[str]]) – If provided, the parents must be in this set of ids. The set is assumed to be valid ontology labels (see ontology.label()).

  • max_paths (int) – Maximum number of results to return. Default: 50.

Return type:

Iterator[Tuple[str, Any, Any, str]]

Returns:

An iterator of parents to source and target, each parent being a tuple of (name, namespace, id, lookup URL)