Ejemplo n.º 1
0
def do_test(gate_name, time_to, initial):

    input_num = len(gates_data[gate_name]["input"])

    gate_dna_number = 10

    graph = {
        "nodes": [gate_name]+["INPUT"]*input_num, 
        "arcs": [{"from" :i, "to": 0} for i in range(1,input_num+1)], 
        "system_parameter":{"time": time_to},
        "simulation_parameters":[
            dict(
                [("device_parameter", {"initial":[gate_dna_number]*len(gates_data[gate_name]["parts"]["id"])})]+
                [(i["id"], i["params"]) for i in gates_data[gate_name]["map"]]
            )
        ]+[{"device_parameter":{"initial":[initial[i]]}} for i in range(input_num)]
    }

    #print "Simulating..."
    if '-d' in sys.argv:
        print "This bio-system is:"
        print graph

    reaction = bio_system(graph)
    if '-d' in sys.argv:
        print reaction.species
        reaction.show_reaction()
    reaction.simulation()

    record = reaction.record_list
    length = len(record["t"])
    record = dict([[i[0],sum(i[1])/length] for i in record.items()])
    reaction.num = record
    return reaction
Ejemplo n.º 2
0
 def test_system(self):
     [bio_system(i) for i in systems_data]
Ejemplo n.º 3
0
#!/usr/bin/env python
from django.test import TestCase

from data_test import system_data
from bio_system import bio_system
from stopwatch import sw_alloc, sw_start, sw_accmu, sw_print


systems_data = [
    {'simulation_parameters': [{'device_parameter': {'initial': [10, 10, 10]}, 'e5': {'reg': 20}, 'e4': {'reg': 20}, 'e6': {'decay1': 0.1, 'decay2': 0.05, 'trans1': 0.01, 'trans2': 0.5}, 'e1': {'decay1': 0.1, 'decay2': 0.05, 'trans1': 0.01, 'trans2': 0.5}, 'e3': {'decay1': 0.1, 'decay2': 0.05, 'trans1': 0.01, 'trans2': 0.5}, 'e2': {'reg': 20}}, {'device_parameter': {'initial': [0]}}], 'nodes': ['NOT3', 'INPUT'], 'system_parameter': {'time': 100}, 'arcs': [{'to': 0, 'from': 1}]},
    {'simulation_parameters': [{'device_parameter': {'initial': [10, 10, 10]}, 'e5': {'reg': 20}, 'e4': {'reg': 20}, 'e6': {'decay1': 0.1, 'decay2': 0.05, 'trans1': 0.01, 'trans2': 0.5}, 'e1': {'decay1': 0.1, 'decay2': 0.05, 'trans1': 0.01, 'trans2': 0.5}, 'e3': {'decay1': 0.1, 'decay2': 0.05, 'trans1': 0.01, 'trans2': 0.5}, 'e2': {'reg': 20}}, {'device_parameter': {'initial': [0]}}], 'nodes': ['NOT5', 'INPUT'], 'system_parameter': {'time': 100}, 'arcs': [{'to': 0, 'from': 1}]},
    {'simulation_parameters': [{'device_parameter': {'initial': [10, 10, 10]}, 'e8': {'decay1': 0.1, 'decay2': 0.05, 'trans1': 0.01, 'trans2': 0.5}, 'e5': {'reg': 20}, 'e4': {'reg': 20}, 'e7': {'decay1': 0.1, 'decay2': 0.05, 'trans1': 0.01, 'trans2': 0.5}, 'e6': {'decay1': 0.1, 'decay2': 0.05, 'trans1': 0.01, 'trans2': 0.5}, 'e1': {'decay1': 0.1, 'decay2': 0.05, 'trans1': 0.01, 'trans2': 0.5}, 'e3': {'reg': 20}, 'e2': {'reg': 20}}, {'device_parameter': {'initial': [0]}}, {'device_parameter': {'initial': [10]}}], 'nodes': ['OR1', 'INPUT', 'INPUT'], 'system_parameter': {'time': 100}, 'arcs': [{'to': 0, 'from': 1}, {'to': 0, 'from': 2}]}]

if __name__ == "__main__":
    sw_alloc('s')
    sw_start('s')
    reaction = bio_system(system_data)
    reaction.simulation()
    sw_accmu('s')
    sw_print('s')
    reaction.show_record(map(lambda x:"S"+str(x), range(len(reaction.nodes)))) 
    exit()
else:
    class TestSystem(TestCase):
        def test_system(self):
            [bio_system(i) for i in systems_data]