Entering edit mode
17 months ago
bioinf_sci
▴
20
How can I filter a bam file using samtools view that retains reads where the cigar string contains M<=35?
How can I filter a bam file using samtools view that retains reads where the cigar string contains M<=35?
A bit messy, but it can be done with regexp matching:
samtools view -e 'cigar =~ "(^|[^0-9])([0-9]|[12][0-9]|3[0-5])M"' -o out.bam in.bam
The regexp is start or non-digit, followed by ?M [12]?M or 3[012345]M.
using samjdk: https://jvarkit.readthedocs.io/en/latest/SamJdk/
I cannot post code here ! there is a bug ni biostars...
so here is a gist:
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Hi, if I want to discard reads where the cigar string contains M < 100, how should I write this instead? Thank you~