brentp / hts-nim-tools

useful command-line tools written to showcase hts-nim
https://github.com/brentp/hts-nim
MIT License
49 stars 6 forks source link

Question: Convert a seq[CigarElement] to Cigar #9

Closed andreas-wilm closed 4 years ago

andreas-wilm commented 4 years ago

Hi Brent,

First of all, thanks for hts-nim!

I'm writing a realigner using hts-nim. For the realignment I have a seq[CigarElement] but am struggling to convert that to Cigar. newCigar() takes a ptr uint32, so I don't know how to go about this. It would be great to see examples of how to create Cigars from scratch. Ultimately I would like to replace a Cigar in a given read with this new Cigar. Any chance you would have some example code for that scenario as well?

Many thanks, Andreas

andreas-wilm commented 4 years ago

Just found your bamject. So I guess I have to convert the read to string first and do the modifications there 😮

brentp commented 4 years ago

Hi Andreas, I just pushed a change to hts-nim that allows you to create a Cigar from a seq[CigarElement]

Check the test and docstring as you are responsible for ensuruing that the seq[CigarElement] does not get garbage-collected while the cigar is still in use because it is using a pointer underneath.

andreas-wilm commented 4 years ago

Thanks a lot Brent!