Model input¶
Content
Pint relies on Automata networks framework which encompasses asynchronous Boolean and multivalued networks.
The python module allows a seamless importation of models in different file formats. The conversion is made automatically and is ensured to be exact. The next sections show how to load a model, access and update its initial state, and saving and exporting to different formats. Finally, we show how to get basic informations on the automata network model.
Loading a model¶
Pint supports multiple formats for specifying Boolean and multivalued networks, in particular SBMLqual and GINsim.
Most of the conversions are performed using BioLQM.
See load()
for the full list of supported formats. If you are missing one, please open an issue.
The loading of a model is done with the function pypint.load
which
returns an abstract object representing the automata network. The format
is guessed from the file extension.
The argument can either be a local path to a file, or a URL which will be downloaded prior to loading:
In [2]:
m = pypint.load("http://ginsim.org/sites/default/files/drosophilaCellCycleVariants.zginml")
The load
function also supports importing models from
CellCollective simply by supplying the
URL to the model repository:
In [3]:
m2 = pypint.load("https://cellcollective.org/#4705/septationinitiationnetwork")
Finally, within the Jupyter notebook web interface, a model can be
uploaded by calling load
without any argument. Once the file
selected, it will be uploaded in the notebook, and loaded as a local
file.
In [4]:
m3 = pypint.load()
Initial state¶
An automata network comes with an initial state, associating to each
automaton its starting local state. Some formats, such as GINsim, allow
to define different states that are identified with a name. In such a
case, the load
function displays the registered states.
The initial state of a model m
is accessed using
m.initial_state
. It is a dictlike object which supports updating.
In [5]:
m.initial_state
Out[5]:
{'Ago': 0,
'CycA': 0,
'CycB': 0,
'CycD': 0,
'CycE': 0,
'Dap': 0,
'E2F': 0,
'Fzr': 0,
'Fzy': 0,
'Notch': 0,
'Rb': 0,
'Rux': 0,
'Stg': 0,
'Wee1': 0}
In [6]:
m.initial_state["CycE"] = 1 # modification of the initial state
m.initial_state.nonzeros() # display only initial automata local states different from 0
Out[6]:
{'CycE': 1}
Registered states are stored in m.named_states
and can be directly
assigned as the initial state:
In [7]:
m.initial_state = m.named_states["NoCycD_Endocycle"]
m.initial_state.changes() # display changes since the default initial state of the model
Out[7]:
{'Dap': 1, 'Fzr': 1, 'Notch': 1, 'Rb': 1, 'Rux': 1}
Instead of modifying inplace the model, one can use the method Model.having()
to create a new copy of the model with supplied initial state modifications:
In [8]:
m.initial_state.reset() # restore to default initial state
m2 = m.having(CycE=1) # having can take keyword arguments
m2 = m.having({"Notch": 1, "Stg": 1}) # .. or a dictionnary
m2 = m.having("NoCycD_Endocycle") # .. or the name of a registered state
Saving and exporting¶
A model can be saved to a local file, in Pint native format:
In [9]:
m.save_as("models/demo_droso.an")
Out[9]:
Pint can also export the model to different formats, such as Petri net (PEP format with .ll
extension or ROMEO with .xml
extension) and NuSMV (.smv
). See EXPORT_SUPPORTED_EXTENSIONS
for the full list of supported exportation format.
Model description¶
Basic statistics on the model can be obtained with the summary
method:
In [10]:
m.summary()
Out[10]:
{'max_local_states': 2,
'nb_automata': 14,
'nb_local_states': 28,
'nb_states': 16384,
'nb_transitions': 61}
max_local_states
gives the number of local states of the largest automaton;nb_automata
is self explanatorynb_local_states
is the sum of the number of local states in each automatonnb_states
is the total number of global states (in our example, it corresponds to 2^14)nb_transitions
is the number of defined local transitions
The list of automata and their local states and transitions can be accessed as follows:
In [11]:
m.automata
Out[11]:
['Ago',
'CycA',
'CycB',
'CycD',
'CycE',
'Dap',
'E2F',
'Fzr',
'Fzy',
'Notch',
'Rb',
'Rux',
'Stg',
'Wee1']
In [12]:
m.local_states
Out[12]:
{'Ago': [0, 1],
'CycA': [0, 1],
'CycB': [0, 1],
'CycD': [0, 1],
'CycE': [0, 1],
'Dap': [0, 1],
'E2F': [0, 1],
'Fzr': [0, 1],
'Fzy': [0, 1],
'Notch': [0, 1],
'Rb': [0, 1],
'Rux': [0, 1],
'Stg': [0, 1],
'Wee1': [0, 1]}
In [13]:
m.local_transitions[:5]
Out[13]:
["Ago" 1 > 0,
"Dap" 1 > 0 when "CycE"=0 and "Notch"=1,
"CycA" 1 > 0 when "Rb"=0 and "E2F"=0,
"CycA" 1 > 0 when "Rb"=0 and "E2F"=1 and "Fzr"=1 and "Fzy"=0,
"CycA" 1 > 0 when "Rb"=0 and "E2F"=1 and "Fzy"=1]
This later list is actually composed of LocalTransition
and SynchronizedLocalTransitions
objects. It allows for further programmatic treatment.
Finally, the method dependency_graph()
returns a directed graph among automata, where an edge from b to a means that at least one transition of a depends on the local state of b. The returned object is a NetworkX digraph which can be further manipulated, or directly displayed in the jupyter notebook:
In [14]:
m.dependency_graph()
Out[14]:
Related functions and classes¶

