-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfdb_Update_InfoFields.m
43 lines (37 loc) · 1.21 KB
/
fdb_Update_InfoFields.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
% This function updates the list of fieldnames in ar.info.fields and add
% missing fields to newinfo in case the new fit sequence has missing
% annotation
%
% fdb.info.fields contains existing fieldnames in ar.checksum
%
% Example:
% fdb.info.fields
%
% ans =
%
% config: {1x38 cell}
% optim: {1x51 cell}
% para: {'lb' 'mean' 'qFit' 'qLog10' 'std' 'type' 'ub'}
%
%
% The newinfo can be concorporated into fdb via:
% fdb.checksum.config{i,1} = newinfo.config;
% fdb.checksum.optim{i,1} = newinfo.optim;
% fdb.checksum.para{i,1} = newinfo.para;
function [fdb,newinfo] = fdb_Update_InfoFields(fdb,newinfo)
F = fieldnames(newinfo);
for f=1:length(F)
fn = fdb.info.fields.(F{f});
fn2 = fieldnames(newinfo.(F{f}));
new = setdiff(fn2,fn);
missing = setdiff(fn,fn2);
for i=1:length(missing)
newinfo.(F{f}).(missing{i}) = 'NA';
end
for i=1:length(new)
for j=1:fdb.info.N
fdb.checksum.(F{f}){j}.(new{i}) = 'NA';
end
fdb.info.fields.(F{f}){end+1} = new{i};
end
end