Skip to content

Commit

Permalink
b2w and inference: rerun windows that failed + check if window was pr…
Browse files Browse the repository at this point in the history
…ocessed already before adding process to process list
  • Loading branch information
LaraFuhrmann committed Jun 7, 2024
1 parent 005909b commit b2b76aa
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
52 changes: 27 additions & 25 deletions viloca/b2w.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,39 +578,41 @@ def build_windows(alignment_file: str, tiling_strategy: TilingStrategy,
all_processes = []
for idx, (window_start, window_length, control_window_length) in enumerate(tiling):
counter = counter_list[idx]
p = Process(
target=parallel_run_one_window,
args=(
reference_filename,
minimum_reads,
tiling,
region_end,
idx,
window_start, # 1-based
window_length,
control_window_length,
alignment_file,
reference_name,
win_min_ext,
permitted_reads_per_location,
counter, # 0-based
exact_conformance_fix_0_1_basing_in_reads,
indel_map,
max_ins_at_pos, # 0-based
extended_window_mode,
exclude_non_var_pos_threshold,
if not os.path.isfile(f"coverage_{idx}.txt"):
p = Process(
target=parallel_run_one_window,
args=(
reference_filename,
minimum_reads,
tiling,
region_end,
idx,
window_start, # 1-based
window_length,
control_window_length,
alignment_file,
reference_name,
win_min_ext,
permitted_reads_per_location,
counter, # 0-based
exact_conformance_fix_0_1_basing_in_reads,
indel_map,
max_ins_at_pos, # 0-based
extended_window_mode,
exclude_non_var_pos_threshold,
)
)
)
all_processes.append(p)
all_processes.append(p)

for p in all_processes:
p.start()

for p in all_processes:
p.join()
if p.exitcode != 0:
logging.debug("[b2w] A process was killed. Terminating the program.")
exit(1)
p.start()
logging.debug("[b2w] A process was killed. Terminating the program. Process was restarted.")
#exit(1)

logging.debug("[b2w] All processes completed successfully.")

Expand Down
11 changes: 7 additions & 4 deletions viloca/shotgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,10 @@ def win_to_run(alpha_w, seed, inference_type, n_max_haplotypes, n_mfa_starts, un

for f1 in file1:
winFile, chr1, beg, end, cov = f1.rstrip().split('\t')
j = min(300_000, int(cov) * 15)
rn_list.append((winFile, j, alpha_w, seed, inference_type, n_max_haplotypes, n_mfa_starts, unique_modus, inference_convergence_threshold))
output_name = output_dir + winFile.split("/")[-1][:-4] + "-" + "cor.fas"
if not os.path.isfile(output_name):
j = min(300_000, int(cov) * 15)
rn_list.append((winFile, j, alpha_w, seed, inference_type, n_max_haplotypes, n_mfa_starts, unique_modus, inference_convergence_threshold))

del end
del(beg, chr1)
Expand Down Expand Up @@ -515,8 +517,9 @@ def main(args):
for p in all_processes:
p.join()
if p.exitcode != 0:
logging.debug("[shotgun] A process was killed. Terminating the program.")
exit(1)
p.start()
logging.debug("[shotgun] A process was killed. Restart process.")
#exit(1)

logging.debug("[shotgun] All processes completed successfully.")

Expand Down

0 comments on commit b2b76aa

Please sign in to comment.