def get_raw_sequence(alignment: bytes,
                len_read_name: int,
                number_cigar_operations: int,
                len_sequence: int, ) -> bytes:
    """Extract the raw sequence from a BAM alignment bytestring

    Parameters
    ----------
    alignment : bytes
        A byte string of a bam alignment entry in raw binary format

    len_read_name : int
        The length of the readname string
        eg from pylazybam.bam.get_len_read_name()

    number_cigar_operations : int
        The number of cigar operations
        eg from pylazybam.bam.get_number_cigar_operations()

    len_sequence : int
        The length of the sequence and quality score strings
        eg from pylazybam.bam.get_len_sequence

    Returns
    -------
    bytes
        The raw sequence in BAM format as a binary bytestring

    """
    start = 36 + len_read_name + (4 * number_cigar_operations)
    end = start + (len_sequence + 1) // 2
    return alignment[start:end]