comparison jbrowse2.py @ 38:07849bf248e3 draft

planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit a74e469a81b38c7142f63de510ae31d3754d1767
author fubar
date Fri, 01 Mar 2024 00:40:38 +0000
parents 7adde511daa1
children 3e7a4ed46551
comparison
equal deleted inserted replaced
37:7adde511daa1 38:07849bf248e3
20 JB2VER = "v2.10.2" 20 JB2VER = "v2.10.2"
21 # version pinned for cloning 21 # version pinned for cloning
22 22
23 TODAY = datetime.datetime.now().strftime("%Y-%m-%d") 23 TODAY = datetime.datetime.now().strftime("%Y-%m-%d")
24 GALAXY_INFRASTRUCTURE_URL = None 24 GALAXY_INFRASTRUCTURE_URL = None
25 JB2REL = "v2.10.1" 25
26 # version pinned for cloning 26 # version pinned for cloning
27 27
28 mapped_chars = { 28 mapped_chars = {
29 ">": "__gt__", 29 ">": "__gt__",
30 "<": "__lt__", 30 "<": "__lt__",
372 ) 372 )
373 return metadata 373 return metadata
374 374
375 375
376 class JbrowseConnector(object): 376 class JbrowseConnector(object):
377 def __init__(self, outdir, genomes): 377 def __init__(self, outdir, jbrowse2path, genomes):
378 self.giURL = GALAXY_INFRASTRUCTURE_URL 378 self.giURL = GALAXY_INFRASTRUCTURE_URL
379 self.outdir = outdir 379 self.outdir = outdir
380 self.jbrowse2path = jbrowse2path
380 os.makedirs(self.outdir, exist_ok=True) 381 os.makedirs(self.outdir, exist_ok=True)
381 self.genome_paths = genomes 382 self.genome_paths = genomes
382 self.genome_name = None 383 self.genome_name = None
383 self.genome_names = [] 384 self.genome_names = []
384 self.trackIdlist = [] 385 self.trackIdlist = []
1306 self.config_json.update(config_json) 1307 self.config_json.update(config_json)
1307 with open(config_path, "w") as config_file: 1308 with open(config_path, "w") as config_file:
1308 json.dump(self.config_json, config_file, indent=2) 1309 json.dump(self.config_json, config_file, indent=2)
1309 1310
1310 def clone_jbrowse(self): 1311 def clone_jbrowse(self):
1311 """Clone a JBrowse directory into a destination directory.""" 1312 """Clone a JBrowse directory into a destination directory. This also works in Biocontainer testing now """
1312 # dest = os.path.realpath(self.outdir)
1313 dest = self.outdir 1313 dest = self.outdir
1314 cmd = ["rm", "-rf", dest + "/*"] 1314 #self.subprocess_check_call(['jbrowse', 'create', dest, '--tag', f"{JB_VER}"])
1315 self.subprocess_check_call(cmd) 1315 shutil.copytree(self.jbrowse2path, dest, dirs_exist_ok=True)
1316 cmd = ["jbrowse", "create", dest, "-t", JB2VER, "-f"]
1317 self.subprocess_check_call(cmd)
1318 for fn in [ 1316 for fn in [
1319 "asset-manifest.json", 1317 "asset-manifest.json",
1320 "favicon.ico", 1318 "favicon.ico",
1321 "robots.txt", 1319 "robots.txt",
1322 "umd_plugin.js", 1320 "umd_plugin.js",
1323 "version.txt", 1321 "version.txt",
1324 "test_data", 1322 "test_data",
1325 ]: 1323 ]:
1326 cmd = ["rm", "-rf", os.path.join(self.outdir, fn)] 1324 cmd = ["rm", "-rf", os.path.join(dest, fn)]
1327 self.subprocess_check_call(cmd) 1325 self.subprocess_check_call(cmd)
1328 cmd = [ 1326 cmd = ["cp", os.path.join(INSTALLED_TO, "jb2_webserver.py"), dest]
1329 "cp",
1330 os.path.join(INSTALLED_TO, "jb2_webserver.py"),
1331 self.outdir,
1332 ]
1333 self.subprocess_check_call(cmd) 1327 self.subprocess_check_call(cmd)
1334 1328
1335 1329
1336 def parse_style_conf(item): 1330 def parse_style_conf(item):
1337 if "type" in item.attrib and item.attrib["type"] in [ 1331 if "type" in item.attrib and item.attrib["type"] in [
1347 1341
1348 1342
1349 if __name__ == "__main__": 1343 if __name__ == "__main__":
1350 parser = argparse.ArgumentParser(description="", epilog="") 1344 parser = argparse.ArgumentParser(description="", epilog="")
1351 parser.add_argument("--xml", help="Track Configuration") 1345 parser.add_argument("--xml", help="Track Configuration")
1346 parser.add_argument("--jbrowse2path", help="Path to JBrowse2 directory in biocontainer or Conda")
1352 parser.add_argument("--outdir", help="Output directory", default="out") 1347 parser.add_argument("--outdir", help="Output directory", default="out")
1353 parser.add_argument("--version", "-V", action="version", version="%(prog)s 2.0.1") 1348 parser.add_argument("--version", "-V", action="version", version="%(prog)s 2.0.1")
1354 args = parser.parse_args() 1349 args = parser.parse_args()
1355 tree = ET.parse(args.xml) 1350 tree = ET.parse(args.xml)
1356 root = tree.getroot() 1351 root = tree.getroot()
1362 # so we'll prepend `http://` and hope for the best. Requests *should* 1357 # so we'll prepend `http://` and hope for the best. Requests *should*
1363 # be GET and not POST so it should redirect OK 1358 # be GET and not POST so it should redirect OK
1364 GALAXY_INFRASTRUCTURE_URL = "http://" + GALAXY_INFRASTRUCTURE_URL 1359 GALAXY_INFRASTRUCTURE_URL = "http://" + GALAXY_INFRASTRUCTURE_URL
1365 jc = JbrowseConnector( 1360 jc = JbrowseConnector(
1366 outdir=args.outdir, 1361 outdir=args.outdir,
1362 jbrowse2path=args.jbrowse2path,
1367 genomes=[ 1363 genomes=[
1368 { 1364 {
1369 "path": os.path.realpath(x.attrib["path"]), 1365 "path": os.path.realpath(x.attrib["path"]),
1370 "meta": metadata_from_node(x.find("metadata")), 1366 "meta": metadata_from_node(x.find("metadata")),
1371 } 1367 }