|
131 | 131 | % Author:
|
132 | 132 | % - Tim Hensen, August 2024
|
133 | 133 |
|
134 |
| -if isempty(searchDirectory) |
135 |
| - searchDirectory = what('2020_WholeBodyModelling\Data').path; |
136 |
| -end |
137 |
| - |
138 |
| -if nargin<3 |
139 |
| - excludeVersion = ''; |
140 |
| -end |
141 |
| - |
142 |
| -% Find latest harvery/harvetta models |
143 |
| -WBMs = what(searchDirectory).mat; |
144 |
| - |
145 |
| -% Check if any WBMs can be found |
146 |
| -if isempty(WBMs) |
147 |
| - error('No WBM .mat files found in folder.') |
148 |
| -end |
149 |
| - |
150 |
| -% Remove .mat |
151 |
| -WBMs = erase(WBMs,'.mat'); |
152 |
| - |
153 |
| -% Exclude WBMs if needed |
154 |
| -if ~isempty(excludeVersion) |
155 |
| - WBMs(excludeVersion)=[]; |
156 |
| -end |
157 |
| - |
158 |
| -% Filter on Harvey or Harvetta |
159 |
| -WBMs(~contains(WBMs,filename))=[]; |
160 |
| - |
161 |
| -% Find version numbers in reconstruction names |
162 |
| -modelNumbers = regexp(WBMs,'[0-9]','match'); |
163 |
| - |
164 |
| -% Produce 2 column numerical array with the major version in the first |
165 |
| -% column and the minor version in the second column. |
166 |
| -modelNumbers = string(vertcat(modelNumbers{:})); |
167 |
| -modelNumbers = str2double(horzcat(modelNumbers(:,1), strcat(modelNumbers(:,2), modelNumbers(:,3)))); |
168 |
| - |
169 |
| -% Add the version letter |
170 |
| -letterVersions = string(regexp(WBMs,'(?<=\d)[a-zA-Z]','match')); |
171 |
| -% Convert lettes to numbers using ascii table |
172 |
| -modelNumbers = [modelNumbers double(char(letterVersions))-96]; % https://www.asciitable.com/ |
173 |
| - |
174 |
| -% Find latest version |
175 |
| -checkLatest = @(x) max(x) == x; |
176 |
| - |
177 |
| -% Find versions with the latest major release |
178 |
| -latestMajor = checkLatest(modelNumbers(:,1)); |
179 |
| -if sum(latestMajor)==1 |
180 |
| - % Select model if only one entry has the highest major release |
181 |
| - nameOfWBM = WBMs(latestMajor); |
182 |
| -else |
183 |
| - % Remove all entries without the latest major release |
184 |
| - modelNumbers(~latestMajor,:)=[]; |
185 |
| - WBMs(~latestMajor)=[]; |
186 |
| - % Find entries with the latest minor release |
187 |
| - latestMinor = checkLatest(modelNumbers(:,2)); |
188 |
| - if sum(latestMinor)==1 |
189 |
| - % Select model if only one entry has the highest major release |
190 |
| - nameOfWBM = WBMs(latestMinor); |
191 |
| - else |
192 |
| - % Remove all entries without the latest minor release |
193 |
| - modelNumbers(~latestMinor,:)=[]; |
194 |
| - WBMs(~latestMinor)=[]; |
195 |
| - % Find entries with the latest letter release |
196 |
| - latestLetter = checkLatest(modelNumbers(:,3)); |
197 |
| - if sum(latestLetter)==1 |
198 |
| - nameOfWBM = WBMs(latestLetter); |
| 134 | +% global useSolveCobraLPCPLEX |
| 135 | +% useSolveCobraLPCPLEX |
| 136 | + |
| 137 | +useReadCbModel = 0; |
| 138 | +switch fileName |
| 139 | + case 'Harvey' |
| 140 | + if useSolveCobraLPCPLEX |
| 141 | + %COBRA v2 format |
| 142 | + load Harvey_1_01c |
| 143 | + |
| 144 | + male.subSystems(strmatch('Transport, endoplasmic reticular',male.subSystems,'exact'))={'Transport, endoplasmic reticulum'}; |
| 145 | + male.subSystems(strmatch('Arginine and Proline Metabolism',male.subSystems,'exact'))={'Arginine and proline Metabolism'}; |
| 146 | + male.subSystems(strmatch(' ',male.subSystems,'exact'))={'Miscellaneous'}; |
| 147 | + |
| 148 | + if 1 |
| 149 | + %convert to v3 format except for coupling constraints |
| 150 | + male = convertOldStyleModel(male,0,0); |
| 151 | + end |
| 152 | + else |
| 153 | + if useReadCbModel |
| 154 | + male = readCbModel('Harvey_1_03c', 'fileType','Matlab', 'modelName', 'male'); |
| 155 | + else |
| 156 | + %COBRA v3 format |
| 157 | + %load Harvey_1_02c |
| 158 | + try |
| 159 | + load Harvey_1_03d |
| 160 | + catch |
| 161 | + load Harvey_1_03c |
| 162 | + end |
| 163 | + end |
| 164 | + end |
| 165 | + if isfield(male,'gender') |
| 166 | + male.sex = male.gender; |
| 167 | + male = rmfield(male,'gender'); |
| 168 | + else |
| 169 | + male.sex = 'male'; |
| 170 | + end |
| 171 | + if isfield(male,'rxnGeneMat') |
| 172 | + male = rmfield(male,'rxnGeneMat'); |
| 173 | + end |
| 174 | + variable = male; |
| 175 | + case 'Harvetta' |
| 176 | + if useSolveCobraLPCPLEX |
| 177 | + %COBRA v2 format |
| 178 | + try |
| 179 | + load Harvetta_1_01d |
| 180 | + catch |
| 181 | + load Harvetta_1_01c |
| 182 | + end |
| 183 | + female.subSystems(strmatch('Transport, endoplasmic reticular',female.subSystems,'exact'))={'Transport, endoplasmic reticulum'}; |
| 184 | + female.subSystems(strmatch('Arginine and Proline Metabolism',female.subSystems,'exact'))={'Arginine and proline Metabolism'}; |
| 185 | + female.subSystems(strmatch(' ',female.subSystems,'exact'))={'Miscellaneous'}; |
| 186 | + |
| 187 | + if 1 |
| 188 | + %convert to v3 format except for coupling constraints |
| 189 | + female = convertOldStyleModel(female,0,0); |
| 190 | + end |
| 191 | + else |
| 192 | + if useReadCbModel |
| 193 | + female = readCbModel('Harvetta_1_03c', 'fileType','Matlab', 'modelName', 'male'); |
199 | 194 | else
|
200 | 195 | error('No single latest model could be found')
|
201 | 196 | end
|
|
0 commit comments