Visualization#

Visualization utilities for molecule graphs, reactions, ITS graphs, diagnostic graph adapters, CRNs, embeddings, and output export helpers.

Modern molecule/reaction/ITS renderers#

synkit.Vis.molecule_drawer.draw_molecule_graph(graph: Graph, *, ax: Axes | None = None, title: str | None = None, label_mode: str = 'hetero', show_atom_map: bool = False, show_bond_order: bool = False, aromatic_style: str = 'circle', include_rdkit_panel: bool = False, use_h_count: bool = False, node_size: int | None = None, bond_width: float | None = None, figsize: Tuple[float, float] = (6.0, 5.0), highlight_nodes: Set[Any] | None = None, highlight_edges: Set[Tuple[Any, Any]] | None = None, highlight_color: str = '#f97316', custom_node_colors: Mapping[Any, str] | None = None) Axes | tuple[Figure, tuple[Axes, Axes]][source]#
class synkit.Vis.reaction_drawer.ReactionHighlights(changed_atoms: frozenset[int], formed_bonds: frozenset[frozenset[int]], broken_bonds: frozenset[frozenset[int]], order_changed_bonds: frozenset[frozenset[int]])[source]#

Bases: object

broken_bonds: frozenset[frozenset[int]]#
changed_atoms: frozenset[int]#
formed_bonds: frozenset[frozenset[int]]#
order_changed_bonds: frozenset[frozenset[int]]#
synkit.Vis.reaction_drawer.draw_reaction_graph(rsmi: str, *, title: str | None = None, show_atom_map: bool = True, highlight_reaction_center: bool = True, label_mode: str = 'hetero', aromatic_style: str = 'circle', figsize_per_mol: Tuple[float, float] = (3.2, 2.8), sanitize: bool = True) tuple[Figure, list[Axes]][source]#
synkit.Vis.reaction_drawer.draw_reaction_graphs(reactant: Graph, product: Graph, *, title: str | None = None, show_atom_map: bool = True, highlight_reaction_center: bool = True, label_mode: str = 'hetero', aromatic_style: str = 'circle', figsize_per_mol: Tuple[float, float] = (3.2, 2.8)) tuple[Figure, list[Axes]][source]#
synkit.Vis.reaction_drawer.find_reaction_highlights(reactant: Graph, product: Graph) ReactionHighlights[source]#
synkit.Vis.its_drawer.draw_its_from_rsmi(rsmi: str, *, format: str = 'tuple', core: bool = False, title: str | None = None, mode: str = 'sigma_pi', show_atom_map: bool = True, label_mode: str = 'hetero', aromatic_style: str = 'circle', include_delta_panel: bool = True, projection: bool = False, show_edge_labels: bool = False, edge_label_mode: str = 'kekule', show_electron_labels: bool = False, electron_label_mode: str = 'charge') tuple[Figure, list[Axes]][source]#
synkit.Vis.its_drawer.draw_its_graph(its: Graph, *, title: str | None = None, mode: str = 'sigma_pi', show_atom_map: bool = True, label_mode: str = 'hetero', aromatic_style: str = 'circle', include_delta_panel: bool = True, projection: bool = False, show_edge_labels: bool = False, edge_label_mode: str = 'kekule', show_electron_labels: bool = False, electron_label_mode: str = 'charge') tuple[Figure, list[Axes]][source]#
synkit.Vis.its_drawer.draw_its_only(its: Graph, *, ax: Axes | None = None, title: str | None = None, show_atom_map: bool = True, label_mode: str = 'hetero', aromatic_style: str = 'circle', show_edge_labels: bool = False, edge_label_mode: str = 'kekule', show_electron_labels: bool = False, electron_label_mode: str = 'charge') Axes[source]#
synkit.Vis.mtg_drawer.draw_mtg_graph(mtg: Any, *, ax: Axes | None = None, title: str | None = None, mode: str = 'timeline', layout: str = 'kamada_kawai', show_atom_map: bool = True, show_edge_labels: bool = True, show_node_badges: bool = False, hydrogen_mode: str = 'changed', changed_only: bool = False, compress: bool = True, show_step_axis: bool = False, dimension: str = '2d', seed: int = 7) tuple[Figure, Axes][source]#
synkit.Vis.mtg_drawer.draw_mtg_steps(mtg: Any, *, steps: Iterable[int] | None = None, include_composed: bool = False, title: str | None = None, max_columns: int = 3, show_atom_map: bool = True, label_mode: str = 'hetero', edge_label_mode: str = 'kekule', show_edge_labels: bool = False, show_electron_labels: bool = False, electron_label_mode: str = 'charge') tuple[Figure, list[Axes]][source]#

