|
1 | | -% ToDo: |
2 | | -% \tC\tau\tconc.\t1\t1\t etc |
3 | | -% num2str(max(time)*1.2) |
| 1 | +function dataFilenames = writeDataFromPEtab(yamlFile, savePath) |
| 2 | +% writeDataFromPEtab(yamlFile, savePath) |
| 3 | +% |
| 4 | +% This function reads the PEtab files and writes the data to excel (.xls) files and creates the corresponding .def files for each simulation condition. |
| 5 | +% |
| 6 | +% Inputs: |
| 7 | +% yamlFile: string, name of the yaml file in the PEtab folder. If not specified, the function will look for a .yaml file in the PEtab folder. Multiple .yaml files are not allowed. |
| 8 | +% savePath: string, path to the folder where the data files should be saved. [default: 'DataPEtab'] |
| 9 | +% |
| 10 | +% Outputs: |
| 11 | +% dataFilenames: cell array of strings, filenames of the data files |
| 12 | +% |
4 | 13 |
|
5 | | -function dataFilenames = arWriteDataFromPEtab(yamlFile, savePath) |
6 | 14 |
|
7 | 15 | %% Filenames |
8 | 16 | if ~exist('yamlFile','var') || isempty(yamlFile) |
|
97 | 105 | end |
98 | 106 |
|
99 | 107 | % only the observableIDs that have uniqueSimConds{i} in their name |
100 | | - observableIdCond = unique(Tdat.observableId(contains(Tdat.observableId, uniqueSimConds{i}))); % find all occurences of uniqueSimConds{i} in observableIds |
101 | | - observableId = regexprep(observableIdCond, ['_',uniqueSimConds{i}],''); |
| 108 | + %observableIdCond = unique(Tdat.observableId(contains(Tdat.observableId, uniqueSimConds{i}))); % find all occurences of uniqueSimConds{i} in observableIds |
| 109 | + %observableId = regexprep(observableIdCond, ['_',uniqueSimConds{i}],''); |
| 110 | + |
| 111 | + % find observabeles that of simulationConditionId |
| 112 | + observableId = unique(Tdat.observableId(contains(Tdat.simulationConditionId, uniqueSimConds{i}))); |
102 | 113 |
|
103 | | - ind = find(contains(Tdat.observableId, uniqueSimConds{i})); |
| 114 | + ind = find(contains(Tdat.simulationConditionId, uniqueSimConds{i})); |
104 | 115 | timeUni = unique(Tdat.time(ind)); |
105 | 116 | timeMax = [timeUni, NaN(length(timeUni),1)]; |
106 | 117 |
|
107 | | - for o = 1:length(observableIdCond) |
108 | | - indObs = find(Tdat.observableId == observableIdCond{o}); |
| 118 | + for o = 1:length(observableId) |
| 119 | + indObs = intersect(find(Tdat.observableId == observableId{o}),ind); % observableID and simulationConditionId |
109 | 120 | tObs = Tdat.time(indObs); |
110 | 121 |
|
111 | 122 | % Compute unique values and counts |
|
132 | 143 | T.(char(observableId(o))) = NaN(length(time), 1); % Fill with NaN for now |
133 | 144 | end |
134 | 145 |
|
135 | | - for o=1:length(observableIdCond) |
136 | | - indObs = find(Tdat.observableId == observableIdCond{o}); |
| 146 | + for o=1:length(observableId) |
| 147 | + indObs = find(Tdat.observableId == observableId{o}); |
137 | 148 | for t = 1:length(indObs) |
138 | 149 | % find all rows in T where T.time==Tdat.time(indObs(t)) |
139 | 150 | indT = find(T.time == Tdat.time(indObs(t))); |
|
169 | 180 |
|
170 | 181 | % Observables |
171 | 182 | fprintf(fid, '\nOBSERVABLES\n'); |
172 | | - indObs = find(contains(Tobs.observableId, uniqueSimConds{i})); |
| 183 | + indObs = find(contains(Tobs.observableId, observableId)); |
173 | 184 | for j = 1:length(indObs) |
174 | 185 | ind = indObs(j); |
175 | | - fprintf(fid, [Tobs.observableName{ind},'\tC\tau\tconc.\t1\t1\t','"',Tobs.observableFormula{ind},'"\n']); |
| 186 | + if isfield(Tobs,'observableName') |
| 187 | + fprintf(fid, [Tobs.observableId{ind},'\tC\tau\tconc.\t1\t1\t','"',Tobs.observableFormula{ind},'"\t"',Tobs.observableName{ind},'"\n']); |
| 188 | + else |
| 189 | + fprintf(fid, [Tobs.observableId{ind},'\tC\tau\tconc.\t1\t1\t','"',Tobs.observableFormula{ind},'"\n']); |
| 190 | + end |
176 | 191 | end |
177 | 192 |
|
178 | 193 | % Errors |
179 | 194 | fprintf(fid, '\nERRORS\n'); |
180 | 195 | for j = 1:length(indObs) |
181 | 196 | ind = indObs(j); |
182 | | - fprintf(fid, [Tobs.observableName{ind},'\t','"',Tobs.noiseFormula{ind},'"\n']); |
| 197 | + fprintf(fid, [Tobs.observableId{ind},'\t','"',Tobs.noiseFormula{ind},'"\n']); |
183 | 198 | end |
184 | 199 |
|
185 | 200 | % Conditions |
|
0 commit comments