# HG changeset patch # User fubar # Date 1711950029 0 # Node ID 7bb6259ea52f1165bfb9987d77a81788c9f129c3 # Parent 3dcda36b97b4b3834f82f62f4da4c6e7aa07174c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit d03454f949af9f3fff638f6a3e52fe42bc96be3b-dirty diff -r 3dcda36b97b4 -r 7bb6259ea52f jbrowse2.py --- a/jbrowse2.py Mon Apr 01 04:35:23 2024 +0000 +++ b/jbrowse2.py Mon Apr 01 05:40:29 2024 +0000 @@ -403,9 +403,7 @@ def __init__(self, outdir, jbrowse2path): self.assemblies = [] # these require more than a few line diff. self.assmeta = {} - self.ass_first_contigs = ( - [] - ) # for default session - these are read as first line of the assembly .fai + self.ass_first_contigs = [] # for default session - these are read as first line of the assembly .fai self.giURL = GALAXY_INFRASTRUCTURE_URL self.outdir = outdir self.jbrowse2path = jbrowse2path @@ -1372,6 +1370,7 @@ config_json.update(self.config_json) if "defaultSession" in config_json: session_json = config_json["defaultSession"] + session_views = [] else: session_json = {} session_views = [] @@ -1404,30 +1403,37 @@ # paf genomes have no tracks associated so nothing for the view if len(tracks_data) > 0: view_json = {"type": "LinearGenomeView", "tracks": tracks_data} - refName = self.assmeta[gnome][0].get("genome_firstcontig", None) - drdict = { - "reversed": False, - "assemblyName": gnome, - "start": 0, - "end": 100000, - "refName": refName, - } - ddl = default_data.get("defaultLocation", None) - if ddl: - loc_match = re.search(r"^([^:]+):([\d,]*)\.*([\d,]*)$", ddl) - # allow commas like 100,000 but ignore as integer - if loc_match: - refName = loc_match.group(1) - drdict["refName"] = refName - if loc_match.group(2) > "": - drdict["start"] = int(loc_match.group(2).replace(",", "")) - if loc_match.group(3) > "": - drdict["end"] = int(loc_match.group(3).replace(",", "")) - else: - logging.info( - "@@@ regexp could not match contig:start..end in the supplied location %s - please fix" - % ddl - ) + logging.debug("Looking for %s in self.ass_ %s" % (gnome, self.ass_first_contigs)) + first = [x for x in self.ass_first_contigs if x[0] == gnome] + if len(first) > 0: + [gnome, refName, end] = first[0] + start = 1 + end = int(end) + refName = self.assmeta[gnome][0].get("genome_firstcontig", None) + drdict = { + "reversed": False, + "assemblyName": gnome, + "start": start, + "end": end, + "refName": refName, + } + else: + ddl = default_data.get("defaultLocation", None) + if ddl: + loc_match = re.search(r"^([^:]+):([\d,]*)\.*([\d,]*)$", ddl) + # allow commas like 100,000 but ignore as integer + if loc_match: + refName = loc_match.group(1) + drdict["refName"] = refName + if loc_match.group(2) > "": + drdict["start"] = int(loc_match.group(2).replace(",", "")) + if loc_match.group(3) > "": + drdict["end"] = int(loc_match.group(3).replace(",", "")) + else: + logging.info( + "@@@ regexp could not match contig:start..end in the supplied location %s - please fix" + % ddl + ) if drdict.get("refName", None): # TODO displayedRegions is not just zooming to the region, it hides the rest of the chromosome view_json["displayedRegions"] = [ @@ -1436,7 +1442,7 @@ logging.info("@@@ defaultlocation %s for default session" % drdict) else: logging.info( - "@@@ no contig name found for default session - please add one!" + "@@@ no track location for default session - please add one!" ) session_views.append(view_json) session_name = default_data.get("session_name", "New session") @@ -1490,16 +1496,6 @@ logging.debug("first contig=%s" % self.ass_first_contigs) [gnome, refName, end] = first_contig start = 0 - # if False or data.get("defaultLocation", ""): - # loc_match = re.search( - # r"^([^:]+):([\d,]*)\.*([\d,]*)$", data["defaultLocation"] - # ) - # # loc_match = re.search(r"^(\w+):(\d+)\.+(\d+)$", data["defaultLocation"]) - # if loc_match: - # refName = loc_match.group(1) - # start = int(loc_match.group(2)) - # end = int(loc_match.group(3)) - # else: aview = { "assembly": gnome, "loc": "{}:{}..{}".format(refName, start, end), @@ -1752,6 +1748,6 @@ jc.config_json["assemblies"] = assconf logging.debug("assemblies=%s, gnames=%s" % (assconf, jc.genome_names)) jc.write_config() - # jc.add_default_session(default_session_data) + jc.add_default_session(default_session_data) jc.add_defsess_to_index(default_session_data) # jc.text_index() not sure what broke here.