scripts/export/genomes/genome_fetch.py
def download_sequence_report_files(project_dir, upid_gca_file):
    """
    Loads upid_gca_file json file and downloads from ENA all sequence report
    files per GCA accession. Skips if no GCA accession available

    project_dir: The path to a project directory as generated by Genome
    Download pipeline (genome_downloader.py)
    upid_gca_file: upid_gca file in json format as generated by the Genome
    download pipeline (genome_downloader.py)

    returns: void
    """

    err_seq_rep_files = {}

    upid_gca_fp = open(upid_gca_file, 'r')
    acc_pairs = json.load(upid_gca_fp)
    upid_gca_fp.close()

    for upid in acc_pairs.keys():

        if acc_pairs[upid]["GCA"] != -1:
            domain_dir = os.path.join(project_dir, acc_pairs[upid]["DOM"])
            if not os.path.exists(domain_dir):
                os.mkdir(domain_dir)

            updir = os.path.join(domain_dir, upid)

            if not os.path.exists(updir):
                os.mkdir(updir)

            seq_rep_url = gc.SEQ_REP_URL_TEMPLATE % (acc_pairs[upid]["GCA"][0:7],
                                                     acc_pairs[upid]["GCA"][0:10],
                                                     acc_pairs[upid]["GCA"])

            filename = "%s_sequence_report.txt" % acc_pairs[upid]["GCA"]

            urllib.urlretrieve(seq_rep_url, os.path.join(updir, filename))

            # check file exists or if it is empty
            if not os.path.exists(filename):
                err_seq_rep_files[upid] = {"GCA": acc_pairs[upid]["GCA"],
                                           "DOM": acc_pairs[upid]["DOM"]}
                continue

            elif os.path.getsize(filename) == 0:
                err_seq_rep_files[upid] = {"GCA": acc_pairs[upid]["GCA"],
                                           "DOM": acc_pairs[upid]["DOM"]}

    if len(err_seq_rep_files.keys()) > 0:
        fp_out = open(os.path.join(project_dir, "err_seq_rep_files.json"), 'w')
        json.dump(err_seq_rep_files, fp_out)
        fp_out.close()

    Loads upid_gca_file json file and downloads from ENA all sequence report
    files per GCA accession. Skips if no GCA accession available

    project_dir: The path to a project directory as generated by Genome
    Download pipeline (genome_downloader.py)
    upid_gca_file: upid_gca file in json format as generated by the Genome
    download pipeline (genome_downloader.py)

    returns: void
    
Loads upid_gca_file json file and downloads from ENA all sequence report
files per GCA accession. Skips if no GCA accession available

The path to a project directory as generated by Genome
Download pipeline (genome_downloader.py)
upid_gca_file: upid_gca file in json format as generated by the Genome
download pipeline (genome_downloader.py)

void
Loads upid_gca_file json file and downloads from ENA all sequence report files per GCA accession . Skips if no GCA accession available The path to a project directory as generated by Genome Download pipeline ( genome_downloader . py ) upid_gca_file : upid_gca file in json format as generated by the Genome download pipeline ( genome_downloader . py ) void
def download_sequence_report_files(project_dir, upid_gca_file):
    err_seq_rep_files = {}
    upid_gca_fp = open(upid_gca_file, 'r')
    acc_pairs = json.load(upid_gca_fp)
    upid_gca_fp.close()
    for upid in acc_pairs.keys():
        if acc_pairs[upid]["GCA"] != -1:
            domain_dir = os.path.join(project_dir, acc_pairs[upid]["DOM"])
            if not os.path.exists(domain_dir):
                os.mkdir(domain_dir)
            updir = os.path.join(domain_dir, upid)
            if not os.path.exists(updir):
                os.mkdir(updir)
            seq_rep_url = gc.SEQ_REP_URL_TEMPLATE % (acc_pairs[upid]["GCA"][0:7],
                                                     acc_pairs[upid]["GCA"][0:10],
                                                     acc_pairs[upid]["GCA"])
            filename = "%s_sequence_report.txt" % acc_pairs[upid]["GCA"]
            urllib.urlretrieve(seq_rep_url, os.path.join(updir, filename))
            if not os.path.exists(filename):
                err_seq_rep_files[upid] = {"GCA": acc_pairs[upid]["GCA"],
                                           "DOM": acc_pairs[upid]["DOM"]}
                continue
            elif os.path.getsize(filename) == 0:
                err_seq_rep_files[upid] = {"GCA": acc_pairs[upid]["GCA"],
                                           "DOM": acc_pairs[upid]["DOM"]}
    if len(err_seq_rep_files.keys()) > 0:
        fp_out = open(os.path.join(project_dir, "err_seq_rep_files.json"), 'w')
        json.dump(err_seq_rep_files, fp_out)
        fp_out.close()
def download_sequence_report_files ( project_dir , upid_gca_file ) : err_seq_rep_files = { } upid_gca_fp = open ( upid_gca_file , 'r' ) acc_pairs = json . load ( upid_gca_fp ) upid_gca_fp . close ( ) for upid in acc_pairs . keys ( ) : if acc_pairs [ upid ] [ "GCA" ] != - 1 : domain_dir = os . path . join ( project_dir , acc_pairs [ upid ] [ "DOM" ] ) if not os . path . exists ( domain_dir ) : os . mkdir ( domain_dir ) updir = os . path . join ( domain_dir , upid ) if not os . path . exists ( updir ) : os . mkdir ( updir ) seq_rep_url = gc . SEQ_REP_URL_TEMPLATE % ( acc_pairs [ upid ] [ "GCA" ] [ 0 : 7 ] , acc_pairs [ upid ] [ "GCA" ] [ 0 : 10 ] , acc_pairs [ upid ] [ "GCA" ] ) filename = "%s_sequence_report.txt" % acc_pairs [ upid ] [ "GCA" ] urllib . urlretrieve ( seq_rep_url , os . path . join ( updir , filename ) ) if not os . path . exists ( filename ) : err_seq_rep_files [ upid ] = { "GCA" : acc_pairs [ upid ] [ "GCA" ] , "DOM" : acc_pairs [ upid ] [ "DOM" ] } continue elif os . path . getsize ( filename ) == 0 : err_seq_rep_files [ upid ] = { "GCA" : acc_pairs [ upid ] [ "GCA" ] , "DOM" : acc_pairs [ upid ] [ "DOM" ] } if len ( err_seq_rep_files . keys ( ) ) > 0 : fp_out = open ( os . path . join ( project_dir , "err_seq_rep_files.json" ) , 'w' ) json . dump ( err_seq_rep_files , fp_out ) fp_out . close ( )
Loads upid_gca_file json file and downloads from ENA all sequence report
files per GCA accession.
Loads upid_gca_file json file and downloads from ENA all sequence report files per GCA accession .
"""
    Loads upid_gca_file json file and downloads from ENA all sequence report
    files per GCA accession. Skips if no GCA accession available

    project_dir: The path to a project directory as generated by Genome
    Download pipeline (genome_downloader.py)
    upid_gca_file: upid_gca file in json format as generated by the Genome
    download pipeline (genome_downloader.py)

    returns: void
    """ # check file exists or if it is empty
project_dir
upid_gca_file