# HG changeset patch # User fubar # Date 1711332605 0 # Node ID 81d53597019652eb80414c81b595a6e9f2168c1a # Parent f807e219cec33d7a04404f86a621019528370496 planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit 403a35e1245fa5e62f4be6116a725b9e4d9c353a diff -r f807e219cec3 -r 81d535970196 autogenJB2.py --- a/autogenJB2.py Fri Mar 22 22:04:08 2024 +0000 +++ b/autogenJB2.py Mon Mar 25 02:10:05 2024 +0000 @@ -172,8 +172,7 @@ for key in keys: if trext in [ "bigwig", - "gff3", - "gff", + "gff", "gff3", "vcf", "maf", ]: @@ -182,6 +181,16 @@ default_session_data["visibility"]["default_off"].append( key ) + if trext in ["gff", "gff3", "bed", "vcf", "maf", "blastxml"]: + ttype = "LinearBasicDisplay" + if trext == "vcf": + ttype = "LinearVariantDisplay" + style_json = { + "type": ttype, + "trackShowLabels": False, + "trackShowDescriptions": False + } + default_session_data["style"][key] = style_json # general_data = { # "analytics": root.find("metadata/general/analytics").text, # "primary_color": root.find("metadata/general/primary_color").text, diff -r f807e219cec3 -r 81d535970196 jbrowse2.py --- a/jbrowse2.py Fri Mar 22 22:04:08 2024 +0000 +++ b/jbrowse2.py Mon Mar 25 02:10:05 2024 +0000 @@ -1,5 +1,5 @@ #!/usr/bin/env python -# change to accumulating all configuration for config.json based on the default from the clone + import argparse import binascii import datetime @@ -24,8 +24,6 @@ TODAY = datetime.datetime.now().strftime("%Y-%m-%d") GALAXY_INFRASTRUCTURE_URL = None -# version pinned for cloning - mapped_chars = { ">": "__gt__", "<": "__lt__", @@ -458,7 +456,7 @@ genome_name = genome_name.split()[0] # spaces and cruft break scripts when substituted if genome_name not in self.genome_names: - # ignore dupes - can have multiple pafs with same references? + # pafs with shared references fapath = genome_node["path"] if not useuri: fapath = os.path.realpath(fapath) @@ -467,7 +465,7 @@ self.genome_names.append(genome_name) if self.genome_name is None: self.genome_name = ( - genome_name # first one for all tracks - other than paf + genome_name # first one for all tracks ) self.genome_sequence_adapter = assem["sequence"]["adapter"] self.genome_firstcontig = None @@ -481,11 +479,16 @@ else: self.genome_firstcontig = fl else: - fl = urllib.request.urlopen(fapath + ".fai").readline() + try: + fl = urllib.request.urlopen(fapath + ".fai").readline() + except: + fl = None if fl: # is first row of the text fai so the first contig name self.genome_firstcontig = ( fl.decode("utf8").strip().split()[0] ) + else: + self.genome_firstcontig = None if self.config_json.get("assemblies", None): self.config_json["assemblies"] += assemblies else: @@ -606,6 +609,8 @@ gziLocation: uri: 'https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/fasta/GRCh38.fa.gz.gzi', Cool will not be likely to be a good fit - see discussion at https://github.com/GMOD/jbrowse-components/issues/2438 + + """ tId = trackData["label"] # can be served - if public. @@ -615,29 +620,25 @@ if useuri: uri = data else: - uri = trackData["hic_url"] + uri = "%s.hic" % trackData["label"] + # slashes in names cause path trouble + dest = os.path.join(self.outdir, uri) + cmd = ["cp", data, dest] + self.subprocess_check_call(cmd) categ = trackData["category"] trackDict = { "type": "HicTrack", "trackId": tId, - "name": uri, + "name": trackData["name"], "assemblyNames": [self.genome_name], "category": [ categ, ], "adapter": { "type": "HicAdapter", - "hicLocation": uri, - }, - "displays": [ - { - "type": "LinearHicDisplay", - "displayId": "%s-LinearHicDisplay" % tId, - }, - ], + "hicLocation": { "uri": uri } + } } - style_json = self._prepare_track_style(trackDict) - trackDict["style"] = style_json self.tracksToAdd.append(trackDict) self.trackIdlist.append(tId) @@ -793,14 +794,6 @@ os.unlink(gff3) def add_bigwig(self, data, trackData): - """ "type": "LinearWiggleDisplay", - "configuration": {}, - "selectedRendering": "", - "resolution": 1, - "posColor": "rgb(228, 26, 28)", - "negColor": "rgb(255, 255, 51)", - "constraints": {} - """ useuri = trackData["useuri"].lower() == "yes" if useuri: url = data @@ -1278,26 +1271,23 @@ def add_default_session(self, default_data): """ - Add some default session settings: set some assemblies/tracks on/off + default session settings are hard and fragile. + .add_default_view() and other configuration code adapted from + https://github.com/abretaud/tools-iuc/blob/jbrowse2/tools/jbrowse2/jbrowse2.py """ tracks_data = [] - # TODO using the default session for now, but check out session specs in the future https://github.com/GMOD/jbrowse-components/issues/2708 - - # We need to know the track type from the config.json generated just before track_types = {} with open(self.config_json_file, "r") as config_file: config_json = json.load(config_file) if self.config_json: config_json.update(self.config_json) - for track_conf in self.tracksToAdd: - track_types[track_conf["trackId"]] = track_conf["type"] tId = track_conf["trackId"] - #if tId in data["visibility"]["default_on"]: + track_types[tId] = track_conf["type"] style_data = default_data["style"].get(tId, None) if not style_data: - logging.warn("### No style data in default data for %s" % tId) + logging.warn("### No style data in default data %s for %s" % (default_data, tId)) style_data = {"type": "LinearBasicDisplay"} if "displays" in track_conf: disp = track_conf["displays"][0]["type"] @@ -1315,7 +1305,7 @@ ) # The view for the assembly we're adding view_json = {"type": "LinearGenomeView", "tracks": tracks_data} - + logging.warn("### view_json=%s" % view_json) refName = None drdict = { "reversed": False, @@ -1408,8 +1398,10 @@ with open(config_path, "w") as config_file: json.dump(self.config_json, config_file, indent=2) - def clone_jbrowse(self, realclone=True): - """Clone a JBrowse directory into a destination directory. This also works in Biocontainer testing now""" + def clone_jbrowse(self, realclone=False): + """Clone a JBrowse directory into a destination directory. This also works in Biocontainer testing now + Leave as True between version updates on temporary tools - requires manual conda trigger :( + """ dest = self.outdir if realclone: self.subprocess_check_call( @@ -1472,7 +1464,6 @@ ) jc.process_genomes() - # .add_default_view() replace from https://github.com/abretaud/tools-iuc/blob/jbrowse2/tools/jbrowse2/jbrowse2.py default_session_data = { "visibility": { "default_on": [], @@ -1500,6 +1491,7 @@ if trackfiles: for x in track.findall("files/trackFile"): track_conf["label"] = x.attrib["label"] + trackkey = track_conf["label"] track_conf["useuri"] = x.attrib["useuri"] if is_multi_bigwig: multi_bigwig_paths.append( @@ -1544,18 +1536,6 @@ ) track_conf["category"] = track.attrib["cat"] track_conf["format"] = track.attrib["format"] - if track.find("options/style"): - track_conf["style"] = { - item.tag: parse_style_conf(item) for item in track.find("options/style") - } - else: - track_conf["style"] = {} - if track.find("options/style_labels"): - track_conf["style_labels"] = { - item.tag: parse_style_conf(item) - for item in track.find("options/style_labels") - } - track_conf["conf"] = etree_to_dict(track.find("options")) track_conf["category"] = track.attrib["cat"] track_conf["format"] = track.attrib["format"] @@ -1566,12 +1546,20 @@ default_session_data["visibility"][ track.attrib.get("visibility", "default_off") ].append(key) - if track_conf.get("style", None): - default_session_data["style"][key] = track_conf["style"] - if track_conf.get("style_lables", None): - default_session_data["style_labels"][key] = track_conf.get( - "style_labels", None - ) + if track.find("options/style"): + default_session_data["style"][key] = { + item.tag: parse_style_conf(item) for item in track.find("options/style") + } + logging.warn("### added %s to defsess %s for %s" % (trackkey, default_session_data, key )) + else: + default_session_data["style"][key] = {} + logging.warn("@@@@ no options/style found for %s" % (key)) + + if track.find("options/style_labels"): + default_session_data["style_labels"][key] = { + item.tag: parse_style_conf(item) + for item in track.find("options/style_labels") + } default_session_data["defaultLocation"] = root.find( "metadata/general/defaultLocation" ).text diff -r f807e219cec3 -r 81d535970196 jbrowse2.xml --- a/jbrowse2.xml Fri Mar 22 22:04:08 2024 +0000 +++ b/jbrowse2.xml Mon Mar 25 02:10:05 2024 +0000 @@ -11,12 +11,8 @@ python '${__tool_directory__}/jbrowse2.py' --version + - + - + - - #else if $track.data_format.useuri.insource == "history": #if $track.data_format.useuri.annotation: @@ -157,7 +151,6 @@ #for $dataset in $track.data_format.useuri.annotation: - #end for - - - + #end if + #if str($track.data_format.data_format_select) in ["bam", "cram"]: + LinearAlignmentsDisplay + #end if + #if str($track.data_format.data_format_select) in ["paf"]: + LinearBasicDisplay + #end if + #if str($track.data_format.data_format_select) in ["hic"]: + LinearHicDisplay + #end if + #if str($track.data_format.data_format_select) == "bam": #for $dataset in $track.data_format.useuri.annotation: @@ -268,8 +265,6 @@ #end if - #end if - #end if #end for #end for diff -r f807e219cec3 -r 81d535970196 macros.xml --- a/macros.xml Fri Mar 22 22:04:08 2024 +0000 +++ b/macros.xml Mon Mar 25 02:10:05 2024 +0000 @@ -542,12 +542,12 @@ - - + help="Multiple references can be used for mashmap PAF. A URI source requires all the associated tabix index files to be in place."> + + - + @@ -559,7 +559,7 @@ - +