Determing number of spliced alignments in a BAM file
1
1
Entering edit mode
8.9 years ago
gc166475 ▴ 10

What is the best way of determining the number of spiced alignments in a BAM file with SAMTOOLS? My research on the web shows that the character "N" in CIGAR string indicates a splice.

Thank you, Greg

SAMTOOLS BAM • 3.7k views
ADD COMMENT
1
Entering edit mode
8.9 years ago

You can play with bash commands..

I don't remember the column that represents the CIGAR (I believe is column 7)

You can do the following

cat your_file.sam | cut -f 7 | grep "N" | wc -l

If playing with BAM files

samtools view your_file.bam | cut -f 7 | grep "N" | wc -l

With cat and samtools view you open the content of the file and pipe it to the cut command, which select column 7. With grep you select those lanes containing a N into the CIGAR string, and pipe it again to wc -l which count the lanes containing such a N

ADD COMMENT
0
Entering edit mode

Thank you for your assistance!

ADD REPLY
0
Entering edit mode

Actually, it's column -f6.

You've helped me too, thanks!!

ADD REPLY

Login before adding your answer.

Traffic: 1846 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6