Query Classes (indra_network_search.query)

This file contains the Query classes mapping incoming rest queries to different algorithms used in the search api.

class indra_network_search.query.BreadthFirstSearchQuery(query, hash_blacklist=None)[source]

Check queries that will use the bfs_search algorithm

alg_options()[source]

Match arguments of bfs_search from query

Return type

Dict[str, Any]

Returns

The argument to provide bfs_search

mesh_options(graph=None)[source]

Get mesh options for bfs_search

Parameters

graph (Optional[DiGraph]) – The graph

Return type

Dict[str, Union[Set, bool, Callable]]

Returns

The mesh option for bfs_search

options

alias of indra_network_search.data_models.BreadthFirstSearchOptions

Show JSON schema
{
   "title": "BreadthFirstSearchOptions",
   "description": "Arguments for indra.explanation.pathfinding.bfs_search",
   "type": "object",
   "properties": {
      "source_node": {
         "title": "Source Node",
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "array",
               "items": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  }
               ]
            }
         ]
      },
      "reverse": {
         "title": "Reverse",
         "default": false,
         "type": "boolean"
      },
      "depth_limit": {
         "title": "Depth Limit",
         "default": 2,
         "type": "integer"
      },
      "path_limit": {
         "title": "Path Limit",
         "type": "integer"
      },
      "max_per_node": {
         "title": "Max Per Node",
         "default": 5,
         "type": "integer"
      },
      "node_filter": {
         "title": "Node Filter",
         "type": "array",
         "items": {
            "type": "string"
         }
      },
      "node_blacklist": {
         "title": "Node Blacklist",
         "type": "array",
         "items": {
            "type": "string"
         },
         "uniqueItems": true
      },
      "terminal_ns": {
         "title": "Terminal Ns",
         "type": "array",
         "items": {
            "type": "string"
         }
      },
      "sign": {
         "title": "Sign",
         "type": "integer"
      },
      "max_memory": {
         "title": "Max Memory",
         "default": 536870912,
         "type": "integer"
      },
      "hashes": {
         "title": "Hashes",
         "type": "array",
         "items": {
            "type": "integer"
         }
      },
      "strict_mesh_id_filtering": {
         "title": "Strict Mesh Id Filtering",
         "default": false,
         "type": "boolean"
      }
   },
   "required": [
      "source_node"
   ]
}

Fields
  • source_node (Union[str, Tuple[str, int]])

  • reverse (Optional[bool])

  • depth_limit (Optional[int])

  • path_limit (Optional[int])

  • max_per_node (Optional[int])

  • node_filter (Optional[List[str]])

  • node_blacklist (Optional[Set[str]])

  • terminal_ns (Optional[List[str]])

  • sign (Optional[int])

  • max_memory (Optional[int])

  • hashes (Optional[List[int]])

  • allow_edge (Optional[Callable[[networkx.classes.digraph.DiGraph, Union[str, Tuple[str, int]], Union[str, Tuple[str, int]]], bool]])

  • edge_filter (Optional[Callable[[networkx.classes.digraph.DiGraph, Union[str, Tuple[str, int]], Union[str, Tuple[str, int]]], bool]])

  • strict_mesh_id_filtering (Optional[bool])

class indra_network_search.query.DijkstraQuery(query, hash_blacklist=None)[source]

Check queries that will use the open_dijkstra_search algorithm

alg_options()[source]

Match arguments of open_dijkstra_search from query

Return type

Dict[str, Any]

Returns

A dict with arguments for open_dijkstra_search

mesh_options(graph=None)[source]

Produces mesh arguments matching open_dijkstra_search from query

Return type

Dict[str, Union[Set, bool, Callable]]

Returns

The mesh options for open_dijkstra_query

options

alias of indra_network_search.data_models.DijkstraOptions