Electron-pushing diagrams#

class synkit.Vis.epd.MechanismVisualizer(atom_map_key: str = 'atom_map')[source]#

Bases: object

atom_color(element: str) str[source]#
draw_trajectory_arrows(ax: Axes, graph: Graph, pos, transitions: Sequence[Any], step_labels: bool = True) None[source]#
visualize_trajectory(reactant_graph: Graph, transitions: Sequence[Any], its_graph: Graph, all_graphs: Sequence[Graph] | None = None, product_graph: Graph | None = None, title: str = 'Trajectory electron pushing', figsize: Tuple[float, float] | None = None, show_its: bool = True, reference_layout: str = 'its', show_atom_map: bool = True, step_labels: bool = False, gap: float = 1.7, show_legend: bool = True, fade_non_rc: bool = False, use_rc_glow: bool = True, show_all_its_labels: bool = False, show_its_node_changes: bool = False, show_its_bond_labels: bool = False, show_product: bool = True, show_step_table: bool = True, max_step_table_rows: int = 8, molecule_edge_label_mode: str = 'none', show_elementary_steps: bool = False, arrows_per_step: int = 2)[source]#
class synkit.Vis.epd.Transition(kind: str, src: Tuple[int, ...], dst: Tuple[int, ...], data: Dict[str, Any])[source]#

Bases: object

data: Dict[str, Any]#
dst: Tuple[int, ...]#
kind: str#
src: Tuple[int, ...]#
synkit.Vis.epd.transition_from_epd_step(step: Any) Transition[source]#
synkit.Vis.epd.transitions_from_epd(epd: Iterable[Any]) List[Transition][source]#
class synkit.Vis.epd.visualizer.MechanismVisualizer(atom_map_key: str = 'atom_map')[source]#

Bases: object

atom_color(element: str) str[source]#
draw_trajectory_arrows(ax: Axes, graph: Graph, pos, transitions: Sequence[Any], step_labels: bool = True) None[source]#
visualize_trajectory(reactant_graph: Graph, transitions: Sequence[Any], its_graph: Graph, all_graphs: Sequence[Graph] | None = None, product_graph: Graph | None = None, title: str = 'Trajectory electron pushing', figsize: Tuple[float, float] | None = None, show_its: bool = True, reference_layout: str = 'its', show_atom_map: bool = True, step_labels: bool = False, gap: float = 1.7, show_legend: bool = True, fade_non_rc: bool = False, use_rc_glow: bool = True, show_all_its_labels: bool = False, show_its_node_changes: bool = False, show_its_bond_labels: bool = False, show_product: bool = True, show_step_table: bool = True, max_step_table_rows: int = 8, molecule_edge_label_mode: str = 'none', show_elementary_steps: bool = False, arrows_per_step: int = 2)[source]#

Diagnostic adapter layer#

class synkit.Vis.visual_model.VisualEdge(source: Hashable, target: Hashable, label: str = '', state: str = 'unchanged', color: str = '#2f3437', width: float = 2.0, raw: Mapping[str, ~typing.Any]=<factory>)[source]#

Bases: object

color: str = '#2f3437'#
label: str = ''#
raw: Mapping[str, Any]#
source: Hashable#
state: str = 'unchanged'#
target: Hashable#
width: float = 2.0#
class synkit.Vis.visual_model.VisualGraph(kind: ~typing.Literal['molecule', 'legacy_its', 'tuple_its', 'compact_mtg', 'mechanism_dag', 'unknown'], nodes: tuple[~synkit.Vis.visual_model.VisualNode, ...], edges: tuple[~synkit.Vis.visual_model.VisualEdge, ...], title: str = '', metadata: ~typing.Mapping[str, ~typing.Any] = <factory>)[source]#

Bases: object

edges: tuple[VisualEdge, ...]#
kind: Literal['molecule', 'legacy_its', 'tuple_its', 'compact_mtg', 'mechanism_dag', 'unknown']#
metadata: Mapping[str, Any]#
nodes: tuple[VisualNode, ...]#
title: str = ''#
class synkit.Vis.visual_model.VisualNode(node_id: Hashable, label: str, element: str | None = None, atom_map: int | None = None, badges: tuple[str, ...]=(), changed: bool = False, raw: Mapping[str, ~typing.Any]=<factory>)[source]#

Bases: object

atom_map: int | None = None#
badges: tuple[str, ...] = ()#
changed: bool = False#
element: str | None = None#
label: str#
node_id: Hashable#
raw: Mapping[str, Any]#
synkit.Vis.visual_model.detect_visual_kind(graph: Graph) Literal['molecule', 'legacy_its', 'tuple_its', 'compact_mtg', 'mechanism_dag', 'unknown'][source]#
synkit.Vis.visual_model.iter_changed_edges(visual: VisualGraph) Iterable[VisualEdge][source]#
synkit.Vis.visual_model.iter_changed_nodes(visual: VisualGraph) Iterable[VisualNode][source]#
synkit.Vis.visual_model.summarize_visual_graph(visual: VisualGraph) Dict[str, Any][source]#
synkit.Vis.visual_model.to_visual_graph(graph: Graph, *, kind: Literal['molecule', 'legacy_its', 'tuple_its', 'compact_mtg', 'mechanism_dag', 'unknown'] | None = None, mode: Literal['compact', 'electron', 'sigma_pi', 'timeline'] = 'compact', show_atom_map: bool = True, title: str = '') VisualGraph[source]#
synkit.Vis.visual_drawer.draw_graph(graph: Graph | VisualGraph, *, ax: Axes | None = None, mode: str = 'compact', title: str | None = None, show_atom_map: bool = True, layout: str = 'spring', pos: Mapping[Any, tuple[float, float]] | None = None, seed: int = 7, node_size: int = 980, font_size: int = 9, edge_label_font_size: int = 8, show_edge_labels: bool = True, show_node_badges: bool = True) tuple[Figure, Axes][source]#

Reaction, graph, and chemical-space utilities#

class synkit.Vis.reaction.rxn.RXNVis(width: int = 800, height: int = 450, dpi: int = 96, background_colour: Tuple[float, float, float, float] | None = None, highlight_by_reactant: bool = True, bond_line_width: float = 2.0, atom_label_font_size: int = 12, show_atom_map: bool = False, highlight_reaction_center: bool = False, rc_atom_color: Tuple[float, float, float] = (1.0, 0.5, 0.0), rc_broken_color: Tuple[float, float, float] = (0.9, 0.2, 0.2), rc_formed_color: Tuple[float, float, float] = (0.0, 0.75, 0.0))[source]#

Bases: object

render(smiles: str, return_bytes: bool = False) Image | bytes[source]#
save_pdf(smiles: str, path: str, resolution: float = 300.0) None[source]#
save_png(smiles: str, path: str) None[source]#
class synkit.Vis.reaction.rule.RuleVis(backend: str = 'nx')[source]#

Bases: object

help() None[source]#
mod_vis(gml: str, path: str = './') None[source]#
nx_vis(input: str | Tuple[Graph, Graph, Graph], sanitize: bool = False, figsize: Tuple[int, int] = (18, 5), orientation: str = 'horizontal', show_titles: bool = True, show_atom_map: bool = False, titles: Tuple[str, str, str] = ('Reactant', 'Imaginary Transition State', 'Product'), add_gridbox: bool = False, rule: bool = False) Figure[source]#
post() None[source]#
vis(input: str | Tuple[Graph, Graph, Graph], **kwargs)[source]#
class synkit.Vis.graph_visualizer.GraphVisualizer(node_attributes: Dict[str, str] | None = None, edge_attributes: Dict[str, str] | None = None)[source]#

Bases: object

