betteridiot / bamnostic

a pure Python multi-version tolerant, runtime and OS-agnostic Binary Alignment Map (BAM) file parser and random access tool
https://bamnostic.readthedocs.io/en/latest/?badge=latest
BSD 3-Clause "New" or "Revised" License
97 stars 19 forks source link

AlignmentFile Iterator doesnt seem to read region data correctly from BAM file #55

Open JustinMoser opened 1 month ago

JustinMoser commented 1 month ago

Describe the bug I am attempting to repackage the SMAca package using bamnostic in place of PySam, specifically using your AlignmentFile class in place of the PySam version. The problem I am facing is when I run

smaca --reference hg19 <BAM_FILE>

I get the following error:

Open-ended region whileuntil_eofis set to False

I have debugged the code and this is because in SMAca it iterates over the generator from the fetch method in AlignmentFile for reading the various regions from the file however when it gets into the fetch method, and then into the _parse_region method, all the arguments seem to be None and so for every region there is no start stop index and so it deems in an "Open-Ended" region, with until_eof also defaulting to false. I have run the same BAM file through SMAca with PySam and it seems to run correctly and produce an output. The purpose of this task is to allow the SMAca package to run outside of a linux environment.

This is being run on Mac OSX Sonoma with Python 3.10.14

Any idea why it replacing PySam with Bamnostic simply to read the AlignmentFile might cause the regions to not be read correctly?

betteridiot commented 2 weeks ago

I am sorry for seeing this so late. Something has bugged my GitHub subscriptions and I just now got this in an email that is not my primary.

Nevertheless, I hope that this wasn't super time-sensitive. I will attempt to dig into this on the weekend.

betteridiot commented 2 weeks ago

Can I see an example of your issues in action? Specifically the error in the context of the code?