% Reactants with initial conditions (see S5 Fig.) numofelements=15; X=zeros(1,numofelements); X(1)=100; % UXP X(2)=10; % CAP X(3)=0; % UDPglucose X(4)=10; % Activator X(5)=0; % UXPActivator complex X(6)=1; % DNAcap X(7)=0; % DNAcapActivator complex X(8)=0; % mRNAcap X(9)=0; % Repressor X(10)=0; % DNAcapRepressor complex X(11)=0; % DNArepressorCAP complex X(12)=0; % DNArepressorCAP2 complex (2 x CAP) X(13)=0; % DNArepressorCAP11 complex (1 CAP attached to DNA, 1 not) X(14)=0; % mRNArepressor X(15)=1; % DNArepressor % Reactions (first line is the reactants, second is the products) numofreactions=23; A=zeros(numofreactions,length(X)); A(1,[1 2])=[1 1]; Y(1,[1 3])=[-1 1]; A(2,[1 4])=[1 1]; Y(2,[1 4 5])=[-1 -1 1]; A(3,[5])=[1]; Y(3,[5 1 4])=[-1 1 1]; A(4,[6 4])=[1 1]; Y(4,[6 4 7])=[-1 -1 1]; A(5,[7])=[1]; Y(5,[6 4 7])=[1 1 -1]; A(6,[7])=[1]; Y(6,[8])=[1]; A(7,[8])=[1]; Y(7,[2])=[1]; A(8,[6 9])=[1 1]; Y(8,[6 9 10])=[-1 -1 1]; A(9,[10])=[1]; Y(9,[6 9 10])=[1 1 -1]; A(10,[6])=1; Y(10,[8])=1; A(11,[8])=[1]; Y(11,[8])=[-1]; A(12,[15 2])=[1 1]; Y(12,[15 2 11])=[-1 -1 1]; A(13,[11])=[1]; Y(13,[11 15 2])=[-1 1 1]; A(14,[11 2])=[1 1]; Y(14,[11 2 12])=[-1 -1 1]; A(15,[12])=[1]; Y(15,[12 13])=[-1 1]; A(16,[13])=[1]; Y(16,[13 15 2])=[-1 1 2]; A(17,[13])=[1]; Y(17,[13 12])=[-1 1]; A(18,[12])=[1]; Y(18,[14])=[1]; A(19,[14])=[1]; Y(19,[9])=[1]; A(20,[14])=[1]; Y(20,[14])=[-1]; A(21,[9])=[1]; Y(21,[9])=[-1]; A(22,[2])=[1]; Y(22,[2])=[-1]; A(23,[1])=[1]; Y(23,[1])=[-1]; % Rates of reactions (see Figure S3) rates=zeros(size(A,1),1); uflux=.3; % uxp flux (.003 for low, .3 for intermediate, 3 for high), rate for equation A1 rates(1)=.0001; % A2 rates(2)=.05; % A4 forward rates(3)=.0005; % A4 backward rates(4)=.05; % B1 forward rates(5)=.00002; % B1 backward rates(6)=.05; % B3 rates(7)=.01; % B4 rates(8)=.01; % C6 forwards rates(9)=.00003; % C6 backwards rates(10)=.01; % B2 rates(11)=.01; % D1 rates(12)=.00001; % C1 forwards rates(13)=.001; % C1 backwards rates(14)=.00001; % C2 rates(15)=.001; % C3 forwards rates(16)=.001; % C7 rates(17)=.005; % C3 backwards rates(18)=.05; % C4 rates(19)=.05; % C5 rates(20)=.01; % D2 rates(21)=.001; % D3 rates(22)=.001; % D4 rates(23)=.001; % A3 (assume PyrG is fixed) % Parameters for simulation tmax=2*10^5; % maximum time t=0; % initial time told=0; % counter for previous time step datamat=zeros(tmax+1,length(X)+1); % store data of times and number of each molecule, may need to be extended datamat(1,:)=[t X]; % initialize ct=1; % counter for number of unique reactions simulated rehisold=0; % counter for previous reaction as=zeros(1,numofreactions+1); % reaction proclivities as(end)=uflux; % Simulation while t0)); end % Calculate time told=t; t=t-1*log(rand())/sum(as); % Determine which reaction occurs ind=sum(rand()>cumsum(as./sum(as)))+1; if ind==numofreactions+1; % Add UTP X(1)=X(1)+1; else X=X+Y(ind,:); end % Store data if ind~=rehisold ct=ct+1; % new reaction, add to counter if ct>size(datamat,1); % Extend size of data mat datamat=[datamat;zeros(100000,length(X)+1)]; end datamat(ct,:)=[t X]; rehisold=ind; end end % Prune early burn-in phase for datamat datamatold=datamat; st=round(.05*ct); datamat=datamat(st+1:ct,:); datamat(:,1)=datamat(:,1)-datamatold(st,1); % adjust time % Visualize colanic acid-like polymer levels close all;plot(datamat(:,1)/60/60,datamat(:,3),'bo-','LineWidth',3); xlabel('Time (hours)','FontSize',18) ylabel('Amount of CAP','FontSize',18) set(gca,'TickLength',[.025 .025],'LineWidth',2) axis square axis([0 48 -5 100]);