Skip to content

Commit

Permalink
added update_metabolabpy
Browse files Browse the repository at this point in the history
  • Loading branch information
ludwigc committed Oct 2, 2024
1 parent 49f655b commit 4dfd164
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 20 deletions.
2 changes: 1 addition & 1 deletion metabolabpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__author__ = 'Christian Ludwig ([email protected])'
__credits__ = 'Christian Ludwig ([email protected])'
__version__ = '0.9.50'
__version__ = '0.9.53'
__license__ = 'GPLv3'
45 changes: 30 additions & 15 deletions metabolabpy/nmr/nmrData.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,22 +1132,29 @@ def conv(self, fid):
return fid
# end conv

def create_title(self, xls=[], dataset_label='', pos_label='', rack_label='', replace_title=False, c_dict={}, excel_name=''):
if len(xls) == 0 or len(dataset_label) == 0 or len(pos_label) == 0 or len(rack_label) == 0 or len(c_dict) == 0 or len(excel_name) == 0:
def create_title(self, xls=[], dataset_label='', pos_label='', rack_label='', replace_title=False, c_dict={}, excel_name='', autosampler='SampleJet'):
if len(xls) == 0 or len(dataset_label) == 0 or len(pos_label) == 0 or len(c_dict) == 0 or len(excel_name) == 0:
return

get_auto_pos = re.compile(r'[A-Z]\d+')
get_rack_num = re.compile(r'<\d+')
try:
pos = get_auto_pos.findall(self.acq.autopos)[0]
rack = get_rack_num.findall(self.acq.autopos)[0][1:]
except:
rack = str(int(int(self.acq.holder) / 100))
pos = int(self.acq.holder) - int(rack)*100 - 1
pos_char = self.nmr_col[str(pos % 8)]
pos_no = str(int(pos / 8) + 1)
if len(rack_label) == 0 and autosampler == 'SampleJet':
return

pos = pos_char + pos_no
if autosampler == 'SampleJet':
get_auto_pos = re.compile(r'[A-Z]\d+')
get_rack_num = re.compile(r'<\d+')
try:
pos = get_auto_pos.findall(self.acq.autopos)[0]
rack = get_rack_num.findall(self.acq.autopos)[0][1:]
except:
rack = str(int(int(self.acq.holder) / 100))
pos = int(self.acq.holder) - int(rack)*100 - 1
pos_char = self.nmr_col[str(pos % 8)]
pos_no = str(int(pos / 8) + 1)

pos = pos_char + pos_no
else:
pos_no = os.path.split(self.orig_data_set)[1]
pos = pos_no

if not replace_title:
title = self.title
Expand All @@ -1162,10 +1169,18 @@ def create_title(self, xls=[], dataset_label='', pos_label='', rack_label='', re
if len(dsl) == 0:
return

line_no = c_dict[dsl][rack + " " + pos]
if autosampler == 'SampleJet':
line_no = c_dict[dsl][rack + " " + pos]
else:
line_no = c_dict[dsl][str(pos)]

title += f'Excel File : {excel_name}\n'
title += f'Excel Line Number : {line_no + 2}\n'
title += f'acqus AUTOPOS : {rack} {pos}\n'
if autosampler == 'SampleJet':
title += f'acqus AUTOPOS : {rack} {pos}\n'

title += f'autosampler : {autosampler}\n'

for col in xls.columns:
if col == 'number':
title += f'{col} : {int(xls[col][line_no])}\n'
Expand Down
14 changes: 10 additions & 4 deletions metabolabpy/nmr/nmrDataSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,14 @@ def compress_buckets(self):

# end compress_buckets

def create_titles(self, xls=[], dataset_label='', pos_label='', rack_label='', replace_title=False, excel_name=''):
if len(xls) == 0 or len(dataset_label) == 0 or len(pos_label) == 0 or len(rack_label) == 0 or len(
def create_titles(self, xls=[], dataset_label='', pos_label='', rack_label='', replace_title=False, excel_name='', autosampler='SampleJet'):
if len(xls) == 0 or len(dataset_label) == 0 or len(pos_label) == 0 or len(
excel_name) == 0:
return

if len(rack_label) == 0 and autosampler == 'SampleJet':
return

if len(self.nmrdat[self.s]) == 0:
return

Expand All @@ -379,11 +382,14 @@ def create_titles(self, xls=[], dataset_label='', pos_label='', rack_label='', r
if not xls[dataset_label][k] in c_dict.keys():
c_dict[xls[dataset_label][k]] = {}

c_dict[xls[dataset_label][k]][str(xls[rack_label][k]).replace(' ','') + " " + str(xls[pos_label][k]).replace(' ','')] = k
if autosampler == 'SampleJet':
c_dict[xls[dataset_label][k]][str(xls[rack_label][k]).replace(' ','') + " " + str(xls[pos_label][k]).replace(' ','')] = k
else:
c_dict[xls[dataset_label][k]][str(xls[pos_label][k]).replace(' ','')] = k

for k in range(len(self.nmrdat[self.s])):
self.nmrdat[self.s][k].create_title(xls, dataset_label, pos_label, rack_label, replace_title, c_dict,
excel_name)
excel_name, autosampler)

# end create_titles

Expand Down

0 comments on commit 4dfd164

Please sign in to comment.