comparison jbrowse2.py @ 3:2de9f585505b draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit b30d2e277cc360437a02fa812c577c0c8d997cff-dirty
author fubar
date Tue, 09 Jan 2024 02:35:52 +0000
parents d78175596286
children efc64d8f4b72
comparison
equal deleted inserted replaced
2:37b2c26c7b9b 3:2de9f585505b
17 17
18 logging.basicConfig(level=logging.INFO) 18 logging.basicConfig(level=logging.INFO)
19 log = logging.getLogger("jbrowse") 19 log = logging.getLogger("jbrowse")
20 TODAY = datetime.datetime.now().strftime("%Y-%m-%d") 20 TODAY = datetime.datetime.now().strftime("%Y-%m-%d")
21 GALAXY_INFRASTRUCTURE_URL = None 21 GALAXY_INFRASTRUCTURE_URL = None
22 JB2REL="v2.10.0"
23 # version pinned for cloning
24
22 mapped_chars = { 25 mapped_chars = {
23 ">": "__gt__", 26 ">": "__gt__",
24 "<": "__lt__", 27 "<": "__lt__",
25 "'": "__sq__", 28 "'": "__sq__",
26 '"': "__dq__", 29 '"': "__dq__",
449 fapath = genome_node["path"] 452 fapath = genome_node["path"]
450 assem = self.make_assembly(fapath, genome_name) 453 assem = self.make_assembly(fapath, genome_name)
451 assemblies.append(assem) 454 assemblies.append(assem)
452 self.genome_names.append(genome_name) 455 self.genome_names.append(genome_name)
453 if self.genome_name is None: 456 if self.genome_name is None:
454 self.genome_name = genome_name # first one for all tracks - other than paf 457 self.genome_name = (
458 genome_name # first one for all tracks - other than paf
459 )
455 if self.config_json.get("assemblies", None): 460 if self.config_json.get("assemblies", None):
456 self.config_json["assemblies"] += assemblies 461 self.config_json["assemblies"] += assemblies
457 else: 462 else:
458 self.config_json["assemblies"] = assemblies 463 self.config_json["assemblies"] = assemblies
459 464
504 "--target", 509 "--target",
505 self.config_json_file, 510 self.config_json_file,
506 "-v", 511 "-v",
507 " LinearGenomeView", 512 " LinearGenomeView",
508 ] 513 ]
509 if self.debug:
510 log.info("### calling set-default-session with cmd=%s" % " ".join(cmd))
511 self.subprocess_check_call(cmd) 514 self.subprocess_check_call(cmd)
512 515
513 def write_config(self): 516 def write_config(self):
514 with open(self.config_json_file, "w") as fp: 517 with open(self.config_json_file, "w") as fp:
515 json.dump(self.config_json, fp) 518 json.dump(self.config_json, fp)
590 """ 593 """
591 mafPlugin = { 594 mafPlugin = {
592 "plugins": [ 595 "plugins": [
593 { 596 {
594 "name": "MafViewer", 597 "name": "MafViewer",
595 "url": "https://unpkg.com/jbrowse-plugin-mafviewer/dist/jbrowse-plugin-mafviewer.umd.production.min.js", 598 "url": "https://unpkg.com/browse/jbrowse-plugin-mafviewer@1.0.6/dist/jbrowse-plugin-mafviewer.umd.production.min.js",
596 } 599 }
597 ] 600 ]
598 } 601 }
599 tId = trackData["label"] 602 tId = trackData["label"]
600 fname = "%s.bed" % tId 603 fname = "%s.bed" % tId
933 def add_paf(self, data, trackData, pafOpts, **kwargs): 936 def add_paf(self, data, trackData, pafOpts, **kwargs):
934 tname = trackData["name"] 937 tname = trackData["name"]
935 tId = trackData["label"] 938 tId = trackData["label"]
936 pgname = pafOpts["genome_label"] 939 pgname = pafOpts["genome_label"]
937 if len(pgname.split() > 1): 940 if len(pgname.split() > 1):
938 pgname = pgname.split()[0] # trouble from spacey names in command lines avoidance 941 pgname = pgname.split()[
942 0
943 ] # trouble from spacey names in command lines avoidance
939 asstrack, gname = self.make_assembly(pafOpts["genome"], pgname) 944 asstrack, gname = self.make_assembly(pafOpts["genome"], pgname)
940 self.genome_names.append(pgname) 945 self.genome_names.append(pgname)
941 if self.config_json.get("assemblies", None): 946 if self.config_json.get("assemblies", None):
942 self.config_json["assemblies"].append(asstrack) 947 self.config_json["assemblies"].append(asstrack)
943 else: 948 else:
944 self.config_json["assemblies"] = [asstrack,] 949 self.config_json["assemblies"] = [
950 asstrack,
951 ]
945 952
946 style_json = self._prepare_track_style(trackData) 953 style_json = self._prepare_track_style(trackData)
947 url = "%s.paf" % (trackData["label"]) 954 url = "%s.paf" % (trackData["label"])
948 dest = "%s/%s" % (self.outdir, url) 955 dest = "%s/%s" % (self.outdir, url)
949 self.symlink_or_copy(os.path.realpath(data), dest) 956 self.symlink_or_copy(os.path.realpath(data), dest)
1254 json.dump(config_json, config_file, indent=2) 1261 json.dump(config_json, config_file, indent=2)
1255 1262
1256 def clone_jbrowse(self): 1263 def clone_jbrowse(self):
1257 """Clone a JBrowse directory into a destination directory.""" 1264 """Clone a JBrowse directory into a destination directory."""
1258 dest = self.outdir 1265 dest = self.outdir
1259 cmd = ["jbrowse", "create", "-f", dest] 1266 cmd = ["jbrowse", "create", "-t",JB2REL, "-f", dest]
1260 self.subprocess_check_call(cmd) 1267 self.subprocess_check_call(cmd)
1261 for fn in [ 1268 for fn in [
1262 "asset-manifest.json", 1269 "asset-manifest.json",
1263 "favicon.ico", 1270 "favicon.ico",
1264 "robots.txt", 1271 "robots.txt",
1266 "version.txt", 1273 "version.txt",
1267 "test_data", 1274 "test_data",
1268 ]: 1275 ]:
1269 cmd = ["rm", "-rf", os.path.join(self.outdir, fn)] 1276 cmd = ["rm", "-rf", os.path.join(self.outdir, fn)]
1270 self.subprocess_check_call(cmd) 1277 self.subprocess_check_call(cmd)
1271 cmd = ["cp", os.path.join(INSTALLED_TO, "servejb2.py"), self.outdir] 1278 cmd = ["cp", os.path.join(INSTALLED_TO, "webserver.py"), self.outdir]
1272 self.subprocess_check_call(cmd) 1279 self.subprocess_check_call(cmd)
1273 1280
1274 1281
1275 def parse_style_conf(item): 1282 def parse_style_conf(item):
1276 if "type" in item.attrib and item.attrib["type"] in ["boolean", "integer"]: 1283 if "type" in item.attrib and item.attrib["type"] in ["boolean", "integer"]: