This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Question: how to get low quality read from sam file

Hello, l am a starter.I used hisat2 to generate a sam file and have extracted unmapping reads. l want to extract reads with a mapping quality lower than 10.My instructor reminded me to think about how to get the mapping quality.but I don't know how to extract it. Thanks for your help.

rna-seq alignment

sam file is a text file and one of the columns codes for map qualities. Filter the data by map quality column and validate with standard tools such as samtools.

2 answers

For example use sambamba:

sambamba view -c -F "mapping_quality < 10" --sam-input -f sam -o filtered.sam in.sam

https://lomereiter.github.io/sambamba/docs/sambamba-view.html

samtools view is able to filter for "quality greater than". But for "lower than", you could use awk:

samtools view -h in.bam | awk -F '\t' '$0 ~ /^@/ || $5< 10'

Log in to answer this question.