loadEcModel Loads the ecModel that matches the modelAdapter. By default, it loads the models/ecModel.yml in the directory specified as param.path in the modelAdapter. Alternative files in the same folder can be loaded by providing the appropriate filename. If loading models from other locations, one can directly use readYAMLmodel. Input: filename name of the ecModel file (Optional, default 'ecModel.yml'). Fill should be located in the models/ subfolder of param.path as specified in the modelAdapter. modelAdapter a loaded model adapter, from where the model folder is read (Optional, will otherwise use the default model adapter). Output: model an ecModel in GECKO 3 format (with ecModel.ec structure) Usage: model = loadEcModel(filename, modelAdapter)
0001 function model = loadEcModel(filename, modelAdapter) 0002 % loadEcModel 0003 % Loads the ecModel that matches the modelAdapter. By default, it loads 0004 % the models/ecModel.yml in the directory specified as param.path in 0005 % the modelAdapter. Alternative files in the same folder can be loaded by 0006 % providing the appropriate filename. If loading models from other 0007 % locations, one can directly use readYAMLmodel. 0008 % 0009 % Input: 0010 % filename name of the ecModel file (Optional, default 'ecModel.yml'). 0011 % Fill should be located in the models/ subfolder of 0012 % param.path as specified in the modelAdapter. 0013 % modelAdapter a loaded model adapter, from where the model folder is 0014 % read (Optional, will otherwise use the default model adapter). 0015 % 0016 % Output: 0017 % model an ecModel in GECKO 3 format (with ecModel.ec structure) 0018 % 0019 % Usage: 0020 % model = loadEcModel(filename, modelAdapter) 0021 0022 if nargin < 2 || isempty(modelAdapter) 0023 modelAdapter = ModelAdapterManager.getDefault(); 0024 if isempty(modelAdapter) 0025 error('Either send in a modelAdapter or set the default model adapter in the ModelAdapterManager.') 0026 end 0027 end 0028 params = modelAdapter.getParameters(); 0029 if nargin < 1 || isempty(filename) 0030 filename = 'ecModel.yml'; 0031 else 0032 end 0033 0034 if ~endsWith(filename,{'yml','yaml'}) 0035 error(['ecModels should preferably be distributed in YAML file format, ', ... 0036 'as otherwise model content will be lost. If the model is in ', ... 0037 'SBML format, you can use the usual importModel function to load ', ... 0038 'this as any other genome-scale model.']) 0039 end 0040 0041 filename = fullfile(params.path,'models',filename); 0042 if endsWith(filename,{'yml','yaml'}) 0043 model = readYAMLmodel(filename); 0044 elseif endsWith(filename,{'xml','sbml'}) 0045 model = importModel(filename); 0046 end 0047 end