clc; clear all;
[hlavicka,fasta]=fastaread('pokus.fasta');
 
% BEZ PŘEKRYVU
sig{1}=fasta(1:6000);
sig{2}=fasta(13001:19000);

okno=1000;

% vektory bazí
a=1+1i;c=-1-1i;g=-1+1i;t=1-1i;
for i=1:2
    delka_cteni(i)=length(sig{i});
    zapis=zeros(1,delka_cteni(i),'double');
    zapis(sig{i}=='A')=angle(a);
    zapis(sig{i}=='C')=angle(c);
    zapis(sig{i}=='G')=angle(g);
    zapis(sig{i}=='T')=angle(t);    
    KontigNum{i,1}=cumsum(zapis);
end


xsig{1}=KontigNum{1}(6000-okno+1:end);
% xsig{1}=xsig{1}-mean(xsig{1});
xsig{2}=KontigNum{2}(1:okno);
% xsig{2}=xsig{2}-mean(xsig{2});

% [XCorelCoef,lag]=xcorr(xsig{1},xsig{2},'coeff');
[XCorelCoef,lag]=xcov(xsig{1},xsig{2},'coeff');

[MAX,poziceMAX]=max(XCorelCoef);
[MIN,poziceMIN]=min(XCorelCoef);

 
% figure,plot(lag,XCorelCoef)