function [bldxdt]=YcgEeq(t,x)

%in seconds
tf=1;
% max transc. YcgF 
k1=1.54e-3*tf;      % 1/s
% max transc YcgE 
k2=0.848e-3*tf;    % 1/s
% max transl. YcgF 
k3=0.167*tf;         % 1/s
% max transl. YcgE 
k4=0.167*tf;         % 1/s
% dimerization of YcgF
kdim=8e-3*tf;      % nm^2/(sW)
% dissoc of YcgF dimer 
kdis=0.0058*tf;     % 1/s
% binding of YcgF dim to YcgE
kbind=1e2*tf;        % 1/(molec*s)
% undbinding of YcgFdim&YcgE
kubind=1*tf;          % 1/s

% Hill coeff YcgF,YcgF
n1=2;                % guessed (two interacting molec)

% degrad mRNA
gamma1=2.3105e-3*tf; %1/s
% degrad Protein
gamma2=1.9254e-5*tf; %1/s

bldxdt=[
    % 1 YcgF RNA
    k1-gamma1*x(1);
    % 2 YcgF prot inactive
    k3*x(1)-2*kdim*x(2)^2*Hill(BlueLightInput(t),n1,1/2)+2*kdis*x(3)-gamma2*x(2);
    % 3 YcgF prot dimer
    kdim*x(2)^2*Hill(BlueLightInput(t),n1,1/2)-kbind*x(3)*x(5)-kdis*x(3)+kubind*x(6)-gamma2*x(3);
    % 4 YcgE RNA
    k2-gamma1*x(4);
    % 5 YcgE prot
    k4*x(4)-kbind*x(3)*x(5)+kubind*x(6)-gamma2*x(5);
    % 6 YcgE_YcgF complex
    -kubind*x(6)+kbind*x(3)*x(5);
    ];
end

function B=BlueLightInput(t)
global p
%gives blue light impulse intensity, normalized to 1

if (norm(t)>p.bstart) && (norm(t)<p.bstart+p.bdur)
    B=p.bint;
else
    B=0;
end
end

function H=Hill(x,n,tresh)
H=(x.^n)/(tresh.^n+x.^n);
end