I have a sam file. I want to select the reads with the best MAPQ (mapping quality).
Firstly, for example, I can have three reads with the same name but these have different MAPQ value, therefore I want to exclude the two reads with less MAPQ value and select the read with the best MAPQ.
Second, if there are three reads with the same name and the same number of MAPQ I want to exclude these three reads.
Thanks
Thanks Devon Can I do it in shell (awk, perl)? Are there any way to do it using samtools?
For the second requirement you can undoubtedly do that with perl. If the file is name sorted then you might be able to put something together with awk, but it'd be more trouble than it's worth. Stick to perl if that's what you know (or play with the code that Pierre posted if you're OK with javascript).