-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyncCodex.m
More file actions
40 lines (34 loc) · 896 Bytes
/
syncCodex.m
File metadata and controls
40 lines (34 loc) · 896 Bytes
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
function [ removed ] = syncCodex( codexPath )
% syncCodex: Removes Genes from codex that are not in the Database
load('AllenAPI_Paths.mat')
if ~exist('codexPath','var')
codexPath = [AtlasGeneDir 'geneCodex.mat'];
end
codex = load(codexPath);
gc = codex.geneCodex;
genes = gc(2:end,1);
empties = find(cellfun(@(x) isempty(x),genes));
if ~isempty(empties)
gc(empties,:) = [];
end
genes = gc(2:end,1);
A = dir(AtlasGeneDir);
A = A([A.isdir]);
A = A(cellfun(@(x) ~strcmp(x(1),'.'),{A.name}));
geneDirs = {A.name};
rmv = [];
for j=1:numel(genes),
if ~any(strcmp(geneDirs,genes{j}))
rmv = [rmv j];
end
end
removed = genes(rmv);
gc(rmv,:) = [];
codex.geneCodex = gc;
codex.TotalGenes = size(gc,1)-1;
codex.LastUpdate = date;
fn = fieldnames(codex);
for i=1:numel(fn),
eval([fn{i} '= codex.(fn{i});']);
end
eval(['save(''' codexPath ''',''' strjoin(fn,''',''') ''');'])