ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/osprai/osprai/trunk/test.py
(Generate patch)
# Line 9 | Line 9
9   sys.path.append("/home/clausted/Dropbox/ISB/subversion/osprai/trunk")
10  
11   ## Import libaries
12 + import os
13 + import numpy as np
14 + ## Import Osprai libraries.
15   import ba_class
16   import vu_module
17   import io_module
# Line 30 | Line 33
33  
34   def test_io_module():
35      print "Loading SPR data files..."
36 +    os.chdir("exampledata")
37      ba1 = readbiosensor("example-biosensor.txt")
38      ba1 = readicmtxt("example-icm.txt")
39      ba1 = readsprit("example-sprit.txt")
# Line 38 | Line 42
42      writesprit(ba1,"testwritesprit.txt")
43      writeclamp(ba1,"testwriteclamp.txt")
44      writebiosensor(ba1, "testwritebiosensor.txt")
45 +    os.chdir("..")
46      print "Done with test_io_module."
47      return
48      
49   def test_cal_module_vu_module():
50      print "Loading an SPR data file..."
51 <    ba1 = readicmtxt("example-icm.txt")
51 >    ba1 = readicmtxt("./exampledata/example-icm.txt")
52      
53      print "Plotting the raw data file..."
54      dotgraph(ba1)
# Line 199 | Line 204
204      return
205  
206  
207 + def test_noisy_fit():
208 +    print "test_noisy_fit"
209 +    ## Create a ba1 with a single ROI.
210 +    ba1 = BiosensorArray(1,300)
211 +    roi = ba1.roi[0]
212 +    ## Simple 1to1 binding curve.
213 +    ## Note KD = 2.2e-2 / 4.4e-4 = 5e-7, log10(5e-7) = -6.3
214 +    roi.simulate(bulkRI=0.0, kon=4.4e4, koff=2.2e-2, conc=7.7e-7)
215 +    ## Add 5 units of noise.
216 +    params = dict(rms=dict(value=5))
217 +    roi.value = noise(roi.time, roi.value, params)
218 +    ## Create a copy ba2 and use for fitting three parameters.
219 +    ba2 = deepcopy(ba1)
220 +    roi = ba2.roi[0]
221 +    roi.model = simple1to1
222 +    roi.params = simple1to1_def_params()
223 +    roi.params['rmax']['fixed'] = 'float'
224 +    roi.params['kon']['fixed'] = 'float'
225 +    roi.params['koff']['fixed'] = 'float'
226 +    roi.params['conc']['value'] = 7.7e-7
227 +    print roi.params
228 +    ## Fit.
229 +    #mclma(ba2.roi, maxiter=15, verbose=False)
230 +    mclma(ba2.roi)
231 +    roi.value = zeros(len(roi.value))
232 +    roi.value = roi.model(roi.time, roi.value, roi.params)
233 +    ## View
234 +    dualgraph(ba1, ba2, "Fit to noisy data")
235 +    kD = float(roi.params['koff']['value']) / float(roi.params['kon']['value'])
236 +    print "The expected value is -6.3. The fitted value is:"
237 +    print round((np.log10(kD)), 1)
238 +    return
239 +
240  
241   ## Run selected test or tests.
242 +
243   #test_io_module()
244   #test_cal_module_vu_module()
245 +
246   #demo_mtl()
247   #test_mdl_module_fit_module()
248 < test_mdl_module_series()
248 > #test_mdl_module_series()
249 > test_noisy_fit()
250 >
251  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines