Repository 'jbrowse2'
hg clone https://toolshed.g2.bx.psu.edu/repos/fubar/jbrowse2

Changeset 99:990291e918c7 (2024-06-21)
Previous changeset 98:b1260bca5fdc (2024-06-05) Next changeset 100:666c07b60cd2 (2024-06-21)
Commit message:
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit a1537aea75fc902d0e38c0b7c698830a939648b1-dirty
modified:
jbrowse2.py
jbrowse2.xml
macros.xml
added:
__pycache__/jbrowse2.cpython-312.pyc
b
diff -r b1260bca5fdc -r 990291e918c7 __pycache__/jbrowse2.cpython-312.pyc
b
Binary file __pycache__/jbrowse2.cpython-312.pyc has changed
b
diff -r b1260bca5fdc -r 990291e918c7 jbrowse2.py
--- a/jbrowse2.py Wed Jun 05 10:00:07 2024 +0000
+++ b/jbrowse2.py Fri Jun 21 23:34:31 2024 +0000
[
@@ -20,8 +20,8 @@
 logging.basicConfig(level=logging.DEBUG)
 log = logging.getLogger("jbrowse")
 
-JB2VER = "v2.11.0"
-# version pinned if cloning - but not used until now
+JB2VER = "v2.11.1"
+# version pinned if cloning - but not cloning now
 logCommands = True
 # useful for seeing what's being written but not for production setups
 TODAY = datetime.datetime.now().strftime("%Y-%m-%d")
@@ -455,7 +455,7 @@
             log.error(command)
             log.error(output)
             log.error(err)
-            raise RuntimeError(f"Command ( {command} ) failed with exit code {retcode}")
+            raise RuntimeError("Command failed with exit code %s" % (retcode))
 
     def subprocess_check_output(self, command):
         if logCommands:
@@ -698,8 +698,8 @@
             ]
         }
         categ = trackData["category"]
