-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDFTDNA4D.m
52 lines (42 loc) · 1.02 KB
/
DFTDNA4D.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
function [ PS] = DFTDNA4D(seq)
% Program to compute DFT of a DNA sequence represented by 4-D binary
% indicators
% Input: DNA sequece
% Output: Fourier power spectrum of the DNA sequene
%
% Changchuan Yin, Ph.D.
% Dept. of Mathematics, Statistics and Computer Science
% University of Illinois at Chicago
% Last update 02/08/2016
%
% Citation
% Yin, C., & Wang, J. (2016).Periodic power spectrum with applications in detection of latent periodicities
% in DNA sequences. Journal of Mathematical Biology.
seq=upper(seq);
N = length(seq);
bA = zeros(1,N);
bT = zeros(1,N);
bC = zeros(1,N);
bG = zeros(1,N);
for i=1:N
if strcmp(seq(i),'A')
bA(i) = 1;
elseif strcmp(seq(i),'T')
bT(i) = 1;
elseif strcmp(seq(i),'C')
bC(i) = 1;
elseif strcmp(seq(i),'G')
bG(i) = 1;
end
end
%Calculate the general FFT spectrum
FFTA = fft(bA,N);
PSA = abs(FFTA).^2;
FFTT = fft(bT,N);
PST = abs(FFTT).^2;
FFTC = fft(bC,N);
PSC = abs(FFTC).^2;
FFTG = fft(bG,N);
PSG = abs(FFTG).^2;
PS = PSA + PST + PSC + PSG;
end