seqan / seqan3

The modern C++ library for sequence analysis. Contains version 3 of the library and API docs.
https://www.seqan.de
Other
396 stars 81 forks source link

appending records to a .bam #3250

Open notestaff opened 4 months ago

notestaff commented 4 months ago

Is it possible with seqan3 to open a .bam file for writing in append mode, so that any records pushed to it get appended to the end, but the file header of the existing file is not touched (and a new file header is not mistakenly appended)? Thanks! @eseiler

smehringer commented 4 months ago

Hi @notestaff,

interesting use case. No, currently this is not possible because a header is always written. There might be even more issues but this one I am sure of.

The problem with allow appending to a BAM file is that you have to extremely careful that the header information in the file-to-be-appended-to is the same as the one in memory of the program writing new records. Do you know if other tools allow this?

An obvious workaround (that you are probably already using) is to write individual files and then, as a postprocessing step, concatenate them all.