Skip to content

Commit

Permalink
implemnt reuse_files
Browse files Browse the repository at this point in the history
  • Loading branch information
LaraFuhrmann committed Nov 27, 2024
1 parent e29a17b commit 2ff2bfa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions viloca/b2w.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def parallel_run_one_window(
indel_map,
max_ins_at_pos,
extended_window_mode,
exclude_non_var_pos_threshold
exclude_non_var_pos_threshold,
):
"""
build one window.
Expand Down Expand Up @@ -510,7 +510,8 @@ def build_windows(alignment_file: str, tiling_strategy: TilingStrategy,
exact_conformance_fix_0_1_basing_in_reads: Optional[bool] = False,
extended_window_mode: Optional[bool] = False,
exclude_non_var_pos_threshold: Optional[float] = -1,
maxthreads: Optional[int] = 1) -> None:
maxthreads: Optional[int] = 1,
reuse_files = False) -> None:
"""Summarizes reads aligned to reference into windows.
Three products are created:
#. Multiple FASTA files (one for each window position)
Expand Down Expand Up @@ -580,7 +581,7 @@ 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]
if not os.path.isfile(f"coverage_{idx}.txt"):
if not (reuse_files and os.path.isfile(f"coverage_{idx}.txt")):
p = Process(
target=parallel_run_one_window,
args=(
Expand All @@ -605,6 +606,8 @@ def build_windows(alignment_file: str, tiling_strategy: TilingStrategy,
)
)
all_processes.append(p)
else:
logging.info(f'[file already exits] Use window files generated on {time.ctim(pathlib.Path(f"coverage_{idx}.txt").stat().st_mtime)}')

for p in all_processes:
p.start()
Expand Down

0 comments on commit 2ff2bfa

Please sign in to comment.