Skip to main content

manipulate SAM cigar strings

Project description


cigar is a simple library for dealing with cigar strings. the most useful
feature now is soft-masking from left or right. This allows one to adjust
a SAM record only by changing the cigar string to soft-mask a number of bases
such that the rest of the SAM record (pos, tlen, etc.) remain valid, but
downstream tools will not consider the soft-masked bases in further analysis.


>>> c = Cigar('100M')
>>> len(c)
>>> str(c)
>>> list(c.items())
[(100, 'M')]

>>> c = Cigar('20H20M20S')
>>> len(c)
>>> str(c)
>>> list(c.items())
[(20, 'H'), (20, 'M'), (20, 'S')]

>>> c.mask_left(29).cigar, c.cigar
('20H9S11M20S', '20H20M20S')

>>> c = Cigar('10M20S10M')
>>> c.mask_left(10).cigar
>>> c.mask_left(9).cigar
>>> Cigar('10S').mask_left(10).cigar
>>> Cigar('10H').mask_left(10).cigar
>>> Cigar('10H').mask_left(11).cigar
>>> Cigar('10H').mask_left(9).cigar

>>> Cigar('1M10H').mask_left(9).cigar

>>> Cigar('5M10H').mask_left(9).cigar

>>> c = Cigar('1S1H1S5H1S5M10H')
>>> c.mask_left(9).cigar == c.cigar

>>> c = Cigar('1S1H1S5H1S5M10H')
>>> c.mask_right(9).cigar == c.cigar
>>> c.mask_right(11).cigar


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cigar-0.1.tar.gz (2.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page