コード例 #1
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
コード例 #2
0
def chemspectra_molfile_convert():
    molfile = FileContainer(request.files.get('molfile'))
    mm = MoleculeModel(molfile)
    return jsonify(
        status=True,
        smi=mm.smi,
        mass=mm.mass,
        svg=mm.svg,
    )
コード例 #3
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)
コード例 #4
0
def chemspectra_predict_by_peaks_json():
    payload = request.json
    layout = payload.get('layout')
    peaks = payload.get('peaks')
    shift = payload.get('shift')
    molfile = FileContainer().from_str(payload.get('molfile'))
    mm = MoleculeModel(molfile, layout, decorate=True)

    outcome = InferModel.predict_nmr(
        mm=mm,
        layout=layout,
        peaks=peaks,
        shift=shift
    )
    if outcome:
        return jsonify(outcome)
    abort(400)
コード例 #5
0
def test_ms_mzml_converter_composer():
    params = {'mass': 230.079907196}

    with open(target_dir + source_dir + '/ms/svs813f1.mzML', 'rb') as f:
        file = FileStorage(f)
        file = FileContainer(file)
        mscv = MSConverter(file, params)
        mscp = MSComposer(mscv)

    lines = mscp.tf_jcamp().read()[:800] \
                .decode('utf-8', errors='ignore').split('\n')

    assert '##$CSSCANAUTOTARGET=3' in lines
    assert '##$CSSCANEDITTARGET=3' in lines
    assert '##$CSSCANCOUNT=24' in lines
    assert '##$CSTHRESHOLD=0.05' in lines
    assert '51.012176513671875, 34359.0' in lines