Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features of version 1.2.1 #203

Merged
merged 4 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,26 @@ logger.error('message to log')
```
Note: You need to use function as the same as your logger level, which named as lowercased of level's name, to write your log message to the logs file


### 2.3. Automatic startup in crontab

To make sure ChemSpectra is started on reboot you can use this BASH script in your root crontab (if required, adapt Chemotion ELN username and home directory):

```sh
#!/bin/bash

sudo -H -u production bash -c "cd /home/production/chem-spectra-app && \
source /home/production/anaconda3/bin/activate chem-spectra && \
gunicorn -w 4 -b 0.0.0.0:3007 server:app --daemon"

# Remember to modify path according to your installation
docker run --detach --name msconvert_docker \
--rm -it \
-e WINEDEBUG=-all \
-v /home/production/chem-spectra-app/chem_spectra/tmp:/data chambm/pwiz-skyline-i-agree-to-the-vendor-licenses \
bash
```

## 3. Run test

```
Expand Down
2 changes: 2 additions & 0 deletions chem_spectra/controller/helper/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def extract_params(request):
list_file_names = request.form.getlist('list_file_names[]')
data_type_mapping = request.form.get('data_type_mapping', default='')
detector = request.form.get('detector', default=None)
dsc_meta_data = request.form.get('dsc_meta_data', default=None)

params = {
'peaks_str': request.form.get('peaks_str', default=None),
Expand All @@ -131,6 +132,7 @@ def extract_params(request):
'axesUnits': axesUnits,
'data_type_mapping': data_type_mapping,
'detector': detector,
'dsc_meta_data': dsc_meta_data,
}
has_params = (
params.get('peaks_str') or
Expand Down
295 changes: 219 additions & 76 deletions chem_spectra/lib/composer/ni.py

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions chem_spectra/lib/converter/jcamp/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, path, params=False):
self.is_emissions = self.__is_emissions()
self.is_dls_acf = self.__is_dls_acf()
self.is_dls_intensity = self.__is_dls_intensity()
self.is_dsc = self.__is_dsc()
self.non_nmr = self.__non_nmr()
self.ncl = self.__ncl()
self.simu_peaks = self.__read_simu_peaks()
Expand Down Expand Up @@ -156,6 +157,9 @@ def __is_dls_acf(self):

def __is_dls_intensity(self):
return self.typ in ['DLS intensity']

def __is_dsc(self):
return self.typ in ['DIFFERENTIAL SCANNING CALORIMETRY']

def __ncl(self):
try:
Expand Down
3 changes: 2 additions & 1 deletion chem_spectra/lib/converter/jcamp/data_type.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"SORPTION-DESORPTION MEASUREMENT": ["SORPTION-DESORPTION MEASUREMENT"],
"Emissions": ["Emissions", "EMISSIONS", "FLUORESCENCE SPECTRUM", "FL SPECTRUM"],
"DLS ACF": ["DLS ACF"],
"DLS intensity": ["DLS INTENSITY", "DLS intensity"]
"DLS intensity": ["DLS INTENSITY", "DLS intensity"],
"DIFFERENTIAL SCANNING CALORIMETRY": ["DIFFERENTIAL SCANNING CALORIMETRY"]
}
}
3 changes: 2 additions & 1 deletion chem_spectra/lib/converter/jcamp/data_type.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"SORPTION-DESORPTION MEASUREMENT": ["SORPTION-DESORPTION MEASUREMENT"],
"Emissions": ["Emissions", "EMISSIONS", "FLUORESCENCE SPECTRUM", "FL SPECTRUM"],
"DLS ACF": ["DLS ACF"],
"DLS intensity": ["DLS INTENSITY", "DLS intensity"]
"DLS intensity": ["DLS INTENSITY", "DLS intensity"],
"DIFFERENTIAL SCANNING CALORIMETRY": ["DIFFERENTIAL SCANNING CALORIMETRY"]
}
}
4 changes: 3 additions & 1 deletion chem_spectra/lib/converter/jcamp/ni.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, base):
self.is_emissions = base.is_emissions if hasattr(base, 'is_emissions') else False
self.is_dls_acf = base.is_dls_acf if hasattr(base, 'is_dls_acf') else False
self.is_dls_intensity = base.is_dls_intensity if hasattr(base, 'is_dls_intensity') else False
self.is_dsc = base.is_dsc if hasattr(base, 'is_dsc') else False
self.non_nmr = base.non_nmr
self.ncl = base.ncl
self.is_dept = base.is_dept
Expand Down Expand Up @@ -98,7 +99,8 @@ def __thres(self):
"CYCLIC VOLTAMMETRY": THRESHOLD_XRD,
"SORPTION-DESORPTION MEASUREMENT": THRESHOLD_XRD,
"DLS intensity": THRESHOLD_XRD,
"Emissions": THRESHOLD_EMISSION
"Emissions": THRESHOLD_EMISSION,
"DIFFERENTIAL SCANNING CALORIMETRY": THRESHOLD_TGA,
}

