diff --git a/src/harpy/snakefiles/align_bwa.smk b/src/harpy/snakefiles/align_bwa.smk index 1e506e342..08e94a65e 100644 --- a/src/harpy/snakefiles/align_bwa.smk +++ b/src/harpy/snakefiles/align_bwa.smk @@ -19,14 +19,16 @@ genome_zip = True if bn.lower().endswith(".gz") else False bn_idx = f"{bn}.gzi" if genome_zip else f"{bn}.fai" skipreports = config["skip_reports"] windowsize = config["depth_windowsize"] -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) wildcard_constraints: sample = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/align_ema.smk b/src/harpy/snakefiles/align_ema.smk index 3138c06b8..b0a5b2724 100644 --- a/src/harpy/snakefiles/align_ema.smk +++ b/src/harpy/snakefiles/align_ema.smk @@ -23,14 +23,16 @@ bn_idx = f"{bn}.gzi" if genome_zip else f"{bn}.fai" envdir = os.getcwd() + "/.harpy_envs" windowsize = config["depth_windowsize"] skipreports = config["skip_reports"] -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) wildcard_constraints: sample = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/align_strobealign.smk b/src/harpy/snakefiles/align_strobealign.smk index 4f3bc92c1..302d338e3 100644 --- a/src/harpy/snakefiles/align_strobealign.smk +++ b/src/harpy/snakefiles/align_strobealign.smk @@ -21,14 +21,16 @@ windowsize = config["depth_windowsize"] molecule_distance = config["molecule_distance"] readlen = config["average_read_length"] autolen = isinstance(readlen, str) -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) wildcard_constraints: sample = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/deconvolve.smk b/src/harpy/snakefiles/deconvolve.smk index 2d7d26e7f..6f5f60af2 100644 --- a/src/harpy/snakefiles/deconvolve.smk +++ b/src/harpy/snakefiles/deconvolve.smk @@ -15,11 +15,6 @@ kmer_length = config["kmer_length"] window_size = config["window_size"] density = config["density"] dropout = config["dropout"] -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) - bn_r = r"([_\.][12]|[_\.][FR]|[_\.]R[12](?:\_00[0-9])*)?\.((fastq|fq)(\.gz)?)$" samplenames = {re.sub(bn_r, "", os.path.basename(i), flags = re.IGNORECASE) for i in fqlist} @@ -27,6 +22,12 @@ samplenames = {re.sub(bn_r, "", os.path.basename(i), flags = re.IGNORECASE) for wildcard_constraints: sample = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onsuccess: print("") rprint( diff --git a/src/harpy/snakefiles/demultiplex_gen1.smk b/src/harpy/snakefiles/demultiplex_gen1.smk index 5c4b12da3..4f361892f 100644 --- a/src/harpy/snakefiles/demultiplex_gen1.smk +++ b/src/harpy/snakefiles/demultiplex_gen1.smk @@ -16,10 +16,6 @@ samplefile = config["inputs"]["demultiplex_schema"] skipreports = config["skip_reports"] outdir = config["output_directory"] envdir = os.getcwd() + "/.harpy_envs" -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) def barcodedict(smpl): d = {} @@ -36,6 +32,12 @@ def barcodedict(smpl): samples = barcodedict(samplefile) samplenames = [i for i in samples.keys()] +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/impute.smk b/src/harpy/snakefiles/impute.smk index 1db6eef8c..60c114468 100644 --- a/src/harpy/snakefiles/impute.smk +++ b/src/harpy/snakefiles/impute.smk @@ -20,11 +20,6 @@ skipreports = config["skip_reports"] outdir = config["output_directory"] envdir = os.getcwd() + "/.harpy_envs" paramspace = Paramspace(pd.read_csv(paramfile, sep=r"\s+", skip_blank_lines=True).rename(columns=str.lower), param_sep = "", filename_params = ["k", "s", "ngen", "bxlimit"]) -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) - with open(biallelic, "r") as f_open: contigs = [i.rstrip() for i in f_open.readlines()] @@ -36,6 +31,12 @@ def sam_index(infile): if not os.path.exists(f"{infile}.bai"): subprocess.run(f"samtools index {infile} {infile}.bai".split()) +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/phase.smk b/src/harpy/snakefiles/phase.smk index df2387b74..fa5d35a76 100644 --- a/src/harpy/snakefiles/phase.smk +++ b/src/harpy/snakefiles/phase.smk @@ -21,11 +21,6 @@ skipreports = config["skip_reports"] samples_from_vcf = config["samples_from_vcf"] variantfile = config["inputs"]["variantfile"] bamlist = config["inputs"]["alignments"] -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) - # toggle linked-read aware mode if config["ignore_bx"]: fragfile = outdir + "/extract_hairs/{sample}.unlinked.frags" @@ -40,7 +35,6 @@ if samples_from_vcf: else: samplenames = [Path(i).stem for i in bamlist] - # toggle indel mode if config["inputs"].get("genome", None): genomefile = config["inputs"]["genome"] @@ -63,6 +57,12 @@ else: wildcard_constraints: sample = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/preflight_bam.smk b/src/harpy/snakefiles/preflight_bam.smk index f9e997d2d..a7e479500 100644 --- a/src/harpy/snakefiles/preflight_bam.smk +++ b/src/harpy/snakefiles/preflight_bam.smk @@ -14,15 +14,17 @@ from rich.panel import Panel outdir = config["output_directory"] envdir = os.getcwd() + "/.harpy_envs" bamlist = config["inputs"] -samplenames = {Path(i).stem for i in bamlist} -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) +samplenames = {Path(i).stem for i in bamlist} wildcard_constraints: sample = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/preflight_fastq.smk b/src/harpy/snakefiles/preflight_fastq.smk index a59036456..7592d2d53 100644 --- a/src/harpy/snakefiles/preflight_fastq.smk +++ b/src/harpy/snakefiles/preflight_fastq.smk @@ -15,14 +15,16 @@ outdir = config["output_directory"] envdir = os.getcwd() + "/.harpy_envs" bn_r = r"([_\.][12]|[_\.][FR]|[_\.]R[12](?:\_00[0-9])*)?\.((fastq|fq)(\.gz)?)$" samplenames = {re.sub(bn_r, "", os.path.basename(i), flags = re.IGNORECASE) for i in fqlist} -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) wildcard_constraints: sample = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/qc.smk b/src/harpy/snakefiles/qc.smk index c9b56cfd4..6920be955 100644 --- a/src/harpy/snakefiles/qc.smk +++ b/src/harpy/snakefiles/qc.smk @@ -25,10 +25,6 @@ if deconvolve: decon_d = deconvolve["density"] decon_a = deconvolve["dropout"] skipreports = config["skip_reports"] -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) bn_r = r"([_\.][12]|[_\.][FR]|[_\.]R[12](?:\_00[0-9])*)?\.((fastq|fq)(\.gz)?)$" samplenames = {re.sub(bn_r, "", os.path.basename(i), flags = re.IGNORECASE) for i in fqlist} @@ -36,6 +32,12 @@ samplenames = {re.sub(bn_r, "", os.path.basename(i), flags = re.IGNORECASE) for wildcard_constraints: sample = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onsuccess: print("") rprint( diff --git a/src/harpy/snakefiles/simulate_linkedreads.smk b/src/harpy/snakefiles/simulate_linkedreads.smk index 76b26def1..6ba6e355d 100644 --- a/src/harpy/snakefiles/simulate_linkedreads.smk +++ b/src/harpy/snakefiles/simulate_linkedreads.smk @@ -19,11 +19,12 @@ if barcodes: barcodefile = barcodes else: barcodefile = f"{outdir}/workflow/input/4M-with-alts-february-2016.txt" -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) onsuccess: shutil.rmtree('./_Inline', ignore_errors=True) diff --git a/src/harpy/snakefiles/simulate_snpindel.smk b/src/harpy/snakefiles/simulate_snpindel.smk index b60e11a4a..27ed8914d 100644 --- a/src/harpy/snakefiles/simulate_snpindel.smk +++ b/src/harpy/snakefiles/simulate_snpindel.smk @@ -15,11 +15,6 @@ snp_vcf = config["inputs"].get("snp_vcf", None) indel_vcf = config["inputs"].get("indel_vcf", None) heterozygosity = config["heterozygosity"] outprefix = config["prefix"] -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) - in_vcfs = [] snp = False indel = False @@ -65,6 +60,12 @@ else: variants = [i for i,j in zip(["snp", "indel"], [snp, indel]) if j] +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onsuccess: print("") rprint( diff --git a/src/harpy/snakefiles/simulate_variants.smk b/src/harpy/snakefiles/simulate_variants.smk index 348453964..35e1daf44 100644 --- a/src/harpy/snakefiles/simulate_variants.smk +++ b/src/harpy/snakefiles/simulate_variants.smk @@ -16,11 +16,6 @@ genome = config["inputs"]["genome"] vcf = config["inputs"].get("vcf", None) heterozygosity = float(config["heterozygosity"]) vcf_correct = "None" -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) - if vcf: vcf_correct = vcf[:-4] + ".vcf.gz" if vcf.lower().endswith("bcf") else vcf variant_params = f"-{variant}_vcf {vcf_correct}" @@ -52,6 +47,12 @@ else: cnv_ratio =config.get("cnv_ratio", None) variant_params += f" --cnv_gain_loss_ratio {cnv_ratio}" if cnv_ratio else "" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onsuccess: print("") rprint( diff --git a/src/harpy/snakefiles/snp_freebayes.smk b/src/harpy/snakefiles/snp_freebayes.smk index 3de06f040..65b2a6fe1 100644 --- a/src/harpy/snakefiles/snp_freebayes.smk +++ b/src/harpy/snakefiles/snp_freebayes.smk @@ -42,14 +42,16 @@ else: cont,startpos,endpos = line.split() intervals.add(f"{cont}:{startpos}-{endpos}") regions = dict(zip(intervals, intervals)) -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) wildcard_constraints: sample = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/snp_mpileup.smk b/src/harpy/snakefiles/snp_mpileup.smk index 75bef02e0..a615c70ee 100644 --- a/src/harpy/snakefiles/snp_mpileup.smk +++ b/src/harpy/snakefiles/snp_mpileup.smk @@ -37,14 +37,16 @@ else: cont,startpos,endpos = line.split() intervals.add(f"{cont}:{startpos}-{endpos}") regions = dict(zip(intervals, intervals)) -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) wildcard_constraints: sample = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/sv_leviathan.smk b/src/harpy/snakefiles/sv_leviathan.smk index 5d7189d18..8645f96f3 100644 --- a/src/harpy/snakefiles/sv_leviathan.smk +++ b/src/harpy/snakefiles/sv_leviathan.smk @@ -24,14 +24,16 @@ bn = os.path.basename(genomefile) genome_zip = True if bn.lower().endswith(".gz") else False if genome_zip: bn = bn[:-3] -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) wildcard_constraints: sample = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/sv_leviathan_pop.smk b/src/harpy/snakefiles/sv_leviathan_pop.smk index d1d0ae587..512b77d86 100644 --- a/src/harpy/snakefiles/sv_leviathan_pop.smk +++ b/src/harpy/snakefiles/sv_leviathan_pop.smk @@ -21,15 +21,17 @@ skipreports = config["skip_reports"] bn = os.path.basename(genomefile) if bn.lower().endswith(".gz"): bn = bn[:-3] -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) wildcard_constraints: sample = "[a-zA-Z0-9._-]+", population = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/sv_naibr.smk b/src/harpy/snakefiles/sv_naibr.smk index c79e94f70..08eb44fc4 100644 --- a/src/harpy/snakefiles/sv_naibr.smk +++ b/src/harpy/snakefiles/sv_naibr.smk @@ -23,13 +23,6 @@ skipreports = config["skip_reports"] bn = os.path.basename(genomefile) genome_zip = True if bn.lower().endswith(".gz") else False bn_idx = f"{bn}.gzi" if genome_zip else f"{bn}.fai" -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) - -wildcard_constraints: - sample = "[a-zA-Z0-9._-]+" def process_args(args): argsDict = { @@ -45,6 +38,15 @@ def process_args(args): argsDict[i[0].lstrip("-")] = i[1] return argsDict +wildcard_constraints: + sample = "[a-zA-Z0-9._-]+" + +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/sv_naibr_phase.smk b/src/harpy/snakefiles/sv_naibr_phase.smk index 4eb29b53d..0833534df 100644 --- a/src/harpy/snakefiles/sv_naibr_phase.smk +++ b/src/harpy/snakefiles/sv_naibr_phase.smk @@ -31,14 +31,16 @@ if vcffile.lower().endswith("bcf"): vcfindex = vcffile + ".csi" else: vcfindex = vcffile + ".tbi" -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) wildcard_constraints: sample = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/sv_naibr_pop.smk b/src/harpy/snakefiles/sv_naibr_pop.smk index a99d4c055..8415c289a 100644 --- a/src/harpy/snakefiles/sv_naibr_pop.smk +++ b/src/harpy/snakefiles/sv_naibr_pop.smk @@ -23,15 +23,17 @@ bn = os.path.basename(genomefile) outdir = config["output_directory"] if bn.lower().endswith(".gz"): bn = bn[:-3] -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) wildcard_constraints: sample = "[a-zA-Z0-9._-]+", population = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint( diff --git a/src/harpy/snakefiles/sv_naibr_pop_phase.smk b/src/harpy/snakefiles/sv_naibr_pop_phase.smk index 37acf43dd..28718cecf 100644 --- a/src/harpy/snakefiles/sv_naibr_pop_phase.smk +++ b/src/harpy/snakefiles/sv_naibr_pop_phase.smk @@ -27,15 +27,17 @@ skipreports = config["skip_reports"] outdir = config["output_directory"] if bn.lower().endswith(".gz"): bn = bn[:-3] -os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) -dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") -extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") -logger.logger.addHandler(extra_logfile_handler) wildcard_constraints: sample = "[a-zA-Z0-9._-]+", population = "[a-zA-Z0-9._-]+" +onstart: + os.makedirs(f"{outdir}/logs/snakemake", exist_ok = True) + dt_string = datetime.now().strftime("%d_%m_%Y-%H_%M_%S") + extra_logfile_handler = pylogging.FileHandler(f"{outdir}/logs/snakemake/{dt_string}.snakelog") + logger.logger.addHandler(extra_logfile_handler) + onerror: print("") rprint(