diff jbrowse2.py @ 50:f350467f9433 draft

planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit 44df75b3714aa9e02983e0b67ef43fc0eee4a8d4
author fubar
date Thu, 07 Mar 2024 04:51:43 +0000
parents 7e867ff86e44
children bdfa6a7c4543
line wrap: on
line diff
--- a/jbrowse2.py	Thu Mar 07 00:27:48 2024 +0000
+++ b/jbrowse2.py	Thu Mar 07 04:51:43 2024 +0000
@@ -602,23 +602,17 @@
         useuri = trackData["useuri"].lower() == "yes"
         if useuri:
             uri = data
-            adapt = {
-                "type": "HicAdapter",
-                "hicLocation": uri,
-                "locationType": "UriLocation",
-            },
         else:
             uri = trackData["hic_url"]
-            adapt = {
-                "type": "HicAdapter",
-                "hicLocation": uri,
-            },
         trackDict = {
             "type": "HicTrack",
             "trackId": tId,
             "name": uri,
             "assemblyNames": [self.genome_name],
-            "adapter":  adapt,
+            "adapter": {
+                "type": "HicAdapter",
+                "hicLocation": uri,
+            },
             "displays": [
                 {
                     "type": "LinearHicDisplay",
@@ -787,21 +781,13 @@
         useuri = trackData["useuri"].lower() == "yes"
         if useuri:
             url = data
-            adapt = {
-                "type": "BigWigAdapter",
-                "bigWigLocation": {"uri": url},
-                "locationType": "UriLocation",
-            }
         else:
             url = "%s.bigwig" % trackData["label"]
             # slashes in names cause path trouble
             dest = os.path.join(self.outdir, url)
             cmd = ["cp", data, dest]
             self.subprocess_check_call(cmd)
-            adapt = {
-                "type": "BigWigAdapter",
-                "bigWigLocation": {"uri": url},
-            }
+        bwloc = {"uri": url}
         tId = trackData["label"]
         trackDict = {
             "type": "QuantitativeTrack",
@@ -810,7 +796,10 @@
             "assemblyNames": [
                 self.genome_name,
             ],
-            "adapter":  adapt,
+            "adapter": {
+                "type": "BigWigAdapter",
+                "bigWigLocation": bwloc,
+            },
             "displays": [
                 {
                     "type": "LinearWiggleDisplay",
@@ -829,31 +818,12 @@
         bindex = bam_index
         if useuri:
             url = data
-            adapt =  {
-                "type": "BamAdapter",
-                "bamLocation": {"uri": url},
-                "index": {
-                    "location": {
-                        "uri": bindex,
-                       "locationType": "UriLocation",
-                       }
-                }
-            }
         else:
             fname = "%s.bam" % trackData["label"]
             dest = "%s/%s" % (self.outdir, fname)
             url = fname
             bindex = fname + '.bai'
             self.subprocess_check_call(["cp", data, dest])
-            adapt =  {
-                "type": "BamAdapter",
-                "bamLocation": {"uri": url},
-                "index": {
-                    "location": {
-                        "uri": bindex,
-                       }
-                    }
-                }
             if bam_index is not None and os.path.exists(bam_index):
                 if not os.path.exists(bindex):
                     # bai most probably made by galaxy and stored in galaxy dirs, need to copy it to dest
@@ -874,7 +844,15 @@
             "trackId": tId,
             "name": trackData["name"],
             "assemblyNames": [self.genome_name],
-            "adapter": adapt,
+            "adapter": {
+                "type": "BamAdapter",
+                "bamLocation": {"uri": url},
+                "index": {
+                    "location": {
+                        "uri": bindex,
+                    }
+                },
+            },
             "displays": [
                 {
                     "type": "LinearAlignmentsDisplay",
@@ -893,29 +871,13 @@
         bindex = cram_index
         if useuri:
             url = data
-            adapt =  {
-                "type": "CramAdapter",
-                "cramLocation": {"uri": url},
-                "craiLocation": {
-                    "uri": bindex,
-                    "locationType": "UriLocation",
-                },
-                "sequenceAdapter": self.genome_sequence_adapter,
-               }
         else:
             fname = "%s.cram" % trackData["label"]
             dest = "%s/%s" % (self.outdir, fname)
             bindex = fname + '.bai'
             url = fname
             self.subprocess_check_call(["cp", data, dest])
-            adapt =  {
-                "type": "CramAdapter",
-                "cramLocation": {"uri": url},
-                "craiLocation": {
-                    "uri": bindex,
-                },
-                "sequenceAdapter": self.genome_sequence_adapter,
-               }
+
             if bindex is not None and os.path.exists(bindex):
                 if not os.path.exists(dest+'.crai'):
                     # most probably made by galaxy and stored in galaxy dirs, need to copy it to dest
@@ -938,7 +900,14 @@
             "trackId": tId,
             "name": trackData["name"],
             "assemblyNames": [self.genome_name],
-            "adapter": adapt,
+            "adapter": {
+                "type": "CramAdapter",
+                "cramLocation": {"uri": url},
+                "craiLocation": {
+                    "uri": bindex,
+                },
+                "sequenceAdapter": self.genome_sequence_adapter,
+            },
             "displays": [
                 {
                     "type": "LinearAlignmentsDisplay",
@@ -961,19 +930,6 @@
         useuri = trackData["useuri"].lower() == "yes"
         if useuri:
             url = data
-            adapt = {
-                "type": "VcfTabixAdapter",
-                "vcfGzLocation": {
-                    "uri": url,
-                    "locationType": "UriLocation",
-                },
-                "index": {
-                    "location": {
-                        "uri": url + ".tbi",
-                        "locationType": "UriLocation",
-                    }
-                },
-            },
         else:
             url = "%s.vcf.gz" % tId
             dest = "%s/%s" % (self.outdir, url)
@@ -981,7 +937,12 @@
             self.subprocess_popen(cmd)
             cmd = ["tabix", "-f", "-p", "vcf", dest]
             self.subprocess_check_call(cmd)
-            adapt = {
+        trackDict = {
+            "type": "VariantTrack",
+            "trackId": tId,
+            "name": trackData["name"],
+            "assemblyNames": [self.genome_name],
+            "adapter": {
                 "type": "VcfTabixAdapter",
                 "vcfGzLocation": {
                     "uri": url
@@ -991,13 +952,7 @@
                         "uri": url + ".tbi",
                     }
                 },
-            }
-        trackDict = {
-            "type": "VariantTrack",
-            "trackId": tId,
-            "name": trackData["name"],
-            "assemblyNames": [self.genome_name],
-            "adapter": adapt,
+            },
             "displays": [
                 {
                     "type": "LinearVariantDisplay",
@@ -1040,24 +995,17 @@
         useuri = trackData["useuri"].lower() == "yes"
         if useuri:
             url = trackData["path"]
-            adapter = {
-                "type": "Gff3TabixAdapter",
-                "gffGzLocation": {
-                    "uri": url,
-                    "locationType": "UriLocation",
-                },
-                "index": {
-                    "location": {
-                        "uri": url + ".tbi",
-                        "locationType": "UriLocation",
-                    }
-                },
-            }
         else:
             url = "%s.%s.gz" % (trackData["label"], ext)
             dest = "%s/%s" % (self.outdir, url)
             self._sort_gff(data, dest)
-            adapter = {
+        tId = trackData["label"]
+        trackDict = {
+            "type": "FeatureTrack",
+            "trackId": tId,
+            "name": trackData["name"],
+            "assemblyNames": [self.genome_name],
+            "adapter": {
                 "type": "Gff3TabixAdapter",
                 "gffGzLocation": {
                     "uri": url,
@@ -1067,14 +1015,7 @@
                         "uri": url + ".tbi",
                     }
                 },
-            }
-        tId = trackData["label"]
-        trackDict = {
-            "type": "FeatureTrack",
-            "trackId": tId,
-            "name": trackData["name"],
-            "assemblyNames": [self.genome_name],
-            "adapter": adapt,
+            },
             "displays": [
                 {
                     "type": "LinearBasicDisplay",
@@ -1096,24 +1037,16 @@
         useuri = trackData["useuri"].lower() == "yes"
         if useuri:
             url = data
-            adapt = {
-                "type": "BedTabixAdapter",
-                "bedGzLocation": {
-                    "uri": url,
-                    "locationType": "UriLocation",
-                },
-                "index": {
-                    "location": {
-                        "uri": url + ".tbi",
-                        "locationType": "UriLocation",
-                    }
-                },
-            }
         else:
             url = "%s.%s.gz" % (trackData["label"], ext)
             dest = "%s/%s" % (self.outdir, url)
             self._sort_bed(data, dest)
-            adapt = {
+        trackDict = {
+            "type": "FeatureTrack",
+            "trackId": tId,
+            "name": trackData["name"],
+            "assemblyNames": [self.genome_name],
+            "adapter": {
                 "type": "BedTabixAdapter",
                 "bedGzLocation": {
                     "uri": url,
@@ -1123,13 +1056,7 @@
                         "uri": url + ".tbi",
                     }
                 },
-            }
-        trackDict = {
-            "type": "FeatureTrack",
-            "trackId": tId,
-            "name": trackData["name"],
-            "assemblyNames": [self.genome_name],
-            "adapter": adapt,
+            },
             "displays": [
                 {
                     "type": "LinearBasicDisplay",
@@ -1179,7 +1106,11 @@
             "trackId": tId,
             "assemblyNames": passnames,
             "name": tname,
-            "adapter": adapt,
+            "adapter": {
+                "type": "PAFAdapter",
+                "pafLocation": {"uri": url},
+                "assemblyNames": passnames,
+            },
             # "displays": [
             # {
             # "type": "LinearSyntenyDisplay",