Esempio n. 1
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)
            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)

            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
            )
            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=', e
        abort(404)
Esempio n. 2
0
def transcript_page(transcript_id):
    db = get_db()
    try:
        transcript = lookups.get_transcript(db, transcript_id)

        cache_key = 't-transcript-{}'.format(transcript_id)
        t = cache.get(cache_key)
        print 'Rendering %stranscript: %s' % ('' if t is None else 'cached ', transcript_id)
        if t is None:

            gene = lookups.get_gene(db, transcript['gene_id'])
            gene['transcripts'] = lookups.get_transcripts_in_gene(db, transcript['gene_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)

            t = render_template(
                'transcript.html',
                transcript=transcript,
                transcript_json=json.dumps(transcript),
                variants_in_transcript=variants_in_transcript,
                variants_in_transcript_json=json.dumps(variants_in_transcript),
                coverage_stats=coverage_stats,
                coverage_stats_json=json.dumps(coverage_stats),
                gene=gene,
                gene_json=json.dumps(gene),
                csq_order=csq_order,
            )
            cache.set(cache_key, t)
        return t
    except Exception, e:
        print 'Failed on transcript:', transcript_id, ';Error=', traceback.format_exc()
        abort(404)
Esempio n. 3
0
def transcript_api(transcript_id):
    db = get_db()
    transcript = lookups.get_transcript(db, transcript_id)
    if transcript is None:
        abort(404)
    cache_key = 'json-transcript-{}'.format(transcript_id)
    json = cache.get(cache_key)
    if json is None:
        json = get_transcript_data(db, transcript_id, transcript, 'json', cache_key)
    print 'Sending json for transcript: %s' % transcript_id
    return json
Esempio n. 4
0
def transcript_template(transcript_id):
    db = get_db()
    transcript = lookups.get_transcript(db, transcript_id)
    if transcript is None:
        abort(404)
    cache_key = 'template-transcript-{}'.format(transcript_id)
    template = cache.get(cache_key)
    if template is None:
        template = get_transcript_data(db, transcript_id, transcript, 'template', cache_key)
    print 'Sending template for transcript: %s' % transcript_id
    return template
Esempio n. 5
0
def transcript_page(transcript_id):
    db = get_db()
    try:
        _log()
        transcript = lookups.get_transcript(db, transcript_id)
        if not transcript: return not_found_page('The requested transcript {!s} could not be found.'.format(transcript_id))
        gene = lookups.get_gene(db, transcript['gene_id'])
        intervalset = IntervalSet.from_transcript(db, transcript_id)
        genes = TranscriptSet.from_transcript(db, transcript_id).genes
        return render_template(
            'transcript.html',
            intervalset=intervalset, genes=genes, csq=Consequence.as_obj,
            gene=gene,
            transcript=transcript,
        )
    except:_err(); abort(500)
Esempio n. 6
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)
Esempio n. 7
0
def transcript_page(transcript_id):
    db = get_db()
    try:
        transcript = lookups.get_transcript(db, transcript_id)

        cache_key = 't-transcript-{}'.format(transcript_id)
        t = cache.get(cache_key)
        if t is None:

            gene = lookups.get_gene(db, transcript['gene_id'])
            gene['transcripts'] = lookups.get_transcripts_in_gene(
                db, transcript['gene_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, transcript['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)

            t = render_template(
                'transcript.html',
                transcript=transcript,
                transcript_json=json.dumps(transcript),
                variants_in_transcript=variants_in_transcript,
                variants_in_transcript_json=json.dumps(variants_in_transcript),
                coverage_stats=coverage_stats,
                coverage_stats_json=json.dumps(coverage_stats),
                gene=gene,
                gene_json=json.dumps(gene),
                cnvs=cnvs_in_transcript,
                cnvs_json=json.dumps(cnvs_in_transcript),
                cnvgenes=cnvs_per_gene,
                cnvgenes_json=json.dumps(cnvs_per_gene))
            cache.set(cache_key, t, timeout=1000 * 60)
        print 'Rendering transcript: %s' % transcript_id
        return t
    except Exception, e:
        print 'Failed on transcript:', transcript_id, ';Error=', traceback.format_exc(
        )
        abort(404)
Esempio n. 8
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)
Esempio n. 9
0
def transcript_page(transcript_id):
    dbname = session['db_selected']
    db = get_db()
    try:
        transcript = lookups.get_transcript(db, transcript_id)

        cache_key = 't-transcript-{}'.format(transcript_id)
        t = cache.get(cache_key)
        print 'Rendering %stranscript: %s' % ('' if t is None else 'cached ',
                                              transcript_id)
        if t is None:

            gene = lookups.get_gene(db, transcript['gene_id'])
            gene['transcripts'] = lookups.get_transcripts_in_gene(
                db, transcript['gene_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)

            t = render_template(
                'transcript.html',
                transcript=transcript,
                transcript_json=json.dumps(transcript),
                variants_in_transcript=variants_in_transcript,
                variants_in_transcript_json=json.dumps(variants_in_transcript),
                coverage_stats=coverage_stats,
                coverage_stats_json=json.dumps(coverage_stats),
                gene=gene,
                gene_json=json.dumps(gene),
                csq_order=csq_order,
                dbname=dbname,
            )
            cache.set(cache_key, t)
        return t
    except Exception, e:
        print 'Failed on transcript:', transcript_id, ';Error=', traceback.format_exc(
        )
        abort(404)
Esempio n. 10
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)
Esempio n. 11
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)
Esempio n. 12
0
def transcript_page(transcript_id):
    db = get_db()
    try:
        transcript = lookups.get_transcript(db, transcript_id)

        cache_key = "t-transcript-{}".format(transcript_id)
        t = cache.get(cache_key)
        print "Rendering %stranscript: %s" % ("" if t is None else "cached ", transcript_id)
        if t is None:

            gene = lookups.get_gene(db, transcript["gene_id"])
            gene["transcripts"] = lookups.get_transcripts_in_gene(db, transcript["gene_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)

            t = render_template(
                "transcript.html",
                transcript=transcript,
                transcript_json=json.dumps(transcript),
                variants_in_transcript=variants_in_transcript,
                variants_in_transcript_json=json.dumps(variants_in_transcript),
                coverage_stats=coverage_stats,
                coverage_stats_json=json.dumps(coverage_stats),
                gene=gene,
                gene_json=json.dumps(gene),
                csq_order=csq_order,
            )
            cache.set(cache_key, t)
        return t
    except Exception, e:
        print "Failed on transcript:", transcript_id, ";Error=", traceback.format_exc()
        abort(404)
def get_gene_page_content(gene_id):
    db = get_db()
    try:
        print "gene_id", gene_id
        gene = lookups.get_gene(db, gene_id)
        print "gene", gene
        if gene is None:
            abort(404)
        gene_name = gene['gene_name']
        print gene_name
        variants_in_gene = lookups.get_variants_in_gene(db, gene_name)
        transcripts_in_gene = lookups.get_transcripts_in_gene(db, gene_id)
        transcript_id = gene['canonical_transcript']
        transcript = lookups.get_transcript(db, transcript_id)
        variants_in_transcript = lookups.get_variants_in_transcript(
            db, transcript_id)
        add_transcript_coordinate_to_variants(db, variants_in_transcript,
                                              transcript_id)

        #print gene
        #print variants_in_gene
        #print transcript
        #print transcripts_in_gene
        #print "variants_in_transcript\n",variants_in_transcript

        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)
        print 'Rendering gene: %s' % gene_id
        return t
    except Exception, e:
        print 'Failed on gene:', gene_id, ';Error=', traceback.format_exc()
        abort(404)