%------------------- LineShapeKin SETUP  -----------------------------
%-- version 1.1 
%
% 3/21/08
% Written by Evgenii Kovrigin, Medical College of Wisconsin
%
% 3/22/08 - interfaced to Direct Parameter Mapping
% 3/25/08 - bugs fixed.
%
% 3/29/08 - data localization changed


% NOTE:  This 'setup.m' is STRICTLY SPECIFIC for a three-parameter model
%             where we fit Kd, Koff and w0_B with w0_B individual for every
%             residue. It is taken from corresponding array as a starting
%             value for fitting.  Here you CANNOT use GLOBAL fitting mode

global   YES NO ;


% Define enzyme concentration at each titration point. If your addition of
% ligand did not change volume - use the same number for all points
Ptotal = [ 530 530 530 530 530 530 530 530 530 530]*1.0e-6;  % M

% Total Ligand/Protein ratio at each titration point
LPratio = [ 0 0.0812 0.162 0.325 0.487 0.649 0.812 0.974 1.14 1.3];

%-- Temperatures (only used with temperature-dependent model. Otherwise -
%     ignored.
T =  ones(1,length(Ptotal)) *298;



% NOTE: If you need to exclude any points for a SPECIFIC residue from
% fitting (due to overlap) - edit  'titration_points.txt' file in the
% residue data folder. 


%--- Path do Sparky data folder
%Sparky_data_path='/Users/kovrigin/Documents/Workspace/Data/Data.XI/EKM7.LINESHAPEKIN_for_ENC_2008/Version_3.0/User_Data/DPM.Kd_koff_v0/Data_for_MatLab/';
Sparky_data_path='../Data_for_MatLab/';

%--- Folder where to save results
results_path='results'; 


%-- Enter here a list of residues to use ----

% -- cut-and-paste them from  Data_for_Matlab/matlab.peaklist ---
resnames =   {   'V108_x_w1', 'H12_x_w2', 'Y92_x_w1'};
w0_B = [  7133.32 4.73661e+03 8.04177e+03   ];


                    
residue_number=3  ; %--- particular residue in 'resnames' to look at
                    %  (read only in 'simulation',  'single',  'just display data' and 'Direct Parameter Mapping' mode) 

                    

%% --- MODE OF OPERATION ---

%project_name='simulation';  %-- calculate titration profile using provided R2 and w0 values

%project_name='just display data'; %- only do normalization and plotting of raw data
%project_name= 'single'; %- lets you fit just one of them
                                        %           in this case set residue_number=... desired number
                                        %           in all other cases this
                                        %           variable is disregarded
                                        
%project_name= 'individual' ; %- fit all of them individually to individual Koffs 

%project_name= 'global';%- fit all of them to one Koff

project_name= 'DPM';    %--- direct parameter mapping mode 



%% ===== DIRECT PARAMETER MAPPING modes ---


DPM_session='single';            %--- single residue calculation
%DPM_session= 'individual';     %---  calculation calculations on the entire set of 
                                                        %        residues.

%-- Choose mode of DPM operation     (these modes are used consequtively 
%     for convenience because 'computation' is run only once and takes a
%     long time, while 'analysis' is fast and may need to be rerun multiple
%     times with different SSD levels (see DPM_setup.m)

%DPM_mode='computation';   % computation of SSD matrices

DPM_mode='analysis';        % analysis: selection of equivalent parameter sets and  plotting


%==== END OF DIRECT PARAMETER MAPPING SETTINGS ====



%% THIS SECTION IS SPECIFIC TO A 'SINGLE' FITTING SESSION FOR A MODEL ADJUSTING W0_B
%    these are the starting values of w0_B
%   you must first determine in 'just_display_data' runs
Model.w0_B = w0_B(residue_number);
model_setup;  %-- to set up limits for this parameter



% -- Normalization by total integral of the trace: 
%           It requires that peak tails go down to baseline ON BOTH SIDES,
%           otherwise incorrect results will be obtained: first and last points of the trace are taken as 
%           constant baseline estimate to subtract baseline.
Normalization='integration' ; 

%Integration_mode='rectangular';   %-- integration by rectangular formula
Integration_mode='simpson';   %-- integration by Simpson's formula NOTE:





% 2. ---- Baseline correction ---  
%  Use ONLY when your peak falls off to the noise floor AT LEAST on one
%  side and noise floor is elevated
%Baseline_Correction=YES; 
Baseline_Correction=NO;

% 3. --- starting line width in fitting of initial raw data for
%           determination of positions and relaxation rates of end points
Line_Width_0=50;

% -- Plotting option for fitting or simulation results
Stacked_Plot=YES;   %--- YES  to display the titration series stacked rather than overlayed
Percent_Shift=75 ;   %-- percentage of the peak height for shifting next trace up. Applicable 
                                %    if  Stacked_Plot=YES


% 5. -- Before starting, make sure that Matlab knows where the code is:
%   use File:Set Path and [Add Folder] 



% 6. ---- NOW YOU ARE READY. TYPE IN 'main' AT A MATLAB COMMAND LINE -----

%% Read definitions of the fitting model from this file

DPM_setup;   %--- load DPM-specific parameters

