I'm trying to figure out how STAR generates the mapping statistics in the .Log.final.out file, by trying to use standard commands such as samtools to count. But I'm having trouble getting the exact number that STAR reports.
First, samtools view -F 256 gets basically all read pairs (which is presumably what STAR is reporting). What is the criteria for "Uniquely mapped" and "Multimapped to multiple loci"? Does it require that both reads are mapped, or can one of them be unmapped? I've done samtools view -F 260 -F 264, but this gives me a number that is substantially lower than the "Uniquely mapped" + "Multiple loci" counts (excluding the too many loci row).
One way I've thought about doing it is to first filter out all the unmapped read pairs and secondary mappings, and then filter by the NH tag with grep. Would that work?