scripts/export/genomes/genome_fetch.py
def fetch_ena_file(acc, file_format, dest_dir, compressed=True):
    """
    Retrieves a file given a valid ENA accession and stores it in the
    indicated destination in the selected format

    acc: A valid ENA entry accession
    format: A valid ENA file format (xml, fasta, txt)
    dest_dit: A valid path to destination directory
    """

    seq_url = None
    file_path = None

    if file_format.find("xml") != -1:
        seq_url = ENA_XML_URL % acc
        file_path = os.path.join(dest_dir, acc + FORMATS[file_format])

    # fetching compressed file
    else:
        if compressed is True:
            seq_url = ENA_DATA_URL_GZIP % (acc, file_format)
            file_path = os.path.join(dest_dir, acc + FORMATS[file_format] + ".gz")
        else:
            seq_url = ENA_DATA_URL % (acc, file_format)
            file_path = os.path.join(dest_dir, acc + FORMATS[file_format])

    # check url is available
    response = requests.get(seq_url)
    if response.status_code == 200:
        urllib.urlretrieve(seq_url, file_path)

    if os.path.exists(file_path):
        return True

    return False

    Retrieves a file given a valid ENA accession and stores it in the
    indicated destination in the selected format

    acc: A valid ENA entry accession
    format: A valid ENA file format (xml, fasta, txt)
    dest_dit: A valid path to destination directory
    
Retrieves a file given a valid ENA accession and stores it in the
indicated destination in the selected format

A valid ENA entry accession
format: A valid ENA file format (xml, fasta, txt)
dest_dit: A valid path to destination directory
Retrieves a file given a valid ENA accession and stores it in the indicated destination in the selected format A valid ENA entry accession format : A valid ENA file format ( xml fasta txt ) dest_dit : A valid path to destination directory
def fetch_ena_file(acc, file_format, dest_dir, compressed=True):
    seq_url = None
    file_path = None
    if file_format.find("xml") != -1:
        seq_url = ENA_XML_URL % acc
        file_path = os.path.join(dest_dir, acc + FORMATS[file_format])
    else:
        if compressed is True:
            seq_url = ENA_DATA_URL_GZIP % (acc, file_format)
            file_path = os.path.join(dest_dir, acc + FORMATS[file_format] + ".gz")
        else:
            seq_url = ENA_DATA_URL % (acc, file_format)
            file_path = os.path.join(dest_dir, acc + FORMATS[file_format])
    response = requests.get(seq_url)
    if response.status_code == 200:
        urllib.urlretrieve(seq_url, file_path)
    if os.path.exists(file_path):
        return True
    return False
def fetch_ena_file ( acc , file_format , dest_dir , compressed = True ) : seq_url = None file_path = None if file_format . find ( "xml" ) != - 1 : seq_url = ENA_XML_URL % acc file_path = os . path . join ( dest_dir , acc + FORMATS [ file_format ] ) else : if compressed is True : seq_url = ENA_DATA_URL_GZIP % ( acc , file_format ) file_path = os . path . join ( dest_dir , acc + FORMATS [ file_format ] + ".gz" ) else : seq_url = ENA_DATA_URL % ( acc , file_format ) file_path = os . path . join ( dest_dir , acc + FORMATS [ file_format ] ) response = requests . get ( seq_url ) if response . status_code == 200 : urllib . urlretrieve ( seq_url , file_path ) if os . path . exists ( file_path ) : return True return False
Retrieves a file given a valid ENA accession and stores it in the
indicated destination in the selected format
Retrieves a file given a valid ENA accession and stores it in the indicated destination in the selected format
"""
    Retrieves a file given a valid ENA accession and stores it in the
    indicated destination in the selected format

    acc: A valid ENA entry accession
    format: A valid ENA file format (xml, fasta, txt)
    dest_dit: A valid path to destination directory
    """ # fetching compressed file # check url is available
acc
file_format
dest_dir
compressed