prime_implicants¶
- active_primes(primes: dict, subspace: Dict[str, int]) Dict[str, List[List[dict]]] ¶
returns all primes that are active in, i.e., consistent with subspace.
- copy_primes(primes: dict) dict ¶
Creates a copy of primes.
- arguments:
primes: prime implicants
- returns:
new_primes: a copy of primes
example:
>>> new_primes = copy_primes(primes)
- create_blinkers(primes: dict, names: Iterable[str], copy: bool = False) Optional[dict] ¶
Creates a blinker for every member of names. Variables that alrerady exist in primes are overwritten. A blinker is a variable with in-degree one and negative auto-regulation. Blinkers can therefore change their activity in every state of the transition system.
Note
Suppose that a given network has a lot of inputs, e.g.:
>>> len(find_inputs(primes)) 20
Since input combinations define trap spaces, see e.g. Klarner2015(b) Sec. 5.1, all of which contain at least one minimal trap space, it follows that the network has at least 2^20 minimal trap spaces - too many to enumerate. To find out how non-input variables stabilize in minimal trap spaces turn the inputs into blinkers:
>>> inputs = find_inputs(primes) >>> create_blinkers(primes, inputs) >>> tspaces = trap_spaces(primes, "min")
- arguments:
primes: prime implicants
names: variables to become blinkers
copy: change primes in place or copy and return
- returns:
new_primes if copy == True
example:
>>> names = ["p21", "p53"] >>> create_blinkers(primes, names)
- create_constants(primes: dict, constants: Dict[str, int], copy: bool = False) Optional[dict] ¶
Creates a constant in primes for every name, value pair in constants. Names that already exist in primes are overwritten.
- arguments:
primes: prime implicants
constants: names and values
copy: change primes in place or copy and return
- returns:
new_primes if copy == True
example:
>>> create_constants(primes, {"p53":1, "p21":0})
- create_disjoint_union(primes1: dict, primes2: dict) dict ¶
Creates a new primes dictionary that is the disjoint union of the networks represented by primes1 and primes2. Here, “disjoint” means that the names of primes1 and primes2 must not intersect.
- arguments:
primes1: prime implicants
primes2: prime implicants
- returns:
new_primes: the disjoint union of primes1 and primes2
example:
>>> primes1 = bnet2primes("A, B \n B, A") >>> primes2 = bnet2primes("C, D \n D, E") >>> primes = create_disjoint_union(primes1, primes2) >>> primes2bnet(primes) A, B B, A C, D D, E
- create_inputs(primes: dict, names: Iterable[str], copy: bool = False) Optional[dict] ¶
Creates an input for every member of names. Variables that already exist in primes are overwritten.
Note
Suppose that a given network has constants, e.g.:
>>> len(find_constants(primes))>0 True
Too analyze how the network behaves under all possible values for these constants, turn them into inputs:
>>> constants = find_constants(primes) >>> create_inputs(primes, constants)
- arguments:
primes: prime implicants
names: variables to become constants
copy: change primes in place or copy and return
- returns:
new_primes if copy == True
example:
>>> names = ["p21", "p53"] >>> create_inputs(primes, names)
- create_variables(primes: dict, update_functions: Dict[str, Union[callable, str]], copy: bool = False) Optional[dict] ¶
Creates the variables defined in update_functions and add them to primes. Variables that already exist in primes are overwritten. Raises an exception if the resulting primes contain undefined variables. The update_functions are given as a dictionary of names and functions that are either a bnet string or a Python callable.
- arguments:
primes: prime implicants
update_functions: a dictionary of names and update functions
copy: change primes in place or copy and return
- returns:
new_primes if copy == True
example:
>>> primes = bnet2primes("A, A") >>> create_variables(primes, {"B": "A"}) >>> create_variables(primes, {"C": lambda A, B: A and not B}) >>> primes2bnet(primes) A, A B, A C, A&!B
- find_constants(primes: dict) Dict[str, int] ¶
Finds all constants in the network defined by primes.
- arguments:
primes: prime implicants
- returns:
constants: the names and activities of constants
example:
>>> find_constants(primes) {"CGC":1,"IFNAR1":1,"IFNAR2":0,"IL4RA":1}
- find_inputs(primes: dict) List[str] ¶
Finds all inputs in the network defined by primes.
- arguments:
primes: prime implicants
- returns:
names: the names of the inputs
example:
>>> find_inputs(primes) ["DNA_damage","EGFR","FGFR3"]
- find_outputs(primes: dict) List[str] ¶
Finds all outputs in the network defined by primes.
- arguments:
primes: prime implicants
- returns:
names: the names of the outputs
example:
>>> find_inputs(primes) ["Proliferation","Apoptosis","GrowthArrest"]
- find_predecessors(primes: dict, targets: Iterable[str]) List[str] ¶
Finds all predecessors of targets in primes.
- arguments:
primes: prime implicants
targets: compute predecessors of these nodes
- returns:
predecessors: the predecessors
example:
>>> find_predecessors(primes) ["ERK", "MEK", "RAF"]
- find_successors(primes: dict, sources: Iterable[str]) List[str] ¶
Finds all successors of sources in primes.
- arguments:
primes: prime implicants
sources: compute successors of these nodes
- returns:
successors: the successors
example:
>>> find_successors(primes) ["ERK", "MEK", "RAF"]
- get_constant_primes(value: int) List[List[dict]] ¶
Gets the prime implicants for a constant of give value.
- arguments:
value: either 0 or 1
- returns:
implicants: the implicants
example:
>>> primes[name] = get_constant_primes(value=1)
- is_constant(primes: dict, name: str) bool ¶
Decides whether name is a constant in primes.
- arguments:
primes: prime implicants
name: the component
- returns:
constant: whether name is constant
example:
>>> is_constant(primes, "MEK") False
- list_input_combinations(primes: dict, format: str = 'dict') Union[List[str], List[dict]] ¶
A generator for all possible input combinations of primes. Returns the empty dictionary if there are no inputs.
- arguments:
primes: prime implicants
format: format of returned subspaces, “str” or “dict”
- returns:
subspaces: input combination in desired format
example:
>>> for x in list_input_combinations(primes, "str"): print(x) 0--0-- 0--1-- 1--0-- 1--1--
- percolate(primes: dict, add_constants: Optional[Dict[str, int]] = None, remove_constants: bool = False, max_iterations: Optional[int] = None, copy: bool = False) Optional[dict] ¶
Detects constants in primes and percolates their values.
- arguments:
primes: prime implicants
max_iterations: max number of components to fix during percolation
add_constants: create new constants before percolation
remove_constants: remove constants after percolation
copy: change primes in place or copy and return
- returns:
new_primes if copy == True
example:
>>> new_primes = percolate(primes, copy=True)
- primes_are_equal(primes1: dict, primes2: dict) bool ¶
Tests whether primes1 and primes2 are equal. The dictionary comparison primes1 == primes2 does in general not work because the clauses of each may not be in the same order.
- arguments:
primes1, primes2: prime implicants
- returns:
answer: whether primes1 == primes2
example:
>>> primes_are_equal(primes1, primes2) True
- remove_all_constants(primes: dict, copy: bool = False) Optional[dict] ¶
Removes all constants from primes.
- arguments:
copy: change primes in place or copy and return
- returns:
new_primes if copy == True
example:
>>> remove_all_constants(primes)
- remove_all_variables_except(primes: dict, names: Iterable[str], copy: bool = False) Optional[dict] ¶
Removes all variables except those in names from primes. Members of names that are not in primes are ignored. Note that names must be closed under the predecessors relation, i.e., it must be a set of variables that contains all its predecessors.
- arguments:
primes: prime implicants
names: the names of variables to keep
copy: change primes in place or copy and return
- returns:
new_primes if copy == True
example:
>>> names = ["PKC", "GADD45", "ELK1", "FOS"] >>> remove_all_variables_except(primes, names)
- remove_variables(primes: dict, names: Iterable[str], copy: bool = False) Optional[dict] ¶
Removes all variables contained in names from primes. Members of names that are not in primes are ignored. Note that names must be closed under the successors relation, i.e., it must be a set of variables that contains all its successors.
- arguments:
primes: prime implicants
names: the names of variables to remove
copy: change primes in place or copy and return
- returns:
new_primes if copy == True
example:
>>> names = ["PKC", "GADD45", "ELK1", "FOS"] >>> remove_variables(primes, names)
- rename_variable(primes: dict, old_name: str, new_name: str, copy: bool = False) Optional[dict] ¶
Renames a single component, i.e., replace every occurence of old_name with new_name. Throws an exception if new_name is already contained in primes.
- arguments:
primes: prime implicants
old_name: the old name of the component
new_name: the new name of the component
copy: change primes in place or copy and return
- returns:
new_primes if copy == True
example:
>>> names = ["PKC", "GADD45", "ELK1", "FOS"] >>> remove_all_variables_except(primes, names)
- update_primes(primes: dict, name: str, constants: dict, copy: bool = False) Optional[dict] ¶
Updates the primes of the component name given the constants.
- arguments:
primes: prime implicants
name: name of the component to update
constants: the assumed constants
copy: change primes in place or copy and return
- returns:
new_primes if copy == True
example:
>>> primes["ERK"] = update_primes(primes, name="ERK", subspace={"MEK": 1, "RAF": 0})