예제 #1
0
def get_gene_page_content(gene_id):
    dbname = session['db_selected']
    db = get_db()
    try:
        gene = lookups.get_gene(db, gene_id)
        if gene is None:
            abort(404)
        cache_key = 't-gene-{}'.format(gene_id)
        t = cache.get(cache_key)
        print 'Rendering %sgene: %s' % ('' if t is None else 'cached ',
                                        gene_id)
        if t is None:
            variants_in_gene = lookups.get_variants_in_gene(db, gene_id)
            transcripts_in_gene = lookups.get_transcripts_in_gene(db, gene_id)

            # Get some canonical transcript and corresponding info
            transcript_id = gene['canonical_transcript']
            transcript = lookups.get_transcript(db, transcript_id)
            variants_in_transcript = lookups.get_variants_in_transcript(
                db, transcript_id)
            coverage_stats = lookups.get_coverage_for_transcript(
                db, transcript['xstart'] - EXON_PADDING,
                transcript['xstop'] + EXON_PADDING)
            add_transcript_coordinate_to_variants(db, variants_in_transcript,
                                                  transcript_id)
            constraint_info = lookups.get_constraint_for_transcript(
                db, transcript_id)

            t = render_template(
                'gene.html',
                gene=gene,
                transcript=transcript,
                variants_in_gene=variants_in_gene,
                variants_in_transcript=variants_in_transcript,
                transcripts_in_gene=transcripts_in_gene,
                coverage_stats=coverage_stats,
                constraint=constraint_info,
                csq_order=csq_order,
                dbname=dbname,
            )
            cache.set(cache_key, t)
        return t
    except Exception, e:
        print 'Failed on gene:', gene_id, ';Error=', traceback.format_exc()
        abort(404)
예제 #2
0
def get_gene_data(db, gene_id, gene, request_type, cache_key):
    try:
        transcript_id = gene['canonical_transcript']
        transcripts_in_gene = lookups.get_transcripts_in_gene(db, gene_id)
        variant_data  = lookups.get_variants_in_gene_or_transcript(db, gene_id=gene_id)
        variants_in_transcript = variant_data["all_variants"]

        # Get some canonical transcript and corresponding info
        transcript = lookups.get_transcript(db, transcript_id)
        coverage_stats_exomes = lookups.get_coverage_for_transcript(db, 'exome_coverage', transcript['xstart'] - EXON_PADDING, transcript['xstop'] + EXON_PADDING)
        # change base_coverage to e.g. genome_base_coverage when the data gets here
        coverage_stats_genomes = lookups.get_coverage_for_transcript(db, 'genome_coverage', transcript['xstart'] - EXON_PADDING, transcript['xstop'] + EXON_PADDING)
        coverage_stats = {
            'exomes': coverage_stats_exomes,
            'genomes': coverage_stats_genomes
        }
        add_transcript_coordinate_to_variants(db, variants_in_transcript, transcript_id)
        constraint_info = lookups.get_constraint_for_transcript(db, transcript_id)
        if request_type == 'template':
            result = render_template(
                'gene.html',
                gene=gene,
                transcript=transcript,
                variants_in_transcript=variants_in_transcript,
                transcripts_in_gene=transcripts_in_gene,
                coverage_stats=coverage_stats,
                constraint=constraint_info,
                uuid_lists=variant_data['uuid_lists']
            )
        if request_type == 'json':
            result = jsonify(
                gene=gene,
                transcript=transcript,
                variants_in_transcript=variants_in_transcript,
                transcripts_in_gene=transcripts_in_gene,
                coverage_stats=coverage_stats,
                constraint=constraint_info,
                uuid_lists=variant_data['uuid_lists']
            )
        cache.set(cache_key, result, timeout=1000*60)
        return result
    except Exception, e:
        print 'Failed on gene:', gene_id, ';Error=', traceback.format_exc()
        abort(404)
