Skip to content

Commit

Permalink
JBrowse2: add another required file for pulsar; remove label punctuat…
Browse files Browse the repository at this point in the history
…ion that can break JBrowse2 paths (bgruening#1512)

* adding first tested and working generated tool from https://github.com/fubar2/nftoolmaker
It actually does work. Sort of.
Hope this is useful to someone.

* fixes suggested by bgruening for the PR - all adjustments will now apply to all future generated tools :)

* add yara mapper ToolFactory - NOT from nf-core.
Allows single ended fastq or fasta to be mapped, or a pair of forward and reverse - both must be fastq

* small test files still work :)

* single quotes for $runme - disappeared mysteriously :(

* adding panaroo

* Finally fixed the '$runme' suggestion and got the sanitisers not to.

* fix profile="22.05" - need to update galaxyxml to fix this and the stdio replacement...

* cleanup master branch of fork

* update help
some prompts
add bgperpx - todo add as a parameter

* 2.12.2 update
Add wiggle track colour and other controls
Add bpPerPx in advanced section to control view scale at default open
Clarify dependence on remote URI tabix data if uri source used.

* bump to 2.12.3 jb2
still passes tests - no breakage yet.

* fix JB2VER although not currently used...

* Have the no-build plugin for bed colour above and below zero binary working!
Involved a substantial simplification of the default_session setup - just needed "configuration": displayId in the display.
Simples.

* remove copy for strings.

* Update tools/jbrowse2/jbrowse2.xml

Co-authored-by: Björn Grüning <[email protected]>

* Update tools/jbrowse2/jbrowse2.xml

Co-authored-by: Björn Grüning <[email protected]>

* fix flake errors and some suggestions

* thought I'd got this one...

* add the new plugin js

* change bed default to not use plugin

* add help explaining relationship to the Bigwig extremes to bed features tool and to the advanced control form.

* update to 2.13.0 release
fix biotools jbrowse entry
informative error message if collection has no fasta reference

* decrement version suffix back to zero

* remove flakery spaces

* make genome from history and built in genome non-optional to fix a sentry issue reported and PR suggested by Marius

* update to 2.13.1 opportunistically :)

* Add collection_type to input collection. It should always be a list

<param name="autoCollection" type="data_collection" collection_type="list" label="Collection of bed, bam and other track files"/>

Suggestion from Marius - thanks!

* change bigwigs to default to global +/- 3sd scaling.
makes them much more useful for most purposes - can swap back
otherwise local differences can appear to be more important than they really are...
use element_identifier for labels instead of name

