brentp / hts-nim

nim wrapper for htslib for parsing genomics data files

Home Page:https://brentp.github.io/hts-nim/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consider adding additional getters in BAM

nh13 opened this issue · comments

In addition to reverse, how about forward?
In addition to qcfail, how about pf?

I really like what you have started in hts-nim, and I have found having the logically opposite getter (reverse vs. forward, paired vs fragment, mate_unmapped vs mate_mapped) to really powerful. See the scala BAM API in fgbio for some ideas to make it much nicer than htsjdk or the htslib C-API.

I agree on the utility of this, but this is a case where I think matching the underlying API makes sense because it has become the way that most users are accustomed to deal with these things. Another reason I don't want to include is that because of UFCS, a user can create their own accessors, like:

import hts 

proc forward*(f: Flag): bool {.inline.} =
  return not f.reverse

var b:Bam
b.open("K02209.disc.bam")

for r in b:
  if r.flag.forward:                                                            
    echo $r

which is working code. This is a trade-off between surface-area of the API I create/expose in hts-nim and the ergonomics of the library. I think that keeping the API small and letting the user define their own convenience functions is the mode to follow here.

As a NIM novice, this was really helpful.