pyfastx icon indicating copy to clipboard operation
pyfastx copied to clipboard

[Feature Request] Read from stdin option

Open jolespin opened this issue 3 years ago • 3 comments

It would be awesome if pyfastx could read from stdin for streaming purposes between programs.

import sys, pyfastx

def main():
    for id, seq in pyfastx.Fasta(sys.stdin, build_index=False):
        print(id)
if __name__ == "__main__":
    main()

Here's the error:

Traceback (most recent call last):
  File "/Users/jespinoz/test.py", line 7, in <module>
    main()
  File "/Users/jespinoz/test.py", line 4, in main
    for id, seq in pyfastx.Fasta(sys.stdin, build_index=False):
TypeError: a bytes-like object is required, not '_io.TextIOWrapper

jolespin avatar Sep 02 '22 05:09 jolespin

Thank you for your idea. But it will be complicated to implement this function due to the requirement of index building.

lmdu avatar Nov 24 '22 13:11 lmdu

This feature would be incredibly useful. You mention that building an index is required – but what about the case where build_index=False?

bede avatar May 22 '23 18:05 bede

I am so sorry. I could not find a good solution to resolve it. Because we use C language to implement the Fasta and Fastq parser class.

lmdu avatar May 26 '23 08:05 lmdu