Something like the following gives you the total number of soft- and hard-clipped reads
samtools view my.bam | cut -f6 | sed -n '/^[0-9]\+[SH]\|[0-9]\+[SH]$/p' | wc -l
Is there a way to check if there is a trimmed/clipped reads aligned and how much are they from my attempt of running bowtie2 --local mode?
You can read the CIGAR code in the SAM file. Look for H and S which represent hard clipping and soft clipping. The number in front of the H and S indicates the number of clipping.
Something like the following gives you the total number of soft- and hard-clipped reads
samtools view my.bam | cut -f6 | sed -n '/^[0-9]\+[SH]\|[0-9]\+[SH]$/p' | wc -l
Thanks, I want to check as my reads are quite short 20-25, and I used --local and seed -L 8, but in the IGV I do not see any clipped reads aligned near exon-intron sites? I'm running you command now .....
You might have to fiddle with your scoring parameters and filter for those short reads. See Bowtie2-manual --local and --score-min. Otherwise clipped reads might just not be reported.
Log in to answer this question.