function [] = z_tsv2data(filename)


tsv_fid=fopen([filename, '.tsv'], 'r');



end_of_tsv_data=0;

header_nonsense=fgetl(tsv_fid);

tabstr=sprintf('\t');

coding_index=0;

noncoding_index=0;

while ~end_of_tsv_data
    current_line=fgetl(tsv_fid);
    if current_line==-1
        end_of_tsv_data=1;
        break
    else
        delimited_line=strsplit(current_line, tabstr);
        if str2num(delimited_line{2})
            noncoding_index=noncoding_index+1;
            noncoding_seqs{noncoding_index}=delimited_line{1};
            noncoding_counts(noncoding_index)=str2num(delimited_line{2});
        elseif findstr(delimited_line{2}, '*')
            noncoding_index=noncoding_index+1;
            noncoding_seqs{noncoding_index}=delimited_line{1};
            noncoding_counts(noncoding_index)=str2num(delimited_line{3});
        else
            coding_index=coding_index+1;
            coding_seqs{coding_index}=delimited_line{1};
            coding_counts(coding_index)=str2num(delimited_line{3});
        end
    end
end

fclose(tsv_fid);
    
coding_fid=fopen([filename, '_coding.data'], 'w');

fprintf(coding_fid, '%s \n', ['#Pool=', filename]);
fprintf(coding_fid, '%s \n', '#Frame=coding');
fprintf(coding_fid, '%s \n', ['#N_Sequences=', num2str(length(coding_counts))]);
fprintf(coding_fid, '%s \n', ['#Read_Length=', num2str(length(coding_seqs{1}))]);
fprintf(coding_fid, '%s \n', 'Sequence Counts');

for i=1:length(coding_counts)
    fprintf(coding_fid, '%s \n', [coding_seqs{i}, ' ', num2str(coding_counts(i))]);
end

fclose(coding_fid);

noncoding_fid=fopen([filename, '_noncoding.data'], 'w');

fprintf(noncoding_fid, '%s \n', ['#Pool=', filename]);
fprintf(noncoding_fid, '%s \n', '#Frame=noncoding');
fprintf(noncoding_fid, '%s \n', ['#N_Sequences=', num2str(length(noncoding_counts))]);
fprintf(noncoding_fid, '%s \n', ['#Read_Length=',num2str(length(noncoding_seqs{1}))] );
fprintf(noncoding_fid, '%s \n', 'Sequence Counts');

for i=1:length(noncoding_counts)
    fprintf(noncoding_fid, '%s \n', [noncoding_seqs{i}, ' ', num2str(noncoding_counts(i))]);
end

fclose(noncoding_fid);


end