Hi everyone,
My sam files contains only three flag values:0, 4, 16. I want to filter out the flag values of 4 and 16, so I used a pipe as follows.
samtools view -Sh -F 4 in.sam | perl -F"\t" -ane 'print if /\@/; print if $F[1] == 0' | samtools view -Sb - > out.bam
After subsequent samtools sort out.bam out.sorted
and samtools index out.sorted.bam
steps, I run samtools tview, but see nothing there. Is my command wrong? Any of your comments will be much appreciated. THANKS!
Why don't you use
-f
or-F
option of samtools to filter based on flag ?Hi Geek_y, thank you for your comment.
samtools -F
is definitely the way to go, but just for sake of completeness, one error in your perl snippet is/\@/
, which should be/^@/
.Thank you thackl.