scripts/release/genome_browser_hub_generator.py
def generate_new_genome_browser_hub_directories(genome_id_file, release_version, dest_dir, genome_project_dir):
    """
    Generates a new genome_browser_hub directory for an upcoming Rfam release

    genome_id_file: A tab delimited file containing the genome upids, assembly names and
    scientific names for each genome
    release_version: The Rfam version the genome browser hub derives from
    dest_dir: A valid path where to generate the directories. Preferably a new Rfam release
    directory

    return: void
    """

    accession_mapings = genome_browser_hub_id_list_parser(genome_id_file)

    # creating basic directory
    if not os.path.exists(dest_dir):
        os.mkdir(dest_dir)

    # create an output directory where to generate the bidbed files
    bed_files_dir = os.path.join(dest_dir, "bed_files")
    os.mkdir(bed_files_dir)

    # create a new genome_browser_hub directory
    new_gbh_dir = os.path.join(dest_dir, "genome_browser_hub")
    os.mkdir(new_gbh_dir)

    # generate genome.txt file
    generate_genome_text_file_from_dict(accession_mapings, release_version, new_gbh_dir)

    # generate hub.txt file
    generate_hub_txt_file(release_version, new_gbh_dir)

    # generate hub_description.html file
    generate_hub_description_html_file(release_version, new_gbh_dir)

    # change to bed_files dir
    os.chdir(bed_files_dir)
    # now generate genome directories, bigbed and trackDB files
    for genome in accession_mapings.keys():
        # replace spaces in species name with underscores
        # to be used as the genome directory name. If very long replace with common name
        genome_name = accession_mapings[genome]["species_name"].replace(' ', '_')
        genome_dir = os.path.join(new_gbh_dir, genome_name)
        os.mkdir(genome_dir)

        tbl_file_path = os.path.join(os.path.join(os.path.join(genome_project_dir,
                                                               genome[-3:]), genome),
                                     genome+'.tbl')

        genome_bed_dir = os.path.join(bed_files_dir, genome)
        os.mkdir(genome_bed_dir)

        tbl_copy = os.path.join(genome_bed_dir, genome+'.tbl')
        shutil.copyfile(tbl_file_path, tbl_copy)

        # call perl script to generate the bedfiles need upid.tbl file here
        cmd = "/path/to/tblout2bigBedGenomes.pl %s %s"

        subprocess.call(cmd % (tbl_copy, release_version), shell=True)
        shutil.copyfile(os.path.join(genome_bed_dir, genome+'.bigBed'), os.path.join(genome_dir, "bigBed"))

        generate_trackdb_file(genome_name, release_version, genome_dir)

    print "Done!"

    Generates a new genome_browser_hub directory for an upcoming Rfam release

    genome_id_file: A tab delimited file containing the genome upids, assembly names and
    scientific names for each genome
    release_version: The Rfam version the genome browser hub derives from
    dest_dir: A valid path where to generate the directories. Preferably a new Rfam release
    directory

    return: void
    
Generates a new genome_browser_hub directory for an upcoming Rfam release
genome_id_file: A tab delimited file containing the genome upids, assembly names and
scientific names for each genome
release_version: The Rfam version the genome browser hub derives from
dest_dir: A valid path where to generate the directories. Preferably a new Rfam release
directory

