Stuck on BAMWriter

Looking for example code for wrapping with BGZFStream

Hi, did you see Specifically, RNA-Seq Coverage has an example code to read a BAM file using Bio.jl.

If you have seen an error or something, pasting reproducible code with data would be necessary to help you.

I am sorry about leaving out code, I was confused by the discourse format and wasn’t sure how my text would show up in a new topic as opposed to a new post (one and the same I see). Also, the BioTutorial is helpful, although it doesn’t seem to have an example of BAMWriter usage in there.

What I intended to post after my topic was put up:

"I’m a big fan of Julia and Bio.jl but as a biologist sometimes I need a little example code to get me started. I have successfully been able to read and write files, including reading BAM files, but writing BAM files has stumped me. How does one “wrap with a BGZFStream object provided from BGZFStreams.jl”, and when opening the file with the BAMWriter, where does the SAM header come into play?

Thank you for your help! My current sorry state of pseudo-code below (rough outline to illustrate):"

stream = BGZFStream("aNewBamFile.bam")
writer = open(BGZFStream(BAMWriter), SAMHeader)
while true
	write(writer, BAMRecord(recordtowrite))

Thank you for using our package :smiley:.

Unfortunately, the current BAM support is still limited to reading data from files. There is no interface for users to create or modify BAM files without knowing the details of the BAM specs and its implementation in Bio.jl. But this is one of the highest priority tasks on my list and I’m going to implement it soon after the current job finished. No promise, but I’d like to work on creating a simple and consistent interface for writing formatted data within a few months. I’m sorry for your inconvenience until that.

Oh don’t worry, I’m already very thrilled at the pace of Bio.jl and if I need something before then I should get my ass in gear and help out! :smile: Unfortunately, I still have some learning to do before I can submit useful pull requests, so thank you for working on the package and I’m looking forward to contributing in the future! Cheers! -Andrew