# HG changeset patch
# User fubar
# Date 1713674549 0
# Node ID 3c4db8203fadb744c9f90d4828e95dd4b1ddf6ec
# Parent 6246925692cb0c79c91503e52a99c8aebc44dd3b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit f2fba2e6b169256dc9adfa141e3bd59665f08f78
diff -r 6246925692cb -r 3c4db8203fad autogenJB2.py
--- a/autogenJB2.py Thu Apr 18 10:57:29 2024 +0000
+++ b/autogenJB2.py Sun Apr 21 04:42:29 2024 +0000
@@ -143,7 +143,7 @@
sys.stdout.write("#### calling %s" % " ".join(cmd))
jc.subprocess_check_call(cmd)
track_conf.update(
- {"conf": {"options": {"bam": {"bam_index": " %s,%s " % (trackname,ipath)}}}}
+ {"conf": {"options": {"bam": {"bam_index": " %s:%s," % (tpath,ipath)}}}}
)
elif trext == "cram":
ipath = track[3]
@@ -161,7 +161,7 @@
]
jc.subprocess_check_call(cmd)
track_conf.update(
- {"conf": {"options": {"cram": {"cram_index": "%s,%s" % (trackname,ipath)}}}}
+ {"conf": {"options": {"cram": {"cram_index": "%s:%s," % (tpath, ipath)}}}}
)
track_conf["path"] = tpath
track_conf["format"] = trext
diff -r 6246925692cb -r 3c4db8203fad jbrowse2.py
--- a/jbrowse2.py Thu Apr 18 10:57:29 2024 +0000
+++ b/jbrowse2.py Sun Apr 21 04:42:29 2024 +0000
@@ -864,7 +864,7 @@
def add_bam(self, data, trackData, bam_indexes=None, **kwargs):
tId = trackData["label"]
- realFName = trackData["key"]
+ realFName = trackData["path"]
useuri = trackData["useuri"].lower() == "yes"
categ = trackData["category"]
if useuri:
@@ -872,36 +872,24 @@
else:
fname = tId
dest = "%s/%s" % (self.outdir, fname)
+ self.subprocess_check_call(["cp", data, dest])
url = fname
bindex = fname + ".bai"
- self.subprocess_check_call(["cp", data, dest])
- bi = bam_indexes.split()
+ bi = bam_indexes.split(",")
bam_index = [
- x.split(",")[1].strip()
+ x.split(":")[1].strip()
for x in bi
- if "," in x and x.split(",")[0].strip() == realFName
+ if ":" in x and x.split(":")[0].strip() == realFName
]
- if len(bam_index) > 0:
- bam_index = bam_index[0]
- else:
- bam_index = None
logging.debug(
- "===realFName=%s got %s as bi, %s for bam_index"
- % (realFName, bi, bam_index)
+ "===realFName=%s got %s as bam_indexes %s as bi, %s for bam_index"
+ % (realFName, bam_indexes, bi, bam_index)
)
- if bam_index is not None and os.path.exists(bam_index):
- if not os.path.exists(bindex):
- # bai most probably made by galaxy and stored in galaxy dirs, need to copy it to dest
- self.subprocess_check_call(["cp", bam_index, bindex])
- else:
- # Can happen in exotic condition
- # e.g. if bam imported as symlink with datatype=unsorted.bam, then datatype changed to bam
- # => no index generated by galaxy, but there might be one next to the symlink target
- # this trick allows to skip the bam sorting made by galaxy if already done outside
- if os.path.exists(os.path.realpath(data) + ".bai"):
- self.symlink_or_copy(os.path.realpath(data) + ".bai", bindex)
- else:
- log.warn("Could not find a bam index (.bai file) for %s", data)
+ if len(bam_index) > 0 and os.path.exists(os.path.realpath(bam_index[0])):
+ self.subprocess_check_call(["cp", bam_index[0], bindex])
+ else:
+ cmd = ["samtools", "index", "-b", "-o", bindex, data]
+ self.subprocess_check_call(cmd)
trackDict = {
"type": "AlignmentsTrack",
"trackId": tId,
@@ -933,7 +921,7 @@
def add_cram(self, data, trackData, cram_indexes=None, **kwargs):
tId = trackData["label"]
- realFName = trackData["key"]
+ realFName = trackData["path"]
categ = trackData["category"]
useuri = trackData["useuri"].lower() == "yes"
gsa = self.assmeta.get(trackData["assemblyNames"], None)
@@ -949,25 +937,21 @@
dest = os.path.join(self.outdir, fname)
url = fname
self.subprocess_check_call(["cp", data, dest])
- ci = cram_indexes.split()
+ ci = cram_indexes.split(",")
cram_index = [
- x.split(",")[1].strip()
+ x.split(":")[1].strip()
for x in ci
- if "," in x and x.split(",")[0] == realFName
+ if ":" in x and x.split(":")[0].strip() == realFName
]
- if len(cram_index) > 0:
- cram_index = cram_index[0]
- else:
- cram_index = None
logging.debug(
- "=== for %s got %s as cram_indexes, %s for cram_index"
- % (realFName, cram_indexes, cram_index)
+ "===realFName=%s got %s as cram_indexes %s as ci, %s for cram_index"
+ % (realFName, cram_indexes, ci, cram_index)
)
- if cram_index and os.path.exists(cram_index):
+ if len(cram_index) > 0 and os.path.exists(cram_index[0]):
if not os.path.exists(dest + ".crai"):
# most probably made by galaxy and stored in galaxy dirs, need to copy it to dest
self.subprocess_check_call(
- ["cp", os.path.realpath(cram_index), dest + ".crai"]
+ ["cp", os.path.realpath(cram_index[0]), dest + ".crai"]
)
else:
cpath = os.path.realpath(dest) + ".crai"
diff -r 6246925692cb -r 3c4db8203fad jbrowse2.xml
--- a/jbrowse2.xml Thu Apr 18 10:57:29 2024 +0000
+++ b/jbrowse2.xml Sun Apr 21 04:42:29 2024 +0000
@@ -232,7 +232,7 @@
#for $dataset in $track.data_format.useuri.annotation:
- ${dataset.name},${dataset.metadata.bam_index}
+ ${dataset}:${dataset.metadata.bam_index},
#end for
@@ -240,7 +240,7 @@
#for $dataset in $track.data_format.useuri.annotation:
- ${dataset.name},${dataset.metadata.cram_index}
+ ${dataset}:${dataset.metadata.cram_index},
#end for