Piping samtools commands
1
1
Entering edit mode
9.9 years ago
jyu429 ▴ 120

Hi,

I'm wondering how one would go about streaming the followings samtools commands without the intermediate bam and sam files.

samtools view -F 4 -b in.bam > filtered.bam
samtools sort filtered.bam filtered_sorted
samtools view filtered_sorted.bam > filtered_sorted.sam
awk -F "\t" '{print $3}' filtered_sorted.sam > rnames.txt

I'd appreciate any help!

samtools • 4.6k views
ADD COMMENT
1
Entering edit mode
9.9 years ago
samtools view -b -F 4 in.bam | samtools sort -o - TMP | samtools view - | awk '{ print $3}' > rnames.txt

rm TMP
ADD COMMENT
0
Entering edit mode

Thank you! But was there something wrong with the prior answer you had?

ADD REPLY
1
Entering edit mode

If you really care only about the final output, you could simply do:

samtools view -F 4 in.bam | cut -f3 | sort > rnames.txt
ADD REPLY

Login before adding your answer.

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