Samtools issues with bai files
1
0
Entering edit mode
7.6 years ago
njmcdonald ▴ 40

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 • 3.1k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
1
Entering edit mode
7.6 years ago

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 COMMENT

Login before adding your answer.

Traffic: 1762 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6