Exemplo n.º 1
0
def linear(n=2, k_in=1, k_out=1, k_fret=1):
    nodes = [objects.InputNode('node1', production_rate=k_in, emit_rate = 0.0, decay_rate=0.0)] + \
        [objects.Node(f'node{i}', emit_rate = 0.0, decay_rate = 0.0) for i in range(2, n)] + \
        [objects.Node(f'node{n}', emit_rate=k_out, decay_rate = 0.0)]

    for i in range(n - 1):
        nodes[i].add_input(nodes[i + 1], k_fret)
        nodes[i + 1].add_input(nodes[i], k_fret)

    return objects.Network(nodes)
Exemplo n.º 2
0
def network_from_rates(K_fret, k_out, k_in, k_decay = None):
    num_nodes = len(k_out)

    if k_decay is None:  k_decay = np.zeros(num_nodes)

    nodes = [object_utils.InputNode('node{}'.format(i), production_rate=k_in_i, emit_rate=k_out_i, decay_rate=k_decay_i) for i,(k_out_i,k_in_i, k_decay_i) in enumerate(zip(k_out, k_in, k_decay))]
    for i,j in it.product(range(num_nodes), range(num_nodes)):
        if i==j:  continue
        nodes[j].add_input(nodes[j], K_fret[i,j])

    return object_utils.Network(nodes)
Exemplo n.º 3
0
def generate_RBM_network(num_nodes, rate_matrix, input_rates, output_rates):
  rad = num_nodes*20
  center_x = rad + 50
  center_y = rad + 50
  node_pos = [
      (rad*np.cos(n/num_nodes*2*np.pi) + center_x, rad*np.sin(n/num_nodes*2*np.pi) + center_y)
      for n in range(num_nodes)
  ]

  nodes = [
      utils.InputNode('in{}'.format(n), production_rate=k_in, emit_rate=k_out)
      for n,(k_in,k_out) in enumerate(zip(input_rates, output_rates))
  ]

  # to be properly undirected, make sure the rate matrix is symmetric
  for i,j in it.product(range(num_nodes), range(num_nodes)):
    n1,n2 = nodes[i],nodes[j]
    n1.add_input(n2, rate_matrix[i,j])

  sim = gui.Simulator(nodes = nodes, node_pos = node_pos)
  return sim
Exemplo n.º 4
0
import numpy as np

# INTRAPACKAGE IMPORTS
sys.path.insert(0, os.path.dirname(os.path.dirname(
    os.path.abspath(__file__))))  # add parent directory to python path
from objects import utils

x_ON = sys.argv[1].upper() == 'ON'
y_ON = sys.argv[2].upper() == 'ON'
print('x: {}, y: {}'.format(x_ON, y_ON))

eps = 100
k_slow = 100
x = utils.InputNode('input1',
                    production_rate=eps**5 * k_slow * x_ON,
                    emit_rate=0.0)
y = utils.InputNode('input2',
                    production_rate=eps**5 * k_slow * y_ON,
                    emit_rate=0.0)
h = utils.Node('middle', emit_rate=0.0)
w = utils.Node('waste', emit_rate=k_slow * eps)
#w2 = utils.Node('waste2', emit_rate = k_slow)
z = utils.Node('output', emit_rate=k_slow * eps**5)
h.add_input(x, k_slow)
h.add_input(y, k_slow)
w.add_input(h, k_slow * eps**4)
#w2.add_input(w, k_slow*eps)
z.add_input(h, k_slow * eps**2)
nodes = [x, y, h, w, z]