You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today I'd like to report a potential bug in the pysam.view method. Basically, it appears that the method silently fails to write BAM file when --output is used.
For example, it correctly works if I simply print the output of the method:
(test) sbslee@Seung-beens-Mac-mini Desktop % cat test1.py
import pysam
input_bam = 'HG00276_PyPGx.sorted.markdup.recal.bam'
region = 'chr22:42513500-42513510'
print(pysam.view(input_bam, region))
(test) sbslee@Seung-beens-Mac-mini Desktop % python test1.py | head -n 1
[W::hts_idx_load3] The index file is older than the data file: HG00276_PyPGx.sorted.markdup.recal.bai
HNMY2CCXX:3:1108:1832082:0 163 chr22 42513351 60 150M = 42513555 354 TTTTTAATTCCACAGTGTTTGAAGGACATACTTGAAATAAATTTAAAATCCATTGAGATTTGTTTCGTGGTCCAGAATATGGCCTATCTTGGTGAATGTTTCATGTGTATGTGAAACTGAGGCATCCATCCCTCAGTTTCAACCACCCAT ?EEEEFIGHFFIEGFDGGIHHIKGGIEJIHFJHHILJHFDKIIIHKKKIGGDIJHCFDIIIHHIIG?HHGIGGDGIIDHIHGFGEGHGKIGGIHDKIHHII;KIHDGHB?:HHCD??J@DGFFJIGHJD<@1EFJ@DII@D4@=D@@;<D MC:Z:150M MD:Z:150 PG:Z:MarkDuplicates RG:Z:2117 NM:i:0 AS:i:150 XS:i:27
However, if I try to write the output to a new BAM file using --output, it does nothing without producing any errors:
(test) sbslee@Seung-beens-Mac-mini Desktop % cat test2.py
import pysam
input_bam = 'HG00276_PyPGx.sorted.markdup.recal.bam'
output_bam = 'HG00276_PyPGx_CYP2D6.bam'
region = 'chr22:42513500-42513510'
pysam.view(input_bam, region, '--output', output_bam)
(test) sbslee@Seung-beens-Mac-mini Desktop % python test2.py
[W::hts_idx_load3] The index file is older than the data file: HG00276_PyPGx.sorted.markdup.recal.bai
If you wrapped print(…) around the call in test2.py, you would see that the output is captured as the return value of pysam.view() — just as in test1.py.
If you are using -o or --output or etc options to redirect the output yourself within the pysam.view() etc call, you need to use pysam.view(…, catch_stdout=False) as per #677 (comment) and #958 (comment) et al.
…tation
Describe both samtools and bcftools invocations. Supersedes #1275.
Add reference documentation covering all the keyword arguments, etc.
Describe in detail how to redirect output to a file, a common use case.
Fixes#1096, fixes#1241, fixes#1323, et al.
Update doc/conf.py's rst_epilog samtools and bcftools URLs to point to
version-specific man pages, and have devtools/import.py update the URLs.
Dear pysam team,
Thanks always for your hard work!
Today I'd like to report a potential bug in the
pysam.view
method. Basically, it appears that the method silently fails to write BAM file when--output
is used.For example, it correctly works if I simply print the output of the method:
However, if I try to write the output to a new BAM file using
--output
, it does nothing without producing any errors:Link to test BAM file: https://1drv.ms/u/s!Apgoq3uQ2gCqgrsQmcNbCDYyw9rzsg?e=c86K1u
Link to test index file: https://1drv.ms/u/s!Apgoq3uQ2gCqgrsPD0TSk-2Kx1yDUg?e=TUYAUK
I'm using the latest version of pysam (0.19.0):
I installed pysam using conda:
Thanks for your time!
The text was updated successfully, but these errors were encountered: