Skip to content
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

fix: properly handle proxy setting in vep cache wrapper #986

Merged
merged 5 commits into from Jan 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 34 additions & 12 deletions bio/vep/cache/wrapper.py
@@ -1,21 +1,43 @@
__author__ = "Johannes Köster"
__copyright__ = "Copyright 2020, Johannes Köster"
__copyright__ = "Copyright 2023, Johannes Köster"
__email__ = "johannes.koester@uni-due.de"
__license__ = "MIT"

import tempfile
from pathlib import Path
from snakemake.shell import shell


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

shell(
"vep_install --AUTO cf "
"--SPECIES {snakemake.params.species} "
"--ASSEMBLY {snakemake.params.build} "
"--VERSION {snakemake.params.release} "
"--CACHEDIR {snakemake.output} "
"--CONVERT "
"--NO_UPDATE "
"{extra} {log}"
)
try:
release = int(snakemake.params.release)
except ValueError:
raise ValueError("The parameter release is supposed to be an integer.")

with tempfile.TemporaryDirectory() as tmpdir:
# We download the cache tarball manually because vep_install does not consider proxy settings (in contrast to curl).
# See https://github.com/bcbio/bcbio-nextgen/issues/1080
vep_dir = "vep" if release >= 97 else "VEP"
cache_tarball = (
f"{snakemake.params.species}_vep_{release}_{snakemake.params.build}.tar.gz"
)
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
shell(
"curl -L ftp://ftp.ensembl.org/pub/release-{snakemake.params.release}/"
"variation/{vep_dir}/{cache_tarball} "
"-o {tmpdir}/{cache_tarball} {log}"
)

log = snakemake.log_fmt_shell(stdout=True, stderr=True, append=True)
shell(
"vep_install --AUTO cf "
"--SPECIES {snakemake.params.species} "
"--ASSEMBLY {snakemake.params.build} "
"--VERSION {release} "
"--CACHEURL {tmpdir} "
"--CACHEDIR {snakemake.output} "
"--CONVERT "
"--NO_UPDATE "
"{extra} {log}"
)