<div dir="auto">Nice idea, I would never have thought of that.<div dir="auto"><br></div><div dir="auto">Thanks Peter!</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 13, 2024, 11:18 AM Peter Cock <<a href="mailto:p.j.a.cock@googlemail.com">p.j.a.cock@googlemail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ah. I would give it a file handle then:<br>
<br>
with bgzf.open("example.txt.bgz", "w") as bgzf_handle:<br>
my_data_frame.to_csv(bgzf_handle, ...)<br>
<br>
I would expect that to work according to<br>
<a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html" rel="noreferrer noreferrer" target="_blank">https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html</a><br>
- possibly with an explicit compression=None added?<br>
<br>
Peter<br>
<br>
<br>
On Wed, Mar 13, 2024 at 11:08 AM Dan Bolser <<a href="mailto:dan.bolser@outsee.co.uk" target="_blank" rel="noreferrer">dan.bolser@outsee.co.uk</a>> wrote:<br>
><br>
> pandas.to_csv is the function that writes data. pandas.read_csv silently handles decompression as needed.<br>
><br>
><br>
><br>
> On Wed, Mar 13, 2024, 10:49 AM Peter Cock <<a href="mailto:p.j.a.cock@googlemail.com" target="_blank" rel="noreferrer">p.j.a.cock@googlemail.com</a>> wrote:<br>
>><br>
>> Yes. BGZF is just a special kind of GZIP file, if all you are doing is<br>
>> decompressing it for reading it then the standard gzip.open(...)<br>
>> is fine.<br>
>><br>
>> Peter<br>
>><br>
>><br>
>> On Wed, Mar 13, 2024 at 10:03 AM Dan Bolser <<a href="mailto:dan.bolser@outsee.co.uk" target="_blank" rel="noreferrer">dan.bolser@outsee.co.uk</a>> wrote:<br>
>>><br>
>>> bgzip is a 'bio' thing, so thought I'd ask here. It's perhaps not 'biopython', but it's bio/python.<br>
>>><br>
>>> On Tue, 12 Mar 2024 at 19:11, Sean Brimer <<a href="mailto:skbrimer@gmail.com" target="_blank" rel="noreferrer">skbrimer@gmail.com</a>> wrote:<br>
>>>><br>
>>>> Hi Dan,<br>
>>>><br>
>>>> This feels more like a panda's issue than a biopython issue. That said, I think you could just use gzip. I think. bgzip for samtools was built on top of gzip so it probably decompresses in a similar way.<br>
>>>><br>
>>>> On Tue, Mar 12, 2024 at 12:52 PM Dan Bolser <<a href="mailto:dan.bolser@outsee.co.uk" target="_blank" rel="noreferrer">dan.bolser@outsee.co.uk</a>> wrote:<br>
>>>>><br>
>>>>> Hi,<br>
>>>>><br>
>>>>> I can pass `compression="gzip"` to pandas.DataFrame.to_csv, but not bgzip... how to update pandas to support bgzip?<br>
>>>>><br>
>>>>><br>
>>>>> Thanks,<br>
>>>>> _______________________________________________<br>
>>>>> Biopython mailing list - <a href="mailto:Biopython@biopython.org" target="_blank" rel="noreferrer">Biopython@biopython.org</a><br>
>>>>> <a href="https://mailman.open-bio.org/mailman/listinfo/biopython" rel="noreferrer noreferrer" target="_blank">https://mailman.open-bio.org/mailman/listinfo/biopython</a><br>
>>><br>
>>> _______________________________________________<br>
>>> Biopython mailing list - <a href="mailto:Biopython@biopython.org" target="_blank" rel="noreferrer">Biopython@biopython.org</a><br>
>>> <a href="https://mailman.open-bio.org/mailman/listinfo/biopython" rel="noreferrer noreferrer" target="_blank">https://mailman.open-bio.org/mailman/listinfo/biopython</a><br>
</blockquote></div>