% data = serp_read(target, replicates);
%
% Simple stringread function to parse txt files from Bukau scripts.
%
% target -      string containing the target name, i.e. 'Nic96'
% replicates -  number of replicates, i.e. 4
%
% MB 29/04/21

function data = serp_read(target, replicates);

for i = 1:replicates,
    file_total = [target '_total_No' num2str(i) '_Reads.txt'];
    disp(['Reading ' file_total ' ...']);
    fid = fopen (file_total);
    cdata = textscan(fid,'%n%n%n%n%s%n%n', 'Delimiter', '\t', 'EmptyValue', -5);
    fclose (fid);
    data(i).total = cdata;
    disp (['Returned length of ' num2str(size (cdata{1,6},1)) ' and Max reads ' num2str(max (cdata{1,6}(:) ))]);

    file_IP = [target '_IP_No' num2str(i) '_Reads.txt'];
    disp(['Reading ' file_IP ' ...']);
    fid = fopen (file_IP);
    cdata = textscan(fid,'%n%n%n%n%s%n%n', 'Delimiter', '\t', 'EmptyValue', -5);
    fclose (fid);
    data(i).IP = cdata;
    disp (['Returned length of ' num2str(size (cdata{1,6},1)) ' and Max reads ' num2str(max (cdata{1,6}(:) ))]);
end