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
@logicin 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_upin below expression - rate_down (double) – the value of
rt_downin below expression
This function will write a simple formula of the form
rate_up = @logic ? rt_up : 0 ;rate_down = @logic ? 0 : rt_down ;- rate_up (double) – the value of
-
- Network
-
class
maboss.network.Network(nodeList)[source]¶ Represent a boolean network.
Initialised with a list of Nodes whose
logExps must contain only names present in the list.Network objects are in charge of carrying the initial states of each node.
-
set_istate(nodes, probDict)[source]¶ Change the inital states probability of one or several nodes.
Parameters: 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
-
- Simulation
-
class
maboss.simulation.Simulation(nt, **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, **kwargs)[source]¶ Initialize the Simulation object.
Parameters: - nt (
Network) – the network associated with the simulation. - kwargs (dict) – parameters of the simulation
- nt (
-
mutate(node, state)[source]¶ Trigger or untrigger mutation for a node.
Parameters: - node (
Node) – TheNodeto 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.
- node (
-
print_bnd(out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]¶ Produce the content of the bnd file associated to the simulation.
-
- Result
-
class
maboss.result.Result(simul)[source]¶ Class that handles the results of MaBoSS simulation.
Parameters: simul ( Simulation) – The simulation object that produce the results.When a Result object is created, two temporary files are written in
/tmp/these files are the.bndand.cfgfile represented by the associated Simulation object. MaBoSS is then executed on these to temporary files and its output are stored in a temporary folder. The Result object has several attributes to access the contents of the folder as pandas dataframe. It also has methods to produce somme plots.By default, the cfg, bnd and MaBoSS output are removed from the disk when the Result object is destructed. Result object has a method to save cfg, bnd and results in the working directory.
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_filename)[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
Simulationobject
Return type: