changeset 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 0e592dcaeb7f
children 81d535970196
files jbrowse2.py jbrowse2.xml macros.xml
diffstat 3 files changed, 117 insertions(+), 68 deletions(-) [+]
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,
--- a/jbrowse2.xml	Thu Mar 21 09:06:52 2024 +0000
+++ b/jbrowse2.xml	Fri Mar 22 22:04:08 2024 +0000
@@ -139,16 +139,17 @@
         #for $tg in $track_groups:
             #for $track in $tg.data_tracks:
                 #if $track.data_format.useuri.insource == "uri":
-                   <track cat="${tg.category}" format="${track.data_format.data_format_select}" visibility="${track.data_format.track_visibility}">
-                      <files>
-                        <trackFile path="${track.data_format.useuri.annouri}" ext="${track.data_format.data_format_select}" label="${track.data_format.useuri.annoname}" useuri="yes">
-                            <metadata>
-                            <dataset id = "${track.data_format.useuri.annouri}" />
-                            </metadata>
-                         </trackFile>
-                     </files>
-                    <options/>
-                </track>
+                    <track cat="${tg.category}" format="paf" visibility="${track.data_format.track_visibility}">
+                        <files>
+                             <trackFile path="${ $track.data_format.useuri.insource.annouri}" ext="paf"
+                                label="${track.data_format.useuri.insource.annoname}" useuri="yes">
+                                <metadata>
+                                <dataset id = "${track.data_format.useuri.insource.annouri}" />
+                                </metadata>
+                             </trackFile>
+                        </files>
+                        <options/>
+                    </track>
                 #else if $track.data_format.useuri.insource == "history":
                     #if $track.data_format.useuri.annotation:
                     <track cat="${tg.category}" format="${track.data_format.data_format_select}" visibility="${track.data_format.track_visibility}">
@@ -203,7 +204,10 @@
                             #end if
                         #end if
                         #if str($track.data_format.data_format_select) in ["bam", "cram"]:
-                            <type>"LinearAlignmentsDisplay"</type>
+                            <type>LinearAlignmentsDisplay</type>
+                        #end if
+                        #if str($track.data_format.data_format_select) in ["paf"]:
+                            <type>LinearBasicDisplay</type>
                         #end if
                         </style>
                     #if str($track.data_format.data_format_select) == "bam":
@@ -235,13 +239,13 @@
                     #else if str($track.data_format.data_format_select) == "paf":
                         <paf>
                             <genome>
-                            #for gnome in $track.data_format.synteny_genome:
-                                $gnome,
+                            #for refgenome in $track.data_format.pafuseuri.refgenomes:
+                                $refgenome.annotation,
                             #end for
                             </genome>
                             <genome_label>
-                            #for gnome in $track.data_format.synteny_genome:
-                                $gnome.name,
+                            #for refgenome in $track.data_format.pafuseuri.refgenomes:
+                                $refgenome.annoname,
                             #end for
                             </genome_label>
                         </paf>
@@ -327,17 +331,17 @@
             <repeat name="data_tracks" title="Annotation Track">
                 <conditional name="data_format" label="Track Data Selection Options">
                     <param type="select" label="Track Type" name="data_format_select">
-                        <option value="bam">BAM Pileup track</option>
+                        <option value="bam">BAM track. Recommend convert to faster BED unless mapping annotation needed</option>
                         <option value="bed">BED track</option>
                         <option value="bigwig">BigWig track</option>
-                        <option value="blastxml">Blast XML track - converted to GFF</option>
+                        <option value="blastxml">Blast XML track (as GFF3)</option>
+                        <option value="cram">CRAM track. Currently not advantageous over BAM in Galaxy. Convert to BED like BAM.</option>
+                        <option value="gff">GFF/GFF3 track</option>
                         <option value="cool">HiC as cool/mcool/scool format files</option>
