From ba07be2fd9dfd71fe4bde15a38a7ae015cd5c082 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 ++++++++++++ environment.yml | 2 +- requirements.txt | 2 +- .../cyclicvoltammetry/RCV_LSH-R444_full+Fc.jdx | 1 + tests/test_cyclic_volta.py | 2 ++ tests/test_ms.py | 2 -- 7 files changed, 18 insertions(+), 4 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 80269c0a..b448736d 100644 --- a/chem_spectra/lib/composer/ni.py +++ b/chem_spectra/lib/composer/ni.py @@ -148,6 +148,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: @@ -226,6 +237,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/environment.yml b/environment.yml index 5addf1f1..288f61bb 100644 --- a/environment.yml +++ b/environment.yml @@ -76,7 +76,7 @@ dependencies: - pytz==2023.3 - rdkit==2023.9.1 - regex==2019.4.9 - - requests==2.31.0 + - requests==2.32.0 - scipy==1.7.3 - six==1.11.0 - tomli==2.0.1 diff --git a/requirements.txt b/requirements.txt index 73621146..69711403 100644 --- a/requirements.txt +++ b/requirements.txt @@ -35,7 +35,7 @@ pytest==7.2.0 python-dateutil==2.8.2 pytz==2023.3 regex==2019.4.9 -requests==2.31.0 +requests==2.32.0 scipy==1.7.3 six==1.11.0 urllib3==1.26.18 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