Skip to content

Commit

Permalink
feat: store scan rate and spectrum direction
Browse files Browse the repository at this point in the history
  • Loading branch information
Lan Le committed Jun 18, 2024
1 parent 1f2f42c commit ba07be2
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 4 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 @@ -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:
Expand Down Expand Up @@ -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())

Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 ba07be2

Please sign in to comment.