Repository: galaxyproject/galaxy
Pull request #19787: Add bigbed to bed converter and tests
Author: login: d-callan
Labels: name: kind/enhancement
name: area/testing
name: area/datatypes
Created: 2025-03-11T15:50:12Z | Merged: 2025-03-21T15:10:20Z

adding a bigbed to bed datatype converter. see https://github.com/galaxyproject/brc-analytics/issues/371

## How to test the changes?
(Select all options that apply)
- [x] I've included appropriate [automated tests](https://docs.galaxyproject.org/en/latest/dev/writing_tests.html).
- [ ] This is a refactoring of components with existing test coverage.
- [ ] Instructions for manual testing are as follows:
  1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

## License
- [x] I agree to license these and all my past contributions to the core galaxy codebase under the [MIT license](https://opensource.org/licenses/MIT).



Diff:
diff --git a/lib/galaxy/config/sample/datatypes_conf.xml.sample b/lib/galaxy/config/sample/datatypes_conf.xml.sample
index 4921630bdc1c..a23368c282a4 100644
--- a/lib/galaxy/config/sample/datatypes_conf.xml.sample
+++ b/lib/galaxy/config/sample/datatypes_conf.xml.sample
@@ -88,6 +88,7 @@
     </datatype>
     <datatype extension="idat" type="galaxy.datatypes.binary:Idat" display_in_upload="true"/>
     <datatype extension="bigbed" type="galaxy.datatypes.binary:BigBed" mimetype="application/octet-stream" display_in_upload="true">
+      <converter file="bigbed_to_bed_converter.xml" target_datatype="bed"/>
       <display file="ucsc/bigbed.xml"/>
       <display file="igb/bb.xml"/>
     </datatype>
diff --git a/lib/galaxy/datatypes/converters/bigbed_to_bed_converter.xml b/lib/galaxy/datatypes/converters/bigbed_to_bed_converter.xml
new file mode 100644
index 000000000000..7503a90ef204
--- /dev/null
+++ b/lib/galaxy/datatypes/converters/bigbed_to_bed_converter.xml
@@ -0,0 +1,113 @@
+<tool id="ucsc_bigbedtobed" name="Convert from bigBed to ascii bed format." version="@TOOL_VERSION@+galaxy@SUFFIX_VERSION@" profile="20.01">
+    <description>Convert bigBed to BED</description>
+    <macros>
+        <token name="@TOOL_VERSION@">377</token>
+        <token name="@SUFFIX_VERSION@">0</token>
+    </macros>
+    <requirements>
+        <requirement type="package" version="@TOOL_VERSION@">ucsc-bigbedtobed</requirement>
+    </requirements>
+    <command detect_errors="exit_code"><![CDATA[
+        bigBedToBed '${bigbed_input}'
+        #if $chrom
+            -chrom='${chrom}'
+        #end if
+        #if str($start)
+            -start=$start
+        #end if
+        #if str($end)
+            -end=$end
+        #end if
+        output.bed
+    ]]></command>
+    <inputs>
+        <param name="bigbed_input" type="data" format="bigbed" label="BigBed input"/>
+        <param argument="-chrom" type="text" value="" optional="true" label="Restrict output to given chromosome">
+            <sanitizer invalid_char="">
+                <valid initial="string.letters,string.digits">
+                    <add value="+" />
+                    <add value="-" />
+                    <add value=" " />
+                    <add value="_" />
+                </valid>
+            </sanitizer>
+            <validator type="regex">[A-Za-z0-9 -_+]+</validator>
+        </param>
+        <param argument="-start" type="integer" min="0" optional="true" label="Restrict output to only that over start" />
+        <param argument="-end" type="integer" min="0" optional="true" label="Restrict output to only that under end" />
+    </inputs>
+    <outputs>
+        <data name="bed_output" format="bed" from_work_dir="output.bed" label="${tool.name} on ${on_string}: bed"/>
+    </outputs>
+    <tests>
+        <!--Test 01 -->
+        <test expect_num_outputs="1">
+            <param name="bigbed_input" value="1.bigbed"/>
+	    <output name="bed_output" ftype="bed">
+	        <assert_contents>
+                    <has_n_lines n="3339"/>
+                </assert_contents>
+	    </output>
+	</test>
+        <!--Test 02 -->
+        <test expect_num_outputs="1">
+            <param name="bigbed_input" value="1.bigbed"/>
+            <param name="chrom" value="chr21"/>
+	    <output name="bed_output" ftype="bed">
+            	<assert_contents>
+          		<has_n_lines n="0"/>
+        	</assert_contents>
+	    </output>
+            <assert_command>
+                <has_text text="-chrom='chr21'"/>
+	    </assert_command>
+        </test>
+        <!--Test 03 -->
+        <test expect_num_outputs="1">
+            <param name="bigbed_input" value="1.bigbed"/>
+            <param name="start" value="100"/>
+	    <output name="bed_output" ftype="bed">
+	    	<assert_contents>
+          		<has_n_lines n="3339"/>
+        	</assert_contents>
+	    </output>
+            <assert_command>
+                <has_text text="-start=100"/>
+	    </assert_command>
+        </test>
+        <!--Test 04 -->
+        <test expect_num_outputs="1">
+            <param name="bigbed_input" value="1.bigbed"/>
+            <param name="end" value="100000000"/>
+	    <output name="bed_output" ftype="bed">
+	    	<assert_contents>
+          		<has_n_lines n="1966"/>
+        	</assert_contents>
+	    </output>
+            <assert_command>
+                <has_text text="-end=100000000"/>
+	    </assert_command>
+        </test>
+    </tests>
+    <help><![CDATA[
+
+.. class:: infomark
+
+**Purpose**
+
+bigBedToBed - Convert from bigBed to BED format. This utility will convert a bigBed file
+to a standard BED file, preserving the original structure while making it human-readable.
+
+    ]]></help>
+    <citations>
+        <citation type="bibtex">
+            @misc{githubKent,
+            author = {Kent, Jim},
+            year = {2021},
+            title = {bigbedtobed},
+            publisher = {GitHub},
+            journal = {GitHub repository},
+            url = {https://github.com/ucscGenomeBrowser/kent}}
+        </citation>
+    </citations>
+</tool>


Reviews:
user: login: martenson
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-11T15:55:11Z
user: login: martenson
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-11T15:55:42Z
user: login: martenson
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-11T15:57:19Z

Review comments:
diff_hunk: @@ -0,0 +1,97 @@
+<tool id="bigbedtobed" name="Convert from bigBed to ascii bed format." version="@TOOL_VERSION@+galaxy@SUFFIX_VERSION@" profile="20.01">
path: lib/galaxy/datatypes/converters/bigbed_to_bed_converter.xml
user: login: martenson
body: ```suggestion
<tool id="ucsc_bigbedtobed" name="Convert from bigBed to ascii bed format." version="@TOOL_VERSION@+galaxy@SUFFIX_VERSION@" profile="20.01">
```
created_at: 2025-03-11T15:55:11Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,97 @@
+<tool id="bigbedtobed" name="Convert from bigBed to ascii bed format." version="@TOOL_VERSION@+galaxy@SUFFIX_VERSION@" profile="20.01">
path: lib/galaxy/datatypes/converters/bigbed_to_bed_converter.xml
user: login: martenson
body: "standard" for choosing ids of ucsc tools (https://github.com/galaxyproject/tools-iuc/tree/main/tools/ucsc_tools)
created_at: 2025-03-11T15:55:42Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,97 @@
+<tool id="bigbedtobed" name="Convert from bigBed to ascii bed format." version="@TOOL_VERSION@+galaxy@SUFFIX_VERSION@" profile="20.01">
path: lib/galaxy/datatypes/converters/bigbed_to_bed_converter.xml
user: login: martenson
body: you can also likely copy the citation and more from e.g. https://github.com/galaxyproject/tools-iuc/blob/main/tools/ucsc_tools/ucsc_chainantirepeat/ucsc_chainantirepeat.xml
created_at: 2025-03-11T15:57:19Z
author_association: MEMBER

PR comments:
user: login: d-callan
created_at: 2025-03-13T16:52:24Z
body: does this need anything else from me? im not sure i understand the failures tbh..
author_association: CONTRIBUTOR
user: login: mvdbeek
created_at: 2025-03-17T15:12:44Z
body: Can you take a look at the artefacts in https://github.com/galaxyproject/galaxy/actions/runs/13901245452?pr=19787 ? The first 3 tests are failing. `<output name="bed_output" value="output.bed" ftype="bed"/>` means that we're expecting an exact match between what the converter generates and the output file that you've included in the PR. You can use any of the assert_contents statements and remove the explicit comparison with `output.bed`. `has_n_lines` (https://docs.galaxyproject.org/en/latest/dev/schema.html#has-n-lines) would be enough I think.
author_association: MEMBER
user: login: mvdbeek
created_at: 2025-03-21T15:10:14Z
body: Thanks @d-callan!
author_association: MEMBER