% Function calculates the GC content as a function of 
% sequence length. Returns two vectors - pos, and fgc
% with 'fgc' or GC fraction, along 'pos' on the 'seq'.

function [pos, fgc] = GCSlidingWindow (seq, winsize, overlap)
    seq_length = length(seq);
    start_pos = 1:overlap:(seq_length-winsize+1);
    end_pos = start_pos + winsize - 1;
    mid_point = (start_pos + end_pos)/2;
    
    % preallocate x, and y arrays
    pos = zeros(length(start_pos), 1);
    fgc = zeros(length(start_pos), 1);
    
    for i = 1:length(start_pos)
        subseq = seq(start_pos(i):end_pos(i));
        pos(i) = mid_point(i);
        fgc(i) = GC(subseq);
    end