-                        <option value="cram">CRAM</option>
-                        <option value="gff">GFF/GFF3 feature track</option>
                         <option value="hic">HiC as juicebox_hic format file. Tabular hic_matrix will NOT work.</option>
                         <option value="maf">Multiple alignment format. Reference name must match the MAF name exactly to work correctly</option>
                         <option value="paf">PAF - approximate mapping positions between two set of sequences</option>
-                       <option value="vcf">VCF SNP</option>
+                       <option value="vcf">VCF SNP track</option>
                     </param>
                     <when value="blastxml">
                         <expand macro="input_conditional" label="BlastXML Track Data" format="blastxml" />
@@ -411,12 +415,10 @@
                         <expand macro="track_visibility" />
                     </when>
                     <when value="paf">
-                        <param label="Comparison genome sequence" help="Paf from these as the reference(s), using the common reference as the reads to map"
-                            format="fasta"
-                            name="synteny_genome"
-                            type="data"
-                            multiple="True"/>
-                        <expand macro="input_conditional" label="Synteny data" format="paf" help="Make paf with mashmap or minimap2 mapping real reference onto desired syntenic references"/>
+                        <expand macro="input_conditional" label="PAF format synteny mapping data" format="paf"
+                             help="PAF made with mashmap or minimap2 mapping the real reference as a query on the comparison genomes as references"/>
+                        <expand macro="pafref_conditional"  label="Comparison genome sequence(s)"
+                            format="fasta" help="Paf from these as the reference(s), using the common reference as the reads to map"/>
                         <expand macro="track_visibility" />
                     </when>
 
--- a/macros.xml	Thu Mar 21 09:06:52 2024 +0000
+++ b/macros.xml	Fri Mar 22 22:04:08 2024 +0000
@@ -522,7 +522,7 @@
                 <param name="insource" type="select" label="Define track data as a history file or an internet URI"
                     help="A public URI implies that all the associated tabix files are also in place. They are created for history files">
                     <option value="history" selected="true">Track data from a history file</option>
-                    <option value="uri" selected="true">Tabix data URI - index files must be available at corresponding URI</option>
+                    <option value="uri" >Tabix data URI - index files must be available at corresponding URI</option>
                 </param>
                 <when value="history">
                        <param label="@LABEL@" format="@FORMAT@" name="annotation" multiple="True" optional="true" type="data" />
@@ -539,6 +539,39 @@
                 </when>
             </conditional>
      </xml>
+    <xml name="pafref_conditional" token_label="Track Data" token_format="data">
+        <conditional name="pafuseuri">
+                <param name="insource" type="select" label="PAF reference data from a history file or an internet URI?"
+                    help="A public URI implies that all the associated tabix files are also in place. They are created for history files">
+                    <option value="history" selected="true">PAF genome reference data from a history file</option>
+                    <option value="uri">PAF genome reference data from tabix data URI - index files must be available at corresponding URI</option>
+                </param>
+                <when value="history">
+                    <repeat name="refgenomes" title="Add one or more comparison genomes used to make the PAF">
+                       <param label="@LABEL@" format="@FORMAT@" name="annotation" multiple="True" optional="true" type="data" />
+                       <param label="Short name for track display" name="annoname" type="text" >
+                             <sanitizer invalid_char="_">
+                                <valid initial="string.printable" >
+                                    <remove value="'" />
+                                </valid>
+                              </sanitizer>
+                        </param>
+                    </repeat>
+                </when>
+                <when value="uri">
+                    <repeat name="refgenomes" title="Provide URI for a comparison genomesused to make the PAF">
+                       <param label="@LABEL@" name="annotation"  type="text" />
+                       <param label="Short name for track display" name="annoname" type="text" >
+                             <sanitizer invalid_char="_">
+                                <valid initial="string.printable" >
+                                    <remove value="'" />
+                                </valid>
+                              </sanitizer>
+                        </param>
+                    </repeat>
+                </when>
+            </conditional>
+     </xml>
     <xml name="citations">
         <citations>
         <citation type="doi">10.1186/s13059-016-0924-1</citation>