Skip to main content

Python module to manipulate the minimap2's CS tag

Project description

Licence Test Python PyPI Bioconda DOI

cstag

cstag is a Python library designed for handling and manipulating minimap2's CS tags.

🌟Features

  • cstag.call(): Generate a CS tag
  • cstag.shorten(): Convert a CS tag from long to short format
  • cstag.lengthen(): Convert a CS tag from short to long format
  • cstag.consensus(): Generate a consensus cs tag from multiple cs tags
  • cstag.mask(): Mask low-quality bases in a CS tag
  • cstag.split(): Split a CS tag
  • cstag.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, 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_tag = "=AC+GGG=T-ACGT*at~gt10cg=GNNN"
description = "Example"

cs_tag_html = cstag.to_html(cs_tag, description)
Path("report.html").write_text(cs_tag_html)
# => Output "report.html"

The resulting report.html looks like this :point_down:

example_report

📣Feedback

For questions, bug reports, or any other inquiries, feel free to reach out!
Please use GitHub Issues for reporting.

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

cstag-0.5.1.tar.gz (17.1 kB view hashes)

Uploaded Source

Built Distribution

cstag-0.5.1-py3-none-any.whl (14.0 kB view hashes)

Uploaded Python 3

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