Previous changeset 34:2893ef33fba9 (2024-02-25) Next changeset 36:5f39f745682f (2024-02-29) |
Commit message:
planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit 80b849766a962bac4bd0bb8cb69c118cc42699cd-dirty |
modified:
autogenJB2.py autogenJB2.xml jbrowse2.py jbrowse2.xml macros.xml |
b |
diff -r 2893ef33fba9 -r 15da358c3108 autogenJB2.py --- a/autogenJB2.py Sun Feb 25 04:18:53 2024 +0000 +++ b/autogenJB2.py Wed Feb 28 10:08:57 2024 +0000 |
[ |
b'@@ -1,65 +1,66 @@\n import argparse\n-import re\n+import logging\n import sys\n \n-from jbrowse2 import jbrowseConnector as jbC\n+from jbrowse2 import JbrowseConnector as jbC\n+\n+logging.basicConfig(level=logging.debug)\n+log = logging.getLogger("jbrowse")\n \n \n-def makeDefaultLocation(jc, defLoc=None):\n-\n- refName = None\n- drdict = {\n- "reversed": False,\n- "assemblyName": jc.genome_name,\n- "start": 0,\n- "end": 100000,\n- }\n+def makeDefaultLocation():\n \n- if defLoc:\n- loc_match = re.search(r"^([^:]+):([\\d,]*)\\.*([\\d,]*)$", defLoc)\n- # allow commas like 100,000 but ignore as integer\n- if loc_match:\n- refName = loc_match.group(1)\n- drdict["refName"] = refName\n- if loc_match.group(2) > "":\n- drdict["start"] = int(loc_match.group(2).replace(",", ""))\n- if loc_match.group(3) > "":\n- drdict["end"] = int(loc_match.group(3).replace(",", ""))\n- else:\n- jc.logging.info(\n- "@@@ regexp could not match contig:start..end in the supplied location %s - please fix"\n- % defLoc\n- )\n- else:\n- drdict["refName"] = jc.genome_firstcontig\n- if drdict.get("refName", None):\n- jc.logging.info("@@@ defaultlocation %s for default session" % drdict)\n- return drdict\n- else:\n- jc.logging.info("@@@ no contig name found for default session - please add one!")\n- return None\n+ refName = jc.genome_firstcontig\n+ defloc = "%s:100..10000" % refName\n+ print (\'defloc\',defloc)\n+ return defloc\n \n \n if __name__ == "__main__":\n parser = argparse.ArgumentParser(description="", epilog="")\n- parser.add_argument("--sessname", help="Session name", default="AutoJBrowse")\n+ parser.add_argument("--sessName", help="Session name", default="AutoJBrowse")\n+ parser.add_argument(\n+ "--trackmeta",\n+ help="Repeatable of \'filename, filext,filepath, ... ,\' for JBrowse2 tracks",\n+ default=[],\n+ action="append",\n+ )\n parser.add_argument(\n- "--collection",\n- help="Collection of \'filepath, filename, filext\' for JBrowse2",\n+ "--referencemeta",\n+ help="Repeatable \'filename, filext, filepath, ... ,\' for JBrowse2 reference tracks",\n default=[],\n- action="extend",\n+ action="append",\n+ )\n+ parser.add_argument(\n+ "--pafmeta",\n+ help="Repeatable. Each is a \'filename, filext, filepath, ... ,\' for a JBrowse2 paf track",\n+ default=[],\n+ action="append",\n )\n- parser.add_argument("--version", "-V", action="version", version="%(prog)s 0.0.1")\n+ parser.add_argument(\n+ "--pafreferencemeta",\n+ help="Repeatable. Each is a \'pafname,filepath,refname,filepath,refname....\'. Every paf must have a corresponding one ",\n+ default=[],\n+ action="append",\n+ )\n+\n+ parser.add_argument("--version", "-V", action="version", version="%(prog)s 2.10.2")\n+ parser.add_argument("--outdir", help="Output directory", required=True)\n args = parser.parse_args()\n- sessName = args.sessname\n- flistList = [x.split(",") for x in args.collection]\n- if flistList:\n- listgenomes = [f for f in flistList if f[0].startswith("REFERENCE_")]\n+ sessName = args.sessName\n+ # --trackmeta $jbrowseme[$key],$jbrowseme[$key].ext,\'$key\'\n+ trackList = [x.strip().split(",") for x in args.trackmeta if x > \'\']\n+ refList = [x.strip().split(",") for x in args.referencemeta if x > \'\']\n+ print("tracklist = %s\\nreflist = %s" % (trackList,refList))\n+ if len(refList) > 0:\n+ listgenomes = [f for f in refList if f[1] in [\'fasta\', \'fasta.gz\']]\n+ # assume no pafs here\n+ print(\'genomes=%s\' % listgenomes)\n if len(listgenomes) > 0:\n genome_paths = [\n- x[1] for x in listgenomes\n+ x[0] for x in listgenomes\n ] # expect genome_1_genomename.fasta etc\n- '..b' defLoc = makeDefaultLocation(jc)\n- listtracks = [f for f in flistList if not f[0].startswith("REFERENCE_")]\n+\n+ listtracks = trackList\n # foo.paf must have a foo_paf.fasta or fasta.gz to match\n- tnames = [x[0] for x in listtracks]\n- texts = [x[2] for x in listtracks]\n+ tnames = [x[2] for x in listtracks]\n+ texts = [x[1] for x in listtracks]\n for i, track in enumerate(listtracks):\n- if track[2] == "paf":\n- refname = track[0] + "_paf.fasta"\n- refdat = [x[1] for x in listtracks if x[0] == refname]\n+ tpath, trext, trackname = track[:3]\n+ if trext == "paf":\n+ refname = trackname + "_paf.fasta"\n+ refdat = [x[2] for x in listtracks if x[2] == refname]\n if not refdat:\n jc.logging.warn(\n "!! No reference file %s corresponding to paf file %s found. Not building - there must be a corresponding fasta for each paf"\n- % (refname, tnames[i])\n+ % (refname, trackname)\n )\n sys.exit(3)\n else:\n track_conf = {\n "conf": {\n "options": {\n- "paf": {"genome": refdat, "genome_label": track[0]}\n+ "paf": {"genome": refdat, "genome_label": trackname}\n }\n }\n }\n+ elif trext == \'bam\':\n+ track_conf["conf"] = {"options": {"bam": {"bam_indices": {"bam_index": track[3]}}}}\n+ elif trext == \'cram\':\n+ track_conf["conf"] = {"options": {"cram": {"cram_indices": {"cram_index": track[3]}}}}\n else:\n track_conf = {}\n- track_conf["format"] = track[2]\n- track_conf["name"] = track[0]\n- track_conf["label"] = track[0]\n- track_conf["trackfiles"] = []\n+ track_conf["format"] = trext\n+ track_conf["name"] = trackname\n+ track_conf["label"] = trackname\n+ track_conf["trackfiles"] = [(tpath, trext, trackname,{}),]\n+ track_conf["category"] = "Autogenerated"\n keys = jc.process_annotations(track_conf)\n \n if keys:\n for key in keys:\n- default_session_data["visibility"][\n- track.attrib.get("visibility", "default_off")\n- ].append(key)\n+ if trext in ["bigwig", "gff3", "gff", "vcf", "maf",]:\n+ default_session_data["visibility"]["default_on"].append(key)\n+ else:\n+ default_session_data["visibility"]["default_off"].append(key)\n # if track_conf.get("style", None):\n # default_session_data["style"][key] = track_conf[\n # "style"\n@@ -140,8 +150,10 @@\n else:\n jc.config_json["tracks"] = jc.tracksToAdd\n jc.write_config()\n- defaultData = {"defaultLocation": defLoc, "session_name": sessName}\n- jc.add_default_session(defaultData)\n+ defLoc = makeDefaultLocation()\n+ default_session_data.update({"defaultLocation": defLoc, "session_name": sessName})\n+ track_conf.update(default_session_data)\n+ jc.add_default_session(default_session_data)\n # jc.text_index() not sure what broke here.\n else:\n- sys.stderr.write("!! empty collection supplied - nothing to process")\n+ print("!! empty collection supplied - nothing to process")\n' |
b |
diff -r 2893ef33fba9 -r 15da358c3108 autogenJB2.xml --- a/autogenJB2.xml Sun Feb 25 04:18:53 2024 +0000 +++ b/autogenJB2.xml Wed Feb 28 10:08:57 2024 +0000 |
[ |
@@ -1,5 +1,5 @@ - <tool id="autogenjb2" name="autogenjb2" version="2.10.0_0" profile="22.05"> - <description>Files to JBrowse2</description> + <tool id="autogenjb2" name="autogenjb2" version="2.10.2_0" profile="22.05"> + <description>Track collection to JBrowse2</description> <macros> <import>macros.xml</import> </macros> @@ -11,20 +11,35 @@ <version_command>python '${__tool_directory__}/autogenJB2.py' --version</version_command> <command detect_errors="aggressive"><![CDATA[ python '$__tool_directory__/autogenJB2.py' -#for $key in $jbrowseme.keys(): ---collection '$key,$jbrowseme[$key],$jbrowseme[$key].ext' +#for $key in $autoCollection.keys(): + #if $autoCollection[$key].ext == 'fasta': + --referencemeta '$autoCollection[$key],$autoCollection[$key].ext,$key' + #else if $autoCollection[$key].ext in ['bed', 'bigwig', 'cool', 'gff', 'gff3', 'hic', 'maf', 'mcool', 'scool', 'vcf'] + --trackmeta '$autoCollection[$key],$autoCollection[$key].ext,$key' + #else if $autoCollection[$key].ext in ['bam',] + --trackmeta '$autoCollection[$key],$autoCollection[$key].ext,$key,$autoCollection[$key].metadata.bam_index' + #else if $autoCollection[$key].ext in ['cram',] + --trackmeta '$autoCollection[$key],$autoCollection[$key].ext,$key,$autoCollection[$key].metadata.cram_index' + #end if #end for ---sessName "Autogen JBrowse" +--outdir '$output.files_path' +--sessName "Autogen JBrowse" && + + cp '$output.files_path/index.html' '$output' + +## Ugly testing hack since I cannot get <extra_files> to test the files I want to test. Hmph. + + ]]></command> <inputs> <param - label="Collection of files specially named to become tracks" - name="jbrowseme" + label="Collection of files to become tracks - they must have short, informative names" + name="autoCollection" type="data_collection"> </param> </inputs> <outputs> - <data format="html" name="output" label="JBrowse2"/> + <data format="html" name="output" label="AutoJBrowse2"/> </outputs> <help><![CDATA[ |
b |
diff -r 2893ef33fba9 -r 15da358c3108 jbrowse2.py --- a/jbrowse2.py Sun Feb 25 04:18:53 2024 +0000 +++ b/jbrowse2.py Wed Feb 28 10:08:57 2024 +0000 |
[ |
@@ -1062,59 +1062,6 @@ 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") - dest = os.path.join(self.outdir, rel_dest) - - self.symlink_or_copy(os.path.realpath(data), dest) - - self._add_track( - trackData["label"], - trackData["key"], - trackData["category"], - rel_dest, - config={}, - ) - - def add_sparql(self, url, query, query_refnames, trackData): - - json_track_data = { - "type": "FeatureTrack", - "trackId": id, - "name": trackData["label"], - "adapter": { - "type": "SPARQLAdapter", - "endpoint": {"uri": url, "locationType": "UriLocation"}, - "queryTemplate": query, - }, - "category": [trackData["category"]], - "assemblyNames": [self.genome_name], - } - - if query_refnames: - json_track_data["adapter"]["refNamesQueryTemplate"]: query_refnames - - self.subprocess_check_call( - [ - "jbrowse", - "add-track-json", - "--target", - os.path.join(self.outdir, "data"), - json_track_data, - ] - ) - - # Doesn't work as of 1.6.4, might work in the future - # self.subprocess_check_call([ - # 'jbrowse', 'add-track', - # '--trackType', 'sparql', - # '--name', trackData['label'], - # '--category', trackData['category'], - # '--target', os.path.join(self.outdir, 'data'), - # '--trackId', id, - # '--config', '{"queryTemplate": "%s"}' % query, - # url]) - def process_annotations(self, track): category = track["category"].replace("__pd__date__pd__", TODAY) for i, ( @@ -1190,7 +1137,7 @@ outputTrackConfig, ) elif dataset_ext == "bam": - real_indexes = track["conf"]["options"]["pileup"]["bam_indices"][ + real_indexes = track["conf"]["options"]["bam"]["bam_indices"][ "bam_index" ] if not isinstance(real_indexes, list): @@ -1199,7 +1146,7 @@ self.add_bam( dataset_path, outputTrackConfig, - track["conf"]["options"]["pileup"], + track["conf"]["options"]["bam"], bam_index=real_indexes[i], ) elif dataset_ext == "cram": @@ -1475,16 +1422,6 @@ metadata, ) ) - else: - # For tracks without files (rest, sparql) - track_conf["trackfiles"].append( - ( - "", # N/A, no path for rest or sparql - track.attrib["format"], - track.find("options/label").text, - {}, - ) - ) if is_multi_bigwig: metadata = metadata_from_node(x.find("metadata")) |
b |
diff -r 2893ef33fba9 -r 15da358c3108 jbrowse2.xml --- a/jbrowse2.xml Sun Feb 25 04:18:53 2024 +0000 +++ b/jbrowse2.xml Wed Feb 28 10:08:57 2024 +0000 |
[ |
b'@@ -93,107 +93,110 @@\n <tracks>\n #for $tg in $track_groups:\n #for $track in $tg.data_tracks:\n- <track cat="${tg.category}" format="${track.data_format.data_format_select}" visibility="${track.data_format.track_visibility}">\n- #if $track.data_format.data_format_select != "sparql":\n- <files>\n- #set dataset = $track.data_format.annotation\n- <trackFile path="${dataset}" ext="${dataset.ext}" label="${dataset.name}">\n- <metadata>\n- <dataset id="${__app__.security.encode_id($dataset.id)}" hid="${dataset.hid}"\n- size="${dataset.get_size(nice_size=True)}"\n- edam_format="${dataset.datatype.edam_format}"\n- file_ext="${dataset.ext}" />\n- <history id="${__app__.security.encode_id($dataset.history_id)}"\n- #if $dataset.history.user:\n- user_email="${dataset.history.user.email}"\n- user_id="${dataset.history.user_id}"\n- display_name="${dataset.history.get_display_name()}"/>\n- #else\n- user_email="anonymous"\n- user_id="-1"\n- display_name="Unnamed History"/>\n- #end if\n- <metadata\n- #for (key, value) in $dataset.get_metadata().items():\n- #if "_types" not in $key and $value is not None and len(str($value)) < 5000:\n- #if isinstance($value, list):\n- #set value_str = "[%s]" % \',\'.join([str(val) for val in value])\n- ${key}="$value_str"\n- #else\n- ${key}="${value}"\n- #end if\n- #end if\n- #end for\n- />\n- <tool\n- tool_id="${dataset.creating_job.tool_id}"\n- tool_version="${dataset.creating_job.tool_version}"\n- />\n- </metadata>\n- </trackFile>\n- </files>\n- #else\n- <track cat="${tg.category}" format="sparql" visibility="off">\n- #end if\n+ <track cat="${tg.category}" format="${track.data_format.data_format_select}" visibility="${track.data_format.track_visibility}">\n+ #if $track.data_format.data_format_select != "sparql":\n+ #for $dataset in $track.data_format.annotation:\n+ <files>\n+ <trackFile path="${dataset}" ext="${dataset.ext}" label="${dataset.name}">\n+ <metadata>\n+ <dataset id="${__app__.security.encode_id($dataset.id)}" hid="${dataset.hid}"\n+ size="${dataset.get_size(nice_size=True)}"\n+ edam_format="${dataset.datatype.edam_format}"\n+ file_ext="${dataset.ext}" />\n+ <history id="${__app__.security.encode_id($dataset.history_id)}"\n+ #if $dataset.history.user:\n+ user_email="${dataset.history.user.email}"\n+ user_id="${dataset.history.user_id}"\n+ display_name="${dataset.history.get_display_name()}"/>\n+ #else\n+ user_email="anonymous"\n+ '..b'f" />\n <expand macro="track_visibility" />\n </when>\n- <when value="wiggle">\n+ <when value="bigwig">\n <expand macro="input_conditional" label="BigWig Track Data" format="bigwig" />\n <expand macro="track_visibility" />\n </when>\n <when value="paf">\n- <param label="Comparison genome sequence" help="Paf from these as the references, using the real reference as the reads to map"\n+ <param label="Comparison genome sequence" help="Paf from these as the reference(s), using the common reference as the reads to map"\n format="fasta"\n name="synteny_genome"\n type="data"\n@@ -331,55 +333,6 @@\n <expand macro="input_conditional" label="HiC data in cool/mcool/scool format" format="cool,mcool,scool" />\n <expand macro="track_visibility" />\n </when>\n- <when value="sparql">\n- <param type="text" label="SPARQL Server URL" name="url" />\n- <param type="text" label="Track Label" name="label" value="SPARQL Genes" />\n- <param type="text" label="SPARQL Query" name="query" area="true">\n- <sanitizer>\n- <mapping initial="galaxy.util.mapped_chars">\n- <add source=" " target=" " />\n- <add source=">" target="__gt__" />\n- <add source="<" target="__lt__" />\n- </mapping>\n- <valid initial="default">\n- <add value="|" />\n- <add value="#" />\n- <add value="{"/>\n- <add value="}"/>\n- <add value="!"/>\n- <add value="?"/>\n- <add value="&"/>\n- <add value="+"/>\n- <add value="="/>\n- <add value="\'"/>\n- <add value=\'"\'/>\n- </valid>\n- </sanitizer>\n- </param>\n- <param type="text" label="SPARQL reference names query" help="This query should return a line for each reference name in a `refName` column" name="query_refnames" area="true">\n- <sanitizer>\n- <mapping initial="galaxy.util.mapped_chars">\n- <add source=" " target=" " />\n- <add source=">" target="__gt__" />\n- <add source="<" target="__lt__" />\n- </mapping>\n- <valid initial="default">\n- <add value="|" />\n- <add value="#" />\n- <add value="{"/>\n- <add value="}"/>\n- <add value="!"/>\n- <add value="?"/>\n- <add value="&"/>\n- <add value="+"/>\n- <add value="="/>\n- <add value="\'"/>\n- <add value=\'"\'/>\n- </valid>\n- </sanitizer>\n- </param>\n- <expand macro="track_visibility" />\n- </when>\n </conditional>\n </repeat>\n </repeat>\n' |
b |
diff -r 2893ef33fba9 -r 15da358c3108 macros.xml --- a/macros.xml Sun Feb 25 04:18:53 2024 +0000 +++ b/macros.xml Wed Feb 28 10:08:57 2024 +0000 |
b |
@@ -505,7 +505,7 @@ </xml> <xml name="input_conditional" token_label="Track Data" token_format="data"> - <param label="@LABEL@" format="@FORMAT@" name="annotation" type="data" multiple="False"/> + <param label="@LABEL@" format="@FORMAT@" name="annotation" type="data" multiple="True"/> </xml> <xml name="citations"> <citations> |