I'm using the htslib
library for reading SAM/BAM files, it works perfectly. I can also write the alignments back to a new SAM/BAM file.
For example, the following code prints the DNA sequence of an alignment:
bam1_t *b = ...;
int i;
for (i = 0; i < b->core.l_qseq; ++i) {
printf("%c", seq_nt16_str[bam_seqi(bam_get_seq(b),i)]);
}
Question: How do I change the query sequence? Say, change the first letter to 'T'? bam_get_seq
returns the sequence of a read, but there is no bam_set_seq
function? Ideally, I'm looking for something like:
bam_set_seq(b, 'TTTT') # My new DNA sequence
If I can figure out how to do the update, I know how to write the information to a new SAM/BAM file.