def run_vardict(): params.v = True params.G = ref params.b = infile params._stdout = outfile Shell().vardict(**params).run() if gz: shell.gzip(outfile)
def run_elprep(): elpsh = Shell(subcmd = True, equal = ' ').elprep params['log-path'] = joboutdir params['nr-of-threads'] = nthread params['sorting-order'] = sortby if steps.sort else 'keep' params['mark-duplicates'] = steps.markdup params['remove-duplicates'] = steps.rmdup params[''] = [infile, outfile] if steps.markdup: params['mark-optical-duplicates'] = path.join(joboutdir, inprefix + '.opticaldups.txt') if steps.recal: params['bqsr'] = path.join(joboutdir, inprefix + '.bqsr.txt') params['bqsr-reference'] = ref + '.elprep' if knownSites: params['known-sites'] = knownSites elpsh.filter(**params).run() if steps.index: subshell.samtools.index(outfile, outfile + '.bai')
def run_picard(): global infile mem = mem2(argsmem, '-jdict') mem['-Djava.io.tmpdir'] = tmpdir shellpicard = Shell(subcmd = True, dash = '', equal = '=').picard(**mem) if not (steps.sort or steps.index or steps.markdup or steps.rmdup): shellpicard.SamFormatConverter(TMP_DIR = tmpdir, I = infile, O = outfile).run() else: bamfile = outfile if steps.sort: bamfile = path.join(joboutdir, inprefix + '.sorted.bam') shellpicard.ShortSam(TMP_DIR = tmpdir, I = infile, O = bamfile, SO = sortby).run() if infile != {{i.infile | quote}}: shell.rm(f = True, _ = infile) infile = bamfile if steps.markdup: mfile = "/dev/null" bamfile = path.join(joboutdir, inprefix + '.dedup.bam') shellpicard.MarkDuplicates(REMOVE_DUPLICATES = 'true' if steps.rmdup else 'false', TMP_DIR = tmpdir, I = infile, O = bamfile, M = mfile).run() if infile != {{i.infile | quote}}: shell.rm(f = True, _ = infile) infile = bamfile if steps.index: shellpicard.BuildBamIndex(TMP_DIR = tmpdir, I = infile, O = outfile + '.bai').run() if infile != outfile: if path.exists(infile + '.bai'): shell.mv(infile + '.bai', outfile + '.bai') shell.mv(infile, outfile)
def run_gatk(): gatkmem = mem2(mem, 'jdict') gatkmem['Djava.io.tmpdir={!r}'.format(tmpdir)] = True gatksh = Shell(equal = ' ', dash = '-') params.T = 'HaplotypeCaller' params.R = ref params.I = infile params.o = outfile params.nct = nthread params._ = list(gatkmem.keys()) gatksh(**params).run() if gz: shell.gzip(outfile)
def run_biobambam(): mem = mem2(argsmem, 'M') if steps.index: params.index = 1 params.indexfilename = outfile + '.bai' params.I = infile params.O = outfile params.SO = sortby params.blockme = mem params.tmpfile = path.join(tmpdir, 'biobambam.tmp') params.inputformat = infmt params.outfmt = 'bam' params.inputthreads = nthread params.outputthreads = nthread params.markduplicates = int(steps.markdup) params.rmdup = int(steps.rmdup) Shell(dash = '', equal = '=').biobambam(**params).run()
def run_samtools(): shellst = Shell(subcmd=True).samtools params['@'] = nthread shellst.index(_=[infile, outidx]).run()
shell.TOOLS.update(dict( biobambam = biobambam, sambamba = sambamba, samtools = samtools, picard = picard, elprep = elprep )) if steps.rmdup: steps.markdup = True if not path.exists(tmpdir): shell.mkdir(tmpdir, p = True) if steps.recal and tool != 'elprep': raise ValueError('Step "recal" is only enabled by "elprep", use pBamRecal for other tools.') subshell = Shell(subcmd = True) def run_biobambam(): mem = mem2(argsmem, 'M') if steps.index: params.index = 1 params.indexfilename = outfile + '.bai' params.I = infile params.O = outfile params.SO = sortby params.blockme = mem params.tmpfile = path.join(tmpdir, 'biobambam.tmp') params.inputformat = infmt params.outfmt = 'bam' params.inputthreads = nthread