Unconfigured Ad

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

    #1

    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

      • SEQadmin2
        Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
        by SEQadmin2



        Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

        Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
        ...
        10-14-2026, 09:55 AM
      • SEQadmin2
        New Genomics Technologies Take Aim at Long-Standing Limits
        by SEQadmin2


        Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

        We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
        ...
        09-28-2026, 10:25 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by SEQadmin2, 10-22-2026, 11:13 AM
      0 responses
      29 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 10-22-2026, 10:48 AM
      0 responses
      22 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 10-15-2026, 10:52 AM
      0 responses
      38 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 10-14-2026, 05:39 AM
      0 responses
      45 views
      0 reactions
      Last Post SEQadmin2  
      Working...