From 2b9759619ec6d4c585eb3f4a48804d5bf9f2e2db Mon Sep 17 00:00:00 2001 From: Lan Le Date: Tue, 28 May 2024 10:29:13 +0200 Subject: [PATCH] feat: store scan rate and spectrum direction --- README.md | 1 + chem_spectra/lib/composer/ni.py | 12 ++++++++++++ setup.py | 2 +- .../cyclicvoltammetry/RCV_LSH-R444_full+Fc.jdx | 1 + tests/test_cyclic_volta.py | 2 ++ tests/test_ms.py | 2 -- 6 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3b38b631..f5ad640f 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ This backend web service provides NMR/IR/MS processing for jcamp/RAW/mzML files. +![GitHub release (release name instead of tag name)](https://img.shields.io/github/v/release/ComPlat/chem-spectra-app?include_prereleases&label=version) ![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg) ![Testing](https://github.com/ComPlat/chem-spectra-app/actions/workflows/unit_test.yml/badge.svg) diff --git a/chem_spectra/lib/composer/ni.py b/chem_spectra/lib/composer/ni.py index 96cd1089..f1dc335e 100644 --- a/chem_spectra/lib/composer/ni.py +++ b/chem_spectra/lib/composer/ni.py @@ -166,6 +166,17 @@ def __get_xy_of_peak(self, peak): y = peak['y'] or '' return x, y + def __gen_cyclic_voltammetry_medadata(self): + scan_rate = self.core.dic.get('SCANRATE', [0.1])[0] + x_values = self.core.xs + spectrum_direction = '' + if len(x_values) > 2: + spectrum_direction = 'NEGATIVE' if x_values[0] > x_values[1] else 'POSITIVE' + return [ + f"##$CSSCANRATE={scan_rate}\n", + f"##$CSSPECTRUMDIRECTION={spectrum_direction}\n" + ] + def __gen_cyclic_voltammetry_data_peaks(self): content = ['##$CSCYCLICVOLTAMMETRYDATA=\n'] if self.core.is_cyclic_volta: @@ -245,6 +256,7 @@ def __compose(self): meta.extend(self.gen_simulation_info()) if self.core.is_cyclic_volta: meta.extend(self.__gen_header_cyclic_voltammetry()) + meta.extend(self.__gen_cyclic_voltammetry_medadata()) meta.extend(self.__gen_cyclic_voltammetry_data_peaks()) meta.extend(self.gen_ending()) diff --git a/setup.py b/setup.py index c18fe239..962b6c22 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='chem-spectra-app', - version='1.2.1', + version='1.2.2', packages=find_packages(), include_package_data=True, zip_safe=False, diff --git a/tests/fixtures/source/cyclicvoltammetry/RCV_LSH-R444_full+Fc.jdx b/tests/fixtures/source/cyclicvoltammetry/RCV_LSH-R444_full+Fc.jdx index ea3f8943..703eed7b 100644 --- a/tests/fixtures/source/cyclicvoltammetry/RCV_LSH-R444_full+Fc.jdx +++ b/tests/fixtures/source/cyclicvoltammetry/RCV_LSH-R444_full+Fc.jdx @@ -4,6 +4,7 @@ ##DATA CLASS=XYPOINTS ##ORIGIN= ##OWNER= +##SCAN_RATE=0.09 ##FIRSTX=1.49048 ##LASTX=1.50049 ##MINX=-1.9005 diff --git a/tests/test_cyclic_volta.py b/tests/test_cyclic_volta.py index 4cb60356..8539dac1 100644 --- a/tests/test_cyclic_volta.py +++ b/tests/test_cyclic_volta.py @@ -28,4 +28,6 @@ def test_cv_compose(): nicv = JcampNIConverter(jbcv) nicmpsr = NIComposer(nicv) assert "$$ === CHEMSPECTRA CYCLIC VOLTAMMETRY ===\n" in nicmpsr.meta + assert "##$CSSCANRATE=0.09\n" in nicmpsr.meta + assert "##$CSSPECTRUMDIRECTION=NEGATIVE\n" in nicmpsr.meta assert "##$CSCYCLICVOLTAMMETRYDATA=\n" in nicmpsr.meta diff --git a/tests/test_ms.py b/tests/test_ms.py index 6e1c4ab7..bfb210d2 100644 --- a/tests/test_ms.py +++ b/tests/test_ms.py @@ -21,8 +21,6 @@ def test_ms_mzml_converter_composer(): lines = mscp.tf_jcamp().read()[:800] \ .decode('utf-8', errors='ignore').split('\n') - - print(lines) assert '##$CSSCANAUTOTARGET=24' in lines assert '##$CSSCANEDITTARGET=24' in lines