def get_uc_lc_sequence_segment(seq, cp,
                               vp_ext=20,
                               con_ext=0):
    """
    Given a sequence, a center position inside the sequence, a viewpoint
    extension value, and a context extension value: get the lowercase-
    uppercase-lowercase sequence segment.

    cp:
    1-based position that marks the center of the sequence.

    >>> seq = "ACGTacgtXYZ"
    >>> cp = 7
    >>> vp_ext = 3
    >>> con_ext = 2
    >>> get_uc_lc_sequence_segment(seq, cp, vp_ext=vp_ext, con_ext=con_ext)
    'cgTACGTXYz'
    >>> cp = 7
    >>> vp_ext = 20
    >>> con_ext = 20
    >>> get_uc_lc_sequence_segment(seq, cp, vp_ext=vp_ext, con_ext=con_ext)
    'ACGTACGTXYZ'
    >>> cp = 5
    >>> vp_ext = 0
    >>> con_ext = 0
    >>> get_uc_lc_sequence_segment(seq, cp, vp_ext=vp_ext, con_ext=con_ext)
    'A'
    >>> cp = 5
    >>> vp_ext = 0
    >>> con_ext = 2
    >>> get_uc_lc_sequence_segment(seq, cp, vp_ext=vp_ext, con_ext=con_ext)
    'gtAcg'
    >>> cp = 5
    >>> vp_ext = 2
    >>> con_ext = 0
    >>> get_uc_lc_sequence_segment(seq, cp, vp_ext=vp_ext, con_ext=con_ext)
    'GTACG'

    """
    # Checks.
    lseq = len(seq)
    assert lseq, "lseq evaluated to False"
    assert cp <= lseq, "given cp > lseq"
    assert cp > 0, "given cp < 1"

    # Upstream extensions.
    usucs = cp - vp_ext - 1
    usuce = cp - 1
    uslcs = cp - vp_ext - con_ext - 1
    uslce = usucs
    # Downstream extensions.
    dsucs = cp
    dsuce = cp + vp_ext
    dslcs = dsuce
    dslce = cp + vp_ext + con_ext

    # Extract segments.
    usucseg = seq[usucs:usuce].upper()
    uslcseg = seq[uslcs:uslce].lower()
    dsucseg = seq[dsucs:dsuce].upper()
    dslcseg = seq[dslcs:dslce].lower()
    cpseg = seq[cp-1:cp].upper()

    # Give it to me.
    final_seg = uslcseg + usucseg + cpseg + dsucseg + dslcseg
    return final_seg