linchemin.cgu.syngraph_operations.remove_reaction_from_syngraph

linchemin.cgu.syngraph_operations.remove_reaction_from_syngraph(syngraph: BipartiteSynGraph | MonopartiteMolSynGraph | MonopartiteReacSynGraph, reaction_to_remove: str, remove_dandling_nodes: bool = True) BipartiteSynGraph | MonopartiteMolSynGraph | MonopartiteReacSynGraph[source]

To remove a reaction (and optionally the possible dangling nodes) from a SynGraph object based on the reaction smiles

Parameters:

syngraph: Union[MonopartiteReacSynGraph, BipartiteSynGraph, MonopartiteMolSynGraph]

The SynGraph object from which the nodes should be removed

reaction_to_remove: str

The smiles of the reaction to be removed

remove_dandling_nodes: bool

Wether the possible dandling nodes should be removed

Returns:

new_graph: Union[MonopartiteReacSynGraph, BipartiteSynGraph, MonopartiteMolSynGraph]

A new SynGraph object from which the selected node and all its “parent” nodes are removed

Raises:

TypeError: if the input object is not a SynGraph

SmilesTypeError: if the provided smiles is not a valid reaction smiles

KeyError: if the reaction to be removed is not present in the input SynGraph

Example

>>> new_graph = remove_reaction_from_syngraph(syngraph, 'CCN.O>>CCO')