Scripts
This is the entry point for our code, it calls all other relevant functions.
Run_main
Code
1function [settings, sb, results, model_folders, plots] = ... 2 Run_main(Folder, Analysis, settings) 3% Main function to perform various analyses on a selected model 4% using a given settings file. 5% 6% Syntax: [settings, sb, results, model_folders, plots] = ... 7% Run_main(Folder, Analysis, settings) 8% 9% Inputs: 10% - Folder: Name of the model folder located at 11% "Repository_name"/Matlab/Model/ 12% - Analysis: Integer code representing the desired analysis to run: 13% 1 = Diagnostics 14% 2 = Parameter Estimation 15% 3 = Local Sensitivity Analysis 16% 4 = Global Sensitivity Analysis 17% 5 = Profile Likelihood Analysis 18% 6 = Reproduce a previous analysis 19% 7 = Reproduce the plots of a previous analysis 20% 8 = Import model files 21% - Settings: Name of the settings file located at 22% "Repository_name"/Matlab/Model/"Folder"/Matlab/Settings 23% 24% Outputs: 25% - stg: Structure containing the settings used for the analysis 26% - sb: Structure containing the sbtab data 27% - rst: Structure containing the results of the analysis 28% - mmf: Structure containing folder paths 29% - plots: Structure containing plot data (if applicable) 30% 31% This function performs the following steps: 32% 1. Collect user inputs and create a timestamp 33% 2. Get the main MATLAB folder and add it to the path if needed 34% 3. Load settings and data based on user choices 35% 4. Create the folder structure for model files 36% 5. Import or generate sbtab data if needed 37% 6. Re-Run the selected analysis 38% 7. Plot results (if applicable) 39% ?? 8. Save analysis results and plots (if specified in settings) 40 41user_choices = {Folder, Analysis, settings}; 42 43%Get the date and time 44date_stamp = string(year(datetime)) + "_" + ... 45 string(month(datetime)) + "_" + string(day(datetime)) ... 46 + "__" + string(hour(datetime)) + "_" + string(minute(datetime)) ... 47 + "_" + string(round(second(datetime))); 48 49% Get the folder where the MATLAB code and models are located 50Matlab_main_folder = fileparts(mfilename('fullpath')) + "/"; 51Matlab_main_folder = strrep(Matlab_main_folder,"\","/"); 52 53addpath(genpath(Matlab_main_folder)) 54if ~contains(strrep(path, "\", "/"), ... 55 extractAfter(Matlab_main_folder, ... 56 strlength(Matlab_main_folder) - 1)) 57 % If the folder is not in the path, add it 58 addpath(genpath(Matlab_main_folder)); 59end 60 61model_folders.main = Matlab_main_folder; 62 63% Name of the various analysis that can be run with this code 64analysis_options = ["Diagnostics", "Parameter Estimation", ... 65 "Local Sensitivity Analysis", "Global Sensitivity Analysis", ... 66 "Profile Likelihood Analysis", "Reproduce a previous analysis", ... 67 "Reproduce the plots of a previous analysis", "Import model files"]; 68 69% Code for choosing the model and loading the settings files 70[settings, results, sb] = ... 71 f_user_input(model_folders, analysis_options, user_choices); 72 73% Get the folder structure used for the model files 74[model_folders] = default_folders(settings, model_folders, date_stamp); 75 76% Runs the import scripts if chosen in settings 77if settings.import 78 [settings, sb] = f_import(settings, model_folders); 79else 80 % Creates a struct based on the sbtab that is used elswhere in the code 81 % and also adds the number of experiments and outputs to the settings 82 % variable 83 if isempty(sb)% check needed for plot reproduction 84 [settings, sb] = f_generate_sbtab_struct(settings, model_folders); 85 end 86end 87 88% Runs the Analysis chosen by the user input 89 [results, settings] = ... 90 f_analysis(settings, settings.analysis, model_folders, ... 91 analysis_options, results); 92 93% Plots the results of the analysis, this can be done independently after 94% loading the results of a previously run analysis 95plots = []; 96if settings.plot 97 plots = f_plot(results, settings, model_folders); 98 % Save plots results if chosen in settings 99 % if settings.save_results 100 % f_save_plots(model_folders) 101 % end 102end 103 104% Save Analysis results if chosen in settings 105if settings.save_results 106 % try 107 f_save_analysis(settings, sb, results, model_folders, plots) 108 % catch 109 % end 110end 111end
This is the main script from the MATLAB® portion of the workflow. Depending on the configurations on the settings file and choices on the user facing prompts it can call functions to:
Perform conversions of the SBtab:
SBtab( .xlsx) to SBtab (.tsv)
SBtab (.xlsx) to MATLAB® SimBiology® (.m, .sbproj)
MATLAB® SimBiology® to SBML (.xml)
Perform analysis on the model:
Diagnostics
Parameter Estimation
Global Sensitivity Analysis
It can also reproduce a the calculations of a previous analysis or just its plots.