%------------------- LineShapeKin MODEL_SETUP -----------------------------
%-- version 3.0 
%
% 3/11/08
% Written by Evgenii Kovrigin, Medical College of Wisconsin


%  This is the model where I only fit Kd and Koff - not scale factor! I
%  assume you already fit your data in a 'single' mode and adjusted the
%  scaling of the data in 'scale_factor.txt' for every peak.


%
% This file contains model-specific parameters. You edit this file if you
%   want to change your fitting model. 
%
%  X_columns is a structure that
%      specifies column positions of protein concentration, ligand/protein
%      ratio, relaxation rates, peak positions, temperature etc.
%
%  B_vector
%      is a structure that specifies positions of variable for fitting such
%      as Koff, scale_factor, Kd, activation energy etc.
%
%  Model_description
%     is a structure that contains additional information on the fitting
%     model
%
%  This file sets these variables global so for fitting functions to access
%  them.
%
% 3/29/08 - Dataset ID column added
%               - switcheable Scale Factor fitting

global YES NO X_columns B_vector Model;

%% Definition of the 'Xcomposite' array of experimental data

X_columns.number= 9;  %-- Enter here total number of columns used in 
                                        %    'Xcomposite' matrix of
                                        %    experimental conditions (see
                                        %    prepare_residue_data.m)

%-- Enter here positions the specific data columns appear in the 'Xcomposite' vector                                        
X_columns.Ptotal  =1;
X_columns.LPratio=2;
X_columns.Xtotal = 3;
X_columns.R2A    = 4;
X_columns.R2B    = 5;
X_columns.wA     = 6;
X_columns.wB     = 7;
X_columns.Temp= 8;
X_columns.DataID= 9;   



%% Model description
Model.name = 'Two-site exchange (fitted Kd)';


% Starting and fixed parameters of the fitting model

%-- list corresponding Kds here If the model does fitting of Kd then
%     this number is used as a starting parameter. If the grid search
%     (below) is requested for the parameter then its value here is
%     disregarded and taken from B_vector.grid_values

Model.Kd  = 1.40e-6 ;  %-- [M]
%- if Kd is variable set these
Model.Kd_min=0; 
Model.Kd_max=10e10;

%-- list corresponding koffs here to be used as a starting parameter.
Model.Koff    =     100 ;  %-- /s 
Model.Koff_min=0; 
Model.Koff_max=10e10;

%--- correction factor for intensity of spectra (to compensate for
%      imprecise normalization)
Model.scale_factor = 1.0; 
Model.scale_factor_min = 0;  
Model.scale_factor_max = 1e9;  




%% Definition of the 'beta' vector:   variable parameters in the model to
%    fit.

%--  Generate starting 'beta' vector
B_vector.starting_values = [ Model.Kd, Model.Koff];
B_vector.min = [ Model.Kd_min, Model.Koff_min];
B_vector.max = [ Model.Kd_max, Model.Koff_max];
B_vector.parameter_names= { 'Kd' , 'Koff'};


%--  Assign here the positions of the fitting parameters in the 'beta'
%     vector to use in when addressing the vector
B_vector.fit_scale_factor=NO;  
B_vector.Kd = 1;
B_vector.Koff = 2;
%B_vector.scale_factor = 3;

%---- Setting the grid values to start fitting from when searching for global
%        minimum
B_vector.grid_search_parameter=B_vector.Koff;
B_vector.grid_values=[ 0.1 100 1e5 ];
%B_vector.grid_values=[ 100  ];

