-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdeambiguity.m
61 lines (47 loc) · 1.15 KB
/
deambiguity.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
function [seqtxt2]=deambiguity(seqtxt)
%DEAMBIGUITY - de-ambiguity DNA
%
%
% R = G A (purine)
% Y = T C (pyrimidine)
% K = G T (keto)
% M = A C (amino)
% S = G C
% W = A T
%
% B = G T C
% D = G A T
% H = A C T
% V = G C A
% N = A G C T (any)
% $LastChangedDate: 2013-01-06 12:45:03 -0600 (Sun, 06 Jan 2013) $
% $LastChangedRevision: 328 $
% $LastChangedBy: jcai $
[n,m]=size(seqtxt);
seqtxt2=[];
for k=1:n
s=seqtxt(k,:);
s2=i_builds2(s);
seqtxt2=[seqtxt2;s2];
end
function s2=i_builds2(s)
s2=[];
ambiChar='RYKMSW';
acgtChar={'GA','TC','GT','AC','CC','AT'};
% ambiChar='BDHV';
% acgtChar={'GTC','GAT','ACT','GCA'};
% ambiChar='N';
% acgtChar={'AGCT'};
for k=1:length(ambiChar)
ambic=ambiChar(k);
acgtc=acgtChar{k};
idx=find(s==ambic);
if ~isempty(idx)
for i=1:length(acgtc)-size(s2,1), s2=[s2;s]; end
fillings=transpose(acgtc);
for j=1:length(idx), s2(:,idx(j))=fillings; end
end
end
if isempty(s2)
s2=s;
end