Ejemplo n.º 1
0
def submit_indel_primer():
    """
        This endpoint is used to submit an indel primer job.
        The endpoint request is executed as a background task to keep the job alive.
    """
    data = request.get_json()

    # Generate an ID for the data based on its hash
    data_hash = hash_it(data, length=32)
    data['date'] = str(arrow.utcnow())

    # Check whether analysis has previously been run and if so - skip
    result = check_blob(f"reports/indel_primer/{data_hash}/results.tsv")
    if result:
        return jsonify({
            'thread_name': 'done',
            'started': True,
            'data_hash': data_hash
        })

    logger.debug("Submitting Indel Primer Job")
    # Upload query information
    data_blob = f"reports/indel_primer/{data_hash}/input.json"
    upload_file(data_blob, json.dumps(data), as_string=True)

    thread = Thread(target=indel_primer_task,
                    args=(data_hash, data['site'], data['strain_1'],
                          data['strain_2'], SV_VCF_URL))
    thread.daemon = True
    thread.start()
    return jsonify({
        'thread_name': str(thread.name),
        'started': True,
        'data_hash': data_hash
    })
Ejemplo n.º 2
0
def submit_h2():
    """
        This endpoint is used to submit a heritability job.
        The endpoint request is executed as a background task to keep the job alive.
    """
    data = request.get_json()
    data = [x for x in data[1:] if x[0] is not None]
    header = ["AssayNumber", "Strain", "TraitName", "Replicate", "Value"]
    data = pd.DataFrame(data, columns=header)
    data = data.to_csv(index=False, sep="\t")

    # Generate an ID for the data based on its hash
    data_hash = hash_it(data, length=32)
    logger.debug(data_hash)

    # Upload data immediately.
    data_blob = f"reports/heritability/{data_hash}/data.tsv"
    upload_file(data_blob, data, as_string=True)

    thread = Thread(target=h2_task, args=(
        data,
        data_hash,
    ))
    thread.daemon = True
    thread.start()
    return jsonify({
        'thread_name': str(thread.name),
        'started': True,
        'data_hash': data_hash
    })
Ejemplo n.º 3
0
def donate():
    """
        Process donation
    """
    title = "Donate"
    form = donation_form(request.form)

    # Autofill email
    if session.get('user') and not form.email.data:
        form.email.data = session.get('user')['user_email']

    if form.validate_on_submit():
        # order_number is generated as a unique string
        order_obj = {"is_donation": True, "date": chicago_date()}
        order_obj['items'] = u"{}:{}".format("CeNDR strain and data support",
                                             form.data.get('total'))
        order_obj.update(form.data)
        order_obj['invoice_hash'] = hash_it(order_obj, length=8)
        order_obj[
            'url'] = f"https://elegansvariation.org/order/{order_obj['invoice_hash']}"
        send_email({
            "from":
            "*****@*****.**",
            "to": [order_obj["email"]],
            "cc":
            app.config.get("CC_EMAILS"),
            "subject":
            f"CeNDR Dontaion #{order_obj['invoice_hash']}",
            "text":
            DONATE_SUBMISSION_EMAIL.format(
                invoice_hash=order_obj["invoice_hash"],
                donation_amount=order_obj.get('total'))
        })

        add_to_order_ws(order_obj)
        return redirect(url_for("order.order_confirmation",
                                invoice_hash=order_obj["invoice_hash"]),
                        code=302)

    return render_template('about/donate.html', **locals())