def extract_10x(alignment):
    """Given a 10x BAM entry as a pysam.AlignedSegment, extract the barcode,
    UMI, and sequence.

    :param alignment: a single BAM entry
    :type alignment: pysam.AlignedSegment

    :return: a 3-tuple containing (barcodes, umis, sequence)
    :rtype: tuple
    """
    barcode = alignment.get_tag('CR')
    umi = alignment.get_tag('UR')
    # The quality scores for the sequence is returned as an array.array of
    # unsigned chars.
    sequence = alignment.query_sequence

    return ([barcode], [umi], sequence)