pysam-developers / pysam

Pysam is a Python package for reading, manipulating, and writing genomics data such as SAM/BAM/CRAM and VCF/BCF files. It's a lightweight wrapper of the HTSlib API, the same one that powers samtools, bcftools, and tabix.
https://pysam.readthedocs.io/en/latest/
MIT License
779 stars 274 forks source link

Is there a way to sort VCF/BCF, like pysam.sort? #1223

Closed antonylebechec closed 1 year ago

antonylebechec commented 1 year ago

Hi!

I would like to sort a VCF/BCF file, especially before tabix. However, pysam.sort is exclusively for SAM/BAM.

Is there a way to sort a VCF file with pysam?

Thanks a lot!

Best,

jmarshall commented 1 year ago

pysam.sort() is really a shorthand for pysam.samtools.sort().

There is also pysam.bcftools.sort(), which is what you're looking for. You'll need to add import pysam.bcftools too.

antonylebechec commented 1 year ago

Thanks a lot! I'm new in pysam... Great tool!!!