What Is Practical Issues For Samtools Not Able To Sort The Sam File Directly?
3
0
Entering edit mode
10.3 years ago
Rm 8.2k

I was just wondering why we always needs to convert .sam to .bam and the sort it and convert back to .sam Any programming bottle necks to handle .sam file directly for this?

samtools sort sam bam • 3.8k views
ADD COMMENT
0
Entering edit mode

If you convert a sorted .bam file to .sam file, are you sure the .sam file is sorted?

ADD REPLY
0
Entering edit mode

yes, the samtools view command output the records in the bam file in the order they are stored.

ADD REPLY
2
Entering edit mode
10.3 years ago

Sorting is a resource consuming operation, the binary formats will sort much faster.

ADD COMMENT
2
Entering edit mode
10.3 years ago

Why would you convert back to sam? Leave things in .bam as much as possible. You probably only need to eyeball exerpts of your .sam file. pipe samtools view into something else if you have to run awk or grep or something like that on a ,bam file

ADD COMMENT
0
Entering edit mode

Or instead of using awk/grep on the output of samtools view, bamtools can be helpful to query bams directly.

ADD REPLY
0
Entering edit mode

I did all the piping and to get the sorted sam. I have methylation data (bismark generated sam file); Some of the R packages (say methylKit) need sorted SAM files only.

ADD REPLY
1
Entering edit mode
8.3 years ago

You could use Picard's SortSam tool to just sort the .sam file directly.

ADD COMMENT

Login before adding your answer.

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