From 9733154015f67a5fbb53b867aed957e078ed75d5 Mon Sep 17 00:00:00 2001 From: LaraFuhrmann <55209716+LaraFuhrmann@users.noreply.github.com> Date: Thu, 27 Feb 2025 12:05:36 +0100 Subject: [PATCH] #45 write cooocurring_mutations.csv in the beginning of main --- viloca/shorah_snv.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/viloca/shorah_snv.py b/viloca/shorah_snv.py index 5b39b5b..949e9aa 100644 --- a/viloca/shorah_snv.py +++ b/viloca/shorah_snv.py @@ -525,23 +525,6 @@ def get_cooccuring_muts_haplo_df(haplo_filename, ref_filename, beg, end, chrom): return df -def write_cooccuring_muts_file(): - - tmp_df =[] - - # iterate over haplotype files - with open("coverage.txt") as cov_file: - for line in cov_file: - # winFile, chrom, beg, end, cov - _, chrom, beg, end, _ = line.rstrip().split("\t") - - file_stem = "w-%s-%s-%s" % (chrom, beg, end) - haplo_filename = os.path.join(working_dir, "haplotypes", file_stem + ".reads-support.fas") - ref_name = os.path.join(working_dir, "haplotypes", file_stem + ".ref.fas") - tmp_df.append(get_cooccuring_muts_df(fname_haplo, fname_ref, beg,end,chrom)) - - pd.concat(tmp_df).to_csv("cooccurring_mutations.csv") - def main(args): """main code""" @@ -563,6 +546,20 @@ def main(args): logging.info(str(inspect.getfullargspec(main))) + # write: "cooccurring_mutations.csv" + tmp_df =[] + # iterate over haplotype files + with open("coverage.txt") as cov_file: + for line in cov_file: + # winFile, chrom, beg, end, cov + _, chrom, beg, end, _ = line.rstrip().split("\t") + + file_stem = "w-%s-%s-%s" % (chrom, beg, end) + haplo_filename = os.path.join(working_dir, "haplotypes", file_stem + ".reads-support.fas") + ref_name = os.path.join(working_dir, "haplotypes", file_stem + ".ref.fas") + tmp_df.append(get_cooccuring_muts_df(fname_haplo, fname_ref, beg,end,chrom)) + pd.concat(tmp_df).to_csv("cooccurring_mutations.csv") + # snpD_m is the file with the 'consensus' SNVs (from different windows) logging.debug("now parsing SNVs") all_SNVs = getSNV(extended_window_mode, exclude_non_var_pos_threshold,