Skip to content

Commit

Permalink
Merge branch 'fix-no-inputs-used-for-peak-call' of github.com:alsmith…
Browse files Browse the repository at this point in the history
…151/SeqNado into fix-no-inputs-used-for-peak-call
  • Loading branch information
alsmith151 committed Feb 5, 2024
2 parents 7aefbeb + 42f68c3 commit f1446ee
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions seqnado/workflow/rules/hub.smk
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,30 @@ def get_hub_input(wildcards):
return input_files


def get_peak_files(wildcards):
peak_files = []

if config["call_peaks"]:
if ASSAY == "ChIP":
peak_files.extend(
expand(
"seqnado_output/peaks/{method}/{sample}.bed",
method=config["peak_calling_method"],
sample=SAMPLE_NAMES_IP,
)
)
elif ASSAY == "ATAC":
peak_files.extend(
expand(
"seqnado_output/peaks/{method}/{sample}.bed",
method=config["peak_calling_method"],
sample=SAMPLE_NAMES,
)
)

return peak_files


rule save_design:
output:
"seqnado_output/design.csv",
Expand All @@ -102,9 +126,33 @@ rule save_design:
DESIGN.to_dataframe().to_csv("seqnado_output/design.csv", index=False)


rule validate_peaks:
input:
get_peak_files,
output:
sentinel="seqnado_output/peaks/.validated",
container:
None
log:
"seqnado_output/logs/validate_peaks.log",
run:
from loguru import logger

with logger.catch():
for peak_file in input.peaks:
with open(peak_file, "r+") as p:
peak_entries = p.readlines()
if len(peak_entries) < 1:
p.write("chr1\t1\t2\n")

with open(output.sentinel, "w") as s:
s.write("validated")


rule bed_to_bigbed:
input:
bed="seqnado_output/peaks/{directory}/{sample}.bed",
sentinel="seqnado_output/peaks/.validated",
output:
bigbed="seqnado_output/peaks/{directory}/{sample}.bigBed",
params:
Expand Down Expand Up @@ -149,3 +197,4 @@ rule generate_hub:

localrules:
generate_hub,
validate_peaks,

0 comments on commit f1446ee

Please sign in to comment.