I've looked through the documentation for samtools and pysam but haven't found what I'm looking for. Pysam can check if read.is_secondary
which returns true if the read is not primary alignment. Whilst in samtools, I think the corresponding flag is:
256 0x100 secondary alignment
But what I'm looking for is a way to view/filter reads that are mapped to multiple regions, is there a way to do this with samtools or pysam?
Note that this is an optional tag, so it may or may not be present, depending on the aligner and command. I suggest filtering reads based on the required field mapq; a read with mapq 3 or lower is not uniquely mapped, and a read with mapq >3 is uniquely mapped.
Hi Brian, i would like to extract only the reads with mapping score 0, but as far as i understand the parameter "-q" only filters out what is equal or smaller that the argument. But i would actually isolate and study on only mapq 0 reads. Can you help me with that?
If you have
bamtools
,To support use of MAPq, see reference here: https://monashdatafluency.github.io/rnaseq-intro/qc.html
With your command,there may be some multi alignments containing such as NH:i:12 in NH tag.Maybe the pattern "(NH:i:1\b|^@)" is better.