blachlylab / dhtslib

D bindings and OOP wrappers for htslib
MIT License
7 stars 1 forks source link

Make Cigar iterable #44

Closed jblachly closed 4 years ago

jblachly commented 4 years ago

(wishlist only) Evidently there is a generator CigarItr which takes cigar struct and makes range, but couldn't we embed range primitives within Cigar itself? would be more ergonomic

charlesgregory commented 4 years ago

How should it be iterable? Should we return CigarOps (i.e 6M, 3I, 3D ...)? CigarItr returns a sequence of ops (i.e. 6M3I3D -> M, M, M, M, M, M, I, I, I, D, D, D).

jblachly commented 4 years ago

I should be able to do this:

foreach(c; read.cigar) {
    f( c.op );
    g( c.length);
}
jblachly commented 4 years ago

which is how it works in pysam (kind of, that returns a tuple) - we shoudl return a struct which I thought you were already doing? I saw the iter returns a struct with properties .ops and .length already

charlesgregory commented 4 years ago

No my CigarItr returns an Ops enum and repeats until the CigarOp is exhausted.