Skip to content

Commit

Permalink
Merge pull request #5704 from fubar2/wigbigwig
Browse files Browse the repository at this point in the history
Wigbigwig
  • Loading branch information
bgruening authored Jan 18, 2024
2 parents 735fa1b + c3f50b6 commit ab36a3c
Show file tree
Hide file tree
Showing 16 changed files with 293 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/ucsc_tools/wigtobigwig/.shed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
categories:
- Convert Formats
description: converts bedGraph (wig) files into binary bigwig
homepage_url: https://genome.ucsc.edu/goldenPath/help/bigWig.html
long_description: UCSC wigtobigwig tool wrapper to make bigwig files for genome browser tracks from very dense feature tracks
name: ucsc_wigtobigwig
owner: iuc
remote_repository_url: https://github.com/galaxyproject/tools-iuc/tree/master/tools/wigtobigwig
type: unrestricted
33 changes: 33 additions & 0 deletions tools/ucsc_tools/wigtobigwig/readme.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
wigtobigwig
===========


Derived from a built-in filter tool

History
=======

- 1.1.2 Moved to IUC



Wrapper License (MIT/BSD Style)
===============================

Permission to use, copy, modify, and distribute this software and its
documentation with or without modifications and for any purpose and
without fee is hereby granted, provided that any copyright notices
appear in all copies and that both those copyright notices and this
permission notice appear in supporting documentation, and that the names
of the contributors or copyright holders not be used in advertising or
publicity pertaining to distribution of the software without specific
prior permission.

THE CONTRIBUTORS AND COPYRIGHT HOLDERS OF THIS SOFTWARE DISCLAIM ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
30 changes: 30 additions & 0 deletions tools/ucsc_tools/wigtobigwig/test-data/1.bedgraph
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
chr1 0 14361 0
chr1 14361 14829 1
chr1 14829 14969 0
chr1 14969 15038 1
chr1 15038 15795 0
chr1 15795 15947 1
chr1 15947 16606 0
chr1 16606 16765 1
chr1 16765 16857 0
chr1 16857 17055 1
chr1 17055 17232 0
chr1 17232 17368 1
chr1 17368 17605 0
chr1 17605 17742 1
chr1 17742 17914 0
chr1 17914 18061 1
chr1 18061 18267 0
chr1 18267 18366 1
chr1 18366 24737 0
chr1 24737 24891 1
chr1 24891 29320 0
chr1 29320 29370 1
chr1 29370 34610 0
chr1 34610 35174 2
chr1 35174 35276 0
chr1 35276 35481 2
chr1 35481 35720 0
chr1 35720 36081 2
chr1 36081 69090 0
chr1 69090 69093 3
Binary file added tools/ucsc_tools/wigtobigwig/test-data/1.bigwig
Binary file not shown.
3 changes: 3 additions & 0 deletions tools/ucsc_tools/wigtobigwig/test-data/1.wig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
track type=wiggle_0 name="tb_knownGene" description="table browser query on knownGene" visibility=3 url=
chr7 127475 127491 1
chr7 1274801 1294883 2
Binary file added tools/ucsc_tools/wigtobigwig/test-data/3.bigwig
Binary file not shown.
3 changes: 3 additions & 0 deletions tools/ucsc_tools/wigtobigwig/test-data/dbkeys.loc.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#<dbkey> <display_name> <len_file_path>
hg17 hg17 ${__HERE__}/hg17.len

