Esempio n. 1
0
def mendelian_variant_search(request, project_id, family_id):

    project = get_object_or_404(Project, project_id=project_id)
    family = get_object_or_404(Family, project=project, family_id=family_id)
    if not project.can_view(request.user):
        raise PermissionDenied

    if not family.has_data('variation'):
        return render(request, 'analysis_unavailable.html', {
            'reason': 'This family does not have any variant data.'
        })
    elif project.project_status == Project.NEEDS_MORE_PHENOTYPES and not request.user.is_staff:
        return render(request, 'analysis_unavailable.html', {
            'reason': 'Awaiting phenotype data.'
        })

    has_gene_search = get_project_datastore(project_id).project_collection_is_loaded(project_id)
    gene_lists = [project_gene_list.gene_list.toJSON(details=True) for project_gene_list in ProjectGeneList.objects.filter(project=project)]
    sys.stderr.write("returning mendelian_variant_search page for %(project_id)s %(family_id)s. has_gene_search = %(has_gene_search)s\n " % locals() )
    return render(request, 'mendelian_variant_search.html', {
        'gene_lists': json.dumps(gene_lists),
        'project': project,
        'family': family,
        'family_genotype_filters_json': json.dumps(x_inheritance.get_genotype_filters(family.xfamily())),
        'has_gene_search': has_gene_search or get_elasticsearch_dataset(project_id) is not None
    })
Esempio n. 2
0
 def has_variant_data(self):
     """
     Can we do cohort variant analyses
     So all individuals must have variant data
     """
     if get_elasticsearch_dataset(self.project.project_id) is not None:
         return True
     return all(individual.has_variant_data()
                for individual in self.get_individuals())
Esempio n. 3
0
    def has_variant_data(self):
        """
        Can we do family variant analyses on this family
        So True if any of the individuals have any variant data
        """
        if get_elasticsearch_dataset(self.project.project_id,
                                     family_id=self.family_id) is not None:
            return True

        return any(individual.has_variant_data()
                   for individual in self.get_individuals())
Esempio n. 4
0
    def get_data_status(self):
        if get_elasticsearch_dataset(self.project.project_id) is not None:
            return "loaded"

        if not self.has_variant_data():
            return 'no_variants'
        elif not get_datastore(self.project.project_id).family_exists(
                self.project.project_id, self.cohort_id):
            return 'not_loaded'
        else:
            return get_datastore(self.project.project_id).get_family_status(
                self.project.project_id, self.cohort_id)
Esempio n. 5
0
def add_extra_info_to_variants_project(reference, project, variants):
    """
    Add other info to a variant list that client might want to display:
    - disease annotations
    - coding_gene_ids
    """
    project_id = project.project_id
    if get_elasticsearch_dataset(project_id) is not None:
        #raise ValueError("Project is in elasticsearch: " + str(project_id))
        return

    add_gene_names_to_variants(reference, variants)
    add_disease_genes_to_variants(project, variants)
    add_gene_databases_to_variants(variants)
    add_gene_info_to_variants(variants)
    add_clinical_info_to_variants(variants)
Esempio n. 6
0
def add_extra_info_to_variants_family(reference, family, variants):
    """
    Add other info to a variant list that client might want to display:
    - disease annotations
    - coding_gene_ids
    """
    project_id = family.project.project_id
    if get_elasticsearch_dataset(project_id, family.family_id) is not None:
        #raise ValueError("Project is in elasticsearch: " + str(project_id))
        return

    add_gene_names_to_variants(reference, variants)
    add_disease_genes_to_variants(family.project, variants)
    add_gene_databases_to_variants(variants)
    add_gene_info_to_variants(variants)

    add_notes_to_variants_family(family, variants)
    #add_populations_to_variants(variants, settings.ANNOTATOR_REFERENCE_POPULATION_SLUGS)
    #add_custom_populations_to_variants(variants, family.project.private_reference_population_slugs())

    add_clinical_info_to_variants(variants)
Esempio n. 7
0
def project_home(request, project_id):

    project = get_object_or_404(Project, project_id=project_id)
    if not project.can_view(request.user):
        raise PermissionDenied
    project.set_accessed()
    if project.can_admin(request.user):
        auth_level = 'admin'
    elif project.can_edit(request.user):
        auth_level = 'editor'
    elif project.is_public:
        auth_level = 'public'
    elif project.can_view(request.user):
        auth_level = 'viewer'
    else:
        raise Exception("Authx - how did we get here?!?")

    phenotips_supported = True
    if settings.PROJECTS_WITHOUT_PHENOTIPS is not None and project_id in settings.PROJECTS_WITHOUT_PHENOTIPS:
        phenotips_supported = False
    return render(
        request, 'project.html', {
            'phenotips_supported':
            phenotips_supported,
            'project':
            project,
            'auth_level':
            auth_level,
            'can_edit':
            project.can_edit(request.user),
            'is_manager':
            project.can_admin(request.user),
            'has_gene_search':
            get_project_datastore(project_id).project_collection_is_loaded(
                project_id) or
            (get_elasticsearch_dataset(project_id) is not None)
        })
Esempio n. 8
0
 def has_variant_data(self):
     if get_elasticsearch_dataset(
             self.project.project_id,
             family_id=self.family.family_id) is not None:
         return True
     return self.vcf_files.all().count() > 0