diff jbrowse2.py @ 5:efc64d8f4b72 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 79e81bef99f582680d9aa4eec88980c675f3fae9
author fubar
date Tue, 09 Jan 2024 05:24:48 +0000
parents 2de9f585505b
children 79f7265f90bd
line wrap: on
line diff
--- a/jbrowse2.py	Tue Jan 09 02:37:42 2024 +0000
+++ b/jbrowse2.py	Tue Jan 09 05:24:48 2024 +0000
@@ -19,7 +19,7 @@
 log = logging.getLogger("jbrowse")
 TODAY = datetime.datetime.now().strftime("%Y-%m-%d")
 GALAXY_INFRASTRUCTURE_URL = None
-JB2REL="v2.10.0"
+JB2REL = "v2.10.0"
 # version pinned for cloning
 
 mapped_chars = {
@@ -435,16 +435,18 @@
             "displayId": "%s-LinearBasicDisplay" % trackDict["trackId"],
         }
 
-        if trackDict.get("displays", None):
-            style_data["type"] = trackDict["displays"]["type"]
-            style_data["displayId"] = trackDict["displays"]["displayId"]
-        return {"displays": [style_data]}
+        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 {
+            "displays": [
+                style_data,
+            ]
+        }
 
     def process_genomes(self):
         assemblies = []
         for i, genome_node in enumerate(self.genome_paths):
-            if self.debug:
-                log.info("genome_node=%s" % str(genome_node))
             genome_name = genome_node["meta"]["dataset_dname"].strip()
             if len(genome_name.split()) > 1:
                 genome_name = genome_name.split()[0]
@@ -550,7 +552,6 @@
             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
         """
-        log.info("#### trackData=%s" % trackData)
         tId = trackData["label"]
         # can be served - if public.
         # dsId = trackData["metadata"]["dataset_id"]
@@ -579,8 +580,8 @@
                 },
             ],
         }
-        # style_json = self._prepare_track_style(trackDict)
-        # trackDict["style"] = style_json
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -614,8 +615,6 @@
             dest,
         ]
         self.subprocess_check_call(cmd)
-        if True or self.debug:
-            log.info("### convertMAF.sh called as %s" % " ".join(cmd))
         # Construct samples list
         # We could get this from galaxy metadata, not sure how easily.
         ps = subprocess.Popen(["grep", "^s [^ ]*", "-o", data], stdout=subprocess.PIPE)
@@ -625,8 +624,6 @@
         soutp = outp.split("\n")
         samp = [x.split("s ")[1] for x in soutp if x.startswith("s ")]
         samples = [x.split(".")[0] for x in samp]
-        if self.debug:
-            log.info("### got samples = %s " % (samples))
         trackDict = {
             "type": "MafTrack",
             "trackId": tId,
@@ -644,9 +641,16 @@
                 },
             },
             "assemblyNames": [self.genome_name],
+            "displays": [
+                {
+                    "type": "LinearBasicDisplay",
+                    "displayId": "%s-LinearBasicDisplay" % tId,
+                },
+                {"type": "LinearArcDisplay", "displayId": "%s-LinearArcDisplay" % tId},
+            ],
         }
-        # style_json = self._prepare_track_style(trackDict)
-        # trackDict["style"] = style_json
+        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):
@@ -714,6 +718,8 @@
                 {"type": "LinearArcDisplay", "displayId": "%s-LinearArcDisplay" % tId},
             ],
         }
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -744,8 +750,8 @@
                 }
             ],
         }
-        # style_json = self._prepare_track_style(trackDict)
-        # trackDict["style"] = style_json
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -755,7 +761,6 @@
         dest = "%s/%s" % (self.outdir, fname)
         url = fname
         self.subprocess_check_call(["cp", data, dest])
-        log.info("### copied %s to %s" % (data, dest))
         bloc = {"uri": url}
         if bam_index is not None and os.path.exists(os.path.realpath(bam_index)):
             # bai most probably made by galaxy and stored in galaxy dirs, need to copy it to dest
@@ -792,8 +797,8 @@
                 },
             ],
         }
-        # style_json = self._prepare_track_style(trackDict)
-        # trackDict["style"] = style_json
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -840,8 +845,8 @@
                 },
             ],
         }
-        # style_json = self._prepare_track_style(trackDict)
-        # trackDict["style"] = style_json
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -893,8 +898,8 @@
                 {"type": "LinearArcDisplay", "displayId": "%s-LinearArcDisplay" % tId},
             ],
         }
-        # style_json = self._prepare_track_style(trackDict)
-        # trackDict["style"] = style_json
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -922,14 +927,18 @@
             },
             "displays": [
                 {
+                    "type": "LinearPileupDisplay",
+                    "displayId": "%s-LinearPileupDisplay" % tId,
+                },
+                {
                     "type": "LinearBasicDisplay",
                     "displayId": "%s-LinearBasicDisplay" % tId,
                 },
                 {"type": "LinearArcDisplay", "displayId": "%s-LinearArcDisplay" % tId},
             ],
         }
-        # style_json = self._prepare_track_style(trackDict)
-        # trackDict["style"] = style_json
+        style_json = self._prepare_track_style(trackDict)
+        trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
 
@@ -1151,17 +1160,11 @@
 
         # We need to know the track type from the config.json generated just before
         track_types = {}
-        logging.info("### add default session has data = %s\n" % str(data))
         with open(self.config_json_file, "r") as config_file:
             config_json = json.load(config_file)
-        logging.info("### config.json read \n%s\n" % (config_json))
 
         for track_conf in self.tracksToAdd:  # config_json["tracks"]:
             track_types[track_conf["trackId"]] = track_conf["type"]
-        logging.info(
-            "### self.tracksToAdd = %s; track_types = %s"
-            % (str(self.tracksToAdd), str(track_types))
-        )
 
         for on_track in data["visibility"]["default_on"]:
             style_data = {"type": "LinearBasicDisplay", "height": 100}
@@ -1263,7 +1266,7 @@
     def clone_jbrowse(self):
         """Clone a JBrowse directory into a destination directory."""
         dest = self.outdir
-        cmd = ["jbrowse", "create", "-t",JB2REL, "-f", dest]
+        cmd = ["jbrowse", "create", "-t", JB2REL, "-f", dest]
         self.subprocess_check_call(cmd)
         for fn in [
             "asset-manifest.json",
@@ -1437,12 +1440,7 @@
             pass
         track_conf["conf"] = etree_to_dict(track.find("options"))
         jc.add_general_configuration(general_data)
-        print("## processed", str(track_conf), "trackIdlist", jc.trackIdlist)
     x = open(args.xml, "r").read()
-    log.info(
-        "###done processing xml=%s; trackIdlist=%s, config=%s"
-        % (x, jc.trackIdlist, str(jc.config_json))
-    )
     jc.config_json["tracks"] = jc.tracksToAdd
     if jc.usejson:
         jc.write_config()