From 6f8b1ec9b1ea67504f1004ca5982ca368223c5ae Mon Sep 17 00:00:00 2001 From: Lan Le Date: Tue, 14 May 2024 15:12:57 +0200 Subject: [PATCH] feat: read mw, mp, d, mn values for sec --- chem_spectra/lib/composer/ni.py | 34 +++++++++++++++++++++++ tests/fixtures/source/sec/SEC-ExFile.zip | Bin 0 -> 59029 bytes tests/lib/composer/test_ni_composer.py | 24 ++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 tests/fixtures/source/sec/SEC-ExFile.zip diff --git a/chem_spectra/lib/composer/ni.py b/chem_spectra/lib/composer/ni.py index 3ed13c7..7b66d27 100644 --- a/chem_spectra/lib/composer/ni.py +++ b/chem_spectra/lib/composer/ni.py @@ -130,6 +130,16 @@ def __gen_header_cyclic_voltammetry(self): '$$ === CHEMSPECTRA CYCLIC VOLTAMMETRY ===\n', ] + def __gen_header_sec(self): + core_dic = self.core.dic + sec_data_key = ['MN', 'MW', 'MP', 'D'] + result = [] + for key in sec_data_key: + dic_value = core_dic.get(key, []) + key_str = f"##{key}={dic_value[0]}\n" if len(dic_value) > 0 else f'##{key}=\n' + result.append(key_str) + return result + def __get_xy_of_peak(self, peak): if peak is None: return '', '' @@ -201,6 +211,8 @@ def __compose(self): meta.extend(self.gen_headers_root()) meta.extend(self.__gen_headers_spectrum_orig()) + if self.core.is_sec: + meta.extend(self.__gen_header_sec()) meta.extend(self.gen_spectrum_orig()) meta.extend(self.__gen_headers_im()) meta.extend(self.__gen_headers_integration()) @@ -479,6 +491,9 @@ def tf_img(self): plt.ylabel("Y ({})".format(self.core.label['y']), fontsize=18) plt.locator_params(nbins=self.__plt_nbins()) plt.grid(False) + + self.__generate_info_box(plt) + # Save tf_img = tempfile.NamedTemporaryFile(suffix='.png') plt.savefig(tf_img, format='png') @@ -487,6 +502,25 @@ def tf_img(self): plt.cla() return tf_img + + def __generate_info_box(self, plotlib): + if not self.core.is_sec: + return + core_dic = self.core.dic + sec_data_key = ['MN', 'MW', 'MP', 'D'] + result = [] + for key in sec_data_key: + dic_value = core_dic.get(key, []) + key_str = f"{key}={dic_value[0]}" if len(dic_value) > 0 else None + if key_str is not None: + result.append(key_str) + + info_str = '\n'.join(result) + props = dict(boxstyle='round', facecolor='wheat', alpha=0.5) + ax = plotlib.gca() + ax.text(0.05, 0.95, info_str, fontsize=14, verticalalignment='top', bbox=props, transform=ax.transAxes) + + def __prepare_metadata_info_for_csv(self, csv_writer: csv.DictWriter): csv_writer.writerow({ 'Anodic E(V)': 'Measurement type', diff --git a/tests/fixtures/source/sec/SEC-ExFile.zip b/tests/fixtures/source/sec/SEC-ExFile.zip new file mode 100644 index 0000000000000000000000000000000000000000..cabf0d471164dc0f160056db62a28f78c7540f7a GIT binary patch literal 59029 zcmeI5O>dl6mft<;$pG;t7|Z}!WK*#lft_x$tDcv7o)SO|*b;4XtQSJ0ZD~dmp-2|p z>Xt}FqTJm{2FPY+*|W(e-ymOLHUWYF$tTD%%V3bNknQC6KQEW{upYZD+e#Zjx*?c6 zymjt9=bn4s@2!K6fAIT%{FeUr?BI(BCx7$T=fC;QTW{ |AjFUM_!fxjcTldOV$N z|NQh<@4kDqe{_3q=kWRJqa2>%mUDJ)KT|_`}J`&sNVaE}vYS zZ=GD6f3bRTxq7j+eExj$-fVleJ$;{#+}b_bog6(p0MGuP?M?O`+`RqC;r_k5lbavi zzjtT%=-!9-cMm>#m?LlA-aS0rdGPSy-u~UAL!kHW?|-;|cSk>cc6aZ-et7W7-TkA( zojd!tZ|~pUKia#maSt81d;h2VNB4K{Kb+X_{NeWQPxo%`eEMYhbTa9x8@nBQ-i=2G%gYx}PJZ#IdAxuA^T(6?&}8_b?V|@reDKcQoylyw z>bt!k)%x`_{o2f1|MixBo7IcGA5Hbg1N~Yz`NzGZy_>V0{n?Gl{ry{$*^l|pqU%go6fZ7He-Ml$(r_-PC-)_pDFfc$jCP%Ah z&sQ&&m;Rxf_ioR24h|0|hqpeR)c^Hwp9$m1#nV^M&OymvtKnZ~p!;us<$tQb^-uy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lib/composer/test_ni_composer.py index 8f6eeea..e55fb4d 100644 --- a/tests/lib/composer/test_ni_composer.py +++ b/tests/lib/composer/test_ni_composer.py @@ -1,15 +1,19 @@ import json import pytest import numpy as np +import tempfile +import zipfile from chem_spectra.lib.converter.jcamp.base import JcampBaseConverter from chem_spectra.lib.converter.jcamp.ni import JcampNIConverter from chem_spectra.lib.composer.ni import NIComposer from chem_spectra.controller.helper.file_container import FileContainer +from chem_spectra.lib.converter.bagit.base import BagItBaseConverter as BagItConveter source_nmr = './tests/fixtures/source/1H.dx' source_nmr_edit = './tests/fixtures/source/1H.edit.jdx' source_ir = './tests/fixtures/source/IR.dx' source_dir_molfile = './tests/fixtures/source/molfile/c60h57fn4.mol' +source_sec = './tests/fixtures/source/sec/SEC-ExFile.zip' @pytest.fixture def data_schema(): @@ -37,6 +41,10 @@ def molfile_data(): molfile_str = molfile.read() return molfile_str +@pytest.fixture +def bagit_file_sec(): + return source_sec + def test_init_ni_composer_failed(): with pytest.raises(Exception) as error: _ = NIComposer(None) @@ -250,3 +258,19 @@ def test_ni_composer_generate_nmrium_with_molfile(jcamp_file_1h, molfile_data): assert 'id' in molecule_data.keys() assert molecule_data['label'] == 'P1' assert molecule_data['molfile'] == molfile_data + +def test_ni_composer_generate_jcamp(bagit_file_sec): + with tempfile.TemporaryDirectory() as td: + with zipfile.ZipFile(bagit_file_sec, 'r') as z: + z.extractall(td) + + converter = BagItConveter(td) + for jcamp_file in converter.data: + base_converter = JcampBaseConverter(jcamp_file.name) + ni_converter = JcampNIConverter(base=base_converter) + ni_composer = NIComposer(core=ni_converter) + headers = ni_composer._NIComposer__gen_header_sec() + assert headers in [ + ['##MN=1.287E+3\n', '##MW=1.465E+3\n', '##MP=1.345E+3\n', '##D=1.139E+0\n'], + ['##MN=\n', '##MW=\n', '##MP=\n', '##D=\n'] + ]