Show JSON schema
{
   "title": "DijkstraOptions",
   "description": "Arguments for open_dijkstra_search",
   "type": "object",
   "properties": {
      "start": {
         "title": "Start",
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "array",
               "items": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  }
               ]
            }
         ]
      },
      "reverse": {
         "title": "Reverse",
         "default": false,
         "type": "boolean"
      },
      "path_limit": {
         "title": "Path Limit",
         "type": "integer"
      },
      "hashes": {
         "title": "Hashes",
         "type": "array",
         "items": {
            "type": "integer"
         }
      },
      "ignore_nodes": {
         "title": "Ignore Nodes",
         "type": "array",
         "items": {
            "type": "string"
         }
      },
      "ignore_edges": {
         "title": "Ignore Edges",
         "type": "array",
         "items": {
            "type": "array",
            "items": [
               {
                  "type": "string"
               },
               {
                  "type": "string"
               }
            ]
         }
      },
      "terminal_ns": {
         "title": "Terminal Ns",
         "type": "array",
         "items": {
            "type": "string"
         }
      },
      "weight": {
         "title": "Weight",
         "type": "string"
      },
      "const_c": {
         "title": "Const C",
         "default": 1,
         "type": "integer"
      },
      "const_tk": {
         "title": "Const Tk",
         "default": 10,
         "type": "integer"
      }
   },
   "required": [
      "start"
   ]
}

Fields
  • start (Union[str, Tuple[str, int]])

  • reverse (Optional[bool])

  • path_limit (Optional[int])

  • hashes (Optional[List[int]])

  • ignore_nodes (Optional[List[str]])

  • ignore_edges (Optional[List[Tuple[str, str]]])

  • terminal_ns (Optional[List[str]])

  • weight (Optional[str])

  • ref_counts_function (Optional[Callable])

  • const_c (Optional[int])

  • const_tk (Optional[int])

class indra_network_search.query.MultiInteractorsQuery(rest_query)[source]

Check queries that will use pathfinding.direct_multi_interactors

options

alias of indra_network_search.data_models.MultiInteractorsOptions

Show JSON schema
{
   "title": "MultiInteractorsOptions",
   "description": "Multi interactors options",
   "type": "object",
   "properties": {
      "nodes": {
         "title": "Nodes",
         "type": "array",
         "items": {
            "type": "string"
         }
      },
      "downstream": {
         "title": "Downstream",
         "type": "boolean"
      },
      "allowed_ns": {
         "title": "Allowed Ns",
         "type": "array",
         "items": {
            "type": "string"
         }
      },
      "stmt_types": {
         "title": "Stmt Types",
         "type": "array",
         "items": {
            "type": "string"
         }
      },
      "source_filter": {
         "title": "Source Filter",
         "type": "array",
         "items": {
            "type": "string"
         }
      },
      "max_results": {
         "title": "Max Results",
         "default": 50,
         "type": "integer"
      },
      "hash_blacklist": {
         "title": "Hash Blacklist",
         "type": "array",
         "items": {
            "type": "integer"
         },
         "uniqueItems": true
      },
      "node_blacklist": {
         "title": "Node Blacklist",
         "type": "array",
         "items": {
            "type": "string"
         }
      },
      "belief_cutoff": {
         "title": "Belief Cutoff",
         "default": 0.0,
         "type": "number"
      },
      "curated_db_only": {
         "title": "Curated Db Only",
         "default": false,
         "type": "boolean"
      }
   },
   "required": [
      "nodes",
      "downstream"
   ]
}

Fields
  • nodes (List[str])

  • downstream (bool)

  • allowed_ns (Optional[List[str]])

  • stmt_types (Optional[List[str]])

  • source_filter (Optional[List[str]])

  • max_results (int)

  • hash_blacklist (Optional[Set[int]])

  • node_blacklist (Optional[List[str]])

  • belief_cutoff (float)

  • curated_db_only (bool)

result_options()[source]

Return a dict with options for the MultiInteractorsResultManager

Return type

Dict[str, Any]

Returns

A dict with the options for the MultiInteractorsResultManager

run_options()[source]

Return options needed for direct_multi_interactors

Return type

Dict[str, Any]

Returns

The options needed for direct_multi_interactors

class indra_network_search.query.OntologyQuery(query)[source]

Check queries that will use shared_parents

alg_options()[source]

Match arguments of shared_parents from query

Return type

Dict[str, Any]

Returns

