maboss API

In the maboss module, the informations contained in the MaBoSS’s .cfg and .bnd files are represented by Python objects.

Network objects represent most of the information contained in the .bnd file, and Simulation object contained the information contained in the .cfg file.

The maboss module can call the MaBoSS software via the run method of Simulation objects. This method writes a .cfg and a .bnd files and run MaBoSS on them. Then, a Result object is created to interact with MaBoSS output files.

types

  • Node
class maboss.network.Node(name, logExp=None, rt_up=1, rt_down=1, is_internal=False, internal_var={}, is_mutant=False)[source]

Represent a node of a boolean network.

name

the name of the node

rt_up

A string, an expression that will be evaluated by MaBoSS to determine the probability of the node to switch from down to up

rt_down

A string, similar to rt_up but determine the probability to go from up to down

logExp

A string, the value that will be attributed to the internal node variable @logic in the bnd file

Node objects have a __str__ method that prints their representation in the MaBoSS language.

set_logic(string)[source]

Set logExp to string if string is a valid boolean expression.

Parameters:string (str) – the boolean expression to be attributed to self.logExp
set_rate(rate_up, rate_down)[source]

Set the value of rate_up and rate_down.

Parameters:
  • rate_up (double) – the value of rt_up in below expression
  • rate_down (double) – the value of rt_down in below expression

This function will write a simple formula of the form

rate_up = @logic ? rt_up : 0 ; rate_down = @logic ? 0 : rt_down ;
  • Network
class maboss.network.Network(nodeList)[source]

Represent a boolean network.

Initialised with a list of Nodes whose logExp s must contain only names present in the list.

Network objects are in charge of carrying the initial states of each node.

copy() → a shallow copy of od[source]
set_istate(nodes, probDict, warnings=True)[source]

Change the inital states probability of one or several nodes.

Parameters:
  • nodes (a Node or a list or tuple of Node) – the node(s) whose initial states are to be modified
  • probDict (dict) – the probability distribution of intial states

If nodes is a Node object or a singleton, probDict must be a probability distribution over {0, 1}, it can be expressed by a list [P(0), P(1)] or a dictionary: {0: P(0), 1: P(1)}.

If nodes is a tuple or a list of several Node objects, the Node object will be bound, and probDict must be a probability distribution over a part of {0, 1}^n. It must be expressed in the form of a dictionary {(b1, …, bn): P(b1,..,bn),…}. States that do not appear in the dictionary will be considered to be impossible. If a state has a 0 probability of being an intial state but might be reached later, it must explicitly appear as a key in probDict.

Example

>>> my_network.set_istate('node1', [0.3, 0.7]) # node1 will have a probability of 0.7 of being up
>>> my_network.set_istate(['node1', 'node2'], {(0, 0): 0.4, (1, 0): 0.6, (0, 1): 0}) # node1 and node2 can never be both up because (1, 1) is not in the dictionary
set_output(output_list)[source]

Set all the nodes that are not in the output_list as internal.

Parameters:output_list (list of Node) – the nodes to remain external
  • Simulation
class maboss.simulation.Simulation(nt, parameters={}, command=None, **kwargs)[source]

Class that handles MaBoSS simulations.

network

A Network object, that will be translated in a bnd file

mutations

A list of nodes for which mutation can be triggered by modifying the cfg file

palette

A mapping of nodes to color for plotting the results of the simulation.

param

A dictionary that contains global variables (keys starting with a ‘$’), and simulation parameters (keys not starting with a ‘$’).

__init__(nt, parameters={}, command=None, **kwargs)[source]

Initialize the Simulation object.

Parameters:
  • nt (Network) – the network associated with the simulation.
  • kwargs (dict) – parameters of the simulation
continue_from_result(result)[source]

Set the initial state from as the last state from result.

get_initial_state()[source]

TODO

mutate(node, state)[source]

Trigger or untrigger mutation for a node.

Parameters:
  • node (Node) – The Node to be modified
  • State (str) –
    • 'ON' (always up)
    • 'OFF' (always down)
    • 'WT' (mutable but with normal behaviour)

The node will appear as a mutable node in the bnd file. This means that its rate will be of the form:

rate_up = $LowNode ? 0 :($HighNode ? 1: (@logic ? rt_up : 0))

If the node is already mutable, this method will simply set $HighNode and $LowNode accordingly to the desired mutation.

print_bnd(out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

Produce the content of the bnd file associated to the simulation.

print_cfg(out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

Produce the content of the cfg file associated to the simulation.

run(command=None, workdir=None, overwrite=False, prefix='res')[source]

Run the simulation with MaBoSS and return a Result object.

Parameters:command – specify a MaBoSS command, default to None for automatic selection
Return type:Result
update_parameters(**kwargs)[source]

Add elements to self.param.

  • Result
class maboss.result.Result(simul, command=None, workdir=None, overwrite=False, prefix='res')[source]
get_first_state_index(df)

Return the indice of the first column being a state By default it’s five, but if we specify some refstate, it’ll be more.

get_fptable()

Return the content of fp.csv as a pandas dataframe.

make_node_proba_error_table(df)

Same as make_trajectory_table but with nodes instead of states.

make_node_proba_table(df)

Same as make_trajectory_table but with nodes instead of states.

make_trajectory_error_table(df, states, cols)

Creates a table giving the probablilty of each state a every moment.

The rows are indexed by time points and the columns are indexed by state name.

make_trajectory_full_table(df, states, cols)

Creates a table with the format used in the original script MBSS_FormatTable.pl

make_trajectory_table(df, states, cols, nona=False)

Creates a table giving the probablilty of each state a every moment.

The rows are indexed by time points and the columns are indexed by state name.

make_trajectory_table_parallel(df, states, cols, nb_cores)

Creates a table giving the probablilty of each state a every moment.

The rows are indexed by time points and the columns are indexed by state name.

plot_entropy_trajectory(until=None)

Plot the evolution of the (transition) entropy over time.

Parameters:until (float) – plot only up to time=`until`.
plot_fixpoint()

Plot the probability distribution of fixed point.

plot_node_trajectory(until=None, legend=True, error=False, prob_cutoff=0.01)

Plot the probability of each node being up over time.

Parameters:until (float) – plot only up to time=`until`.
plot_piechart(embed_labels=False, autopct=4, prob_cutoff=0.01)

Plot the states probability distribution of last time point.

Parameters:
  • prob_cutoff (float) – states with a probability below this cut-off are grouped as “Others”
  • embed_labels (bool) – if True, the labels are displayed within the pie
  • autopct (float or bool) – display pourcentages greater than autopct within the pie (defaults to 4 if it is a Boolean)
plot_trajectory(legend=True, until=None, error=False, prob_cutoff=0.01)

Plot the graph state probability vs time.

Parameters:
  • until (float) – plot only up to time=`until`
  • legend (bool) – display legend
save(prefix, replace=False)[source]

Write the cfg, bnd and all results in working dir.

prefix is a string that will determine the name of the created files. If there is a conflict with existing files, the existing files will be replaced or not, depending on the value of the replace argument.

parser

Function to import the ginsim out in Python.

The ginsim output is a special case of MaBoSS format. This parser uses the very specific structure of the ginsim output and not able to parse every MaBoSS file.

maboss.gsparser.load(bnd_filename, *cfg_filenames, **extra_args)[source]

Loads a network from a MaBoSS format file.

Parameters:
  • bnd_filename (str) – Network file
  • cfg_filename (str) – Configuraton file
  • simulation_name (str) – name of the returned Simulation object
Return type:

Simulation