load
(filename=None, format=None, simplify=True, **opts) Load a Pint model from given filename. The format is guessed from the filename extension, but can be enforced with the format parameter. Except when loading directly from a
.an
file (native format for Pint), the model will be converted to .an and a simplification step is performed. This latter stage can be deactivated with simplify=Falsefilename can be either a path to local file, or an URL. In the latter case, it will be downloaded locally first, and then processed as a local file.
Within IPython/Jupyter web notebook, the filename argument can be omited: in that case, a file upload form will be displayed.
Supported file extensions:
.an
(automata network), native Pint file format;.ginml
, imported using GINsim.zginml
, like ginml, with in addition the support of named initial states;.sbml
(SBMLqual), imported using GINsim (with bioLQM);.boolsim
,.booleannet
,.boolfunctions
(or.bn
): Boolean network formats, imported using GINsim (with bioLQM)`..bc
: Biocham model  the importation implements its Boolean semantics (experimental feature)
Supported URL schemes:
 CellCollective models can be imported by supplying the URL of the model main page. The SBML file location is determined automatically;
 any other URL is treated as a link to a file with supported extension. It will be downloaded and then loaded as a local file.
Returns a
Model
instance. If the model results from an importation, IPython displays the link to the generated .an file.Examples:
>>> m1 = pypint.load("mylocalfile.an") >>> m2 = pypint.load("http://ginsim.org/sites/default/files/FrontiersThFullmodelannotated.zginml") >>> m3 = pypint.load("https://cellcollective.org/#4705/septationinitiationnetwork")
See also
LOAD_SUPPORTED_FORMATS
for supported formats.

class
Model
Abstract class for manipulating and analyzing an AN (Automata Network) model.
A Model is typically instanciated using the
load()
function, or usingInMemoryModel
for small inmemory AN specifications.
automata
¶ The list of automata names

local_states
¶ Dictionnary associating to each automaton its list of local states (str or int list).

local_transitions
¶ The list of local transitions (
LocalTransition
orSynchronizedLocalTransitions
) in the AN specification.

initial_state
¶ The current initial state of the model (
InitialState
instance).

named_states
¶ A dictionnary of named
InitialState
instances.

features
¶ A list of features the AN model is using, if any, among:
 “synced_transitions”: the AN uses synchronized local transitions.

dependency_graph
() Returns the dependency graph between automata: there is an edge from a to b if some local transitions of b depends on a.
Complexity: linear with the number of local transitions.
Return type: NetworkX digraph (nx.DiGraph)

having
(initial_state=None, **kwargs) Returns a copy of the model with supplied modifications
Parameters:  initial_state (InitialState or str) – new initial state
 kwargs – if nonempty, defines a new initial state from
Model.initial_state
by callingInitialState.having()
.
Return type: Exemples:
>>> m.having(m.named_states["ProT1"]).reachability("Tf1=1") >>> m.having(HR=1).reachability("Tf1=1")

save_as
(filename) Save the AN model with its initial state to local file filename. The format is guessed from the extension of filename.
See also
EXPORT_SUPPORTED_EXTENSIONS
, and similar methodexport()
Examples:
>>> m.save_as("mymodel.an") # save to a local file in Pint native format >>> m.save_as("mymodel.ll") # export in PEP format (Petri net)

summary
(model) Returns a dictionnary with various information on the AN model:
"nb_automata"
: number of automata (equivalent to len(m.automata))"nb_local_states"
: total number of local states"max_local_states"
: largest number of local states within one automaton."nb_transitions"
: number of local transitions"nb_states"
: total number of states
Return type: dict

See also
Model
 Complete API
InitialState
 Initial state API