-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslml2report.m
214 lines (191 loc) · 6 KB
/
slml2report.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
function answer = slml2report( model1_filename, model2_filename )
% SLML2REPORT Generate a report comparing two generative models
%
% List Of Input Arguments Descriptions
% ----------------------- ------------
% model1 A generative model filename
% model2 A generative model filename
%
% Example
% > filename1 = '/path/to/model/model1.mat';
% > filename2 = '/path/to/model/model2.mat';
% answer = slml2report( filename1, filename2 );
% Author: Robert F. Murphy
%
% Copyright (C) 2013-2019 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://www.cellorganizer.org or
% send email to [email protected]
answer = false;
if nargin ~= 2
warning( ['Wrong number of input arguments. If slml2report' ...
' is not deployed, then the number of input arguments must be 2.'] );
return
end
try
load( model1_filename ); model1 = model; clear model;
load( model2_filename ); model2 = model; clear model;
catch err
warning('Unable to open or read model files')
getReport(err)
return;
end
try
nuc_class_same = strcmp(model1.nuclearShapeModel.class, model2.nuclearShapeModel.class);
if ~nuc_class_same
warning('Nuclear shape model class is not the same.');
return
end
catch err
getReport(err)
return
end
try
cell_class_same = strcmp(model1.cellShapeModel.class, model2.cellShapeModel.class);
if ~cell_class_same
warning('Cell shape model class is not the same.');
return
end
catch err
getReport(err)
return
end
try
prot_class_same = strcmp(model1.proteinModel.class, model2.proteinModel.class);
if ~prot_class_same
warning('Protein model class is not the same.');
return
end
catch err
getReport(err)
return
end
try
nuc_type_same = strcmp(model1.nuclearShapeModel.type, model2.nuclearShapeModel.type);
if ~nuc_type_same
warning('Nuclear shape model type is not the same.');
return
end
catch err
getReport(err)
return
end
try
cell_type_same = strcmp(model1.cellShapeModel.type, model2.cellShapeModel.type);
if ~cell_type_same
warning('Cell Shape model type is not the same.');
return
end
catch err
getReport(err)
return
end
try
prot_type_same = strcmp(model1.proteinModel.type, model2.proteinModel.type);
if ~prot_type_same
warning('Protein model type is not the same.');
return
end
catch err
getReport(err)
return
end
% param = struct([]);
% param = ml_initparam(param, struct('verbose', true, 'includenuclear', true, ...
% 'includecell', true, 'includeprot', true));
param = struct('verbose', true, 'includenuclear', true, 'includecell', true, ...
'includeprot', true);
models{1} = model1;
models{2} = model2;
classlabels = [];
for i=1:2
try
classlabels = strcat(classlabels, [models{i}.proteinModel.class int2str(i) ';']);
catch
classlabels = strcat(classlabels, [models{i}.proteinModel.type int2str(i) ';']);
end
classlabels = classlabels(1:end);
end
if exist('./report', 'dir')
rmdir('./report', 's')
end
mkdir('./report');
if isdeployed()
fileID = fopen('./index.md', 'w');
fprintf(fileID, '# slml2report output\n');
fprintf( fileID,'## Filenames\n' );
fprintf( fileID,'```\n' );
fprintf( fileID, ['model1_filename = ' model1_filename '\n'] );
fprintf( fileID, ['model2_filename = ' model2_filename '\n'] );
fprintf( fileID,'```\n' );
else
fileID = fopen('./index.m', 'w');
fprintf(fileID, '%%%% slml2report output\n');
fprintf(fileID, '%%%%%% Filenames\n');
fprintf(fileID, 'model1_filename = ''%s'';\n', model1_filename);
fprintf(fileID, 'model2_filename = ''%s'';\n', model1_filename);
fprintf(fileID, '\n');
end
%%%%%%%%%%%%%%%%%%%%%%% SWITCH STATEMENTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if isdeployed()
f = @models2report_running_when_deployed;
else
f = @models2report_running_on_matlab_engine;
end
switch model1.proteinModel.class
case 'vesicle'
switch model1.proteinModel.type
case 'gmm'
f(models, param, classlabels, fileID);
otherwise
fprintf('Case for proteinModel.type: ''%s'' ot yet implemented', ...
model1.proteinModel.type);
return
end
otherwise
fprintf('Case for proteinModel.class: ''%s'' not yet implemented', ...
model1.proteinModel.class);
return
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fclose(fileID);
if isdeployed()
system(['pandoc ' pwd filesep 'index.md -o index.html']);
if exist([pwd filesep 'index.html'], 'file')
movefile([pwd filesep 'index.html'], [pwd filesep 'report']);
end
else
publish('./index.m');
movefile('./html/index.html', './report');
rmdir('./html', 's');
end
image_info = dir('*.png');
image_names = {image_info.name};
for i = 1:length(image_names)
movefile(image_names{i}, ['report' filesep image_names{i}]);
end
if exist('./index.m', 'file')
delete('./index.m')
end
if exist('./index.md', 'file')
delete('./index.md')
end
close all
answer = true;
end