booldog.boolean

Submodules

Classes

BooleanNetworkMixin

Class for Boolean network functions.

BooleanNetworkModificationMixin

Mixin class to modify a Boolean network.

Package Contents

class booldog.boolean.BooleanNetworkMixin

Class for Boolean network functions.

This class is not intended to be used directly, but rather as a mixin.

get_primes()

Get prime implicants

Returns:

primes – Prime implicants of the Boolean network.

Return type:

dict

get_rule(node_id)

Get the rule for a given node.

Parameters:

node (str or BoolDogNode) – Node identifier or BoolDogNode object.

Returns:

The rule for the given node.

Return type:

str

primes_to_matrices() tuple[numpy.ndarray, numpy.ndarray]

Represent Boolean network a “activation” and “inhibition” matrices.

Returns:

  • act (np.array) – n * n matrix with entry m_{i, j} = 1 iff node_j activates node_i

  • inh (np.array) – n * n matrix with entry m_{i, j} = 1 iff node_j inhibits node_i

Notes

Only if graph is of type threshold (i.e. SQUAD) does this make sense. Used in SquadODE Create logic matrices

generate_states(fixed=None)

Generate all possible states of the graph.

Parameters:

fixed (dict) – A dictionary of {node:state} to be kept fixed, with node in graph.nodes, and state in {0, 1}.

Yields:

state (np.array) – length n array with a state of the graph.

inactivate_state()

A state space with all nodes inactive

activate_state()

A state space with all nodes active

boolean_simulation(initial_states=None)

Compute a Boolean simulation (or state transition) from optional initial values.

Parameters:

initial_states (int, str, list, dict, or BooleanStateSpace, optional) – Initial states, see Notes for format

Notes

This is a wrapper for pyboolnet.state_transition_graphs.primes2stg, and therefore takes the same argument format for initial states.

From pyboolnet documentation:

Either a list of states in dict or str format::

    init = ["000", "111"]
    init = ["000", {"v1":1,"v2":1,"v3":1}]

or as a function that is called on every state and must return
either True or False to indicate whether the state ought to be initial::

    init = lambda x: x["v1"]>=x["v2"]

or by a subspace in which case all the states contained in it are
initial::

    init = "--1"
    init = {"v3":1}
standard_states_format(states)

Notes

https://github.com/hklarner/pyboolnet/blob/529860bc1185277fb2b5e0f3b36c9ba6c7b9fe2f/pyboolnet/state_transition_graphs.py#L124-L135

steady_states()

All steady states of the Boolean graph.

get_parents(node_id)

Fetch regulators/inputs to a node

Parameters:

node (str) – Node name

Returns:

parents – Set of parent nodes

Return type:

set

get_interactions(direction='out')

direction out: interactions[a][b] a –> b direction in: interactions[a][b] a <– b

is_constant(node_id)

Whether node is a constant (has no input) in the network.

Parameters:

node_id (str) – Node identifier

Returns:

constant – Whether node is a constant

Return type:

bool

Notes

This is a wrapper for pyboolnet.prime_implicants.is_constant.

list_network_inputs()

List all nodes that have no regulators/inputs in the network.

Returns:

inputs – List of input node names

Return type:

list

Notes

class booldog.boolean.BooleanNetworkModificationMixin

Mixin class to modify a Boolean network. This class is not intended to be used directly, but rather as a mixin.

_track_network_modifications(modification_type, node_id, rule=None)

Keep track of network modifications

_update_model_object(uncache_primes=True)

Update the model attributes after a modification.

modify_network(modifications)

Modify the network according to the given modifications.

Parameters:

modifications (list) – List of Modification objects.

Returns:

The network is modified in place.

Return type:

None

Notes

Each Modification object must have the following attributes: - modification_type : str

Type of modification. One of “add_node”, “remove_node”, “update”.

  • nodestr or list

    Name of node(s) to modify.

  • rulestr or None

    Rule to define the update function of node, in bnet form. All nodes in rule need to be defined in Network.

The modifications are applied in the order they are given. A node cannot be removed if other nodes depend on it (i.e. it occurs in their update logic). To remove such a node, either also remove all of its dependants, or first update the logic rule of its dependants to remove dependency.

This is a wrapper for pyboolnet.prime_implicants.create_variables and pyboolnet.prime_implicants.remove_variables.

remove_node(node_id)

Removes node from the network.

Parameters:

node (str) – Names of node to remove

Return type:

None

Notes

A node cannot be removed if other nodes depend on it (i.e. it occurs in their update logic). To remove such a node, either also remove all of its dependants, or first update the logic rule of its dependants to remove dependency.

This is a wrapper for pyboolnet.prime_implicants.remove_variables.

_test_node_removabilty(node_ids)

Test if a node (set) can be removed from the network.

remove_nodes(node_ids)

Removes all nodes in node_ids from the network.

Parameters:

node_ids (list) – List of identifiers of nodes to remove

Return type:

None

Notes

A node cannot be removed if other nodes depend on it (i.e. it occurs in their update logic). To remove such a node, either also remove all of its dependants, or first update the logic rule of its dependants to remove dependency.

This is a wrapper for pyboolnet.prime_implicants.remove_variables.

add_node(node_id, rule, name=None)

Add a new node to Network.

Parameters:
  • node (str) – Node name

  • rule (str) – Rule to define update of node, in bnet form. All nodes in rule need to be defined in Network.

Returns:

  • None

  • This is a wrapper for pyboolnet.prime_implicants.create_variables.

update_node(node_id, rule, modification_type=ModificationTypes.UPDATE)

Update (modify) or add the logic rule defining the update of node. If node does not yet exist, it will be added, if it does exist, its update logic will be overwritten.

Parameters:
  • node_id (str) – Node identifier

  • rule (str) – New rule to define update of node, in bnet form. All nodes in rule need to be defined in Network.

Returns:

  • None

  • This is a wrapper for pyboolnet.prime_implicants.create_variables.