-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_score_data.m
68 lines (51 loc) · 1.42 KB
/
load_score_data.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
function [data, tags] = load_score_data( file )
% [data, tags] = load_score_data( file )
%
% data is a structure with two fields:
% data.scores
% data.score_labels
%
fid = fopen( file );
data.scores = [];
data.score_labels = {};
tags = {};
found_score_labels = 0;
count = 0;
while ~feof( fid ) & ~found_score_labels
l = fgetl( fid );
if length(l) < 2 % problem!
data = {};
return;
end
cols = split_string( l );
if length( cols ) > 0 & strcmp( cols{1}, 'SCORE:' )
if (~found_score_labels )
found_score_labels = 1;
score_labels = { cols{2: (length(cols)-1)} };
end
end
end
fclose( fid );
%%%%%%%%%%%%%%%%%%%%
keyword = 'SCORE';
scorenums = [1:length( score_labels)] + 1;
command = ['grep ',keyword,' ',file,' | ',...
'awk ''{print $',num2str(scorenums(1))];
for i = 2: length( scorenums)
command = [command, ',$',num2str(scorenums(i))];
end
command = [command,...
'}'' | grep -v inp | ',...
'grep -v R | grep -v H | grep -v score | grep -v pdb | grep -v descr | ', ...
' grep -v total | grep -v S_ > data.txt'];
system(command);
scores = load('data.txt');
data.scores = scores;
data.score_labels = score_labels;
%%%%%%%%%%%%%%%%%%%%
command = ['grep ',keyword,' ',file,' | ',...
'awk ''{print $',num2str(scorenums(end)+1),'}'' | grep -v description > tags.txt'];
system(command);
tags = read_constructs( 'tags.txt' );
system( 'rm tags.txt' );
system( 'rm data.txt' );