Mercurial > repos > fubar > jbrowse2
changeset 104:9e3f69d9fed1 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit a1537aea75fc902d0e38c0b7c698830a939648b1-dirty
author | fubar |
---|---|
date | Sun, 23 Jun 2024 00:13:57 +0000 |
parents | dc3fe98e7b37 |
children | 33b73d16537a |
files | __pycache__/jbrowse2.cpython-312.pyc jbrowse2.py |
diffstat | 2 files changed, 64 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/jbrowse2.py Sat Jun 22 06:17:01 2024 +0000 +++ b/jbrowse2.py Sun Jun 23 00:13:57 2024 +0000 @@ -2,6 +2,7 @@ import argparse import binascii +import copy import datetime # import hashlib import json @@ -679,8 +680,8 @@ ], "adapter": {"type": "HicAdapter", "hicLocation": {"uri": uri}}, } - self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) - self.trackIdlist.append(tId) + self.tracksToAdd[trackData["assemblyNames"]].append(copy.copy(trackDict)) + self.trackIdlist.append(copy.copy(tId)) def add_maf(self, data, trackData): """ @@ -753,8 +754,8 @@ } style_json = self._prepare_track_style(trackDict) trackDict["style"] = style_json - self.tracksToAdd[gname].append(trackDict) - self.trackIdlist.append(tId) + self.tracksToAdd[gname].append(copy.copy(trackDict)) + self.trackIdlist.append(copy.copy(tId)) if self.config_json.get("plugins", None): self.config_json["plugins"].append(mafPlugin[0]) else: @@ -827,8 +828,8 @@ } style_json = self._prepare_track_style(trackDict) trackDict["style"] = style_json - self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) - self.trackIdlist.append(tId) + self.tracksToAdd[trackData["assemblyNames"]].append(copy.copy(trackDict)) + self.trackIdlist.append(copy.copy(tId)) def add_bam(self, data, trackData, bam_indexes=None, **kwargs): tId = trackData["label"] @@ -884,8 +885,8 @@ } style_json = self._prepare_track_style(trackDict) trackDict["style"] = style_json - self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) - self.trackIdlist.append(tId) + self.tracksToAdd[trackData["assemblyNames"]].append(copy.copy(trackDict)) + self.trackIdlist.append(copy.copy(tId)) def add_cram(self, data, trackData, cram_indexes=None, **kwargs): tId = trackData["label"] @@ -950,8 +951,8 @@ } style_json = self._prepare_track_style(trackDict) trackDict["style"] = style_json - self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) - self.trackIdlist.append(tId) + self.tracksToAdd[trackData["assemblyNames"]].append(copy.copy(trackDict)) + self.trackIdlist.append(copy.copy(tId)) def add_vcf(self, data, trackData): tId = trackData["label"] @@ -1000,8 +1001,8 @@ } style_json = self._prepare_track_style(trackDict) trackDict["style"] = style_json - self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) - self.trackIdlist.append(tId) + self.tracksToAdd[trackData["assemblyNames"]].append(copy.copy(trackDict)) + self.trackIdlist.append(copy.copy(tId)) def _sort_gff(self, data, dest): # Only index if not already done @@ -1063,8 +1064,8 @@ } style_json = self._prepare_track_style(trackDict) trackDict["style"] = style_json - self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) - self.trackIdlist.append(tId) + self.tracksToAdd[trackData["assemblyNames"]].append(copy.copy(trackDict)) + self.trackIdlist.append(copy.copy(tId)) def add_bed(self, data, ext, trackData): tId = trackData["label"] @@ -1112,8 +1113,8 @@ } style_json = self._prepare_track_style(trackDict) trackDict["style"] = style_json - self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) - self.trackIdlist.append(tId) + self.tracksToAdd[trackData["assemblyNames"]].append(copy.copy(trackDict)) + self.trackIdlist.append(copy.copy(tId)) def add_paf(self, data, trackData, pafOpts, **kwargs): tname = trackData["name"] @@ -1147,10 +1148,10 @@ if gname not in self.genome_names: # ignore if already there - eg for duplicates among pafs. asstrack, first_contig = self.make_assembly(gpath, gname, useuri) - self.genome_names.append(gname) + self.genome_names.append(copy.copy(gname)) self.tracksToAdd[gname] = [] - self.assemblies.append(asstrack) - self.ass_first_contigs.append(first_contig) + self.assemblies.append(copy.copy(asstrack)) + self.ass_first_contigs.append(copy.copy(first_contig)) trackDict = { "type": "SyntenyTrack", "trackId": tId, @@ -1194,8 +1195,8 @@ "displayId": "%s-LinearBasicDisplay" % tId, } trackDict["style"] = style_json - self.tracksToAdd[trackData["assemblyNames"]].append(trackDict) - self.trackIdlist.append(tId) + self.tracksToAdd[trackData["assemblyNames"]].append(copy.copy(trackDict)) + self.trackIdlist.append(copy.copy(tId)) def process_annotations(self, track): category = track["category"].replace("__pd__date__pd__", TODAY) @@ -1311,6 +1312,7 @@ else: logging.warning("Do not know how to handle %s", dataset_ext) # Return non-human label for use in other fields + logging.debug("### processanno ext=%s trackstoadd = %s" % (dataset_ext, self.tracksToAdd)) yield outputTrackConfig["label"] def add_default_session(self, default_data): @@ -1338,16 +1340,23 @@ tId = track_conf["trackId"] if tId in default_data[gnome]["visibility"]["default_on"]: track_types[tId] = track_conf["type"] - style_data = default_data[gnome]["style"].get(tId, None) + style_data = default_data[gnome]["style"].get(tId, {}) if not style_data: logging.debug( - "### No style data for %s in available default data %s" + "No style data for %s in available default data %s" % (tId, default_data) ) - style_data = {"type": "LinearBasicDisplay"} - if "displays" in track_conf: - disp = track_conf["displays"][0]["type"] - style_data["type"] = disp + else: + logging.debug( + "style data for %s = %s" + % (tId, style_data) + ) + + if style_data.get('type',None): + style_data["type"] = "LinearBasicDisplay" + if "displays" in track_conf: + disp = track_conf["displays"][0]["type"] + style_data["type"] = disp if track_conf.get("style_labels", None): # TODO fix this: it should probably go in a renderer block (SvgFeatureRenderer) but still does not work # TODO move this to per track displays? @@ -1551,8 +1560,9 @@ def parse_style_conf(item): if item.text.lower() in ["false", "true", "yes", "no"]: return item.text.lower in ("yes", "true") - else: - return item.text + elif item.text.isdigit(): + return int(item.text) + return item.text if __name__ == "__main__": @@ -1632,28 +1642,27 @@ ) ) else: - if trackfiles: - metadata = metadata_from_node(x.find("metadata")) - track_conf["dataset_id"] = metadata.get( - "dataset_id", "None" + metadata = metadata_from_node(x.find("metadata")) + track_conf["dataset_id"] = metadata.get( + "dataset_id", "None" + ) + if x.attrib["useuri"].lower() == "yes": + tfa = ( + x.attrib["path"], + x.attrib["ext"], + x.attrib["useuri"], + track_conf["label"], + metadata, ) - if x.attrib["useuri"].lower() == "yes": - tfa = ( - x.attrib["path"], - x.attrib["ext"], - x.attrib["useuri"], - track_conf["label"], - metadata, - ) - else: - tfa = ( - os.path.realpath(x.attrib["path"]), - x.attrib["ext"], - x.attrib["useuri"], - track_conf["label"], - metadata, - ) - track_conf["trackfiles"].append(tfa) + else: + tfa = ( + os.path.realpath(x.attrib["path"]), + x.attrib["ext"], + x.attrib["useuri"], + track_conf["label"], + metadata, + ) + track_conf["trackfiles"].append(tfa) if is_multi_bigwig: metadata = metadata_from_node(x.find("metadata")) @@ -1670,7 +1679,6 @@ track_conf["category"] = track.attrib["cat"] track_conf["format"] = track.attrib["format"] track_conf["conf"] = etree_to_dict(track.find("options")) - logging keys = jc.process_annotations(track_conf) if keys: for key in keys: @@ -1684,11 +1692,10 @@ if trak["trackId"] == key: stile = trak.get("style", {}) if track.find("options/style"): - supdate = { - item.tag: parse_style_conf(item) - for item in track.find("options/style") - } - stile.update(supdate) + for item in track.find("options/style"): + if item.text: + stile[item.tag] = parse_style_conf(item) + logging.debug("stile=%s" % stile) default_session_data[primaryGenome]["style"][key] = stile if track.find("options/style_labels"): default_session_data[primaryGenome]["style_labels"][key] = { @@ -1714,6 +1721,7 @@ "font_size": root.find("metadata/general/font_size").text, } jc.add_general_configuration(general_data) + jc.add_default_session(default_session_data) trackconf = jc.config_json.get("tracks", []) for gnome in jc.genome_names: gtracks = jc.tracksToAdd[gnome] @@ -1739,7 +1747,6 @@ ) ) jc.write_config() - jc.add_default_session(default_session_data) # note that this can be left in the config.json but has NO EFFECT if add_defsess_to_index is called. # jc.add_defsess_to_index(default_session_data) # jc.text_index() not sure what broke here.