generating Percent ID using CIGAR strings

Hello everyone,
I'm currently working with a bam file and I need to generate the percent ID of matches that are found in the CIGAR string. I'm having some trouble getting there, here are the libraries that I have.
library(Biostrings)
library(Rsamtools)
library(readr)
library(GenomicAlignments)
library(GenomicRanges)
library(IRanges)
library(GenomeInfoDb)
library(XVector)
Here are some of the codes that I'm working with.
###Gal is a gene alignments object where each element describes a genomic alignment
BamFile(file= "Example.bowtie2.bam")
gal <- readGAlignments("Example.bowtie2.bam")
gal
###I have a data table here that gives me the number of matches, insertions and deletions
colSums(cigarOpTable(cigar(gal)))

The percent identity = match-(NM)/length.
I will appreciate the help.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.