예제 #3
0
def get_gene_page_content(gene_id):
    db = get_db()
    try:
        gene = lookups.get_gene(db, gene_id)
        if gene is None:
            abort(404)
        cache_key = 't-gene-{}'.format(gene_id)
        t = cache.get(cache_key)
        if t is None:
            variants_in_gene = lookups.get_variants_in_gene(db, gene_id)
            transcripts_in_gene = lookups.get_transcripts_in_gene(db, gene_id)

            # Get some canonical transcript and corresponding info
            transcript_id = gene['canonical_transcript']
            transcript = lookups.get_transcript(db, transcript_id)
            variants_in_transcript = lookups.get_variants_in_transcript(
                db, transcript_id)
            cnvs_in_transcript = lookups.get_exons_cnvs(db, transcript_id)
            cnvs_per_gene = lookups.get_cnvs(db, gene_id)
            coverage_stats = lookups.get_coverage_for_transcript(
                db, transcript['xstart'] - EXON_PADDING,
                transcript['xstop'] + EXON_PADDING)
            add_transcript_coordinate_to_variants(db, variants_in_transcript,
                                                  transcript_id)
            constraint_info = lookups.get_constraint_for_transcript(
                db, transcript_id)

            t = render_template('gene.html',
                                gene=gene,
                                transcript=transcript,
                                variants_in_gene=variants_in_gene,
                                variants_in_transcript=variants_in_transcript,
                                transcripts_in_gene=transcripts_in_gene,
                                coverage_stats=coverage_stats,
                                cnvs=cnvs_in_transcript,
                                cnvgenes=cnvs_per_gene,
                                constraint=constraint_info)
            cache.set(cache_key, t, timeout=1000 * 60)
        print 'Rendering gene: %s' % gene_id
        return t
    except Exception, e:
        print 'Failed on gene:', gene_id, ';Error=', traceback.format_exc()
        abort(404)
예제 #4
0
def get_gene_page_content(gene_id):
    db = get_db()
    try:
        gene = lookups.get_gene(db, gene_id)
        if gene is None:
            abort(404)
        cache_key = 't-gene-{}'.format(gene_id)
        t = cache.get(cache_key)
        if t is None:
            variants_in_gene = lookups.get_variants_in_gene(db, gene_id)
            transcripts_in_gene = lookups.get_transcripts_in_gene(db, gene_id)

            # Get some canonical transcript and corresponding info
            transcript_id = gene['canonical_transcript']
            transcript = lookups.get_transcript(db, transcript_id)
            variants_in_transcript = lookups.get_variants_in_transcript(db, transcript_id)
            cnvs_in_transcript = lookups.get_exons_cnvs(db, transcript_id)
            cnvs_per_gene = lookups.get_cnvs(db, gene_id)
            coverage_stats = lookups.get_coverage_for_transcript(db, transcript['xstart'] - EXON_PADDING, transcript['xstop'] + EXON_PADDING)
            add_transcript_coordinate_to_variants(db, variants_in_transcript, transcript_id)
            constraint_info = lookups.get_constraint_for_transcript(db, transcript_id)

            t = render_template(
                'gene.html',
                gene=gene,
                transcript=transcript,
                variants_in_gene=variants_in_gene,
                variants_in_transcript=variants_in_transcript,
                transcripts_in_gene=transcripts_in_gene,
                coverage_stats=coverage_stats,
                cnvs = cnvs_in_transcript,
                cnvgenes = cnvs_per_gene,
                constraint=constraint_info
            )
            cache.set(cache_key, t, timeout=1000*60)
        print 'Rendering gene: %s' % gene_id
        return t
    except Exception, e:
        print 'Failed on gene:', gene_id, ';Error=', traceback.format_exc()
        abort(404)
예제 #5
0
def get_gene_page_content(gene_id):
    db = get_db()
    try:
        gene = lookups.get_gene(db, gene_id)
        if gene is None:
            abort(404)
        cache_key = "t-gene-{}".format(gene_id)
        t = cache.get(cache_key)
        print "Rendering %sgene: %s" % ("" if t is None else "cached ", gene_id)
        if t is None:
            variants_in_gene = lookups.get_variants_in_gene(db, gene_id)
            transcripts_in_gene = lookups.get_transcripts_in_gene(db, gene_id)

            # Get some canonical transcript and corresponding info
            transcript_id = gene["canonical_transcript"]
            transcript = lookups.get_transcript(db, transcript_id)
            variants_in_transcript = lookups.get_variants_in_transcript(db, transcript_id)
            coverage_stats = lookups.get_coverage_for_transcript(
                db, transcript["xstart"] - EXON_PADDING, transcript["xstop"] + EXON_PADDING
            )
            add_transcript_coordinate_to_variants(db, variants_in_transcript, transcript_id)
            constraint_info = lookups.get_constraint_for_transcript(db, transcript_id)

            t = render_template(
                "gene.html",
                gene=gene,
                transcript=transcript,
                variants_in_gene=variants_in_gene,
                variants_in_transcript=variants_in_transcript,
                transcripts_in_gene=transcripts_in_gene,
                coverage_stats=coverage_stats,
                constraint=constraint_info,
                csq_order=csq_order,
            )
            cache.set(cache_key, t)
        return t
    except Exception, e:
        print "Failed on gene:", gene_id, ";Error=", traceback.format_exc()
        abort(404)