This is a test version of Biostars. For the public version, visit https://www.biostars.org.
File not suitable for fasta index generation.

Hey, I have a sorted and indexed .bam file, and I am running it through freebayes, with the script :

freebayes -f ref.fa -@ in.vcf.gz aln.bam >var.vcf

And I had error like this:

unable to find FASTA index entry for '1'

I have changed the headers in fasta file from chr1, chr2 ... to 1, 2, 3 .. to match vcf file by:

for i in {1..64185939}; do echo $i; done | paste - <(sed '/^>/d' hg38.fa) | sed -e 's/^/>/' -e 's/\t/\n/' > new.fa

then I run this script and I get the:

index file index.fai not found, generating...
ERROR: mismatched line lengths at line 39028338 within sequence
File not suitable for fasta index generation.

Could you give me some advice?

fasta index freebayes

1 answer

The message is clear: the line lengths in your fasta files should all have the same size:

you want

> seq1
aaaaaaaaaaaaaaaaaaaaaaaaaaaa 
aaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaa
> seq2
aaaaaaaaaaaaaaaaaaaaaaaaaaaa 
aaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaa

you have

> seq1
aaaaaaaaaaaaaaaaaaaaaaaaaaaa 
aaa
aaaaaaaa
> seq2
aaaaaaaaaaaaaaaaaaaaaaaaaaaa 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaa

you could use https://broadinstitute.github.io/picard/command-line-overview.html#NormalizeFasta to fix the fasta.

Log in to answer this question.