if self.params.get('user_data_type_mapping'):
Expand Down
2 changes: 2 additions & 0 deletions chem_spectra/lib/converter/nmrium/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def __init__(self, file=None):

self.simu_peaks = []
self.is_cyclic_volta = False
self.is_sec = False
self.is_dsc = False
self.typ = ''
self.threshold = 1.0

Expand Down
4 changes: 4 additions & 0 deletions chem_spectra/lib/converter/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def parse_params(params):
'jcamp_idx': 0,
'axesUnits': None,
'detector': None,
'dsc_meta_data': None,
}

select_x = params.get('select_x', None)
Expand Down Expand Up @@ -68,6 +69,8 @@ def parse_params(params):
user_data_type_mapping = params.get('data_type_mapping')
detector = params.get('detector')
detector = json.loads(detector) if detector else None
dsc_meta_data = params.get('dsc_meta_data')
dsc_meta_data = json.loads(dsc_meta_data) if dsc_meta_data else None
if (cyclicvolta is not None):
spectraList = cyclicvolta['spectraList']
if (len(spectraList) > 0):
Expand Down Expand Up @@ -101,6 +104,7 @@ def parse_params(params):
'axesUnits': axesUnits,
'user_data_type_mapping': user_data_type_mapping,
'detector': detector,
'dsc_meta_data': dsc_meta_data,
}


