Generated Code

The following is matlab code generated by the CellML API from this CellML file. (Back to language selection)

The raw code is available.

```function [VOI, STATES, ALGEBRAIC, CONSTANTS] = mainFunction()
% This is the "main function".  In Matlab, things work best if you rename this function to match the filename.
[VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel();
end

function [algebraicVariableCount] = getAlgebraicVariableCount()
% Used later when setting a global variable with the number of algebraic variables.
% Note: This is not the "main method".
algebraicVariableCount =5;
end
% There are a total of 11 entries in each of the rate and state variable arrays.
% There are a total of 55 entries in the constant variable array.
%

function [VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel()
% Create ALGEBRAIC of correct size
global algebraicVariableCount;  algebraicVariableCount = getAlgebraicVariableCount();
% Initialise constants and state variables
[INIT_STATES, CONSTANTS] = initConsts;

% Set timespan to solve over
tspan = [0, 10];

% Set numerical accuracy options for ODE solver
options = odeset('RelTol', 1e-06, 'AbsTol', 1e-06, 'MaxStep', 1);

% Solve model with ODE solver
[VOI, STATES] = ode15s(@(VOI, STATES)computeRates(VOI, STATES, CONSTANTS), tspan, INIT_STATES, options);

% Compute algebraic variables
[RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS);
ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI);

% Plot state variables against variable of integration
[LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends();
figure();
plot(VOI, STATES);
xlabel(LEGEND_VOI);
l = legend(LEGEND_STATES);
set(l,'Interpreter','none');
end

function [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends()
LEGEND_STATES = ''; LEGEND_ALGEBRAIC = ''; LEGEND_VOI = ''; LEGEND_CONSTANTS = '';
LEGEND_VOI = strpad('time in component environment (minute)');
LEGEND_CONSTANTS(:,1) = strpad('V_max1 in component V1 (micromolar_per_minute)');
LEGEND_CONSTANTS(:,2) = strpad('GEFt in component V1 (micromolar)');
LEGEND_CONSTANTS(:,44) = strpad('V_1 in component V1 (per_minute)');
LEGEND_CONSTANTS(:,3) = strpad('Str in component V2 (dimensionless)');
LEGEND_CONSTANTS(:,4) = strpad('V_max2 in component V2 (micromolar_per_minute)');
LEGEND_CONSTANTS(:,45) = strpad('V_2 in component V2 (per_minute)');
LEGEND_CONSTANTS(:,5) = strpad('k_c3 in component V3 (per_minute)');
LEGEND_CONSTANTS(:,6) = strpad('PKAt in component V3 (micromolar)');
LEGEND_CONSTANTS(:,7) = strpad('GAPt in component V3 (micromolar)');
LEGEND_CONSTANTS(:,46) = strpad('V_3 in component V3 (per_minute)');
LEGEND_CONSTANTS(:,8) = strpad('V_max4 in component V4 (micromolar_per_minute)');
LEGEND_CONSTANTS(:,47) = strpad('V_4 in component V4 (per_minute)');
LEGEND_CONSTANTS(:,9) = strpad('k_gef in component V5 (per_minute)');
LEGEND_CONSTANTS(:,10) = strpad('RASt in component V5 (micromolar)');
LEGEND_CONSTANTS(:,48) = strpad('V_5 in component V5 (per_minute)');
LEGEND_CONSTANTS(:,11) = strpad('k_gap in component V6 (per_minute)');
LEGEND_CONSTANTS(:,49) = strpad('V_6 in component V6 (per_minute)');
LEGEND_CONSTANTS(:,12) = strpad('k_c7 in component V7 (per_minute)');
LEGEND_CONSTANTS(:,13) = strpad('PDEt in component V7 (micromolar)');
LEGEND_CONSTANTS(:,50) = strpad('V_7 in component V7 (per_minute)');
LEGEND_CONSTANTS(:,14) = strpad('V_max8 in component V8 (micromolar_per_minute)');
LEGEND_CONSTANTS(:,51) = strpad('V_8 in component V8 (per_minute)');
LEGEND_CONSTANTS(:,15) = strpad('a in component VPKAact (per_micromolar_squared_minute)');
LEGEND_CONSTANTS(:,16) = strpad('r in component VPKAact (per_minute)');
LEGEND_STATES(:,1) = strpad('R2C2 in component holoenzyme_R_C (dimensionless)');
LEGEND_STATES(:,2) = strpad('cAMP in component cyclic_AMP (micromolar)');
LEGEND_ALGEBRAIC(:,4) = strpad('C in component C_subunit (dimensionless)');
LEGEND_ALGEBRAIC(:,1) = strpad('R2cAMP2 in component holoenzyme_R_cAMP (dimensionless)');
LEGEND_ALGEBRAIC(:,5) = strpad('V_PKAact in component VPKAact (per_minute)');
LEGEND_CONSTANTS(:,17) = strpad('K_1 in component active_GEF (dimensionless)');
LEGEND_CONSTANTS(:,18) = strpad('K_2 in component active_GEF (dimensionless)');
LEGEND_STATES(:,3) = strpad('GEFa in component active_GEF (dimensionless)');
LEGEND_CONSTANTS(:,19) = strpad('K_3 in component active_GAP (dimensionless)');
LEGEND_CONSTANTS(:,20) = strpad('K_4 in component active_GAP (dimensionless)');
LEGEND_STATES(:,4) = strpad('GAPa in component active_GAP (dimensionless)');
LEGEND_CONSTANTS(:,21) = strpad('K_5 in component RAS_to_GTP (dimensionless)');
LEGEND_CONSTANTS(:,22) = strpad('K_6 in component RAS_to_GTP (dimensionless)');
LEGEND_STATES(:,5) = strpad('RGTP in component RAS_to_GTP (dimensionless)');
LEGEND_CONSTANTS(:,25) = strpad('K_7 in component active_PDE (dimensionless)');
LEGEND_CONSTANTS(:,26) = strpad('K_8 in component active_PDE (dimensionless)');
LEGEND_STATES(:,7) = strpad('PDEa in component active_PDE (dimensionless)');
LEGEND_CONSTANTS(:,27) = strpad('k_s in component cyclic_AMP (per_minute)');
LEGEND_CONSTANTS(:,28) = strpad('k_d in component cyclic_AMP (per_minute)');
LEGEND_CONSTANTS(:,29) = strpad('CYCLt in component cyclic_AMP (micromolar)');
LEGEND_CONSTANTS(:,30) = strpad('K_md in component cyclic_AMP (micromolar)');
LEGEND_CONSTANTS(:,31) = strpad('k_c9 in component V9 (per_minute)');
LEGEND_CONSTANTS(:,32) = strpad('MSNt in component V9 (micromolar)');
LEGEND_CONSTANTS(:,52) = strpad('V_9 in component V9 (per_minute)');
LEGEND_CONSTANTS(:,33) = strpad('V_max10 in component V10 (micromolar_per_minute)');
LEGEND_CONSTANTS(:,53) = strpad('V_10 in component V10 (per_minute)');
LEGEND_CONSTANTS(:,34) = strpad('k_c11 in component V11 (per_minute)');
LEGEND_CONSTANTS(:,54) = strpad('V_11 in component V11 (per_minute)');
LEGEND_CONSTANTS(:,35) = strpad('V_max12 in component V12 (micromolar_per_minute)');
LEGEND_CONSTANTS(:,55) = strpad('V_12 in component V12 (per_minute)');
LEGEND_CONSTANTS(:,36) = strpad('k_t1 in component cytosol (per_minute)');
LEGEND_CONSTANTS(:,37) = strpad('k_t2 in component cytosol (per_minute)');
LEGEND_CONSTANTS(:,38) = strpad('K_11 in component cytosol (dimensionless)');
LEGEND_CONSTANTS(:,39) = strpad('K_12 in component cytosol (dimensionless)');
LEGEND_STATES(:,8) = strpad('MN in component nucleus (dimensionless)');
LEGEND_STATES(:,9) = strpad('MCP in component cytosol_phos (dimensionless)');
LEGEND_STATES(:,10) = strpad('MC in component cytosol (dimensionless)');
LEGEND_CONSTANTS(:,40) = strpad('K_9 in component nucleus (dimensionless)');
LEGEND_CONSTANTS(:,41) = strpad('K_10 in component nucleus (dimensionless)');
LEGEND_STATES(:,11) = strpad('MNP in component nucleus_phos (dimensionless)');
LEGEND_CONSTANTS(:,42) = strpad('k_t3 in component nucleus_phos (per_minute)');
LEGEND_CONSTANTS(:,43) = strpad('k_t4 in component nucleus_phos (per_minute)');
LEGEND_ALGEBRAIC(:,2) = strpad('M_cyto in component Mcyto (dimensionless)');
LEGEND_ALGEBRAIC(:,3) = strpad('M_nucl in component Mnucl (dimensionless)');
LEGEND_RATES(:,3) = strpad('d/dt GEFa in component active_GEF (dimensionless)');
LEGEND_RATES(:,4) = strpad('d/dt GAPa in component active_GAP (dimensionless)');
LEGEND_RATES(:,5) = strpad('d/dt RGTP in component RAS_to_GTP (dimensionless)');
LEGEND_RATES(:,7) = strpad('d/dt PDEa in component active_PDE (dimensionless)');
LEGEND_RATES(:,2) = strpad('d/dt cAMP in component cyclic_AMP (micromolar)');
LEGEND_RATES(:,1) = strpad('d/dt R2C2 in component holoenzyme_R_C (dimensionless)');
LEGEND_RATES(:,10) = strpad('d/dt MC in component cytosol (dimensionless)');
LEGEND_RATES(:,8) = strpad('d/dt MN in component nucleus (dimensionless)');
LEGEND_RATES(:,11) = strpad('d/dt MNP in component nucleus_phos (dimensionless)');
LEGEND_RATES(:,9) = strpad('d/dt MCP in component cytosol_phos (dimensionless)');
LEGEND_STATES  = LEGEND_STATES';
LEGEND_ALGEBRAIC = LEGEND_ALGEBRAIC';
LEGEND_RATES = LEGEND_RATES';
LEGEND_CONSTANTS = LEGEND_CONSTANTS';
end

function [STATES, CONSTANTS] = initConsts()
VOI = 0; CONSTANTS = []; STATES = []; ALGEBRAIC = [];
CONSTANTS(:,1) = 1;
CONSTANTS(:,2) = 4;
CONSTANTS(:,3) = 1;
CONSTANTS(:,4) = 1;
CONSTANTS(:,5) = 3.5;
CONSTANTS(:,6) = 0.3;
CONSTANTS(:,7) = 1.5;
CONSTANTS(:,8) = 1.3;
CONSTANTS(:,9) = 240;
CONSTANTS(:,10) = 250;
CONSTANTS(:,11) = 600;
CONSTANTS(:,12) = 3.333;
CONSTANTS(:,13) = 0.5;
CONSTANTS(:,14) = 1.5;
CONSTANTS(:,15) = 1;
CONSTANTS(:,16) = 1;
STATES(:,1) = 0.5;
STATES(:,2) = 1;
CONSTANTS(:,17) = 0.05;
CONSTANTS(:,18) = 0.05;
STATES(:,3) = 0.36;
CONSTANTS(:,19) = 0.01;
CONSTANTS(:,20) = 0.01;
STATES(:,4) = 0.5;
CONSTANTS(:,21) = 0.001;
CONSTANTS(:,22) = 0.001;
STATES(:,5) = 0.1;
CONSTANTS(:,23) = 0.01;
CONSTANTS(:,24) = 1;
STATES(:,6) = 0.1;
CONSTANTS(:,25) = 0.01;
CONSTANTS(:,26) = 0.01;
STATES(:,7) = 0.5;
CONSTANTS(:,27) = 4;
CONSTANTS(:,28) = 100;
CONSTANTS(:,29) = 0.7;
CONSTANTS(:,30) = 20;
CONSTANTS(:,31) = 3.333;
CONSTANTS(:,32) = 1;
CONSTANTS(:,33) = 0.6;
CONSTANTS(:,34) = 3.333;
CONSTANTS(:,35) = 2;
CONSTANTS(:,36) = 10;
CONSTANTS(:,37) = 0.001;
CONSTANTS(:,38) = 0.05;
CONSTANTS(:,39) = 0.05;
STATES(:,8) = 0.25;
STATES(:,9) = 0.25;
STATES(:,10) = 0.25;
CONSTANTS(:,40) = 0.05;
CONSTANTS(:,41) = 0.05;
STATES(:,11) = 0.25;
CONSTANTS(:,42) = 0.001;
CONSTANTS(:,43) = 10;
CONSTANTS(:,44) = CONSTANTS(:,1)./CONSTANTS(:,2);
CONSTANTS(:,45) = ( CONSTANTS(:,3).*CONSTANTS(:,4))./CONSTANTS(:,2);
CONSTANTS(:,46) = ( CONSTANTS(:,5).*CONSTANTS(:,6))./CONSTANTS(:,7);
CONSTANTS(:,47) = CONSTANTS(:,8)./CONSTANTS(:,7);
CONSTANTS(:,48) = ( CONSTANTS(:,9).*CONSTANTS(:,2))./CONSTANTS(:,10);
CONSTANTS(:,49) = ( CONSTANTS(:,11).*CONSTANTS(:,7))./CONSTANTS(:,10);
CONSTANTS(:,50) = ( CONSTANTS(:,12).*CONSTANTS(:,6))./CONSTANTS(:,13);
CONSTANTS(:,51) = CONSTANTS(:,14)./CONSTANTS(:,13);
CONSTANTS(:,52) = ( CONSTANTS(:,31).*CONSTANTS(:,6))./CONSTANTS(:,32);
CONSTANTS(:,53) = ( CONSTANTS(:,3).*CONSTANTS(:,33))./CONSTANTS(:,32);
CONSTANTS(:,54) = ( CONSTANTS(:,34).*CONSTANTS(:,6))./CONSTANTS(:,32);
CONSTANTS(:,55) = ( CONSTANTS(:,3).*CONSTANTS(:,35))./CONSTANTS(:,32);
if (isempty(STATES)), warning('Initial values for states not set');, end
end

function [RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS)
global algebraicVariableCount;
statesSize = size(STATES);
statesColumnCount = statesSize(2);
if ( statesColumnCount == 1)
STATES = STATES';
ALGEBRAIC = zeros(1, algebraicVariableCount);
utilOnes = 1;
else
statesRowCount = statesSize(1);
ALGEBRAIC = zeros(statesRowCount, algebraicVariableCount);
RATES = zeros(statesRowCount, statesColumnCount);
utilOnes = ones(statesRowCount, 1);
end
RATES(:,3) = ( CONSTANTS(:,44).*(1.00000 - STATES(:,3)))./(CONSTANTS(:,17)+(1.00000 - STATES(:,3))) - ( CONSTANTS(:,45).*STATES(:,3))./(CONSTANTS(:,18)+STATES(:,3));
RATES(:,5) = ( CONSTANTS(:,48).*STATES(:,3).*(1.00000 - STATES(:,5)))./(CONSTANTS(:,21)+(1.00000 - STATES(:,5))) - ( CONSTANTS(:,49).*STATES(:,4).*STATES(:,5))./(CONSTANTS(:,22)+STATES(:,5));
RATES(:,6) =  CONSTANTS(:,23).*STATES(:,5).*CONSTANTS(:,10).*(1.00000 - STATES(:,6)) -  CONSTANTS(:,24).*STATES(:,6);
ALGEBRAIC(:,4) =  2.00000.*(1.00000 - STATES(:,1));
RATES(:,4) = ( CONSTANTS(:,46).*ALGEBRAIC(:,4).*(1.00000 - STATES(:,4)))./(CONSTANTS(:,19)+(1.00000 - STATES(:,4))) - ( CONSTANTS(:,47).*STATES(:,4))./(CONSTANTS(:,20)+STATES(:,4));
RATES(:,7) = ( CONSTANTS(:,50).*ALGEBRAIC(:,4).*(1.00000 - STATES(:,7)))./(CONSTANTS(:,25)+(1.00000 - STATES(:,7))) - ( CONSTANTS(:,51).*STATES(:,7))./(CONSTANTS(:,26)+STATES(:,7));
ALGEBRAIC(:,1) = 1.00000 - STATES(:,1);
RATES(:,1) =   - CONSTANTS(:,15).*STATES(:,1).*power(STATES(:,2), 2.00000)+ CONSTANTS(:,16).*power(ALGEBRAIC(:,4), 2.00000).*ALGEBRAIC(:,1).*power(CONSTANTS(:,6), 2.00000).*1.00000;
RATES(:,10) = ((  - CONSTANTS(:,36).*STATES(:,10)+ CONSTANTS(:,37).*STATES(:,8)) - ( CONSTANTS(:,54).*ALGEBRAIC(:,4).*STATES(:,10))./(CONSTANTS(:,38)+STATES(:,10)))+( CONSTANTS(:,55).*STATES(:,9))./(CONSTANTS(:,39)+STATES(:,9));
RATES(:,8) = (( CONSTANTS(:,36).*STATES(:,10) -  CONSTANTS(:,37).*STATES(:,8)) - ( CONSTANTS(:,52).*ALGEBRAIC(:,4).*STATES(:,8))./(CONSTANTS(:,40)+STATES(:,8)))+( CONSTANTS(:,53).*STATES(:,11))./(CONSTANTS(:,41)+STATES(:,11));
RATES(:,11) = ((( CONSTANTS(:,52).*ALGEBRAIC(:,4).*STATES(:,8))./(CONSTANTS(:,40)+STATES(:,8)) - ( CONSTANTS(:,53).*STATES(:,11))./(CONSTANTS(:,41)+STATES(:,11)))+ CONSTANTS(:,42).*STATES(:,9)) -  CONSTANTS(:,43).*STATES(:,11);
RATES(:,9) = (  - CONSTANTS(:,42).*STATES(:,9)+ CONSTANTS(:,43).*STATES(:,11)+( CONSTANTS(:,54).*ALGEBRAIC(:,4).*STATES(:,10))./(CONSTANTS(:,38)+STATES(:,10))) - ( CONSTANTS(:,55).*STATES(:,9))./(CONSTANTS(:,39)+STATES(:,9));
ALGEBRAIC(:,5) =  CONSTANTS(:,15).*STATES(:,1).*power(STATES(:,2), 2.00000) -  CONSTANTS(:,16).*ALGEBRAIC(:,4).*ALGEBRAIC(:,1).*power(CONSTANTS(:,6), 2.00000).*1.00000;
RATES(:,2) = ( CONSTANTS(:,27).*STATES(:,6).*CONSTANTS(:,29) - ( CONSTANTS(:,28).*CONSTANTS(:,13).*STATES(:,7).*STATES(:,2))./(CONSTANTS(:,30)+STATES(:,2))) -  2.00000.*ALGEBRAIC(:,5).*CONSTANTS(:,6);
RATES = RATES';
end

% Calculate algebraic variables
function ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI)
statesSize = size(STATES);
statesColumnCount = statesSize(2);
if ( statesColumnCount == 1)
STATES = STATES';
utilOnes = 1;
else
statesRowCount = statesSize(1);
utilOnes = ones(statesRowCount, 1);
end
ALGEBRAIC(:,4) =  2.00000.*(1.00000 - STATES(:,1));
ALGEBRAIC(:,1) = 1.00000 - STATES(:,1);
ALGEBRAIC(:,5) =  CONSTANTS(:,15).*STATES(:,1).*power(STATES(:,2), 2.00000) -  CONSTANTS(:,16).*ALGEBRAIC(:,4).*ALGEBRAIC(:,1).*power(CONSTANTS(:,6), 2.00000).*1.00000;
ALGEBRAIC(:,2) = STATES(:,10)+STATES(:,9);
ALGEBRAIC(:,3) = STATES(:,8)+STATES(:,11);
end

% Pad out or shorten strings to a set length
req_length = 160;
insize = size(strin,2);
if insize > req_length
strout = strin(1:req_length);
else
strout = [strin, blanks(req_length - insize)];
end
end

```
Source
Derived from workspace Garmendia-Torres, Goldbeter and Jacquet 2007 at changeset 99e423da60ca.
Collaboration
To begin collaborating on this work, please use your git client and issue this command: