def family_coverage_gene_list(request, family, gene_list): """ Table of summary coverages for each gene in the gene list """ sample_id_list = [str(individual.pk) for individual in family.get_individuals()] cache_key = ('family_coverage_gene_list', family.project.project_id, family.family_id, gene_list.slug) cached_results = server_utils.get_cached_results(cache_key) if cached_results: gene_coverages = cached_results else: gene_coverages = [] for gene_id in gene_list.gene_id_list(): d = { 'gene_id': gene_id, 'gene_name': get_reference().get_gene_symbol(gene_id), 'totals': get_coverage_store().get_coverage_totals_for_gene(gene_id, sample_id_list) } d['coding_size'] = sum(d['totals'].values()) try: d['percent'] = float(d['totals']['callable'])*100 / d['coding_size'] except ZeroDivisionError: d['percent'] = 0 gene_coverages.append(d) server_utils.save_results_cache(cache_key, gene_coverages) return render(request, 'coverage/family_coverage_gene_list.html', { 'project': family.project, 'family': family, 'gene_list': gene_list, 'gene_coverages': gene_coverages, })