Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pysam.fastq: OSError: [Errno 9] Bad file descriptor #1195

Open
schorlton opened this issue Jun 6, 2023 · 0 comments
Open

pysam.fastq: OSError: [Errno 9] Bad file descriptor #1195

schorlton opened this issue Jun 6, 2023 · 0 comments

Comments

@schorlton
Copy link

Getting OSError: [Errno 9] Bad file descriptor when trying to use pysam as a samtools wrapper. Full reproduction:

docker run -it --rm \
    -u root \
    -v $(pwd):/work \
    -w /work \
    mambaorg/micromamba@sha256:1d05a8a7d88142f8225927756272748bc5feb438c0185de362e98ae5d88bf2f4 \
    bash

micromamba install pysam==0.21.0 -c bioconda -c conda-forge -c defaults
cat test.sam 
HWI-EAS240_0001:2:1:1144:15181#0	4	*	0	0	*	*	0	0	CTCAGGTGGCTTCCAACATTGGGATGAGTAACGTTAGNCATGTGTCAAGATCGGAAGANNGGTTCAGCAGGAATGC	bbbabbbbbbbbabbbabbabbbabbbbb`bbbb`VWBVUWWVZXZbYbXb_bbbOOGBBOOOOO\\VX`bbbbbb
>>> import pysam
>>> pysam.fastq("-0", "test.fastq", "test.sam")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 9] Bad file descriptor
>>> 
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
OSError: [Errno 9] Bad file descriptor

However, samtools works:

micromamba install -y samtools==1.17 -c conda-forge -c bioconda -c defaults

samtools fastq -0 samtools.fastq test.sam 
[M::bam2fq_mainloop] discarded 0 singletons
[M::bam2fq_mainloop] processed 1 reads
(base) root@f11037699062:/work# cat samtools.fastq 
@HWI-EAS240_0001:2:1:1144:15181#0
CTCAGGTGGCTTCCAACATTGGGATGAGTAACGTTAGNCATGTGTCAAGATCGGAAGANNGGTTCAGCAGGAATGC
+
bbbabbbbbbbbabbbabbabbbabbbbb`bbbb`VWBVUWWVZXZbYbXb_bbbOOGBBOOOOO\\VX`bbbbbb

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant