Is there equivalent of bgzip in Python?
2
0
Entering edit mode
2.1 years ago
magnolia ▴ 20

Hello,

I want to use bgzip in Python and index it with tabix. I figured out tabix part with pysam.tabix_index but I don't know how to create gz file. I've tried gzip module from Python itself but pysam.tabix_index was unhappy about it.

Does anyone know how to do it?

python bgzip • 2.9k views
ADD COMMENT
4
Entering edit mode
2.1 years ago

If you're already using pysam anyway, the function you are looking for is pysam.tabix_compress.

ADD COMMENT
0
Entering edit mode

Thanks a lot for bringing that to my attention! I actually tried it before and didn't work but it totally works now. I guess it didn't work before because of other parts of my code. Thanks again!

ADD REPLY
1
Entering edit mode
2.1 years ago

Read and write BGZF compressed files (the GZIP variant used in BAM).

https://biopython.org/docs/1.78/api/Bio.bgzf.html

ADD COMMENT
0
Entering edit mode

Oh I was really hoping that I wouldn't need another package just for compression but oh well. Thanks a lot!

ADD REPLY

Login before adding your answer.

Traffic: 1577 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6