f='after2013';
list=dir(f);
start_location=[];
for i=3:1:size(list,1)
    ID=list(i).name(1:end-4);
    seq=fastaread([f,'/',ID,'.fna']);
    seq=seq.Sequence;
    seq=upper(seq);
    rseq=seqrcomplement(seq);
    L=size(seq,2);
    load(['gbffmat/',ID,'.gbff.mat']);
    cds=g.CDS;
    for j=1:1:size(cds,2)
        c=1;
        if contains(cds(j).location,'complement')
            s=rseq;
            Loc=L-cds(j).indices+1;
        else
            s=seq;
            Loc=cds(j).indices;
        end
        if Loc(1)>L-2
            disp('!!')
            continue
        end
        start=s(Loc(1):Loc(1)+2);
        if ~(strcmp(start,'ATG') ||...
           strcmp(start,'CTG') ||...
           strcmp(start,'GTG') ||...
           strcmp(start,'TTG'))
            continue
        end
        p=Loc(1)-3;
        while p>=1 &&...
              ~(...
              strcmp(s(p:p+2),'TAA') ||...
              strcmp(s(p:p+2),'TAG') ||...
              strcmp(s(p:p+2),'TGA') ||...
              contains(s(p:p+2),'N')...
              )
            if strcmp(s(p:p+2),'ATG') ||...
               strcmp(s(p:p+2),'CTG') ||...
               strcmp(s(p:p+2),'GTG') ||...
               strcmp(s(p:p+2),'TTG')
                c=c+1;
            end
            p=p-3;
        end
        if size(start_location,2)<c
            start_location(1,c)=0;
        end
        start_location(c)=start_location(c)+1;
    end
end