Mercurial > repos > fubar > jbrowse2
diff jbrowse2.py @ 133:cec274db51c0 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 7d28252954cae9f8db5f8a85d8f29cb2865b504b-dirty
author | fubar |
---|---|
date | Fri, 18 Oct 2024 11:57:55 +0000 |
parents | 1efcc387bef4 |
children | ed3a21033188 |
line wrap: on
line diff
--- a/jbrowse2.py Thu Oct 17 11:58:53 2024 +0000 +++ b/jbrowse2.py Fri Oct 18 11:57:55 2024 +0000 @@ -446,7 +446,7 @@ p = subprocess.Popen( command, cwd=self.outdir, - shell=True, + shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, @@ -554,13 +554,11 @@ else: faname = gname + ".fa.gz" fadest = os.path.realpath(os.path.join(self.outdir, faname)) - cmd = "bgzip -i -c %s -I %s.gzi > %s && samtools faidx %s" % ( - fapath, - fadest, - fadest, - fadest, - ) - self.subprocess_popen(cmd) + cmd = ["bgzip", "-i", "-c", fapath, "-I", fadest + ".gzi"] + with open(fadest, "wb") as fout: + self.subprocess_check_call(cmd, output=fout) + cmd = ["samtools", "faidx", fadest] + self.subprocess_check_call(cmd) contig = open(fadest + ".fai", "r").readline().strip() adapter = { "type": "BgzipFastaAdapter", @@ -957,8 +955,9 @@ else: url = tId dest = os.path.join(self.outdir, url) - cmd = "bgzip -c %s > %s" % (data, dest) - self.subprocess_popen(cmd) + cmd = ["bgzip", "-c", data] + with open(dest, "wb") as fout: + subprocess.run(cmd, stdout=fout) cmd = ["tabix", "-f", "-p", "vcf", dest] self.subprocess_check_call(cmd) trackDict = { @@ -1001,18 +1000,20 @@ def _sort_gff(self, data, dest): # Only index if not already done if not os.path.exists(dest): - cmd = "jbrowse sort-gff '%s' | bgzip -c > '%s'" % ( - data, - dest, - ) - self.subprocess_popen(cmd) + e = os.environ + e['SHELL'] = '/bin/sh' + cmd = ['/bin/sh', '-c', "jbrowse sort-gff %s | bgzip -c > %s" % (data, dest)] + subprocess.run(cmd, env=e) self.subprocess_check_call(["tabix", "-f", "-p", "gff", dest]) def _sort_bed(self, data, dest): # Only index if not already done if not os.path.exists(dest): - cmd = "sort -k1,1 -k2,2n '%s' | bgzip -c > '%s'" % (data, dest) - self.subprocess_popen(cmd) + cmd = ["sort", "-k1,1", "-k2,2n", data] + ps = subprocess.run(cmd, check=True, capture_output=True) + cmd = ["bgzip", "-c"] + with open(dest, "wb") as fout: + subprocess.run(cmd, input=ps.stdout, stdout=fout) cmd = ["tabix", "-f", "-p", "bed", dest] self.subprocess_check_call(cmd) @@ -1130,7 +1131,7 @@ self.trackIdlist.append(tId) def add_paf(self, data, trackData, pafOpts, **kwargs): - canPIF = False + canPIF = True tname = trackData["name"] tId = trackData["label"] url = tId @@ -1138,11 +1139,15 @@ useuri = data.startswith("http://") or data.startswith("https://") if not useuri: if canPIF: - fakeName = '%s.paf' % tId + fakeName = "%s.paf" % tId url = "%s.pif.gz" % tId cmd = ["cp", data, fakeName] self.subprocess_check_call(cmd) - cmd = ["jbrowse", "make-pif", fakeName] # jbrowse pif input.paf --out output.pif.gz # specify output file, creates output.pif.gz.tbi also + cmd = [ + "jbrowse", + "make-pif", + fakeName, + ] # jbrowse pif input.paf --out output.pif.gz # specify output file, creates output.pif.gz.tbi also self.subprocess_check_call(cmd) usePIF = True else: