def getFTPs(accessions, ftp, search, exclude, convert = False, threads = <NUM_LIT:1>, attempt = <NUM_LIT:1>,<EOL>max_attempts = <NUM_LIT:2>):
info = wget(ftp)[<NUM_LIT:0>]<EOL>allMatches = []<EOL>for genome in open(info, encoding = '<STR_LIT:utf8>'):<EOL><INDENT>genome = str(genome)<EOL>matches, genomeInfo = check(genome, accessions)<EOL>if genomeInfo is not False:<EOL><INDENT>f = genomeInfo[<NUM_LIT:0>] + search<EOL>Gftp = genomeInfo[<NUM_LIT>]<EOL>Gftp = Gftp + '<STR_LIT:/>' + search<EOL>allMatches.extend(matches)<EOL>yield (Gftp, f, exclude, matches)<EOL><DEDENT><DEDENT>newAccs = []<EOL>missing = accessions.difference(set(allMatches))<EOL>if convert is True:<EOL><INDENT>pool = Pool(threads)<EOL>pool = pool.imap_unordered(searchAccession, missing)<EOL>for newAcc in tqdm(pool, total = len(missing)):<EOL><INDENT>status, accession, newAcc = newAcc<EOL>if status is True:<EOL><INDENT>newAccs.append(newAcc)<EOL><DEDENT>print('<STR_LIT>', accession, '<STR_LIT>', newAcc)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for accession in missing:<EOL><INDENT>print('<STR_LIT>', accession)<EOL><DEDENT><DEDENT>if len(newAccs) > <NUM_LIT:0> and attempt <= max_attempts:<EOL><INDENT>print('<STR_LIT>', attempt)<EOL>attempt += <NUM_LIT:1><EOL>for hit in getFTPs(set(newAccs), ftp, search, exclude, convert,<EOL>threads = <NUM_LIT:1>, attempt = attempt):<EOL><INDENT>yield hit<EOL><DEDENT><DEDENT>
download genome info from NCBI