SEX.DETERRMINE
calculate the relative coverage of X and Y chromosomes, and their associated error bars, out of capture data.
Example
This wrapper can be used in the following way:
rule test_sexdeterrmine:
input:
depth="samples.depth.tsv",
output:
tsv="results.tsv",
json="results.json",
threads: 1
log:
"sexdeterrmine.log",
wrapper:
"v5.5.2-17-g33d5b76/bio/sexdeterrmine"
Note that input, output and log file paths can be chosen freely.
When running with
snakemake --use-conda
the software dependencies will be automatically deployed into an isolated environment before execution.
Notes
See depth header format at: https://github.com/TCLamnidis/Sex.DetERRmine/tree/master?tab=readme-ov-file#instructions
Software dependencies
sexdeterrmine=1.1.2
Input/Output
Input:
depth
: Path to samtools depths file accross multiple samples with a header line giving sample names.
Output:
Path to result table
Params
No extra parameters handled.
:
Code
# coding: utf-8
"""Snakemake wrapper for Sex.DetERRmine"""
__author__ = "Thibault Dayris"
__copyright__ = "Copyright 2024, Thibault Dayris"
__email__ = "thibault.dayris@gustaveroussy.fr"
__license__ = "MIT"
from snakemake.shell import shell
from tempfile import TemporaryDirectory
import os
import os.path
log = snakemake.log_fmt_shell(
stdout=False,
stderr=True,
append=False,
)
extra = snakemake.params.get("extra", "")
with TemporaryDirectory() as tempdir:
old_path = os.getcwd()
depth_path = os.path.realpath(snakemake.input.depth)
os.chdir(tempdir)
shell(f"sexdeterrmine --Input {depth_path} {extra} > out.tsv 2> sexdeterrmine.log")
log = snakemake.log_fmt_shell(
stdout=True,
stderr=True,
append=True,
)
os.chdir(old_path)
os.replace(f"{tempdir}/sexdeterrmine.log", str(snakemake.log))
tsv = snakemake.output.get("tsv")
if tsv:
shell("mv --verbose {tempdir}/out.tsv {tsv} {log}")
json = snakemake.output.get("json")
if json:
shell("mv --verbose {tempdir}/sexdeterrmine.json {json} {log}")