Case Operations (``upper``, ``lower``, ``swapcase``) ==================================================== Three deterministic operations change the case of sequence characters without altering the underlying bases. XML region tags are preserved intact; only molecular characters are transformed. All three accept an optional ``region=`` parameter to restrict the transformation to a named segment. .. code-block:: python import poolparty as pp pp.init() ---- Examples -------- upper: uppercase a full sequence ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Convert every base of a lowercase sequence to uppercase. .. code-block:: python wt = pp.from_seq("atcgatcg") up = pp.upper(wt) up.print_library() .. raw:: html
up: seq_length=8, num_states=1 ATCGATCG
upper: uppercase a named region only ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Only the content of the ``cre`` region is uppercased; the flanking lowercase bases remain unchanged. .. code-block:: python wt = pp.from_seq("aaaaatcgatcgtttt") up = pp.upper(wt, region="cre") up.print_library() .. raw:: html
up: seq_length=8, num_states=1 aaaa<cre>ATCGATCG</cre>tttt
lower: lowercase a full sequence ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Convert every base of an uppercase sequence to lowercase. .. code-block:: python wt = pp.from_seq("ATCGATCG") lo = pp.lower(wt) lo.print_library() .. raw:: html
lo: seq_length=8, num_states=1 atcgatcg
lower: lowercase a named region only ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Only the content of the ``cre`` region is lowercased; the uppercase flanks are returned unchanged. .. code-block:: python wt = pp.from_seq("AAAAATCGATCGTTTT") lo = pp.lower(wt, region="cre") lo.print_library() .. raw:: html
lo: seq_length=8, num_states=1 AAAA<cre>atcgatcg</cre>TTTT
swapcase: swap a mixed-case sequence ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Invert the case of every base: uppercase becomes lowercase and vice versa. .. code-block:: python wt = pp.from_seq("ATCGatcg") sw = pp.swapcase(wt) sw.print_library() .. raw:: html
sw: seq_length=8, num_states=1 atcgATCG
swapcase: visually distinguish a region ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Apply ``lower`` to the full sequence, then ``swapcase`` restricted to the ``cre`` region to make that segment stand out in uppercase. .. code-block:: python wt = pp.from_seq("AAAAATCGATCGTTTT") lo = pp.lower(wt) hi = pp.swapcase(lo, region="cre") hi.print_library() .. raw:: html
hi: seq_length=8, num_states=1 aaaa<cre>ATCGATCG</cre>tttt
See :func:`~poolparty.swapcase`.