Exemple #1
0
def alignment_view(request, project_uid, alignment_group_uid):
    """View of a single AlignmentGroup.
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    alignment_group = get_object_or_404(AlignmentGroup,
            reference_genome__project=project, uid=alignment_group_uid)

    # Initial javascript data.
    init_js_data = json.dumps({
        'project': adapt_model_instance_to_frontend(project),
        'alignment_group': adapt_model_instance_to_frontend(alignment_group)
    })
    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'alignment_group': alignment_group,
        'experiment_sample_to_alignment_list_json': adapt_model_to_frontend(
                ExperimentSampleToAlignment,
                {'alignment_group': alignment_group}),
        'init_js_data': init_js_data,
        'flag_genome_finishing_enabled': int(settings.FLAG__GENOME_FINISHING_ENABLED)
    }
    return render(request, 'alignment.html', context)
def alignment_view(request, project_uid, alignment_group_uid):
    """View of a single AlignmentGroup.
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    alignment_group = get_object_or_404(AlignmentGroup,
            reference_genome__project=project, uid=alignment_group_uid)

    if request.POST:
        return _rerun_alignment(alignment_group)

    # Initial javascript data.
    init_js_data = json.dumps({
        'project': adapt_model_instance_to_frontend(project),
        'alignment_group': adapt_model_instance_to_frontend(alignment_group)
    })
    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'alignment_group': alignment_group,
        'experiment_sample_to_alignment_list_json': adapt_model_to_frontend(
                ExperimentSampleToAlignment,
                {'alignment_group': alignment_group}),
        'init_js_data': init_js_data
    }
    return render(request, 'alignment.html', context)
Exemple #3
0
def variant_set_view(request, project_uid, variant_set_uid):
    """Data view for a single VariantSet which includes options for taking
    actions on the VariantSet.
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)
    variant_set = get_object_or_404(VariantSet,
            reference_genome__project=project,
            uid=variant_set_uid)

    # Initial javascript data.
    init_js_data = json.dumps({
        'entity': {
            'uid': variant_set.uid,
            'project': adapt_model_instance_to_frontend(project),
            'refGenomeUid': variant_set.reference_genome.uid,
        }
    })

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'variant_set': variant_set,
        'init_js_data': init_js_data,
        'is_print_mage_oligos_enabled':
                settings.FLAG__PRINT_MAGE_OLIGOS_ENABLED,
        'is_generate_new_reference_genome_enabled':
                settings.FLAG__GENERATE_NEW_REFERENCE_GENOME_ENABLED
    }

    return render(request, 'variant_set.html', context)
Exemple #4
0
def alignment_create_view(request, project_uid):
    """Displays the view for creating a new alignment.

    Also handles POST request to actually creating the alignment.
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    # Validate and kick off new alignment.
    if request.POST:
        return _start_new_alignment(request, project)

    # Show the data that renders the create view.
    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(project)
    })

    is_new_project = bool(request.GET.get('is_new_project', False))

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'init_js_data': init_js_data,
        'is_new_project': is_new_project
    }
    return render(request, 'alignment_create.html', context)
def alignment_create_view(request, project_uid):
    """Displays the view for creating a new alignment.

    Also handles POST request to actually creating the alignment.
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    # Validate and kick off new alignment.
    if request.POST:
        return _start_new_alignment(request, project)

    # Show the data that renders the create view.
    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(project)
    })

    is_new_project = bool(request.GET.get('is_new_project', False))

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'init_js_data': init_js_data,
        'is_new_project': is_new_project
    }
    return render(request, 'alignment_create.html', context)
Exemple #6
0
def reference_genome_view(request, project_uid, ref_genome_uid):
    """Overview of a single ReferenceGenome.
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    reference_genome = ReferenceGenome.objects.get(project=project,
            uid=ref_genome_uid)

    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(reference_genome)
    })

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'reference_genome': reference_genome,
        'reference_genome_uid': reference_genome.uid,
        'has_fasta': reference_genome.dataset_set.filter(
                type=Dataset.TYPE.REFERENCE_GENOME_FASTA).exists(),
        'has_genbank': reference_genome.dataset_set.filter(
                type=Dataset.TYPE.REFERENCE_GENOME_GENBANK).exists(),
        'jbrowse_link': reference_genome.get_client_jbrowse_link(),
        'init_js_data': init_js_data
    }
    return render(request, 'reference_genome.html', context)