Expand Down
45 changes: 23 additions & 22 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@ channels:
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2024.3.11=h06a4308_0
- ca-certificates=2023.08.22=h06a4308_0
- ld_impl_linux-64=2.38=h1181459_1
- libffi=3.4.4=h6a678d5_1
- libffi=3.4.4=h6a678d5_0
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.13=h7f8727e_1
- pip=24.0=py38h06a4308_0
- python=3.8.19=h955ad1f_0
- openssl=3.0.11=h7f8727e_2
- pip=23.3=py38h06a4308_0
- python=3.8.18=h955ad1f_0
- readline=8.2=h5eee18b_0
- setuptools=69.5.1=py38h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.43.0=py38h06a4308_0
- xz=5.4.6=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- setuptools=68.0.0=py38h06a4308_0
- sqlite=3.41.2=h5eee18b_0
- tk=8.6.12=h1ccaba5_0
- wheel=0.41.2=py38h06a4308_0
- xz=5.4.2=h5eee18b_0
- zlib=1.2.13=h5eee18b_0
- pip:
- adjusttext==1.1.1
- astroid==2.15.8
- atomicwrites==1.4.1
- attrs==23.2.0
Expand All @@ -32,15 +33,14 @@ dependencies:
- click==8.1.7
- contourpy==1.1.1
- coverage==7.5.1
- coverage-badge==1.1.1
- cycler==0.12.1
- dill==0.3.8
- dill==0.3.7
- entrypoints==0.3
- exceptiongroup==1.2.1
- exceptiongroup==1.1.3
- flake8==3.7.9
- flask==2.2.5
- flask-jwt-extended==4.5.2
- fonttools==4.51.0
- fonttools==4.43.1
- gunicorn==22.0.0
- idna==3.7
- importlib-metadata==3.6.0
Expand All @@ -58,12 +58,13 @@ dependencies:
- netcdf4==1.5.3
- numpy==1.22.4
- olefile==0.46
- packaging==24.0
- packaging==23.2
- pandas==2.0.3
- pathlib2==2.3.4
- pillow==10.3.0
- platformdirs==4.2.1
- platformdirs==4.1.0
- pluggy==0.12.0
- py==1.11.0
- pycodestyle==2.5.0
- pyflakes==2.1.1
- pyjwt==2.8.0
Expand All @@ -76,14 +77,14 @@ dependencies:
- pytz==2023.3
- rdkit==2023.9.1
- regex==2019.4.9
- requests==2.31.0
- requests==2.32.2
- scipy==1.7.3
- six==1.11.0
- tomli==2.0.1
- tomlkit==0.12.4
- typing-extensions==4.11.0
- tzdata==2024.1
- urllib3==1.26.18
- tomlkit==0.12.3
- typing-extensions==4.9.0
- tzdata==2023.3
- urllib3==1.26.19
- werkzeug==3.0.3
- wrapt==1.16.0
- zipp==0.5.2
Expand Down
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ MarkupSafe==2.1.2
matplotlib==3.7.3
mccabe==0.6.1
more-itertools==7.2.0
# -e git+https://github.com/ComPlat/nmrglue.git@c5a7d4d0073fedff68808b4e9c95836a8c20413e#egg=nmrglue
-e git+https://github.com/ComPlat/nmrglue.git@e6e8a63b1848ae0525f07de0a6ec0cfdb900ba60#egg=nmrglue
netCDF4==1.5.3
numpy==1.22.4
Expand All @@ -35,10 +34,10 @@ pytest==7.2.0
python-dateutil==2.8.2
pytz==2023.3
regex==2019.4.9
requests==2.31.0
requests==2.32.2
scipy==1.7.3
six==1.11.0
urllib3==1.26.18
urllib3==1.26.19
Werkzeug==3.0.3
zipp==0.5.2
pyopenms==2.6.0
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.0',
version='1.2.1',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
Expand Down
Binary file added tests/fixtures/source/bagit/dsc/dsc.zip
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/lib/converter/bagit/test_bagit_base_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
emissions_layout_path = target_dir + 'emissions/emissions.zip'
dls_acf_layout_path = target_dir + 'dls_acf/dls_acf.zip'
dls_intensity_layout_path = target_dir + 'dls_intensity/dls_intensity.zip'
dsc_layout_path = target_dir + 'dsc/dsc.zip'

def assertFileType(file, mimeStr):
assert mimetypes.guess_type(file.name)[0] == mimeStr
Expand Down Expand Up @@ -144,3 +145,12 @@ def test_bagit_has_one_file_no_combined_image():

converter = BagItConveter(td)
assert converter.combined_image is None

def test_bagit_convert_to_jcamp_dsc_layout():
with tempfile.TemporaryDirectory() as td:
with zipfile.ZipFile(dsc_layout_path, 'r') as z:
z.extractall(td)

converter = BagItConveter(td)
jcamp = converter.data[0]
assertJcampContent(jcamp, '##DATA TYPE=DIFFERENTIAL SCANNING CALORIMETRY')
6 changes: 6 additions & 0 deletions tests/lib/converter/jcamp/test_jcamp_ni_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ def test_init_jcamp_ni_success(jcamp_file_1h):

assert ni_converter is not None
assert ni_converter.base == base_converter

def test_init_jcamp_ni_nmr_label(jcamp_file_1h):
base_converter = JcampBaseConverter(jcamp_file_1h)
ni_converter = JcampNIConverter(base=base_converter)

assert ni_converter.label == {'x': 'PPM', 'y': 'ARBITRARY'}

6 changes: 6 additions & 0 deletions tests/lib/converter/test_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def expected_default_params():
'jcamp_idx': 0,
'axesUnits': None,
'detector': None,
'dsc_meta_data': None,
}

def test_parse_params_without_params(expected_default_params):
Expand Down Expand Up @@ -222,6 +223,11 @@ def test_parse_params_detector():
def test_parse_solvent():
#TODO: need to be updated
assert 1==1

def test_parse_dsc_meta_data():
params = {'dsc_meta_data': '{"meltingPoint": "1.0", "tg": "1.0"}'}
parsed_data = parse_params(params)
assert parsed_data['dsc_meta_data'] == {"meltingPoint": "1.0", "tg": "1.0"}

def test_reduce_pts_when_does_not_have_any_x():
array_data = []
Expand Down
Loading