<commit_before># -*- coding: utf-8 -*-
import logging
from flask import (Blueprint, render_template, request, send_file)

from .partial import send_file_partial

igv_bp  = Blueprint('igv', __name__, template_folder='templates',
                      static_folder='static', static_url_path='/igv/static')

LOG = logging.getLogger(__name__)

@igv_bp.route('/igv')
def viewer():
    """Visualize BAM alignments using igv.js (https://github.com/igvteam/igv.js)"""
    chrom = request.args['contig']
    if chrom == 'MT':
        chrom = 'M'

    start = request.args['start']
    stop = request.args['stop']

    locus = "chr{0}:{1}-{2}".format(chrom,start,stop)
    LOG.debug('Displaying locus %s', locus)

    chromosome_build = request.args['build']
    LOG.debug('Chromosome build is %s', chromosome_build)

    samples = request.args.getlist('sample')
    bam_files = request.args.getlist('bam')
    bai_files = request.args.getlist('bai')
    LOG.debug('loading the following tracks: %s', bam_files)

    display_obj={}

    # Add chromosome build info to the track object
    reference = ''
    reference_url = ''
    indexURL = ''
    format = ''
    if chromosome_build == '37':
        reference = 'hg19'
        reference_url = 'https://s3.amazonaws.com/igv.broadinstitute.org/annotations/hg19/genes/refGene.hg19.bed.gz'
        indexURL = 'https://s3.amazonaws.com/igv.broadinstitute.org/annotations/hg19/genes/refGene.hg19.bed.gz.tbi'
        format = 'bed'
    elif chromosome_build == '38':
        reference = 'hg38'
        reference_url = 'https://s3.amazonaws.com/igv.broadinstitute.org/annotations/hg38/genes/Homo_sapiens.GRCh38.80.sorted.gtf.gz'
        indexURL = 'https://s3.amazonaws.com/igv.broadinstitute.org/annotations/hg38/genes/Homo_sapiens.GRCh38.80.sorted.gtf.gz.tbi'
        format = 'gtf'

    display_obj['reference_id'] = reference
    display_obj['genome'] = reference
    display_obj['reference_track'] = {
        'name' : 'Genes',
        'type' : 'annotation',
        'format': format,
        'sourceType': 'file',
        'url' : reference_url,
        'indexURL' : indexURL,
        'displayMode' : 'EXPANDED'
    }

    sample_tracks = []
    counter = 0
    for sample in samples:
        # some samples might not have an associated bam file, take care if this
        if bam_files[counter]:
            sample_tracks.append({ 'name' : sample, 'url' : bam_files[counter], 'indexURL' : bai_files[counter] })
        counter += 1

    display_obj['sample_tracks'] = sample_tracks
    return render_template('igv_viewer.html', locus=locus, **display_obj )<commit_msg>modified reference name to match the one in case collection<commit_after># -*- coding: utf-8 -*-
import logging
from flask import (Blueprint, render_template, request, send_file)

from .partial import send_file_partial

igv_bp  = Blueprint('igv', __name__, template_folder='templates',
                      static_folder='static', static_url_path='/igv/static')

LOG = logging.getLogger(__name__)

@igv_bp.route('/igv')
def viewer():
    """Visualize BAM alignments using igv.js (https://github.com/igvteam/igv.js)"""
    chrom = request.args.get('contig')
    if chrom == 'MT':
        chrom = 'M'

    start = request.args.get('start')
    stop = request.args.get('stop')

    locus = "chr{0}:{1}-{2}".format(chrom,start,stop)
    LOG.debug('Displaying locus %s', locus)

    chromosome_build = request.args.get('build')
    LOG.debug('Chromosome build is %s', chromosome_build)

    samples = request.args.getlist('sample')
    bam_files = request.args.getlist('bam')
    bai_files = request.args.getlist('bai')
    LOG.debug('loading the following tracks: %s', bam_files)

    display_obj={}

    # Add chromosome build info to the track object
    reference = ''
    reference_url = ''
    indexURL = ''
    format = ''
    if chromosome_build == 'GRCh37':
        reference = 'hg19'
        reference_url = 'https://s3.amazonaws.com/igv.broadinstitute.org/annotations/hg19/genes/refGene.hg19.bed.gz'
        indexURL = 'https://s3.amazonaws.com/igv.broadinstitute.org/annotations/hg19/genes/refGene.hg19.bed.gz.tbi'
        format = 'bed'
    elif chromosome_build == 'GRCh38':
        reference = 'hg38'
        reference_url = 'https://s3.amazonaws.com/igv.broadinstitute.org/annotations/hg38/genes/Homo_sapiens.GRCh38.80.sorted.gtf.gz'
        indexURL = 'https://s3.amazonaws.com/igv.broadinstitute.org/annotations/hg38/genes/Homo_sapiens.GRCh38.80.sorted.gtf.gz.tbi'
        format = 'gtf'

    display_obj['reference_id'] = reference
    display_obj['genome'] = reference
    display_obj['reference_track'] = {
        'name' : 'Genes',
        'type' : 'annotation',
        'format': format,
        'sourceType': 'file',
        'url' : reference_url,
        'indexURL' : indexURL,
        'displayMode' : 'EXPANDED'
    }

    sample_tracks = []
    counter = 0
    for sample in samples:
        # some samples might not have an associated bam file, take care if this
        if bam_files[counter]:
            sample_tracks.append({ 'name' : sample, 'url' : bam_files[counter], 'indexURL' : bai_files[counter] })
        counter += 1

    display_obj['sample_tracks'] = sample_tracks
    return render_template('igv_viewer.html', locus=locus, **display_obj )
{'fraction_non_alphanumeric': 0.1422625804010594, 'fraction_numerical': 0.014377601210745366, 'mean_word_length': 3.1499215070643642, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6702541', 'n_tokens_mistral': 1846, 'n_tokens_neox': 1731, 'n_words': 329}