Skip to content

Commit

Permalink
Merge pull request #27 from RTKlab-BYU/improve-mzML-convertion
Browse files Browse the repository at this point in the history
Improve mz ml convertion and change page size
  • Loading branch information
xiaofengxie128 authored Jul 26, 2023
2 parents 2dc7bdc + 48839fd commit c4fa293
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion web/data_manager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
'DEFAULT_PAGINATION_CLASS': 'rest_framework.'
'pagination.PageNumberPagination',
'DATETIME_FORMAT': "%Y-%m-%d %H:%M:%S",
'PAGE_SIZE': 10,
'PAGE_SIZE': 100,
'DEFAULT_PERMISSION_CLASSES': [
# 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
'rest_framework.permissions.DjangoModelPermissions',
Expand Down
15 changes: 9 additions & 6 deletions web/file_manager/File_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ def __init__(self, instance=None, FileStorage=None, creator_setting=None, system
self.record.project_name, self.enable_batch, self.batch_name,\
self.assigned_user = self.record.project_name.split(',')
try:
self.assigned_user = int(self.assigned_user.split('_')[0])
self.assigned_user = int(self.assigned_user)
except Exception as error: # not a user
pass
else:
if self.record.record_creator.is_staff and self.assigned_user != 0:
self.record.record_creator = User.objects.get(pk=self.assigned_user)
self.record.record_creator = User.objects.get(
pk=self.assigned_user)
to_tz = timezone.get_default_timezone()
self.record.acquisition_time = self.record.uploaded_time
# compromise, otherwise on acquisition time for sort
Expand Down Expand Up @@ -174,7 +175,9 @@ def create_cache(self):
xml.sax.parse(self.mzML, xml_parse)
except Exception as error:
logger.warning(f"Convertion failed {retry+1} time, "
f"will retry until failed 5 times, {error}")
f"will retry until failed 6 times, {error}")
os.remove(self.mzML) if os.path.exists(self.mzML) else None
time.sleep(10)
self.convert()
else:
is_converted = True
Expand All @@ -184,10 +187,10 @@ def create_cache(self):
logger.error(
f"{self.fullname} Convertion "
f"abandoned after {retry} retries.")
return
return False
if not self.creator_setting.exists() or \
not self.creator_setting.first().replace_raw_with_mzML:
os.remove(self.mzML)
os.remove(self.mzML) if os.path.exists(self.mzML) else None

self.record.instrument_model = xml_parse.model
self.record.instrument_sn = xml_parse.SN
Expand Down Expand Up @@ -259,7 +262,7 @@ def move_file(self):
if not check_folder:
os.makedirs(os.path.join(
settings.MEDIA_ROOT, file_dir))

# keep the original raw file or converted mzML file
if self.creator_setting.exists() and \
self.creator_setting.first().replace_raw_with_mzML:
newfile_name = f"{file_dir}/{self.filename + '.mzML'}"
Expand Down

0 comments on commit c4fa293

Please sign in to comment.