Skip to content
Snippets Groups Projects
Commit 6ecb2350 authored by Manavalan Gajapathy's avatar Manavalan Gajapathy
Browse files

edits outpaths as multi-project support has been stripped

parent a04b37c7
No related branches found
No related tags found
1 merge request!1QuaC - First major review
......@@ -4,7 +4,7 @@
"partition": "express",
"cpus-per-task": "{threads}",
"mem": "8G",
"output": "logs/rule_logs/{rule}-%j.log"
"output": "{LOGS_PATH}/rule_logs/{rule}-%j.log"
},
"mosdepth": {
"partition": "short",
......
......@@ -6,6 +6,7 @@ module load snakemake/5.9.1-foss-2018b-Python-3.6.6
snakemake -s workflow/Snakefile --use-conda -k -p --config modules=all
'''
from pathlib import Path
import pandas as pd
......
......@@ -21,10 +21,8 @@ def modules_to_run(chosen, allowed_options=['somalier', 'verifybamid', 'indexcov
return selected_modules
EXTERNAL_DIR = Path("data/external")
RAW_DIR = Path("data/raw")
INTERIM_DIR = Path("data/interim")
PROCESSED_DIR = Path("data/processed")
OUT_DIR = Path("data/processed")
LOGS_PATH = Path(config['logs_path'])
LOGS_PATH.mkdir(parents=True, exist_ok=True)
......@@ -41,25 +39,20 @@ def get_targets(tool_name, project=PROJECT_NAME, samples=SAMPLES):
flist = []
if tool_name == 'somalier':
flist += expand(str(PROCESSED_DIR / "somalier/{project}/relatedness/somalier.html"),
project=[PROJECT_NAME]),
flist += expand(str(PROCESSED_DIR / "somalier/{project}/ancestry/somalier.somalier-ancestry.html"),
project=[PROJECT_NAME]),
flist += [
OUT_DIR / "somalier" / "relatedness" / "somalier.html",
OUT_DIR / "somalier" / "ancestry" / "somalier.somalier-ancestry.html"
]
elif tool_name == 'indexcov':
flist += expand(str(PROCESSED_DIR / "indexcov/{project}/index.html"),
project=[PROJECT_NAME])
flist += [OUT_DIR / "indexcov" / "index.html"]
elif tool_name == 'covviz':
flist += expand(str(PROCESSED_DIR / "covviz/{project}/covviz_report.html"),
project=[PROJECT_NAME]),
flist += [OUT_DIR / "covviz/" / "covviz_report.html"]
elif tool_name == 'mosdepth':
flist += expand(str(PROCESSED_DIR / "mosdepth/{project}/mosdepth_{project}.html"),
project=[PROJECT_NAME]),
flist += expand(str(PROCESSED_DIR / "mosdepth/{project}/results/{sample}.mosdepth.global.dist.txt"),
project=[PROJECT_NAME],
flist += [OUT_DIR / "mosdepth" / f"mosdepth_{PROJECT_NAME}.html"]
flist += expand(str(OUT_DIR / "mosdepth" / "results" / "{sample}.mosdepth.global.dist.txt"),
sample=SAMPLES),
elif tool_name == 'verifybamid':
flist += expand(str(PROCESSED_DIR / "verifyBamID/{project}/{sample}.Ancestry"),
project=[PROJECT_NAME],
flist += expand(str(OUT_DIR / "verifyBamID" / "{sample}.Ancestry"),
sample=SAMPLES),
......
......@@ -11,13 +11,13 @@ TARGETS_COVERAGE = [
########################## Mosdepth ##########################
rule mosdepth_coverage:
input:
bam = PROJECTS_PATH / "{project}" / "analysis" / "{sample}" / "bam" / "{sample}.bam",
bam_index = PROJECTS_PATH / "{project}" / "analysis" / "{sample}" / "bam" / "{sample}.bam.bai",
bam = PROJECTS_PATH / PROJECT_NAME / "analysis" / "{sample}" / "bam" / "{sample}.bam",
bam_index = PROJECTS_PATH / PROJECT_NAME / "analysis" / "{sample}" / "bam" / "{sample}.bam.bai",
output:
dist = PROCESSED_DIR / "mosdepth/{project}/results/{sample}.mosdepth.global.dist.txt",
summary = PROCESSED_DIR / "mosdepth/{project}/results/{sample}.mosdepth.summary.txt",
dist = OUT_DIR / "mosdepth" / "results" / "{sample}.mosdepth.global.dist.txt",
summary = OUT_DIR / "mosdepth" / "results" / "{sample}.mosdepth.summary.txt",
message:
"Running mosdepth for coverage. Project: {wildcards.project}, sample: {wildcards.sample}"
"Running mosdepth for coverage. Sample: {wildcards.sample}"
group:
"mosdepth"
conda:
......@@ -39,13 +39,13 @@ rule mosdepth_coverage:
rule mosdepth_plot:
input:
dist = expand(str(PROCESSED_DIR / "mosdepth" / "{{project}}" / "results" / "{sample}.mosdepth.global.dist.txt"),
dist = expand(str(OUT_DIR / "mosdepth" / "results" / "{sample}.mosdepth.global.dist.txt"),
sample=SAMPLES),
script = WORKFLOW_PATH / "src/mosdepth/v0.3.1/plot-dist.py",
output:
PROCESSED_DIR / "mosdepth/{project}/mosdepth_{project}.html",
OUT_DIR / "mosdepth" / f"mosdepth_{PROJECT_NAME}.html",
message:
"Running mosdepth plotting. Project: {wildcards.project}"
"Running mosdepth plotting"
group:
"mosdepth"
params:
......@@ -65,17 +65,17 @@ rule mosdepth_plot:
########################## indexcov ##########################
rule indexcov:
input:
bam = expand(str(PROJECTS_PATH / "{{project}}" / "analysis" / "{sample}" / "bam" / "{sample}.bam"),
bam = expand(str(PROJECTS_PATH / PROJECT_NAME / "analysis" / "{sample}" / "bam" / "{sample}.bam"),
sample=SAMPLES),
bam_index = expand(str(PROJECTS_PATH / "{{project}}" / "analysis" / "{sample}" / "bam" / "{sample}.bam.bai"),
bam_index = expand(str(PROJECTS_PATH / PROJECT_NAME / "analysis" / "{sample}" / "bam" / "{sample}.bam.bai"),
sample=SAMPLES),
goleft_tool = config['goleft']['tool'],
output:
html = PROCESSED_DIR / "indexcov/{project}/index.html",
bed = PROCESSED_DIR / "indexcov/{project}/{project}-indexcov.bed.gz",
log = PROCESSED_DIR / "indexcov/{project}/stdout.log",
html = OUT_DIR / "indexcov" / "index.html",
bed = OUT_DIR / "indexcov" / f"{PROJECT_NAME}-indexcov.bed.gz",
log = OUT_DIR / "indexcov" / "stdout.log",
message:
"Running indexcov. Project: {wildcards.project}"
"Running indexcov"
params:
outdir = lambda wildcards, output: Path(output[0]).parent,
project_dir = lambda wildcards, input: str(Path(input['bam'][0]).parents[2]),
......@@ -93,13 +93,13 @@ rule indexcov:
########################## covviz ##########################
rule covviz:
input:
bed = PROCESSED_DIR / "indexcov/{project}/{project}-indexcov.bed.gz",
bed = OUT_DIR / "indexcov" / f"{PROJECT_NAME}-indexcov.bed.gz",
ped = PEDIGREE_FPATH,
output:
html = PROCESSED_DIR / "covviz/{project}/covviz_report.html",
log = PROCESSED_DIR / "covviz/{project}/stdout.log",
html = OUT_DIR / "covviz" / "covviz_report.html",
log = OUT_DIR / "covviz" / "stdout.log",
message:
"Running covviz. Project: {wildcards.project}"
"Running covviz"
conda:
str(WORKFLOW_PATH / "configs/env/covviz.yaml")
shell:
......
......@@ -4,15 +4,15 @@ TARGETS_SOMALIER = [
rule somalier_extract:
input:
bam = PROJECTS_PATH / "{project}" / "analysis" / "{sample}" / "bam" / "{sample}.bam",
bam_index = PROJECTS_PATH / "{project}" / "analysis" / "{sample}" / "bam" / "{sample}.bam.bai",
bam = PROJECTS_PATH / PROJECT_NAME / "analysis" / "{sample}" / "bam" / "{sample}.bam",
bam_index = PROJECTS_PATH / PROJECT_NAME / "analysis" / "{sample}" / "bam" / "{sample}.bam.bai",
somalier_tool = config['somalier']['tool'],
sites = config['somalier']['sites'],
ref_genome = config['ref'],
output:
PROCESSED_DIR / "somalier/{project}/extract/{sample}.somalier",
OUT_DIR / "somalier/extract/{sample}.somalier",
message:
"Running somalier extract. Project: {wildcards.project}"
"Running somalier extract. Sample: {wildcards.sample}"
group:
"somalier"
params:
......@@ -29,16 +29,16 @@ rule somalier_extract:
rule somalier_relate:
input:
extracted = expand(str(PROCESSED_DIR / "somalier" / "{{project}}" / "extract" / "{sample}.somalier"),
extracted = expand(str(OUT_DIR / "somalier" / "extract" / "{sample}.somalier"),
sample=SAMPLES),
ped = PEDIGREE_FPATH,
somalier_tool = config['somalier']['tool'],
output:
out = expand(str(PROCESSED_DIR / "somalier/{{project}}/relatedness/somalier.{ext}"),
out = expand(str(OUT_DIR / "somalier" / "relatedness" / "somalier.{ext}"),
ext=['html', 'groups.tsv', 'pairs.tsv', 'samples.tsv']),
log = PROCESSED_DIR / "somalier/{project}/relatedness/somalier.log",
log = OUT_DIR / "somalier" / "relatedness" / "somalier.log",
message:
"Running somalier relate. Project: {wildcards.project}"
"Running somalier relate"
group:
"somalier"
params:
......@@ -59,17 +59,17 @@ rule somalier_relate:
rule somalier_ancestry:
input:
extracted = expand(str(PROCESSED_DIR / "somalier" / "{{project}}" / "extract" / "{sample}.somalier"),
extracted = expand(str(OUT_DIR / "somalier" / "extract" / "{sample}.somalier"),
sample=SAMPLES),
somalier_tool = config['somalier']['tool'],
labels_1kg = config['somalier']['labels_1kg'],
somalier_1kg = directory(config['somalier']['somalier_1kg']),
output:
out = expand(str(PROCESSED_DIR / "somalier/{{project}}/ancestry/somalier.somalier-ancestry.{ext}"),
out = expand(str(OUT_DIR / "somalier" / "ancestry" / "somalier.somalier-ancestry.{ext}"),
ext=['html', 'tsv']),
log = PROCESSED_DIR / "somalier/{project}/relatedness/somalier.log",
log = OUT_DIR / "somalier" / "relatedness" / "somalier.log",
message:
"Running somalier ancestry. Project: {wildcards.project}"
"Running somalier ancestry."
group:
"somalier"
params:
......
......@@ -5,16 +5,16 @@ TARGETS_CONTAMINATION = [
rule verifybamid:
input:
bam = PROJECTS_PATH / "{project}" / "analysis" / "{sample}" / "bam" / "{sample}.bam",
bam_index = PROJECTS_PATH / "{project}" / "analysis" / "{sample}" / "bam" / "{sample}.bam.bai",
bam = PROJECTS_PATH / PROJECT_NAME / "analysis" / "{sample}" / "bam" / "{sample}.bam",
bam_index = PROJECTS_PATH / PROJECT_NAME / "analysis" / "{sample}" / "bam" / "{sample}.bam.bai",
ref_genome = config['ref'],
svd = expand(f"{config['verifyBamID']['svd_dat']}.{{ext}}",
ext=['bed', 'mu', 'UD'])
output:
ancestry = PROCESSED_DIR / "verifyBamID/{project}/{sample}.Ancestry",
selfsm = PROCESSED_DIR / "verifyBamID/{project}/{sample}.selfSM",
ancestry = OUT_DIR / "verifyBamID/{sample}.Ancestry",
selfsm = OUT_DIR / "verifyBamID/{sample}.selfSM",
message:
"Running VerifyBamID to detect within-species contamination. Project: {wildcards.project}, sample: {wildcards.sample}"
"Running VerifyBamID to detect within-species contamination. sample: {wildcards.sample}"
conda:
str(WORKFLOW_PATH / "configs/env/verifyBamID.yaml")
params:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment