epi2me-labs / modbam2bed

Other
47 stars 8 forks source link

unaligned bam #24

Closed rrazaghi closed 2 years ago

rrazaghi commented 2 years ago

Hi @cjw85 ,

was wondering if there's a way to parse reads in an unaligned modbam using modbampy. Thanks!

cjw85 commented 2 years ago

In what sense? I guess to return simply and list of (position, score) tuples for the modified base probabilities?

rrazaghi commented 2 years ago

yes exactly! I've received a few feature requests for these within modbamtools and trying to make a module around them

cjw85 commented 2 years ago

I think we're basically in the realm here of reimplementing pysam, which I'd rather not do.

The information you want is available through pysam: https://pysam.readthedocs.io/en/latest/api.html?highlight=modified%20bases#pysam.AlignedSegment.modified_bases

They don't appear to have anything tying into the pileup API; so there's no one API that "does everything". You may wish to ask @AndreasHeger about this as I know he was playing with the code in modbampy.

rrazaghi commented 2 years ago

I wasn't aware this was implemented (partially) in pysam but this is exactly what I want. I saw Marcus has opened an issue there as it currently does not support ? in MM tag. Thanks!

cjw85 commented 2 years ago

It doesn't support ? because I believe it uses a slightly older version of htslib than the current development branch. IIRC even the current development branch of htslib doesn't do anything clever with the ? flag, it just doesn't barf like the earlier implementation.