Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • dfermin315
    Junior Member
    • Mar 2017
    • 4

    Fixing BAM file header. Getting "truncated file. Aborting" error

    Hello.

    I have a BAM file that I need to filter and then update the header for.

    These are my commands:

    Code:
    samtools view -@ 32  -h -b -f 2 -T /data/hs37d5.fa \
      -o samp1234.clean.bam \
      bam.files/samp1234.bam \
      1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X Y MT
    
    samtools view -H samp1234.clean.bam | \
      grep -v -e 'SN:GL' -e 'SN:NC' -e 'SN:hs37d5' \
      > samp1234.corrected.sam
    
    samtools reheader samp1234.corrected.sam \
      samp1234.clean.bam > samp1234.clean.reheaded.bam
    
    samtools sort -@ 32 \
      -o samp1234.clean.reheaded.sorted.bam \
      samp1234.clean.reheaded.bam

    The first 3 commands execute without any problems.
    Using
    Code:
    samtools view -h samp1234.clean.reheaded.bam | less -S
    I can see that the new BAM file does indeed contain the correct header.

    However every time I run the sorting command I get the error message:
    Code:
    samtools sort: truncated file. Aborting
    The samp1234.clean.reheaded.bam file seems to be fine in every regard. I can't seem to find a fault with it .

    Performing the reheading step in place doesn't seem to help nor does the -P option

    Does anyone have a suggestion of what I'm doing wrong?

    In case it helps I'm using samtools version 1.4-5-g692e058 (using htslib 1.4-5-g10bc1a7)

    Thanks in advance for any and all help.
  • GenoMax
    Senior Member
    • Feb 2008
    • 7142

    #2
    Consider the answer given in this thread: https://www.biostars.org/p/289770/

    Comment

    • dfermin315
      Junior Member
      • Mar 2017
      • 4

      #3
      Thanks for pointing me to that post!
      I'm still having issues but I'll work with the suggested command there.

      Comment

      Latest Articles

      Collapse

      • GATTACAT
        Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
        by GATTACAT
        Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
        07-01-2026, 11:43 AM
      • SEQadmin2
        Nine Things a Sample Prep Scientist Thinks About Before Sequencing
        by SEQadmin2


        I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

        Here are nine questions we think about, in roughly the order they matter, before...
        06-18-2026, 07:11 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by SEQadmin2, 07-02-2026, 11:08 AM
      0 responses
      25 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 06-30-2026, 05:37 AM
      0 responses
      23 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 06-26-2026, 11:10 AM
      0 responses
      23 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 06-17-2026, 06:09 AM
      0 responses
      55 views
      0 reactions
      Last Post SEQadmin2  
      Working...