Skip to content

Commit

Permalink
fixed multiprocess Pool freeze on subprocess error and added better m…
Browse files Browse the repository at this point in the history
…essages when file list is provided listing missing files
  • Loading branch information
kbessonov1984 committed Jul 29, 2024
1 parent 58b956e commit f8cd859
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ectyper/ectyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ def run_program():
os.makedirs(temp_dir, exist_ok=True)

LOG.info("Gathering genome files list ...")
raw_genome_files = decompress_gunzip_files(genomeFunctions.get_files_as_list(args.input), temp_dir)
input_files_list = genomeFunctions.get_files_as_list(args.input)
raw_genome_files = decompress_gunzip_files(input_files_list, temp_dir)

LOG.info("Identifying genome file types")

LOG.info(f"Identifying genome file types on {len(raw_genome_files)} inputs ...")
raw_files_dict = genomeFunctions.identify_raw_files(raw_genome_files,
args)

Expand Down
10 changes: 9 additions & 1 deletion ectyper/genomeFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ def get_files_as_list(file_or_directory):
for root, dirs, files in os.walk(file_or_directory):
for filename in files:
files_list.append(os.path.join(root, filename))
LOG.info(f"Identified {len(files_list)} genomes in {file_or_directory}")
# check if input is concatenated file locations separated by , (comma)
elif ',' in file_or_directory:
LOG.info("Using genomes in the input list")
LOG.info("Using genomes in the input list separated by ','")
missing_inputs_count = 0
for filename in file_or_directory.split(','):
if os.path.exists(os.path.abspath(filename)):
files_list.append(os.path.abspath(filename))
else:
LOG.warning(f"File {filename} not found in the ',' separated list")
missing_inputs_count += 1
LOG.info(f"Total of {len(files_list)} genomes identified with a valid path and {missing_inputs_count} missing")
else:
LOG.info("Checking existence of file " + file_or_directory)
input_abs_file_path = os.path.abspath(file_or_directory)
Expand Down Expand Up @@ -213,8 +219,10 @@ def assemble_reads(reads, bowtie_base, combined_fasta, temp_dir, cores=1):
'-U', reads,
'-S', sam_reads
]

subprocess_util.run_subprocess(bowtie_run)


# Convert reads from sam to bam
bam_reads = os.path.join(temp_dir, output_name + '.bam')
sam_convert = [
Expand Down
3 changes: 2 additions & 1 deletion ectyper/subprocess_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ def run_subprocess(cmd, input_data=None, un=False, ignorereturncode=False):
LOG.error("Error in subprocess. The following command failed: {}".format(cmd))
LOG.error("Subprocess failed with error: \"{}\"".format(comp_proc.stderr.decode("utf-8")))
LOG.critical("ectyper has stopped")
exit("subprocess failure")
raise Exception(f"subprocess failure while running {cmd} command")

0 comments on commit f8cd859

Please sign in to comment.