예제 #1
0
def download_data_set(request, data_set_id, what, file_ext):
    us = get_session(request)
    data_sets = DataSet.get_common_data_sets() if us is None else us.get_all_allowed_dataset_set()

    if what == 'reference':
        data_set_id, file_ext = DataSet.split_seq_ext(data_set_id + file_ext)

    try:
        ds = data_sets.get(dirname=data_set_id)
    except DataSet.DoesNotExist:
        return HttpResponseNotFound('Data set %s was not found' % data_set_id)

    if what == 'reference':
        fpath = os.path.join(ds.get_dirpath(), ds.reference_fname)
        if DataSet.split_seq_ext(fpath)[1] != file_ext:
            return HttpResponseNotFound()

        return __download(fpath, data_set_id + file_ext)

    else:
        if what == 'genes':
            fpath = os.path.join(ds.get_dirpath(), ds.genes_fname)
        elif what == 'operons':
            fpath = os.path.join(ds.get_dirpath(), ds.operons_fname)
        else:
            return HttpResponseNotFound()

        if DataSet.split_genes_ext(fpath)[1] != file_ext:
            return HttpResponseNotFound()

        return __download(fpath, data_set_id + '_' + what + file_ext)
예제 #2
0
def __set_data_set_info(qs, response_dict):
    data_set_title = ''
    if qs.data_set:
        if qs.data_set.remember:
            data_set_title = escape(qs.data_set.name)

        response_dict['data_set'] = {
            'title': data_set_title,
            'id': qs.data_set.dirname,
            'reference_ext': DataSet.split_seq_ext(qs.data_set.reference_fname)[1] if qs.data_set.reference_fname else None,
            'genes_ext': DataSet.split_genes_ext(qs.data_set.genes_fname)[1] if qs.data_set.genes_fname else None,
            'operons_ext': DataSet.split_genes_ext(qs.data_set.operons_fname)[1] if qs.data_set.operons_fname else None,
        }