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.

Files for cigar, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size cigar-0.1.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page