-
Notifications
You must be signed in to change notification settings - Fork 1
/
appendAdapters.m
73 lines (62 loc) · 2.31 KB
/
appendAdapters.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
69
70
71
72
73
function [adapterList,probeHeader,probeSequence,probeSequence3Seg,probeSequenceCore]...
=appendAdapters(adapterList,oligos,params)
% params = struct('species','Mouse','verbose',1,...
% 'dir1','C:\FISHerMan\Db\Mouse.alladapters.fas',...
% 'gf','GGAATCGTTGCGGGTGTCCT','grr','CCGCAACATCCAGCATCGTG');
if params(1).verbose
disp('concatenating oligos with adapters');
end
[Header, Sequence] = fastaread(oligos);
Header = Header';
Sequence = Sequence';
pos = regexp(Header, ':');
trimmedHeader = Header;
for n = 1:length(Header)
trimmedHeader{n,1} = Header{n,1}(1:pos{n,1}(1)-1);
end
adapterHeader = unique(trimmedHeader, 'stable');
geneNum = length(adapterHeader);
[~, adapterSequence] = fastaread(adapterList);
adapterSequence = adapterSequence(1:geneNum)';
adapterList = [params(1).species '.adapters.txt'];
if exist(adapterList, 'file')
delete(adapterList);
end
fastawrite(adapterList, adapterHeader, adapterSequence);
probeHeader = {};
probeSequence = {};
probeSequence3Seg = {};
probeSequenceCore = {};
for n = 1:length(adapterHeader)
if params(1).verbose && mod(n, 1000) == 1
disp([' concatenating oligos for transcript no. ' num2str(n)]);
end
index = ismember(trimmedHeader, adapterHeader{n,1});
probeHeader(end+1:end+sum(index),1) = Header(index);
probe = Sequence(index);
probe3Seg = Sequence(index);
probeCore = Sequence(index);
for m = 1:length(probe)
temp = probe{m,1};
temp3Seg = probe3Seg{m,1};
tempCore = probeCore{m,1};
temp = strcat(params(1).gf, adapterSequence{n,1}, temp, params(1).grr);
temp3Seg = strcat(adapterSequence{n,1}, temp3Seg, params(1).grr, 'CCC');
tempCore = strcat(adapterSequence{n,1}(11:20), tempCore, params(1).grr(1:10));
probe{m,1} = temp;
probe3Seg{m,1} = temp3Seg;
probeCore{m,1} = tempCore;
end
probeSequence(end+1:end+sum(index),1) = probe;
probeSequence3Seg(end+1:end+sum(index),1) = probe3Seg;
probeSequenceCore(end+1:end+sum(index),1) = probeCore;
end
% if params(1).verbose
% disp('saving the probe fasta file');
% end
%
% probes = [params.species '.probes.fas'];
% if exist(probes, 'file')
% delete(probes);
% end
% fastawrite(probes, probeHeader, probeSequence);