-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSnakefile
68 lines (51 loc) · 1.93 KB
/
Snakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
__author__ = "Breeshey Roskams-Hieter"
__email__ = "roskamsh@ohsu.edu"
__license__ = "MIT"
"""Computation Hub omic data processing pipeline"""
import datetime
import sys
import os
import pandas as pd
timestamp = ('{:%Y-%m-%d_%H:%M:%S}'.format(datetime.datetime.now()))
configfile:"config.yaml"
project_id = config["project_id"]
seq_type = config["seq_type"]
md = pd.read_table(config["samples"], index_col=["SampleID"], dtype=str)
if config["seq_type"]=="SE":
CASES, = glob_wildcards("samples/cases/{sample}.fastq.gz")
else:
CASES, = glob_wildcards("samples/cases/{sample}_R1.fastq.gz")
if config["seq_type"]=="SE":
CONTROLS, = glob_wildcards("samples/controls/{sample}.fastq.gz")
else:
CONTROLS, = glob_wildcards("samples/controls/{sample}_R1.fastq.gz")
## multiple samples may use the same control input/IgG files
CONTROLS_UNIQUE = list(set(CONTROLS))
SAMPLES = CASES + CONTROLS_UNIQUE
rule_dirs = ['mapReads','makeTracks','bb2bed','call_peaks']
for rule in rule_dirs:
if not os.path.exists(os.path.join(os.getcwd(),'logs',rule)):
log_out = os.path.join(os.getcwd(), 'logs', rule)
os.makedirs(log_out)
print(log_out)
def get_peak(wildcards):
if md.loc[wildcards.sample,["Peak_call"]].values == "broad":
return "broad"
elif md.loc[wildcards.sample,["Peak_call"]].values == "narrow":
return "narrow"
else:
return "ERROR"
def message(mes):
sys.stderr.write("|--- " + mes + "\n")
for sample in SAMPLES:
message("Sample " + sample + " will be processed")
for case in CASES:
message("case " + case + " will be expanded")
rule all:
input:
expand("samples/bigBed/{sample}.all.bb", sample = CASES),
expand("samples/bigBed/{sample}.all.bb", sample = CONTROLS),
expand("samples/bigwig/{sample}.bw", sample = SAMPLES),
expand("results/motifs/{sample}/homerResults.html", sample = CASES)
include: "rules/align.smk"
include: "rules/peaks.smk"