def clusterWell(self): # Check if the dereplicated file is empty if self.dereplicated_file == '' or gzipIsEmpty(self.dereplicated_file): self.clustered_file = '' else: # Define the clustered path clustered_path = os.path.join(self.out_path, self.clustered_dir) # Create the directory, if needed if not os.path.exists(clustered_path): os.makedirs(clustered_path) # Define the clustered file self.clustered_file = os.path.join(clustered_path, '%s_clustered.fasta' % self.ID) # Cluster the file clusterFasta(self.on_plate, self.ID, self.dereplicated_file, self.clustered_file) # Gzip the file, return the updated filename self.clustered_file = gzipCompress(self.clustered_file, return_filename=True)
def truncateWell(self): # Check if the merged file is empty if self.merged_file == '' or gzipIsEmpty(self.merged_file): self.truncated_file = '' else: # Define the truncated path truncated_path = os.path.join(self.out_path, self.truncated_dir) # Create the directory, if needed if not os.path.exists(truncated_path): os.makedirs(truncated_path) # Define the truncated file self.truncated_file = os.path.join(truncated_path, '%s_stripped.fastq' % self.ID) # Truncate the merged file truncateFastq(self.merged_file, self.truncated_file) # Gzip the file, return the updated filename self.truncated_file = gzipCompress(self.truncated_file, return_filename=True)
def filterWell(self): # Check if the truncated file is empty if self.truncated_file == '' or gzipIsEmpty(self.truncated_file): self.filtered_file = '' else: # Define the filtered path filtered_path = os.path.join(self.out_path, self.filtered_dir) # Create the directory, if needed if not os.path.exists(filtered_path): os.makedirs(filtered_path) # Define the filtered file self.filtered_file = os.path.join(filtered_path, '%s_filtered.fasta' % self.ID) # Filter the truncated file filterFastq(self.truncated_file, self.filtered_file) # Gzip the file, return the updated filename self.filtered_file = gzipCompress(self.filtered_file, return_filename=True)
def mergeWell(self): # Check if the R1 or R2 files are empty if gzipIsEmpty(self.well_R1_file) or gzipIsEmpty(self.well_R2_file): self.merged_file = '' self.unmerged_R1_file = '' self.unmerged_R2_file = '' else: # Add a trailing directory symbol to the output path merged_path = os.path.join(self.out_path, self.merged_dir, '') # Create the directory, if needed if not os.path.exists(merged_path): os.makedirs(merged_path) # Define the merged and unmerged files self.merged_file = '%s%s_merged.fastq' % (merged_path, self.ID) self.unmerged_R1_file = '%s%s_notmerged_R1.fastq' % (merged_path, self.ID) self.unmerged_R2_file = '%s%s_notmerged_R2.fastq' % (merged_path, self.ID) # Merge the well R1 and R2 files mergePairs(self.ID, self.well_R1_file, self.well_R2_file, self.merged_file, self.unmerged_R1_file, self.unmerged_R2_file) # Gzip the files, return the updated filenames self.merged_file = gzipCompress(self.merged_file, return_filename=True) self.unmerged_R1_file = gzipCompress(self.unmerged_R1_file, return_filename=True) self.unmerged_R2_file = gzipCompress(self.unmerged_R2_file, return_filename=True)
def sortWell(self): # Define the sorted path sorted_path = os.path.join(self.out_path, self.clustered_dir) # Define the clustered file sort_file = os.path.join(sorted_path, '%s_sorted_clustered.fasta' % self.ID) # Cluster the file sortFasta(self.on_plate, self.ID, self.clustered_file, sort_file) # Gzip the file, return the updated filename sort_file = gzipCompress(sort_file, return_filename=True) logging.info('%s-%s: Sorted clustered file' % (self.on_plate, self.ID)) # Rename the clustered file self.clustered_file = sort_file