-        fname = f"{tId}"
-        dest = os.path.join(self.outdir, fname)
+        fname = tId
+        dest = "%s/%s" % (self.outdir, fname)
         gname = trackData["assemblyNames"]
 
         cmd = [
@@ -1198,6 +1198,9 @@
 
     def process_annotations(self, track):
         category = track["category"].replace("__pd__date__pd__", TODAY)
+        tt1 = ",/ :;\\"
+        tt2 = "______"
+        labttab = str.maketrans(tt1,tt2)
         for trackIndex, (
             dataset_path,
             dataset_ext,
@@ -1209,20 +1212,12 @@
                 # Unsanitize labels (element_identifiers are always sanitized by Galaxy)
                 for key, value in mapped_chars.items():
                     track_human_label = track_human_label.replace(value, key)
-                track_human_label = track_human_label.replace(" ", "_")
+                track_human_label = track_human_label.translate(labttab)
             outputTrackConfig = {
                 "category": category,
                 "style": {},
             }
 
-            # hashData = [
-            #    str(dataset_path),
-            #    track_human_label,
-            #    track["category"],
-            # ]
-            # hashData = "|".join(hashData).encode("utf-8")
-            # hash_string = hashlib.md5(hashData).hexdigest()
-
             outputTrackConfig["assemblyNames"] = track["assemblyNames"]
             outputTrackConfig["key"] = track_human_label
             outputTrackConfig["useuri"] = useuri
@@ -1230,13 +1225,6 @@
             outputTrackConfig["ext"] = dataset_ext
             outputTrackConfig["trackset"] = track.get("trackset", {})
             outputTrackConfig["label"] = track["label"]
-            # outputTrackConfig["label"] = "%s_%i_%s_%s" % (
-            #    dataset_ext,
-            #    trackIndex,
-            #    track_human_label,
-            #    hash_string,
-            # )
-
             outputTrackConfig["metadata"] = extra_metadata
             outputTrackConfig["name"] = track_human_label
             if track["label"] in self.trackIdlist:
@@ -1331,6 +1319,7 @@
          https://github.com/abretaud/tools-iuc/blob/jbrowse2/tools/jbrowse2/jbrowse2.py
         """
         # TODO using the default session for now, but check out session specs in the future https://github.com/GMOD/jbrowse-components/issues/2708
+        bpPerPx = 50 # this is tricky since browser window width is unknown - this seems a compromise that sort of works....
         track_types = {}
         with open(self.config_json_file, "r") as config_file:
             config_json = json.load(config_file)
@@ -1369,24 +1358,17 @@
                             "displays": [style_data],
                         }
                     )
-            view_json = {
-                "type": "LinearGenomeView",
-                "offsetPx": 0,
-                "minimized": False,
-                "tracks": tracks_data,
-            }
             first = [x for x in self.ass_first_contigs if x[0] == gnome]
-            if len(first) > 0:
-                [gnome, refName, end] = first[0]
-                start = 0
-                end = int(end)
-                drdict = {
-                    "refName": refName,
-                    "start": start,
-                    "end": end,
+            drdict = {
                     "reversed": False,
                     "assemblyName": gnome,
                 }
+            if len(first) > 0:
+                [gnome, refName, end] = first[0]
+                drdict["refName"] = refName
+                drdict["start"] = 0
+                end = int(end)
+                drdict["end"] = end        
             else:
                 ddl = default_data.get("defaultLocation", None)
                 if ddl:
@@ -1404,6 +1386,13 @@
                             "@@@ regexp could not match contig:start..end in the supplied location %s - please fix"
                             % ddl
                         )
+            view_json = {
+                "type": "LinearGenomeView",
+                "offsetPx": 0,
+                "bpPerPx" : bpPerPx,
+                "minimized": False,
+                "tracks": tracks_data
+            }
             if drdict.get("refName", None):
                 # TODO displayedRegions is not just zooming to the region, it hides the rest of the chromosome
                 view_json["displayedRegions"] = [
@@ -1628,7 +1617,7 @@
             if trackfiles:
                 for x in trackfiles:
                     track_conf["label"] = "%s_%d" % (
-                        x.attrib["label"].replace(" ", "_").replace(",", ""),
+                        x.attrib["label"].replace(" ", "_").replace(",", "_").replace("/","_"),
                         trackI,
                     )
                     trackI += 1
b
diff -r b1260bca5fdc -r 990291e918c7 jbrowse2.xml
--- a/jbrowse2.xml Wed Jun 05 10:00:07 2024 +0000
+++ b/jbrowse2.xml Fri Jun 21 23:34:31 2024 +0000
[
b'@@ -8,6 +8,7 @@\n         <xref type="bio.tools">jbrowse2</xref>\n     </xrefs>\n     <expand macro="requirements"/>\n+    <expand macro="creators"/>\n     <required_files>\n         <include path="autogenJB2.py"/>\n         <include path="blastxml_to_gapped_gff3.py"/>\n@@ -28,9 +29,9 @@\n         #if $autoCollection[$key].is_collection:\n             #set subCol=$autoCollection[$key]\n             #set pafs=[($subCol[x],$subcol[x].ext,x) for x in $subCol.keys() if $subCol[x].ext == \'paf\']\n+            #set refs=[($subCol[x],$subcol[x].ext,x) for x in $subCol.keys() if $subCol[x].ext in [\'fasta.gz\',\'fasta\']]\n             #if len($pafs) > 0:\n                 --pafmeta \'$pafs[0]\'\n-                #set refs = [($pafs[0][2],$subCol[x],x) for x in $subCol.keys() if $subCol[x].ext == \'fasta\']\n                 #for $ref in $refs:\n                     --pafreferencemeta \'$ref\'\n                 #end for\n@@ -314,7 +315,7 @@\n ]]></configfile>\n     </configfiles>\n     <inputs>\n-        <repeat name="assemblies" min="1" title="Genome reference to provide display coordinates for this set of tracks" help="JBrowse2 can show a set of tracks for each of multiple genome reference fasta files">\n+        <repeat name="assemblies" min="1" title="Genome for a set of tracks" help="Tracks will display on this genome coordinates so must all match. Multiple genomes with their own sets of tracks can be added">\n             <conditional name="reference_genome">\n                 <param name="genome_type_select" type="select" label="Reference genome source" help="Select a built in, history or remote tabix URI for the reference track">\n                     <option selected="True" value="indexed">Use a Galaxy server built-in genome</option>\n@@ -334,8 +335,11 @@\n                     <param name="genome" type="data" format="fasta" optional="true" label="Select the reference genome"/>\n                 </when>\n                 <when value="uri">\n-                    <param name="uri" type="text" label="URI pointing to tabix compressed fasta"/>\n-                    <param name="refname" type="text" label="Reference dbkey for tracks with this genome, such as hg38 or SacCer4"/>\n+                    <param name="uri" type="text" label="URI pointing to tabix compressed fasta - must always be on-line" \n+                        help="Warning: Requires an internet connection to view. If this URI is not available for any reason, the track will show an error. Saves disk storage">\n+                    </param>\n+                    <param name="refname" type="text" label="Reference dbkey for tracks with this genome, such as hg38 or SacCer4">\n+                    </param>\n                 </when>\n             </conditional>\n             <repeat name="track_groups" title="Track Group">\n@@ -343,16 +347,16 @@\n                 <repeat name="data_tracks" title="Annotation Track">\n                     <conditional name="data_format" label="Track Data Selection Options">\n                         <param name="data_format_select" type="select" label="Track Type">\n-                            <option value="bam">BAM track. Recommend convert to faster BED unless mapping annotation needed</option>\n+                            <option value="bam">BAM track. Recommend converting to BED/bigWig unless mapping annotation needed</option>\n                             <option value="bed">BED track</option>\n                             <option value="bigwig">BigWig track</option>\n                             <option value="blastxml">Blast XML track (as GFF3)</option>\n-                            <option value="cram">CRAM track, we recomment to convert to BED like for BAM</option>\n+                            <option value="cram">CRAM track. Recommend converting to BED/bigWig unless mapping annotation needed</option>\n                             <option value="gff">GFF/GFF3 track</option>\n                             <option value="cool">HiC as cool/mcool/scool format files</option>\n                        '..b'   <when value="blastxml">\n@@ -404,6 +408,7 @@\n                         <when value="bigwig">\n                             <expand macro="input_conditional" label="BigWig Track Data" format="bigwig"/>\n                             <expand macro="track_visibility"/>\n+                            <expand macro="track_styling_bigwig"/>                            \n                         </when>\n                         <when value="paf">\n                             <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"/>\n@@ -1129,29 +1134,31 @@\n \n JBrowse2-in-Galaxy offers a highly configurable, workflow-compatible Genome viewer.\n \n-Compared to JBrowse1-in-Galaxy, there is no support for alternative codons for unusual genomes,\n-and detailed track styling is not yet implemented. Please contact us if you are missing features.\n \n Use and local viewing\n =====================\n \n+All tracks have a coordinate system, based on the reference genome, so that must be chosen before adding groups of tracks.\n+There are 10 Galaxy datatypes that can be turned into a track for display - in all cases, the selected reference genome must have been \n+used to generate the data:\n+\n+    bam\n+    bed\n+    bigwig\n+    blastxml\n+    cram\n+    gff3\n+    hic\n+    maf\n+    paf\n+    vcf\n+\n+cram and bam will be large, so very slow amd are only recommended if you need the cigar annotation. \n+Otherwise conversion to bed is recommended to slim them down. \n+Unfortunately if you have millions of rows in a bed, it will also be very slow - in which case a bigwig is recommended. \n \n A JBrowse2 history item can be opened by viewing it (the "eye" icon).\n \n-The same browser data and setup can also be downloaded as a compressed zip archive by clicking the download ("floppy disk") icon in the history.\n-This can be shared and viewed without Galaxy.\n-\n-A replacement application to serve the browser is required without Galaxy. A local python web server can be started using a script included in each archive,\n-assuming that Python3 is already working on your desktop - if not you will have to install it first. Unzip the archive (*unzip [filename].zip*) and change\n-directory to the first level in that zip archive. It contains a file named *jb2_webserver.py*\n-\n-With python3 installed,\n-\n-*python3 jb2_webserver.py*\n-\n-will serve the unarchived JBrowse2 configuration from the same directory as the python script automatically. If a new browser window does not open,\n-but the script appears to be running, try pointing your web browser to the default of *localhost:8080*\n-\n Overview\n --------\n \n@@ -1175,6 +1182,7 @@\n \n **Track Groups** represent a set of tracks in a single category.\n \n+\n Annotation Tracks\n -----------------\n \n@@ -1232,6 +1240,22 @@\n **Protein blast search** option merely informs underlying tools that\n they should adjust feature locations by 3x.\n \n+Local viewing\n+=============\n+\n+The same browser data and setup can also be downloaded as a compressed zip archive by clicking the download ("floppy disk") icon in the history.\n+This can be shared and viewed without Galaxy.\n+\n+A replacement application to serve the browser is required without Galaxy. A local python web server can be started using a script included in each archive,\n+assuming that Python3 is already working on your desktop - if not you will have to install it first. Unzip the archive (*unzip [filename].zip*) and change\n+directory to the first level in that zip archive. It contains a file named *jb2_webserver.py*\n+\n+With python3 installed,\n+\n+*python3 jb2_webserver.py*\n+\n+will serve the unarchived JBrowse2 configuration from the same directory as the python script automatically. If a new browser window does not open,\n+but the script appears to be running, try pointing your web browser to the default of *localhost:8080*\n \n ]]></help>\n     <expand macro="citations"/>\n'
b
diff -r b1260bca5fdc -r 990291e918c7 macros.xml
--- a/macros.xml Wed Jun 05 10:00:07 2024 +0000
+++ b/macros.xml Fri Jun 21 23:34:31 2024 +0000
b
@@ -333,6 +333,13 @@
                     <option value="LinearWiggleDisplay" selected="true">LinearWiggleDisplay</option>
                 </param>
                 <when value="LinearWiggleDisplay">
+                    <param name="color" type="color" value="#135560" label="Wiggle colour">
+                        <sanitizer>
+                            <valid initial="string.ascii_letters,string.digits">
+                                <add value="#"/>
+                            </valid>
+                        </sanitizer>
+                    </param>
                     <param name="autoscale" type="select" label="Autoscale type">
                         <option value="local" selected="true">Local</option>
                         <option value="global">Global</option>
@@ -432,13 +439,13 @@
         <conditional name="useuri">
             <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">Tabix data URI - index files must be available at corresponding URI</option>
+                <option value="uri">Tabix data URI: Internet connection required to view. Tabix index files must be available</option>
             </param>
             <when value="history">
                 <param name="annotation" type="data" format="@FORMAT@" optional="true" label="@LABEL@" multiple="True"/>
             </when>
             <when value="uri">
-                <param name="annouri" type="text" label="@LABEL@"/>
+                <param name="annouri" type="text" label="@LABEL@" help="Requires internet. Will show an error if not online. Saves all the tabix file disk storage"/>
                 <param name="annoname" type="text" label="Short name for track display">
                     <sanitizer invalid_char="_">
                         <valid initial="string.printable">