Mercurial > repos > fubar > jbrowse2
diff jbrowse2.py @ 31:cb4b32ca9968 draft
planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit 48bc917d34af182e9158915862c8a35723660919-dirty
author | fubar |
---|---|
date | Fri, 23 Feb 2024 07:15:42 +0000 |
parents | 8f02a84ee278 |
children | fe48ed5810bd |
line wrap: on
line diff
--- a/jbrowse2.py Wed Feb 21 02:57:30 2024 +0000 +++ b/jbrowse2.py Fri Feb 23 07:15:42 2024 +0000 @@ -450,22 +450,24 @@ if len(genome_name.split()) > 1: genome_name = genome_name.split()[0] # spaces and cruft break scripts when substituted - fapath = genome_node["path"] - assem = self.make_assembly(fapath, genome_name) - assemblies.append(assem) - 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 - ) - self.genome_firstcontig = None - fl = open(fapath, "r").readline().strip().split(">") - if len(fl) > 1: - fl = fl[1] - if len(fl.split()) > 1: - self.genome_firstcontig = fl.split()[0].strip() - else: - self.genome_firstcontig = fl + if genome_name not in self.genome_names: + # ignore dupes - can have multiple pafs with same references? + fapath = genome_node["path"] + assem = self.make_assembly(fapath, genome_name) + assemblies.append(assem) + 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 + ) + self.genome_firstcontig = None + fl = open(fapath, "r").readline().strip().split(">") + if len(fl) > 1: + fl = fl[1] + if len(fl.split()) > 1: + self.genome_firstcontig = fl.split()[0].strip() + else: + self.genome_firstcontig = fl if self.config_json.get("assemblies", None): self.config_json["assemblies"] += assemblies else: @@ -1013,26 +1015,31 @@ def add_paf(self, data, trackData, pafOpts, **kwargs): tname = trackData["name"] tId = trackData["label"] - pgname = pafOpts["genome_label"] - if len(pgname.split()) > 1: - pgname = pgname.split()[ - 0 - ] # trouble from spacey names in command lines avoidance - asstrack = self.make_assembly(pafOpts["genome"], pgname) - self.genome_names.append(pgname) - if self.config_json.get("assemblies", None): - self.config_json["assemblies"].append(asstrack) - else: - self.config_json["assemblies"] = [ - asstrack, - ] + pgnames = [x.strip() for x in pafOpts["genome_label"].split(',')] + pgpaths = [x.strip() for x in pafOpts["genome"].split(',')] + passnames = [self.genome_name] # always first + for i, gname in enumerate(pgnames): + if len(gname.split()) > 1: + gname = gname.split()[0] + # trouble from spacey names in command lines avoidance + if gname not in self.genome_names: + passnames.append(gname) + # ignore if already there - eg for duplicates among pafs. + asstrack = self.make_assembly(pgpaths[i], gname) + self.genome_names.append(gname) + if self.config_json.get("assemblies", None): + self.config_json["assemblies"].append(asstrack) + else: + self.config_json["assemblies"] = [ + asstrack, + ] url = "%s.paf" % (trackData["label"]) dest = "%s/%s" % (self.outdir, url) self.symlink_or_copy(os.path.realpath(data), dest) trackDict = { "type": "SyntenyTrack", "trackId": tId, - "assemblyNames": [self.genome_name, pgname], + "assemblyNames": passnames, "name": tname, "adapter": { "type": "PAFAdapter", @@ -1533,6 +1540,9 @@ default_session_data["session_name"] = root.find( "metadata/general/session_name" ).text + jc.zipOut = root.find( + "metadata/general/zipOut" + ).text == "true" general_data = { "analytics": root.find("metadata/general/analytics").text, "primary_color": root.find("metadata/general/primary_color").text,