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