0

I'm trying to generate bcf files with bcftools with the following general code

bcftools mpileup -Ou -f ref.fai file.bam

Index was built with

samtools faidx index.fna

Sorted and markduped bam was by

samtools sort file.bam -o file_sorted.bam
samtools markdup file_sorted.bam file_sorted_md.bam

Then I ran

bcftools mpileup -Ou -f index.fna.fai file_sorted_md.bam > raw.bcf

receiving the following error

[E::fai_build_core] Format error, unexpected "N" at line 1

A general view of the index is

NM_001248012.2  2447    80      2447    2448
NM_001248013.1  612     2593    612     613
NM_001248014.1  1919    3266    1919    1920
NM_001248015.2  552     5264    552     553
NM_001248016.2  1074    5917    1074    1075
NM_001248017.2  788     7070    788     789
NM_001248019.2  1069    7940    1069    1070
NM_001248020.2  970     9088    970     971
NM_001248022.3  832     10137   832     833
NM_001248023.2  890     11048   890     891
NM_001248024.1  808     12017   808     809
NM_001248025.3  884     12904   884     885
NM_001248026.3  929     13867   929     930

I already tried removing the "N" from all lines, and then removing all alphabetic characters, but still getting an error with the numbers, like

[E::fai_build_core] Format error, unexpected "0" at line 1

I've also tried passing the bam file in a txt file

ls | grep file_sorted_md.bam > bam_list.txt
bcftools mpileup -Ou -f index.fna.fai -b bam_list.txt > raw.bcf

but cannot continue

Also searched on the web for the error, but other different errors appear

What is the problem and how can I solve it?

Mauro
  • 47
  • 6

1 Answers1

0

The problem was that although an index must have been build, in the following code instead of passing the index,

bcftools mpileup -Ou -f index.fna.fai -b bam_list.txt > raw.bcf

the reference genome must be passed

bcftools mpileup -Ou -f reference.fna -b bam_list.txt > raw.bcf 
Mauro
  • 47
  • 6