Skip to content

Commit

Permalink
try to make ftp tests more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
apriltuesday committed Sep 15, 2023
1 parent 61e1fdd commit 25afa6b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
23 changes: 11 additions & 12 deletions eva_submission/vep_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
]



def vep_path(version):
return os.path.join(cfg['vep_path'], f'ensembl-vep-release-{version}/vep')

Expand Down Expand Up @@ -110,19 +109,19 @@ def get_vep_cache_version_from_ftp(assembly_accession, ensembl_assembly_name=Non
# otherwise we just search the most recent release.

# First try main Ensembl release
ftp = get_ftp_connection(ensembl_ftp_url)
all_releases = get_releases(ftp, '/pub', current_release_only)
release = search_releases(ftp, all_releases, species_name, assembly_name, taxonomy_id)
if release:
return release, 'ensembl'
with get_ftp_connection(ensembl_ftp_url) as ftp:
all_releases = get_releases(ftp, '/pub', current_release_only)
release = search_releases(ftp, all_releases, species_name, assembly_name, taxonomy_id)
if release:
return release, 'ensembl'

# Then try all Ensembl genomes
genome_ftp = get_ftp_connection(ensembl_genome_ftp_url)
for subdir in ensembl_genome_dirs:
genome_releases = get_releases(genome_ftp, subdir, current_release_only)
release = search_releases(genome_ftp, genome_releases, species_name, assembly_name, taxonomy_id)
if release:
return release, 'genomes'
with get_ftp_connection(ensembl_genome_ftp_url) as genome_ftp:
for subdir in ensembl_genome_dirs:
genome_releases = get_releases(genome_ftp, subdir, current_release_only)
release = search_releases(genome_ftp, genome_releases, species_name, assembly_name, taxonomy_id)
if release:
return release, 'genomes'

logger.info(f'No VEP cache found anywhere on Ensembl FTP for {species_name} and {assembly_name}')
return None, None
Expand Down
11 changes: 6 additions & 5 deletions tests/test_vep_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,12 @@ def test_get_vep_versions(self):
def test_download_and_extract_vep_cache(self):
with patch('eva_submission.vep_utils.retrieve_species_scientific_name_from_tax_id_ncbi') as m_get_scf_name:
m_get_scf_name.return_value = 'whatever_species_name'
download_and_extract_vep_cache(
get_ftp_connection('ftp.ensembl.org'),
'/pub/release-105/variation/indexed_vep_cache/papio_anubis_refseq_vep_105_Panubis1.0.tar.gz', 1001
)
assert os.path.exists(os.path.join(cfg['vep_cache_path'], 'whatever_species_name', '105_Panubis1.0'))
with get_ftp_connection('ftp.ensembl.org') as ftp_conn:
download_and_extract_vep_cache(
ftp_conn,
'/pub/release-105/variation/indexed_vep_cache/papio_anubis_refseq_vep_105_Panubis1.0.tar.gz', 1001
)
assert os.path.exists(os.path.join(cfg['vep_cache_path'], 'whatever_species_name', '105_Panubis1.0'))

def test_get_species_and_assembly(self):
assemblies2results = {
Expand Down

0 comments on commit 25afa6b

Please sign in to comment.