Skip to content

Instantly share code, notes, and snippets.

@daemontus
Created April 4, 2022 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daemontus/81b39cb1a8c40a1f33186fe7aeee93c2 to your computer and use it in GitHub Desktop.
Save daemontus/81b39cb1a8c40a1f33186fe7aeee93c2 to your computer and use it in GitHub Desktop.
# pip install biodivine_aeon
from biodivine_aeon import *
from pathlib import Path
import sys
model_string = Path(sys.argv[1]).read_text()
# Parse `model_string` as `.aeon` model file.
bn = BooleanNetwork.from_aeon(model_string)
# Get the underlying `RegulatoryGraph` of the `BooleanNetwork`.
# (Some basic functions are implemented for both BN and RG, but
# some more specific stuff is only available for the RG object)
rg = bn.graph()
# Note that we have a "VariableId" and "ParameterId" (parameter=uninterpreted function)
# objects that identify variables/parameters (this is mostly a technicality from
# Rust, where using string names for everything would likely perform poorly). Typically, when
# the API returns a variable, it returns it as a "VariableId". However, all Python
# functions that take a variable will also accept a string name. So if you have a known or
# fixed network, you can mostly use names as well as IDs.
# List all regulations in a file, grouped by the target variable:
for target in rg.variables():
print(" > Regulations targeting", rg.get_variable_name(target))
for regulator in rg.regulators(target):
print(" > ", rg.get_variable_name(regulator), "regulates", rg.get_variable_name(target))
regulation = rg.find_regulation(regulator, target)
# 'activation' / 'inhibition' / None
print(" > Monotonicity:", regulation['monotonicity'])
# True/False
print(" > Essential:", regulation['observable'])
# Also can list regulations grouped by regulator variable using `rg.targets(regulator)`.
# Or simply go through all regulation objects in arbitrary order using `rg.regulations()`.
# List all update functions.
for variable in bn.variables():
# A string representing the function, or None if the function is undefined.
function = bn.get_update_function(variable)
print("Function of", rg.get_variable_name(variable), "is:", function)
# List all named uninterpreted functions in the model.
# (completely unknown update functions are not included - only the ones that
# explicitly appear as part of a larger function expression)
for parameter in bn.parameters():
print("Uninterpreted function", bn.get_parameter_name(parameter), "has arity", bn.get_parameter_arity(parameter))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment