linchemin.cgu.syngraph.SynGraph¶
- class linchemin.cgu.syngraph.SynGraph(initiator: List[dict] | Iron | None = None)[source]¶
Abstract class implementing the homonym data model as a dictionary of sets.
- Attributes:
graph: a dictionary of sets
name: an optional string containing the name of the graph
uid: a string uniquely identifying the SynGraph instance based on the underlying graph
- __init__(initiator: List[dict] | Iron | None = None)[source]¶
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:
an Iron instance
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.
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 SynGraph instance from an Iron object
builder_from_reaction_list(chemical_equations)To build a SynGraph instance from a list of ChemicalEquation objects
get_leaves()To retrieve the list of 'leaf' nodes of a SynGraph instance
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_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
uidTo define the SynGraph unique identifier based on the underlying graph