Package: cstag
cstagcstagis a Python library tailored for the manipulation and handling ofminimap2's CS tags.🌟 Featurescstag.call(): Generate a CS tagcstag.shorten(): Convert a CS tag from its long to short formatcstag.lengthen(): Convert a CS tag from its short to long formatcstag.consensus(): Create a consensus CS tag from multiple CS tagscstag.mask(): Mask low-quality bases within a CS tagcstag.split(): Break down a CS tag into its constituent partscstag.revcomp(): Convert a CS tag to its reverse complementcstag.to_sequence(): Reconstruct a reference subsequence from the alignmentcstag.to_vcf(): Generate a VCF representationcstag.to_html(): Generate an HTML representationcstag.to_pdf(): Produce a PDF fileFor comprehensive documentation, please visitour docs.To add CS tags to SAM/BAM files, check outcstag-cli.🛠 InstallationUsingPyPI:pipinstallcstagUsingBioconda:condainstall-cbiocondacstag💡 UsageGenerating CS Tagsimportcstagcigar="8M2D4M2I3N1M"md="2A5^AG7"seq="ACGTACGTACGTACG"print(cstag.call(cigar,md,seq))# :2*ag:5-ag:4+ac~nn3nn:1print(cstag.call(cigar,md,seq,long=True))# =AC*ag=TACGT-ag=ACGT+ac~nn3nn=GShortening or Lengthening CS Tagsimportcstag# Convert a CS tag from long to shortcs_tag="=ACGT*ag=CGT"print(cstag.shorten(cs_tag))# :4*ag:3# Convert a CS tag from short to longcs_tag=":4*ag:3"cigar="8M"seq="ACGTACGT"print(cstag.lengthen(cs_tag,cigar,seq))# =ACGT*ag=CGTCreating a Consensusimportcstagcs_tags=["=ACGT","=AC*gt=T","=C*gt=T","=C*gt=T","=ACT+ccc=T"]positions=[1,1,2,2,1]print(cstag.consensus(cs_tags,positions))# =AC*gt=TMasking Low-Quality Basesimportcstagcs_tag="=ACGT*ac+gg-cc=T"cigar="5M2I2D1M"qual="AA!!!!AA"phred_threshold=10print(cstag.mask(cs_tag,cigar,qual,phred_threshold))# =ACNN*an+ng-cc=TSplitting a CS Tagimportcstagcs_tag="=ACGT*ac+gg-cc=T"print(cstag.split(cs_tag))# ['=ACGT', '*ac', '+gg', '-cc', '=T']Reverse Complement of a CS Tagimportcstagcs_tag="=ACGT*ac+gg-cc=T"print(cstag.revcomp(cs_tag))# =A-gg+cc*tg=ACGTReconstructing the Reference Subsequenceimportcstagcs_tag="=AC*gt=T-gg=C+tt=A"print(cstag.to_sequence(cs_tag))# ACTTCTTAGenerating a VCF Reportimportcstagcs_tag="=AC*gt=T-gg=C+tt=A"chrom="chr1"pos=1print(cstag.to_vcf(cs_tag,chrom,pos))"""##fileformat=VCFv4.2#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFOchr1	3	.	G	T	.	.	.chr1	4	.	TGG	T	.	.	.chr1	5	.	C	CTT	.	.	."""The multiple CS tags enable reporting of the variant allele frequency (VAF).importcstagcs_tags=["=ACGT","=AC*gt=T","=C*gt=T","=ACGT","=AC*gt=T"]chroms=["chr1","chr1","chr1","chr2","chr2"]positions=[2,2,3,10,100]print(cstag.to_vcf(cs_tags,chroms,positions))"""##fileformat=VCFv4.2##INFO=<ID=DP,Number=1,Type=Integer,Description="Total Depth">##INFO=<ID=RD,Number=1,Type=Integer,Description="Depth of Ref allele">##INFO=<ID=AD,Number=1,Type=Integer,Description="Depth of Alt allele">##INFO=<ID=VAF,Number=1,Type=Float,Description="Variant allele frequency (AD/DP)">#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFOchr1	4	.	G	T	.	.	DP=3;RD=1;AD=2;VAF=0.667chr2	102	.	G	T	.	.	DP=1;RD=0;AD=1;VAF=1.0"""Generating an HTML ReportimportcstagfrompathlibimportPathcs_tag="=AC+ggg=T-acgt*at~gt10ag=GNNN"description="Example"cs_tag_html=cstag.to_html(cs_tag,description)Path("report.html").write_text(cs_tag_html)# Output "report.html"You can visualize mutations indicated by the CS tag using the generatedreport.htmlfile as shown below:Generating a PDF Reportimportcstagcs_tag="=AC+ggg=T-acgt*at~gt10ag=GNNN"description="Example"path_out="report.pdf"cstag.to_pdf(cs_tag,description,path_out)# Output "report.pdf"You can obtain the same images ofcstag.to_htmlas a PDF file.📣 Feedback and SupportFor questions, bug reports, or other forms of feedback, we'd love to hear from you!Please useGitHub Issuesfor all reporting purposes.🤝 Code of ConductPlease note that this project is released with aContributor Code of Conduct.By participating in this project you agree to abide by its terms.