Hello,
I'm trying to call the function "bam_header_read" of SAMtools code from within my C++ program to read fields in BAM file headers. I'm currently interested, for example, in getting reference sequence names from the header.
But "bam_header_read" always complains "wrong header" for the bam input files I provide. The funny thing is that I'm creating these bam files from sam files using SAMtools's own "view" module with the parameters indicated in the SAMtools manual page. The "view" module doesn't complain about the sam input, but the bam output produced by "view" is somehow not accepted by "bam_header_read".
Anyone have some idea about why this happens? Or know of alternative ways to read bam header info using SAMtools code?
I guess an alternative would be to do an external system command call of SAMtools "view", and read the output back into my program, but I wanted to avoid that.
Best, g_solid
I'm trying to call the function "bam_header_read" of SAMtools code from within my C++ program to read fields in BAM file headers. I'm currently interested, for example, in getting reference sequence names from the header.
But "bam_header_read" always complains "wrong header" for the bam input files I provide. The funny thing is that I'm creating these bam files from sam files using SAMtools's own "view" module with the parameters indicated in the SAMtools manual page. The "view" module doesn't complain about the sam input, but the bam output produced by "view" is somehow not accepted by "bam_header_read".
Anyone have some idea about why this happens? Or know of alternative ways to read bam header info using SAMtools code?
I guess an alternative would be to do an external system command call of SAMtools "view", and read the output back into my program, but I wanted to avoid that.
Best, g_solid
Comment