Go Back   SEQanswers > Bioinformatics > Bioinformatics

Similar Threads
Thread Thread Starter Forum Replies Last Post
COSMIC vcf file contains "N" & "." characters in ALT column vipul jain Bioinformatics 1 09-03-2015 12:16 AM
Samtools "is recognized as '*'" "truncated file" error axiom7 Bioinformatics 3 11-26-2014 02:53 AM
Something wrong with access Bam file using "SeqAn" library sunredrock Bioinformatics 2 04-14-2013 11:59 PM
The position file formats ".clocs" and "_pos.txt"? Ist there any difference? elgor Illumina/Solexa 0 06-27-2011 07:55 AM
help on "truncated file", when converting sam to bam jianfeng.mao Bioinformatics 0 12-18-2010 02:03 AM

Thread Tools
Old 05-30-2018, 01:20 PM   #1
Junior Member
Location: Michigan, US

Join Date: Mar 2017
Posts: 2
Default Fixing BAM file header. Getting "truncated file. Aborting" error


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

These are my commands:

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 \

The first 3 commands execute without any problems.
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:
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.
dfermin315 is offline   Reply With Quote
Old 05-30-2018, 02:54 PM   #2
Senior Member
Location: East Coast USA

Join Date: Feb 2008
Posts: 6,884

Consider the answer given in this thread:
GenoMax is offline   Reply With Quote
Old 06-01-2018, 04:32 AM   #3
Junior Member
Location: Michigan, US

Join Date: Mar 2017
Posts: 2

Thanks for pointing me to that post!
I'm still having issues but I'll work with the suggested command there.
dfermin315 is offline   Reply With Quote

reheader, samtools

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -8. The time now is 05:58 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO