1function sbmlStruct = getSBMLDefaultStruct(varargin) 2% structure = getSBMLDefaultStruct(element_name, level, version, 3% packages (optional), packageVersion (optional)) 4% 5% Takes 6% 7% 1. element_name - the name of the SBML element whose structure is wanted 8% 2. level - an integer for the value of the level field to be added 9% 3. version - an integer for the value of the version field to be added 10% 4. packages, cell array of package names 11% 5. packageVersion, an integer array representing the SBML package versions 12% 13% Returns 14% 15% 1. structure - the original structure with additional fields 'level' and 16% 'version' added to this and every child 17% structure 18% 19 20% Thanks to Thomas Pfau for providing this function. 21 22%<!--------------------------------------------------------------------------- 23% This file is part of libSBML. Please visit http://sbml.org for more 24% information about SBML, and the latest version of libSBML. 25% 26% Copyright (C) 2013-2017 jointly by the following organizations: 27% 1. California Institute of Technology, Pasadena, CA, USA 28% 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK 29% 3. University of Heidelberg, Heidelberg, Germany 30% 31% Copyright (C) 2009-2013 jointly by the following organizations: 32% 1. California Institute of Technology, Pasadena, CA, USA 33% 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK 34% 35% Copyright (C) 2006-2008 by the California Institute of Technology, 36% Pasadena, CA, USA 37% 38% Copyright (C) 2002-2005 jointly by the following organizations: 39% 1. California Institute of Technology, Pasadena, CA, USA 40% 2. Japan Science and Technology Agency, Japan 41% 42% This library is free software; you can redistribute it and/or modify 43% it under the terms of the GNU Lesser General Public License as 44% published by the Free Software Foundation. A copy of the license 45% agreement is provided in the file named "LICENSE.txt" included with 46% this software distribution and also available online as 47% http://sbml.org/software/libsbml/license.html 48%----------------------------------------------------------------------- --> 49 50pkgCount = 0; 51 52if (nargin < 3) 53 error('not enough input arguments'); 54else 55 element_name = varargin{1}; 56 level = varargin{2}; 57 version = varargin{3}; 58end; 59packages = {}; 60packageVersion = 1; 61if (nargin > 3) 62 if (nargin < 5) 63 error('not enough input arguments'); 64 end; 65 pkgCount = length(varargin{4}); 66 packages = varargin{4}; 67 if (length(varargin{5}) ~= pkgCount) 68 error('need a version number for each package'); 69 end; 70 packageVersion = varargin{5}; 71end; 72 73fieldData = [getStructureFieldnames(element_name, level, version, ... 74packages, packageVersion) ; getDefaultValues(element_name, level, ... 75version, packages, packageVersion)]; 76 77if ~isempty(fieldData) 78 fieldData = reshape(fieldData,numel(fieldData),1); 79 sbmlStruct = struct(fieldData{:}); 80else 81 sbmlStruct = struct(); 82end; 83end