Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rachmani
    Junior Member
    • Aug 2010
    • 2

    #1

    Parsing error in BAM header

    Hi~ I am pretty new to this area, having a hard time with these huge files..

    I wanted to use IndelGenotyperV2 (from GATK) with my newly built BAM files. When I executed the command I found an error like below..

    java.lang.RuntimeException: net.sf.samtools.SAMFormatException: Error parsing SAM header. Problem parsing @PG key:value pair.

    And the @PG line is like below:

    @PG ID:illumina_export2sam.pl VN:2.0.0 CL:/opt/GOAT/CASAVA_1.7.0a6/bin/illumina_export2sam.pl --read1=s_7_1_export.txt --read2=s_7_2_export.txt

    I don't figure out what the problem is here.. There are all three tags (ID, VN, and CL).

    One hint is that I can find a warning when I check the header part with samtools (samtools view myfile.bam -H) like below:

    The tag '--' present (at least) twice on line [@PG ID:illumina_export2sam.pl VN:2.0.0 CL:/opt/GOAT/CASAVA_1.7.0a6/bin/illumina_export2sam.pl --read1=s_7_1_export.txt --read2=s_7_2_export.txt]

    Is this a cause of this error? or there's any other problem in my file?

    Thanks,
  • zee
    NGS specialist
    • Apr 2008
    • 249

    #2
    I would recommend that you "reheader" your sam file with "samtools reheader" if you would like to try and isolate the cause of this problem.
    Basically use "samtools view -H file.bam > header.txt". Edit header.txt and perhaps remove the "--" from all your header lines, then use "samtools reheader" with your new header file and the bam file.

    Comment

    • jmarshall
      Samtools maintainer
      • Jul 2009
      • 39

      #3
      The hint from samtools view is telling you that '--' is being interpreted as a tag, which means that it is immediately following a tab character each time it appears.

      SAM header fields are delimited by tabs, so header field values of course cannot themselves contain tabs. Your CL: value has the words of the command line separated by tabs rather than spaces, leading to parsing confusion.

      If illumina_export2sam.pl is generating this CL: value with tabs inside it, then that is a bug in illumina_export2sam.pl -- it should be replacing tabs with spaces (or doing something similar) to ensure that it is outputting a valid SAM header.

      You may be able to reheader your BAM file so as to replace these spurious tabs with spaces yourself. Or when you produce the SAM file it would be easy to replace them with sed or a text editor. Or it should be easy to fix illumina_export2sam.pl yourself if it is a Perl script -- just search for /@PG/ and/or /CL:/ which most likely appear exactly once in the script.

      Comment

      • rachmani
        Junior Member
        • Aug 2010
        • 2

        #4
        Thank you zee and jmarshall.
        As in your postings, I extracted original headers from my BAM files using "samtools view -H myfile.bam > output.file". And using picard "ReplaceSamHeader", I successfully replaced the modified header.

        So, now the IndelGenotyperV2 does not arise an error message about bam headers.
        Now it is complaining about memory.. haha (althogh I gave 2g to him)

        Thank you both anyway

        Comment

        • disciple
          Junior Member
          • Mar 2011
          • 3

          #5
          Originally posted by zee View Post
          I would recommend that you "reheader" your sam file with "samtools reheader" if you would like to try and isolate the cause of this problem.
          Basically use "samtools view -H file.bam > header.txt". Edit header.txt and perhaps remove the "--" from all your header lines, then use "samtools reheader" with your new header file and the bam file.
          I also have a problem of the BAM file header
          "Error parsing SAM header. Problem parsing @PG key:value pair. Line:
          @PG TopHat VN:1.0.13"
          when i use "samtools view -H file.bam > header.txt" and Edit header.txt then use "samtools reheader" ,it comes out gibberish.how to use the "samtools reheader "??

          Comment

          Latest Articles

          Collapse

          • SEQadmin2
            Beyond CRISPR/Cas9: Understand, Choose, and Use the Right Genome Editing Tool
            by SEQadmin2



            CRISPR/Cas9 sparked the gene editing revolution for both research and therapeutics.1 But this system still showed severe issues that limited its applications. The most prominent were the heavy reliance on PAM sequences, delivery limitations, double-stranded breaks that prompt unintended edits and cell death, and editing inefficiency (both in targeting and in knock-in reliability).

            Despite this, “CRISPR helped turn genome editing from a specialized technique into
            ...
            Yesterday, 11:01 AM
          • SEQadmin2
            Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
            by SEQadmin2


            Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

            The systematic characterization of the human proteome has
            ...
            07-20-2026, 11:48 AM
          • SEQadmin2
            Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
            by SEQadmin2



            Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
            ...
            07-09-2026, 11:10 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, Yesterday, 02:55 AM
          0 responses
          9 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-24-2026, 12:17 PM
          0 responses
          12 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-23-2026, 11:41 AM
          0 responses
          12 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-20-2026, 11:10 AM
          0 responses
          24 views
          0 reactions
          Last Post SEQadmin2  
          Working...