def get_read_position(read, soft_clip_threshold):
    ''' get the read position (taking account of clipping) '''
    is_spliced = False

    if read.is_reverse:
        pos = read.aend
        if read.cigar[-1][0] == 4:
            pos = pos + read.cigar[-1][1]
        start = read.pos

        if ('N' in read.cigarstring or
            (read.cigar[0][0] == 4 and
             read.cigar[0][1] > soft_clip_threshold)):

            cigar = read.cigar[::-1]
            is_spliced = find_splice(cigar)
    else:
        pos = read.pos
        if read.cigar[0][0] == 4:
            pos = pos - read.cigar[0][1]
        start = pos

        if ('N' in read.cigarstring or
            (read.cigar[-1][0] == 4 and
             read.cigar[-1][1] > soft_clip_threshold)):
            is_spliced = find_splice(read.cigar)

    return start, pos, is_spliced
def get_read_position ( read , soft_clip_threshold ) : is_spliced = False if read . is_reverse : pos = read . aend if read . cigar [ - 1 ] [ 0 ] == 4 : pos = pos + read . cigar [ - 1 ] [ 1 ] start = read . pos if ( 'N' in read . cigarstring or ( read . cigar [ 0 ] [ 0 ] == 4 and read . cigar [ 0 ] [ 1 ] > soft_clip_threshold ) ) : cigar = read . cigar [ : : - 1 ] is_spliced = find_splice ( cigar ) else : pos = read . pos if read . cigar [ 0 ] [ 0 ] == 4 : pos = pos - read . cigar [ 0 ] [ 1 ] start = pos if ( 'N' in read . cigarstring or ( read . cigar [ - 1 ] [ 0 ] == 4 and read . cigar [ - 1 ] [ 1 ] > soft_clip_threshold ) ) : is_spliced = find_splice ( read . cigar ) return start , pos , is_spliced
get the read position (taking account of clipping)