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
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
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
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
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
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
aaaa<cre>ATCGATCG</cre>tttt
See :func:`~poolparty.upper`, :func:`~poolparty.lower`, and
:func:`~poolparty.swapcase`.