-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '414-defining-tumor-purityploidy' of github.com:bihealth…
…/snappy-pipeline into 414-defining-tumor-purityploidy
- Loading branch information
Showing
4 changed files
with
81 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,48 @@ | |
""" | ||
|
||
import os | ||
import sys | ||
|
||
# The following is required for being able to import snappy_wrappers modules | ||
# inside wrappers. These run in an "inner" snakemake process which uses its | ||
# own conda environment which cannot see the snappy_pipeline installation. | ||
base_dir = os.path.normpath(os.path.join(os.path.dirname(__file__), "..", "..", "..", "..")) | ||
sys.path.insert(0, base_dir) | ||
|
||
from snakemake import shell | ||
|
||
from snappy_wrappers.tools.genome_windows import yield_contigs | ||
|
||
__author__ = "Eric Blanc <[email protected]>" | ||
|
||
|
||
def config_to_r(x): | ||
if x is None: | ||
return "NULL" | ||
if isinstance(x, str): | ||
return f'"{x}"' | ||
if isinstance(x, bool): | ||
return "TRUE" if x else "FALSE" | ||
if isinstance(x, list): | ||
return "c({})".format(", ".join([config_to_r(xx) for xx in x])) | ||
if isinstance(x, dict): | ||
return "list({})".format( | ||
", ".join(['"{}"={}'.format(k, config_to_r(v)) for k, v in x.items()]) | ||
) | ||
return str(x) | ||
|
||
|
||
step = snakemake.config["pipeline_step"]["name"] | ||
config = snakemake.config["step_config"][step]["sequenza"] | ||
genome = snakemake.config["static_data_config"]["reference"]["path"] | ||
|
||
f = open(genome + ".fai", "rt") | ||
contigs = config_to_r(list(yield_contigs(f, config.get("ignore_chroms")))) | ||
f.close() | ||
|
||
args_extract = config_to_r(dict(config["extra_args_extract"])) | ||
args_fit = config_to_r(dict(config["extra_args_fit"])) | ||
|
||
shell.executable("/bin/bash") | ||
|
||
shell( | ||
|
@@ -35,13 +72,21 @@ | |
R --vanilla --slave << __EOF | ||
library(sequenza) | ||
seqz <- sequenza.extract("{snakemake.input.seqz}") | ||
CP <- sequenza.fit(seqz) | ||
args <- list(file="{snakemake.input.seqz}", assembly="{config[assembly]}", chromosome.list={contigs}) | ||
args <- c(args, {args_extract}) | ||
seqz <- do.call(sequenza.extract, args=args) | ||
args <- list(sequenza.extract=seqz, chromosome.list={contigs}, mc.cores=1) | ||
args <- c(args, {args_fit}) | ||
CP <- do.call(sequenza.fit, args=args) | ||
sequenza.results(sequenza.extract=seqz, cp.table=CP, sample.id="{snakemake.params[sample_id]}", out.dir=dirname("{snakemake.output.done}")) | ||
__EOF | ||
pushd $(dirname {snakemake.output.done}) ; for f in $(ls) ; do md5sum $f > $f.md5 ; done ; popd | ||
touch {snakemake.output.done} | ||
""" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters