Skip to content

Commit

Permalink
feat: store scan rate and spectrum direction (#196) (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
baolanlequang authored Jun 25, 2024
1 parent 3635673 commit 8144d7f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 12 additions & 0 deletions chem_spectra/lib/composer/ni.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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())

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
##DATA CLASS=XYPOINTS
##ORIGIN=
##OWNER=
##SCAN_RATE=0.09
##FIRSTX=1.49048
##LASTX=1.50049
##MINX=-1.9005
Expand Down
2 changes: 2 additions & 0 deletions tests/test_cyclic_volta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions tests/test_ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8144d7f

Please sign in to comment.