Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 5 additions & 0 deletions bio/reference/ensembl-genomes-annotation/environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
channels:
- conda-forge
- nodefaults
dependencies:
- curl
Comment thread
kbseah marked this conversation as resolved.
Outdated
13 changes: 13 additions & 0 deletions bio/reference/ensembl-genomes-annotation/meta.yaml
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``)
28 changes: 28 additions & 0 deletions bio/reference/ensembl-genomes-annotation/test/Snakefile
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"
67 changes: 67 additions & 0 deletions bio/reference/ensembl-genomes-annotation/wrapper.py
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(".")
Comment thread
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)
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
5 changes: 5 additions & 0 deletions bio/reference/ensembl-genomes-sequence/environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
channels:
- conda-forge
- nodefaults
dependencies:
- curl
14 changes: 14 additions & 0 deletions bio/reference/ensembl-genomes-sequence/meta.yaml
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/``)
81 changes: 81 additions & 0 deletions bio/reference/ensembl-genomes-sequence/test/Snakefile
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"
Loading