-
Notifications
You must be signed in to change notification settings - Fork 3
/
slml2info.m
134 lines (117 loc) · 3.61 KB
/
slml2info.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
function answer = slml2info( varargin )
% SLML2INFO Generate a report from information extracted from a genearative model file
%
% List Of Input Arguments Descriptions
% ----------------------- ------------
% filenames List of files
% options Options structure
%
% Example
% > filenames = {'/path/to/model/file/model.mat'};
% > answer = slml2info( filenames );
% Author: Ivan E. Cao-Berg, Xin Lu, Robert F. Murphy
% Copyright (C) 2020 Murphy Lab
% Carnegie Mellon University
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published
% by the Free Software Foundation; either version 2 of the License,
% or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
% General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
% 02110-1301, USA.
%
% For additional information visit http://murphylab.web.cmu.edu or
% send email to murphy@cmu.edu
%default answer - leave as is
answer = false;
%parse vargargin
if isdeployed()
filename = is_deployed(varargin{1});
load(filename);
else
if length(varargin) == 1
files = varargin{1};
options = {};
elseif length(varargin) == 2
files = varargin{1};
options = varargin{2};
else
warning('Wrong number of input arguments');
return
end
end
if ~iscell( files )
warning('Input argument files must be a cell-array')
return
end
if length(files) == 1
filename = files{1};
else
for i=1:length(files)
load(files{i});
if ~is_tcell_model( model )
warning('Method only accepts one input model of this class/type');
return
end
end
end
%default value is set to report as to not break functionality in
%CellOrganizer for Galaxy and CellOrganizer for Docker. Do not change this
%value
if ~isdeployed() && nargin == 1
options.output_directory = [pwd filesep 'report'];
end
if ~isfield( options, 'output_directory' )
options.output_directory = [pwd filesep 'report'];
end
if ~exist( options.output_directory )
disp(['Creating output directory ' options.output_directory ]);
mkdir( options.output_directory )
end
outputfile = [ options.output_directory filesep 'index.html' ];
if exist(outputfile, 'file')
delete(outputfile)
end
fileID = fopen( outputfile, 'w' );
html_init( fileID );
if exist( 'filename', 'var' )
if exist(filename, 'file')
load( filename );
header2html( fileID,'Filename' );
text2html( fileID, filename );
else
disp(['Filename ' filename ' does not exist.']);
answer = false;
return
end
%when filename exists and files == 1
model.model_filename=filename;
model2info_v2( model, fileID, options );
else
% when files > 1 and filename ! exist
filename=files{1};
load( filename ); %this replaces current options
header2html( fileID,'Filename' );
text2html( fileID, filename );
model.model_filename=files;
model2info_v2( model, fileID, options );
end
html_close( fileID );
fclose( fileID );
if exist([pwd filesep 'html'])
movefile([pwd filesep 'html' filesep '*'], options.output_directory );
rmdir([pwd filesep 'html'], 's' );
end
if isdeployed
close all
end
answer = true;
end%slml2info