Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Refactor runfoldermanager.check_fastqs. Various comment updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nana Mensah authored and Nana Mensah committed Oct 24, 2019
1 parent fd55920 commit b1b1f8d
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions wscleaner/wscleaner/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def count_logfiles(self):
# Set uploaded runfolder name. Runfolder is renamed upon upload to the DNANexus project
# without the first four characters
uploaded_runfolder = dxpy.describe(self.id)['name'][4:]
# Set logfiles locatoin. This is expected in 'Logfiles/', a subdirectory of the uploaded runfolder
# Set logfile location in DNANexus project. This is expected in 'Logfiles/', a subdirectory of the uploaded runfolder
logfile_dir = str(Path('/',uploaded_runfolder,'Logfiles'))
logfile_list = dxpy.find_data_objects(project=self.id, folder=logfile_dir, classname='file')
logfile_count = len(list(logfile_list))
Expand All @@ -134,7 +134,7 @@ def __dx_find_one_project(self):
return None

def __bool__(self):
"""Boolean expressions on class instances will return True if a single DNAnexus project was found."""
"""Allows boolean expressions on class instances which return True if a single DNAnexus project was found."""
if self.id:
return True
else:
Expand Down Expand Up @@ -185,7 +185,7 @@ def find_runfolders(self, min_age=14):
runfolder_objects = []
for directory in subdirectories:
rf = RunFolder(directory)
# Criteria for runfolder: Older than or equal to min_age and containsn fastq.gz files
# Criteria for runfolder: Older than or equal to min_age and contains fastq.gz files
if (rf.age >= min_age) and (rf.find_fastqs(count=True) > 0):
self.logger.debug(f'{rf.name} IS RUNFOLDER.')
runfolder_objects.append(rf)
Expand All @@ -197,14 +197,7 @@ def check_fastqs(self, runfolder):
"""Returns true if a runfolder's fastq.gz files match those in it's DNAnexus project."""
dx_fastqs = runfolder.dx_project.find_fastqs()
local_fastqs = runfolder.find_fastqs()
fastqs_equal = sorted(dx_fastqs) == sorted(local_fastqs)
# Fastq files with "Undetermined" in their name may not be uploaded to DNAnexus.
# We accept local runfolders with 2 more fastq files than their dna nexus project.
equal_without_undetermined_fastqs = (
len(local_fastqs) == len(dx_fastqs) + 2 and
all([fastq in local_fastqs for fastq in dx_fastqs])
)
fastq_bool = fastqs_equal or equal_without_undetermined_fastqs
fastq_bool = all([fastq in dx_fastqs for fastq in local_fastqs])
self.logger.debug(f'{runfolder.name} FASTQ BOOL: {fastq_bool}')
return fastq_bool

Expand Down

0 comments on commit b1b1f8d

Please sign in to comment.