pyfastx icon indicating copy to clipboard operation
pyfastx copied to clipboard

close for Fasta object

Open diekhans opened this issue 10 months ago • 2 comments

There isn't a way to close a pyfastx.Fasta object, while would be consistent with python open, Have Fasta object as a context manager as well would be great.

P.S. wow, this is an awesomely usefully package

diekhans avatar Feb 04 '25 05:02 diekhans

You don't have to manually close pyfastx.Fasta. It will be closed automatically.

lmdu avatar Mar 18 '25 00:03 lmdu

Lianming Du @.***> writes:

You don't have to manually close pyfastx.Fasta. It will be closed automatically.

Automatically when it is garbage collected?? Yes, this happens with python files as well.

However, files have a close() under the 'explicit is better than implicit' and the fact that Python doesn't guarantee that there is reference counting or when an object will he garbage collected. Plus it is consistent with many clases that open resources, making Fasta object not a special case.

Have the Fasta object as a context manager would be a nice addition.

BTW, this is an AMAZING package. It is so annoying to split fastx files for cluster jobs. Not having convert gziped files or splice them is such a win. thank you!

diekhans avatar Mar 18 '25 05:03 diekhans