Skip to content

Commit

Permalink
working again
Browse files Browse the repository at this point in the history
  • Loading branch information
niekwit committed Nov 22, 2024
1 parent 78ccef0 commit 457ca12
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions workflow/scripts/run_find_peaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,8 @@
"""
import glob
import os
import logging
from snakemake.shell import shell

# Setup logging
log = snakemake.log[0]
logging.basicConfig(format='%(levelname)s:%(message)s',
level=logging.DEBUG,
handlers=[logging.FileHandler(log)])

# Get current working dir
cwd = os.getcwd()

Expand All @@ -48,13 +41,18 @@
sample = os.path.basename(bedgraph).replace("-vs-Dam-norm.gatc.bedgraph","")

# Run find_peaks
command = """perl {find_peaks} --fdr={fdr}
--frac={frac} --min_count={min_count}
--min_quant={min_quant} --n={n}
--step={step} --unified_peaks={up}
{bedgraph} > {log} 2>&1 """
logging.debug(f"Running: {command}")
shell(command)
shell(
"perl {find_peaks} "
"--fdr={fdr} "
"--frac={frac} "
"--min_count={min_count} "
"--min_quant={min_quant} "
"--n={n} "
"--step={step} "
"--unified_peaks={up} "
"{bedgraph} "
"> {log} 2>&1 "
)

# Locate GFF and data files and move to output dir (parent dir)
gff_temp = glob.glob(f"{outdir}/peak_analysis.{sample}*/{sample}*.peaks.gff") # peak file
Expand All @@ -63,13 +61,15 @@
assert len(data_temp) == 1, "No or more than one data file found"

# Rename and move files
command = f"mv {gff_temp[0]} {gff} && mv {data_temp[0]} {data}"
logging.debug(f"Running: {command}")
shell(command)
shell(
f"mv {gff_temp[0]} {gff} && "
f"mv {data_temp[0]} {data}"
)

# Remove empty dir
empty_dir = os.path.dirname(gff_temp[0])
os.rmdir(empty_dir)

# Go back to original working dir
os.chdir(cwd) # Is this needed?

0 comments on commit 457ca12

Please sign in to comment.