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.
import poolparty as pp
pp.init()
Examples
upper: uppercase a full sequence
Convert every base of a lowercase sequence to uppercase.
wt = pp.from_seq("atcgatcg")
up = pp.upper(wt)
up.print_library()
upper: uppercase a named region only
Only the content of the cre region is uppercased; the flanking lowercase
bases remain unchanged.
wt = pp.from_seq("aaaa<cre>atcgatcg</cre>tttt")
up = pp.upper(wt, region="cre")
up.print_library()
lower: lowercase a full sequence
Convert every base of an uppercase sequence to lowercase.
wt = pp.from_seq("ATCGATCG")
lo = pp.lower(wt)
lo.print_library()
lower: lowercase a named region only
Only the content of the cre region is lowercased; the uppercase flanks
are returned unchanged.
wt = pp.from_seq("AAAA<cre>ATCGATCG</cre>TTTT")
lo = pp.lower(wt, region="cre")
lo.print_library()
swapcase: swap a mixed-case sequence
Invert the case of every base: uppercase becomes lowercase and vice versa.
wt = pp.from_seq("ATCGatcg")
sw = pp.swapcase(wt)
sw.print_library()
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.
wt = pp.from_seq("AAAA<cre>ATCGATCG</cre>TTTT")
lo = pp.lower(wt)
hi = pp.swapcase(lo, region="cre")
hi.print_library()
See upper(), lower(), and
swapcase().