Mercurial > repos > fubar > jbrowse2
diff jbrowse2.py @ 108:5d1259b88c27 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 9de1453a009c254ab11b16ae8a56cb5c22b131bf
author | fubar |
---|---|
date | Sat, 29 Jun 2024 06:10:22 +0000 |
parents | a074cd6b5905 |
children | 27e9ddaaf325 |
line wrap: on
line diff
--- a/jbrowse2.py Sun Jun 23 06:59:56 2024 +0000 +++ b/jbrowse2.py Sat Jun 29 06:10:22 2024 +0000 @@ -4,7 +4,6 @@ import binascii import copy import datetime -# import hashlib import json import logging import os @@ -21,7 +20,7 @@ logging.basicConfig(level=logging.DEBUG) log = logging.getLogger("jbrowse") -JB2VER = "v2.11.1" +JB2VER = "v2.12.3" # version pinned if cloning - but not cloning now logCommands = True # useful for seeing what's being written but not for production setups @@ -757,7 +756,7 @@ 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]) + self.config_json["plugins"].append(mafPlugin["plugins"][0]) else: self.config_json.update(mafPlugin) @@ -1068,6 +1067,7 @@ self.trackIdlist.append(copy.copy(tId)) def add_bed(self, data, ext, trackData): + bedPlugin = {"name": "BedScorePlugin", "umdLoc": { "uri": "bedscoreplugin.js" } } tId = trackData["label"] categ = trackData["category"] useuri = trackData["useuri"].lower() == "yes" @@ -1077,6 +1077,16 @@ url = tId + ".gz" dest = os.path.join(self.outdir, url) self._sort_bed(data, dest) + if True or trackData.get("usebedscore",None): + bedgzlocation = { + "uri": url, + "columnNames": ["chr","start","end","name","score"], + "scoreColumn": "score", + } + else: + bedgzlocation = { + "uri": url, + } trackDict = { "type": "FeatureTrack", "trackId": tId, @@ -1087,19 +1097,21 @@ categ, ], "type": "BedTabixAdapter", - "bedGzLocation": { - "uri": url, - }, + "bedGzLocation": bedgzlocation, "index": { "location": { "uri": url + ".tbi", - } + }, }, }, "displays": [ { "type": "LinearBasicDisplay", "displayId": "%s-LinearBasicDisplay" % tId, + "renderer": { + "type": "SvgFeatureRenderer", + "color1": "jexl:customColor(feature)", + }, }, { "type": "LinearPileupDisplay", @@ -1113,6 +1125,10 @@ } style_json = self._prepare_track_style(trackDict) trackDict["style"] = style_json + if self.config_json.get("plugins", None): + self.config_json["plugins"].append(bedPlugin) + else: + self.config_json["plugins"] = [bedPlugin,] self.tracksToAdd[trackData["assemblyNames"]].append(copy.copy(trackDict)) self.trackIdlist.append(copy.copy(tId)) @@ -1340,23 +1356,10 @@ 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, {}) - if not style_data: - logging.debug( - "No style data for %s in available default data %s" - % (tId, default_data) - ) - else: - logging.debug( - "style data for %s = %s" - % (tId, style_data) - ) - - if style_data.get('type',None) == None: - style_data["type"] = "LinearBasicDisplay" + display = {"type": "linearBasicDisplay"} if "displays" in track_conf: - disp = track_conf["displays"][0]["type"] - style_data["type"] = disp + display["type"] = track_conf["displays"][0]["type"] + display["configuration"] = track_conf["displays"][0]["displayId"] 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? @@ -1365,7 +1368,7 @@ { "type": track_types[tId], "configuration": tId, - "displays": [style_data], + "displays": [display], } ) first = [x for x in self.ass_first_contigs if x[0] == gnome] @@ -1554,7 +1557,8 @@ os.remove(path) except OSError as e: log.error("Error: %s - %s." % (e.filename, e.strerror)) - shutil.copyfile(os.path.join(INSTALLED_TO, "jb2_webserver.py"), os.path.join(dest, "jb2_webserver.py")) + for neededfile in ["jb2_webserver.py", "bedscoreplugin.js"]: + shutil.copyfile(os.path.join(INSTALLED_TO, neededfile), os.path.join(dest, neededfile)) def parse_style_conf(item): @@ -1627,6 +1631,9 @@ trackfiles = track.findall("files/trackFile") if trackfiles: for x in trackfiles: + isBed = False + if x.attrib['ext'] == "bed": + isBed = True track_conf["label"] = "%s_%d" % ( x.attrib["label"].replace(" ", "_").replace(",", "_").replace("/","_"), trackI, @@ -1675,7 +1682,6 @@ {}, # No metadata for multiple bigwig ) ) - track_conf["category"] = track.attrib["cat"] track_conf["format"] = track.attrib["format"] track_conf["conf"] = etree_to_dict(track.find("options")) @@ -1686,22 +1692,6 @@ if not vis: vis = "default_off" default_session_data[primaryGenome]["visibility"][vis].append(key) - trakdat = jc.tracksToAdd[primaryGenome] - stile = {} - for trak in trakdat: - if trak["trackId"] == key: - stile = trak.get("style", {}) - if track.find("options/style"): - 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] = { - item.tag: parse_style_conf(item) - for item in track.find("options/style_labels") - } default_session_data[primaryGenome]["tracks"].append(key) default_session_data["defaultLocation"] = root.find( "metadata/general/defaultLocation"