Skip to content

Commit

Permalink
feat: Genepred to bed (#2726)
Browse files Browse the repository at this point in the history
<!-- Ensure that the PR title follows conventional commit style (<type>:
<description>)-->
<!-- Possible types are here:
https://github.com/commitizen/conventional-commit-types/blob/master/index.json
-->

<!-- Add a description of your PR here-->

This PR adds UCSC genePredToBed to the list of available wrappers.

While UCSC tools have a very simple and common CLI, each of them has its
own conda package. So I did not merge all of them into a single
multi-command wrapper like XSV or SeqKit.

### QC
<!-- Make sure that you can tick the boxes below. -->

* [X] I confirm that:

For all wrappers added by this PR, 

* there is a test case which covers any introduced changes,
* `input:` and `output:` file paths in the resulting rule can be changed
arbitrarily,
* either the wrapper can only use a single core, or the example rule
contains a `threads: x` statement with `x` being a reasonable default,
* rule names in the test case are in
[snake_case](https://en.wikipedia.org/wiki/Snake_case) and somehow tell
what the rule is about or match the tools purpose or name (e.g.,
`map_reads` for a step that maps reads),
* all `environment.yaml` specifications follow [the respective best
practices](https://stackoverflow.com/a/64594513/2352071),
* the `environment.yaml` pinning has been updated by running
`snakedeploy pin-conda-envs environment.yaml` on a linux machine,
* wherever possible, command line arguments are inferred and set
automatically (e.g. based on file extensions in `input:` or `output:`),
* all fields of the example rules in the `Snakefile`s and their entries
are explained via comments (`input:`/`output:`/`params:` etc.),
* `stderr` and/or `stdout` are logged correctly (`log:`), depending on
the wrapped tool,
* temporary files are either written to a unique hidden folder in the
working directory, or (better) stored where the Python function
`tempfile.gettempdir()` points to (see
[here](https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir);
this also means that using any Python `tempfile` default behavior
works),
* the `meta.yaml` contains a link to the documentation of the respective
tool or command,
* `Snakefile`s pass the linting (`snakemake --lint`),
* `Snakefile`s are formatted with
[snakefmt](https://github.com/snakemake/snakefmt),
* Python wrapper scripts are formatted with
[black](https://black.readthedocs.io).
* Conda environments use a minimal amount of channels, in recommended
ordering. E.g. for bioconda, use (conda-forge, bioconda, nodefaults, as
conda-forge should have highest priority and defaults channels are
usually not needed because most packages are in conda-forge nowadays).

---------

Co-authored-by: tdayris <tdayris@gustaveroussy.fr>
Co-authored-by: tdayris <thibault.dayris@gustaveroussy.fr>
Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: Felix Mölder <felix.moelder@uni-due.de>
Co-authored-by: Christopher Schröder <christopher.schroeder@tu-dortmund.de>
  • Loading branch information
8 people committed Mar 8, 2024
1 parent 92c9521 commit 3998574
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bio/ucsc/genePredToBed/environment.yaml
@@ -0,0 +1,6 @@
channels:
- conda-forge
- bioconda
- nodefaults
dependencies:
- ucsc-genepredtobed=447
11 changes: 11 additions & 0 deletions bio/ucsc/genePredToBed/meta.yaml
@@ -0,0 +1,11 @@
name: genePredToBed
description: Convert from genePred to bed format. Does not yet handle genePredExt
url: https://hgdownload.cse.ucsc.edu/admin/exe/
authors:
- "Thibault Dayris"
input:
- Path to a genePred file
output:
- Path to the output bed12 file
params:
- extra: Optional parameters for `genePredToBed`
11 changes: 11 additions & 0 deletions bio/ucsc/genePredToBed/test/Snakefile
@@ -0,0 +1,11 @@
rule test_genePredToBed:
input:
"annotation.genePred",
output:
"annotation.bed",
params:
extra="",
log:
"ucsc.log",
wrapper:
"master/bio/ucsc/genePredToBed"
19 changes: 19 additions & 0 deletions bio/ucsc/genePredToBed/test/annotation.genePred
@@ -0,0 +1,19 @@
ENST00000456328.2 chr1 + 11868 14409 14409 14409 3 11868,12612,13220, 12227,12721,14409,
ENST00000450305.2 chr1 + 12009 13670 13670 13670 6 12009,12178,12612,12974,13220,13452, 12057,12227,12697,13052,13374,13670,
ENST00000488147.1 chr1 - 14403 29570 29570 29570 11 14403,15004,15795,16606,16857,17232,17605,17914,18267,24737,29533, 14501,15038,15947,16765,17055,17368,17742,18061,18366,24891,29570,
ENST00000619216.1 chr1 - 17368 17436 17436 17436 1 17368, 17436,
ENST00000473358.1 chr1 + 29553 31097 31097 31097 3 29553,30563,30975, 30039,30667,31097,
ENST00000469289.1 chr1 + 30266 31109 31109 31109 2 30266,30975, 30667,31109,
ENST00000607096.1 chr1 + 30365 30503 30503 30503 1 30365, 30503,
ENST00000417324.1 chr1 - 34553 36081 36081 36081 3 34553,35276,35720, 35174,35481,36081,
ENST00000461467.1 chr1 - 35244 36073 36073 36073 2 35244,35720, 35481,36073,
ENST00000606857.1 chr1 + 52472 53312 53312 53312 1 52472, 53312,
ENST00000642116.1 chr1 + 57597 64116 64116 64116 3 57597,58699,62915, 57653,58856,64116,
ENST00000492842.2 chr1 + 62948 63887 63887 63887 1 62948, 63887,
ENST00000641515.1 chr1 + 65418 71585 69090 70008 3 65418,65519,69036, 65433,65573,71585,
ENST00000335137.4 chr1 + 69054 70108 69090 70008 1 69054, 70108,
ENST00000466430.5 chr1 - 89294 120932 120932 120932 4 89294,92090,112699,120774, 91629,92240,112804,120932,
ENST00000477740.5 chr1 - 92229 129217 129217 129217 4 92229,112699,120720,129054, 92240,112804,120932,129217,
ENST00000471248.1 chr1 - 110952 129173 129173 129173 3 110952,112699,129054, 111357,112804,129173,
ENST00000610542.1 chr1 - 120724 133723 133723 133723 4 120724,120873,129054,133373, 120869,120932,129223,133723,
ENST00000453576.2 chr1 - 129080 133566 133566 133566 2 129080,133373, 129223,133566,
13 changes: 13 additions & 0 deletions bio/ucsc/genePredToBed/wrapper.py
@@ -0,0 +1,13 @@
# coding: utf-8

__author__ = "Thibault Dayris"
__mail__ = "thibault.dayris@gustaveroussy.fr"
__copyright__ = "Copyright 2024, Thibault Dayris"
__license__ = "MIT"

from snakemake import shell

extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)

shell("genePredToBed {extra} {snakemake.input} {snakemake.output} {log}")
7 changes: 7 additions & 0 deletions test.py
Expand Up @@ -5309,6 +5309,13 @@ def test_ucsc_bedgraphtobigwig():
)


@skip_if_not_modified
def test_ucsc_genepredtobed():
run(
"bio/ucsc/genePredToBed",
["snakemake", "--cores", "1", "annotation.bed", "--use-conda", "-F"],
)

@skip_if_not_modified
def test_ucsc_fatotwobit():
run(
Expand Down

0 comments on commit 3998574

Please sign in to comment.