scripts/release/clan_file_generator.py
def clan_file_generator(output_dir, clan_comp_type='FULL', clan_acc=None):
    """
    Generates clan files for clan competition

    output_dir: The path to the output directory. It will be created if
    it does not exist
    clan_comp_type: This can be 'FULL' for clan competition on on full_region_table
    or PDB for clan competition on pdb_full_region

    returns: void
    """

    if os.path.exists(output_dir) is False:
        os.mkdir(output_dir)

    # fetch all clans
    clans = []
    if clan_acc is None:
        clans = rfamdb.fetch_clan_accessions()

    elif os.path.isfile(clan_acc):
        # fetches clan accessions from file
        clans = parse_clan_file(clan_acc)

    elif clan_acc[0:2] == "CL":
        clans.append(clan_acc)

    else:
        sys.exit("Wrong clan input provided!")

    # some sanity checks
    if clan_comp_type.upper() != 'FULL' and clan_comp_type.upper() != 'PDB':
        sys.exit("\nPlease provide correct type for clan competition!")

    # generate clan files
    for clan in clans:
        regions = []
        if clan_comp_type.upper() == 'FULL':
            regions = rfamdb.fetch_clan_full_region_records(clan)

        elif clan_comp_type.upper() == 'PDB':
            regions = rfamdb.fetch_clan_pdb_full_region_records(clan)

        # open a new clan file to dump the sequences
        if len(regions) > 0:
            print("clan: ", clan)
            clan_fp = open(os.path.join(output_dir, clan) + ".txt", 'w')

        # if no available regions, move to next clan
        else:
            continue

        flag = 1
        # loop over rows
        for region in regions:
            # append fields
            if clan_comp_type == 'FULL':
                region = region[:len(region) - 1]
            line = ''
            for field in region:
                if flag == 1:
                    line = str(field)
                    flag = 0
                else:
                    line = line + '\t' + str(field)

            line += '\n'

            clan_fp.write(line)
            flag = 1

        clan_fp.close()

        flag = 1

    Generates clan files for clan competition

    output_dir: The path to the output directory. It will be created if
    it does not exist
    clan_comp_type: This can be 'FULL' for clan competition on on full_region_table
    or PDB for clan competition on pdb_full_region

    returns: void
    
Generates clan files for clan competition
output_dir: The path to the output directory. It will be created if
it does not exist
clan_comp_type: This can be 'FULL' for clan competition on on full_region_table
or PDB for clan competition on pdb_full_region

void
Generates clan files for clan competition output_dir : The path to the output directory . It will be created if it does not exist clan_comp_type : This can be ' FULL ' for clan competition on on full_region_table or PDB for clan competition on pdb_full_region void
def clan_file_generator(output_dir, clan_comp_type='FULL', clan_acc=None):
    if os.path.exists(output_dir) is False:
        os.mkdir(output_dir)
    clans = []
    if clan_acc is None:
        clans = rfamdb.fetch_clan_accessions()
    elif os.path.isfile(clan_acc):
        clans = parse_clan_file(clan_acc)
    elif clan_acc[0:2] == "CL":
        clans.append(clan_acc)
    else:
        sys.exit("Wrong clan input provided!")
    if clan_comp_type.upper() != 'FULL' and clan_comp_type.upper() != 'PDB':
        sys.exit("\nPlease provide correct type for clan competition!")
    for clan in clans:
        regions = []
        if clan_comp_type.upper() == 'FULL':
            regions = rfamdb.fetch_clan_full_region_records(clan)
        elif clan_comp_type.upper() == 'PDB':
            regions = rfamdb.fetch_clan_pdb_full_region_records(clan)
        if len(regions) > 0:
            print("clan: ", clan)
            clan_fp = open(os.path.join(output_dir, clan) + ".txt", 'w')
        else:
            continue
        flag = 1
        for region in regions:
            if clan_comp_type == 'FULL':
                region = region[:len(region) - 1]
            line = ''
            for field in region:
                if flag == 1:
                    line = str(field)
                    flag = 0
                else:
                    line = line + '\t' + str(field)
            line += '\n'
            clan_fp.write(line)
            flag = 1
        clan_fp.close()
        flag = 1
def clan_file_generator ( output_dir , clan_comp_type = 'FULL' , clan_acc = None ) : if os . path . exists ( output_dir ) is False : os . mkdir ( output_dir ) clans = [ ] if clan_acc is None : clans = rfamdb . fetch_clan_accessions ( ) elif os . path . isfile ( clan_acc ) : clans = parse_clan_file ( clan_acc ) elif clan_acc [ 0 : 2 ] == "CL" : clans . append ( clan_acc ) else : sys . exit ( "Wrong clan input provided!" ) if clan_comp_type . upper ( ) != 'FULL' and clan_comp_type . upper ( ) != 'PDB' : sys . exit ( "\nPlease provide correct type for clan competition!" ) for clan in clans : regions = [ ] if clan_comp_type . upper ( ) == 'FULL' : regions = rfamdb . fetch_clan_full_region_records ( clan ) elif clan_comp_type . upper ( ) == 'PDB' : regions = rfamdb . fetch_clan_pdb_full_region_records ( clan ) if len ( regions ) > 0 : print ( "clan: " , clan ) clan_fp = open ( os . path . join ( output_dir , clan ) + ".txt" , 'w' ) else : continue flag = 1 for region in regions : if clan_comp_type == 'FULL' : region = region [ : len ( region ) - 1 ] line = '' for field in region : if flag == 1 : line = str ( field ) flag = 0 else : line = line + '\t' + str ( field ) line += '\n' clan_fp . write ( line ) flag = 1 clan_fp . close ( ) flag = 1
Generates clan files for clan competition
output_dir: The path to the output directory.
Generates clan files for clan competition output_dir : The path to the output directory .
"""
    Generates clan files for clan competition

    output_dir: The path to the output directory. It will be created if
    it does not exist
    clan_comp_type: This can be 'FULL' for clan competition on on full_region_table
    or PDB for clan competition on pdb_full_region

    returns: void
    """ # fetch all clans # fetches clan accessions from file # some sanity checks # generate clan files # open a new clan file to dump the sequences # if no available regions, move to next clan # loop over rows # append fields
output_dir
clan_comp_type
clan_acc