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 innodes (
List
[Union
[str
,Tuple
[str
,int
]]]) – The starting nodesdownstream (
bool
) – If True, look for shared targets, otherwise look for shared regulatorsallowed_ns (
Optional
[List
[str
]]) – A list of allowed node namespacesstmt_types (
Optional
[List
[str
]]) – A list of allowed statemtent typessource_filter (
Optional
[List
[str
]]) – A list of valid sourcesmax_results (
int
) – The maximum number of results to returnhash_blacklist (
Optional
[Set
[int
]]) – A list of hashes to blacklistnode_blacklist (
Optional
[List
[str
]]) – A list of node names to blacklistbelief_cutoff (
float
) – If set, an edge will not be allowed if all its supporting statements have belief scores below this valuecurated_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 innodes (
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
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 insource (
Union
[str
,Tuple
[str
,int
]]) – Node to look for common up- or downstream neighbors from with targettarget (
Union
[str
,Tuple
[str
,int
]]) – Node to look for common up- or downstream neighbors from with sourceallowed_ns (
Optional
[List
[str
]]) – If provided, filter common nodes to these namespacesstmt_types (
Optional
[List
[str
]]) – If provided, filter the statements in the supporting edges to these statement typessource_filter (
Optional
[List
[str
]]) – If provided, filter the statements in the supporting edges to those with these sourcesmax_results (
int
) – The maximum number of results to returnregulators (
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 edgesnode_blacklist (
Optional
[List
[str
]]) – A list of node names to excludebelief_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
Get shared ontological parents of source and target
- Parameters:
source_ns (
str
) – Namespace of sourcesource_id (
str
) – Identifier of sourcetarget_ns (
str
) – Namespace of targettarget_id (
str
) – Identifier of targetimmediate_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)