Error In Sam To Bam Conversion
2
2
Entering edit mode
11.7 years ago
SK ▴ 110

I want to convert SAM file into BAM. I am using command

samtools view -b -S -o bowtie.glob.bam bowtie.glob.sam

but getting error

Parse error at line 25645: invalid CIGAR character

Could someone please help me to solve this problem?

next-gen samtools RNA-seq • 9.6k views
ADD COMMENT
1
Entering edit mode

Could you post line 25645 of your SAM file? And the version number of your samtools?

ADD REPLY
0
Entering edit mode

Could you please try:

samtools view -b -S bowtie.glob.bam bowtie.glob.sam

This is because -b already gives bam output and -S as sam input. This might help.

ADD REPLY
0
Entering edit mode

Thanks Rohit, but samtools view -b -S -o bowtie.glob.bam bowtie.glob.sam is the same command that I used.

ADD REPLY
0
Entering edit mode

Also, what program generated that SAM file?

ADD REPLY
1
Entering edit mode
11.7 years ago
Rohit ★ 1.5k

I went through it, the solution is to add the index file. Create the index files with

samtools faidx sequence.fa

This creates the index file *.fai. The final command for conversion is

samtools view -bt sequence.fa.fai -S bowtie.glob.sam -o bowtie.glob.sam

Cheers,
Rohit

ADD COMMENT
1
Entering edit mode
11.7 years ago

I know you have got the solution but here is what is mentioned in the samtools manual:

Import SAM to BAM when @SQ lines are present in the header:

samtools view -bS aln.sam > aln.bam

If @SQ lines are absent:

samtools faidx ref.fa 
samtools view -bt ref.fa.fai aln.sam > aln.bam

where ref.fa.fai is generated automatically by the faidx command.

ADD COMMENT
1
Entering edit mode

The manual was where I got the solution from... Forgot to mention that...

Cheers...

ADD REPLY

Login before adding your answer.

Traffic: 2161 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