sam file error
1
0
Entering edit mode
7.7 years ago
2yuna710 ▴ 10

After sequences mapping, I got Sam format files. So, I wanted to sort the files by samtools. But I got some error messages as below.

[W::sam_read1] parse error at line 1
[bam_sort_core] truncated file. Aborting.

I opened the Sam files, and they may be error as below.

The lines like [M::mem_pestat] skip orientation FF as there are not enough pairs are also in between of Sam file.

I don't know how to fix them. Please help me!!

$ head -n 20 KPGP-00145_L1.sam
[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: (461, 468, 475)
[M::mem_pestat] low and high boundaries for computing mean and std.dev: (433, 503)
[M::mem_pestat] mean and std.dev: (467.88, 10.86)
[M::mem_pestat] low and high boundaries for proper pairs: (419, 517)
[M::mem_pestat] analyzing insert size distribution for orientation RF...
[M::mem_pestat] (25, 50, 75) percentile: (528, 1240, 2853)
[M::mem_pestat] low and high boundaries for computing mean and std.dev: (1, 7503)
[M::mem_pestat] mean and std.dev: (1599.90, 1413.75)
[M::mem_pestat] low and high boundaries for proper pairs: (1, 9828)
[M::mem_pestat] skip orientation RR as there are not enough pairs
[M::mem_pestat] skip orientation RF
@SQ SN:1            LN:249250621
@SQ SN:2    LN:243199373
@SQ SN:3    LN:198022430
@SQ SN:4    LN:191154276
@SQ SN:5    LN:180915260
@SQ SN:6    LN:171115067
@SQ SN:7    LN:159138663
genome sequence • 3.0k views
ADD COMMENT
3
Entering edit mode

Hello,

what was the exact command for producing your sam file?

The lines with [M::mem_pestat] looks like info messages from bwa. But they should not appear in the sam file.

fin swimmer

ADD REPLY
1
Entering edit mode

I moved this to a comment because it's not an answer to the thread (although definitely helpful suggestion and follow-up question).

ADD REPLY
2
Entering edit mode

well this case some time occurs when you run your alignment command with "nohup". Try running without nohup option.

Try this might help you.

ADD REPLY
0
Entering edit mode

When I ran without nohup option, it worked normally!! I really appreciate your answer!!

But I don't know why nohup option makes abnormal result. Could you explain the reason? I cannot find the reason.

ADD REPLY
2
Entering edit mode

It looks as if stdout and stderr were merged. Could you please post the commands that you typed a) to generate the sam, b) to sort the sam (which should not work (at least with the older samtools versions))

ADD REPLY
0
Entering edit mode

Your thought is right! Thank you so much. Because of nohup option the result was abnormal. I don't know why this situation happened.

ADD REPLY
2
Entering edit mode
7.7 years ago
Michael 55k

It is unclear which command and version you are using, but most likely nohup is the culprit. If running under nohup, it is mandatory in newer versions of samtools (htslib) to specify the output filename using option '-o sorted.bam', see the documentation http://www.htslib.org/doc/samtools.html

ADD COMMENT
0
Entering edit mode

Yes, you are right. Thank you so much. nohup is the culprit. Although I used the newest version of samtools with nohup, the problem occurred.

ADD REPLY
0
Entering edit mode

It is because of using a later htslib versions of samtools have a different call syntax. In the earlier versions (0.x), a prefix for the output needed to be provided: like so samtools sort my.bam out.sorted which would generate out.sorted.bam and not write anything to stdout. The way it is now is imo much better.

You should be able to run it just fine under nohup like so:

nohup samtools sort -o aln.sorted.bam aln.bam
ADD REPLY

Login before adding your answer.

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