def run_bedtools(): params.i = infile shell.grep('^#', infile, _stdout=outfile) c = shell.Shell(dash='-', equal=' ', subcmd=True).bedtools if unique: c.sort(**params).pipe().uniq(__stdout=outfile).run() else: params.__stdout = outfile c.sort(**params).run()
def run_bedops(): params['max-mem'] = args.mem params.tmpdir = tmpdir params._ = infile shell.grep('^#', infile, _stdout=outfile) c = shell.Shell(equal=' ') if unique: c.bedops(**params).pipe().uniq(__stdout=outfile).run() else: params.__stdout = outfile c.bedops(**params).run()
def run_sort(): params.T = tmpdir params.S = argsmem params.u = unique if sortby == 'coord': params.k = ['1,1', '2,2n'] else: params.k = '4' shell.grep('^#', infile, _stdout=outfile) shell.Shell().grep(v='^#', infile).pipe(dash='-', equal='=').sort(**params, __stdout=outfile).run()
from pyppl import Box from bioprocs.utils.shell import grep, zcat infile = {{i.infile | quote}} outfile = {{o.outfile | quote}} params = {{args.params | repr}} keyword = {{args.keyword | repr}} if not keyword: raise ValueError('A keyword (args.keyword) is required.') params._stdout = outfile if infile.endswith('.gz'): zcat(infile).pipe().grep(_=keyword, **params) else: grep(_=[keyword, infile], **params)
from os import remove from pyppl import Box from bioprocs.utils import shell infiles = {{i.infile | repr}} params = {{args.params | repr}} shell.TOOLS.bedtools = {{args.bedtools | quote}} mergedtmp = '{{job.outdir}}/mergedtmp.bed' mergedtmpsorted = '{{job.outdir}}/mergedtmp.sorted.bed' shell.touch(mergedtmp) for infile in infiles: shell.grep(v='^#', _=infile, __stdout=mergedtmp) shell.sort(k=['1,1', '2,2n'], _=mergedtmp, _stdout=mergedtmpsorted) params.i = mergedtmpsorted params._stdout = outfile shell.Shell(subcmd=True, dash='-', equal=' ').bedtools.merge(**params).run() shell.rm_rf(mergedtmp) shell.rm_rf(mergedtmpsorted)