This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Samtools mpileup fasta index problem

Hi,

I have a directory of .fasta files and .fasta.fai files. I am trying to use those as a reference sequence to the samtools mpileup command for reads in a different directory (BAM-Format):

for I in *
do
../../../../../../samtools-1.2/samtools mpileup ../Sorted_bam/Sorted_Aligned_$i.bam.bam -f $i -d 16847 -g -P flat > $i.bcf
done

But when I run it I get the error:

[mpileup] 1 samples in 1 input files
[fai_load] build FASTA index.
[fai_load] fail to open FASTA index.

​14 times (there are 14 files). What am I be doing wrong?

Thanks in advance.

fasta next-gen samtools

To to run samtools faidx $i by itself and see if you get the same error.

1 answer

if your directory has both .fasta and .fasta.fai files, the for loop needs to avoid the .fasta.fai ones:

for i in *.fasta

Yup it worked. Thanks!

Log in to answer this question.