This is a test version of Biostars. For the public version, visit https://www.biostars.org.
samtools mpileup fail to create bcf

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

1 answer

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/

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

Log in to answer this question.