Mercurial > repos > fubar > jbrowse2
changeset 7:b04fd993b31e draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 53a108d8153c955044ae7eb8cb06bdcfd0036717
author | fubar |
---|---|
date | Wed, 17 Jan 2024 07:50:52 +0000 |
parents | 79f7265f90bd |
children | 9a168aa68f06 |
files | 4f27993eab7751041e8c72047be3ea53_0.bw apache2_licence.txt jb2_webserver.py jbrowse2.py jbrowse2.xml plants.sh readme.rst webserver.py |
diffstat | 8 files changed, 564 insertions(+), 553 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/4f27993eab7751041e8c72047be3ea53_0.bw Wed Jan 17 07:50:52 2024 +0000 @@ -0,0 +1,82 @@ + +<!DOCTYPE HTML> +<html lang="en"> + <!--js-app.mako--> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + + <!-- Set meta description --> + + <meta name="description" content="Log in to Galaxy to get access to more tools and resources. Register now for a free account." /> + + <title> + Galaxy + | ToolFactoryDev + </title> + + <link rel="index" href="/"/> + + <link href="/static/dist/base.css?v=1704404015" media="screen" rel="stylesheet" type="text/css" /> + <link href="/static/style/jquery-ui/smoothness/jquery-ui.css?v=1704404015" media="screen" rel="stylesheet" type="text/css" /> + </head> + + <body scroll="no" class="full-content"> + <!-- Provide mount point for application --> + <main> + <div id="app"></div> + </main> + + + <noscript> + <div class="overlay overlay-background noscript-overlay"> + <div> + <h3 class="title">Javascript Required for Galaxy</h3> + <div> + The Galaxy analysis interface requires a browser with Javascript enabled.<br> + Please enable Javascript and refresh this page. + </div> + </div> + </div> + </noscript> + + + <script src="/static/dist/libs.bundled.js?v=1704404015" type="text/javascript"></script> +<script src="/static/dist/analysis.bundled.js?v=1704404015" type="text/javascript"></script> + + + + <script type="text/javascript"> + console.debug("Initializing javascript application:", "app"); + + // js-app.mako + var options = {"root": "/", "user": {"id": null, "total_disk_usage": 0.0, "nice_total_disk_usage": "0 bytes", "quota_percent": null}, "config": {"enable_notification_system": false, "welcome_directory": "plugins/welcome_page/new_user/static/topics/", "enable_celery_tasks": false, "admin_tool_recommendations_path": "/evol/galaxytf23.1.3/config/tool_recommendations_overwrite.yml", "version_extra": null, "tool_training_recommendations_api_url": "https://training.galaxyproject.org/training-material/api/top-tools.json", "expose_user_email": false, "simplified_workflow_run_ui_job_cache": "off", "toolbox_auto_sort": true, "is_admin_user": false, "message_box_class": "info", "show_welcome_with_login": true, "default_locale": "auto", "visualizations_visible": true, "interactivetools_enable": false, "ga_code": null, "allow_user_creation": false, "enable_account_interface": true, "nginx_upload_path": null, "quota_url": "https://galaxyproject.org/support/account-quotas/", "matomo_site_id": null, "object_store_ids_allowing_selection": [], "wiki_url": "https://galaxyproject.org/", "fixed_delegated_auth": false, "use_remote_user": null, "brand": "ToolFactoryDev", "screencasts_url": "https://www.youtube.com/c/galaxyproject", "helpsite_url": "https://help.galaxyproject.org/", "object_store_allows_id_selection": false, "enable_tool_recommendations": false, "oidc": {}, "plausible_domain": null, "simplified_workflow_run_ui": "prefer", "aws_estimate": false, "user_library_import_dir_available": false, "ftp_upload_site": null, "quota_source_labels": [], "tool_recommendation_model_path": "https://github.com/galaxyproject/galaxy-test-data/raw/master/tool_recommendation_model_v_0.2.hdf5", "enable_quotas": false, "markdown_to_pdf_available": false, "post_user_logout_href": "/root/login?is_logout_redirect=true", "enable_unique_workflow_defaults": false, "enable_oidc": false, "citations_export_message_html": "When writing up your analysis, remember to include all references that should be cited in order to completely describe your work. Also, please remember to <a href=\"https://galaxyproject.org/citing-galaxy\">cite Galaxy<\/a>.", "single_user": false, "python": [3, 10], "enable_beacon_integration": false, "logo_src": "/static/toolfactorylogo.png", "enable_tool_source_display": false, "require_login": true, "datatypes_disable_auto": false, "inactivity_box_content": "Your account has not been activated yet. Feel free to browse around and see what's available, but you won't be able to upload data or run jobs until you have verified your email address.", "mailing_join_addr": null, "topk_recommendations": 20, "terms_url": null, "logo_url": "/", "server_startttime": 1704404015, "panel_views": {"default": {"id": "default", "model_class": "type", "name": "Full Tool Panel", "description": "Galaxy's fully configured toolbox panel with all sections, tools, and configured workflows loaded.", "view_type": "default", "searchable": true}, "ontology:edam_operations": {"id": "ontology:edam_operations", "model_class": "EdamToolPanelView", "name": "EDAM Operations", "description": "Tools are grouped using annotated EDAM operation information (if available).", "view_type": "ontology", "searchable": true}, "ontology:edam_topics": {"id": "ontology:edam_topics", "model_class": "EdamToolPanelView", "name": "EDAM Topics", "description": "Tools are grouped using annotated EDAM topic information (if available).", "view_type": "ontology", "searchable": true}}, "message_box_visible": false, "cookie_domain": null, "allow_user_dataset_purge": true, "file_sources_configured": false, "overwrite_model_recommendations": false, "upload_from_form_button": "always-off", "message_box_content": null, "prefer_custos_login": false, "version_minor": "3", "support_url": "https://galaxyproject.org/support/", "registration_warning_message": "Please register only one account - we provide this service free of charge and have limited computational resources. Multi-accounts are tracked and will be subjected to account termination and data deletion.", "select_type_workflow_threshold": -1, "release_doc_base_url": "https://docs.galaxyproject.org/en/release_", "plausible_server": null, "lims_doc_url": "https://usegalaxy.org/u/rkchak/p/sts", "tool_training_recommendations_link": "https://training.galaxyproject.org/training-material/by-tool/{training_tool_identifier}.html", "citation_url": "https://galaxyproject.org/citing-galaxy", "matomo_server": null, "chunk_upload_size": 10485760, "welcome_url": "/static/welcome.html", "logo_src_secondary": null, "has_user_tool_filters": true, "remote_user_logout_href": null, "version_major": "23.1", "server_mail_configured": false, "default_panel_view": "default", "tool_training_recommendations": true, "simplified_workflow_run_ui_target_history": "prefer_current", "enable_beta_markdown_export": false, "allow_user_impersonation": false, "themes": {}, "active_view": "analysis", "enable_webhooks": true, "show_inactivity_warning": false, "tool_shed_urls": ["https://toolshed.g2.bx.psu.edu/"], "tool_dynamic_configs": ["/evol/galaxytf23.1.3/local_tools/local_tool_conf.xml"], "stored_workflow_menu_entries": []}, "params": {"redirect": "/datasets/cc4287507a7e4aae/display/4f27993eab7751041e8c72047be3ea53_0.bw"}, "session_csrf_token": "a403b55f14053e4e", "redirect": "/datasets/cc4287507a7e4aae/display/4f27993eab7751041e8c72047be3ea53_0.bw"}; + var bootstrapped = {}; + + config.set({ + options: options, + bootstrapped: bootstrapped, + form_input_auto_focus: false + }); + </script> + + + + <script type="text/javascript"> + + var sentry = {}; + + config.set({ + sentry: sentry + }); + + </script> + + + </body> +</html> + + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apache2_licence.txt Wed Jan 17 07:50:52 2024 +0000 @@ -0,0 +1,178 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jb2_webserver.py Wed Jan 17 07:50:52 2024 +0000 @@ -0,0 +1,184 @@ +#!/usr/bin/env python3# spec: simplest python web server with range support and multithreading that takes root path, +# port and bind address as command line arguments; by default uses the current dir as webroot, +# port 8000 and bind address of 0.0.0.0 +# borrowed from https://github.com/danvk/RangeHTTPServer +# and reborrowed from https://gist.github.com/glowinthedark/b99900abe935e4ab4857314d647a9068 +# +# The Apache 2.0 license copy in this repository is distributed with this code in accordance with that licence. +# https://www.apache.org/licenses/LICENSE-2.0.txt +# This part is not MIT licenced like the other components. + +# APPENDIX: How to apply the Apache License to your work. + +# To apply the Apache License to your work, attach the following +# boilerplate notice, with the fields enclosed by brackets "[]" +# replaced with your own identifying information. (Don't include +# the brackets!) The text should be enclosed in the appropriate +# comment syntax for the file format. We also recommend that a +# file or class name and description of purpose be included on the +# same "printed page" as the copyright notice for easier +# identification within third-party archives. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import argparse +import functools +import os +import re +import socketserver +import webbrowser +from http.server import SimpleHTTPRequestHandler + + +DEFAULT_PORT = 8080 + + +def copy_byte_range(infile, outfile, start=None, stop=None, bufsize=16 * 1024): + """Like shutil.copyfileobj, but only copy a range of the streams. + + Both start and stop are inclusive. + """ + if start is not None: + infile.seek(start) + while 1: + to_read = min(bufsize, stop + 1 - infile.tell() if stop else bufsize) + buf = infile.read(to_read) + if not buf: + break + outfile.write(buf) + + +BYTE_RANGE_RE = re.compile(r"bytes=(\d+)-(\d+)?$") + + +def parse_byte_range(byte_range): + """Returns the two numbers in 'bytes=123-456' or throws ValueError. + + The last number or both numbers may be None. + """ + if byte_range.strip() == "": + return None, None + + m = BYTE_RANGE_RE.match(byte_range) + if not m: + raise ValueError("Invalid byte range %s" % byte_range) + + first, last = [x and int(x) for x in m.groups()] + if last and last < first: + raise ValueError("Invalid byte range %s" % byte_range) + return first, last + + +class RangeRequestHandler(SimpleHTTPRequestHandler): + """Adds support for HTTP 'Range' requests to SimpleHTTPRequestHandler + + The approach is to: + - Override send_head to look for 'Range' and respond appropriately. + - Override copyfile to only transmit a range when requested. + """ + + def handle(self): + try: + SimpleHTTPRequestHandler.handle(self) + except Exception: + # ignored, thrown whenever the client aborts streaming (broken pipe) + pass + + def send_head(self): + if "Range" not in self.headers: + self.range = None + return SimpleHTTPRequestHandler.send_head(self) + try: + self.range = parse_byte_range(self.headers["Range"]) + except ValueError: + self.send_error(400, "Invalid byte range") + return None + first, last = self.range + + # Mirroring SimpleHTTPServer.py here + path = self.translate_path(self.path) + f = None + ctype = self.guess_type(path) + try: + f = open(path, "rb") + except IOError: + self.send_error(404, "File not found") + return None + + fs = os.fstat(f.fileno()) + file_len = fs[6] + if first >= file_len: + self.send_error(416, "Requested Range Not Satisfiable") + return None + + self.send_response(206) + self.send_header("Content-type", ctype) + + if last is None or last >= file_len: + last = file_len - 1 + response_length = last - first + 1 + + self.send_header("Content-Range", "bytes %s-%s/%s" % (first, last, file_len)) + self.send_header("Content-Length", str(response_length)) + self.send_header("Last-Modified", self.date_time_string(fs.st_mtime)) + self.end_headers() + return f + + def end_headers(self): + self.send_header("Accept-Ranges", "bytes") + return SimpleHTTPRequestHandler.end_headers(self) + + def copyfile(self, source, outputfile): + if not self.range: + return SimpleHTTPRequestHandler.copyfile(self, source, outputfile) + + # SimpleHTTPRequestHandler uses shutil.copyfileobj, which doesn't let + # you stop the copying before the end of the file. + start, stop = self.range # set in send_head() + copy_byte_range(source, outputfile, start, stop) + + +class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer): + allow_reuse_address = True + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Simple Python Web Server with Range Support" + ) + parser.add_argument( + "--root", + default=os.getcwd(), + help="Root path to serve files from (default: current working directory)", + ) + parser.add_argument( + "--port", + type=int, + default=DEFAULT_PORT, + help=f"Port to listen on (default: {DEFAULT_PORT})", + ) + parser.add_argument( + "--bind", default="0.0.0.0", help="IP address to bind to (default: 0.0.0.0)" + ) + args = parser.parse_args() + + handler = functools.partial(RangeRequestHandler, directory=args.root) + + webbrowser.open(f"http://{args.bind}:{args.port}") + + with ThreadedTCPServer((args.bind, args.port), handler) as httpd: + print( + f"Serving HTTP on {args.bind} port {args.port} (http://{args.bind}:{args.port}/)" + ) + httpd.serve_forever()
--- a/jbrowse2.py Tue Jan 09 06:55:34 2024 +0000 +++ b/jbrowse2.py Wed Jan 17 07:50:52 2024 +0000 @@ -17,6 +17,10 @@ logging.basicConfig(level=logging.INFO) log = logging.getLogger("jbrowse") + +JB2VER = "v2.10.0" +# version pinned for cloning + TODAY = datetime.datetime.now().strftime("%Y-%m-%d") GALAXY_INFRASTRUCTURE_URL = None JB2REL = "v2.10.0" @@ -371,7 +375,6 @@ class JbrowseConnector(object): def __init__(self, outdir, genomes): - self.debug = False self.usejson = True self.giURL = GALAXY_INFRASTRUCTURE_URL self.outdir = outdir @@ -387,16 +390,14 @@ def subprocess_check_call(self, command, output=None): if output: - if self.debug: - log.debug("cd %s && %s > %s", self.outdir, " ".join(command), output) + log.debug("cd %s && %s > %s", self.outdir, " ".join(command), output) subprocess.check_call(command, cwd=self.outdir, stdout=output) else: log.debug("cd %s && %s", self.outdir, " ".join(command)) subprocess.check_call(command, cwd=self.outdir) def subprocess_popen(self, command): - if self.debug: - log.debug(command) + log.debug(command) p = subprocess.Popen( command, cwd=self.outdir, @@ -414,8 +415,7 @@ raise RuntimeError("Command failed with exit code %s" % (retcode)) def subprocess_check_output(self, command): - if self.debug: - log.debug(" ".join(command)) + log.debug(" ".join(command)) return subprocess.check_output(command, cwd=self.outdir) def symlink_or_copy(self, src, dest): @@ -465,9 +465,14 @@ self.config_json["assemblies"] = assemblies def make_assembly(self, fapath, gname): - faname = gname + ".fa.gz" + hashData = [ + fapath, + gname, + ] + hashData = "|".join(hashData).encode("utf-8") + ghash = hashlib.md5(hashData).hexdigest() + faname = ghash + ".fa.gz" fadest = os.path.join(self.outdir, faname) - # fadest = os.path.realpath(os.path.join(self.outdir, faname)) cmd = "bgzip -i -c %s -I %s.gzi > %s && samtools faidx %s" % ( fapath, fadest, @@ -556,7 +561,7 @@ # can be served - if public. # dsId = trackData["metadata"]["dataset_id"] # url = "%s/api/datasets/%s/display?to_ext=hic " % (self.giURL, dsId) - hname = trackData["name"] + hname = trackData["label"] dest = os.path.join(self.outdir, hname) cmd = ["cp", data, dest] # these can be very big. @@ -603,8 +608,6 @@ tId = trackData["label"] fname = "%s.bed" % tId dest = "%s/%s" % (self.outdir, fname) - # self.symlink_or_copy(data, dest) - # Process MAF to bed-like. Need build to munge chromosomes gname = self.genome_name cmd = [ "bash", @@ -722,11 +725,11 @@ trackDict["style"] = style_json self.tracksToAdd.append(trackDict) self.trackIdlist.append(tId) - os.unlink(gff3) def add_bigwig(self, data, trackData): - url = "%s.bw" % trackData["name"] + 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) @@ -735,7 +738,7 @@ trackDict = { "type": "QuantitativeTrack", "trackId": tId, - "name": url, + "name": trackData["name"], "assemblyNames": [ self.genome_name, ], @@ -754,6 +757,7 @@ trackDict["style"] = style_json self.tracksToAdd.append(trackDict) self.trackIdlist.append(tId) + logging.debug("#### wig trackData=%s" % str(trackData)) def add_bam(self, data, trackData, bamOpts, bam_index=None, **kwargs): tId = trackData["label"] @@ -959,35 +963,24 @@ asstrack, ] - style_json = self._prepare_track_style(trackData) url = "%s.paf" % (trackData["label"]) dest = "%s/%s" % (self.outdir, url) self.symlink_or_copy(os.path.realpath(data), dest) - - if self.usejson: - trackDict = { - "type": "SyntenyTrack", - "trackId": tId, + trackDict = { + "type": "SyntenyTrack", + "trackId": tId, + "assemblyNames": [self.genome_name, pgname], + "name": tname, + "adapter": { + "type": "PAFAdapter", + "pafLocation": {"uri": url}, "assemblyNames": [self.genome_name, pgname], - "name": tname, - "adapter": { - "type": "PAFAdapter", - "pafLocation": {"uri": url}, - "assemblyNames": [self.genome_name, pgname], - }, - "config": style_json, - } - self.tracksToAdd.append(trackDict) - self.trackIdlist.append(tId) - else: - self._add_track( - trackData["label"], - trackData["key"], - trackData["category"], - dest, - assemblies=[self.genome_name, pgname], - config=style_json, - ) + }, + } + style_json = self._prepare_track_style(trackDict) + trackDict["style"] = style_json + self.tracksToAdd.append(trackDict) + self.trackIdlist.append(tId) def add_hicab(self, data, trackData, hicOpts, **kwargs): rel_dest = os.path.join("data", trackData["label"] + ".hic") @@ -995,14 +988,12 @@ self.symlink_or_copy(os.path.realpath(data), dest) - style_json = self._prepare_track_style(trackData) - self._add_track( trackData["label"], trackData["key"], trackData["category"], rel_dest, - config=style_json, + config={}, ) def add_sparql(self, url, query, query_refnames, trackData): @@ -1061,12 +1052,7 @@ } outputTrackConfig["key"] = track_human_label - if self.debug: - log.info( - "Processing category = %s, track_human_label = %s", - category, - track_human_label, - ) + # We add extra data to hash for the case of REST + SPARQL. if ( "conf" in track @@ -1076,7 +1062,7 @@ rest_url = track["conf"]["options"]["url"] else: rest_url = "" - + outputTrackConfig["trackset"] = track.get("trackset", {}) # I chose to use track['category'] instead of 'category' here. This # is intentional. This way re-running the tool on a different date # will not generate different hashes and make comparison of outputs @@ -1165,26 +1151,22 @@ for track_conf in self.tracksToAdd: track_types[track_conf["trackId"]] = track_conf["type"] - - for on_track in data["visibility"]["default_on"]: - style_data = {"type": "LinearBasicDisplay", "height": 100} - if on_track in data["style"]: - if "display" in data["style"][on_track]: - style_data["type"] = data["style"][on_track]["display"] - del data["style"][on_track]["display"] - style_data.update(data["style"][on_track]) - if on_track in data["style_labels"]: - # TODO fix this: it should probably go in a renderer block (SvgFeatureRenderer) but still does not work - # TODO move this to per track displays? - style_data["labels"] = data["style_labels"][on_track] - - tracks_data.append( - { - "type": track_types[on_track], - "configuration": on_track, - "displays": [style_data], - } - ) + tId = track_conf["trackId"] + if tId in data["visibility"]["default_on"]: + style_data = {"type": "LinearBasicDisplay"} + if "displays" in track_conf: + style_data["type"] = track_conf["displays"][0]["type"] + 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? + style_data["labels"] = track_conf["style_labels"] + tracks_data.append( + { + "type": track_types[tId], + "configuration": tId, + "displays": [style_data], + } + ) # The view for the assembly we're adding view_json = {"type": "LinearGenomeView", "tracks": tracks_data} @@ -1199,7 +1181,7 @@ elif self.genome_name is not None: refName = self.genome_name start = 0 - end = 100000 # Booh, hard coded! waiting for https://github.com/GMOD/jbrowse-components/issues/2708 + end = 10000 # Booh, hard coded! waiting for https://github.com/GMOD/jbrowse-components/issues/2708 if refName is not None: # TODO displayedRegions is not just zooming to the region, it hides the rest of the chromosome @@ -1265,8 +1247,11 @@ def clone_jbrowse(self): """Clone a JBrowse directory into a destination directory.""" + # dest = os.path.realpath(self.outdir) dest = self.outdir - cmd = ["jbrowse", "create", "-t", JB2REL, "-f", dest] + cmd = ["rm", "-rf", dest + "/*"] + self.subprocess_check_call(cmd) + cmd = ["jbrowse", "create", dest, "-t", JB2VER, "-f"] self.subprocess_check_call(cmd) for fn in [ "asset-manifest.json", @@ -1278,7 +1263,7 @@ ]: cmd = ["rm", "-rf", os.path.join(self.outdir, fn)] self.subprocess_check_call(cmd) - cmd = ["cp", os.path.join(INSTALLED_TO, "webserver.py"), self.outdir] + cmd = ["cp", os.path.join(INSTALLED_TO, "jb2_webserver.py"), self.outdir] self.subprocess_check_call(cmd) @@ -1386,21 +1371,17 @@ {}, # No metadata for multiple bigwig ) ) - track_conf["category"] = track.attrib["cat"] track_conf["format"] = track.attrib["format"] - track_conf["style"] = { - item.tag: parse_style_conf(item) for item in track.find("options/style") - } - - track_conf["style"] = { - item.tag: parse_style_conf(item) for item in track.find("options/style") - } - - track_conf["style_labels"] = { - item.tag: parse_style_conf(item) - for item in track.find("options/style_labels") - } + if track.find("options/style"): + track_conf["style"] = { + item.tag: parse_style_conf(item) for item in track.find("options/style") + } + if track.find("options/style_labels"): + track_conf["style_labels"] = { + item.tag: parse_style_conf(item) + for item in track.find("options/style_labels") + } track_conf["conf"] = etree_to_dict(track.find("options")) keys = jc.process_annotations(track_conf) @@ -1410,10 +1391,14 @@ default_session_data["visibility"][ track.attrib.get("visibility", "default_off") ].append(key) - default_session_data["style"][key] = track_conf[ - "style" - ] # TODO do we need this anymore? - default_session_data["style_labels"][key] = track_conf["style_labels"] + if track_conf.get("style", None): + default_session_data["style"][key] = track_conf[ + "style" + ] # TODO do we need this anymore? + if track_conf.get("style_lables", None): + default_session_data["style_labels"][key] = track_conf.get( + "style_labels", None + ) default_session_data["defaultLocation"] = root.find( "metadata/general/defaultLocation" @@ -1444,7 +1429,6 @@ jc.config_json["tracks"] = jc.tracksToAdd if jc.usejson: jc.write_config() - # jc.add_default_view() jc.add_default_session(default_session_data) # jc.text_index() not sure what broke here.
--- a/jbrowse2.xml Tue Jan 09 06:55:34 2024 +0000 +++ b/jbrowse2.xml Wed Jan 17 07:50:52 2024 +0000 @@ -130,145 +130,9 @@ #end if <options> - <style> - <display>${track.data_format.jbstyle.track_style.display}</display> - ## TODO change this to a for loop? - #if 'show_labels' in $track.data_format.jbstyle.track_style - <trackShowLabels type="boolean">${track.data_format.jbstyle.track_style.show_labels}</trackShowLabels> - #end if - #if 'show_descriptions' in $track.data_format.jbstyle.track_style - <trackShowDescriptions type="boolean">${track.data_format.jbstyle.track_style.show_descriptions}</trackShowDescriptions> - #end if - #if 'display_mode' in $track.data_format.jbstyle.track_style - <trackDisplayMode>${track.data_format.jbstyle.track_style.display_mode}</trackDisplayMode> - #end if - #if 'max_height' in $track.data_format.jbstyle.track_style - <trackMaxHeight type="integer">${track.data_format.jbstyle.track_style.max_height}</trackMaxHeight> - #end if - #if 'autoscale' in $track.data_format.jbstyle.track_style - <autoscale>${track.data_format.jbstyle.track_style.autoscale}</autoscale> - #end if - #if 'resolution' in $track.data_format.jbstyle.track_style - <resolution type="integer">${track.data_format.jbstyle.track_style.resolution}</resolution> - #end if - #if 'summaryScoreMode' in $track.data_format.jbstyle.track_style - <summaryScoreMode>${track.data_format.jbstyle.track_style.summaryScoreMode}</summaryScoreMode> - #end if - #if 'scaleType' in $track.data_format.jbstyle.track_style - <scaleType>${track.data_format.jbstyle.track_style.scaleType}</scaleType> - #end if - #if 'filled' in $track.data_format.jbstyle.track_style - <filled type="boolean">${track.data_format.jbstyle.track_style.filled}</filled> - #end if - #if 'displayCrossHatches' in $track.data_format.jbstyle.track_style - <displayCrossHatches type="boolean">${track.data_format.jbstyle.track_style.displayCrossHatches}</displayCrossHatches> - #end if - #if 'minScore' in $track.data_format.jbstyle.track_style and $track.data_format.jbstyle.track_style.minScore - <minScore type="integer">${track.data_format.jbstyle.track_style.minScore}</minScore> - #end if - #if 'maxScore' in $track.data_format.jbstyle.track_style and $track.data_format.jbstyle.track_style.maxScore - <maxScore type="integer">${track.data_format.jbstyle.track_style.maxScore}</maxScore> - #end if - ## TODO other coloring/etc options in each renderer (e.g https://github.com/GMOD/jbrowse-components/blob/main/plugins/svg/src/SvgFeatureRenderer/configSchema.ts) - </style> - <style_labels> - ## TODO other label options: https://github.com/GMOD/jbrowse-components/blob/main/plugins/svg/src/SvgFeatureRenderer/configSchema.ts - #if 'label' in $track.data_format.jbstyle.track_style - <name>${track.data_format.jbstyle.track_style.label}</name> - #end if - #if 'description' in $track.data_format.jbstyle.track_style - <description>${track.data_format.jbstyle.track_style.description}</description> - #end if - </style_labels> - #if str($track.data_format.data_format_select) == "gene_calls" or str($track.data_format.data_format_select) == "blast" or str($track.data_format.data_format_select) == "sparql": - <scaling> - #if str($track.data_format.jbcolor_scale.color_score.color_score_select) == "none": - <method>ignore</method> - <scheme> - #if str($track.data_format.jbcolor_scale.color_score.color.color_select) == "automatic": - <color>__auto__</color> - #else - <color>${track.data_format.jbcolor_scale.color_score.color.style_color}</color> - #end if - </scheme> - #else - <method>score</method> - <algo>${track.data_format.jbcolor_scale.color_score.score_scaling}</algo> - <scales> - <type>${track.data_format.jbcolor_scale.color_score.score_scales.scale_select}</type> + - #if str($track.data_format.jbcolor_scale.color_score.score_scales.scale_select) == "manual": - <min>${track.data_format.jbcolor_scale.color_score.score_scales.minimum}</min> - <max>${track.data_format.jbcolor_scale.color_score.score_scales.maximum}</max> - #end if - </scales> - <scheme> - <type>${track.data_format.jbcolor_scale.color_score.color_scheme.score_scheme}</type> - ## auto_color - #if str($track.data_format.jbcolor_scale.color_score.color_scheme.score_scheme) == "opacity": - #if str($track.data_format.jbcolor_scale.color_score.color_scheme.color.color_select) == "automatic": - <color>__auto__</color> - #else - <color>${track.data_format.jbcolor_scale.color_score.color_scheme.color.style_color}</color> - #end if - #end if - </scheme> - #end if - </scaling> - <menus> - #for $menu_item in $track.data_format.jbmenu.track_menu: - <menu> - <action>${menu_item.menu_action}</action> - #if str($menu_item.menu_label) != "": - <label>${menu_item.menu_label}</label> - #end if - #if str($menu_item.menu_title) != "": - <title>${menu_item.menu_title}</title> - #end if - #if str($menu_item.menu_url) != "": - <url>${menu_item.menu_url.replace("&", "&").replace("\"", """)}</url> - #end if - #if str($menu_item.menu_icon) != "": - <iconClass>${menu_item.menu_icon}</iconClass> - #end if - </menu> - #end for - </menus> - #end if - - #if str($track.data_format.data_format_select) == "wiggle": - <wiggle> - <type>${track.data_format.xyplot}</type> - <variance_band>${track.data_format.var_band}</variance_band> - #if str($track.data_format.scaling.scale_select) == "auto_local": - <autoscale>local</autoscale> - #else if str($track.data_format.scaling.scale_select) == "auto_global": - <autoscale>global</autoscale> - #else: - <min>${track.data_format.scaling.minimum}</min> - <max>${track.data_format.scaling.maximum}</max> - #end if - <scale>${track.data_format.scale_select2}</scale> - - ## Wiggle tracks need special color config - #if str($track.data_format.jbcolor.color.color_select) != "automatic": - <color_pos>${track.data_format.jbcolor.color.style_pos_color}</color_pos> - <color_neg>${track.data_format.jbcolor.color.style_neg_color}</color_neg> - #else: - <color_pos>__auto__</color_pos> - <color_neg>__auto__</color_neg> - #end if - - ## Bicolor pivot config - #if str($track.data_format.jbcolor.bicolor_pivot.bicolor_pivot_select) == "zero": - <bicolor_pivot>zero</bicolor_pivot> - #else if str($track.data_format.jbcolor.bicolor_pivot.bicolor_pivot_select) == "mean": - <bicolor_pivot>mean</bicolor_pivot> - #else: - <bicolor_pivot>${track.data_format.jbcolor.bicolor_pivot.pivot_point}</bicolor_pivot> - #end if - </wiggle> - #else if str($track.data_format.data_format_select) == "pileup": + #if str($track.data_format.data_format_select) == "pileup": <pileup> <bam_indices> #for $dataset in $track.data_format.annotation: @@ -291,14 +155,12 @@ #end if <protein>${track.data_format.is_protein}</protein> <min_gap>${track.data_format.min_gap}</min_gap> - <index>${track.data_format.index}</index> </blast> #else if str($track.data_format.data_format_select) == "gene_calls": <gff> #if $track.data_format.match_part.match_part_select == "true": <match>${track.data_format.match_part.name}</match> #end if - <index>${track.data_format.index}</index> </gff> #else if str($track.data_format.data_format_select) == "synteny": <synteny> @@ -360,17 +222,17 @@ value="Default" help="Organise your tracks into Categories for a nicer end-user experience. You can use #date# and it will be replaced with the current date in 'yyyy-mm-dd' format, which is very useful for repeatedly updating a JBrowse instance when member databases / underlying tool versions are updated." optional="False"/> <repeat name="data_tracks" title="Annotation Track"> - <conditional name="data_format" label="Track Options"> + <conditional name="data_format" label="Track Data Selection Options"> <param type="select" label="Track Type" name="data_format_select"> <option value="pileup">BAM Pileup track</option> - <option value="wiggle">BigWig XY track</option> - <option value="blast">Blast XML track - converted to GFF with actual gaps between hits</option> + <option value="wiggle">BigWig track</option> + <option value="blast">Blast XML track - converted to GFF</option> <option value="cram">CRAM</option> - <option value="gene_calls" selected="true">GFF/GFF3/BED feature tracks</option> - <option value="hic">HiC binary data. Existing cool format must be converted to binary hic - hic_matrix will NOT work.</option> + <option value="gene_calls" selected="true">GFF/GFF3/BED feature track</option> + <option value="hic">HiC (compressed binary) track. Existing cool format must be converted to binary hic - hic_matrix will NOT work.</option> <option value="sparql">SPARQL</option> - <option value="synteny">Synteny</option> - <option value="vcf">VCF SNP annotation track</option> + <option value="synteny">Synteny track with PAF data</option> + <option value="vcf">VCF SNP annotation</option> </param> <when value="blast"> <expand macro="input_conditional" label="BlastXML Track Data" format="blastxml" /> @@ -393,18 +255,6 @@ name="is_protein" truevalue="true" falsevalue="false" /> - - <param label="Index this track" name="index" type="boolean" checked="false" truevalue="true" falsevalue="false" /> - - <expand macro="track_styling_feature" - classname="feature" - label="description" - description="Hit_titles" - height="600px"/> - <expand macro="color_selection" - token_scaling_lin_select="false" - token_scaling_log_select="true" /> - <expand macro="track_menu" /> <expand macro="track_visibility" /> </when> <when value="vcf"> @@ -429,68 +279,20 @@ </when> <when value="false" /> </conditional> - - <param label="Index this track" name="index" type="boolean" checked="false" truevalue="true" falsevalue="false" /> - - <expand macro="track_styling_feature" - classname="feature" - label="product,name,id" - description="note,description" - height="10px"/> - <expand macro="color_selection" /> - <expand macro="track_menu" /> <expand macro="track_visibility" /> </when> <when value="pileup"> <expand macro="input_conditional" label="BAM Track Data" format="bam" /> - <expand macro="track_styling_xam"/> <expand macro="track_visibility" /> </when> <when value="cram"> <expand macro="input_conditional" label="CRAM Track Data" format="cram" /> - <expand macro="track_styling_xam"/> <expand macro="track_visibility" /> </when> <when value="wiggle"> <expand macro="input_conditional" label="BigWig Track Data" format="bigwig" /> - - <param label="Use XYPlot" - help="instead of continuous colored band" - type="boolean" - name="xyplot" - truevalue="JBrowse/View/Track/Wiggle/XYPlot" - falsevalue="JBrowse/View/Track/Wiggle/Density" /> - <param label="Show variance band" - help="Only for XYPlots" - type="boolean" - name="var_band" - truevalue="true" - falsevalue="false" /> + <expand macro="track_visibility" /> - <conditional name="scaling" label="Scaling"> - <param type="select" label="Track Scaling" name="scale_select"> - <option value="auto_local" selected="true">Autoscale (local)</option> - <option value="auto_global">Autoscale (global)</option> - <option value="fixed">Specify Min/Max</option> - </param> - <when value="auto_local"></when> - <when value="auto_global"></when> - <when value="fixed"> - <param label="Track minimum" name="minimum" - type="integer" value="0" /> - <param label="Track maximum" name="maximum" - type="integer" value="100" /> - </when> - </conditional> - <param type="select" label="Visual Scaling" name="scale_select2"> - <option value="linear" selected="true">Linear</option> - <option value="log">Logarithmic (Dynamically Calculated)</option> - </param> - - <expand macro="color_selection_minmax" /> - - <expand macro="track_styling_bigwig"/> - <expand macro="track_visibility" /> </when> <when value="synteny"> @@ -498,7 +300,7 @@ format="fasta" name="synteny_genome" type="data" /> - <!-- TODO add .out (MashMap) .chain (UCSC), .delta (mummer) and .anchors (mcscan) inputs --> + <expand macro="input_conditional" label="Synteny data" format="paf" /> <expand macro="track_visibility" /> </when> @@ -593,7 +395,6 @@ <has_text text="trackFile path="></has_text> <has_text text="file_ext="bigwig""></has_text> <has_text text="format="wiggle""></has_text> - <has_text text="LinearWiggleDisplay"></has_text> </assert_contents> </output> </test> @@ -908,7 +709,6 @@ <conditional name="data_format"> <param name="data_format_select" value="gene_calls"/> <param name="annotation" value="gff3/1.gff"/> - <param name="index" value="true"/> <conditional name="match_part"> <param name="match_part_select" value="false"/> </conditional> @@ -928,13 +728,10 @@ <output name="output"> <assert_contents> <has_text text="With menu or index"/> - <has_text text="Some menu item"/> - <has_text text="Frame title"/> - <has_text text="dijitIconNewTask"/> + <has_text text="gene_calls"/> </assert_contents> </output> </test> - <!-- TODO add a synteny test --> <!-- TODO add a bam and a cram test --> <!-- TODO add an hic test --> @@ -955,16 +752,22 @@ Use and local viewing ===================== + A JBrowse2 history item can be opened by viewing it (the "eye" icon). -They can also be downloaded as archives ("floppy disk" icon) to share and for local viewing. -One extra step is required before they can be viewed. A local python web server must be started using a script included in each archive. -Unzip the archive (*unzip [filename].zip*) and change to the first level directory. It contains a file named "webserver.py" + +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. +This can be shared and viewed without Galaxy. -Assuming you have python3 installed, running: +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, +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 +directory to the first level in that zip archive. It contains a file named *jb2_webserver.py* -*python3 webserver.py* +With python3 installed, -will serve the unarchived JBrowse2 configuration, so it can be browsed by pointing a web browser to localhost:8080 +*python3 jb2_webserver.py* + +will serve the unarchived JBrowse2 configuration from the same directory as the python script automatically. If a new browser window does not open, +but the script appears to be running, try pointing your web browser to the default of *localhost:8080* Overview -------- @@ -973,13 +776,9 @@ JavaScript and HTML5. The JBrowse-in-Galaxy (JiG) tool was written to help build complex -JBrowse installations straight from Galaxy, taking advantage of the -latest Galaxy features such as dataset collections, sections, and colour -pickers. It allows you to build up a JBrowse instance without worrying +JBrowse installations straight from Galaxy. It allows you to build up a JBrowse instance without worrying about how to run the command line tools to format your data, and which -options need to be supplied and where. Additionally it comes with many -javascript functions to handle colouring of features which would be -nearly impossible to write without the assistance of this tool. +options need to be supplied and where. The JBrowse-in-Galaxy tool is maintained by `the Galaxy IUC <https://github.com/galaxyproject/tools-iuc/issues>`__, who you can help you @@ -988,8 +787,8 @@ Options ------- -The first option you encounter is the **Fasta Sequence(s)**. This option -now accepts multiple fasta files, allowing you to build JBrowse +The first option you encounter is the **Reference sequence(s)** to use. This option +now accepts multiple fasta files, allowing you to build JBrowse2 instances that contain data for multiple genomes or chrosomomes (generally known as "landmark features" in gff3 terminology.) @@ -1046,11 +845,6 @@ they should adjust feature locations by 3x. -VCFs/SNPs -~~~~~~~~~ - -These tracks do not support any special configuration. - @ATTRIBUTION@ ]]></help> <expand macro="citations"/>
--- a/plants.sh Tue Jan 09 06:55:34 2024 +0000 +++ b/plants.sh Wed Jan 17 07:50:52 2024 +0000 @@ -1,1 +1,1 @@ -planemo shed_update --shed_target toolshed --owner fubar --name jbrowse2 --shed_key 8d01f2f35d48a0405f72d6d37aedde60 jbrowse2 +planemo shed_update --shed_target toolshed --owner fubar --name jbrowse2 --shed_key 8d01f2f35d48a0405f72d6d37aedde60 ./
--- a/readme.rst Tue Jan 09 06:55:34 2024 +0000 +++ b/readme.rst Wed Jan 17 07:50:52 2024 +0000 @@ -8,92 +8,40 @@ workflow summary. E.g. annotate a genome, then visualise all of the associated datasets as an interactive HTML page. This tool MUST be whitelisted (or ``sanitize_all_html=False`` in galaxy.ini) to function correctly. -gunicorn does not support byte range requests, so this tool must be served by nginx -or other web server, correctly configured to support range requests. +The built-in Galaxy gunicorn server does not support byte range requests, so this tool must be proxied by nginx +or another web server, correctly configured to support range requests. A tiny web server is bundled +with each JBrowse2 archive - see below. Installation ============ -It is recommended to install this wrapper via the Galaxy Tool Shed. +This wrapper is normally installed by a server administrator from the Galaxy Tool Shed IUC JBrowse2 repository. -Running Locally -=============== +Local display +============= -The Galaxy tool interface writes out a xml file which is then used to generate -the visualizations. An example used during development/testing can be seen in -`test-data/*/test.xml`. The format is in no way rigorously defined and is -likely to change at any time! Beware. ;) +Each JBrowse2 history item can be downloaded ("floppy disk" icon) to your local disk. There, it can be unzipped into a new directory. +That directory includes a python script, *jb2_webserver.py* that will run a local web server able to serve byte range requests, +giving the same view as seen when viewed from the Galaxy history. + +From the newly unzipped directory where that file can be found, and with Python3 installed and working, + +`python3 jb2_webserver.py` + +will open the preconfigured browser using the default web browser application. History ======= - 2.10.0+galaxy2 - - UPDATED to JBrowse 2.10.0 - - REMOVED most colour and track control from XML and script. + - UPDATED existing JBrowse1.16.11 code to JBrowse 2.10.0 - seems to work well with defaults. - need to document and implement track settings by running the browser locally. - works well enough to be useful in workflows such as TreeValGal. - JB2 seems to set defaults wisely. - not yet ideal for users who need fine grained track control. -- 1.16.11+galaxy0 - - - UPDATED to JBrowse 1.16.11 - -- 1.16.10+galaxy0 - - - UPDATED to JBrowse 1.16.10 - - ADDED GALAXY_JBROWSE_SYMLINKS environment variable: if set, the tool will make symlinks to bam/bigwig files instead of copying them - -- 1.16.9+galaxy0 - - - UPDATED to JBrowse 1.16.9 - -- 1.16.8+galaxy0 - - - UPDATED to JBrowse 1.16.8 - -- 1.16.5+galaxy0 - - - UPDATED to JBrowse 1.16.5 - -- 1.16.4+galaxy0 - - - UPDATED to JBrowse 1.16.4 - - ADDED filter too big metadata - - CHANGED default value for topLevelFeatures (gene subfeatures are now inferred) and style.className (feature style was fixed) - -- 1.16.2+galaxy0 - - - UPDATED to JBrowse 1.16.2 - - ADDED support for NeatHTMLFeatures and NeatCanvasFeatures track types - -- 1.16.1+galaxy0 - - - UPDATED to JBrowse 1.16.1 - - ADDED support for MultiBigWig plugin - - ADDED support for tabix indexing of fasta and gff - - ADDED support for REST and SPARQL endpoints - - ADDED option to change chunk size for BAM tracks - - FIXED loading of VCF files. They were gzipped and the URLs were incorrect - - FIXED metadata on tracks types other than GFF+HTML - - FIXED infrastructure URL parsing (and embedding in links) for some tracks - - REMOVED support for selecting multiple genomes as input due to tracking of track metadata - - REMOVED support for themes as JBrowse no longer allow runtime loading of plugins - -- 0.7 Support for plugins (currently GC Content, Bookmarks, ComboTrackSelector), - track metadata -- 0.5.2 Support for CanvasFeatures options. -- 0.5.1 Support for contextual menus. Conda tests. -- 0.5 Update existing instances on disk. Index names. Support HTML tracks - instead of Canvas. Support default tracks. General JBrowse optinos -- 0.4 Support for dataset collections and customisation of tracks including - labelling, colours, styling. Added support for genetic code selection. - Fixed package installation recipe issues. -- 0.3 Added support for BigWig, etc. -- 0.2 Added support for BAM, Blast, VCF. -- 0.1 Initial public release. Wrapper License (MIT/BSD Style) ===============================
--- a/webserver.py Tue Jan 09 06:55:34 2024 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,159 +0,0 @@ -#!/usr/bin/env python3 - -# spec: simplest python web server with range support and multithreading that takes root path, -# port and bind address as command line arguments; by default uses the current dir as webroot, -# port 8000 and bind address of 0.0.0.0 -# borrowed from https://github.com/danvk/RangeHTTPServer -# and reborrowed from https://gist.github.com/glowinthedark/b99900abe935e4ab4857314d647a9068 - - -import argparse -import functools -import os -import re -import socketserver -import webbrowser -from http.server import SimpleHTTPRequestHandler - - -DEFAULT_PORT = 8080 - - -def copy_byte_range(infile, outfile, start=None, stop=None, bufsize=16 * 1024): - """Like shutil.copyfileobj, but only copy a range of the streams. - - Both start and stop are inclusive. - """ - if start is not None: - infile.seek(start) - while 1: - to_read = min(bufsize, stop + 1 - infile.tell() if stop else bufsize) - buf = infile.read(to_read) - if not buf: - break - outfile.write(buf) - - -BYTE_RANGE_RE = re.compile(r"bytes=(\d+)-(\d+)?$") - - -def parse_byte_range(byte_range): - """Returns the two numbers in 'bytes=123-456' or throws ValueError. - - The last number or both numbers may be None. - """ - if byte_range.strip() == "": - return None, None - - m = BYTE_RANGE_RE.match(byte_range) - if not m: - raise ValueError("Invalid byte range %s" % byte_range) - - first, last = [x and int(x) for x in m.groups()] - if last and last < first: - raise ValueError("Invalid byte range %s" % byte_range) - return first, last - - -class RangeRequestHandler(SimpleHTTPRequestHandler): - """Adds support for HTTP 'Range' requests to SimpleHTTPRequestHandler - - The approach is to: - - Override send_head to look for 'Range' and respond appropriately. - - Override copyfile to only transmit a range when requested. - """ - - def handle(self): - try: - SimpleHTTPRequestHandler.handle(self) - except Exception: - # ignored, thrown whenever the client aborts streaming (broken pipe) - pass - - def send_head(self): - if "Range" not in self.headers: - self.range = None - return SimpleHTTPRequestHandler.send_head(self) - try: - self.range = parse_byte_range(self.headers["Range"]) - except ValueError: - self.send_error(400, "Invalid byte range") - return None - first, last = self.range - - # Mirroring SimpleHTTPServer.py here - path = self.translate_path(self.path) - f = None - ctype = self.guess_type(path) - try: - f = open(path, "rb") - except IOError: - self.send_error(404, "File not found") - return None - - fs = os.fstat(f.fileno()) - file_len = fs[6] - if first >= file_len: - self.send_error(416, "Requested Range Not Satisfiable") - return None - - self.send_response(206) - self.send_header("Content-type", ctype) - - if last is None or last >= file_len: - last = file_len - 1 - response_length = last - first + 1 - - self.send_header("Content-Range", "bytes %s-%s/%s" % (first, last, file_len)) - self.send_header("Content-Length", str(response_length)) - self.send_header("Last-Modified", self.date_time_string(fs.st_mtime)) - self.end_headers() - return f - - def end_headers(self): - self.send_header("Accept-Ranges", "bytes") - return SimpleHTTPRequestHandler.end_headers(self) - - def copyfile(self, source, outputfile): - if not self.range: - return SimpleHTTPRequestHandler.copyfile(self, source, outputfile) - - # SimpleHTTPRequestHandler uses shutil.copyfileobj, which doesn't let - # you stop the copying before the end of the file. - start, stop = self.range # set in send_head() - copy_byte_range(source, outputfile, start, stop) - - -class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer): - allow_reuse_address = True - - -if __name__ == "__main__": - parser = argparse.ArgumentParser( - description="Simple Python Web Server with Range Support" - ) - parser.add_argument( - "--root", - default=os.getcwd(), - help="Root path to serve files from (default: current working directory)", - ) - parser.add_argument( - "--port", - type=int, - default=DEFAULT_PORT, - help=f"Port to listen on (default: {DEFAULT_PORT})", - ) - parser.add_argument( - "--bind", default="0.0.0.0", help="IP address to bind to (default: 0.0.0.0)" - ) - args = parser.parse_args() - - handler = functools.partial(RangeRequestHandler, directory=args.root) - - webbrowser.open(f"http://{args.bind}:{args.port}") - - with ThreadedTCPServer((args.bind, args.port), handler) as httpd: - print( - f"Serving HTTP on {args.bind} port {args.port} (http://{args.bind}:{args.port}/)" - ) - httpd.serve_forever()