def _tag_aln_check(aln, seqlen, barcodelen, orientation, edit=0, pos=0):
    r_len = aln.r_end - aln.r_pos
    mismatches = barcodelen - r_len + aln.mismatches

    if mismatches <= edit:
        if orientation == '5' and aln.q_pos <= pos:  # allow at most {pos} extra bases at start
            return True, ''
        elif orientation == '3' and aln.q_end >= seqlen - pos:  # allow at most {pos} extra bases at end
            return True, ''
        else:
            return False, 'Not at right location'
    else:
        return False, 'too many mismatches'

    return False, '?'
dataset/ETHPy150Open ngsutils/ngsutils/ngsutils/fastq/barcode_split.py/_tag_aln_check/original