Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to SBML 5.16 #1054

Merged
merged 13 commits into from
Dec 12, 2017
Prev Previous commit
Moved extension <-> Format assignment into internal function
  • Loading branch information
tpfau committed Dec 11, 2017
commit 3324ebceec1805b25a748d5e1fd1a59020c2ed0c
64 changes: 32 additions & 32 deletions src/base/io/writeCbModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -160,44 +160,14 @@
if fileNameFull
[folder, fileName, extension] = fileparts([filePath filesep fileNameFull]);
fileName = [folder filesep fileName extension];
switch extension
case '.MPS'
format = 'mps';
case {'.xls', '.xlsx'}
format = 'xls';
case '.txt'
format = 'text';
case '.xml'
format = 'sbml';
case '.mat'
format = 'mat';
case '.expa'
format = 'expa';
otherwise
format = 'unknown';
end
format = getFormatFromExtension(extension);
else
return;
end
else
if strcmp(format,'toselect') % no format was given. try to detect from fileName.
[~, ~, extension] = fileparts(fileName);
switch extension
case '.MPS'
format = 'mps';
case {'.xls', '.xlsx'}
format = 'xls';
case '.txt'
format = 'text';
case '.xml'
format = 'sbml';
case '.mat'
format = 'mat';
case '.expa'
format = 'expa';
otherwise
format = 'unknown';
end
format = getFormatFromExtension(extension);
end
end
% Use lower case
Expand Down Expand Up @@ -259,3 +229,33 @@
geneStr = [geneStr ' ' geneNames{i}];
end
geneStr = strtrim(geneStr);



function format = getFormatFromExtension(extension)
%Get the format from the file extension.
%
% INPUT:
%
% extension: The file extension
%
% OUTPUT:
%
% format: The file format

switch extension
case '.MPS'
format = 'mps';
case {'.xls', '.xlsx'}
format = 'xls';
case '.txt'
format = 'text';
case '.xml'
format = 'sbml';
case '.mat'
format = 'mat';
case '.expa'
format = 'expa';
otherwise
format = 'unknown';
end