Skip to content

Commit

Permalink
Merge pull request #954 from biorack/untargeted_dev
Browse files Browse the repository at this point in the history
Skip result file renaming inside results zip (readability reaname) if the project name doesn't conform
  • Loading branch information
bkieft-usa authored Oct 10, 2024
2 parents 58b37a4 + 4eb467d commit fc4eb08
Showing 1 changed file with 10 additions and 6 deletions.
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

0 comments on commit fc4eb08

Please sign in to comment.