INNER CODE UNIT · Python

get_name_and_checksum

kblin/ncbi-genome-download · ncbi_genome_download/core.py:606

def get_name_and_checksum(checksums, end):
    """Extract a full filename and checksum from the checksums list for a file ending in given end."""
    cds_fasta = NgdConfig.get_fileending('cds-fasta')
    rna_fasta = NgdConfig.get_fileending('rna-fasta')
    for entry in checksums:
        if not entry['file'].endswith(end):
            # wrong file
            continue
        # workaround for ..cds_from_genomic.fna.gz and ..rna_from_genomic.fna.gz also
        # ending in _genomic.fna.gz, causing bogus matches for the plain fasta
        if (entry['file'].endswith(cds_fasta) and end != cds_fasta) or \
           (entry['file'].endswith(rna_fasta) and end != rna_fasta):
            # still the wrong file
            continue  # pragma: no cover  # somehow coverage misses that this is in fact covered
        filename = entry['file']
        expected_checksum = entry['checksum']
        return filename, expected_checksum
    raise ValueError('No entry for file ending in {!r}'.format(end))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…