def process(self, **kw): ext = kw.get('to') or 'sql' outfile = self.temporary_path(ext=ext) info = {'datatype': kw.get('datatype') or 'qualitative'} convert(kw.get('infile'), outfile, chrmeta=kw.get('assembly') or None, info=info) self.new_file(outfile, 'converted_file') return 1
def __call__(self, **kw): ext = kw.get('to') or 'sql' info = {'datatype': kw.get('datatype') or 'qualitative'} infile = kw.get('infile') fname = os.path.splitext(os.path.split(infile)[-1])[0] outfile = self.temporary_path(fname=fname, ext=ext) convert(infile, outfile, chrmeta=kw.get('assembly') or None, info=info) self.new_file(outfile, 'converted_file') return self.display_time()
def __call__(self, **kw): b2wargs = [] control = None sample = kw.get("sample") assert os.path.exists(str(sample)), "Bam file not found: '%s'." % sample if kw.get('control'): control = kw['control'] b2wargs = ["-c", str(control)] assert os.path.exists(str(control)), "Control file not found: '%s'." % control control = os.path.abspath(control) sample = os.path.abspath(sample) nreads = int(kw.get('normalization') or -1) bamfile = track(sample, format='bam') if nreads < 0: if control is None: nreads = len(set((t[4] for t in bamfile.read()))) else: b2wargs += ["-r"] merge_strands = int(kw.get('merge_strands') or -1) read_extension = int(kw.get('read_extension') or -1) output = self.temporary_path(fname='density_') format = kw.get("format", "sql") with execution(None) as ex: files = bam_to_density(ex, sample, output, nreads=nreads, merge=merge_strands, read_extension=read_extension, sql=True, args=b2wargs) if merge_strands >= 0: suffixes = ["merged"] else: suffixes = ["fwd", "rev"] for n, x in enumerate(files): tsql = track(x, format='sql', fields=['start', 'end', 'score'], chrmeta=bamfile.chrmeta, info={'datatype': 'quantitative'}) tsql.save() if format == "sql": outname = x else: outname = os.path.splitext(x)[0]+"."+format convert(x, outname, mode="overwrite") self.new_file(outname, 'density_'+suffixes[n]) return self.display_time()