SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
Invalid VCF files from Lifescope - allele "-" yl01 Bioinformatics 0 09-27-2013 05:53 AM
samtools invalid BAM binary header bob-loblaw Bioinformatics 4 04-08-2013 02:15 PM
"samtools: no @sq lines in the header" - metagenome! PenelopeFudd Bioinformatics 11 08-12-2012 10:04 PM
"allele balance ratio" and "quality by depth" in VCF files efoss Bioinformatics 2 10-25-2011 12:13 PM
Help with Samtools "view" Ash Bioinformatics 1 10-01-2010 06:29 AM

Reply
 
Thread Tools
Old 04-01-2014, 09:45 AM   #1
fabfab
Junior Member
 
Location: Paris, France

Join Date: Mar 2014
Posts: 3
Question Pipelining "Samtools view" : invalid header in output .bam files

Hi,

I'm trying to filter properly paired and mapped reads from a BWA alignment using this command:
Code:
samtools view -hu -F4 bam_sorted.bam | samtools view -hu -F256 - | samtools view -h -f3 - > test.bam
But the terminal tells me:
Code:
[bam_header_read] EOF marker is absent. The input is probably truncated.
[bam_header_read] EOF marker is absent. The input is probably truncated.
Despite these error messages, the output file (test.bam) is generated and seems to contain the reads I selected.
I red that I should not take care of this error messages. However, how I can be sure that there are no problems or that my output file is not truncated ?

But there's a more annoying consequence: I cannot handle further my test.bam file, because samtools says the formatting is incorrect !
example, if I try:
Code:
samtools view -c test.bam
I get again:
Code:
[bam_header_read] EOF marker is absent. The input is probably truncated.
[bam_header_read] invalid BAM binary header (this is not a BAM file).
[main_samview] fail to read the header from "test.bam".
But if I open the file (using the -u option in the last pipe to avoid compression), I see that the header with @HD and @SQ is here ! So why do samtools not see it ?

Moreover, when I use "samtools view" to convert my .sam into .bam or to sort the previous .bam, everything works well (header is present and samtools can read the .bam file)... at least when I run these command in two steps not piping them.

I've read several threads on this issue, but I couldn't find a clear answer
(but I'm new to bioinformatics, so maybe I did'nt get it).
Please, could someone help me on this issue?

For info, I'm running samtools Version: 0.1.19-96b5f2294a.
Before, I ran BWA (Version: 0.7.5a-r405) for mapping

Last edited by fabfab; 04-02-2014 at 01:25 AM.
fabfab is offline   Reply With Quote
Old 04-01-2014, 10:32 AM   #2
maubp
Peter (Biopython etc)
 
Location: Dundee, Scotland, UK

Join Date: Jul 2009
Posts: 1,543
Default

Quote:
Originally Posted by fabfab View Post
But the terminal tells me:
Code:
[bam_header_read] EOF marker is absent. The input is probably truncated.
[bam_header_read] EOF marker is absent. The input is probably truncated.
This warning can be a false alarm due to a bug in samtools v0.0.18 and v0.0.19 but which should be fixed in later releases - see https://github.com/samtools/samtools/issues/18
maubp is offline   Reply With Quote
Old 04-01-2014, 10:34 AM   #3
maubp
Peter (Biopython etc)
 
Location: Dundee, Scotland, UK

Join Date: Jul 2009
Posts: 1,543
Default

Quote:
Originally Posted by fabfab View Post
Hi,

I'm trying to filter properly paired and mapped reads from a BWA alignment using this command:
Code:
samtools view -hu -F4 bam_sorted.sam | ...
Are you really starting with a SAM input file? You need the -S (big S) to tell samtools view the input is SAM (it defaults to expecting BAM input).
maubp is offline   Reply With Quote
Old 04-02-2014, 12:40 AM   #4
fabfab
Junior Member
 
Location: Paris, France

Join Date: Mar 2014
Posts: 3
Default

Hi,

In fact, I tried starting both with a .bam and .sam file (using the -S option in that case), but I ended up with the same error warning messages.
Excuse me, I made a mistake in copy-pasting my command lines, so my post is confusing. I edited my previous post to correct the code I use (in red)

Ok if this is a bug and I can neglect the error warnings.
But what about my main issue: I cannot use the output filtered .bam file with samtools because it is not recognized as a correctly formated BAM ?

Thanks for help,
Fabrice
fabfab is offline   Reply With Quote
Old 04-02-2014, 01:24 AM   #5
fabfab
Junior Member
 
Location: Paris, France

Join Date: Mar 2014
Posts: 3
Default

Hi again,

Ok, I got my mistake !
It might seem silly for most of you, but I write it down for beginners that could face the same issues...
In my previous pipe, the last ouput is not a compressed bam: I omitted the option -b:

before:
Quote:
Code:
samtools view -hu -F4 bam_sorted.bam | samtools view -hu -F256 - | samtools view -h -f3 - > test.bam
modified code:
Code:
samtools view -hu -F4 bam_sorted.bam | samtools view -hu -F256 - | samtools view -bh -f3 - > test.bam

I still have the error messages (that we don't care about)
But now, I can work with the output (test.bam) which is in a correct format recognized by samtools.
fabfab is offline   Reply With Quote
Reply

Tags
.bam, format, samtools 0.1.19.0

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 04:21 PM.


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