Esempio n. 1
0
__author__ = "Johannes Köster, Felix Mölder, Christopher Schröder"
__copyright__ = "Copyright 2017, Johannes Köster"
__email__ = "[email protected], [email protected]"
__license__ = "MIT"

from os import path
from snakemake.shell import shell
from tempfile import TemporaryDirectory

shell.executable("bash")

log = snakemake.log_fmt_shell(stdout=False, stderr=True)

params = snakemake.params.get("extra", "")
norm = snakemake.params.get("normalize", False)

# Infer output format
uncompressed_bcf = snakemake.params.get("uncompressed_bcf", False)
out_name, out_ext = path.splitext(snakemake.output[0])
if out_ext == ".vcf":
    out_format = "v"
elif out_ext == ".bcf":
    if uncompressed_bcf:
        out_format = "u"
    else:
        out_format = "b"
elif out_ext == ".gz":
    out_name, out_ext = path.splitext(out_name)
    if out_ext == ".vcf":
        out_format = "z"
    else:
Esempio n. 2
0
# f = open(snakemake.log.run, 'at')
# f.write("## COMMAND: "+command+"\n")
# f.close()
# shell(command)

# command = "rm "+snakemake.input.bam + ".bai"
# f = open(snakemake.log.run, 'at')
# f.write("## COMMAND: "+command+"\n")
# f.close()
# shell(command)

# else:
TOOL = "umi_tools"
SAMTOOLS = "samtools"

shell.executable("/bin/bash")

version = str(
    subprocess.Popen(SAMTOOLS + " --version 2>&1 | grep \"samtools\" ",
                     shell=True,
                     stdout=subprocess.PIPE).communicate()[0], 'utf-8')
f = open(snakemake.log.run, 'at')
f.write("## VERSION: " + version + "\n")
f.close()

command = TOOL + " dedup -I " + snakemake.input.bam + " -S " + snakemake.output.bam + " --log " + snakemake.output.mtx \
+ " --extract-umi-method=read_id --umi-separator='_' --method=directional --edit-distance-threshold=0 \
--spliced-is-unique --multimapping-detection-method=NH"

f = open(snakemake.log.run, 'at')
f.write("## COMMAND: " + command + "\n")
Esempio n. 3
0
def init_powersnake():
    # pipefail is supported by bash only.
    shell.executable(os.popen('which bash').read().strip())
    shell.prefix('set -e; set -o pipefail; ')
Esempio n. 4
0
import os
from snakemake.shell import shell
from snakemake.utils import makedirs

shell.executable('/bin/bash')

URL = 'https://github.com/lcdb/lcdb-test-data/blob/add-chipseq/data/{}?raw=true'

def _download_file(fn, dest=None):
    url = URL.format(fn)
    if dest is None:
        dest = fn
    makedirs(os.path.dirname(dest))
    basename = os.path.basename(fn)
    shell('wget -q -O- {url} > {dest}')
    return dest

_download_file('rnaseq_samples/sample1/sample1.small_R1.fastq.gz')
_download_file('rnaseq_samples/sample2/sample2.small_R1.fastq.gz')
_download_file('rnaseq_samples/sample3/sample3.small_R1.fastq.gz')
_download_file('rnaseq_samples/sample4/sample4.small_R1.fastq.gz')

shell('mkdir -p data/rnaseq_samples/sample{{1,2,3,4}}')
for n in [1, 2, 3, 4]:
    shell(
        'mv rnaseq_samples/sample{n}/sample{n}.small_R1.fastq.gz '
        'data/rnaseq_samples/sample{n}/sample{n}_R1.fastq.gz'
    )
shell('rm -r rnaseq_samples')
Esempio n. 5
0
def init_powersnake():
    # pipefail is supported by bash only.
    shell.executable(os.popen('which bash').read().strip())
    shell.prefix('set -e; set -o pipefail; ')