scripts/validation/genome_download_validator.py
def project_download_validator(project_dir, id_pairs_file=None, filename=None):
    """
    Loops over a genome download project directory and reports all the upids
    that need to be recovered

    project_dir: Destination directory of genome download pipeline
    id_pairs_file: A json file with all the UPids of the corresponding
    Uniprot's release. If None simply reports a list of UPIds
    filename: A name for the output file. "recovery.tsv" will be used otherwise

    returns: void
    """
    upids_to_recover = []

    sub_dirs = [x for x in os.listdir(project_dir) if x in gc.DOMAINS]

    for sub_dir in sub_dirs:
        domain_dir_path = os.path.join(project_dir, sub_dir)
        upids_to_recover.extend(domain_download_validator(domain_dir_path,
                                                          filename=None))
        # would also be good to remove those genome dirs

    if filename is None:
        filename = "recovery"

    if len(upids_to_recover) != 0:
        fp_out = open(os.path.join(project_dir, filename + '.tsv'), 'w')

        if id_pairs_file is not None:
            fp_in = open(id_pairs_file, 'r')
            all_id_pairs = json.load(fp_in)
            fp_in.close()

            for upid in upids_to_recover:
                fp_out.write(upid + '\t' + str(all_id_pairs[upid]["GCA"]) +
                             '\t' + all_id_pairs[upid]["DOM"] + '\n')

        # list upids if the UPID/GCA pairs are not available
        else:
            for upid in upids_to_recover:
                fp_out.write(upid + '\n')

        fp_out.close()

    else:
        print "\nGenome Download Success!"

    Loops over a genome download project directory and reports all the upids
    that need to be recovered

    project_dir: Destination directory of genome download pipeline
    id_pairs_file: A json file with all the UPids of the corresponding
    Uniprot's release. If None simply reports a list of UPIds
    filename: A name for the output file. "recovery.tsv" will be used otherwise

    returns: void
    
Loops over a genome download project directory and reports all the upids
that need to be recovered

Destination directory of genome download pipeline
id_pairs_file: A json file with all the UPids of the corresponding
Uniprot's release. If None simply reports a list of UPIds
filename: A name for the output file. "recovery.tsv" will be used otherwise

void
Loops over a genome download project directory and reports all the upids that need to be recovered Destination directory of genome download pipeline id_pairs_file : A json file with all the UPids of the corresponding Uniprot ' s release . If None simply reports a list of UPIds filename : A name for the output file . " recovery . tsv " will be used otherwise void
def project_download_validator(project_dir, id_pairs_file=None, filename=None):
    upids_to_recover = []
    sub_dirs = [x for x in os.listdir(project_dir) if x in gc.DOMAINS]
    for sub_dir in sub_dirs:
        domain_dir_path = os.path.join(project_dir, sub_dir)
        upids_to_recover.extend(domain_download_validator(domain_dir_path,
                                                          filename=None))
    if filename is None:
        filename = "recovery"
    if len(upids_to_recover) != 0:
        fp_out = open(os.path.join(project_dir, filename + '.tsv'), 'w')
        if id_pairs_file is not None:
            fp_in = open(id_pairs_file, 'r')
            all_id_pairs = json.load(fp_in)
            fp_in.close()
            for upid in upids_to_recover:
                fp_out.write(upid + '\t' + str(all_id_pairs[upid]["GCA"]) +
                             '\t' + all_id_pairs[upid]["DOM"] + '\n')
        else:
            for upid in upids_to_recover:
                fp_out.write(upid + '\n')
        fp_out.close()
    else:
        print "\nGenome Download Success!"
def project_download_validator ( project_dir , id_pairs_file = None , filename = None ) : upids_to_recover = [ ] sub_dirs = [ x for x in os . listdir ( project_dir ) if x in gc . DOMAINS ] for sub_dir in sub_dirs : domain_dir_path = os . path . join ( project_dir , sub_dir ) upids_to_recover . extend ( domain_download_validator ( domain_dir_path , filename = None ) ) if filename is None : filename = "recovery" if len ( upids_to_recover ) != 0 : fp_out = open ( os . path . join ( project_dir , filename + '.tsv' ) , 'w' ) if id_pairs_file is not None : fp_in = open ( id_pairs_file , 'r' ) all_id_pairs = json . load ( fp_in ) fp_in . close ( ) for upid in upids_to_recover : fp_out . write ( upid + '\t' + str ( all_id_pairs [ upid ] [ "GCA" ] ) + '\t' + all_id_pairs [ upid ] [ "DOM" ] + '\n' ) else : for upid in upids_to_recover : fp_out . write ( upid + '\n' ) fp_out . close ( ) else : print "\nGenome Download Success!"
Loops over a genome download project directory and reports all the upids
that need to be recovered
Loops over a genome download project directory and reports all the upids that need to be recovered
"""
    Loops over a genome download project directory and reports all the upids
    that need to be recovered

    project_dir: Destination directory of genome download pipeline
    id_pairs_file: A json file with all the UPids of the corresponding
    Uniprot's release. If None simply reports a list of UPIds
    filename: A name for the output file. "recovery.tsv" will be used otherwise

    returns: void
    """ # would also be good to remove those genome dirs # list upids if the UPID/GCA pairs are not available
project_dir
id_pairs_file
filename