Python module to manipulate the minimap2's CS tag
Project description
cstag
`cstag`` is a Python library designed for handling and manipulating minimap2's CS tags.
🌟Features
cstag.call()
: Generate a CS tagcstag.shorten()
: Convert a CS tag from long to short formatcstag.lengthen()
: Convert a CS tag from short to long formatcstag.consensus()
: Generate a consensus cs tag from multiple cs tagscstag.mask()
: Mask low-quality bases in a CS tagcstag.split()
: Split a CS tagcstag.revcomp()
: Converts a CS tag into its reverse complement.cstag.to_html()
: Output html report
Visit the documentation for more details.
🛠 Installation
Using PyPI:
pip install cstag
Using Bioconda:
conda install -c bioconda cstag
💡Usage
Generate CS Tags
import cstag
cigar = "8M2D4M2I3N1M"
md = "2A5^AG7"
seq = "ACGTACGTACGTACG"
cstag.call(cigar, md, seq)
# => :2*ag:5-ag:4+ac~nn3nn:1
cstag.call(cigar, md, seq, is_long=True)
# => =AC*ag=TACGT-ag=ACGT+ac~nn3nn=G
Shorten or Lengthen CS Tags
import cstag
# Convert a CS tag from long to short
cs = "=ACGT*ag=CGT"
cstag.shorten(cs)
# => :4*ag:3
# Convert a CS tag from short to long
cs = ":4*ag:3"
cigar = "8M"
seq = "ACGTACGT"
cstag.lengthen(cs, cigar, seq)
# => =ACGT*ag=CGT
Generate a Consensus
import cstag
cs_list = ["=ACGT", "=AC*gt=T", "=C*gt=T", "=C*gt=T", "=ACT+ccc=T"]
cigar_list = ["4M", "4M", "1S3M", "3M", "3M3I1M"]
pos_list = [1, 1, 1, 2, 1]
cstag.consensus(cs_list, cigar_list, pos_list)
# => =AC*gt*T
Mask Low-Quality Bases
import cstag
cs = "=ACGT*ac+gg-cc=T"
cigar = "5M2I2D1M"
qual = "AA!!!!AA"
phred_threshold = 10
cstag.mask(cs, cigar, qual, phred_threshold)
# => =ACNN*an+ng-cc=T
Split a CS Tag
import cstag
cs = "=ACGT*ac+gg-cc=T"
cstag.split(cs)
# => ['', '=ACGT', '*ac', '+gg', '-cc', '=T']
Reverse Complement of a CS Tag
import cstag
cs = "=ACGT*ac+gg-cc=T"
cstag.revcomp(cs)
# => =A-gg+cc*tg=ACGT
Generate HTML Report
import cstag
from pathlib import Path
cs = "=AC+GGG=T-ACGT*at~gt10cg=GNNN"
description = "Example"
cstag_html = cstag.to_html(cs, description)
Path("report.html").write_text(cstag_html)
# => Output "report.html"
The resulting report.html
looks like this :point_down:
📣Feedback
For questions, bug reports, or any other inquiries, feel free to reach out!
Please use GitHub Issues for reporting.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cstag-0.5.0.tar.gz
(15.3 kB
view hashes)
Built Distribution
cstag-0.5.0-py3-none-any.whl
(12.3 kB
view hashes)