ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/osprai/osprai/trunk/test.py
Revision: 26
Committed: Fri May 14 22:36:12 2010 UTC (9 years, 7 months ago) by clausted
File size: 2695 byte(s)
Log Message:
Added mass-transport limitation model simple1to1_mtl.

Line User Rev File contents
1 clausted 7 """
2     Christopher Lausted, Institute for Systems Biology
3 clausted 20 Last modified on 100425 (yymmdd)
4 clausted 23 Small script to test various OSPRAI components.
5 clausted 7 """
6    
7 clausted 23 ## Import libaries
8     import ba_class
9     import vu_module
10     import io_module
11     import cal_module
12     import mdl_module
13     import fit_module
14 clausted 26 import osprai_one
15 clausted 19 ## Reload Osprai libraries in case code has changed.
16 clausted 23 reload(ba_class)
17     reload (vu_module)
18     reload(io_module)
19     reload(cal_module)
20     reload(mdl_module)
21     reload(fit_module)
22 clausted 26 reload(osprai_one)
23 clausted 23 ## Or just import this next one...
24     from osprai_one import *
25 clausted 7
26 clausted 23
27 clausted 19 print "Test the model module..."
28 clausted 23 ba0 = BiosensorArray(1,300) ## Create ba1 with one ROI and 300 datapoints.
29 clausted 19 roi0 = ba0.roi[0]
30 clausted 23 roi0.time = arange(300, dtype=float) ## Samples every 1 second.
31     roi0.value = zeros(300, dtype=float) + 20 ## Baseline signal is 20 units.
32 clausted 20 roi0.params = {'t1': {'value':30.0, 'min':30.0, 'max':30.0, 'fixed':True} }
33 clausted 19 roi0.params['rmax'] = {'value': 100.0}
34     roi0.params['conc'] = {'value': 1e-6}
35     roi0.params['kon'] = {'value': 2e4}
36     roi0.params['t2'] = {'value': 150.0}
37     roi0.params['koff'] = {'value': 1e-3}
38     roi0.params['t3'] = {'value': 270.0}
39 clausted 23 roi0.model = simple1to1
40 clausted 19 roi0.value =roi0.model(roi0.time, roi0.value, roi0.params)
41 clausted 23 linegraph(ba0, "Simulation")
42 clausted 19
43 clausted 24 ba1 = copyinterval(ba0, 20, 240)
44     linegraph(ba1, "Trimmed")
45     exit()
46    
47 clausted 19 print "Testing the fitting..."
48     ba1 = deepcopy(ba0)
49     roi0 = ba1.roi[0]
50 clausted 20 roi0.params['koff'] = {'value':1.0e-2, 'min':1e-8, 'max':1e-1, 'fixed':False}
51     roi0.params['kon'] = {'value':1.0e2, 'min':1e1, 'max':1e8, 'fixed':False}
52     roi0.params['rmax'] = {'value':50, 'min':1, 'max':90, 'fixed':False}
53 clausted 23 clma(roi0)
54 clausted 19 roi0.value =roi0.model(roi0.time, roi0.value, roi0.params)
55 clausted 23 dualgraph(ba0, ba1, "Fitted Data with an incorrect Rmax parameter")
56     #exit()
57 clausted 19
58    
59 clausted 14 print "Loading an SPR data file..."
60 clausted 23 #ba1 = readbiosensor("example-biosensor.txt")
61     ba1 = readicmtxt("example-icm.txt")
62     #ba1 = readsprit("example-sprit.txt")
63     #ba1 = applykey(ba1, "example-key.tsv")
64 clausted 11 #ba1.set_plot_all()
65     #ba1.set_plot_list(range(6))
66     #ba1.plot()
67 clausted 7
68 clausted 23 #writesprit(ba1,"testwritesprit.txt")
69     #writeclamp(ba1,"testwriteclamp.txt")
70     #writebiosensor(ba1, "testwritebiosensor.txt")
71 clausted 7
72 clausted 14 print "Plotting the raw data file..."
73 clausted 23 linegraph(ba1)
74     #dotgraph(ba1)
75     #dualgraph(ba1, ba1)
76 clausted 11
77 clausted 14 print "Plotting the calibrated data..."
78 clausted 23 ba2 = calibrate(ba1, ba1, 2850, 3120)
79     linegraph(ba2, "Calibrated SPR Data")
80 clausted 12
81 clausted 14 print "Use ROI #16 as background, subtract, and plot..."
82 clausted 23 bgset(ba2, 16)
83     ba2 = bgsubt(ba2)
84     linegraph(ba2, "Calibrated & Referenced SPR Data")
85 clausted 14
86     print "Test of scatterplot using time points 500, 1000, 1500, 2000"
87 clausted 23 scatterplot(ba2, 3600, 4200, 3600, 4700, "Scatterplot")
88 clausted 14
89     print "Done with test."