A dict with arguments for shared_parents

options

alias of indra_network_search.data_models.OntologyOptions

Show JSON schema
{
   "title": "OntologyOptions",
   "description": "Arguments for indra_network_search.pathfinding.shared_parents",
   "type": "object",
   "properties": {
      "source_ns": {
         "title": "Source Ns",
         "type": "string"
      },
      "source_id": {
         "title": "Source Id",
         "type": "string"
      },
      "target_ns": {
         "title": "Target Ns",
         "type": "string"
      },
      "target_id": {
         "title": "Target Id",
         "type": "string"
      },
      "max_paths": {
         "title": "Max Paths",
         "default": 50,
         "type": "integer"
      },
      "immediate_only": {
         "title": "Immediate Only",
         "default": false,
         "type": "boolean"
      },
      "is_a_part_of": {
         "title": "Is A Part Of",
         "type": "array",
         "items": {
            "type": "string"
         },
         "uniqueItems": true
      }
   },
   "required": [
      "source_ns",
      "source_id",
      "target_ns",
      "target_id"
   ]
}

Fields
  • source_ns (str)

  • source_id (str)

  • target_ns (str)

  • target_id (str)

  • max_paths (int)

  • immediate_only (Optional[bool])

  • is_a_part_of (Optional[Set[str]])

result_options()[source]

Provide args to OntologyResultManager in result_handler

Return type

Dict

Returns

The arguments for the Ontology Result manger

run_options(graph=None)[source]

Check query options and return them for shared_parents

Parameters

graph (Optional[DiGraph]) – The graph used in the search. Must contains node attributes ‘ns’ and ‘id’ for each node.

Return type

Dict[str, Any]

Returns

The options for shared_parents

class indra_network_search.query.PathQuery(query, hash_blacklist)[source]

Parent Class for ShortestSimplePaths, Dijkstra and BreadthFirstSearch

alg_options()[source]

Returns the options for the algorithm used, excl mesh options

Return type

Dict[str, Any]

mesh_options(graph=None)[source]

Return algorithm specific mesh options

Return type

Dict[str, Any]

result_options()[source]

Provide args to corresponding result class in result_handler

Return type

Dict

Returns

Options for the PathResult class

run_options(graph=None)[source]

Combines all options to one dict that can be sent to algorithm

Return type

Dict[str, Any]

class indra_network_search.query.Query(query)[source]

Parent class to all Query classes

The Query classes are helpers that make sure the methods of the IndraNetworkSearchAPI receive the data needed from a NetworkSearchQuery or other Rest query.

alg_options()[source]

Returns the options for the algorithm used

Return type

Dict[str, Any]

api_options()[source]

These options are used when IndraNetworkSearchAPI handles the query

The options here impact decisions on which extra search algorithms to include and which graph to pick

Return type

Dict[str, Any]

Returns

A dict of ApiOptions

result_options()[source]

Provide args to corresponding result class in result_handler

Return type

Dict

run_options(graph=None)[source]

Combines all options to one dict that can be sent to algorithm

Return type

Dict[str, Any]

class indra_network_search.query.SharedRegulatorsQuery(query, hash_blacklist=None)[source]

Check queries that will use shared_interactors(regulators=True)

class indra_network_search.query.SharedTargetsQuery(query, hash_blacklist=None)[source]

Check queries that will use shared_interactors(regulators=False)

class indra_network_search.query.ShortestSimplePathsQuery(query, hash_blacklist=None)[source]

Check queries that will use the shortest_simple_paths algorithm

alg_options()[source]

Match arguments of shortest_simple_paths from query

Return type

Dict[str, Any]

Returns

A dict with arguments for shortest_simple_paths

mesh_options(graph=None)[source]

Match input to shortest_simple_paths

Return type

Dict[str, Union[Set, int, bool, Callable]]

Returns

The mesh options for shortest_simple_paths

options

alias of indra_network_search.data_models.ShortestSimplePathOptions

Show JSON schema
{
   "title": "ShortestSimplePathOptions",
   "description": "Arguments for indra.explanation.pathfinding.shortest_simple_paths",
   "type": "object",
   "properties": {
      "source": {
         "title": "Source",
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "array",
               "items": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  }
               ]
            }
         ]
      },
      "target": {
         "title": "Target",
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "array",
               "items": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "integer"
                  }
               ]
            }
         ]
      },
      "weight": {
         "title": "Weight",
         "type": "string"
      },
      "ignore_nodes": {
         "title": "Ignore Nodes",
         "type": "array",
         "items": {
            "type": "string"
         },
         "uniqueItems": true
      },
      "ignore_edges": {
         "title": "Ignore Edges",
         "type": "array",
         "items": {
            "type": "array",
            "items": [
               {
                  "type": "string"
               },
               {
                  "type": "string"
               }
            ]
         },
         "uniqueItems": true
      },
      "hashes": {
         "title": "Hashes",
         "type": "array",
         "items": {
            "type": "integer"
         }
      },
      "strict_mesh_id_filtering": {
         "title": "Strict Mesh Id Filtering",
         "default": false,
         "type": "boolean"
      },
      "const_c": {
         "title": "Const C",
         "default": 1,
         "type": "integer"
      },
      "const_tk": {
         "title": "Const Tk",
         "default": 10,
         "type": "integer"
      }
   },
   "required": [
      "source",
      "target"
   ]
}

Fields
  • source (Union[str, Tuple[str, int]])

  • target (Union[str, Tuple[str, int]])

  • weight (Optional[str])

  • ignore_nodes (Optional[Set[str]])

  • ignore_edges (Optional[Set[Tuple[str, str]]])

  • hashes (Optional[List[int]])

  • ref_counts_function (Optional[Callable])

  • strict_mesh_id_filtering (Optional[bool])

  • const_c (Optional[int])

  • const_tk (Optional[int])

class indra_network_search.query.SubgraphQuery(query)[source]

Check queries that gets the subgraph

alg_options(graph)[source]

Match arguments of get_subgraph_edges

Parameters

graph (DiGraph) – The graph the search will be performed with

Return type

Dict[str, List[Node]]

Returns

A dict with the arguments for get_subgraph_edges

options

alias of indra_network_search.data_models.SubgraphOptions

Show JSON schema
{
   "title": "SubgraphOptions",
   "description": "Argument for indra_network_search.pathfinding.get_subgraph_edges",
   "type": "object",
   "properties": {
      "nodes": {
         "title": "Nodes",
         "type": "array",
         "items": {
            "$ref": "#/definitions/Node"
         }
      }
   },
   "required": [
      "nodes"
   ],
   "definitions": {
      "Node": {
         "title": "Node",
         "description": "Data for a node",
         "type": "object",
         "properties": {
            "name": {
               "title": "Name",
               "minLength": 1,
               "type": "string"
            },
            "namespace": {
               "title": "Namespace",
               "minLength": 1,
               "type": "string"
            },
            "identifier": {
               "title": "Identifier",
               "minLength": 1,
               "type": "string"
            },
            "lookup": {
               "title": "Lookup",
               "minLength": 1,
               "type": "string"
            },
            "sign": {
               "title": "Sign",
               "minimum": 0,
               "maximum": 1,
               "type": "integer"
            }
         },
         "required": [
            "namespace",
            "identifier"
         ]
      }
   }
}

Fields
  • nodes (List[indra_network_search.data_models.Node])

result_options()[source]

Return options needed for SubgraphResultManager

Return type

Dict[str, Any]

Returns

A dict with options for the SubgraphResultManager

run_options(graph)[source]

Return options needed for get_subgraph_edges

Parameters

graph (DiGraph) – The graph the search will be performed with

Return type

Dict[str, Any]

Returns

A dict with the arguments for get_subgraph_edges

class indra_network_search.query.UIQuery(query, hash_blacklist=None)[source]

Parent Class for all possible queries that come from the web UI

alg_options()[source]

Returns the options for the algorithm used

Return type

Dict[str, Any]

result_options()[source]

Provide args to corresponding result class in result_handler

Return type

Dict

run_options(graph=None)[source]

Combines all options to one dict that can be sent to algorithm

Return type

Dict[str, Any]