コード例 #1
0
def jcamp():
    file = FileContainer(request.files['file'])
    molfile = FileContainer(request.files.get('molfile'))
    params = extract_params(request)
    if file:  # and allowed_file(file):
        tf_jcamp = TraModel(file, molfile=molfile, params=params).convert2jcamp()
        return send_file(
            tf_jcamp,
            attachment_filename='spectrum.jdx',
            as_attachment=True
        )
コード例 #2
0
def image():
    file = FileContainer(request.files['file'])
    molfile = FileContainer(request.files.get('molfile'))
    params = extract_params(request)
    if file:  # and allowed_file(file):
        tf_img = TraModel(file, molfile=molfile, params=params).convert2img()
        return send_file(
            tf_img,
            attachment_filename='spectrum.png',
            as_attachment=True,
            mimetype='image/png'
        )
コード例 #3
0
def zip_image():
    file = FileContainer(request.files['file'])
    molfile = FileContainer(request.files.get('molfile'))
    params = extract_params(request)
    if file:  # and allowed_file(file):
        tf_img = TraModel(file, molfile=molfile, params=params).convert2img()
        memory = to_zip_response([tf_img])
        return send_file(
            memory,
            attachment_filename='spectrum.zip',
            as_attachment=True
        )
コード例 #4
0
def chemspectra_file_convert():
    file = FileContainer(request.files['file'])
    molfile = FileContainer(request.files.get('molfile'))
    params = extract_params(request)
    if file:
        tf_jcamp, tf_img = TraModel(file, molfile=molfile,
                                    params=params).convert2jcamp_img()
        if not tf_jcamp:
            abort(400)
        jcamp = base64.b64encode(tf_jcamp.read()).decode("utf-8")
        img = base64.b64encode(tf_img.read()).decode("utf-8")
        return jsonify(status=True, jcamp=jcamp, img=img)
コード例 #5
0
def chemspectra_file_refresh():
    # src = FileContainer(request.files['src'])
    dst = FileContainer(request.files['dst'])
    molfile = FileContainer(request.files.get('molfile'))
    # filename = request.form.get('filename', default=None)
    params = extract_params(request)
    if dst:  # and allowed_file(file):
        tm = TraModel(dst, molfile=molfile, params=params)
        tf_jcamp, tf_img = tm.convert2jcamp_img()
        if not tf_jcamp:
            abort(400)
        jcamp = base64.b64encode(tf_jcamp.read()).decode("utf-8")
        img = base64.b64encode(tf_img.read()).decode("utf-8")
        return jsonify(status=True, jcamp=jcamp, img=img)
コード例 #6
0
def zip_jcamp_n_img():
    file = FileContainer(request.files['file'])
    molfile = FileContainer(request.files.get('molfile'))
    params = extract_params(request)
    if file:  # and allowed_file(file):
        cmpsr = TraModel(file, molfile=molfile, params=params).to_composer()
        tf_jcamp, tf_img = cmpsr.tf_jcamp(), cmpsr.tf_img()
        spc_type = cmpsr.core.ncl if cmpsr.core.typ == 'NMR' else cmpsr.core.typ
        memory = to_zip_response([tf_jcamp, tf_img])
        rsp = make_response(
            send_file(
                memory,
                attachment_filename='spectrum.zip',
                as_attachment=True
            )
        )
        rsp.headers['X-Extra-Info-JSON'] = json.dumps({'spc_type': spc_type})
        return rsp
コード例 #7
0
def chemspectra_file_save():
    src = FileContainer(request.files['src'])
    dst = FileContainer(request.files['dst'])
    molfile = FileContainer(request.files.get('molfile'))
    filename = request.form.get('filename', default=None)
    params = extract_params(request)
    if dst:  # and allowed_file(file):
        tm = TraModel(dst, molfile=molfile, params=params)
        tf_jcamp, tf_img = tm.convert2jcamp_img()
        tf_arr = [
            src.temp_file(),
            tf_jcamp,
            tf_img,
            tm.tf_predict(),
        ]
        memory = to_zip_response(tf_arr, filename, src_idx=0)
        return send_file(memory,
                         attachment_filename='spectrum.zip',
                         as_attachment=True)