Skip to content

Commit

Permalink
add mass chromatogram layout
Browse files Browse the repository at this point in the history
  • Loading branch information
f-idiris committed Oct 18, 2023
1 parent 2667282 commit c505ffc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
10 changes: 9 additions & 1 deletion chem_spectra/lib/converter/jcamp/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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_mass_chromatogram= self.__is_mass_chromatogram()
self.non_nmr = self.__non_nmr()
self.ncl = self.__ncl()
self.simu_peaks = self.__read_simu_peaks()
Expand Down Expand Up @@ -81,6 +82,8 @@ def __set_datatype(self):
return 'DLS ACF'
elif 'DLS INTENSITY' in dts or 'DLS intensity' in dts:
return 'DLS intensity'
elif 'MASS CHROMATOGRAM' in dts:
return 'MASS CHROMATOGRAM'
return ''

def __typ(self):
Expand Down Expand Up @@ -119,6 +122,8 @@ def __typ(self):
return 'DLS ACF'
elif 'DLS INTENSITY' in dt or 'DLS intensity' in dt:
return 'DLS intensity'
elif 'MASS CHROMATOGRAM' in dt:
return 'MASS CHROMATOGRAM'
return ''

def __set_dataclass(self):
Expand All @@ -145,7 +150,7 @@ def __non_nmr(self):
'THERMOGRAVIMETRIC ANALYSIS', 'MS', 'X-RAY DIFFRACTION',
'CYCLIC VOLTAMMETRY', 'SIZE EXCLUSION CHROMATOGRAPHY',
'CIRCULAR DICHROISM SPECTROSCOPY', 'SORPTION-DESORPTION MEASUREMENT', 'Emissions',
'DLS ACF', 'DLS intensity']
'DLS ACF', 'DLS intensity', 'MASS CHROMATOGRAM']

def __is_ir(self):
return self.typ in ['INFRARED']
Expand Down Expand Up @@ -182,6 +187,9 @@ def __is_dls_acf(self):

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

def __is_mass_chromatogram(self):
return self.typ in ['MASS CHROMATOGRAM']

def __ncl(self):
try:
Expand Down
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 @@ -42,6 +42,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_mass_chromatogram = base.is_mass_chromatogram if hasattr(base, 'is_mass_chromatogram') else False
self.non_nmr = base.non_nmr
self.ncl = base.ncl
self.is_dept = base.is_dept
Expand Down Expand Up @@ -108,7 +109,8 @@ def __index_target(self):
'THERMOGRAVIMETRIC ANALYSIS', 'X-RAY DIFFRACTION',
'CYCLIC VOLTAMMETRY', 'SIZE EXCLUSION CHROMATOGRAPHY',
'CIRCULAR DICHROISM SPECTROSCOPY', 'SORPTION-DESORPTION MEASUREMENT',
'Emissions', 'EMISSIONS', 'FLUORESCENCE SPECTRUM', 'FL SPECTRUM', 'DLS ACF', 'DLS INTENSITY', 'DLS intensity'
'Emissions', 'EMISSIONS', 'FLUORESCENCE SPECTRUM', 'FL SPECTRUM', 'DLS ACF', 'DLS INTENSITY',
'DLS intensity', 'MASS CHROMATOGRAM'
]
for tp in target_topics:
if tp in self.datatypes:
Expand Down
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 @@ -9,6 +9,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'
mass_chromatogram_layout_path = target_dir + 'mass_chromatogram/mass_chromatogram.zip'

def assertFileType(file, mimeStr):
assert mimetypes.guess_type(file.name)[0] == mimeStr
Expand Down Expand Up @@ -79,6 +80,15 @@ def test_bagit_convert_to_jcamp_dls_intensity_layout():
jcamp = converter.data[0]
assertJcampContent(jcamp, '##DATA TYPE=DLS intensity')

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

converter = BagItConveter(td)
jcamp = converter.data[0]
assertJcampContent(jcamp, '##DATA TYPE=MASS CHROMATOGRAM')

def test_bagit_convert_to_images():
with tempfile.TemporaryDirectory() as td:
with zipfile.ZipFile(cv_layout_path, 'r') as z:
Expand Down

0 comments on commit c505ffc

Please sign in to comment.