BooN’s Documentation
The BooN project provides a complete set of functionalities for Boolean Network (BooN) analysis. It was originally designed to explore the modeling of genetic networks by Boolean networks. The project includes:
the definition of a Boolean network with the possibility to load and save it;
the computation of the model of dynamics with respect to a mode policy;
the definition of the interaction graph including a modular decomposition of the interaction;
the computation of equilibria based on dynamics model;
the efficient symbolic computation of stable states based on SAT solver;
the controllability analysis predicting which variables must be frozen to reach the expected goal at stable states based on possibility and necessity query;
also different basic functionalities are included as: update formula and importing/exporting to a text or SBML file the Boolean network.
BooN Modules Description
The BooN project comprises 3 modules:
boon
module is related to the manipulation of Boolean network named BooN which is an object.boon.logic
sub module includes the basic functions on propositional formula, as well as more advanced features like fast CNF conversion for large formulas, CNF conversion using Tseitin’s method, and prime implicant calculation. These functions are used in the BooN modules.boonify
module is the graphical interface manipulating BooN:computation of dynamical model for synchronous and asynchronous mode, the computation ot the stable states, and the controllability analysis. For exploring BooN interactively runboonify.py
BooN installation
Go in the directory of BooN and type:
pip install .
or,
python -m pip install .
Function Description
Boon Module
This module contains functions used for the manipulation of Boolean network (BooN). BooN is the class of this module.
- class boon.BooN(descriptor=None, style={'type': 'infix', And: '∧', Equivalent: '⇔', False: 'false', Implies: '⇒', Not: '¬', Or: '∨', True: 'true', Xor: '⊻'}, pos: dict = {})[source]
Boolean Network Class.
- Parameters:
desc (Dict) – Boolean network descriptor { variable: formula, …}.
style (dict) – Output form of the BooN: LOGICAL, SYMPY, MATHEMATICA, JAVA, BOOLNET, …,
pos (dict) – the positions of the nodes in the interaction graph. {node:position, …}.
- cnf(variable: Symbol | None = None, simplify: bool = True, force: bool = True) BooN [source]
Convert the formulas of the Boolean network to CNF.Convert the formulas of the Boolean network to CNF.
- Parameters:
variable (Symbol) – The variable where the formula is to be converted in CNF (Default None). If variable is None, then all the formulas are converted to CNF.
simplify (bool) – Boolean flag determining whether the formula should be simplified (Default True).
force (bool) – Boolean flag forcing the complete simplification of the resulting CNF (Default True).
- Returns:
self
- Return type:
- control(frozenfalse: set | list | frozenset, frozentrue: set | list | frozenset) None [source]
Set control on the BooN. The controlled variables are divided in two classes: the variables frozen to false and the variables frozen to true. A variable can belong to both classes.
- Parameters:
frozenfalse (Iterable object (list, set, tuple)) – List, set or sequence of variables that should be frozen to false by control.
frozentrue (iterable object (list, set, tuple)) – List, set or sequence of variables that should be frozen to true by control.
- Returns:
self
- Return type:
- delete(variable) BooN [source]
Delete a variable in a BooN. The formulas must all be in DNF to properly delete the variable.
- Parameters:
variable (Symbol) – The variable to delete.
- Returns:
self
- Return type:
- destify(query, max_solutions: int = 9223372036854775807, trace: bool = False, solver=<class 'pulp.apis.coin_api.PULP_CBC_CMD'>)[source]
Compute the core which is the minimal set of controls under the inclusion to satisfy the query at stable state. Destify is a neologism that refers to the deliberate and purposeful act of shaping destiny by influencing or directing the course of events or outcomes towards an expected goal.
- Parameters:
query (Sympy formula) – The query defining the expected destiny or goal as propositional formula.
max_solutions (int) – Maximal number of solutions (Default the largest integer = sys.maxsize)
trace (Bool) – Boolean flag determining whether the trace is activated (Default: False).
solver (Pulp function) – The PulpSolver used for solving the problem (Default: PULP_CBC_CMD).
- Returns:
The core of control
- Return type:
frozenset[Sympy symbol]
- dnf(variable: Symbol | None = None, simplify: bool = True, force: bool = True) BooN [source]
Convert formula(s) of the Boolean network to DNF.
- Parameters:
variable (Symbol) – The variable where the formula is to be converted in DNF (Default: None). If variable is None, then all the formulas are converted to DNF.
simplify (bool) – Boolean flag determining whether the formula should be simplified (Default: True).
force (bool) – Boolean flag forcing the complete simplification (Default: True).
- Returns:
modified BooN
- Return type:
- draw_IG(IG: DiGraph | None = None, modular: bool = False, **kwargs) DiGraph [source]
Draw the interaction graph.
- Parameters:
IG (networkx DiGraph) – The interaction graph or None. If None, the interaction graph is generated from BooN (Default: None).
modular (bool) – Boolean indicating whether the modular structure of interactions is displayed if True (Default: False)
kwargs (dict) – additional keyword arguments to pass to the interaction graph drawing
- Returns:
interaction graph
- Return type:
Networkx DiGraph
- draw_model(model: ~networkx.classes.digraph.DiGraph | None = None, mode: ~collections.abc.Callable = <function asynchronous>, color: list[str] = ['tomato', 'gold', 'yellowgreen', 'plum', 'mediumaquamarine', 'darkorange', 'darkkhaki', 'forestgreen', 'salmon', 'lightcoral', 'cornflowerblue', 'orange', 'paleviolet', 'coral', 'dodgerblue', 'yellowgreen', 'orangered', 'pink', 'blueviolet', 'crimson'], **kwargs) None [source]
Draw the graph representing the model of dynamics.
- Parameters:
model (Networkx DiGraph) – Input graph model of the BooN or None (Default: None). If it is None, the asynchronous model computed from the BooN.
mode (function) – Function characterizing the mode of the model (Default: asynchronous)
color (list) – list of colors for highlighting the equlibria (Default: COLOR)
kwargs (dict) – extra parameters of nx.draw_networkx.
- Returns:
None
- Return type:
None
- equilibria(model: ~networkx.classes.digraph.DiGraph | None = None, mode: ~collections.abc.Callable = <function asynchronous>, trace: bool = False) list[list] [source]
Calculate equilibria for the network based on the model of dynamics. The method examines an exponential number of states, and thus it is restricted to networks with a small number of variables (max. ~10).
- Parameters:
model (Networkx DiGraph) – Data model from which the equilibria are calculated (Default: None)
mode (function) – Updating mode function, used if the model is None (Default: asynchronous).
trace (bool) – Define whether the trace of execution is enabled (Default: False (disabled)).
- Returns:
Equilibria structure as a list of lists where each sublist is an attractor.
- Return type:
List[list]
- filter_necessary(query, core: frozenset, trace: bool = False) frozenset [source]
Filter necessary controls in the network such that the query is satisfied for all stable states. This method must be applied to a non-controlled network to correctly functioning.
This function filters controls from the given core based on the condition that they satisfy the query for all stable states of the controlled network.
- Parameters:
query (Sympy expression) – The Boolean query to be satisfied across all stable states of the controlled network.
core – A set of prime implicants (controls) that will be filtered.
trace (bool) – Determines whether to display progress information during filtering (Defaults: False).
- Returns:
A subset of the given core containing only the necessary controls.
- Return type:
frozenset
- classmethod from_ig(IG: nx.DiGraph) Boon [source]
Define the descriptor of a BooN from an interaction graph. The method is a class method.
- Parameters:
IG – Interaction graph.
- Returns:
BooN
- Return type:
- classmethod from_sbmlfile(filename: str) BooN [source]
Import the Boolean network from a sbml file. The method is a class method.
- Parameters:
filename (Str) – The name of the file, if the extension is freestates, then .sbml is added.
- Returns:
BooN
- Return type:
- classmethod from_textfile(filename: str, sep: str = '\n', assign: str = ',', ops: dict = {'type': 'normal form', And: '&', False: '0', Not: '!', Or: '|', True: '1'}, skipline: str = '(targets\\s*,\\s*factors)|(#.*)') BooN [source]
Import the Boolean network from a text file, the syntax of which depends on the ops’ descriptor. The formulas must be in normal form containing OR, AND, NOT operators only. The nodes are circularly mapped. The default format is the Bool Net format (see ops and assign defaults). The method is a class method.
- Parameters:
filename (Str) – The file name to import the Boolean network. If the file extension is freestates, then .bnet is added.
sep (str) – The separator between definitions (default BOONSEP constant)
assign (str) – the operator defining the formula for a variable, e.g., a = f(…) → assign is ‘=’ (Default: ‘,’).
ops (dict) – A dictionary stipulating how the operators And, Or, Not are syntactically written (Default: BOOLNET).
skipline (str (regexp)) – Regular expression describing which lines must be skipped and not analyzed.
- Returns:
BooN
- Return type:
- property interaction_graph: DiGraph
Build the interaction graph.
- Returns:
The interaction graph.
- Return type:
Networkx DiGraph
- classmethod load(filename: str) BooN [source]
Load the Boolean Network from a file. If the extension is freestates, then .boon is added. The method is a class method
- Parameters:
filename (Str) – The name of the file to load the network.
- Returns:
self
- Return type:
- model(mode: ~collections.abc.Callable = <function asynchronous>, self_loop: bool = False, trace: bool = False) DiGraph [source]
Compute the dynamical model of the BooN with respect to a mode.
- Parameters:
mode (function) – Determines the mode policy applied to the model (Default: asynchronous).
self_loop (Bool) – Determines whether the boon loops are included in the model (Default: False).
trace (bool) – Define whether the trace of the execution is enabled (Default: False (disabled)).
- Returns:
a Digraph representing the complete state-based dynamics.
- Return type:
Networkx Digraph
- necessary(query, trace: bool = False)[source]
Compute the necessary constraints. The computation may take time because the query is converted to CNF that may contain a lot of terms.
- Parameters:
query (Sympy formula) – A formula characterizing the query, objective or goal.
trace (bool) – Boolean flag determining whether the trace is activated (Default value = False).
- Returns:
CNF specifying the necessity.
- Return type:
Sympy formula
- possibly(query)[source]
Compute the possibility constraint.
- Parameters:
query (Sympy formula) – A formula characterizing the query, objective or goal.
- Returns:
a formula specifying the possibility.
- Return type:
Sympy formula
- classmethod random(n: int, p_link: float, p_pos: float = 0.5, topology: str = 'Erdos-Reny', min_clauses: int = 1, max_clauses: int = 5, prefix: str = 'x') BooN [source]
Generate a random BooN where the formulas are in DNF. The method is a class method.
- Parameters:
n (Int) – The number of variables.
p_link – probability related to interaction between variables, the use depends on the topology class.
p_pos (Float) – The probability of defining a variable as a positive term (default 0.5).
topology (str) – the topology class of the interaction graph: ‘Erdos-Reny’, ‘Scale-Free’, ‘Small-World’ (default ‘Erdos-Reny’)
min_clauses (Int) – the minimum number of clauses required to define a formula (default 1).
max_clauses (Int) – the minimum number of clauses required to define a formula (default 5).
prefix (Str) – the prefix of the variable name, the variables are of the form <prefix> <int> (default ‘x’).
- Returns:
a random BooN
- Return type:
- rename(source: Symbol, target: Symbol) BooN [source]
Rename a variable.
- Parameters:
source (Symbol) – The variable to rename.
target (Symbol) – The variable renaming the source.
- save(filename: str = 'BooN04-janv.-25-18.boon') None [source]
Save the Boolean Network to file. If the extension is freestates, then .boon is added.
- Parameters:
filename (str) – The name of the file to save the network (Default: BooN+date+hour.boon)
- Returns:
None
- Return type:
None
- property stable_states: list[dict]
Compute all the stable states of a BooN. The algorithm is based on SAT solver.
- Returns:
List of stable states.
- Return type:
List[dict]
- str(sep: str = '\n', assign: str = '=') str [source]
Return a string representing the BooN. The output format can be parameterized (see style argument of BooN)
- Parameters:
sep (str) – The separator between formulas (default BOONSEP constant)
assign (str) – the operator defining the assignment of a formula to a variable (e.g., a = f(…) → assign is ‘=’). (Default: ‘=’)
- to_textfile(filename: str, sep: str = '\n', assign: str = ',', ops: dict = {'type': 'normal form', And: '&', False: '0', Not: '!', Or: '|', True: '1'}, header: str = '# BooN saved on 04-01-2025\ntargets, factors') BooN [source]
Export the Boolean network in a text file. If the file extension is freestates, then .txt is added. The default format is BOOLNET.
- Parameters:
filename (Str) – The file name to export the Boolean network.
sep (str) – The separator between formulas (default BOONSEP constant)
assign (str) – the operator defining the formula for a variable, e.g., a = f(…) → assign is ‘=’ (Default: ‘,’ Boolnet Format).
ops (dict) – A dictionary stipulating how the operators And, Or, Not are syntactically written (Default: BOOLNET).
header (str) – Header text inserted at the beginning of the saved file.
- Returns:
self
- Return type:
- property variables: set
Return the set of variables. (property) :return: Variables :rtype: set[Symbol]
- boon.asynchronous(variables: list | set) frozenset [source]
Asynchronous or sequential mode. One variable is updated per transition.
- Parameters:
variables (List or set) – List of variables.
- Returns:
of sets: {{x1},…,{xi},…,{xn}} representing the asynchronous mode.
- Return type:
frozenset[frozenset[Symbol]]
- boon.controls2actions(controls: frozenset) list[tuple] [source]
Convert a set of controls into a list of actions where an action is a pair (symbol, boolean value). :param controls: The set of control parameters. :type controls: frozenset[Sympy symbols] :return: A list of actions. :rtype: list[tuple[Sympy symbol, bool]]
- boon.core2actions(core: frozenset) list [source]
Convert the core to a list of actions where an action is a list of (variable, Boolean). The actions are sorted by length, meaning that the more parsimonious actions are at first.
- Parameters:
core (Frozenset[Frozenset[Sympy symbol]].) – The core.
- Returns:
A list of combined actions where an action is defined as:[(variable, bool) …]
- Return type:
List[list[tuple]]
- boon.hypercube_layout(arg: int | nx.Digraph) dict [source]
Compute the hypercube layout of a graph.
- Parameters:
arg (Int or networkx Digraph) – The dimension of the hypercube or the network to which the layout is applied.
- Returns:
a dictionary {int:position} where int is the integer code of the hypercube labels.
- Return type:
Dict
- boon.int2state(int_state: int, variables: list | set) dict [source]
Convert an integer state to a dictionary state.
- Parameters:
int_state (Int) – The state coded into integer.
variables (list or set) – List of variables.
- Returns:
a dictionary representing the state {variable: boolean state…}.
- Return type:
Dict
- boon.is_controlled(formula) bool [source]
Check whether a formula is controlled.
- Parameters:
formula (Sympy formula.) – The input formula.
- Returns:
True if the formula is controlled otherwise False
- Return type:
bool
- boon.isctrl(lit) bool [source]
Determines if a literal contains a controller. :param lit: The literal to be validated. :type lit: Literal :return: True if the literal is a negative control, False otherwise. :rtype: Bool
- boon.isnegctrl(lit) bool [source]
Determines if a given literal is a negative control. :param lit: The literal to be validated. :type lit: Literal :return: True if the literal is a negative control, False otherwise. :rtype: Bool
- boon.state2int(state: dict | tuple, variables: set | list | None = None) int [source]
Convert a set of states to an integer the binary profile of which corresponds to the state of the variables.
- Parameters:
state (Dict or tuple) – State of the variables.
variables (list or set) – List of variables.
- Returns:
an integer such that its binary profile represents the state.
- Return type:
Int
- boon.synchronous(variables: list | set) frozenset [source]
synchronous or parallel mode. All the variables are updated jointly per transition.
- Parameters:
variables (list or set) – list of variables.
- Returns:
of sets: {{x1,…,xi,…,xn}} representing the synchronous mode.
- Return type:
frozenset[frozenset[Symbol]]
Logic Module
This module includes functions on propositional formula.
- boon.logic.clause2literals(clause) set [source]
Convert a clause or a cube into of a sequence of literals.
- Parameters:
clause (Sympy formula) – The clause or cube.
- Returns:
set of literals.
- Return type:
Set
- boon.logic.cnf2clauses(cnf)[source]
Decomposition of a CNF into a sequence of clauses.
- Parameters:
cnf (sympy formula) – CNF formula
- Returns:
sequence of clauses.
- Return type:
Tuple[formula]
- boon.logic.errmsg(msg: str, arg='', kind: str = 'ERROR') None [source]
Display an error message and exit in case of error (kind = “ERROR”).
- Parameters:
msg (str) – The error message.
arg (str) – The argument of the error message (Default: “” no args).
kind (str) – Type of error (Default: ERROR). Only the “ERROR” option will exit the application.
- Returns:
None
- Return type:
None
- boon.logic.firstsymbol(formula)[source]
Extract the first symbol from the symbols of a dnf.
- Parameters:
formula (Sympy formula) – The input dnf.
- Returns:
the first symbol.
- boon.logic.newvar(initialize: int | None = None)[source]
Create a new sympy symbol of the form <prefix><number>. The prefix is given by TSEITIN constant.
- Parameters:
initialize (int|None) – Initialize the counter if the value is an integer or let the counter increment by 1 if it is set to None (Default value = None)
- Returns:
a Simpy symbol.
- Return type:
Symbol
- boon.logic.prettyform(formula, style: dict = {'type': 'infix', And: '∧', Equivalent: '⇔', False: 'false', Implies: '⇒', Not: '¬', Or: '∨', True: 'true', Xor: '⊻'}, depth=0)[source]
Return a string of a formula in nice form.
- Parameters:
formula (sympy formula) – The input formula.
style (dict) – The style of the logical operators (Default: LOGICAL)
depth (int) – the current depth of the formula for setting parentheses (Default: 0)
- boon.logic.prime_implicants(formula, kept: ~collections.abc.Callable = <function <lambda>>, max_solutions: int = 9223372036854775807, trace: bool = False, solver: type = <class 'pulp.apis.coin_api.PULP_CBC_CMD'>) frozenset [source]
Compute all the prime implicants of a propositional formula where the literals are filtered by kept function.
- Parameters:
formula (Sympy formula) – The input formula. The formula does not need to be in CNF.
kept (function) – Predicate selecting the literals that are kept in the solutions (Default: function discarding the Tseitin working variables)
max_solutions (int) – maximal number of solutions (Default sys.maxsize)
trace (bool) – a Boolean flag determining whether the trace showing the resolution is activated (Default: False).
solver (solver function) – The solver to use (Default: Pulp solver).
- Returns:
all the prime implicants in the form of a set of sets where each subset represents one prime implicant filtered by kept.
- Return type:
frozenset
- boon.logic.supercnf(formula, trace: bool = False)[source]
Convert the formula to CNF. The method is well adapted to large formula.
- Parameters:
formula (sympy formula) – The formula to convert.
trace (bool) – Boolean flag if True trace the computational steps (Default value = False)
- Returns:
CNF formula
- Return type:
sympy formula
- boon.logic.sympy2z3(formula)[source]
Convert a sympy formula to z3 formula.
- Parameters:
formula (Sympy formula) – The formula to convert.
- Returns:
the equivalent z3 formula.
- Return type:
Z3 formula
Boonify Module
Graphical interface module.
- class boonify.Boonify[source]
Represents the main application window for managing and designing BooNs (Boolean Networks).
Provides a GUI with a comprehensive set of functionalities. This class is primarily responsible for initializing and connecting GUI widgets, setting up callbacks, and constructing an editable graph for network interaction design.
- Variables:
boon – The current Boolean Network object being managed or displayed.
filename – The name of the file associated with the current BooN (empty if no file is loaded or saved).
history – Maintains a history list of BooN objects for undo/redo functionalities.
hindex – The index of the last BooN added to the history.
hupdate – Flag indicating whether the history should be updated.
saved – Flag indicating if the current BooN has been saved.
QView – Widget for displaying BooN visualization.
QStableStates – Widget for displaying stable states of BooNs.
QModel – Widget for displaying the dynamic model of the BooN.
QControllability – Widget for displaying BooN controllability analysis.
editgraph – Editable graphical representation of the BooN’s interaction graph.
disablecallback – Flag indicating whether design callbacks are disabled.
designsize – Scaling factor related to graphics elements in the EditableGraph.
worker – Background thread for processing long-running BooN operations.
canvas – Matplotlib canvas for rendering the network design figure in the GUI.
- add_history()[source]
Adds the current BooN to the history if it differs from the last saved state. This method ensures that changes to the BooN descriptor are tracked and recorded appropriately in the history buffer. It also manages internal state flags to enable or disable disruptive behaviors such as callbacks when updating history. The history index is circularly updated to maintain a fixed-size history buffer.
attribute self.hindex: Index of the current position in the history. attribute self.boon.desc: Descriptor of the current BooN. attribute self.disablecallback: Boolean that disables callback updates when True. attribute self.hupdate: Boolean that indicates whether the history has been updated.
- Returns:
None
- closeEvent(event)[source]
Handles the close event for the application window.
This method ensures that when the application’s close event is triggered, it invokes the quit method to handle quitting properly. The event.ignore() ensures that the close event is ignored unless the application is closed successfully prior to that, in which case event.ignore() will not execute.
- Parameters:
event (QCloseEvent) – The close event being processed, which carries information about the window-closing action.
- Returns:
None
- controllability()[source]
Defines a function that initializes and displays the controllability object related to the current self-instance.
- attributes QControllabilityControllability
And instance of the Controllability class associated with the current object. It encapsulates functionality to assess or manage controllability features.
- Returns:
None
- design()[source]
Designs the BooN based on the events captured from the EditableGraph. This function establishes consistency in the nodes and edges of the graph, processes symbolic representation, determines signs and modularity of edges, and converts the interaction graph (IG) to a BooN object for further utilization. Requires labeled nodes and valid interactions to derive the BooN structure.
- display_saved_flag(val: bool = True)[source]
Displays a flag in the status bar indicating whether the data has been saved.
This method updates the status bar message based on the save state. If the data is saved, a large empty circle is displayed. If the data is not saved, a large black circle is displayed.
- Parameters:
val (bool) – They save a status flag. If True, the data is saved, and the large empty circle is shown. If False, the data is not saved, and the large black circle is displayed.
- exportation()[source]
Exports data to a specified file format (BoolNet or Txt).
The method allows exporting data to a file in the BoolNet or Txt format based on the provided file name and its extension. The BoolNet format is supported with a .bnet extension, and the Python-compatible format is supported with a .txt extension.
- Raises:
ValueError – If the filename extension is unsupported or invalid.
- Returns:
None
- help()[source]
Provides functionality to call and display help using an external Help object.
- Returns:
None
- history_raz()[source]
Resets the history and initializes it with the current state of BooN. It clears the history, sets the history index to the starting position, and ensures that the history update flag is reset.
- Variables:
history – A list to record the history of BooN states. Initially cleared and reinitialized to a default size, HSIZE.
hindex – An integer representing the index position of the last BooN state added to the history. Reset to 0 after cleaning history.
hupdate – A boolean flag indicating whether the history is updated. Set to False after resetting the history.
- importation()[source]
Handles the importation of a file and initializes the respective properties based on the detected file format. This function utilizes specific handlers to import files in supported formats such as BoolNet (.bnet), Python (.txt), and SBML (.sbml or .xml). It ensures that the application state is updated after the import, refreshing the GUI, setting up the design, and clearing the history if the file is successfully imported.
If an unsupported file extension is provided, it displays a critical error message to inform the user about acceptable formats.
- Returns:
None
- model()[source]
Display the dynamical model if the number of variables does not exceed the defined model boundary
- Returns:
None
- open()[source]
Open a file using a file dialog, load its contents, and update the application state.
This method presents a file dialog to the user to choose a file with the specific extension. After successfully selecting a file, the method loads its content, refreshes the application view, initializes the design setup, and clears the history.
- Returns:
None
- quit()[source]
Terminates the application based on user confirmation and save status.
This method checks if the BooN has been saved. If it is not saved, it prompts the user with a dialog to choose whether to save, cancel, or quit without saving.
- Returns:
None
- redo()[source]
Redo the last undone operation by navigating through the history list and updating the current state. This method ensures that callback functions are temporarily disabled during the operation to avoid disruptive updates.
- refresh()[source]
Refreshes all visible components, such as BooN View, Stable States View, Model View, and Controllability View. Each visible component is reinitialized or updated via its relevant function. This ensures that all active components reflect the most current state.
- Returns:
None
- resizeEvent(event, **kwargs)[source]
Adjusts the current graphical interface parameters and components based on a resize event. It retrieves the existing graphical configurations, calculates appropriate scaling values, and reconfigures the graphical elements accordingly to maintain visual and functional consistency.
- Parameters:
event (QResizeEvent) – Resize event triggering the adjustment process.
kwargs (dict) – Additional keyword arguments that might be required for expansion or specific functionality.
- Returns:
None
- save()[source]
Saves the current state to a file.
This method attempts to save the current state to a file using the filename attribute. If a filename is already provided, the current state is saved to this file, and the saved status flag is updated. If no filename is specified, the method triggers a save-as operation to determine the filename.
- Returns:
None
- saveas()[source]
Saves the current content to a file. The method opens a “Save As” dialog to specify a filename and filepath, saves the content to the chosen file, and updates relevant components accordingly.
- setup_design()[source]
Sets up the design of the interaction graph and its visual representation. The method configures node and edge properties, styles, positions, and visual elements on the canvas. It integrates information from an existing interaction graph and generates an editable representation of the network for visualization.
Attributes that affect the design are updated during this process, and the design callback is temporarily disabled to avoid interference.
- show_history()[source]
Displays the entire history of changes, showing each entry formatted according to its identifier and rendering logic using a tabulated structure. The current history index is highlighted, and associated data details are presented using a plain tabular format. If a history entry lacks data, it displays a placeholder.
- undo()[source]
Restores the previous state from the history while preventing disruptive updates.
This method decrements the history index and restores the previous state of the boon attribute using the corresponding entry in the history. It ensures that no unwanted side effects occur during the update process. After restoring the state, it refreshes the current state and reinitializes necessary design parameters.
- Raises:
IndexError – Raised if the history operation fails due to an invalid index or empty history.
- Returns:
None
- class boonify.Controllability(parent=None)[source]
Controllability class for managing user interactions with the controllability widget of the GUI application.
This class is responsible for initializing the controllability user interface, handling the interactions between destiny and observers tables, computing control actions based on user selections, and managing the graphical representation of these actions.
- Variables:
parent – Parent window instance for the controllability widget.
actions – Stores the calculated control actions, if any.
row – Index of the currently selected solution in control actions, if applicable.
- controllability()[source]
The method calculates control actions required to achieve or avoid a defined goal (or state) in a system represented by the BooN model. The method determines the applicable control actions by analyzing a user-specified query defining the desired or undesired state, along with the possible variables that can be controlled. This process involves interpreting various parameters such as observer states, query types, and logical modalities.
- Returns:
None
- destiny_to_observers(label: str)[source]
Updates the check state of an item in the Observers table based on the provided label and the currently selected row in the Destiny table.
- Parameters:
label (str) – A string indicating the check state condition. If the label is “None”, the item is unchecked; otherwise, it is checked.
- Returns:
None
- class boonify.Help(parent=None)[source]
Defines the Help class, a window in the application providing a user interface for displaying help documentation.
This class inherits from QMainWindow and is used to load and display an HTML-based help file using QWebEngineView. It provides a ‘Close’ button to dismiss the window. The layout and UI components are loaded from a .ui file.
- Variables:
CloseButton – The button widget used to close the help window.
web – A web engine view widget used to render and display the help HTML content.
WebContainer – The container widget to hold the QWebEngineView displaying the help content.
- class boonify.Model(parent=None)[source]
A Model class for managing and visualizing network dynamics using a GUI interface.
- Variables:
parent – Reference to the parent window or application.
mode – Represents the selected mode of dynamics (asynchronous or synchronous).
layout – Defines the network layout function to be used for visualization.
canvas – Matplotlib widget for rendering the network visualization.
- cb_network_layout()[source]
Adjusts the network layout based on the selected option and applies the corresponding layout algorithm to the network. The method retrieves the currently selected network layout from a user interface component, maps it to an appropriate algorithm, and configures the network’s visualization layout accordingly. It also invokes an update via the modeling method to apply and reflect the changes.
- Return type:
None
- rb_mode()[source]
Determine and set the mode of operation based on user selection from the interface. This function checks the state of radio buttons to assign either an asynchronous or synchronous mode. The established mode is then used for further modeling via a further call to the modeling method.
- Returns:
None
- class boonify.StableStates(parent=None)[source]
A dialog for displaying and managing stable states in a computational model.
This class represents a graphical interface for visualizing stable states of a Boolean network model. It allows users to switch between different display styles, such as icons or textual representation, for better interpretation of the stable states.
- Variables:
parent – Reference to the parent widget or application component.
style – The display style for representing stable states (e.g., ‘Icon Boolean’).
datamodel – The data model used for organizing and displaying stable states.
- cb_styling()[source]
Updates the current style setting from the user interface and refreshes the stable states view.
- Returns:
None.
- stablestates()[source]
Generates and sets up a data model to visualize stable states of a system.
This method processes the stable states of a parent object’s model and organizes them into a table-like structure using a Qt QStandardItemModel. Each row represents a variable, and each column corresponds to a stable state. The presentation style of the data (e.g., icons, boolean values, or integers) is determined by the specified style attribute of the object.
- Returns:
None
- class boonify.Threader(app=<function Threader.<lambda>>)[source]
Threader class for managing application execution within a separate thread.
This class is designed to separate the execution of a provided application function into its own thread using PyQt’s threading mechanism. The class provides functionality to start, switch, and terminate the application running within the thread effectively.
- Variables:
finished – Signal emitted when the thread’s application completes execution.
app – The callable application to be executed within the thread.
thread – The QThread instance used to run the application in a separate thread.
- apply(app)[source]
Handles the application of a given app instance to a particular object by assigning the provided app to the instance attribute.
- Parameters:
app – The application instance to be applied.
- Returns:
None
- class boonify.View(parent=None)[source]
Represents a dialog interface for managing and displaying Boolean formulas in a tabular format. The interface supports operations like editing, validating, and converting Boolean formulas, and dynamically updates the view accordingly.
This class is designed to be a standalone dialog that integrates with a parent component, using its logical formulas and variables for display and interaction.
- Variables:
style – Style of the formulas displayed in the view.
parent – Reference to the parent entity using this view, typically the Boonify class, which contains the necessary logical formulas and variables.
formulas – List of formula input fields linked to variables. Each field corresponds to a row in the table, allowing live editing of formulas.
- cb_styling()[source]
Updates the current styling for the component based on the selected style and refreshes the view.
- Returns:
None
- change_formula()[source]
Update the BooN formula based on user input and refresh-related components.
This method processes the formula input provided through the GUI, verifies its syntax and the validity of the variables involved, and updates the associated BooN data structure if the formula passes all checks. It also refreshes related components to reflect the changes. In case of errors, appropriate error messages are displayed to the user.
- Returns:
None
- convertdnf()[source]
Converts the current BooNn into Disjunctive Normal Form (DNF) and refreshes the view accordingly.
- Returns:
None
- initialize_view()[source]
Initializes and populates the view with formula fields and their respective descriptions and attributes. This method configures a table to display rows of formulas, sets the required text and style for each formula, and identifies and specifies the type of logical formulation.