Skip to content

Commit

Permalink
feat: Pyroe id-to-name (#1499)
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
-->

### Description

This PR adds the pyroe id-to-name sub-command to the list of available
wrappers

### 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),
* 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 Jul 6, 2023
1 parent e0d2831 commit 6e1d31d
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 1 deletion.
6 changes: 6 additions & 0 deletions bio/pyroe/idtoname/environment.yaml
@@ -0,0 +1,6 @@
channels:
- conda-forge
- bioconda
- nodefaults
dependencies:
- pyroe =0.9.3
14 changes: 14 additions & 0 deletions bio/pyroe/idtoname/meta.yaml
@@ -0,0 +1,14 @@
name: pyroe id-to-name
url: https://pyroe.readthedocs.io/en/latest/geneid_to_name.html
description: >
Create a 2-column tab-separated file mapping IDs to names
author:
- Thibault Dayris
input:
- Path to genome annotation (GTF or GFF3)
output:
- Path to gene id <-> gene names mapping
params:
- extra: Optional parameters to be passed to pyroe
notes: |
Format is automatically inferred from input files.
12 changes: 12 additions & 0 deletions bio/pyroe/idtoname/test/Snakefile
@@ -0,0 +1,12 @@
rule test_pyroe_idtoname:
input:
"annotation.{format}",
output:
"id2name.{format}.tsv",
threads: 1
log:
"logs/{format}.log",
params:
extra="",
wrapper:
"master/bio/pyroe/idtoname"
9 changes: 9 additions & 0 deletions bio/pyroe/idtoname/test/annotation.gff3
@@ -0,0 +1,9 @@
##gff-version 3
#description: evidence-based annotation of the human genome (GRCh38), version 43 (Ensembl 109)
#provider: GENCODE
#contact: gencode-help@ebi.ac.uk
#format: gff3
#date: 2022-11-29
##sequence-region chr1 1 248956422
chr1 HAVANA gene 11869 14409 . + . ID=ENSG00000290825.1;gene_id=ENSG00000290825.1;gene_type=lncRNA;gene_name=DDX11L2;level=2;tag=overlaps_pseudogene
chr1 HAVANA transcript 11869 14409 . + . ID=ENST00000456328.2;Parent=ENSG00000290825.1;gene_id=ENSG00000290825.1;transcript_id=ENST00000456328.2;gene_type=lncRNA;gene_name=DDX11L2;transcript_type=lncRNA;transcript_name=DDX11L2-202;level=2;transcript_support_level=1;tag=basic,Ensembl_canonical;havana_transcript=OTTHUMT00000362751.1
7 changes: 7 additions & 0 deletions bio/pyroe/idtoname/test/annotation.gtf
@@ -0,0 +1,7 @@
##description: evidence-based annotation of the human genome (GRCh38), version 43 (Ensembl 109)
##provider: GENCODE
##contact: gencode-help@ebi.ac.uk
##format: gtf
##date: 2022-11-29
chr1 HAVANA gene 11869 14409 . + . gene_id "ENSG00000290825.1"; gene_type "lncRNA"; gene_name "DDX11L2"; level 2; tag "overlaps_pseudogene";
chr1 HAVANA transcript 11869 14409 . + . gene_id "ENSG00000290825.1"; transcript_id "ENST00000456328.2"; gene_type "lncRNA"; gene_name "DDX11L2"; transcript_type "lncRNA"; transcript_name "DDX11L2-202"; level 2; transcript_support_level "1"; tag "basic"; tag "Ensembl_canonical"; havana_transcript "OTTHUMT00000362751.1";
18 changes: 18 additions & 0 deletions bio/pyroe/idtoname/wrapper.py
@@ -0,0 +1,18 @@
__author__ = "Thibault Dayris"
__copyright__ = "Copyright 2023, Thibault Dayris"
__email__ = "thibault.dayris@gustaveroussy.fr"
__license__ = "MIT"


from snakemake.shell import shell


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

if str(snakemake.input).endswith(("gtf", "gtf.gz")):
extra += " --format GTF "
elif str(snakemake.input).endswith(("gff", "gff.gz", "gff3", "gff3.gz")):
extra += " --format GFF3 "

shell("pyroe id-to-name {extra} {snakemake.input} {snakemake.output} {log}")
13 changes: 12 additions & 1 deletion test.py
Expand Up @@ -170,7 +170,6 @@ def test_nonpareil_plot():
"--use-conda",
"-F",
"results/a.pdf",
"results/samples.pdf",
# Test disabled due to bug in nonpareil (#62)
# "results/a.nomodel.pdf",
]
Expand Down Expand Up @@ -1392,6 +1391,18 @@ def test_art_profiler_illumina():
)


@skip_if_not_modified
def test_pyroe_id_to_name():
run(
"bio/pyroe/idtoname",
["snakemake", "--cores", "1", "--use-conda", "-F", "id2name.gtf.tsv"],
)
run(
"bio/pyroe/idtoname",
["snakemake", "--cores", "1", "--use-conda", "-F", "id2name.gff3.tsv"],
)


@skip_if_not_modified
def test_pyroe_makesplicedunspliced():
run(
Expand Down

0 comments on commit 6e1d31d

Please sign in to comment.