Text-to-model conversion (biomass.construction.text2model)

class biomass.construction.text2model.Text2Model(input_txt, similarity_threshold=0.7, lang='python')

Build a BioMASS-formatted model based on template.

reaction | parameters | initial conditions

input_txt

Model description file (*.txt), e.g., ‘Kholodenko1999.txt’

Type:

str

similarity_threshold

Similarity threshold used in text-to-model conversion. Must lie within (0, 1).

Type:

float (default: 0.7)

lang

Either ‘python’ or ‘julia’.

Type:

Literal[“python”, “julia”] (default: ‘python’)

convert(*, show_restrictions=False, overwrite=False)

Convert text to a biomass-formatted model.

Parameters:
  • show_restrictions (bool (defauld: False)) – Whether to display reaction indices in which thermodynamic restrictions should be imposed. These detailed balance constraints require the product of the equilibrium constants along a cycle to be equal to 1.

  • overwrite (bool (defauld: False)) – If True, the model folder will be overwritten.

Return type:

None

Examples

>>> from pasmopy import Text2Model
>>> Text2Model("Kholodenko1999.txt").convert()
dynamic_plot(save_dir='.', file_name='network.html', show=True, annotate_nodes=True, show_controls=False, which_controls=None)

Saves a dynamic and interactive image of the network graph. Graph is read by pyvis. Using pyvis a dynamic and interactive representation of the biological network is created in html format.

Parameters:
  • show (bool, default=True) – If True the plot will immediately be displayed in the webbrowser.

  • annotate_nodes (bool, default=True) – If True nodes will be scaled according to number of edges and hovering over a node will show interaction partners.

  • show_controls (bool, default=False) – If True control buttons will be displayed.

  • which_controls (List(str), optional, default=None) – Used to specify which control buttons should be displayed. If empty all buttons will be displayed.

Return type:

None

Examples

>>> model.dynamic_plot("path/to/", "graph.html")
Creates graph and shows interactive graph with default options.
>>> model.dynamic_plot("path/to/", "graph.html", show=False, show_controls=True, which_controls=["physics", "manipulation", "interaction"])
Creates interactive graph. Controls for physics, manipulation and interaction will be available.
register_word(terminology=None)

Register user-defined rule word.

Parameters:

terminology (Dict[str, List[str]], optional) – Pair of reaction rule and user-defined rule words.

Return type:

None

Examples

>>> from pasmopy import Text2Model
>>> mm_kinetics = Text2Model("michaelis_menten.txt")
>>> mm_kinetics.register_word({"dissociate": ["releases"]})
>>> mm_kinetics.convert()
static_plot(save_dir='', file_name='model_graph.png', gviz_args='', gviz_prog='dot')

Saves a static image of the network.

Static image is created using pygraphviz.

Parameters:
  • save_dir (string) – Name of the directory in which the image will be stored.

  • file_name (string) – Name as which the image of the graph will be stored.

  • gviz_args (string, optional, default="") – Used to specify command line options for gviz, see https://graphviz.org/pdf/dot.1.pdf for available options.

  • gviz_prog ({"neato", "dot", "twopi", "circo", "fdp", "nop"}, default="dot") – Layout engine with which the graph will be arranged. For details see https://graphviz.org/docs/layouts/ .

Raises:

ValueError – If something is passed as the gviz_prog that is not a viable layout program.

Return type:

None

Examples

>>> model.static_plot("path/to/", "graph.png")
Creates graph with dot layout and default options.
>>> model.static_plot("path/to/", "graph.pdf", gviz_prog="-Nshape=box -Nstyle=filled -Nfillcolor="#ffe4c4" -Edir=none")
Creates graph with dot layout in pdf file format. Nodes will be rectangular and colored bisque, edges will have no arrows indicating direction.
to_markdown(num_reactions, savedir='markdown')

Create markdown table describing differential equations.

Parameters:
  • num_reactions (int) – The number of rate equations in the model.

  • savedir (str (default: "markdown")) – The directory name to save the output.

Return type:

None

Examples

>>> from pasmopy import Text2Model
>>> Text2Model("Kholodenko1999.txt").to_markdown(25)