Skip to content

Commit

Permalink
Update the FTP parsing to cope with changes on ensembl FTP (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcezard authored May 14, 2024
1 parent 70b3d3c commit 9241e81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
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'}

0 comments on commit 9241e81

Please sign in to comment.