(Generate patch)
# Line 22 | Line 22
22    anti-IgG
23    >>> ba1 = BiosensorArray(1, 300)
24    >>> ba1.roi[0].simulate(bulkRI=1000, kon=1e4, koff=1e-2, conc=1e-6)
25 <  >>> print round(ba1.roi[0].value[299], 2)
26 <  160.64
25 >  >>> print round(ba1.roi[0].value[299], 1)
26 >  160.6
27   """
28 < __version__ = "110426"
28 > __version__ = "110518"
29
30
31   ## Import libraries.
# Line 83 | Line 83
83      """End of BiosensorArray class definition."""
84
85
86 +
87 +
88   class RegOfInterest(object):
89      """
90      This Region Of Interest class can hold one SPR sensorgram.
# Line 150 | Line 152
152          ## Example params = {'Rmax': {'value':1, 'min':0, 'max':10, 'fixed':'float'} }
153          self.model = None    ## Model describing this roi. Reference to a function.
154          self.params = []     ## Parameters for this model. A dictionary of dictionaries.
155 +        return
156
157 +
158      def time2dp(self, t):
159 <        """Find datapoint closest to given time."""
159 >        """
160 >        Find datapoint closest to given time. For example::
161 >
162 >          >>> ba1 = BiosensorArray(1, 300)
163 >          >>> ba1.roi[0].simulate()
164 >          >>> print ba1.roi[0].time2dp(40.333)
165 >          40
166 >        """
167          pos2 = self.time.searchsorted(t)    ## Time point just after t.
168          pos2 = min(pos2, len(self.time)-1)  ## Avoid indexing error.
169          pos1 = max(pos2-1,0)                ## Time point just before t.
# Line 163 | Line 174
174              return pos2
175          else:
176              return pos1
177 <
177 >
178 >
179      def time2val(self, t1, t2):
180 <        """Return list of SPR values between t1 and t2"""
180 >        """
181 >        Return list of SPR values between t1 and t2. For example::
182 >
183 >          >>> ba1 = BiosensorArray(1, 300)
184 >          >>> ba1.roi[0].simulate()
185 >          >>> print min(ba1.roi[0].time2val(35, 65))
186 >          1000.0
187 >        """
188          dp1, dp2 = self.time2dp(t1), self.time2dp(t2)
189          return [self.value[i] for i in range(dp1, dp2)]
190 <
191 <    def simulate(self, bulkRI=1000, kon=1e4, koff=1e-2, conc=1e-6):
190 >
191 >
192 >    def simulate(self, bulkRI=1000., kon=10000., koff=.01, conc=.000001):
193          """
194 <        Fill ROI with simulated data from simple 1:1 binding.
195 <
196 <        The following parameters are hard-coded.
197 <
198 <          * Time 35 - 65 s features jump of ``bulkRI``.
199 <          * Time 100 - 200 s has binding using ``kon``, ``conc``.
200 <          * Also jump of ``bulkRI`` / 10.
201 <          * Time 200 - 300 s has dissociation using koff.
182 <
183 <        The model formulas are::
194 >        Fill ROI with 300 s of simulated data from simple 1:1 binding.
195 >        First, there is a brief calibration injection from 35 to 65 s
196 >        that appears as a square wave of height ``bulkRI``.
197 >        At time 100 s, there is a jump of 10% ``bulkRI`` followed by
198 >        binding at a rate dependent on ``kon`` and ``conc``.
199 >        At time 200 s, dissociation occurs at rate ``koff``.
200 >        The maximum response (Rmax) is fixed at 1000 units.
201 >        The model is based on these equations::
202
203            alpha = c*kon+koff
204            Req = Rmax*c*kon / alpha
# Line 220 | Line 238
238      """
239      import doctest
240      doctest.testmod(optionflags=doctest.ELLIPSIS)
241 +    return
242
243
244   if __name__ == "__main__":

### Diff Legend

 – Removed lines + Added lines < Changed lines > Changed lines