Empty file.
25 changes: 25 additions & 0 deletions tools/ucsc_tools/wigtobigwig/test-data/hg17.len
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
dummy_chr 100000000
super_1 100000000
chr1 100000000
chr7 200000000
chrX 200000000
phiX174 100000000
random_phiX_region_1 100000000
random_phiX_region_2 100000000
random_phiX_region_3 100000000
random_phiX_region_4 100000000
random_phiX_region_5 100000000
random_phiX_region_6 100000000
random_phiX_region_7 100000000
random_phiX_region_8 100000000
random_phiX_region_9 100000000
random_phiX_region_10 100000000
random_phiX_region_11 100000000
random_phiX_region_12 100000000
random_phiX_region_13 100000000
random_phiX_region_14 100000000
random_phiX_region_15 100000000
random_phiX_region_16 100000000
random_phiX_region_17 100000000
random_phiX_region_18 100000000
random_phiX_region_19 100000000
Binary file not shown.
1 change: 1 addition & 0 deletions tools/ucsc_tools/wigtobigwig/test-data/merlin.len
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Merlin 172788
2 changes: 2 additions & 0 deletions tools/ucsc_tools/wigtobigwig/test-data/merlin.wig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Merlin 49 1452 1
Merlin 1457 3630 1
1 change: 1 addition & 0 deletions tools/ucsc_tools/wigtobigwig/tool-data/dbkeys.loc.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#<dbkey> <display_name> <len_file_path>
7 changes: 7 additions & 0 deletions tools/ucsc_tools/wigtobigwig/tool_data_table_conf.xml.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<tables>
<!-- Locations of dbkeys and len files under genome directory -->
<table name="__dbkeys__" comment_char="#">
<columns>value, name, len_path</columns>
<file path="tool-data/dbkeys.loc" />
</table>
</tables>
8 changes: 8 additions & 0 deletions tools/ucsc_tools/wigtobigwig/tool_data_table_conf.xml.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<tables>
<!-- Locations of dbkeys and len files under genome directory -->
<table name="__dbkeys__" comment_char="#" allow_duplicate_entries="False">
<columns>value, name, len_path</columns>
<file path="${__HERE__}/test-data/dbkeys.loc.test" />
</table>
</tables>

