Question: Samtools issues with bai files
0
gravatar for njmcdonald
2.5 years ago by
njmcdonald40
North Carolina, US
njmcdonald40 wrote:

I have created a sam file using bowtie2. I need to convert it to a bam file, index it an do downstream variant calling. However, every attempt I've made to make an index file results in an an unusable file.

One approach:

[guest@centos6 wu2]$ samtools view -h wu_0.sorted.bam | head

@HD VN:1.0 SO:coordinate

@SQ SN:Chr1 LN:29923332

@SQ SN:Chr2 LN:19386101

@SQ SN:Chr3 LN:23042017

@SQ SN:Chr4 LN:18307997

@SQ SN:Chr5 LN:26567293

@SQ SN:chloroplast LN:154478

@SQ SN:mitochondria LN:366924

@PG ID:bowtie2 PN:bowtie2 VN:2.2.5 CL:"/usr/local/bin/bowtie2-align-s --wrapper basic-0 -x wu_0_A/wu_0_A wu_0_A_wgs.fastq -s wu_0_bt2.sam"

unknown:2:60:1525:1235/1 0 Chr1 396 42 50M * 0 0 TTACTCCTTTGTGGAAATGTTTGTTCTATCAATTTATCTTTTGTGGGAAA CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC AS:i:0 XN:i:0 XM:i:0 XO:i:0 XG:i:0 NM:i:0 MD:Z:50 YT:Z:UU

I then enter the command to index the file...

$ samtools index wu_0.sorted.bam

I confirm I have a file with the appropriate extension:

wu_0.sorted.bam.bai

I try to run mpileup command and the following errors result:

$ samtools mpileup -v -u -f wu_0.v7.fas wu_0.sorted.bam.bai > wu.vcf

[E::hts_hopen] fail to open file 'wu_0.sorted.bam.bai'

[E::hts_open] fail to open file 'wu_0.sorted.bam.bai'

[mpileup] failed to open wu_0.sorted.bam.bai: Success

Then I tried the following:

[guest@centos6 wu2]$ samtools view -bS wu_0_bt2.sam > wu_0.bam

[guest@centos6 wu2]$ samtools sort wu_0.bam wu.sorted

[guest@centos6 wu2]$ samtools index wu.sorted.bam

[guest@centos6 wu2]$ ls

wu_0_A  wu_0_A_wgs.fastq  wu_0.bam  wu_0_bt2.sam  wu_0_local_bt2.sam  wu_0.v7.fas  wu.sorted.bam  wu.sorted.bam.bai

[guest@centos6 wu2]$ samtools mpileup -v -u -f wu_0.v7.fas wu.sorted.bam.bai > wu.vcf

[fai_load] build FASTA index.

[E::hts_hopen] fail to open file 'wu.sorted.bam.bai'

[E::hts_open] fail to open file 'wu.sorted.bam.bai'

[mpileup] failed to open wu.sorted.bam.bai: No such file or directory

So what is going wrong?

software error • 1.3k views
ADD COMMENTlink modified 2.5 years ago by Devon Ryan88k • written 2.5 years ago by njmcdonald40

Is the .bai file non-zero bytes (i.e. non empty) in both cases?

ADD REPLYlink written 2.5 years ago by genomax63k
1
gravatar for Devon Ryan
2.5 years ago by
Devon Ryan88k
Freiburg, Germany
Devon Ryan88k wrote:

You meant to execute samtools mpileup -v -u -f wu_0.v7.fas wu_0.sorted.bam > wu.vcf. You don't specify the .bai files in commands; the files are loaded as needed.

ADD COMMENTlink written 2.5 years ago by Devon Ryan88k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1914 users visited in the last hour