Location: cellLib @ 91fe586a0fe0 / Scripts / updateVIO.m

Author:
WeiweiAi <wai484@aucklanduni.ac.nz>
Date:
2022-04-13 20:56:06+12:00
Desc:
add updateVIO.m and correct getPara.m
Permanent Source URI:
https://models.cellml.org/workspace/6bc/rawfile/91fe586a0fe054a25297169a6cc939bd3560e4ab/Scripts/updateVIO.m

function comp=updateVIO(comp,idx)
cmnames=string(extractfield(comp,'name'));%unique
if length(cmnames)>length(unique(cmnames))
    disp('There are repetitions of component names')
    return
end
ncomp=length(cmnames);
for i=1:ncomp
    vars=comp(i).vars;    
    init=vars(:,idx.init);
    pub=vars(:,idx.pub);
    priv=vars(:,idx.priv);
    init = replace(init,"none","");
    pub = replace(pub,"none","");
    priv = replace(priv,"none","");
    firstcomma=strings(length(init),1);
    sedcomma=firstcomma;
    bracket1=firstcomma;
    bracket2=firstcomma; 
    
    idxcheck=any([(~(init=="")),(~(pub=="")),(~(priv==""))],2);
    check=find(idxcheck,1);
    if ~isempty(check)
    bracket1(idxcheck,1)="{";
    bracket2(idxcheck,1)="}";
    else
        return
    end
    
    idxcheck=all([~(init==""),~(pub=="")|~(priv=="")],2);
    check=find(idxcheck,1);
    if ~isempty(check)
    firstcomma(idxcheck,1)=", "; 
    init(idxcheck,1)="init: "+init(idxcheck,1);
    end
    
    idxcheck=~(pub=="");
    check=find(idxcheck,1);
    if ~isempty(check)
    pub(idxcheck,1)="pub: "+pub(idxcheck,1);
    end
    
    idxcheck=all([~(priv==""),~(init=="")|~(pub=="")],2);
    check=find(idxcheck,1);
    if ~isempty(check)
    sedcomma(idxcheck,1)=", ";
    priv(idxcheck,1)="priv: "+priv(idxcheck,1);
    end 
    
    vio=bracket1+init+firstcomma+pub+sedcomma+priv+bracket2; 
    comp(i).vars(:,idx.vio)=vio;       
end

end