dot

This module is a minimal implementation of a writer for the dot language. It does contain the minimum functionality to allow the writing of the reaction networks in dot format.

rnets.dot.Opts

Type synonym to define options.

Type:

type

rnets.dot.OptsGlob

Type synonym defining global options.

Type:

type

rnets.dot.IDENT

Identation level when writing the dot file.

Type:

int

rnets.dot.SEP_S_LV

Single level separation, e.g: between two node definition.

Type:

str

rnets.dot.SEP_D_LV

Double level separation, e.g: between node and edge definition.

Type:

str

class rnets.dot.Edge(origin: str, target: str, direction: str = '->', options: Opts | None = None)[source]

Structure representing a dot edge between two nodes.

origin

Starting node name.

Type:

str

target

Target node name.

Type:

str

direction

Symbol to use to connect both nodes. See dot manual for possible values.

Type:

str

options

Options of the edge.

Type:

Opts

class rnets.dot.Graph(kind: str, nodes: Sequence[Node], edges: Sequence[Edge], options: OptsGlob | None)[source]

Structure representing a dot graph.

kind

Graph type.

Type:

str

nodes

Nodes in the graph.

Type:

sequence of Node

edges

Edges in the graph.

Type:

sequence of Edge

options

Dictionary containing multiple global options.

Type:

dict of str as keys and Opts as values

class rnets.dot.Node(name: str, options: Opts | None = None)[source]

Structure representing a dot graph node.

name

Name of the node.

Type:

str

options

dot options for the node.

Type:

Opts

class rnets.dot.OptKind(value, names=_not_given, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enum representing the possible kind of global Opts values

rnets.dot.edge_to_str(e: Edge) str[source]

Converts a Edge into a string.

Parameters:

n (Edge) -- Edge that will be converted.

Returns:

Edge in dot format.

Return type:

str

rnets.dot.graph_to_str(g: Graph) str[source]

Converts a Graph into a dot string.

Parameters:

g (Graph) -- Graph that will be converted.

Returns:

Graph in dot format.

Return type:

str

rnets.dot.ident(s: str, i: int, first: bool = True) str[source]

Ident the given string.

Parameters:
  • s (str) -- String that will be idented.

  • i (int) -- Identation level.

  • first (bool, optional) -- Wether or not ident the first line. defaults to True

Returns:

Idented string.

Return type:

str

Note

This is not the optimal way to perform the identation as we should

build new string every time that we ident. However, I think that it is more useful than to put the identation during the writing.

rnets.dot.ident_if(s: str | None, i: int, first: bool = True) str[source]

Same as ident but returns an empty string if the input string is empty or None.

Parameters:
  • s (str or None) -- String that will be idented.

  • i (int) -- Identation level.

  • first (bool, optional) -- Wether or not ident the first line. defaults to True.

Returns:

Either the idented string or an empty string.

Return type:

str

rnets.dot.node_to_str(n: Node) str[source]

Converts a Node into a string

Parameters:

n (Node) -- Node that will be converted.

Returns:

Node in the dot format.

Return type:

str

rnets.dot.opt_glob_to_str(k: str, o: Opts) str[source]

Format a name followed by Opts. Used to define global variables.

Parameters:
  • k (str) -- OptKind for which the global options will be decided.

  • o (Opts) -- Global options to define.

Returns:

Options in dot format.

Return type:

str

rnets.dot.opts_glob_to_str(os: OptsGlob) str[source]

Format a OptsGlob in dot format.

Parameters:

os (OptsGlob) -- To convert to dot format.

Returns:

Global options in dot format.

Return type:

str

rnets.dot.opts_to_str(o: Opts) str[source]

Converts a Opts into a string.

Parameters:

n (Opts) -- Options that will be converted.

Returns:

of the dot format

Return type:

str