Python module to manipulate the minimap2's CS tag
Project description
cstag
cstag
is a Python module to manipulate minimap2's CS tag.
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
See documentation for more information.
Installation
From PyPI:
pip install cstag
From Bioconda:
conda install -c bioconda cstag
Examples
Generate the cs tag
import cstag
cigar = "8M2D4M2I3N1M"
md = "2A5^AG7"
seq = "ACGTACGTACGTACG"
cstag.call(cigar, md, seq, is_short_form=True)
# => cs:Z::2*ag:5-ag:4+ac~nn3nn:1
cstag.call(cigar, md, seq, is_short_form=False)
# => cs:Z:=AC*ag=TACGT-ag=ACGT+ac~nn3nn=G
Shorten/Lengthen
import cstag
# Convert a cs tag from long to short
cs = "cs:Z:=ACGT*ag=CGT"
cstag.shorten(cs)
# => cs:Z::4*ag:3
# Convert a cs tag from short to long
cs = "cs:Z::4*ag:3"
cigar = "8M"
seq = "ACGTACGT"
cstag.lengthen(cs, cigar, seq)
# => cs:Z:=ACGT*ag=CGT
Call consensus
import cstag
cs_list = ["cs:Z:=ACGT", "cs:Z:=AC*gt=T", "cs:Z:=C*gt=T", "cs:Z:=C*gt=T", "cs:Z:=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)
# => cs:Z:=AC*gt*T
Mask low-quality bases in a cs tag
import cstag
cs = "cs:Z:=ACGT*ac+gg-cc=T"
cigar = "5M2I2D1M"
qual = "AA!!!!AA"
phred_threshold = 10
cstag.mask(cs, cigar, qual, phred_threshold)
# => cs:Z:=ACNN*an+ng-cc=T
Split a cs tag
import cstag
cs = "cs:Z:=ACGT*ac+gg-cc=T"
cstag.split(cs)
# => ['cs:Z:', '=ACGT', '*ac', '+gg', '-cc', '=T']
Converts a cs tag into its reverse complement
import cstag
cs = "cs:Z:=ACGT*ac+gg-cc=T"
cstag.revcomp(cs)
# => cs:Z:=A-gg+cc*tg=ACGT
Output HTML report
import cstag
from pathlib import Path
cs = "cs:Z:=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 report.html
is :point_down:
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.4.3.tar.gz
(15.6 kB
view hashes)
Built Distribution
cstag-0.4.3-py3-none-any.whl
(12.4 kB
view hashes)