This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Parallelizing SAMTOOLS: how to make my command run faster?

Hi Everyone,

I am trying to list the tags within my BAM file using following command:

 samtools view input.bam | cut -f 12- | tr '\t' '\n' | cut -d ':' -f 1 | awk '{ if(!x[$1]++) { print }}'

But it's taking so long for larger BAMs to output the tag names. I have more than 30 BAMs for different WGS samples. Is there any way to optimize my command-line to run it faster?

I have cluster available and we use PBS as job scheduler software.

I want my command to run fast. please help!

Thanks!

next-gen sequencing samtools

for i in *.bam ; do echo "samtools view $i | cut -f 12- | tr '\t' '\n' | cut -d ':' -f 1 | awk '{ if(!x[$1]++) { print }} > $i.out'" | qsub ; done ;

2 answers

Although the bugs are still being worked out, you might consider using Sambamba instead. It was made to be a faster version of Samtools.

Any other solution by using samtools?

I/O is generally not able to be parallelized; unless you're using an SSD, your hard drive can only read in data so fast due to mechanical limitations in the hardware. Sambamba achieves speed-ups over Samtools by optimizing caching methods, but it is still I/O bound.

Any other solution? by using samtools?

You just want to list the different possible tag names? Like this: A: RGID mismatch after using MergeBamAlignment

If so, you can do this in SeQC pretty quick. The reading of a single BAM file is not parallelized, but processing multiple BAMs at once is (because disk IO is always the bottleneck here).

Log in to answer this question.