Location: cellLib @ 1fb1954d66fe / Scripts / updateVIO.m

Author:
WeiweiAi <wai484@aucklanduni.ac.nz>
Date:
2022-05-04 16:46:31+12:00
Desc:
update the readme
Permanent Source URI:
https://models.cellml.org/workspace/6bc/rawfile/1fb1954d66fe1e42d0adacab6b501180d6aef676/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=~(init=="");
    check=find(idxcheck,1);
    if ~isempty(check)
        init(idxcheck,1)="init: "+init(idxcheck,1);
        if ~isempty(find(any([(~(pub(idxcheck)=="")),(~(priv(idxcheck)==""))],2),1))
            firstcomma(idxcheck,1)=", ";
        end
    end
    
    idxcheck=~(pub=="");
    check=find(idxcheck,1);
    if ~isempty(check)
        pub(idxcheck,1)="pub: "+pub(idxcheck,1);
    end
    
    idxcheck=~(priv=="");
    check=find(idxcheck,1);
    if ~isempty(check)
        priv(idxcheck,1)="priv: "+priv(idxcheck,1);
        if ~isempty(find(any([(~(pub(idxcheck)=="")),(~(init(idxcheck)==""))],2),1))
            sedcomma(idxcheck,1)=", ";
        end
    end
    
    vio=bracket1+init+firstcomma+pub+sedcomma+priv+bracket2;
    comp(i).vars(:,idx.vio)=vio;
end

end