def extract_methylation(self): for file_path in os.listdir(self.dir_info.splitted_dir): file_path = os.path.join(self.dir_info.splitted_dir, file_path) extractor = BismarkMethylationExtractor(file_path, self.dir_info.bismark_methylation_extractor_output_dir, ncores=45) command = extractor.bismark_met_extractor_command() # perform logging print("*************************************", file=self.log_file_handler) print("This is how the extractor will be called: ", file=self.log_file_handler) print(command, file=self.log_file_handler) print("", file=self.log_file_handler) print("Logging extractor output to: " + extractor.log_file_path(), file=self.log_file_handler) print("*************************************", file=self.log_file_handler) print("", file=self.log_file_handler) print("", file=self.log_file_handler) # close log, because bismark likes to write to stderr and python doesnt' like it self.log_file_handler.close() # call thea actual command output = run_shell_command(command) # reopen log self.log_file_handler = open(self.dir_info.analysis_log_path, mode='a')
def extract_methylation(self): try: extractor = BismarkMethylationExtractor( self.dir_info.deduplicated_bam_path, self.dir_info.bismark_methylation_extractor_output_dir ) command = extractor.bismark_met_extractor_command() run_shell_command(command) except: raise Exception("Couldn't extract methylation for mate " + self.name + "! Please inspect the log file")