def get_coding_intervals(self, build='<STR_LIT>', genes=None):
intervals = {}<EOL>if not genes:<EOL><INDENT>genes = self.all_genes(build=build)<EOL><DEDENT>LOG.info("<STR_LIT>")<EOL>for i,hgnc_obj in enumerate(genes):<EOL><INDENT>chrom = hgnc_obj['<STR_LIT>']<EOL>start = max((hgnc_obj['<STR_LIT:start>'] - <NUM_LIT>), <NUM_LIT:1>)<EOL>end = hgnc_obj['<STR_LIT:end>'] + <NUM_LIT><EOL>if chrom not in intervals:<EOL><INDENT>intervals[chrom] = intervaltree.IntervalTree()<EOL>intervals[chrom].addi(start, end, i)<EOL>continue<EOL><DEDENT>res = intervals[chrom].search(start, end)<EOL>if not res:<EOL><INDENT>intervals[chrom].addi(start, end, i)<EOL>continue<EOL><DEDENT>for interval in res:<EOL><INDENT>if interval.begin < start:<EOL><INDENT>start = interval.begin<EOL><DEDENT>if interval.end > end:<EOL><INDENT>end = interval.end<EOL><DEDENT>intervals[chrom].remove(interval)<EOL><DEDENT>intervals[chrom].addi(start, end, i)<EOL><DEDENT>return intervals<EOL>
Return a dictionary with chromosomes as keys and interval trees as values

        Each interval represents a coding region of overlapping genes.

        Args:
            build(str): The genome build
            genes(iterable(scout.models.HgncGene)):

        Returns:
            intervals(dict): A dictionary with chromosomes as keys and overlapping genomic intervals as values