% Supplementary Matlab files for the paper:
%
% " Deterministic Modelling and Stochastic Simulation of Pathways using Matlab"
% by M.Ullah, H.Schmidt, K-H.Cho and O.Wolkenhauer
%
% This script file performs stochastic simulation of the enzymatic example. 
%
% We would appreciate a citation if these files are used by others.

reactiondata;                                   % Load parameters

[ts,ns] = stoch(n0,c,D,L,tf);                   % Stochastic simulation

Vh = gma(D,k,L);                                % construct ODEs
options = odeset('refine',16);
[t,x] = ode15s(Vh,[0 tf],x0,options);           % solve of ODEs


[ax,h(1:2),h(3:4)] = plotyy(ts,ns([2 4],:).',t,x(:,[2 4]),'stairs','plot');

%%
set(gcf,'PaperPosition',[2 2 8 6.3],'PaperType','A4');
 
set(ax, 'FontName','cmr','FontSize',8,'Position',[0.1264 0.15 0.7879 0.7643]);

set(h,{'LineWidth'},{1;1;1.5;1.2},{'LineStyle'},{'-';'--';'-.';':'},{'Color'},{'b';'r';'b';'r'});

xlabel(ax(1),'time  (sec)');
ylabel(ax(1),'count of molecules');
% ylabel(ax(2),'concentration  (nM)');
legend(h,{'# {S}','# {P}','{[ S ]  (nM)}','{[ P ]  (nM)}'},'FontName','Times','FontSize',8);
legend boxoff
ylim(ax(1),[0 1.1*max(n0)])
ylim(ax(2),[0 1.1*max(x0)])

% print  -depsc 'figures\enzkin_stoch.eps'