property edge_attributes: Dict[str, str]#
help() None[source]#
property node_attributes: Dict[str, str]#
plot_as_mol(g: Graph, ax: Axes, use_mol_coords: bool = True, node_color: str = '#FFFFFF', node_size: int = 500, edge_color: str = '#000000', edge_width: float = 2.0, label_color: str = '#000000', font_size: int = 12, show_atom_map: bool = False, bond_char: Dict[int | None, str] | None = None, symbol_key: str = 'element', bond_key: str = 'order', aam_key: str = 'atom_map') None[source]#
plot_its(its: Graph, ax: Axes, use_mol_coords: bool = True, title: str | None = None, node_color: str = '#FFFFFF', node_size: int = 500, edge_color: str = '#000000', edge_weight: float = 2.0, show_atom_map: bool = False, use_edge_color: bool = False, symbol_key: str = 'element', bond_key: str = 'order', aam_key: str = 'atom_map', standard_order_key: str = 'standard_order', font_size: int = 12, og: bool = False, rule: bool = False, title_font_size: str = 20, title_font_weight: str = 'bold', title_font_style: str = 'italic') None[source]#
save_molecule(g: Graph, path: str, **kwargs) None[source]#
visualize_its(its: Graph, **kwargs) Figure[source]#
visualize_its_grid(its_list: list[Graph], subplot_shape: tuple[int, int] | None = None, use_edge_color: bool = True, og: bool = False, figsize: tuple[float, float] = (12, 6), **kwargs) tuple[Figure, list[list[Axes]]][source]#
visualize_molecule(g: Graph, **kwargs) Figure[source]#
synkit.Vis.space.chemical.adjust_legend_handles(handles, colors)[source]#
synkit.Vis.space.chemical.scatter_plot(data_train, data_test, size_train=10, size_test=10, title=None, ax=None, xlabel='Coordinate 1', ylabel='Coordinate 2')[source]#
class synkit.Vis.space.embedding.Embedding(cache_dir: str = './cachedir', verbose: int = 0, custom_tsne_params: Dict | None = None)[source]#

Bases: object

property cache: Any#
clear_cache() None[source]#
compute_tsne(X: ndarray, cache: bool = True) ndarray[source]#
reset_tsne_params() None[source]#
set_tsne_params(**params) None[source]#

CRN visualizer#

class synkit.Vis.crn.visualizer.CRNVisualizer(hg: Any)[source]#

Bases: object

bip(*, backend: str = 'nx', species_prefix: str = 'S:', reaction_prefix: str = 'R:', include_stoich: bool = True, title: str | None = None, save: str | None = None, show: bool = True, figsize: Tuple[float, float] = (10, 6), species_color: str = '#4C72B0', reaction_color: str = '#DD8452', edge_label_fontsize: int = 9, node_label_fontsize: int = 10, integer_ids: bool = True, species_fill: str = '#4C72B0', reaction_fill: str = '#DD8452', species_fontcolor: str = 'white', reaction_fontcolor: str = 'white', gv_graph_attr: Dict[str, str] | None = None, gv_node_attr: Dict[str, str] | None = None, gv_edge_attr: Dict[str, str] | None = None)[source]#
crn(*, backend: str = 'nx', species_prefix: str = 'S:', reaction_prefix: str = 'R:', include_stoich: bool = True, title: str | None = None, save: str | None = None, show: bool = True, figsize: Tuple[float, float] = (8, 6), species_color: str = '#4C72B0', reaction_color: str = '#DD8452', edge_label_fontsize: int = 9, node_label_fontsize: int = 10, integer_ids: bool = True, species_fill: str = '#4C72B0', reaction_fill: str = '#DD8452', species_fontcolor: str = 'white', reaction_fontcolor: str = 'white', gv_engine: str = 'sfdp', gv_graph_attr: Dict[str, str] | None = None, gv_node_attr: Dict[str, str] | None = None, gv_edge_attr: Dict[str, str] | None = None)[source]#
species(*, backend: str = 'nx', title: str | None = None, save: str | None = None, show: bool = True, include_min_stoich: bool = True, include_rules: bool = True, figsize: Tuple[float, float] = (7.5, 6), node_color: str = '#4C72B0', node_label_fontsize: int = 10, edge_label_fontsize: int = 9, layout: str = 'spring', gv_engine: str = 'sfdp', gv_node_fill: str = '#4C72B0', gv_node_fontcolor: str = 'white', gv_graph_attr: Dict[str, str] | None = None, gv_node_attr: Dict[str, str] | None = None, gv_edge_attr: Dict[str, str] | None = None)[source]#
stoich(*, figsize: Tuple[float, float] = (8, 6), cmap: str = 'RdBu_r', annotate: bool = True, fmt: str = 'd', title: str | None = None, show: bool = True, save: str | None = None, col_label_mode: str = 'rule_id')[source]#
synkit.Vis.crn.visualizer.plot_bip(hg: Any, **kwargs)[source]#
synkit.Vis.crn.visualizer.plot_crn(hg: Any, **kwargs)[source]#
synkit.Vis.crn.visualizer.plot_stoich(hg: Any, **kwargs)[source]#