:py:mod:`BioSANS2020.model.param_est.param_slider` ================================================== .. py:module:: BioSANS2020.model.param_est.param_slider .. autoapi-nested-parse:: This module is the param_slider module The sole purpose of this module is to visually modify parameters and compare the result to a PLOTTED data as the estimate changes in the plot The functions in this modules are; 1. load_data 2. param_ode_model 3. update_range 4. submit 5. update 5. param_ode_int Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: BioSANS2020.model.param_est.param_slider.load_data BioSANS2020.model.param_est.param_slider.param_ode_model BioSANS2020.model.param_est.param_slider.update_range BioSANS2020.model.param_est.param_slider.submit BioSANS2020.model.param_est.param_slider.update BioSANS2020.model.param_est.param_slider.param_ode_int .. py:function:: load_data() This function reads the trajectory file containing the data which should follow the following example format; time A B 0.0 100.0 0.0 0.25 88.24969025197632 11.750309748023732 0.5 77.88007831231087 22.119921687689185 0.75 68.72892784164061 31.27107215835944 1.0 60.65306592491437 39.346934075085684 1.25 53.526142785532 46.473857214468055 1.5 47.236655135816875 52.76334486418318 1.75 41.68620193454698 58.31379806545308 2.0 36.78794415253036 63.21205584746969 2.25 32.46524678349081 67.53475321650924 ... The format above have a header where the first column is time and all other columns are species or components. The rows are the values of measurements corresponding to the header. Each row is delimited by tab character " ". If the data file is in excel, just copy the data from excel to a text editor, save it with a filename and it will already be tab delimited. If there are several replicates of the data, just append them to the end without the header and this function can still handle all replicates. time A B 0.0 100.0 0.0 # first replicate ... # continuation 0.0 100.0 0.0 # second replicate ... # continuation Args: file (string, optional): trajectory file. Defaults to None. Returns: tuple: tuple of data and labels (data, labels). The data is a list of all the trajectories in the file and the labels are the corresponding name of the columns in the trajectory .. py:function:: param_ode_model(z_var, _, sp_comp, ks_dict, r_dict, p_dict, v_stoich, molar=False) This fuction returns the differential equation of components with respect to time. Args: z_var (list): list of initial concentration tvar (list): time stamp of trajectories i.e. [0, 0.1, 0.2, ...] sp_comp (dict): dictionary of appearance or position of species or component in the reaction tag of BioSANS topology file. For example; #REACTIONS A => B, -kf1 # negative means to be estimated B => C, kf2 The value of sp_comp is sp_comp = {'A': {0}, 'B': {0, 1}, 'C': {1}} A appears in first reaction with index 0 B appears in first and second reaction with index 0, 1 C appears in second reaction with index 1 ks_dict (dict): dictionary of rate constant that appears in each reactions. For example; #REACTIONS A => B , 0.3 # first reaction B <=> C, 0.1, 0.2 # second reaction The value of ks_dict is ks_dict = { 0 : [0.3], # first reaction 1 : [0.1, 0.2] # second reaction } r_dict (dict): dictionary of reactant stoichiometry. For example r_dict = { 0: {'A': 1}, # first reaction, coefficient of A is 1 1: {'B': 1} # second reaction, coefficient of B is 1 } p_dict (dict): dictionary of product stoichiometry. For example p_dict = { 0: {'B': 1}, # first reaction, coefficient of B is 1 1: {'C': 1} # second reaction, coefficient of C is 1 } v_stoich (numpy.ndarray): stoichiometric matrix. For example v_stoich = np.array([ [ -1, 0 ] # species A [ 1, -1 ] # species B [ 0, 1 ] # species C #1st rxn 2nd rxn ]) molar (bool, optional): If True, the units for any amount is in molar. Propensity will be macroscopic. Defaults to False. Returns: dxdt (numpy.ndarray): value of time derivatives of components .. py:function:: update_range(dk_var, valc) This function controls the parameter values in the plot and updates the limits of the slider object. Args: dk_var (matplotlib.widgets.Slider): Slider object that controls parameter values in plot valc (list): 2 item list of slider minimum and maximum value .. py:function:: submit(text, dk_var) This function prepares the 2 item list of slider minimum and maximum value. Args: text (string): The user defined range in the TextBox separated by comma i.e. "0.1,10" dk_var (matplotlib.widgets.Slider): Slider object that controls parameter values in plot .. py:function:: update(ks_dict, kk_list, fig, slabels, lvar, sp_comp, r_dict, p_dict, v_stoich, molar, t_var, z_var) [summary] Args: ks_dict (dict): dictionary of rate constant that appears in each reactions. For example; #REACTIONS A => B , 0.3 # first reaction B <=> C, 0.1, 0.2 # second reaction The value of ks_dict is ks_dict = { 0 : [0.3], # first reaction 1 : [0.1, 0.2] # second reaction } kk_list (list): list of matplotlib.widgets.Slider(Slider object) fig (matplotlib.pylab.figure): plt.subplots object slabels (list): list of components key in sp_comp lvar (list): list of matplotlib.pylab.plot or plt.plot objects sp_comp (dict): dictionary of appearance or position of species or component in the reaction tag of BioSANS topology file. For example; #REACTIONS A => B, -kf1 # negative means to be estimated B => C, kf2 The value of sp_comp is sp_comp = {'A': {0}, 'B': {0, 1}, 'C': {1}} A appears in first reaction with index 0 B appears in first and second reaction with index 0, 1 C appears in second reaction with index 1 r_dict (dict): dictionary of reactant stoichiometry. For example r_dict = { 0: {'A': 1}, # first reaction, coefficient of A is 1 1: {'B': 1} # second reaction, coefficient of B is 1 } p_dict (dict): dictionary of product stoichiometry. For example p_dict = { 0: {'B': 1}, # first reaction, coefficient of B is 1 1: {'C': 1} # second reaction, coefficient of C is 1 } v_stoich (numpy.ndarray): stoichiometric matrix. For example v_stoich = np.array([ [ -1, 0 ] # species A [ 1, -1 ] # species B [ 0, 1 ] # species C #1st rxn 2nd rxn ]) molar (bool, optional): If True, the units for any amount is in molar. Propensity will be macroscopic. Defaults to False. tvar (list): time stamp of trajectories i.e. [0, 0.1, 0.2, ...] z_var (list): list of initial concentration .. py:function:: param_ode_int(conc, t_var, sp_comp, ks_dict, r_dict, p_dict, v_stoich, molar=False, rfile='', set_p=None) [summary] Args: conc (dict): dictionary of initial concentration. For example; {'A': 100.0, 'B': -1.0, 'C': 0.0} negative means unknown or for estimation tvar (list): time stamp of trajectories i.e. [0, 0.1, 0.2, ...] sp_comp (dict): dictionary of appearance or position of species or component in the reaction tag of BioSANS topology file. For example; #REACTIONS A => B, -kf1 # negative means to be estimated B => C, kf2 The value of sp_comp is sp_comp = {'A': {0}, 'B': {0, 1}, 'C': {1}} A appears in first reaction with index 0 B appears in first and second reaction with index 0, 1 C appears in second reaction with index 1 ks_dict (dict): dictionary of rate constant that appears in each reactions. For example; #REACTIONS A => B , 0.3 # first reaction B <=> C, 0.1, 0.2 # second reaction The value of ks_dict is ks_dict = { 0 : [0.3], # first reaction 1 : [0.1, 0.2] # second reaction } r_dict (dict): dictionary of reactant stoichiometry. For example r_dict = { 0: {'A': 1}, # first reaction, coefficient of A is 1 1: {'B': 1} # second reaction, coefficient of B is 1 } p_dict (dict): dictionary of product stoichiometry. For example p_dict = { 0: {'B': 1}, # first reaction, coefficient of B is 1 1: {'C': 1} # second reaction, coefficient of C is 1 } v_stoich (numpy.ndarray): stoichiometric matrix. For example v_stoich = np.array([ [ -1, 0 ] # species A [ 1, -1 ] # species B [ 0, 1 ] # species C #1st rxn 2nd rxn ]) molar (bool, optional): If True, the units for any amount is in molar. Propensity will be macroscopic. Defaults to False. rfile (string, optional): name of topology file where some parameters or components are negative indicating they have to be estimated. Defaults to None. set_p (list, optional): 2 item list of [xscale log, yscale log] and maximum value. Defaults to None. Values can be any of [0,0],[0,1],[1,0],[1,1] Returns: [type]: [description]