Query¶
Query builder for PyBEL.
- exception pybel.struct.query.QueryMissingNetworksError[source]¶
Raised if a query is created from json but doesn’t have a listing of network identifiers.
- exception pybel.struct.query.NodeDegreeIterError[source]¶
Raised when failing to iterate over node degrees.
- class pybel.struct.query.Query(network_ids=None, seeding=None, pipeline=None)[source]¶
Represents a query over a network store.
Build a query.
- append_seeding_induction(nodes)[source]¶
Add a seed induction method.
- Return type
- Returns
seeding container for fluid API
- append_seeding_neighbors(nodes)[source]¶
Add a seed by neighbors.
- Return type
- Returns
seeding container for fluid API
- append_seeding_annotation(annotation, values)[source]¶
Add a seed induction method for single annotation’s values.
- append_seeding_sample(**kwargs)[source]¶
Add seed induction methods.
Kwargs can have
number_edges
ornumber_seed_nodes
.- Return type
- append_pipeline(name, *args, **kwargs)[source]¶
Add an entry to the pipeline. Defers to
pybel_tools.pipeline.Pipeline.append()
.
- run(manager)[source]¶
Run this query and returns the resulting BEL graph.
- Parameters
manager – A cache manager
- Return type
Optional[pybel.BELGraph]
- class pybel.struct.query.Seeding(initlist=None)[source]¶
Represents a container of seeding methods to apply to a network.
- append_induction(nodes)[source]¶
Add a seed induction method.
- Parameters
nodes (
Union
[BaseEntity
,List
[BaseEntity
],List
[Dict
]]) – A node or list of nodes- Return type
- Returns
self for fluid API
- append_neighbors(nodes)[source]¶
Add a seed by neighbors.
- Parameters
nodes (
Union
[BaseEntity
,List
[BaseEntity
],List
[Dict
]]) – A node or list of nodes- Return type
- Returns
self for fluid API
- append_annotation(annotation, values)[source]¶
Add a seed induction method for single annotation’s values.
- append_sample(**kwargs)[source]¶
Add seed induction methods.
Kwargs can have
number_edges
ornumber_seed_nodes
.- Return type
- Returns
self for fluid API
- run(graph)[source]¶
Seed the graph or return none if not possible.
- Return type
Optional[pybel.BELGraph]
- pybel.struct.query.get_subgraph(graph, seed_method=None, seed_data=None, expand_nodes=None, remove_nodes=None)[source]¶
Run a pipeline query on graph with multiple sub-graph filters and expanders.
Order of Operations:
Seeding by given function name and data
Add nodes
Remove nodes
- Parameters
graph (pybel.BELGraph) – A BEL graph
seed_method (
Optional
[str
]) – The name of the get_subgraph_by_* function to useseed_data (
Optional
[Any
]) – The argument to pass to the get_subgraph functionexpand_nodes (
Optional
[List
[BaseEntity
]]) – Add the neighborhoods around all of these nodesremove_nodes (
Optional
[List
[BaseEntity
]]) – Remove these nodes and all of their in/out edges
- Return type
Optional[pybel.BELGraph]