diff jbrowse2.py @ 59:f807e219cec3 draft

planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit faada92caf5aaabe58e52b161687a30d542a07b9
author fubar
date Fri, 22 Mar 2024 22:04:08 +0000
parents 94264fe60478
children 81d535970196
line wrap: on
line diff
--- a/jbrowse2.py	Thu Mar 21 09:06:52 2024 +0000
+++ b/jbrowse2.py	Fri Mar 22 22:04:08 2024 +0000
@@ -439,11 +439,13 @@
         if trackDict.get("displays", None):  # use first if multiple like bed
             style_data["type"] = trackDict["displays"][0]["type"]
             style_data["displayId"] = trackDict["displays"][0]["displayId"]
-        return {
+        wstyle = {
             "displays": [
                 style_data,
             ]
         }
+        logging.warn("style=%s" % (wstyle))
+        return wstyle
 
     def process_genomes(self):
         assemblies = []
@@ -496,16 +498,16 @@
                 "type": "BgzipFastaAdapter",
                 "fastaLocation": {
                     "uri": faname,
-                    "locationType": "UriLocation",
+                    "locationType": "UriLocation"
                 },
                 "faiLocation": {
                     "uri": faname + ".fai",
-                    "locationType": "UriLocation",
+                    "locationType": "UriLocation"
                 },
                 "gziLocation": {
                     "uri": faname + ".gzi",
-                    "locationType": "UriLocation",
-                },
+                    "locationType": "UriLocation"
+                }
             }
         else:
             faname = gname + ".fa.gz"
@@ -528,7 +530,7 @@
                 },
                 "gziLocation": {
                     "uri": faname + ".gzi",
-                },
+                }
             }
 
         trackDict = {
@@ -538,7 +540,6 @@
                 "trackId": gname,
                 "adapter": adapter,
             },
-            "rendering": {"type": "DivSequenceRenderer"},
             "displays": [
                 {
                     "type": "LinearReferenceSequenceDisplay",
@@ -548,7 +549,7 @@
                     "type": "LinearGCContentDisplay",
                     "displayId": "%s-LinearGCContentDisplay" % gname,
                 },
-            ],
+            ]
         }
         return trackDict
 
@@ -635,6 +636,8 @@
                 },
             ],
         }
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -708,6 +711,8 @@
                 },
             ],
         }
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
         if self.config_json.get("plugins", None):
@@ -781,6 +786,8 @@
                 },
             ],
         }
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
         os.unlink(gff3)
@@ -827,6 +834,8 @@
                 }
             ],
         }
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -880,6 +889,8 @@
                 },
             ],
         }
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -928,6 +939,8 @@
                 },
             ],
         }
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -980,6 +993,8 @@
                 },
             ],
         }
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -1041,6 +1056,8 @@
                 },
             ],
         }
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -1088,6 +1105,8 @@
                 },
             ],
         }
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -1095,27 +1114,28 @@
         tname = trackData["name"]
         tId = trackData["label"]
         categ = trackData["category"]
-        pgnames = [x.strip() for x in pafOpts["genome_label"].split(",")]
-        pgpaths = [x.strip() for x in pafOpts["genome"].split(",")]
+        pgnames = [x.strip() for x in pafOpts["genome_label"].split(",") if len(x.strip()) > 0]
+        pgpaths = [x.strip() for x in pafOpts["genome"].split(",") if len(x.strip()) > 0]
         passnames = [self.genome_name]  # always first
+        logging.warn("### add_paf got pafOpts=%s, pgnames=%s, pgpaths=%s for %s" % (pafOpts, pgnames, pgpaths, tId))
         for i, gname in enumerate(pgnames):
             if len(gname.split()) > 1:
                 gname = gname.split()[0]
-                passnames.append(gname)
-                # trouble from spacey names in command lines avoidance
-                if gname not in self.genome_names:
-                    # ignore if already there - eg for duplicates among pafs.
-                    useuri = pgpaths[i].startswith("http://") or pgpaths[i].startswith(
-                        "https://"
-                    )
-                    asstrack = self.make_assembly(pgpaths[i], gname, useuri)
-                    self.genome_names.append(gname)
-                    if self.config_json.get("assemblies", None):
-                        self.config_json["assemblies"].append(asstrack)
-                    else:
-                        self.config_json["assemblies"] = [
-                            asstrack,
-                        ]
+            passnames.append(gname)
+            # trouble from spacey names in command lines avoidance
+            if gname not in self.genome_names:
+                # ignore if already there - eg for duplicates among pafs.
+                useuri = pgpaths[i].startswith("http://") or pgpaths[i].startswith(
+                    "https://"
+                )
+                asstrack = self.make_assembly(pgpaths[i], gname, useuri)
+                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)
@@ -1131,18 +1151,16 @@
                 "type": "PAFAdapter",
                 "pafLocation": {"uri": url},
                 "assemblyNames": passnames,
-            },
-            "displays": [
-                {
-                    "type": "LinearSyntenyDisplay",
-                    "displayId": "%s-LinearSyntenyDisplay" % tId,
-                },
-                {
-                    "type": "DotPlotDisplay",
-                    "displayId": "%s-DotPlotDisplay" % tId,
-                },
-            ],
+            }
         }
+        style_json = {
+        "displays": [
+            { "type": "LinearBasicDisplay",
+            "displayId": "%s-LinearBasicyDisplay" % trackDict["trackId"]
+            }
+            ]
+        }
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -1284,7 +1302,6 @@
             if "displays" in track_conf:
                 disp = track_conf["displays"][0]["type"]
                 style_data["type"] = disp
-                style_data["configuration"] = "%s-%s" % (tId, 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?
@@ -1296,7 +1313,6 @@
                     "displays": [style_data],
                 }
             )
-
         # The view for the assembly we're adding
         view_json = {"type": "LinearGenomeView", "tracks": tracks_data}
 
@@ -1534,9 +1550,6 @@
             }
         else:
             track_conf["style"] = {}
-        tst = track_conf["style"].get("type", None)
-        if tst:
-            track_conf["style"]["configuration"] = "%s-%s" % (track_conf["label"], tst)
         if track.find("options/style_labels"):
             track_conf["style_labels"] = {
                 item.tag: parse_style_conf(item)
@@ -1565,6 +1578,7 @@
     default_session_data["session_name"] = root.find(
         "metadata/general/session_name"
     ).text
+    logging.warn("default_session=%s" % (default_session_data))
     jc.zipOut = root.find("metadata/general/zipOut").text == "true"
     general_data = {
         "analytics": root.find("metadata/general/analytics").text,