* Bump version :(

* update to 2.14.0
remove now missing specific wolf file from 3 old tests.

* version bump 2.15.1
fix tool test output counts to match new code

* Update to 2.15.4 - a patch to fix a regression in 2.15.3 breaking hic tracks GMOD/jbrowse-components#4583
Have updated vcf and blastxml test files too FWIW

* add a label translate to get rid of punctuation like : from file labels to avoid them becoming broken paths.
For example, vcf sort adds a : to the name and that breaks the track path.

* add space for removal in nopunct translate string

* bump version coda

* test a clone instead of copy if the dependency repository cannot be found like when failing on vgp.org pulsar.

* remove trailing slash - not going to help

* add missing <required file> for pulsar after the biocontainer was updated for vgp.usegalaxy
add a failsafe so if the dependency javascript cannot be found it uses JBrowse to bootstrap itself.

* Add a test to confirm that translate is working
File is named "bw/m:e.r.l .i-n.bw"
Test finds <has_text text="me.r.l.i-n.bw_0"/> to confirm that ':' and ' ' have been removed

* add weird filename test file for string translate test

* Update tools/jbrowse2/macros.xml

---------

Co-authored-by: Björn Grüning <[email protected]>
  • Loading branch information
fubar2 and bgruening authored Oct 6, 2024
1 parent 8f49f3c commit 867d545
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 21 deletions.
33 changes: 14 additions & 19 deletions tools/jbrowse2/jbrowse2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import re
import shutil
import ssl
import string
import struct
import subprocess
import tempfile
Expand All @@ -20,7 +21,7 @@
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger("jbrowse")

JB2VER = "v2.12.3"
JB2VER = "v2.15.4"
# version pinned if cloning - but not cloning now
logCommands = True
# useful for seeing what's being written but not for production setups
Expand Down Expand Up @@ -419,7 +420,7 @@ def __init__(self, outdir, jbrowse2path):
self.tracksToAdd = {}
self.config_json = {}
self.config_json_file = os.path.join(outdir, "config.json")
self.clone_jbrowse()
self.clone_jbrowse(realclone=False)

def get_cwd(self, cwd):
if cwd:
Expand Down Expand Up @@ -620,18 +621,9 @@ def text_index(self):
# Index tracks
args = [
"jbrowse",
"text-index",
"--target",
self.outdir,
"--assemblies",
self.genome_name,
"text-index"
]

tracks = ",".join(self.trackIdlist)
if tracks:
args += ["--tracks", tracks]

self.subprocess_check_call(args)
self.subprocess_check_call(args)

def add_hic(self, data, trackData):
"""
Expand Down Expand Up @@ -1555,7 +1547,7 @@ def clone_jbrowse(self, realclone=False):
"""
dest = self.outdir
if realclone:
if (not os.path.exists(self.jbrowse2path)) or realclone:
self.subprocess_check_call(
["jbrowse", "create", dest, "-f", "--tag", f"{JB2VER}"]
)
Expand Down Expand Up @@ -1600,7 +1592,9 @@ def parse_style_conf(item):
args = parser.parse_args()
tree = ET.parse(args.xml)
root = tree.getroot()

removeMe = string.punctuation.replace('.', ' ').replace('/', '').replace('-', '')
# first is a space because space needs to be added here for removal from labels as paths.
nopunct = str.maketrans(dict.fromkeys(removeMe))
# This should be done ASAP
GALAXY_INFRASTRUCTURE_URL = root.find("metadata/galaxyUrl").text
# Sometimes this comes as `localhost` without a protocol
Expand All @@ -1617,7 +1611,7 @@ def parse_style_conf(item):
genomes = [
{
"path": x.attrib["path"],
"label": x.attrib["label"].split(" ")[0].replace(",", ""),
"label": x.attrib["label"].split(" ")[0].translate(nopunct),
"useuri": x.attrib["useuri"],
"meta": metadata_from_node(x.find("metadata")),
}
Expand Down Expand Up @@ -1655,15 +1649,15 @@ def parse_style_conf(item):
if x.attrib['ext'] == "bed":
isBed = True
track_conf["label"] = "%s_%d" % (
x.attrib["label"].replace(" ", "_").replace(",", "_").replace("/", "_"),
x.attrib["label"].translate(nopunct),
trackI,
)
trackI += 1
track_conf["useuri"] = x.attrib["useuri"]
if is_multi_bigwig:
multi_bigwig_paths.append(
(
track_conf["label"],
track_conf["label"].translate(nopunct),
track_conf["useuri"],
os.path.realpath(x.attrib["path"]),
)
Expand Down Expand Up @@ -1770,4 +1764,5 @@ def parse_style_conf(item):
jc.write_config()
# note that this can be left in the config.json but has NO EFFECT if add_defsess_to_index is called.
# jc.add_defsess_to_index(default_session_data)
# jc.text_index() not sure what broke here.
# this command line tool appears currently broken - or at least not working here.
# jc.text_index()
42 changes: 41 additions & 1 deletion tools/jbrowse2/jbrowse2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
<include path="jb2_webserver.py"/>
<include path="jbrowse2.py"/>
<include path="maf2bed.py"/>
<include path="bedscoreplugin.js"/>
</required_files>
<version_command>python '${__tool_directory__}/jbrowse2.py' --version</version_command>
<command detect_errors="aggressive"><![CDATA[
mkdir -p '$output.files_path' &&
cp '$trackxml' '$output.files_path/galaxy.xml' &&
export JBROWSE2_PATH=\$(dirname \$(which jbrowse))/../opt/jbrowse2 &&
export JBROWSE2_PATH=\$(realpath \$(dirname \$(which jbrowse))/../opt/jbrowse2) &&
#if $jbgen.ucol.formcoll=="collect":
python '$__tool_directory__/autogenJB2.py'
#for $key in $autoCollection.keys():
Expand Down Expand Up @@ -1127,6 +1128,45 @@ export JBROWSE2_PATH=\$(dirname \$(which jbrowse))/../opt/jbrowse2 &&
</has_archive_member>
</assert_contents>
</output>
</test>
<test>
<repeat name="assemblies">
<conditional name="reference_genome">
<param name="genome_type_select" value="history"/>
<param name="genome" value="merlin.fa"/>
<param name="genome.ext" value="fasta"/>
<param name="genome.name" value="Merlin"/>
</conditional>
<repeat name="track_groups">
<param name="category" value="Default"/>
<repeat name="data_tracks">
<conditional name="data_format">
<param name="data_format_select" value="bigwig"/>
<conditional name="useuri">
<param name="annotation" value="bw/m:e.r.l .i-n.bw"/>
<param name="insource" value="history"/>
</conditional>
</conditional>
</repeat>
</repeat>
</repeat>
<section name="jbgen">
<param name="zipOut" value="true"/>
</section>
<output name="output">
<assert_contents>
<has_archive_member path="config.json">
<has_text text="QuantitativeTrack"/>
<has_text text="trackId"/>
<has_text text="me.r.l.i-n.bw_0"/>
<has_text text="name"/>
<has_text text="Default"/>
<has_text text="name"/>
<has_text text="assemblyName"/>
<has_text text="merlin.fa"/>
</has_archive_member>
</assert_contents>
</output>
</test>
</tests>
<help><![CDATA[
Expand Down
2 changes: 1 addition & 1 deletion tools/jbrowse2/macros.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</requirements>
</xml>
<token name="@DATA_DIR@">\$GALAXY_JBROWSE_SHARED_DIR</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@VERSION_SUFFIX@">1</token>
<xml name="creators">
<creator>
<person givenName="Helena" familyName="Rasche" url="https://github.com/hexylena"/>
Expand Down
Binary file added tools/jbrowse2/test-data/bw/m:e.r.l .i-n.bw
Binary file not shown.

0 comments on commit 867d545

Please sign in to comment.