from sys import stderr from pyppl import Box from os import path from bioprocs.utils import shell, mem2 from bioprocs.utils.poll import Poll from bioprocs.utils.shell import Shell from bioprocs.utils.reference import bamIndex infile = {{i.infile | quote}} bamIndex(infile, samtools=None) outfile = {{o.outfile | quote}} outprefix = {{o.outfile | prefix | quote}} tool = {{args.tool | quote}} gatk = {{args.gatk | quote}} samtools = {{args.samtools | quote}} picard = {{args.picard | quote}} bamutil = {{args.bamutil | quote}} params = {{args.params | repr}} ref = {{args.ref | quote}} tmpdir = {{args.tmpdir | quote}} knownSites = {{args.knownSites | quote}} argsmem = {{args.mem | quote}} nthread = {{args.nthread | quote}} joboutdir = {{job.outdir | quote}} joblen = {{proc.size | repr}} jobindex = {{job.index | repr}} workdir = {{proc.workdir | quote}} tmpdir = path.join(tmpdir, "{{proc.id}}.{{i.infile | fn}}.{{job.index}}") # pass the index file shell.ln_s(infile + '.bai', outfile + '.bai') if not path.exists(tmpdir):
from pyppl import Box from bioprocs.utils import shell, runcmd, cmdargs from bioprocs.utils.reference import bamIndex infiles = {{i.infiles | repr}} exbaits = {{args.exbaits | repr}} accfile = {{args.accfile | repr}} ref = {{args.ref | repr}} params = {{args.params | repr}} prefix = {{i.infiles | fs2name | quote}} outdir = {{job.outdir | quote}} cnvkit = {{args.cnvkit | quote}} nthread = {{args.nthread | repr}} for infile in infiles: bamIndex(infile) shell.TOOLS['cnvkit'] = cnvkit envs = dict(OPENBLAS_NUM_THREADS=str(nthread), OMP_NUM_THREADS=str(nthread), NUMEXPR_NUM_THREADS=str(nthread), MKL_NUM_THREADS=str(nthread)) ckshell = shell.Shell(subcmd=True, equal=' ', envs=envs, cwd=outdir).cnvkit # generate target file params_t = params.target params_t.o = path.join(outdir, prefix + '.bed') ckshell.target(exbaits, **params_t).run() # generate access file if not accfile:
prefix = {{i.infile | fn2 | quote}} tool = {{args.tool | quote}} gz = {{args.gz | bool}} outfile = {{o.outfile | quote}} params = {{args.params | repr}} samtools = {{args.samtools | quote}} mem = {{args.mem | quote}} nthread = {{args.nthread | repr}} gatk = {{args.gatk | quote}} cfgParams = {{args.cfgParams | repr}} platypus = {{args.platypus | quote}} ssniffer = {{args.snvsniffer | quote}} strelka = {{args.strelka | quote}} vardict = {{ args.vardict | quote}} joboutdir = {{job.outdir | quote}} bamIndex(infile, samtools = None, nthread = nthread) shell.TOOLS.update(dict( gatk = gatk, platypus = platypus, ssniffer = ssniffer, strelka = strelka, vardict = vardict )) if not path.exists(ref): raise ValueError("Reference file not specified") tmpdir = path.join(tmpdir, "{procid}.{prefix}.{jobindex}".format( jobindex = jobindex, procid = procid, prefix = prefix
nprefix = {{i.normal | fn2 | quote}} tool = {{args.tool | quote}} gz = {{args.gz | bool}} outfile = {{o.outfile | quote}} params = {{args.params | repr}} samtools = {{args.samtools | quote}} mem = {{args.mem | quote}} nthread = {{args.nthread | repr}} gatk = {{args.gatk | quote}} ssniper = {{args.somaticsniper | quote}} ssniffer = {{args.snvsniffer | quote}} strelka = {{args.strelka | quote}} virmid = {{ args.virmid | quote}} vardict = {{ args.vardict | quote}} joboutdir = {{job.outdir | quote}} bamIndex(tumor, samtools = None, nthread = nthread) bamIndex(normal, samtools = None, nthread = nthread) if tprefix == nprefix: tprefix = tprefix + '_TUMOR' nprefix = nprefix + '_NORMAL' if gz: # remove ending .gz outfile = outfile[:-3] if not path.exists (ref): stderr.write ("Reference file not specified") exit (1) tmpdir = path.join (tmpdir, "{procid}.{tprefix}.{nprefix}.{jobindex}".format(
{% python from os import path %} itvfile = {{ i.itvfile | quote}} prefix = {{ o.outdir | path.join: fn(i.itvfile) | quote }} tumbam = {{ i.tumbam | quote}} tumsnp = {{ o.outdir | path.join: fn(i.tumbam) | @append: '.bamrc' | quote}} normbam = {{ i.normbam | quote}} normsnp = {{ o.outdir | path.join: fn(i.normbam) | @append: '.bamrc' | quote}} outdir = {{ o.outdir | quote}} params = {{ args.params | repr}} bamrc = {{ args.bam_readcount | quote }} nthread = {{ args.nthread | repr}} affysnps = {{ args.affysnps | quote}} ref = {{ args.ref | quote}} theta = {{ args.theta | quote}} bamIndex(tumbam, samtools = None, nthread = nthread) bamIndex(normbam, samtools = None, nthread = nthread) if not path.isfile(ref): raise ValueError('A reference fasta file is required to extract allele counts.') if not path.isfile(affysnps): raise ValueError('A snp list is required.') def getAlleleCount(bamfile, snpfile, outfile): brcparams = Box() brcparams.f = ref brcparams.w = 0 brcparams.l = snpfile brcparams[''] = bamfile