def TrimCigar(cigar) :
clippings = [1 for cigartype, cigarlength in cigar if cigartype in [4,5]]
if not clippings :
return cigar, 0, None
start = 0
end = 0
# soft and hard clippings can either be in the beginning or end of a read
for cigartype, cigarlength in cigar[:] :
if cigartype == 4 : # soft clipping
start = cigarlength
cigar.remove((cigartype, cigarlength))
elif cigartype == 5 : # hard clipping
cigar.remove((cigartype, cigarlength))
else :
break
for cigartype, cigarlength in reversed(cigar[:]) :
if cigartype == 4 : # soft clipping
end -= cigarlength
cigar.remove((cigartype, cigarlength))
elif cigartype == 5 : # hard clipping
cigar.remove((cigartype, cigarlength))
else :
break
return cigar, start, end if not end == 0 else None
# Give as input the quality string, md from Tags field, cigar, and mincut and maxcut,
# and ipos (starting index of current read in terms of quality sequence)
# and adjustbase (only needed if two reads
# are being merged, and second read starts later than first read).
# Md tells whether there are any base-changes lying closer or equal to mincut from
# read start edge, or at least maxcut away from same edge. These base-changes will be
# discarded, that is, their corresponding base
# quality will be set to 0 (or ! in ascii format).
# Returns updated quality string.
评论列表
文章目录