samtools mpileup fail to create bcf
1
0
Entering edit mode
2.6 years ago
mthm ▴ 50

I have indexed my reference.fasta using bowtie2:

bowtie2-build reference.fasta reference.fasta

created the bam file form the sam file using samtools, sorted and indexed the bam file:

samtools view -S -b Sample1_mapped.sam > Sample1_mapped.bam
samtools sort Sample1_mapped.bam -o Sample1_sorted > Sample1_sorted.bam
samtools index Sample1_sorted.bam

and now am trying to create the bcf from the bam file using the reference:

samtools mpileup -u Sample1_sorted.bam reference.fasta > Sample1.bcf

the error is

[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).
[mpileup] fail to read the header of reference.fasta

list of files created:

enter image description here

where am I wrong?

mpileup rfasta samtools • 989 views
ADD COMMENT
2
Entering edit mode
2.6 years ago
samtools sort Sample1_mapped.bam -o Sample1_sorted > Sample1_sorted.bam

you cannot use both option -o and redirect the output to stdout with '>'

-o FILE Write final output to FILE rather than standard output

furthermore using samtools mpileup for generating BCF is deprecated. use bcftools mpileup. See http://www.htslib.org/workflow/

ADD COMMENT
0
Entering edit mode

Thanks, I needed to put an -f to indicate the reference.fasta is faidx indexed and it worked

ADD REPLY

Login before adding your answer.

Traffic: 2828 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6