More Counting - This Time Reads in Exons and Introns
One thing that is important to compare is the relative coverage of reads in exonic vs. intronic regions. We can count reads in introns and exons using the IntervalTree and Gene classes we used previously. We will derive a new class from the Gene class. The new class objects have properties for keeping track of read counts and methods for searching the exon tree and printing the counts. class GeneWithCounts(Gene): """ GeneWithCounts - extend Gene class to include counts of reads overlapping introns and exons, and search and print routines """ def __init__(self, gene_str): Gene.__init__(self, gene_str) self.read_count = 0 self.reads_in_exons = 0 self.reads_in_introns = 0 def SearchExons(self, read): """ SearchExons - search exon tree for read overlap with exon """ self.read_count += 1 exons = self.exons o...