Commit b584bfbd authored by Sarah Peter's avatar Sarah Peter

Remove Snakefiles for HPC-specific steps

parent 3f613835
SAMPLE = "TC1-ST2-D0.12"
rule all:
input: f"output/{SAMPLE}_peaks.narrowPeak", f"output/{SAMPLE}_control_lambda.bigwig", f"output/{SAMPLE}_treat_pileup.bigwig"
rule mapping:
input: "chip-seq/{sample}.fastq.gz"
output: "bowtie2/{sample}.bam"
params:
idx = "reference/Mus_musculus.GRCm38.dna_sm.chromosome.12"
log: "logs/bowtie2_{sample}.log"
benchmark: "benchmarks/mapping/{sample}.tsv"
conda: "envs/bowtie2.yaml"
threads: 4
shell:
"""
bowtie2 -p {threads} -x {params.idx} -U {input} 2> {log} | \
samtools sort - > {output}
samtools index {output}
"""
rule peak_calling:
input:
control = "bowtie2/INPUT-{sample}.bam",
chip = "bowtie2/H3K4-{sample}.bam"
output:
peaks = "output/{sample}_peaks.narrowPeak",
control_bdg = "macs2/{sample}_control_lambda.bdg",
chip_bdg = "macs2/{sample}_treat_pileup.bdg"
conda: "envs/macs2.yaml"
shell:
"""
macs2 callpeak -t {input.chip} -c {input.control} -f BAM -g mm -n {wildcards.sample} -B -q 0.01 --outdir macs2
cp macs2/{wildcards.sample}_peaks.narrowPeak {output.peaks}
"""
rule bigwig:
input: "macs2/{sample}.bdg"
output: "output/{sample}.bigwig"
params:
idx = "reference/Mus_musculus.GRCm38.dna_sm.chromosome.12.fa.fai"
conda: "envs/ucsc.yaml"
shell:
"""
bedGraphToBigWig {input} {params.idx} {output}
"""
rule clean:
shell:
"""
rm -rf bowtie2/ macs2/ output/
"""
SAMPLE = "TC1-ST2-D0.12"
rule all:
input: f"output/{SAMPLE}_peaks.narrowPeak", f"output/{SAMPLE}_control_lambda.bigwig", f"output/{SAMPLE}_treat_pileup.bigwig"
rule mapping:
input: "chip-seq/{sample}.fastq.gz"
output: "bowtie2/{sample}.bam"
params:
idx = "reference/Mus_musculus.GRCm38.dna_sm.chromosome.12"
log: "logs/bowtie2_{sample}.log"
benchmark: "benchmarks/mapping/{sample}.tsv"
conda: "envs/bowtie2.yaml"
threads: 4
shell:
"""
bowtie2 -p {threads} -x {params.idx} -U {input} 2> {log} | \
samtools sort - > {output}
samtools index {output}
"""
rule peak_calling:
input:
control = "bowtie2/INPUT-{sample}.bam",
chip = "bowtie2/H3K4-{sample}.bam"
output:
peaks = "output/{sample}_peaks.narrowPeak",
control_bdg = "macs2/{sample}_control_lambda.bdg",
chip_bdg = "macs2/{sample}_treat_pileup.bdg"
conda: "envs/macs2.yaml"
shell:
"""
macs2 callpeak -t {input.chip} -c {input.control} -f BAM -g mm -n {wildcards.sample} -B -q 0.01 --outdir macs2
cp macs2/{wildcards.sample}_peaks.narrowPeak {output.peaks}
"""
rule bigwig:
input: "macs2/{sample}.bdg"
output: "output/{sample}.bigwig"
params:
idx = "reference/Mus_musculus.GRCm38.dna_sm.chromosome.12.fa.fai"
conda: "envs/ucsc.yaml"
shell:
"""
bedGraphToBigWig {input} {params.idx} {output}
"""
rule clean:
shell:
"""
rm -rf bowtie2/ macs2/ output/
"""
__default__:
time: "0-00:01:00"
partition: "batch"
nodes: 1
ntasks: 1
ncpus: 1
job-name: "{rule}"
output: "slurm-%j-%x.out"
error: "slurm-%j-%x.err"
mapping:
ncpus: 4
SAMPLE = "TC1-ST2-D0.12"
rule all:
input: f"output/{SAMPLE}_peaks.narrowPeak", f"output/{SAMPLE}_control_lambda.bigwig", f"output/{SAMPLE}_treat_pileup.bigwig"
rule mapping:
input: "chip-seq/{sample}.fastq.gz"
output: "bowtie2/{sample}.bam"
params:
idx = "reference/Mus_musculus.GRCm38.dna_sm.chromosome.12"
log: "logs/bowtie2_{sample}.log"
benchmark: "benchmarks/mapping/{sample}.tsv"
conda: "envs/bowtie2.yaml"
threads: 4
shell:
"""
bowtie2 -p {threads} -x {params.idx} -U {input} 2> {log} | \
samtools sort - > {output}
samtools index {output}
"""
rule peak_calling:
input:
control = "bowtie2/INPUT-{sample}.bam",
chip = "bowtie2/H3K4-{sample}.bam"
output:
peaks = "output/{sample}_peaks.narrowPeak",
control_bdg = "macs2/{sample}_control_lambda.bdg",
chip_bdg = "macs2/{sample}_treat_pileup.bdg"
conda: "envs/macs2.yaml"
shell:
"""
macs2 callpeak -t {input.chip} -c {input.control} -f BAM -g mm -n {wildcards.sample} -B -q 0.01 --outdir macs2
cp macs2/{wildcards.sample}_peaks.narrowPeak {output.peaks}
"""
rule bigwig:
input: "macs2/{sample}.bdg"
output: "output/{sample}.bigwig"
params:
idx = "reference/Mus_musculus.GRCm38.dna_sm.chromosome.12.fa.fai"
conda: "envs/ucsc.yaml"
shell:
"""
bedGraphToBigWig {input} {params.idx} {output}
"""
rule clean:
shell:
"""
rm -rf bowtie2/ macs2/ output/
"""
__default__:
time: "0-00:01:00"
partition: "batch"
nodes: 1
ntasks: 1
ncpus: 1
job-name: "{rule}"
output: "slurm-%j-%x.out"
error: "slurm-%j-%x.err"
mapping:
ncpus: 4
#!/usr/bin/env python3
import os
import sys
from snakemake.utils import read_job_properties
# last command-line argument is the job script
jobscript = sys.argv[-1]
# all other command-line arguments are the dependencies
dependencies = set(sys.argv[1:-1])
# parse the job script for the job properties that are encoded by snakemake within
job_properties = read_job_properties(jobscript)
# collect all command-line options in an array
cmdline = ["sbatch"]
# set all the slurm submit options as before
slurm_args = " -p {partition} -N {nodes} -n {ntasks} -c {ncpus} -t {time} -J {job-name} -o {output} -e {error} ".format(**job_properties["cluster"])
cmdline.append(slurm_args)
if dependencies:
cmdline.append("--dependency")
# only keep numbers in dependencies list
dependencies = [ x for x in dependencies if x.isdigit() ]
cmdline.append("afterok:" + ",".join(dependencies))
cmdline.append(jobscript)
os.system(" ".join(cmdline))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment