Skip to content

Commit

Permalink
fix and refactor: fix generated jcamp for nmrium and change label for…
Browse files Browse the repository at this point in the history
… CV layout (#171)

fix: fixed generated jcamp file cannot be read by nmrium

refactor: change label name for CV data
  • Loading branch information
baolanlequang authored Feb 29, 2024
1 parent 27cff43 commit 107e6e3
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 25 deletions.
1 change: 1 addition & 0 deletions chem_spectra/lib/composer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def generate_original_metadata(self):
content.append(
'###{}= {}\n'.format(str_key.upper(), str_value)
)
content.append('\n\n')
return content
def gen_ending(self):
return [
Expand Down
1 change: 0 additions & 1 deletion chem_spectra/lib/composer/ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def __compose(self):
meta.extend(self.__gen_ntuples_end())

meta.extend(self.generate_original_metadata())
meta.extend(self.gen_ending())

meta.extend(self.gen_ending())
return meta
Expand Down
27 changes: 13 additions & 14 deletions chem_spectra/lib/composer/ni.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ def __compose(self):
meta.extend(self.gen_ending())

meta.extend(self.generate_original_metadata())
meta.extend(self.gen_ending())

meta.extend(self.gen_ending())
return meta
Expand Down Expand Up @@ -490,26 +489,26 @@ def tf_img(self):

def __prepare_metadata_info_for_csv(self, csv_writer: csv.DictWriter):
csv_writer.writerow({
'Ox E(V)': 'Measurement type',
'Red E(V)': 'Cyclic Voltammetry',
'Anodic E(V)': 'Measurement type',
'Cathodic E(V)': 'Cyclic Voltammetry',
})
csv_writer.writerow({
'Ox E(V)': 'Measurement type ID',
'Anodic E(V)': 'Measurement type ID',
})
csv_writer.writerow({
'Ox E(V)': 'Sample ID',
'Anodic E(V)': 'Sample ID',
})
csv_writer.writerow({
'Ox E(V)': 'Analysis ID',
'Anodic E(V)': 'Analysis ID',
})
csv_writer.writerow({
'Ox E(V)': 'Dataset ID',
'Anodic E(V)': 'Dataset ID',
})
csv_writer.writerow({
'Ox E(V)': 'Dataset name',
'Anodic E(V)': 'Dataset name',
})
csv_writer.writerow({
'Ox E(V)': 'Link to sample',
'Anodic E(V)': 'Link to sample',
})
csv_writer.writerow({
})
Expand All @@ -527,7 +526,7 @@ def tf_csv(self):
listMaxMinPeaks = self.core.params['list_max_min_peaks']

with open(tf_csv.name, 'w', newline='', encoding='utf-8') as csvfile:
fieldnames = ['Ox E(V)', 'Ox I(A)', 'Red E(V)', 'Red I(A)', 'I lambda0(A)', 'I ratio', 'E1/2(V)', 'Delta Ep(mV)']
fieldnames = ['Anodic E(V)', 'Anodic I(A)', 'Cathodic E(V)', 'Cathodic I(A)', 'I lambda0(A)', 'I ratio', 'E1/2(V)', 'Delta Ep(mV)']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

self.__prepare_metadata_info_for_csv(writer)
Expand Down Expand Up @@ -577,10 +576,10 @@ def tf_csv(self):
y_pecker = ''

writer.writerow({
'Ox E(V)': '{x_max}'.format(x_max=x_max_peak),
'Ox I(A)': '{y_max}'.format(y_max=y_max_peak),
'Red E(V)': '{x_min}'.format(x_min=x_min_peak),
'Red I(A)': '{y_min}'.format(y_min=y_min_peak),
'Anodic E(V)': '{x_max}'.format(x_max=x_max_peak),
'Anodic I(A)': '{y_max}'.format(y_max=y_max_peak),
'Cathodic E(V)': '{x_min}'.format(x_min=x_min_peak),
'Cathodic I(A)': '{y_min}'.format(y_min=y_min_peak),
'I lambda0(A)': '{y_pecker}'.format(y_pecker=y_pecker),
'I ratio': '{ratio}'.format(ratio=ratio),
'E1/2(V)': '{e12}'.format(e12=e12),
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/result/edit/edit_meta_13C-DEPT135
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ $$ === CHEMSPECTRA ORIGINAL METADATA ===
###$CSSOLVENTNAME= DMSO-d6
###$CSSOLVENTVALUE= 39.52
###$CSSOLVENTX= 0
##END=


##END=

2 changes: 1 addition & 1 deletion tests/fixtures/result/edit/edit_meta_1H
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ $$ === CHEMSPECTRA ORIGINAL METADATA ===
###$CSSOLVENTNAME= DMSO-d6 (quin)
###$CSSOLVENTVALUE= 2.5
###$CSSOLVENTX= 0
##END=


##END=

2 changes: 1 addition & 1 deletion tests/fixtures/result/edit/edit_meta_IR
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ $$ === CHEMSPECTRA ORIGINAL METADATA ===
###$CSTHRESHOLD= 0.8, 0.8
###MAXX= 3997.453, 3997.453
###MINX= 373.96442, 373.96442
##END=


##END=

2 changes: 1 addition & 1 deletion tests/fixtures/result/im/im_meta_1H
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ $$ === CHEMSPECTRA ORIGINAL METADATA ===
###$CSSOLVENTNAME= DMSO-d6 (quin)
###$CSSOLVENTVALUE= 2.5
###$CSSOLVENTX= 0
##END=


##END=

2 changes: 1 addition & 1 deletion tests/fixtures/result/im/im_meta_IR
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ $$ === CHEMSPECTRA ORIGINAL METADATA ===
###MAXY= 1.0055419
###MINY= 0.27871406
###NPOINTS= 2559
##END=


##END=

2 changes: 1 addition & 1 deletion tests/fixtures/result/meta_13C-CPD
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ $$ === CHEMSPECTRA ORIGINAL METADATA ===
###$CSSOLVENTNAME= DMSO-d6
###$CSSOLVENTVALUE= 39.52
###$CSSOLVENTX= 0
##END=


##END=

2 changes: 1 addition & 1 deletion tests/fixtures/result/meta_1H
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ $$ === CHEMSPECTRA ORIGINAL METADATA ===
###$CSSOLVENTNAME= DMSO-d6 (quin)
###$CSSOLVENTVALUE= 2.5
###$CSSOLVENTX= 0
##END=


##END=

2 changes: 1 addition & 1 deletion tests/fixtures/result/meta_IR
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ $$ === CHEMSPECTRA ORIGINAL METADATA ===
###MAXY= 1.0055419
###MINY= 0.27871406
###NPOINTS= 2559
##END=


##END=

2 changes: 1 addition & 1 deletion tests/fixtures/result/meta_SVS-790A_13C
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ $$ === CHEMSPECTRA ORIGINAL METADATA ===
###$CSSOLVENTNAME= Chloroform-d (t)
###$CSSOLVENTVALUE= 77.16
###$CSSOLVENTX= 0
##END=


##END=

2 changes: 1 addition & 1 deletion tests/fixtures/result/ps/ps_meta_IR
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ $$ === CHEMSPECTRA ORIGINAL METADATA ===
###MAXY= 1.0055419
###MINY= 0.27871406
###NPOINTS= 2559
##END=


##END=

1 change: 1 addition & 0 deletions tests/lib/composer/test_base_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ def test_base_composer_generate_original_metadata(jcamp_file_1h):
'###.AVERAGES= 16\n',
'###.SHIFT REFERENCE= INTERNAL, CDCl3, 1, 15.91938\n',
'###.AVERAGES= 16\n',
'\n\n'
]

0 comments on commit 107e6e3

Please sign in to comment.