-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaptReadSequenceData.m
More file actions
68 lines (54 loc) · 1.71 KB
/
aptReadSequenceData.m
File metadata and controls
68 lines (54 loc) · 1.71 KB
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
function aptReadSequenceData(filename, observables,predictors)
%APTREADSEQUENCEDATA reads in data from filename.
% filename is 'str'
global apt
if ~exist('observables','var')
observables = {'MaxIncrease'};
end
if ~exist('observables','var')
predictors = {};
end
if ~isfield(apt,'data')
id = 1;
else
id = length(apt.data) + 1;
end
[header, data, dataCell] = aptReadCSVHeaderFile(filename, ',', true);
isSequence = strcmp(header,{'Sequence'});
apt.data(id).sequence = strrep(dataCell(:,isSequence),'_x000D_','');
for iObs = 1:length(observables)
idxObs = find(strcmp(header,observables(iObs)));
apt.data(id).obsName{iObs} = observables{iObs};
if isempty(idxObs)
apt.data(id).Y{iObs} = nan(size(apt.data(id).sequence));
continue
end
apt.data(id).Y{iObs} = data(:,idxObs);
end
for iPred = 1:length(predictors)
idxPred = find(strcmp(header,predictors(iPred)));
apt.data(id).predName{iPred} = predictors{iPred};
if isempty(idxPred)
apt.data(id).X{iPred} = nan(size(apt.data(id).sequence));
continue
end
apt.data(id).X{iPred} = data(:,idxPred);
end
% Remove nan data?
if isfield(apt.config,'RemoveNaNData') && apt.config.RemoveNaNData
idxnan = false(size(apt.data(id).Y{1}));
for iY = 1:length(apt.data(id).Y)
idxnan = idxnan | isnan(apt.data(id).Y{iY});
end
for iY = 1:length(observables)
apt.data(id).Y{iY} = apt.data(id).Y{iY}(~idxnan);
end
for iPred = 1:length(predictors)
apt.data(id).X{iPred} = apt.data(id).X{iPred}(~idxnan);
end
apt.data(id).sequence = apt.data(id).sequence(~idxnan);
end
apt.data(id).array = id; % default behavior
apt.data(id).conc = nan;
apt.data(id).filename = filename;
end