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

Update the FTP parsing to cope with changes on ensembl FTP #205

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions eva_submission/vep_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ def get_releases(ftp, subdir, current_only):
"""
all_releases = {}
for file in ftp.nlst(subdir):
if "release-" in file:
release_number = file[file.index("-") + 1:]
m = re.match(rf"^{subdir}/release-(\d+)$", file)
if m:
release_number = m.group(1)
all_releases.update({int(release_number): file})
if current_only:
current = max(all_releases)
Expand Down
11 changes: 10 additions & 1 deletion tests/test_vep_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

from eva_submission.submission_config import load_config
from eva_submission.vep_utils import recursive_nlst, get_vep_and_vep_cache_version_from_ensembl, \
get_vep_and_vep_cache_version, download_and_extract_vep_cache, get_ftp_connection, get_species_and_assembly
get_vep_and_vep_cache_version, download_and_extract_vep_cache, get_ftp_connection, get_species_and_assembly, \
get_releases, ensembl_ftp_url, ensembl_genome_ftp_url, ensembl_genome_dirs


class TestVepUtils(TestCase):
Expand Down Expand Up @@ -149,3 +150,11 @@ def test_get_species_and_assembly(self):
for assembly in assemblies2results:
res = get_species_and_assembly(assembly)
assert res == assemblies2results.get(assembly)

def test_get_releases(self):
with get_ftp_connection(ensembl_ftp_url) as ftp:
assert get_releases(ftp, 'pub', current_only=True) == {112: 'pub/release-112'}

with get_ftp_connection(ensembl_genome_ftp_url) as ftp:
assert get_releases(ftp, ensembl_genome_dirs[0], current_only=True) == {58: 'ensemblgenomes/pub/plants/release-58'}

Loading