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

Skip result file renaming inside results zip (readability reaname) if the project name doesn't conform #954

Merged
merged 2 commits into from
Oct 10, 2024
Merged
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
16 changes: 10 additions & 6 deletions metatlas/untargeted/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,20 @@ def rename_untargeted_files_in_archive(
else:
department = raw_data_subdir.upper()

date = project_name.split('_')[0]
submitter = project_name.split('_')[2]
pid = project_name.split('_')[3]
chromatography = project_name.split('_')[7]
if len(project_name.split('_')) >= 9:
date = project_name.split('_')[0]
submitter = project_name.split('_')[2]
pid = project_name.split('_')[3]
chromatography = project_name.split('_')[7]
else:
logging.warning(tab_print("Warning! Project name %s has fewer than expected fields. Skipping renaming files before zip..."%(project_name), 1))
return

# Check if project name follows the standard naming convention
if not any(substring.lower() in chromatography.lower() for substring in ['C18', 'LIPID', 'HILIC']) or \
not date.isdigit() or len(date) != 8:
logging.warning(tab_print("Warning! Project name %s does not follow the standard naming convention. Skipping renaming..."%(project_name), 1))
logging.warning(tab_print("Date: %s, Department: %s, Submitter: %s, PID: %s, Chromatography: %s"%(date, raw_data_subdir, submitter, pid, chromatography), 2))
logging.warning(tab_print("Warning! Project name %s does not follow the standard naming convention. Skipping renaming files before zip..."%(project_name), 1))
logging.warning(tab_print("Here is what could be extracted: Date: %s, Department: %s, Submitter: %s, PID: %s, Chromatography: %s"%(date, raw_data_subdir, submitter, pid, chromatography), 2))
return
else:
new_project_name = f"{date}_{raw_data_subdir}_{submitter}_{pid}_{chromatography}"
Expand Down
Loading