171 changes: 171 additions & 0 deletions tools/ucsc_tools/wigtobigwig/wigtobigwig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<tool id="ucsc_wigtobigwig" name="wigtobigwig" version="@TOOL_VERSION@+galaxy0" profile="22.05">
<description>bedGraph or Wig to bigWig converter</description>
<macros>
<token name="@TOOL_VERSION@">447</token>
</macros>
<xrefs>
<xref type="bio.tools">UCSC_Genome_Browser_Utilities</xref>
</xrefs>
<requirements>
<requirement type="package" version="@TOOL_VERSION@">ucsc-wigtobigwig</requirement>
</requirements>
<stdio>
<!-- Anything other than zero is an error -->
<regex match="needLargeMem: trying to allocate 0 bytes" description="Your input file might be empty or wrongly formatted"/>
<regex match="^Error"/>
</stdio>
<command><![CDATA[
grep -v "^track" '$input1' > trackless &&
wigToBigWig trackless
#if $hist_or_builtin.genome_type_select == "indexed":
'$hist_or_builtin.index.fields.len_path'
#else
'$chromfile'
#end if
'$out_file1'
#if $settings.settingsType == "full":
-blockSize=${settings.blockSize}
-itemsPerSlot=${settings.itemsPerSlot}
${settings.clip}
${settings.unc}
#else:
-clip
#end if
]]>
</command>
<inputs>
<conditional name="hist_or_builtin">
<param name="genome_type_select" type="select" label="Reference genome source" help="Was the Wig/bedgraph input constructed using a genome from your history, or a built-in genome?">
<option selected="True" value="indexed">Input data is for a built-in genome</option>
<option value="history">Input data is for a genome from the current history</option>
</param>
<when value="indexed">
<param name="input1" type="data" format="wig,bedgraph" label="Wig/Bedgraph to convert">
<validator type="unspecified_build"/>
</param>
<param name="index" type="select" label="Source Genome Build">
<options from_data_table="__dbkeys__">
<filter type="data_meta" column="0" key="dbkey" ref="input1"/>
</options>
<validator type="no_options" message="The chosen genome build is not available."/>
</param>
</when>
<when value="history">
<param name="input1" type="data" format="wig,bedgraph" label="Wig/Bedgraph to convert"/>
<param name="chromfile" type="data" format="len,txt,tabular" label="Chromosome length file" help="A file of sequence lengths for the history reference is required to make a bigwig. Compute sequence length tool can make these from fasta files"/>
</when>
</conditional>
<conditional name="settings">
<param name="settingsType" type="select" label="Converter settings to use" help="Default settings should usually be used.">
<option value="preset">Default</option>
<option value="full">Full parameter list</option>
</param>
<when value="preset"/>
<when value="full">
<param argument="-blockSize" type="integer" value="256" label="Items to bundle in r-tree" />
<param argument="-itemsPerSlot" type="integer" value="1024" label="Data points bundled at lowest level"/>
<param argument="-clip" type="boolean" truevalue="-clip" falsevalue="" checked="True" label="Clip chromosome positions" help="Issue warning messages rather than dying if wig file contains items off end of chromosome."/>
<param argument="-unc" type="boolean" truevalue="-unc" falsevalue="" checked="False" label="Do not use compression"/>
</when>
</conditional>
</inputs>
<outputs>
<data name="out_file1" format="bigwig"/>
</outputs>
<tests>
<test expect_num_outputs="1">
<conditional name="hist_or_builtin">
<param name="genome_type_select" value="history"/>
<param name="input1" value="1.wig"/>
<param name="chromfile" value="hg17.len" ftype="len"/>
</conditional>
<conditional name="settings">
<param name="settingsType" value="full"/>
<param name="blockSize" value="256"/>
<param name="itemsPerSlot" value="1024"/>
<param name="clip" value="True"/>
<param name="unc" value="False"/>
</conditional>
<output name="out_file1" file="1.bigwig" compare="sim_size"/>
</test>
<!-- location file test -->
<test expect_num_outputs="1">
<conditional name="hist_or_builtin">
<param name="genome_type_select" value="indexed"/>
<param name="input1" value="1.wig" dbkey="hg17" />
<param name="index" value="hg17" />
</conditional>
<conditional name="settings">
<param name="settingsType" value="preset"/>
</conditional>
<output name="out_file1" file="1.bigwig" compare="sim_size"/>
</test>
<test expect_num_outputs="1">
<conditional name="hist_or_builtin">
<param name="input1" value="1.wig"/>
<param name="genome_type_select" value="history"/>
<param name="chromfile" value="hg17.len" ftype="len"/>
</conditional>
<conditional name="settings">
<param name="settingsType" value="preset"/>
</conditional>
<output name="out_file1" file="1.bigwig" compare="sim_size"/>
</test>
<test expect_num_outputs="1">
<conditional name="hist_or_builtin">
<param name="input1" value="1.bedgraph" ftype="bedgraph"/>
<param name="genome_type_select" value="history"/>
<param name="chromfile" value="hg17.len" ftype="len"/>
</conditional>
<conditional name="settings">
<param name="settingsType" value="preset"/>
</conditional>
<output name="out_file1" file="3.bigwig" compare="sim_size"/>
</test>
<test expect_num_outputs="1">
<conditional name="hist_or_builtin">
<param name="input1" value="merlin.wig" ftype="bedgraph"/>
<param name="genome_type_select" value="history"/>
<param name="chromfile" value="merlin.len" ftype="len"/>
</conditional>
<conditional name="settings">
<param name="settingsType" value="preset"/>
</conditional>
<output name="out_file1" file="merlin.bigwig" compare="sim_size"/>
</test>
</tests>
<help>
**Purpose**

This tool converts bedgraph or wiggle data into bigWig data for visualisation in browsers. The JBrowse tool can display these with other interesting tracks.

**Technical format details**

- **Wiggle format**: The .wig format is line-oriented. Wiggle data is preceded by a UCSC track definition line. Following the track definition line is the track data, which can be entered in three different formats described below.

- **BED format** with no declaration line and four columns of data::

chromA chromStartA chromEndA dataValueA
chromB chromStartB chromEndB dataValueB

- **variableStep** two column data; started by a declaration line and followed with chromosome positions and data values::

variableStep chrom=chrN [span=windowSize]
chromStartA dataValueA
chromStartB dataValueB

- **fixedStep** single column data; started by a declaration line and followed with data values::

fixedStep chrom=chrN start=position step=stepInterval [span=windowSize]
dataValue1
dataValue2

- The **BedGraph format** is described in detail at the `UCSC Bioinformatics website`_

.. _UCSC Bioinformatics website: http://genome.ucsc.edu/goldenPath/help/bedgraph.html

</help>
<citations>
<citation type="doi">10.1093/bioinformatics/btq351</citation>
</citations>
</tool>

0 comments on commit ab36a3c

Please sign in to comment.