scripts/export/genomes/ena_genome_downloader.py
def main(genome_accession_file, project_dir, lsf=True):

    """
    Parses a file of genome accessions and downloads genomes from ENA. Genomes
    are downloaded in fasta format. It is a requirement that genome_accession
    file containes a GCA or WGS accession per genome

    genome_accession_file: A file with a list of upid\tGCA\tdomain or
    upid\tWGS\tdomain pairs
    project_dir: The path to the directory where all genomes will be downloaded
    It will be created if it does not exist

    return: void
    """

    # generating project_directory
    if not os.path.exists(project_dir):
        os.mkdir(project_dir)

    # create a file handle and read genome id pairs
    input_fp = open(genome_accession_file, 'r')

    for genome in input_fp:
        genome_data = genome.strip().split('\t')
        upid = genome_data[0]
        domain = genome_data[2]
        gen_acc = genome_data[1]

        # create domain directory
        domain_dir = os.path.join(project_dir, domain)
        if not os.path.exists(domain_dir):
            os.mkdir(domain_dir)

        # create genome directory e.g. project_dir/domain/updir
        updir = os.path.join(project_dir, os.path.join(domain_dir, upid))
        if not os.path.exists(updir):
            os.mkdir(updir)

        if lsf is not True:
            fetch_genome_from_ENA(gen_acc, updir)

        # submit a job
        else:
            err_file = os.path.join(updir, upid+'.err')
            out_file = os.path.join(updir, upid+'.err')
            bsub_cmd = "bsub -o %s -e %s -g %s %s -f fasta -m -d %s %s" % (out_file,
                                                                      err_file,
                                                                      LSF_GROUP % domain,
                                                                      os.path.join(ENA_TOOL, 'enaDataGet'),
                                                                      updir,
                                                                      gen_acc)
            subprocess.call(bsub_cmd, shell=True)

    Parses a file of genome accessions and downloads genomes from ENA. Genomes
    are downloaded in fasta format. It is a requirement that genome_accession
    file containes a GCA or WGS accession per genome

    genome_accession_file: A file with a list of upid\tGCA\tdomain or
    upid\tWGS\tdomain pairs
    project_dir: The path to the directory where all genomes will be downloaded
    It will be created if it does not exist

    return: void
    
Parses a file of genome accessions and downloads genomes from ENA. Genomes
are downloaded in fasta format. It is a requirement that genome_accession
file containes a GCA or WGS accession per genome

A file with a list of upid\tGCA\tdomain or
upid\tWGS\tdomain pairs
project_dir: The path to the directory where all genomes will be downloaded
It will be created if it does not exist

void
Parses a file of genome accessions and downloads genomes from ENA . Genomes are downloaded in fasta format . It is a requirement that genome_accession file containes a GCA or WGS accession per genome A file with a list of upid \ tGCA \ tdomain or upid \ tWGS \ tdomain pairs project_dir : The path to the directory where all genomes will be downloaded It will be created if it does not exist void
def main(genome_accession_file, project_dir, lsf=True):
    if not os.path.exists(project_dir):
        os.mkdir(project_dir)
    input_fp = open(genome_accession_file, 'r')
    for genome in input_fp:
        genome_data = genome.strip().split('\t')
        upid = genome_data[0]
        domain = genome_data[2]
        gen_acc = genome_data[1]
        domain_dir = os.path.join(project_dir, domain)
        if not os.path.exists(domain_dir):
            os.mkdir(domain_dir)
        updir = os.path.join(project_dir, os.path.join(domain_dir, upid))
        if not os.path.exists(updir):
            os.mkdir(updir)
        if lsf is not True:
            fetch_genome_from_ENA(gen_acc, updir)
        else:
            err_file = os.path.join(updir, upid+'.err')
            out_file = os.path.join(updir, upid+'.err')
            bsub_cmd = "bsub -o %s -e %s -g %s %s -f fasta -m -d %s %s" % (out_file,
                                                                      err_file,
                                                                      LSF_GROUP % domain,
                                                                      os.path.join(ENA_TOOL, 'enaDataGet'),
                                                                      updir,
                                                                      gen_acc)
            subprocess.call(bsub_cmd, shell=True)
def main ( genome_accession_file , project_dir , lsf = True ) : if not os . path . exists ( project_dir ) : os . mkdir ( project_dir ) input_fp = open ( genome_accession_file , 'r' ) for genome in input_fp : genome_data = genome . strip ( ) . split ( '\t' ) upid = genome_data [ 0 ] domain = genome_data [ 2 ] gen_acc = genome_data [ 1 ] domain_dir = os . path . join ( project_dir , domain ) if not os . path . exists ( domain_dir ) : os . mkdir ( domain_dir ) updir = os . path . join ( project_dir , os . path . join ( domain_dir , upid ) ) if not os . path . exists ( updir ) : os . mkdir ( updir ) if lsf is not True : fetch_genome_from_ENA ( gen_acc , updir ) else : err_file = os . path . join ( updir , upid + '.err' ) out_file = os . path . join ( updir , upid + '.err' ) bsub_cmd = "bsub -o %s -e %s -g %s %s -f fasta -m -d %s %s" % ( out_file , err_file , LSF_GROUP % domain , os . path . join ( ENA_TOOL , 'enaDataGet' ) , updir , gen_acc ) subprocess . call ( bsub_cmd , shell = True )
Parses a file of genome accessions and downloads genomes from ENA.
Parses a file of genome accessions and downloads genomes from ENA .
"""
    Parses a file of genome accessions and downloads genomes from ENA. Genomes
    are downloaded in fasta format. It is a requirement that genome_accession
    file containes a GCA or WGS accession per genome

    genome_accession_file: A file with a list of upid\tGCA\tdomain or
    upid\tWGS\tdomain pairs
    project_dir: The path to the directory where all genomes will be downloaded
    It will be created if it does not exist

    return: void
    """ # generating project_directory # create a file handle and read genome id pairs # create domain directory # create genome directory e.g. project_dir/domain/updir # submit a job
genome_accession_file
project_dir
lsf