Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • nilshomer
    replied
    Originally posted by g_solid View Post
    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 can't debug your code for you, but...

    I have had success calling the C API from SAMtools in my own code. See my DNAA package source code available via GIT.

    Leave a comment:


  • g_solid
    started a topic Read BAM header with SAMtools code

    Read BAM header with SAMtools code

    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

Latest Articles

Collapse

  • SEQadmin2
    The Factors Reshaping Genome Assembly
    by SEQadmin2



    When the Human Genome Project declared the human genome finished in 2003, portions of the sequence were still missing, including many of its most repetitive and structurally complex regions.1 Still, for the next two decades, researchers analyzed their sequencing data against the single linear reference that came out of this effort. Released in 2013 as GRCh38, that reference has powered countless discoveries, but it has gaps and cannot capture the genetic diversity of the world’s...
    11-24-2026, 07:04 AM

ad_right_rmr

Collapse

News

Collapse

Topics Statistics Last Post
Started by SEQadmin2, Today, 11:10 AM
0 responses
11 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, Yesterday, 11:06 AM
0 responses
20 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, 11-23-2026, 11:11 AM
0 responses
58 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, 11-17-2026, 06:27 AM
0 responses
55 views
0 reactions
Last Post SEQadmin2  
Working...