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

conditional iterator

danielecook opened this issue · comments

Is there a way to iterate over a VCF by region OR in its entirety?

I'm trying to make supplying a region optional. So something like this:

    doAssert open(v, vcf)
    var records = if region.len > 0:
        v.query(region)
    else:
        v

    for rec in records:
        echo rec

However, I keep running into type errors. How can I return a 'blank' query that returns all records?

Thanks!

I could make query default to iterating over the entire VCF when given the empty string...

That would be a good idea but I like the implementation that makes use of the bed region file too. I am picking up nim b/c of this library and thus far it's been great! Thanks for putting it together.

glad to hear it. I'm happy to answer any other questions.