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
Thanks for the heads-up on this package. It looks great! I'm giving it a test spin now.
When passing a non-sorted BAM:
>>> pycoverm.get_coverages_from_bam(["out.bam"], threads=4)
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ShapeError/IncompatibleShape: incompatible shapes', src/lib.rs:181:6
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: ShapeError/IncompatibleShape: incompatible shapes
A better error-message would be preferrable (I would perhaps do a search-and-replace for unwrap() and replace it with expect("<NEW ERROR MESSAGE>"))
The text was updated successfully, but these errors were encountered:
Yes, I still need to implement a function to check if BAMs are sorted. I'll make it raise an exception.
The reason I haven't implemented this yet is because I'm doing this check in Python (see below), but I agree with you that pyCoverM should be able to do it within itself to avoid unnecessary dependencies.
fromBioimportbgzfdefis_bam_sorted(filepath):
""" Checks if a BAM file is sorted by coordinate. Parameters ---------- filepath : Path Path object pointing to BAM file. Returns ------- bool Returns `True` if the BAM file is sorted by coordinate and `False` otherwise. """withbgzf.BgzfReader(filepath, "rb") asfin:
bam_header=fin.readline().strip()
returnb"SO:coordinate"inbam_header
I just pushed some commits that add the is_bam_sorted, which can be used to check if the BAMs are sorted before inputting them to get_coverages_from_bam.
To check multiple files:
ifnotall(pycoverm.is_bam_sorted(bam_path) forbam_pathinbam_file_list):
raiseException(
"At least one of the supplied BAM files is not sorted by coordinate ""or does not contain a valid header. You can sort it using `samtools sort`."
)
I'll leave the issue open because this function doesn't fix it properly. When I get some time I'll make get_coverages_from_bam raise an exception if at least one of the input BAM files is unsorted.
Dear @apcamargo
Thanks for the heads-up on this package. It looks great! I'm giving it a test spin now.
When passing a non-sorted BAM:
A better error-message would be preferrable (I would perhaps do a search-and-replace for
unwrap()
and replace it withexpect("<NEW ERROR MESSAGE>")
)The text was updated successfully, but these errors were encountered: