Example #1
0
def upload():
    if request.method == 'POST':
        if 'vcf_file' not in request.files:
            return jsonify({'msg': 'No vcf gzip part', 'table': []})
        vcf_type = request.form['vcf_type']
        vcf_file = request.files['vcf_file']
        if vcf_file.filename == '':
            return jsonify({'msg': 'No selected file', 'table': []})

        if vcf_file and vcf_file.filename.rsplit('/')[-1][-6:] == 'vcf.gz':
            # add timestamp
            filename = '_'.join(
                [str(int(time.time())),
                 secure_filename(vcf_file.filename)])
            filepath = os.path.join(Config.VCF_FILE_PATH, filename)
            vcf_file.save(filepath)
            if os.stat(filepath).st_size > 1 * 1000:
                task = async_fetch_vcf_samples.delay(filename,
                                                     current_user.username,
                                                     vcf_type)
                redis_task.push_task(current_user.username, task.id)
                return jsonify({'msg': 'async', 'task_id': task.id})
            else:
                result = fetch_vcf_samples(filename, vcf_type)
                # write to mysql
                for each in result:
                    row = Data(tc_id=each[0],
                               provider=current_user.username,
                               sample_name=each[1],
                               type=vcf_type)
                    row.save()
                return jsonify({'msg': 'ok', 'table': result})
        return jsonify({'msg': 'check upload file(only *.vcf.gz suffix)'})
Example #2
0
def fetch_compare():
    if request.method == 'POST':
        info = request.form['info']
        info = json.loads(info)
        task = compare_info.delay(info)
        redis_task.push_task(current_username(), task.id)
        return jsonify({'msg': 'ok', 'task_id': task.id})
    return jsonify({'msg': 'method not allowed'})
Example #3
0
def fetch_query_result():
    if request.method == 'POST':
        info = request.form['info']
        info = json.loads(info)
        task = snp_info.delay(info)
        if current_user.is_authenticated:
            user_name = current_user.username
        else:
            user_name = 'anonymous'
        redis_task.push_task(user_name, task.id)
        return jsonify({'msg': 'ok', 'task_id': task.id})
    return jsonify({'msg': 'method not allowed'})
Example #4
0
def fetch_enrich_table():
    if request.method == 'POST':
        specie = request.form['specie']
        gene_list = request.form.get('gene_list')
        if gene_list:
            gene_list = parseInput(gene_list)
            if len(gene_list) > 20:
                task = async_run_enrich.delay(specie, gene_list)
                redis_task.push_task(current_user.username, task.id)
                return jsonify({'msg': 'async', 'task_id': task.id})
            result = run_enrich(specie, gene_list)
            if len(result['body']) == 0:
                return jsonify({
                    'msg': 'no enrich on your gene list.',
                    'result': {}
                })
            return jsonify({'msg': 'ok', 'result': result})
        file = request.files['file']
        filename = secure_filename(file.filename)
        file.save(os.path.join(UPLOAD_FOLDER, 'enrich', filename))
        task = async_run_enrich.delay(specie, filename)
        return jsonify({'msg': 'async', 'task_id': task.id})
Example #5
0
def fetch_bsa():
    if request.method == 'POST':
        info = request.form['info']
        task = run_bsa.delay(info)
        redis_task.push_task(current_username(), task.id)
        return jsonify({'msg': 'ok', 'task_id': task.id})