linchemin.cgu.syngraph.BipartiteSynGraph

class linchemin.cgu.syngraph.BipartiteSynGraph(initiator: List[dict] | Iron | None = None)[source]

SynGraph subclass representing a Bipartite (Molecule and ChemicalEquation nodes) SynGraph

__init__(initiator: List[dict] | Iron | None = None)

To instantiate a new SynGraph instance

Parameters:

initiator: initiator: Union[List[dict], Iron, None]

The initiator of the new SynGraph instance (default None -> an empty graph is initialized)) It can be:

  1. an Iron instance

  2. a list of dictionaries of reaction strings in the form

[{‘query_id’: n, ‘output_string’: reaction}]

Methods

__init__([initiator])

To instantiate a new SynGraph instance

add_node(nodes_tup)

To add a 'parent' node and its 'children' nodes to a SynGraph instance.

add_nodes_sequence(reactant, product, ...)

To add Molecule instances of reactants and products of a ChemicalEquation as nodes.

build_chemical_equations(string_list[, ...])

To build a list of ChemicalEquation objects from a list of smiles

builder_from_iron(iron_graph)

To build a BipartiteSynGraph instance from an Iron instance

builder_from_reaction_list(chemical_equations)

To build a BipartiteSynGraph instance from a list of ChemicalEquation objects

find_dangling_sequence(reactants, leaves, ...)

To identify the nodes that are part of a disconnected sequence of nodes.

get_leaves()

To get the list of leaves of a BipartiteSynGraph instance.

get_reaction_roots()

To get the list of ChemicalEquation nodes producing the molecule roots

get_roots()

To retrieve the list of 'root' nodes of a SynGraph instance

get_unique_nodes()

To get the set of unique nodes included in a SynGraph instance

remove_isolated_ces()

To remove ChemicalEquation nodes and their reactants/products if they form isolated sequences.

remove_node(node_to_remove_id)

To remove a node by its uid from a SynGraph instance

set_name(name)

To set the name attribute of a SynGraph instance

Attributes

uid

To define the SynGraph unique identifier based on the underlying graph