void
Generates a new genome_browser_hub directory for an upcoming Rfam release genome_id_file : A tab delimited file containing the genome upids assembly names and scientific names for each genome release_version : The Rfam version the genome browser hub derives from dest_dir : A valid path where to generate the directories . Preferably a new Rfam release directory void
def generate_new_genome_browser_hub_directories(genome_id_file, release_version, dest_dir, genome_project_dir):
    accession_mapings = genome_browser_hub_id_list_parser(genome_id_file)
    if not os.path.exists(dest_dir):
        os.mkdir(dest_dir)
    bed_files_dir = os.path.join(dest_dir, "bed_files")
    os.mkdir(bed_files_dir)
    new_gbh_dir = os.path.join(dest_dir, "genome_browser_hub")
    os.mkdir(new_gbh_dir)
    generate_genome_text_file_from_dict(accession_mapings, release_version, new_gbh_dir)
    generate_hub_txt_file(release_version, new_gbh_dir)
    generate_hub_description_html_file(release_version, new_gbh_dir)
    os.chdir(bed_files_dir)
    for genome in accession_mapings.keys():
        genome_name = accession_mapings[genome]["species_name"].replace(' ', '_')
        genome_dir = os.path.join(new_gbh_dir, genome_name)
        os.mkdir(genome_dir)
        tbl_file_path = os.path.join(os.path.join(os.path.join(genome_project_dir,
                                                               genome[-3:]), genome),
                                     genome+'.tbl')
        genome_bed_dir = os.path.join(bed_files_dir, genome)
        os.mkdir(genome_bed_dir)
        tbl_copy = os.path.join(genome_bed_dir, genome+'.tbl')
        shutil.copyfile(tbl_file_path, tbl_copy)
        cmd = "/path/to/tblout2bigBedGenomes.pl %s %s"
        subprocess.call(cmd % (tbl_copy, release_version), shell=True)
        shutil.copyfile(os.path.join(genome_bed_dir, genome+'.bigBed'), os.path.join(genome_dir, "bigBed"))
        generate_trackdb_file(genome_name, release_version, genome_dir)
    print "Done!"
def generate_new_genome_browser_hub_directories ( genome_id_file , release_version , dest_dir , genome_project_dir ) : accession_mapings = genome_browser_hub_id_list_parser ( genome_id_file ) if not os . path . exists ( dest_dir ) : os . mkdir ( dest_dir ) bed_files_dir = os . path . join ( dest_dir , "bed_files" ) os . mkdir ( bed_files_dir ) new_gbh_dir = os . path . join ( dest_dir , "genome_browser_hub" ) os . mkdir ( new_gbh_dir ) generate_genome_text_file_from_dict ( accession_mapings , release_version , new_gbh_dir ) generate_hub_txt_file ( release_version , new_gbh_dir ) generate_hub_description_html_file ( release_version , new_gbh_dir ) os . chdir ( bed_files_dir ) for genome in accession_mapings . keys ( ) : genome_name = accession_mapings [ genome ] [ "species_name" ] . replace ( ' ' , '_' ) genome_dir = os . path . join ( new_gbh_dir , genome_name ) os . mkdir ( genome_dir ) tbl_file_path = os . path . join ( os . path . join ( os . path . join ( genome_project_dir , genome [ - 3 : ] ) , genome ) , genome + '.tbl' ) genome_bed_dir = os . path . join ( bed_files_dir , genome ) os . mkdir ( genome_bed_dir ) tbl_copy = os . path . join ( genome_bed_dir , genome + '.tbl' ) shutil . copyfile ( tbl_file_path , tbl_copy ) cmd = "/path/to/tblout2bigBedGenomes.pl %s %s" subprocess . call ( cmd % ( tbl_copy , release_version ) , shell = True ) shutil . copyfile ( os . path . join ( genome_bed_dir , genome + '.bigBed' ) , os . path . join ( genome_dir , "bigBed" ) ) generate_trackdb_file ( genome_name , release_version , genome_dir ) print "Done!"
Generates a new genome_browser_hub directory for an upcoming Rfam release
genome_id_file: A tab delimited file containing the genome upids, assembly names and
scientific names for each genome
release_version: The Rfam version the genome browser hub derives from
dest_dir: A valid path where to generate the directories.
Generates a new genome_browser_hub directory for an upcoming Rfam release genome_id_file : A tab delimited file containing the genome upids assembly names and scientific names for each genome release_version : The Rfam version the genome browser hub derives from dest_dir : A valid path where to generate the directories .
"""
    Generates a new genome_browser_hub directory for an upcoming Rfam release

    genome_id_file: A tab delimited file containing the genome upids, assembly names and
    scientific names for each genome
    release_version: The Rfam version the genome browser hub derives from
    dest_dir: A valid path where to generate the directories. Preferably a new Rfam release
    directory

    return: void
    """ # creating basic directory # create an output directory where to generate the bidbed files # create a new genome_browser_hub directory # generate genome.txt file # generate hub.txt file # generate hub_description.html file # change to bed_files dir # now generate genome directories, bigbed and trackDB files # replace spaces in species name with underscores # to be used as the genome directory name. If very long replace with common name # call perl script to generate the bedfiles need upid.tbl file here
genome_id_file
release_version
dest_dir
genome_project_dir