def reference_genome_view(request, project_uid, ref_genome_uid):
    """Overview of a single project.
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    reference_genome = ReferenceGenome.objects.get(project=project,
            uid=ref_genome_uid)

    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(reference_genome)
    })

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'reference_genome': reference_genome,
        'reference_genome_uid': reference_genome.uid,
        'has_fasta': reference_genome.dataset_set.filter(
                type=Dataset.TYPE.REFERENCE_GENOME_FASTA).exists(),
        'has_genbank': reference_genome.dataset_set.filter(
                type=Dataset.TYPE.REFERENCE_GENOME_GENBANK).exists(),
        'jbrowse_link': reference_genome.get_client_jbrowse_link(),
        'init_js_data': init_js_data
    }
    return render(request, 'reference_genome.html', context)
def variant_set_view(request, project_uid, variant_set_uid):
    """Data view for a single VariantSet which includes options for taking
    actions on the VariantSet.
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)
    variant_set = get_object_or_404(VariantSet,
            reference_genome__project=project,
            uid=variant_set_uid)

    # Initial javascript data.
    init_js_data = json.dumps({
        'entity': {
            'uid': variant_set.uid,
            'project': adapt_model_instance_to_frontend(project),
            'refGenomeUid': variant_set.reference_genome.uid,
        }
    })

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'variant_set': variant_set,
        'init_js_data': init_js_data,
        'is_print_mage_oligos_enabled':
                settings.FLAG__PRINT_MAGE_OLIGOS_ENABLED,
        'is_generate_new_reference_genome_enabled':
                settings.FLAG__GENERATE_NEW_REFERENCE_GENOME_ENABLED
    }

    return render(request, 'variant_set.html', context)
Exemple #9
0
def tab_root_analyze(request, project_uid, alignment_group_uid=None, sub_view=None):
    """The analyze view. Subviews are loaded in Javascript.
    """
    context = {}

    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    # Initial javascript data to establish initial state.
    init_js_data = {
        'project': adapt_model_instance_to_frontend(project)
    }

    alignment_group = None
    if alignment_group_uid is not None:
        alignment_group = get_object_or_404(AlignmentGroup,
                uid=alignment_group_uid,
                reference_genome__project__owner=request.user.get_profile())
        init_js_data['alignmentGroup'] = adapt_model_instance_to_frontend(
                alignment_group)
        context['active_alignment_group'] = alignment_group

        ref_genome = alignment_group.reference_genome
        init_js_data['refGenome'] = adapt_model_instance_to_frontend(
                ref_genome)
        context['active_ref_genome'] = ref_genome

    if sub_view is not None:
        if not sub_view in VALID_ANALYZE_SUB_VIEWS:
            raise Http404
        init_js_data['subView'] = sub_view
        context['sub_view'] = sub_view

    ref_genomes_with_alignments = [
            rg for rg in ReferenceGenome.objects.filter(project=project)
            if rg.alignmentgroup_set.exists()]

    context.update({
        'project': project,
        'init_js_data': json.dumps(init_js_data),
        'tab_root': TAB_ROOT__ANALYZE,
        'ref_genomes_with_alignments': ref_genomes_with_alignments,
        'genome_finish_enabled': settings.FLAG__GENOME_FINISHING_ENABLED
    })

    return render(request, 'tab_root_analyze.html', context)
def tab_root_analyze(request, project_uid, alignment_group_uid=None, sub_view=None):
    """The analyze view. Subviews are loaded in Javascript.
    """
    context = {}

    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    # Initial javascript data to establish initial state.
    init_js_data = {
        'project': adapt_model_instance_to_frontend(project)
    }

    alignment_group = None
    if alignment_group_uid is not None:
        alignment_group = get_object_or_404(AlignmentGroup,
                uid=alignment_group_uid,
                reference_genome__project__owner=request.user.get_profile())
        init_js_data['alignmentGroup'] = adapt_model_instance_to_frontend(
                alignment_group)
        context['active_alignment_group'] = alignment_group

        ref_genome = alignment_group.reference_genome
        init_js_data['refGenome'] = adapt_model_instance_to_frontend(
                ref_genome)
        context['active_ref_genome'] = ref_genome

    if sub_view is not None:
        if not sub_view in VALID_ANALYZE_SUB_VIEWS:
            raise Http404
        init_js_data['subView'] = sub_view
        context['sub_view'] = sub_view

    ref_genomes_with_alignments = [rg for rg in ReferenceGenome.objects.all() 
            if rg.alignmentgroup_set.exists()]

    context.update({
        'project': project,
        'init_js_data': json.dumps(init_js_data),
        'tab_root': TAB_ROOT__ANALYZE,
        'ref_genomes_with_alignments': ref_genomes_with_alignments
    })

    return render(request, 'tab_root_analyze.html', context)
Exemple #11
0
def variant_set_list_view(request, project_uid):
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    error_string = ''

    # If a POST, then we are creating a new variant set.
    if request.method == 'POST':
        # Common validation.
        # TODO: Most of this should be validated client-side.
        if (not 'refGenomeID' in request.POST or
                request.POST['refGenomeID'] == ''):
            error_string = 'No reference genome selected.'
        elif (not 'variantSetName' in request.POST or
                request.POST['variantSetName'] == ''):
            error_string = 'No variant set name.'

        if not error_string:
            ref_genome_uid = request.POST['refGenomeID']
            variant_set_name = request.POST['variantSetName']

            # Handling depending on which form was submitted.
            if request.POST['create-set-type'] == 'from-file':
                error_string = _create_variant_set_from_file(request, project,
                        ref_genome_uid, variant_set_name)
            elif request.POST['create-set-type'] == 'empty':
                error_string = _create_variant_set_empty(project,
                        ref_genome_uid, variant_set_name)
            else:
                return HttpResponseBadRequest("Invalid request.")

    # Grab all the ReferenceGenomes for this project
    # (for choosing which ref genome a new variant set goes into).
    ref_genome_list = ReferenceGenome.objects.filter(project=project)

    # Initial javascript data.
    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(project)
    })

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'ref_genome_list' : ref_genome_list,
        'init_js_data' : init_js_data,
        'error_string': error_string
    }

    return render(request, 'variant_set_list.html', context)
def variant_set_list_view(request, project_uid):
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    error_string = ''

    # If a POST, then we are creating a new variant set.
    if request.method == 'POST':
        # Common validation.
        # TODO: Most of this should be validated client-side.
        if (not 'refGenomeID' in request.POST or
                request.POST['refGenomeID'] == ''):
            error_string = 'No reference genome selected.'
        elif (not 'variantSetName' in request.POST or
                request.POST['variantSetName'] == ''):
            error_string = 'No variant set name.'

        if not error_string:
            ref_genome_uid = request.POST['refGenomeID']
            variant_set_name = request.POST['variantSetName']

            # Handling depending on which form was submitted.
            if request.POST['create-set-type'] == 'from-file':
                error_string = _create_variant_set_from_file(request, project,
                        ref_genome_uid, variant_set_name)
            elif request.POST['create-set-type'] == 'empty':
                error_string = _create_variant_set_empty(project,
                        ref_genome_uid, variant_set_name)
            else:
                return HttpResponseBadRequest("Invalid request.")

    # Grab all the ReferenceGenomes for this project
    # (for choosing which ref genome a new variant set goes into).
    ref_genome_list = ReferenceGenome.objects.filter(project=project)

    # Initial javascript data.
    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(project)
    })

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'ref_genome_list' : ref_genome_list,
        'init_js_data' : init_js_data,
        'error_string': error_string
    }

    return render(request, 'variant_set_list.html', context)
def alignment_list_view(request, project_uid):
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(project)
    })

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'init_js_data': init_js_data,
    }

    return render(request, 'alignment_list.html', context)
Exemple #14
0
def alignment_list_view(request, project_uid):
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(project)
    })

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'init_js_data': init_js_data,
    }

    return render(request, 'alignment_list.html', context)
def project_view(request, project_uid):
    """Overview of a single project.
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    # Initial javascript data.
    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(project)
    })

    context = {
        'project': project,
        'init_js_data': init_js_data,
        'tab_root': TAB_ROOT__DATA
    }
    return render(request, 'project.html', context)
Exemple #16
0
def project_view(request, project_uid):
    """Overview of a single project.
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    # Initial javascript data.
    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(project)
    })

    context = {
        'project': project,
        'init_js_data': init_js_data,
        'tab_root': TAB_ROOT__DATA
    }
    return render(request, 'project.html', context)
Exemple #17
0
def reference_genome_list_view(request, project_uid):
    """Shows the ReferenceGenomes and handles creating new
    ReferenceGenomes when requested.
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(project)
    })

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'init_js_data': init_js_data,
    }

    return render(request, 'reference_genome_list.html', context)
def genome_finish_view(request, project_uid):
    """Displays reference genomes on the opening page of
    the genome finish tab
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(project)
    })

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'init_js_data': init_js_data,
    }

    return render(request, 'genome_finish.html', context)
def reference_genome_list_view(request, project_uid):
    """Shows the ReferenceGenomes and handles creating new
    ReferenceGenomes when requested.
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(project)
    })

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'init_js_data': init_js_data,
    }

    return render(request, 'reference_genome_list.html', context)
Exemple #20
0
def contig_view(request, project_uid, contig_uid):
    """Overview of a single Contig.
    """
    project = get_object_or_404(Project, owner=request.user.get_profile(),
            uid=project_uid)

    contig = Contig.objects.get(
            parent_reference_genome__project=project, uid=contig_uid)

    init_js_data = json.dumps({
        'entity': adapt_model_instance_to_frontend(contig)
    })

    context = {
        'project': project,
        'tab_root': TAB_ROOT__DATA,
        'contig': contig,
        'init_js_data': init_js_data,
    }
    return render(request, 'contig.html', context)