Question: sam to bam conversion problem
0
gravatar for jinxinhao1988
21 months ago by
China/Beijing
jinxinhao198860 wrote:

I use bwa mem to align reads. And got several log info at the head of the samfile. Like this:

[M::main_mem] read71286 sequences(10000200 bp)...
[M::mem_pestat]# candidate unique pairs for(FF, FR, RF, RR):(0,5009,0,0) 
[M::mem_pestat]skip orientation FF as there are not enough pairs 
[M::mem_pestat]analyzing insert size distribution for orientation FR...
[M::mem_pestat](25,50,75) percentile:(160,170,174)
[M::mem_pestat]low and high boundaries for computing mean and std. 
[M::mem_pestat]mean and std. dev:(165.99,9.13)
[M::mem_pestat]low and high boundaries for proper pairs:(118,216) 
[M::mem_pestat]skip orientation RF as there are not enough pairs 
[M::mem_pestat]skip orientation RR as there are not enough pairs 
[M::mem_pestat]processed71286 reads in6.210 CPU sec,6.219 real sec

Then I want to convert the sam file into bam, when I use samtools view to do that, It has an error :

# [samopen] no @SQ lines in the header.
# [sam_read1] missing header? Abort!

so I cut the first 11 lines in the head, and then run it again, and I got another error,

# [samopen] SAM header is present: 25 sequences.
# Parse error at line 71433: sequence and quality are inconsistent

So there are mutiple this log info scattered in the sam file ,so I can not convert into bam.

How could this happen? is there other ways I can convert to bam file?

Thank you in advance.

bwa breakdancer • 796 views
ADD COMMENTlink modified 21 months ago by mittu1602170 • written 21 months ago by jinxinhao198860

Please add the commands you used for bwa mem.

ADD REPLYlink written 21 months ago by WouterDeCoster41k

I use the basic command of mem align.

bwa mem test.fasta 1.fq 2.fq > aln_pe.sam

ADD REPLYlink written 21 months ago by jinxinhao198860

Sure you didn't use nohup or '&>` or something similar? Because this looks like combining stderr and stdout together.

ADD REPLYlink written 21 months ago by WouterDeCoster41k

I use nohup and & in the bwa mem running. but don't use in the samtools running cause I want to see the error info. Sorry I don't quite understand the meaning of stderr and stdout combination.

ADD REPLYlink written 21 months ago by jinxinhao198860
1

I use nohup and & in the bwa mem running.

Well there's your problem.

I use the basic command of mem align.

bwa mem test.fasta 1.fq 2.fq > aln_pe.sam

Next time, when someone asks you about the commands you used, give the commands you used and not a piece of it. You left out important information.

ADD REPLYlink modified 21 months ago • written 21 months ago by WouterDeCoster41k

WouterDeCoster means standard log message displayed by BWA got concatenated with your standard .sam output file instead of adding to nohup file. Thus you were able to see BWA log message as first 11 lines of your .sam file.

I think you should rerun the BWA mem again without nohup or anything similar followed by samtools view.

And again if you get this error

[samopen] SAM header is present: 25 sequences.

Parse error at line 71433: sequence and quality are inconsistent

then there is surely something wrong in your reads file as error "sequence and quality are inconsistent" means number of total bases in your sequence is not same as number of quality representing those bases

ADD REPLYlink written 21 months ago by toralmanvar820
1
gravatar for mittu1602
21 months ago by
mittu1602170
India
mittu1602170 wrote:

Try following the commands below with same parameters:\

bwa mem ucsc.hg19.fasta 1.fastq 2.fastq -M   > test.alnpe.sam
samtools view -Sb test.alnpe.sam >test_bam.alnpe.bam
samtools "sort" -@ 24 test_bam.alnpe.bam >test_bam.alnpe.sort.bam

Good luck!!

ADD COMMENTlink written 21 months ago by mittu1602170
1

Simplified, without intermediate files:

bwa mem ref.fasta R1.fastq R2.fastq | samtools sort -o sorted_result.bam -
ADD REPLYlink modified 21 months ago • written 21 months ago by WouterDeCoster41k
0
gravatar for toralmanvar
21 months ago by
toralmanvar820
toralmanvar820 wrote:

you have not mentioned about the parameters you are using for sam to bam conversion, however you can try using simple basic command:

samtools view -bS in.sam > out.bam

Or you can check out similar post addressing the same issue here

ADD COMMENTlink written 21 months ago by toralmanvar820

The bwa align I use basic command line : bwa mem test.fasta 1.fq 2.fa > aln_pe.sam

and the conversion I use exact like the one you write in the comments.

ADD REPLYlink written 21 months ago by jinxinhao198860

one of your file is in fastq and the other in fasta? or just a typo error?

ADD REPLYlink written 21 months ago by mittu1602170
1

Sorry, that's a typo error. I am trying to run the bwa mem without nohup as toralmanvar said. I think maybe that's the problem.

ADD REPLYlink written 21 months ago by jinxinhao198860
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: 726 users visited in the last hour