I'm performing a simulation of protein-protein interactions. I'm using Python to code logic gates as functions to model protein interactions.
My model is basically a series of groups (g0 to g4) containing logic gates (see image). Initially, I set up a list containing my groups, and then for each group a dict that contains proteins (nodes) with their starting values (their so-called seedValues, which are the starting parameters for the network at $t=0$).
My question is this: is there some way of iterating through my groups (and their logic gate functions), that begins at group 0 (g0 in the image) at t, and that at t=t+1 executes groups g0 and g1 synchronously, then executes the three groups g0, g1 and g2 at t=t+2, and so on until t=m, where m is the number of iterations wanted?
Image notes: A and B are switches (the program is supposed to change them, as a way of studying perturbations), C is a constant (never changed). J is the output (mostly for show). D and F are built that way to oscillate, whenever A = 0.
I've understood that threading might be the solution to my problem, but before I dive into that I'm interested in finding a simpler way of solving this.
Because I don't know how to formulate this in Python, I attach some extremely messy pseudocode:
#setting starting conditions
#g is starting group
#m is max number of iterations
#t is time
#u is the number of nodes
#v is the number of groups
g = m = t = 0
u = x (where x is the number of nodes in the model)
v = y (where y is the number of groups in the model)
#implement node iterator
nodeChecker():
timeStep():
t = t + 1
nodeExecute(p):
#p is the number of groups to execute over, in the interval 1 <= g <= v (p=1 is group 1, p=2 is group 1 and 2, ...)
execute all nodes inside selected group(s)
timeStep()
printResults():
print results of execution of nodes at time of execution
print state of unexecuted groups (minus current group(s)) #print the seedValue states of network before execution
at time t, execute nodes in g
nodeExecute(1)
printResults()
at time t+1, execute nodes in g and g+1
nodeExecute(2)
printResults()
...
at time t = m, execute nodes in group g, g+1 ... g+(u-1)
nodeExecute(g+(u-1))
printResults()
stop execution
Code note: 1 <= g <= v is the interval $1 \leq$ g $\leq$ v. x and y aren't code variables; the notation is supposed to indicate u = $x$ and v = $y$.
My ambition is to output something like:
t 0 1 2 ... m
node1 0 1 0 1
node2 1 1 0 0
node3 0 0 1 0
Thank you for your time.