-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbl2seqparser.m
50 lines (40 loc) · 965 Bytes
/
bl2seqparser.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
function [p]=bl2seqparser(idx)
% $LastChangedDate: 2013-01-06 12:45:03 -0600 (Sun, 06 Jan 2013) $
% $LastChangedRevision: 328 $
% $LastChangedBy: jcai $
filename=sprintf('res/%d.res',idx);
txt = textread(filename,'%s','delimiter','\n','whitespace','');
% find first empty string in cell array, which occurs after the first
% consensus line
txt=strtrim(txt);
mt = find(cellfun('isempty',txt));
% eliminate empty lines
txt(mt) = [];
qlen=txt{2};
qlen=str2num(qlen(2:strfind(qlen,' ')-1));
[id]=i_strfind(txt,'Query:');
if isempty(id)
p=0;
return
end
cline=zeros(1,qlen);
coord=[];
for k=1:length(id)
%disp(txt{id(k)})
a=txt{id(k)};
[sid]=strfind(a,' ');
s1=str2num(a(sid(1):sid(2)));
s2=str2num(a(sid(end):end));
coord=[coord;[s1 s2]];
cline(s1:s2)=1;
end
%qlen
p=sum(cline)./qlen;
function [id]=i_strfind(txt,w)
id=[];
x=strfind(txt,w);
for k=1:length(x);
if ~isempty(x{k})
id=[id,k];
end
end