Mercurial > repos > fubar > jbrowse2
comparison jbrowse2.py @ 89:408781c080fc draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 03400b3f71140ce62dba0db266a1f7b94b6c1a11
author | fubar |
---|---|
date | Wed, 17 Apr 2024 22:18:47 +0000 |
parents | 3b2ff9864995 |
children | 3c4db8203fad |
comparison
equal
deleted
inserted
replaced
88:efd1d41f11b4 | 89:408781c080fc |
---|---|
19 logging.basicConfig(level=logging.DEBUG) | 19 logging.basicConfig(level=logging.DEBUG) |
20 log = logging.getLogger("jbrowse") | 20 log = logging.getLogger("jbrowse") |
21 | 21 |
22 JB2VER = "v2.10.3" | 22 JB2VER = "v2.10.3" |
23 # version pinned if cloning - but not cloning now | 23 # version pinned if cloning - but not cloning now |
24 | 24 logCommands = True |
25 # useful for seeing what's being written but not for production setups | |
25 TODAY = datetime.datetime.now().strftime("%Y-%m-%d") | 26 TODAY = datetime.datetime.now().strftime("%Y-%m-%d") |
26 SELF_LOCATION = os.path.dirname(os.path.realpath(__file__)) | 27 SELF_LOCATION = os.path.dirname(os.path.realpath(__file__)) |
27 GALAXY_INFRASTRUCTURE_URL = None | 28 GALAXY_INFRASTRUCTURE_URL = None |
28 mapped_chars = { | 29 mapped_chars = { |
29 ">": "__gt__", | 30 ">": "__gt__", |
425 return subprocess.check_output(["pwd"]).decode("utf-8").strip() | 426 return subprocess.check_output(["pwd"]).decode("utf-8").strip() |
426 # return None | 427 # return None |
427 | 428 |
428 def subprocess_check_call(self, command, output=None, cwd=True): | 429 def subprocess_check_call(self, command, output=None, cwd=True): |
429 if output: | 430 if output: |
430 log.debug("cd %s && %s > %s", self.get_cwd(cwd), " ".join(command), output) | 431 if logCommands: |
432 log.debug( | |
433 "cd %s && %s > %s", self.get_cwd(cwd), " ".join(command), output | |
434 ) | |
431 subprocess.check_call(command, cwd=self.get_cwd(cwd), stdout=output) | 435 subprocess.check_call(command, cwd=self.get_cwd(cwd), stdout=output) |
432 else: | 436 else: |
433 log.debug("cd %s && %s", self.get_cwd(cwd), " ".join(command)) | 437 if logCommands: |
438 log.debug("cd %s && %s", self.get_cwd(cwd), " ".join(command)) | |
434 subprocess.check_call(command, cwd=self.get_cwd(cwd)) | 439 subprocess.check_call(command, cwd=self.get_cwd(cwd)) |
435 | 440 |
436 def subprocess_popen(self, command, cwd=True): | 441 def subprocess_popen(self, command, cwd=True): |
437 log.debug(command) | 442 if logCommands: |
443 log.debug(command) | |
438 p = subprocess.Popen( | 444 p = subprocess.Popen( |
439 command, | 445 command, |
440 cwd=self.get_cwd(cwd), | 446 cwd=self.get_cwd(cwd), |
441 shell=True, | 447 shell=True, |
442 stdin=subprocess.PIPE, | 448 stdin=subprocess.PIPE, |
450 log.error(output) | 456 log.error(output) |
451 log.error(err) | 457 log.error(err) |
452 raise RuntimeError("Command failed with exit code %s" % (retcode)) | 458 raise RuntimeError("Command failed with exit code %s" % (retcode)) |
453 | 459 |
454 def subprocess_check_output(self, command): | 460 def subprocess_check_output(self, command): |
455 log.debug(" ".join(command)) | 461 if logCommands: |
462 log.debug(" ".join(command)) | |
456 return subprocess.check_output(command, cwd=self.outdir) | 463 return subprocess.check_output(command, cwd=self.outdir) |
457 | 464 |
458 def symlink_or_copy(self, src, dest): | 465 def symlink_or_copy(self, src, dest): |
459 if "GALAXY_JBROWSE_SYMLINKS" in os.environ and bool( | 466 if "GALAXY_JBROWSE_SYMLINKS" in os.environ and bool( |
460 os.environ["GALAXY_JBROWSE_SYMLINKS"] | 467 os.environ["GALAXY_JBROWSE_SYMLINKS"] |
489 with urllib.request.urlopen(url, context=scontext) as f: | 496 with urllib.request.urlopen(url, context=scontext) as f: |
490 fl = f.readlines() | 497 fl = f.readlines() |
491 nrow = len(fl) | 498 nrow = len(fl) |
492 except Exception: | 499 except Exception: |
493 nrow = 0 | 500 nrow = 0 |
494 logging.debug("### getNrow returning %d" % nrow) | 501 logging.debug("### getNrow %s returning %d" % (url, nrow)) |
495 return nrow | 502 return nrow |
496 | 503 |
497 def process_genomes(self, genomes): | 504 def process_genomes(self, genomes): |
498 assembly = [] | 505 assembly = [] |
499 assmeta = [] | 506 assmeta = [] |
500 useuri = False | 507 useuri = False |
501 genome_names = [] | 508 primaryGenome = None |
502 for i, genome_node in enumerate(genomes): | 509 for i, genome_node in enumerate(genomes): |
503 this_genome = {} | 510 this_genome = {} |
504 if genome_node["useuri"] == "yes": | 511 if genome_node["useuri"] == "yes": |
505 useuri = True | 512 useuri = True |
506 genome_name = genome_node["label"].strip() | 513 genome_name = genome_node["label"].strip() |
507 if len(genome_name) == 0: | 514 if len(genome_name) == 0: |
508 genome_name = os.path.splitext(os.path.basename(genome_node["path"]))[0] | 515 genome_name = os.path.splitext(os.path.basename(genome_node["path"]))[0] |
509 if len(genome_name.split()) > 1: | 516 if len(genome_name.split()) > 1: |
510 genome_name = genome_name.split()[0] | 517 genome_name = genome_name.split()[0] |
511 # spaces and cruft break scripts when substituted | 518 # spaces and cruft break scripts when substituted |
512 if genome_name not in genome_names: | 519 if not primaryGenome: |
513 # pafs with shared references | 520 primaryGenome = genome_name |
521 if genome_name not in self.genome_names: | |
522 self.genome_names.append(genome_name) | |
514 fapath = genome_node["path"] | 523 fapath = genome_node["path"] |
515 if not useuri: | 524 if not useuri: |
516 fapath = os.path.realpath(fapath) | 525 fapath = os.path.realpath(fapath) |
517 assem, first_contig = self.make_assembly(fapath, genome_name, useuri) | 526 assem, first_contig = self.make_assembly(fapath, genome_name, useuri) |
518 assembly.append(assem) | 527 assembly.append(assem) |
519 self.ass_first_contigs.append(first_contig) | 528 self.ass_first_contigs.append(first_contig) |
520 if len(genome_names) == 0: | 529 if genome_name == primaryGenome: # first one |
521 this_genome["genome_name"] = genome_name # first one for all tracks | 530 this_genome["genome_name"] = genome_name # first one for all tracks |
522 genome_names.append(genome_name) | |
523 this_genome["genome_sequence_adapter"] = assem["sequence"][ | 531 this_genome["genome_sequence_adapter"] = assem["sequence"][ |
524 "adapter" | 532 "adapter" |
525 ] | 533 ] |
526 this_genome["genome_firstcontig"] = None | 534 this_genome["genome_firstcontig"] = None |
527 if not useuri: | 535 if not useuri: |
549 this_genome["genome_firstcontig"] = ( | 557 this_genome["genome_firstcontig"] = ( |
550 fl.decode("utf8").strip().split()[0] | 558 fl.decode("utf8").strip().split()[0] |
551 ) | 559 ) |
552 assmeta.append(this_genome) | 560 assmeta.append(this_genome) |
553 self.assemblies += assembly | 561 self.assemblies += assembly |
554 self.assmeta[genome_names[0]] = assmeta | 562 self.assmeta[primaryGenome] = assmeta |
555 self.tracksToAdd[genome_names[0]] = [] | 563 self.tracksToAdd[primaryGenome] = [] |
556 self.genome_names += genome_names | 564 return primaryGenome |
557 return this_genome["genome_name"] | |
558 | 565 |
559 def make_assembly(self, fapath, gname, useuri): | 566 def make_assembly(self, fapath, gname, useuri): |
560 """added code to grab the first contig name and length for broken default session from Anthony and Helena's code | 567 """added code to grab the first contig name and length for broken default session from Anthony and Helena's code |
561 that poor Bjoern is trying to figure out. | 568 that poor Bjoern is trying to figure out. |
562 """ | 569 """ |
741 mafss = [x for x in mafs if (x.startswith("s\t") or x.startswith("s "))] | 748 mafss = [x for x in mafs if (x.startswith("s\t") or x.startswith("s "))] |
742 samp = [x.split()[1] for x in mafss if len(x.split()) > 0] | 749 samp = [x.split()[1] for x in mafss if len(x.split()) > 0] |
743 sampu = list(dict.fromkeys(samp)) | 750 sampu = list(dict.fromkeys(samp)) |
744 samples = [x.split(".")[0] for x in sampu] | 751 samples = [x.split(".")[0] for x in sampu] |
745 samples.sort() | 752 samples.sort() |
746 logging.debug( | 753 if logCommands: |
747 "$$$$ cmd=%s, mafss=%s samp=%s samples=%s" | 754 logging.debug( |
748 % (" ".join(cmd), mafss, samp, samples) | 755 "$$$$ cmd=%s, mafss=%s samp=%s samples=%s" |
749 ) | 756 % (" ".join(cmd), mafss, samp, samples) |
757 ) | |
750 trackDict = { | 758 trackDict = { |
751 "type": "MafTrack", | 759 "type": "MafTrack", |
752 "trackId": tId, | 760 "trackId": tId, |
753 "name": trackData["name"], | 761 "name": trackData["name"], |
754 "category": [ | 762 "category": [ |
1170 nrow = self.getNrow(dest) | 1178 nrow = self.getNrow(dest) |
1171 else: | 1179 else: |
1172 url = data | 1180 url = data |
1173 nrow = self.getNrow(url) | 1181 nrow = self.getNrow(url) |
1174 categ = trackData["category"] | 1182 categ = trackData["category"] |
1175 pgnames = [x.strip() for x in pafOpts["genome_label"].split(",")] | 1183 pg = pafOpts["genome"].split(",") |
1176 pgpaths = [ | 1184 pgc = [x.strip() for x in pg if x.strip() > ""] |
1177 x.strip() for x in pafOpts["genome"].split(",") if len(x.strip()) > 0 | 1185 gnomes = [x.split(":") for x in pgc] |
1178 ] | |
1179 passnames = [trackData["assemblyNames"]] # always first | 1186 passnames = [trackData["assemblyNames"]] # always first |
1180 for i, gp in enumerate(pgpaths): | 1187 for i, (gpath, gname) in enumerate(gnomes): |
1181 if len(pgnames[i].strip()) == 0: | 1188 # may have been forgotten by user for uri |
1182 # user may have left it blank - cannot make non-optional if want optional tracks. | 1189 if len(gname) == 0: |
1183 gn = os.path.basename(gp) | 1190 gn = os.path.basename(gpath) |
1184 pgnames[i] = os.path.splitext(gn)[0] | 1191 gname = os.path.splitext(gn)[0] |
1185 logging.debug( | 1192 # trouble from spacey names in command lines avoidance |
1186 "### add_paf got pafOpts=%s, pgnames=%s, pgpaths=%s for %s" | |
1187 % (pafOpts, pgnames, pgpaths, tId) | |
1188 ) | |
1189 for i, gp in enumerate(pgpaths): | |
1190 gname = pgnames[i] | |
1191 if len(gname.split()) > 1: | 1193 if len(gname.split()) > 1: |
1192 gname = gname.split()[0] | 1194 gname = gname.split()[0] |
1193 passnames.append(gname) | 1195 if gname not in passnames: |
1194 # trouble from spacey names in command lines avoidance | 1196 passnames.append(gname) |
1195 useuri = gp.startswith("http://") or gp.startswith("https://") | 1197 useuri = gpath.startswith("http://") or gpath.startswith("https://") |
1196 | |
1197 if gname not in self.genome_names: | 1198 if gname not in self.genome_names: |
1198 # ignore if already there - eg for duplicates among pafs. | 1199 # ignore if already there - eg for duplicates among pafs. |
1199 asstrack, first_contig = self.make_assembly(gp, gname, useuri) | 1200 asstrack, first_contig = self.make_assembly(gpath, gname, useuri) |
1200 self.genome_names.append(gname) | 1201 self.genome_names.append(gname) |
1201 self.tracksToAdd[gname] = [] | 1202 self.tracksToAdd[gname] = [] |
1202 self.assemblies.append(asstrack) | 1203 self.assemblies.append(asstrack) |
1204 self.ass_first_contigs.append(first_contig) | |
1203 trackDict = { | 1205 trackDict = { |
1204 "type": "SyntenyTrack", | 1206 "type": "SyntenyTrack", |
1205 "trackId": tId, | 1207 "trackId": tId, |
1206 "assemblyNames": passnames, | 1208 "assemblyNames": passnames, |
1207 "category": [ | 1209 "category": [ |
1269 outputTrackConfig["useuri"] = useuri | 1271 outputTrackConfig["useuri"] = useuri |
1270 outputTrackConfig["path"] = dataset_path | 1272 outputTrackConfig["path"] = dataset_path |
1271 outputTrackConfig["ext"] = dataset_ext | 1273 outputTrackConfig["ext"] = dataset_ext |
1272 | 1274 |
1273 outputTrackConfig["trackset"] = track.get("trackset", {}) | 1275 outputTrackConfig["trackset"] = track.get("trackset", {}) |
1274 outputTrackConfig["label"] = "%s_%d.%s" % ( | 1276 outputTrackConfig["label"] = track["label"] |
1275 track_human_label, | |
1276 self.trackCounter, | |
1277 dataset_ext, | |
1278 ) | |
1279 self.trackCounter += 1 | |
1280 outputTrackConfig["metadata"] = extra_metadata | 1277 outputTrackConfig["metadata"] = extra_metadata |
1281 outputTrackConfig["name"] = track_human_label | 1278 outputTrackConfig["name"] = track_human_label |
1282 | 1279 if track["label"] in self.trackIdlist: |
1280 logging.error( | |
1281 "### not adding %s already in %s" | |
1282 % (track["label"], self.trackIdlist) | |
1283 ) | |
1284 yield None | |
1283 if dataset_ext in ("gff", "gff3"): | 1285 if dataset_ext in ("gff", "gff3"): |
1284 self.add_gff( | 1286 self.add_gff( |
1285 dataset_path, | 1287 dataset_path, |
1286 outputTrackConfig, | 1288 outputTrackConfig, |
1287 ) | 1289 ) |
1414 "type": "LinearGenomeView", | 1416 "type": "LinearGenomeView", |
1415 "offsetPx": 0, | 1417 "offsetPx": 0, |
1416 "minimized": False, | 1418 "minimized": False, |
1417 "tracks": tracks_data, | 1419 "tracks": tracks_data, |
1418 } | 1420 } |
1419 logging.debug( | |
1420 "Looking for %s in self.ass_ %s" % (gnome, self.ass_first_contigs) | |
1421 ) | |
1422 first = [x for x in self.ass_first_contigs if x[0] == gnome] | 1421 first = [x for x in self.ass_first_contigs if x[0] == gnome] |
1423 if len(first) > 0: | 1422 if len(first) > 0: |
1424 [gnome, refName, end] = first[0] | 1423 [gnome, refName, end] = first[0] |
1425 start = 0 | 1424 start = 0 |
1426 end = int(end) | 1425 end = int(end) |
1475 with open(self.config_json_file, "w") as config_file: | 1474 with open(self.config_json_file, "w") as config_file: |
1476 json.dump(self.config_json, config_file, indent=2) | 1475 json.dump(self.config_json, config_file, indent=2) |
1477 | 1476 |
1478 def add_defsess_to_index(self, data): | 1477 def add_defsess_to_index(self, data): |
1479 """ | 1478 """ |
1479 PROBABLY NOW BROKEN by changes since this was deprecated temporarily as at April 18 | |
1480 | |
1480 Included on request of the new codeowner, from Anthony's IUC PR. | 1481 Included on request of the new codeowner, from Anthony's IUC PR. |
1481 Had to be fixed to keep each assembly with the associated tracks for a default view. | 1482 Had to be fixed to keep each assembly with the associated tracks for a default view. |
1482 Originally used only the first assembly, putting all tracks there and so breaking some | 1483 Originally used only the first assembly, putting all tracks there and so breaking some |
1483 when tested with 2 or more. | 1484 when tested with 2 or more. |
1484 | 1485 |
1624 GALAXY_INFRASTRUCTURE_URL = "http://" + GALAXY_INFRASTRUCTURE_URL | 1625 GALAXY_INFRASTRUCTURE_URL = "http://" + GALAXY_INFRASTRUCTURE_URL |
1625 | 1626 |
1626 jc = JbrowseConnector(outdir=args.outdir, jbrowse2path=args.jbrowse2path) | 1627 jc = JbrowseConnector(outdir=args.outdir, jbrowse2path=args.jbrowse2path) |
1627 | 1628 |
1628 default_session_data = {} | 1629 default_session_data = {} |
1630 trackI = 0 | |
1629 for ass in root.findall("assembly"): | 1631 for ass in root.findall("assembly"): |
1630 genomes = [ | 1632 genomes = [ |
1631 { | 1633 { |
1632 "path": x.attrib["path"], | 1634 "path": x.attrib["path"], |
1633 "label": x.attrib["label"], | 1635 "label": x.attrib["label"], |
1634 "useuri": x.attrib["useuri"], | 1636 "useuri": x.attrib["useuri"], |
1635 "meta": metadata_from_node(x.find("metadata")), | 1637 "meta": metadata_from_node(x.find("metadata")), |
1636 } | 1638 } |
1637 for x in ass.findall("metadata/genomes/genome") | 1639 for x in ass.findall("metadata/genomes/genome") |
1638 ] | 1640 ] |
1639 assref_name = jc.process_genomes(genomes) | 1641 primaryGenome = jc.process_genomes(genomes) |
1640 if not default_session_data.get(assref_name, None): | 1642 if not default_session_data.get(primaryGenome, None): |
1641 default_session_data[assref_name] = { | 1643 default_session_data[primaryGenome] = { |
1642 "tracks": [], | 1644 "tracks": [], |
1643 "style": {}, | 1645 "style": {}, |
1644 "style_labels": {}, | 1646 "style_labels": {}, |
1645 "visibility": { | 1647 "visibility": { |
1646 "default_on": [], | 1648 "default_on": [], |
1648 }, | 1650 }, |
1649 } | 1651 } |
1650 for track in ass.find("tracks"): | 1652 for track in ass.find("tracks"): |
1651 track_conf = {} | 1653 track_conf = {} |
1652 track_conf["trackfiles"] = [] | 1654 track_conf["trackfiles"] = [] |
1653 track_conf["assemblyNames"] = assref_name | 1655 track_conf["assemblyNames"] = primaryGenome |
1654 is_multi_bigwig = False | 1656 is_multi_bigwig = False |
1655 try: | 1657 try: |
1656 if track.find("options/wiggle/multibigwig") and ( | 1658 if track.find("options/wiggle/multibigwig") and ( |
1657 track.find("options/wiggle/multibigwig").text == "True" | 1659 track.find("options/wiggle/multibigwig").text == "True" |
1658 ): | 1660 ): |
1662 pass | 1664 pass |
1663 | 1665 |
1664 trackfiles = track.findall("files/trackFile") | 1666 trackfiles = track.findall("files/trackFile") |
1665 if trackfiles: | 1667 if trackfiles: |
1666 for x in trackfiles: | 1668 for x in trackfiles: |
1667 track_conf["label"] = x.attrib["label"] | 1669 track_conf["label"] = "%s_%d" % (x.attrib["label"], trackI) |
1670 trackI += 1 | |
1668 track_conf["useuri"] = x.attrib["useuri"] | 1671 track_conf["useuri"] = x.attrib["useuri"] |
1669 if is_multi_bigwig: | 1672 if is_multi_bigwig: |
1670 multi_bigwig_paths.append( | 1673 multi_bigwig_paths.append( |
1671 ( | 1674 ( |
1672 x.attrib["label"], | 1675 track_conf["label"], |
1673 x.attrib["useuri"], | 1676 track_conf["useuri"], |
1674 os.path.realpath(x.attrib["path"]), | 1677 os.path.realpath(x.attrib["path"]), |
1675 ) | 1678 ) |
1676 ) | 1679 ) |
1677 else: | 1680 else: |
1678 if trackfiles: | 1681 if trackfiles: |
1683 if x.attrib["useuri"].lower() == "yes": | 1686 if x.attrib["useuri"].lower() == "yes": |
1684 tfa = ( | 1687 tfa = ( |
1685 x.attrib["path"], | 1688 x.attrib["path"], |
1686 x.attrib["ext"], | 1689 x.attrib["ext"], |
1687 x.attrib["useuri"], | 1690 x.attrib["useuri"], |
1688 x.attrib["label"], | 1691 track_conf["label"], |
1689 metadata, | 1692 metadata, |
1690 ) | 1693 ) |
1691 else: | 1694 else: |
1692 tfa = ( | 1695 tfa = ( |
1693 os.path.realpath(x.attrib["path"]), | 1696 os.path.realpath(x.attrib["path"]), |
1694 x.attrib["ext"], | 1697 x.attrib["ext"], |
1695 x.attrib["useuri"], | 1698 x.attrib["useuri"], |
1696 x.attrib["label"], | 1699 track_conf["label"], |
1697 metadata, | 1700 metadata, |
1698 ) | 1701 ) |
1699 track_conf["trackfiles"].append(tfa) | 1702 track_conf["trackfiles"].append(tfa) |
1700 | 1703 |
1701 if is_multi_bigwig: | 1704 if is_multi_bigwig: |
1712 | 1715 |
1713 track_conf["category"] = track.attrib["cat"] | 1716 track_conf["category"] = track.attrib["cat"] |
1714 track_conf["format"] = track.attrib["format"] | 1717 track_conf["format"] = track.attrib["format"] |
1715 track_conf["conf"] = etree_to_dict(track.find("options")) | 1718 track_conf["conf"] = etree_to_dict(track.find("options")) |
1716 keys = jc.process_annotations(track_conf) | 1719 keys = jc.process_annotations(track_conf) |
1717 | |
1718 if keys: | 1720 if keys: |
1719 for key in keys: | 1721 for key in keys: |
1720 vis = track.attrib.get("visibility", "default_off") | 1722 vis = track.attrib.get("visibility", "default_off") |
1721 if not vis: | 1723 if not vis: |
1722 vis = "default_off" | 1724 vis = "default_off" |
1723 default_session_data[assref_name]["visibility"][vis].append(key) | 1725 default_session_data[primaryGenome]["visibility"][vis].append(key) |
1724 trakdat = jc.tracksToAdd[assref_name] | 1726 trakdat = jc.tracksToAdd[primaryGenome] |
1725 stile = {} | 1727 stile = {} |
1726 for trak in trakdat: | 1728 for trak in trakdat: |
1727 if trak["trackId"] == key: | 1729 if trak["trackId"] == key: |
1728 stile = trak.get("style", {}) | 1730 stile = trak.get("style", {}) |
1729 if track.find("options/style"): | 1731 if track.find("options/style"): |
1730 supdate = { | 1732 supdate = { |
1731 item.tag: parse_style_conf(item) | 1733 item.tag: parse_style_conf(item) |
1732 for item in track.find("options/style") | 1734 for item in track.find("options/style") |
1733 } | 1735 } |
1734 stile.update(supdate) | 1736 stile.update(supdate) |
1735 default_session_data[assref_name]["style"][key] = stile | 1737 default_session_data[primaryGenome]["style"][key] = stile |
1736 logging.debug("@@@ for %s got style=%s" % (key, stile)) | |
1737 if track.find("options/style_labels"): | 1738 if track.find("options/style_labels"): |
1738 default_session_data[assref_name]["style_labels"][key] = { | 1739 default_session_data[primaryGenome]["style_labels"][key] = { |
1739 item.tag: parse_style_conf(item) | 1740 item.tag: parse_style_conf(item) |
1740 for item in track.find("options/style_labels") | 1741 for item in track.find("options/style_labels") |
1741 } | 1742 } |
1742 default_session_data[assref_name]["tracks"].append(key) | 1743 default_session_data[primaryGenome]["tracks"].append(key) |
1743 default_session_data["defaultLocation"] = root.find( | 1744 default_session_data["defaultLocation"] = root.find( |
1744 "metadata/general/defaultLocation" | 1745 "metadata/general/defaultLocation" |
1745 ).text | 1746 ).text |
1746 default_session_data["session_name"] = root.find( | 1747 default_session_data["session_name"] = root.find( |
1747 "metadata/general/session_name" | 1748 "metadata/general/session_name" |
1748 ).text | 1749 ).text |
1749 logging.debug("default_session=%s" % (default_session_data)) | 1750 logging.debug("default_session=%s" % (json.dumps(default_session_data, indent=2))) |
1750 jc.zipOut = root.find("metadata/general/zipOut").text == "true" | 1751 jc.zipOut = root.find("metadata/general/zipOut").text == "true" |
1751 general_data = { | 1752 general_data = { |
1752 "analytics": root.find("metadata/general/analytics").text, | 1753 "analytics": root.find("metadata/general/analytics").text, |
1753 "primary_color": root.find("metadata/general/primary_color").text, | 1754 "primary_color": root.find("metadata/general/primary_color").text, |
1754 "secondary_color": root.find("metadata/general/secondary_color").text, | 1755 "secondary_color": root.find("metadata/general/secondary_color").text, |
1757 "font_size": root.find("metadata/general/font_size").text, | 1758 "font_size": root.find("metadata/general/font_size").text, |
1758 } | 1759 } |
1759 jc.add_general_configuration(general_data) | 1760 jc.add_general_configuration(general_data) |
1760 trackconf = jc.config_json.get("tracks", []) | 1761 trackconf = jc.config_json.get("tracks", []) |
1761 for gnome in jc.genome_names: | 1762 for gnome in jc.genome_names: |
1762 trackconf += jc.tracksToAdd[gnome] | 1763 gtracks = jc.tracksToAdd[gnome] |
1764 if len(gtracks) > 0: | |
1765 logging.debug( | |
1766 "for genome %s adding gtracks %s" | |
1767 % (gnome, json.dumps(gtracks, indent=2)) | |
1768 ) | |
1769 trackconf += gtracks | |
1763 jc.config_json["tracks"] = trackconf | 1770 jc.config_json["tracks"] = trackconf |
1764 assconf = jc.config_json.get("assemblies", []) | 1771 assconf = jc.config_json.get("assemblies", []) |
1765 assconf += jc.assemblies | 1772 assconf += jc.assemblies |
1766 jc.config_json["assemblies"] = assconf | 1773 jc.config_json["assemblies"] = assconf |
1767 logging.debug("assemblies=%s, gnames=%s" % (assconf, jc.genome_names)) | 1774 logging.debug( |
1775 "assmeta=%s, first_contigs=%s, assemblies=%s, gnames=%s, trackidlist=%s, tracks=%s" | |
1776 % ( | |
1777 jc.assmeta, | |
1778 jc.ass_first_contigs, | |
1779 json.dumps(assconf, indent=2), | |
1780 jc.genome_names, | |
1781 jc.trackIdlist, | |
1782 json.dumps(trackconf, indent=2), | |
1783 ) | |
1784 ) | |
1768 jc.write_config() | 1785 jc.write_config() |
1769 jc.add_default_session(default_session_data) | 1786 jc.add_default_session(default_session_data) |
1770 # note that this can be left in the config.json but has NO EFFECT if add_defsess_to_index is called. | 1787 # note that this can be left in the config.json but has NO EFFECT if add_defsess_to_index is called. |
1771 # jc.add_defsess_to_index(default_session_data) | 1788 # jc.add_defsess_to_index(default_session_data) |
1772 # jc.text_index() not sure what broke here. | 1789 # jc.text_index() not sure what broke here. |