Location: Single PASMC model (Gosak et al 2014) @ 887894c158d4 / Components / buildsrc / assembleModel.m

Author:
WeiweiAi <wai484@aucklanduni.ac.nz>
Date:
2022-06-13 11:44:41+12:00
Desc:
Modify the intracelluar K from 4.7 mM to 5.9 mM
Permanent Source URI:
https://models.cellml.org/workspace/83f/rawfile/887894c158d460d4505bd3fb26d23a7b939ca442/Components/buildsrc/assembleModel.m

clear
addpath(genpath('../../cellLib/Scripts/'))
load("comp.mat")
% Build models
cmnames=string(extractfield(comp,'name'));
modelnames=cmnames([1:8,10:12,17]);
listComp={};
labels=cell(length(modelnames),1);
txtfiles=[];
for i=1:length(modelnames)
    modelname=modelnames(i);
    listComp.name=modelname;
    listComp.def=modelname;
    listComp.from="";
    listComp.impComp="";
    listComp.label=labels{i,1};
    model=buildModel(modelname,comp,listComp,idx);
    modelfile=strcat(modelname,'.txt');
    txtfiles=[txtfiles,modelname];
    writeModel(model,comp,modelfile,idx)
end

modelname="PASMC";
parentnames=cmnames(15);
nm=0;
listComp={};
labels={};
chd=[];
for n=1:length(parentnames)
  icomp=comp(cmnames==parentnames(n));
  chd=[chd;icomp.children];  
end
uni_chd=unique(chd);

for m=1:length(uni_chd)
    ichd=uni_chd(m);   
    listComp(m).name=ichd;
    listComp(m).def=ichd;
    listComp(m).from=strcat(ichd,".cellml");
    listComp(m).impComp=ichd;
    listComp(m).label=[]; 
end

for n=1:length(parentnames)
icomp=comp(cmnames==parentnames(n));
chd=icomp.children;
m=m+1;
listComp(m).name=parentnames(n);
listComp(m).def=parentnames(n);
listComp(m).from="";
listComp(m).impComp="";
listComp(m).label=[];
end
model=buildModel(modelname,comp,listComp,idx);
modelfile=strcat(modelname,'.txt');
txtfiles=[txtfiles,modelname];
writeModel(model,comp,modelfile,idx)

modelname="JKi";
parentnames=modelname;
nm=0;
listComp={};
labels={};
chd=[];
for n=1:length(parentnames)
  icomp=comp(cmnames==parentnames(n));
  chd=[chd;icomp.children];  
end
uni_chd=unique(chd);

for m=1:length(uni_chd)
    ichd=uni_chd(m);   
    listComp(m).name=ichd;
    listComp(m).def=ichd;
    listComp(m).from="../cellLib/Components/E_Nernst.cellml";
    listComp(m).impComp=ichd;
    listComp(m).label=["Ko","K_out";"E_K","v_K";]; 
end

for n=1:length(parentnames)
icomp=comp(cmnames==parentnames(n));
chd=icomp.children;
m=m+1;
listComp(m).name=parentnames(n);
listComp(m).def=parentnames(n);
listComp(m).from="";
listComp(m).impComp="";
listComp(m).label=[];
end
model=buildModel(modelname,comp,listComp,idx);
modelfile=strcat(modelname,'.txt');
txtfiles=[txtfiles,modelname];
writeModel(model,comp,modelfile,idx)

modelname="PASMC_test";
listComp={};
m=0;
m=m+1;
listComp(m).name="PASMC";
listComp(m).def="PASMC";
listComp(m).from="../Components/PASMC.cellml";
listComp(m).impComp="PASMC";
listComp(m).label=[];
m=m+1;
listComp(m).name="output";
listComp(m).def="output";
listComp(m).from="";
listComp(m).impComp="";
listComp(m).label=[];
m=m+1;
listComp(m).name="clamp_para";
listComp(m).def="clamp_para";
listComp(m).from="";
listComp(m).impComp="";
listComp(m).label=[];
m=m+1;
listComp(m).name="Para";
listComp(m).def="Para";
listComp(m).from="../Components/Para.cellml";
listComp(m).impComp="Para";
listComp(m).label=[];
m=m+1;
listComp(m).name="X_clamp_protocol";
listComp(m).def="X_clamp_protocol";
listComp(m).from="../cellLib/Protocols/X_clamp_protocol.cellml";
listComp(m).impComp="X_clamp_protocol";
listComp(m).label=["X","K_out";"time","t";];
m=m+1;
listComp(m).name="time";
listComp(m).def="time_s";
listComp(m).from="../cellLib/Components/time.cellml";
listComp(m).impComp="time_s";
listComp(m).label=["time","t";];

model=buildModel(modelname,comp,listComp,idx);
modelfile=strcat(modelname,'.txt');
writeModel(model,comp,modelfile,idx)

% write the filenames for conversion
txtfiles=[txtfiles,modelname];
fileID = fopen('filenames.txt','w');
fprintf(fileID,'"%s",',txtfiles');
fclose(fileID);