-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PEtabSelect: Save/Load global pets struct
By saving the global struct "pets", the history and state of model selection is not lost when the model selection terminates The pets struct can be recovered by calling arPetsLoad
- Loading branch information
1 parent
caf4fbf
commit 16d4e3c
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function arPetsLoad(name, PetsOutputDir) | ||
% ARPETSLOAD loads the PEtab Select struct "pets" from file. | ||
% | ||
% The python module petab_select cannot be saved to/loaded from a .mat file | ||
% Therefore, only the relevant fields are saved and loaded. | ||
% | ||
% INPUT: | ||
% name: Name of the file to load the struct from. | ||
% PetsOutputDir: Directory to load the file from. | ||
% | ||
% SEE: arPetsSave | ||
|
||
arguments | ||
name char = 'petsSave'; | ||
PetsOutputDir char = fullfile(pwd(), 'PEtabSelect', 'Results'); | ||
end | ||
|
||
% initialize new pets struct | ||
arPetsInitModule; | ||
|
||
% load the struct from file | ||
loadPath = fullfile(PetsOutputDir, name); | ||
load(loadPath, "petsSave"); | ||
|
||
% assign the filed to the global variable | ||
pets.history = petsSave.history; | ||
pets.problem = petsSave.problem; | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function arPetsSave(name, PetsOutputDir) | ||
% ARPETSSAVE saves the PEtab Select struct "pets" to file. | ||
% | ||
% The python module petab_select cannot be saved to/loaded from a .mat file | ||
% Therefore, only the relevant fields are saved and loaded. | ||
% | ||
% INPUT: | ||
% name: Name of the file to save the struct to. | ||
% PetsOutputDir: Directory to save the file to. | ||
% | ||
% SEE: arPetsLoad | ||
|
||
arguments | ||
name char = 'petsSave'; | ||
PetsOutputDir char = fullfile(pwd(), 'PEtabSelect', 'Results'); | ||
end | ||
|
||
% access the global pets struct | ||
global pets | ||
|
||
% create a struct with the relevant fields | ||
petsSave = struct(); | ||
petsSave.history = pets.history; | ||
petsSave.problem = pets.problem; | ||
|
||
% save the struct to file | ||
savePath = fullfile(PetsOutputDir, name); | ||
save(savePath, "petsSave") | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters