Collapse¶
Functions for collapsing nodes.
-
pybel.struct.mutation.collapse.
collapse_pair
(graph, survivor, victim)[source]¶ Rewire all edges from the synonymous node to the survivor node, then deletes the synonymous node.
Does not keep edges between the two nodes.
- Parameters
graph (pybel.BELGraph) – A BEL graph
survivor (
BaseEntity
) – The BEL node to collapse all edges on the synonym tovictim (
BaseEntity
) – The BEL node to collapse into the surviving node
- Return type
-
pybel.struct.mutation.collapse.
collapse_nodes
(graph, survivor_mapping)[source]¶ Collapse all nodes in values to the key nodes, in place.
- Parameters
graph (pybel.BELGraph) – A BEL graph
survivor_mapping (
Mapping
[BaseEntity
,Set
[BaseEntity
]]) – A dictionary with survivors as their keys, and iterables of the corresponding victims as values.
- Return type
-
pybel.struct.mutation.collapse.
collapse_all_variants
(graph)[source]¶ Collapse all genes’, RNAs’, miRNAs’, and proteins’ variants to their parents.
- Parameters
graph (pybel.BELGraph) – A BEL Graph
- Return type
-
pybel.struct.mutation.collapse.
surviors_are_inconsistent
(survivor_mapping)[source]¶ Check that there’s no transitive shit going on.
- Return type
Set
[BaseEntity
]
-
pybel.struct.mutation.collapse.
collapse_to_genes
(graph)[source]¶ Collapse all protein, RNA, and miRNA nodes to their corresponding gene nodes.
- Parameters
graph (pybel.BELGraph) – A BEL graph