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
773 stars 274 forks source link

AlignmentFile from String or StringIO support #1266

Open MauroIb opened 6 months ago

MauroIb commented 6 months ago

I need to create an AlignmentFile obj from a SAM file that I have stored in a string. This is part of a workflow where I run several steps using subprocess.run() and catch their stdout. I am looking for ways of working without making temporary files.

I see that AlignmentFile does not support StringIO, but allows for stdin. I think I can to patch into stdin using standard python tools, but a way to directly feed a string would be great.