function TAG_new = tag_trans(TAG_old)
%%% this function transfer tags to make the positions of mismatch from the
%%% very beginning of the reads and calculate the length of the reads

TAG_new = char(zeros(size(TAG_old)));

A = regexp(mat2cell(TAG_old,ones(size(TAG_old,1),1),size(TAG_old,2)),'(?<=L{).*(?=}M{)','match');
B = regexp(mat2cell(TAG_old,ones(size(TAG_old,1),1),size(TAG_old,2)),'(?<=M{).*(?=})','match');

for i = 1:size(TAG_old,1)
    try
    length = my_str2num(A{i}{1});
    catch
        disp('error');
    end
    errors = my_str2num(B{i}{1});
    if(errors == 0)
        errors = 0;
    else
        errors = errors+length(1); 
        length = length-size(errors,2);
    end

    e_str = sprintf('%d,',errors);
    e_str(end) = [];
    tag_new_tmp = ['L{',int2str(length(2)),'}M{',e_str,'}'];
    TAG_new(i,1:size(tag_new_tmp,2)) = tag_new_tmp;
end
