Skip to content

Commit

Permalink
feat WIP: read lcms and transform to jcamp
Browse files Browse the repository at this point in the history
  • Loading branch information
Lan Le committed Sep 4, 2024
1 parent b54c068 commit 9b66d5e
Show file tree
Hide file tree
Showing 8 changed files with 367 additions and 114 deletions.
47 changes: 47 additions & 0 deletions chem_spectra/controller/transform_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
)

from chem_spectra.model.transformer import TransformerModel as TraModel
from chem_spectra.lib.composer.lcms import LCMSComposer
from chem_spectra.lib.converter.bagit.base import BagItBaseConverter
from chem_spectra.model.molecule import MoleculeModel

Expand Down Expand Up @@ -62,6 +63,52 @@ def zip_jcamp_n_img():
)
)
rsp.headers['X-Extra-Info-JSON'] = json.dumps({'spc_type': 'bagit', 'invalid_molfile': invalid_molfile})
elif isinstance(cmpsr, LCMSComposer):
# check if composered model is hplc ms
# list_jcamps, list_images, list_csv, combined_image = cmpsr.data, cmpsr.images, cmpsr.list_csv, cmpsr.combined_image
# dst_list = []
# for idx in range(len(list_jcamps)):
# tf_jcamp = list_jcamps[idx]
# tf_img = list_images[idx]
# tf_csv = list_csv[idx]
# tf_arr = [tf_jcamp, tf_img, tf_csv]
# dst_list.append(tf_arr)

# if combined_image is not None:
# dst_list.append(combined_image)

# memory = to_zip_bag_it_response(dst_list)
# rsp = make_response(
# send_file(
# memory,
# download_name='spectrum.zip',
# as_attachment=True
# )
# )
# rsp.headers['X-Extra-Info-JSON'] = json.dumps({'spc_type': 'bagit', 'invalid_molfile': invalid_molfile})
list_jcamps = cmpsr.data
dst_list = [[list_jcamps[0]], [list_jcamps[1]], [list_jcamps[2]]]
print(dst_list)
# dst_list = []
# for idx in range(len(list_jcamps)):
# tf_jcamp = list_jcamps[idx]
# tf_img = list_images[idx]
# tf_csv = list_csv[idx]
# tf_arr = [tf_jcamp, tf_img, tf_csv]
# dst_list.append(tf_arr)

# if combined_image is not None:
# dst_list.append(combined_image)

memory = to_zip_bag_it_response(dst_list)
rsp = make_response(
send_file(
memory,
download_name='spectrum.zip',
as_attachment=True
)
)
rsp.headers['X-Extra-Info-JSON'] = json.dumps({'spc_type': 'bagit', 'invalid_molfile': False})
elif isinstance(cmpsr, collections.abc.Sequence):
dst_list = []
spc_type = ''
Expand Down
1 change: 1 addition & 0 deletions chem_spectra/lib/composer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def generate_original_metadata(self):
)
content.append('\n\n')
return content

def gen_ending(self):
return [
'##END=\n',
Expand Down
Loading

0 comments on commit 9b66d5e

Please sign in to comment.