-
Notifications
You must be signed in to change notification settings - Fork 215
feat: Add wrappers in bio/reference for Ensembl Genomes #4882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9e0dc26
Add wrappers ensembl-genomes-annotation, ensembl-genomes-sequence
kbseah cc9e959
Add tests for ensembl-genomes-annotation, ensembl-genomes sequence
kbseah f782b1d
Fix URL errors
kbseah 6dacaba
Add homepage URL for Ensembl Genomes to meta.yaml files
kbseah ee52698
Fix doc typos
kbseah 0d071cf
Correct namespace alias
kbseah b79c795
Remove unused imports; rename tests to match wrapper name
kbseah 316650f
Fix nitpick comments
kbseah 3b8a8e6
Catch output filename without extension
kbseah 4ab3d2e
Catch if only one chromosome passed as str
kbseah f0542fa
Merge branch 'master' into ensembl-genomes
fgvieira b92f385
Merge branch 'snakemake:master' into ensembl-genomes
kbseah 7ffcb28
Pin curl; add deps
kbseah cd179c5
Pin curl, add gzip dep
kbseah 9ccda3a
Use snakemake-wrapper-utils
kbseah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
bio/reference/ensembl-genomes-annotation/environment.linux-64.pin.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # This file may be used to create an environment using: | ||
| # $ conda create --name <env> --file <this file> | ||
| # platform: linux-64 | ||
| # created-by: conda 25.3.1 | ||
| @EXPLICIT | ||
| https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81 | ||
| https://conda.anaconda.org/conda-forge/noarch/ca-certificates-2025.11.12-hbd8a1cb_0.conda#f0991f0f84902f6b6009b4d2350a83aa | ||
| https://conda.anaconda.org/conda-forge/linux-64/libgomp-15.2.0-he0feb66_16.conda#26c46f90d0e727e95c6c9498a33a09f3 | ||
| https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2#73aaf86a425cc6e73fcf236a5a46396d | ||
| https://conda.anaconda.org/conda-forge/linux-64/libgcc-15.2.0-he0feb66_16.conda#6d0363467e6ed84f11435eb309f2ff06 | ||
| https://conda.anaconda.org/conda-forge/linux-64/c-ares-1.34.6-hb03c661_0.conda#920bb03579f15389b9e512095ad995b7 | ||
| https://conda.anaconda.org/conda-forge/linux-64/keyutils-1.6.3-hb9d3cd8_0.conda#b38117a3c920364aff79f870c984b4a3 | ||
| https://conda.anaconda.org/conda-forge/linux-64/libgcc-ng-15.2.0-h69a702a_16.conda#5a68259fac2da8f2ee6f7bfe49c9eb8b | ||
| https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-15.2.0-h934c35e_16.conda#68f68355000ec3f1d6f26ea13e8f525f | ||
| https://conda.anaconda.org/conda-forge/linux-64/libzlib-1.3.1-hb9d3cd8_2.conda#edb0dca6bc32e4f4789199455a1dbeb8 | ||
| https://conda.anaconda.org/conda-forge/linux-64/ncurses-6.5-h2d0b736_3.conda#47e340acb35de30501a76c7c799c41d7 | ||
| https://conda.anaconda.org/conda-forge/linux-64/openssl-3.6.0-h26f9b46_0.conda#9ee58d5c534af06558933af3c845a780 | ||
| https://conda.anaconda.org/conda-forge/linux-64/libedit-3.1.20250104-pl5321h7949ede_0.conda#c277e0a4d549b03ac1e9d6cbbe3d017b | ||
| https://conda.anaconda.org/conda-forge/linux-64/libev-4.33-hd590300_2.conda#172bf1cd1ff8629f2b1179945ed45055 | ||
| https://conda.anaconda.org/conda-forge/linux-64/libssh2-1.11.1-hcf80075_0.conda#eecce068c7e4eddeb169591baac20ac4 | ||
| https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-ng-15.2.0-hdf11a46_16.conda#1b3152694d236cf233b76b8c56bf0eae | ||
| https://conda.anaconda.org/conda-forge/linux-64/zstd-1.5.7-hb78ec9c_6.conda#4a13eeac0b5c8e5b8ab496e6c4ddd829 | ||
| https://conda.anaconda.org/conda-forge/linux-64/krb5-1.21.3-h659f571_0.conda#3f43953b7d3fb3aaa1d0d0723d91e368 | ||
| https://conda.anaconda.org/conda-forge/linux-64/libnghttp2-1.67.0-had1ee68_0.conda#b499ce4b026493a13774bcf0f4c33849 | ||
| https://conda.anaconda.org/conda-forge/linux-64/libcurl-8.17.0-h4e3cde8_1.conda#117499f93e892ea1e57fdca16c2e8351 | ||
| https://conda.anaconda.org/conda-forge/linux-64/curl-8.17.0-h4e3cde8_1.conda#cb3648a22e7d5010fc9edae69bb2eab8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| channels: | ||
| - conda-forge | ||
| - nodefaults | ||
| dependencies: | ||
| - curl | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| name: ensembl-genomes-annotation | ||
| description: | | ||
| Download annotation of genomic sites (e.g. transcripts) for non-vertebrate | ||
| species from Ensembl Genomes FTP servers, and store them in a single .gtf or | ||
| .gff3 file. Adapted from ``ensembl-annotation`` wrapper. | ||
| authors: | ||
| - Brandon Seah | ||
| - Johannes Köster | ||
| url: https://ensemblgenomes.org/ | ||
| output: | ||
| - Ensembl Genomes GTF or GFF3 annotation file | ||
| params: | ||
| - url: URL from where to download cache data (optional; by default is ``https://ftp.ebi.ac.uk/ensemblgenomes/pub``) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| rule get_annotation: | ||
| output: | ||
| "refs/ensembl-genomes-annotation.gtf", | ||
| params: | ||
| species="schizosaccharomyces_pombe", | ||
| division="fungi", | ||
| assembly="ASM294v2", | ||
| release="62", | ||
| log: | ||
| "logs/get_annotation.log", | ||
| cache: "omit-software" # save space and time with between workflow caching (see docs) | ||
| wrapper: | ||
| "master/bio/reference/ensembl-genomes-annotation" | ||
|
|
||
|
|
||
| rule get_annotation_gz: | ||
| output: | ||
| "refs/ensembl-genomes-annotation.gtf.gz", | ||
| params: | ||
| species="schizosaccharomyces_pombe", | ||
| division="fungi", | ||
| assembly="ASM294v2", | ||
| release="62", | ||
| log: | ||
| "logs/get_annotation.log", | ||
| cache: "omit-software" # save space and time with between workflow caching (see docs) | ||
| wrapper: | ||
| "master/bio/reference/ensembl-genomes-annotation" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| __author__ = "Brandon Seah, Johannes Köster" | ||
| __copyright__ = "Copyright 2025, Brandon Seah, Johannes Köster" | ||
| __email__ = "brandon_seah@tll.org.sg" | ||
| __license__ = "MIT" | ||
|
|
||
| import subprocess as sp | ||
| import sys | ||
|
|
||
| from snakemake.shell import shell | ||
| from snakemake.logging import logger | ||
| from pathlib import Path | ||
|
|
||
| species = snakemake.params.species.lower() | ||
| release = int(snakemake.params.release) | ||
| division = snakemake.params.division.lower() | ||
| assembly = snakemake.params.assembly | ||
|
|
||
| out_fmt = Path(snakemake.output[0]).suffixes | ||
| out_gz = (out_fmt.pop() and True) if out_fmt[-1] == ".gz" else False | ||
| out_fmt = out_fmt.pop().lstrip(".") | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| available_divisions = ["fungi", "metazoa", "plants", "protists"] | ||
| if division not in available_divisions: | ||
| raise ValueError( | ||
| f"Invalid division. Division must be one of: {', '.join(available_divisions)}" | ||
| ) | ||
|
|
||
| # TODO: bacteria, fungi/ascomycota folders are further subdivided | ||
| # TODO: chromosome file names may not follow standard naming convention, e.g. | ||
| # Plasmodium_falciparum.GCA000002765v3.dna.primary_assembly.Pf3D7_01_v3.fa.gz | ||
|
|
||
| log = snakemake.log_fmt_shell(stdout=False, stderr=True) | ||
|
|
||
| suffix = "" | ||
| if out_fmt == "gtf": | ||
| suffix = "gtf.gz" | ||
| elif out_fmt == "gff3": | ||
| suffix = "gff3.gz" | ||
| else: | ||
| raise ValueError( | ||
| "invalid format specified. Only 'gtf[.gz]' and 'gff3[.gz]' are currently supported." | ||
| ) | ||
|
|
||
| url = snakemake.params.get("url", "https://ftp.ebi.ac.uk/ensemblgenomes/pub/") | ||
| url = f"{url}/release-{release}/{division}/{out_fmt}/{species}/{species.capitalize()}.{assembly}.{release}.{suffix}" | ||
| ftp_url = url.replace("https://", "ftp://") | ||
|
|
||
| try: | ||
| if out_gz: | ||
| shell("curl --fail -L {url} > {snakemake.output[0]} {log}") | ||
| else: | ||
| shell("(curl --fail -L {url} | gzip -d > {snakemake.output[0]}) {log}") | ||
| except sp.CalledProcessError: | ||
| try: | ||
| if out_gz: | ||
| shell("curl --fail -L {ftp_url} > {snakemake.output[0]} {log}") | ||
| else: | ||
| shell("(curl --fail -L {ftp_url} | gzip -d > {snakemake.output[0]}) {log}") | ||
| except sp.CalledProcessError: | ||
| if snakemake.log: | ||
| sys.stderr = open(snakemake.log[0], "a") | ||
| print( | ||
| "Unable to download annotation data from Ensembl Genomes.\n" | ||
| "Did you check that this combination of species, division, assembly, and release is actually provided?", | ||
| file=sys.stderr, | ||
| ) | ||
| exit(1) | ||
26 changes: 26 additions & 0 deletions
26
bio/reference/ensembl-genomes-sequence/environment.linux-64.pin.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # This file may be used to create an environment using: | ||
| # $ conda create --name <env> --file <this file> | ||
| # platform: linux-64 | ||
| # created-by: conda 25.3.1 | ||
| @EXPLICIT | ||
| https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81 | ||
| https://conda.anaconda.org/conda-forge/noarch/ca-certificates-2025.11.12-hbd8a1cb_0.conda#f0991f0f84902f6b6009b4d2350a83aa | ||
| https://conda.anaconda.org/conda-forge/linux-64/libgomp-15.2.0-he0feb66_16.conda#26c46f90d0e727e95c6c9498a33a09f3 | ||
| https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2#73aaf86a425cc6e73fcf236a5a46396d | ||
| https://conda.anaconda.org/conda-forge/linux-64/libgcc-15.2.0-he0feb66_16.conda#6d0363467e6ed84f11435eb309f2ff06 | ||
| https://conda.anaconda.org/conda-forge/linux-64/c-ares-1.34.6-hb03c661_0.conda#920bb03579f15389b9e512095ad995b7 | ||
| https://conda.anaconda.org/conda-forge/linux-64/keyutils-1.6.3-hb9d3cd8_0.conda#b38117a3c920364aff79f870c984b4a3 | ||
| https://conda.anaconda.org/conda-forge/linux-64/libgcc-ng-15.2.0-h69a702a_16.conda#5a68259fac2da8f2ee6f7bfe49c9eb8b | ||
| https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-15.2.0-h934c35e_16.conda#68f68355000ec3f1d6f26ea13e8f525f | ||
| https://conda.anaconda.org/conda-forge/linux-64/libzlib-1.3.1-hb9d3cd8_2.conda#edb0dca6bc32e4f4789199455a1dbeb8 | ||
| https://conda.anaconda.org/conda-forge/linux-64/ncurses-6.5-h2d0b736_3.conda#47e340acb35de30501a76c7c799c41d7 | ||
| https://conda.anaconda.org/conda-forge/linux-64/openssl-3.6.0-h26f9b46_0.conda#9ee58d5c534af06558933af3c845a780 | ||
| https://conda.anaconda.org/conda-forge/linux-64/libedit-3.1.20250104-pl5321h7949ede_0.conda#c277e0a4d549b03ac1e9d6cbbe3d017b | ||
| https://conda.anaconda.org/conda-forge/linux-64/libev-4.33-hd590300_2.conda#172bf1cd1ff8629f2b1179945ed45055 | ||
| https://conda.anaconda.org/conda-forge/linux-64/libssh2-1.11.1-hcf80075_0.conda#eecce068c7e4eddeb169591baac20ac4 | ||
| https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-ng-15.2.0-hdf11a46_16.conda#1b3152694d236cf233b76b8c56bf0eae | ||
| https://conda.anaconda.org/conda-forge/linux-64/zstd-1.5.7-hb78ec9c_6.conda#4a13eeac0b5c8e5b8ab496e6c4ddd829 | ||
| https://conda.anaconda.org/conda-forge/linux-64/krb5-1.21.3-h659f571_0.conda#3f43953b7d3fb3aaa1d0d0723d91e368 | ||
| https://conda.anaconda.org/conda-forge/linux-64/libnghttp2-1.67.0-had1ee68_0.conda#b499ce4b026493a13774bcf0f4c33849 | ||
| https://conda.anaconda.org/conda-forge/linux-64/libcurl-8.17.0-h4e3cde8_1.conda#117499f93e892ea1e57fdca16c2e8351 | ||
| https://conda.anaconda.org/conda-forge/linux-64/curl-8.17.0-h4e3cde8_1.conda#cb3648a22e7d5010fc9edae69bb2eab8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| channels: | ||
| - conda-forge | ||
| - nodefaults | ||
| dependencies: | ||
| - curl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| name: ensembl-genomes-sequence | ||
| description: | | ||
| Download sequences (e.g. genome) of non-vertebrate species from Ensembl | ||
| Genomes FTP servers, and store them in a single .fasta file. The release | ||
| numbers and folder organization differ from the Ensembl project, which | ||
| maintains data for vertebrate species. Based on wrapper ``ensembl-sequence`` | ||
| authors: | ||
| - Brandon Seah | ||
| - Johannes Köster | ||
| url: https://ensemblgenomes.org/ | ||
| output: | ||
| - fasta file | ||
| params: | ||
| - url: URL from where to download cache data (optional; by default is ``ftp://ftp.ebi.ac.uk/ensemblgenomes/pub/``) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| rule get_genome: | ||
| output: | ||
| "refs/ensembl-genomes-genome.fasta", | ||
| params: | ||
| species="plasmodium_falciparum", | ||
| assembly="GCA000002765v3", | ||
| division="protists", | ||
| datatype="dna", | ||
| release="62", | ||
| log: | ||
| "logs/get_genome.log", | ||
| cache: "omit-software" # save space and time with between workflow caching (see docs) | ||
| wrapper: | ||
| "master/bio/reference/ensembl-genomes-sequence" | ||
|
|
||
|
|
||
| rule get_genome_gzipped: | ||
| output: | ||
| "refs/ensembl-genomes-genome.fa.gz", | ||
| params: | ||
| species="plasmodium_falciparum", | ||
| assembly="GCA000002765v3", | ||
| division="protists", | ||
| datatype="dna", | ||
| release="62", | ||
| log: | ||
| "logs/get_genome.log", | ||
| cache: "omit-software" # save space and time with between workflow caching (see docs) | ||
| wrapper: | ||
| "master/bio/reference/ensembl-genomes-sequence" | ||
|
|
||
|
|
||
| rule get_single_chromosome: | ||
| output: | ||
| "refs/ensembl-genomes-chrMt.fasta", | ||
| params: | ||
| species="schizosaccharomyces_pombe", | ||
| assembly="ASM294v2", | ||
| division="fungi", | ||
| datatype="dna", | ||
| release="62", | ||
| chromosome=["MT"], # optional: restrict to one or multiple chromosomes, for multiple see below | ||
| log: | ||
| "logs/get_genome.log", | ||
| cache: "omit-software" # save space and time with between workflow caching (see docs) | ||
| wrapper: | ||
| "master/bio/reference/ensembl-genomes-sequence" | ||
|
|
||
|
|
||
| rule get_multiple_chromosome: | ||
| output: | ||
| "refs/ensembl-genomes-chr3_and_chrMt.fasta", | ||
| params: | ||
| species="schizosaccharomyces_pombe", | ||
| assembly="ASM294v2", | ||
| division="fungi", | ||
| datatype="dna", | ||
| release="62", | ||
| chromosome=["III", "MT"], | ||
| log: | ||
| "logs/get_genome.log", | ||
| cache: "omit-software" # save space and time with between workflow caching (see docs) | ||
| wrapper: | ||
| "master/bio/reference/ensembl-genomes-sequence" | ||
|
|
||
|
|
||
| rule get_multiple_chromosomes_gzipped: | ||
| output: | ||
| "refs/ensembl-genomes-chr3_and_chrMt.fasta.gz", | ||
| params: | ||
| species="schizosaccharomyces_pombe", | ||
| assembly="ASM294v2", | ||
| division="fungi", | ||
| datatype="dna", | ||
| release="62", | ||
| chromosome=["III", "MT"], | ||
| log: | ||
| "logs/get_genome.log", | ||
| cache: "omit-software" # save space and time with between workflow caching (see docs) | ||
| wrapper: | ||
| "master/bio/reference/ensembl-genomes-sequence" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.