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
I'm encountering a persistent warning message when working with SAM/BAM files using pysam, and I'm seeking your advice on how to suppress or resolve it.
Issue Description
When processing my SAM/BAM files with pysam, I frequently receive the following warning message:
[W::sam_hrecs_update_hashes] PG line with multiple ID tags. The first encountered was preferred ...
I understand that this warning is generated when pysam (or the underlying htslib library) encounters multiple PG (Program) lines in the file header with the same ID tag, and that the software defaults to using the first ID it encounters.
I know the reason for this in this instance and want to ignore it.
Steps I’ve Tried to Suppress the Warning
I’ve attempted several common methods to suppress or redirect this warning, including:
Using Python's warnings.filterwarnings:
import warnings
warnings.filterwarnings("ignore", message=".*PG line with multiple ID tags.*", category=UserWarning, module="pysam")
This approach did not suppress the warning, possibly because it's not using Python’s standard warning system.
Redirecting sys.stderr:
import sys
import os
from contextlib import redirect_stderr
with open(os.devnull, 'w') as fnull:
with redirect_stderr(fnull):
# Code that triggers the warning
This also did not work, which leads me to believe the message is being printed by the underlying C library in a way that bypasses Python’s standard output streams.
My Questions
Is there a recommended method to suppress or redirect this specific warning message?
If this is a common issue, would it be possible to add an option in pysam to suppress such warnings?
Any advice or guidance you can provide would be greatly appreciated. Thank you for your time and for maintaining this incredibly useful library!
Description:
Hi,
I'm encountering a persistent warning message when working with SAM/BAM files using pysam, and I'm seeking your advice on how to suppress or resolve it.
Issue Description
When processing my SAM/BAM files with pysam, I frequently receive the following warning message:
I understand that this warning is generated when pysam (or the underlying htslib library) encounters multiple PG (Program) lines in the file header with the same ID tag, and that the software defaults to using the first ID it encounters.
I know the reason for this in this instance and want to ignore it.
Steps I’ve Tried to Suppress the Warning
I’ve attempted several common methods to suppress or redirect this warning, including:
This approach did not suppress the warning, possibly because it's not using Python’s standard warning system.
This also did not work, which leads me to believe the message is being printed by the underlying C library in a way that bypasses Python’s standard output streams.
My Questions
Any advice or guidance you can provide would be greatly appreciated. Thank you for your time and for maintaining this incredibly useful library!
Environment:
Best,
Oskar
The text was updated successfully, but these errors were encountered: