# HG changeset patch # User greg # Date 1513705576 18000 # Node ID ff5bd57b1fddef33da013312b1d0e67dc50c82be # Parent ce217f091366dfe91f1824b9cfe7cdbffaa0940a Uploaded diff -r ce217f091366 -r ff5bd57b1fdd ideas_genome_tracks.R --- a/ideas_genome_tracks.R Tue Dec 19 12:29:48 2017 -0500 +++ b/ideas_genome_tracks.R Tue Dec 19 12:46:16 2017 -0500 @@ -102,24 +102,25 @@ # Create a trackDb.txt file that includes each state. base_track_file_name <- paste(tracks_dir, hub_name, sep=""); cells = create_track(input_dir_state, chrom_len_file, base_track_file_name); - if (is.null(state_indexes)) { - # Create a a character vector of 1024 viridis color hex codes. - viridis_vector <- viridis(1024, alpha=1, begin=0, end=1, direction=1, option="D"); - colors_used <- vector(); - } else { + # Create a a character vector of 1024 viridis color hex codes. + # This vector could be used even if the state_colors were received + # since colors may not have been chosen for all states. + viridis_vector <- viridis(1024, alpha=1, begin=0, end=1, direction=1, option="D"); + colors_used <- vector(); + if (!is.null(state_indexes)) { # Split state_indexes into a list of integers. - indexes <- c(); + s_indexes <- c(); index_str <- as.character(state_indexes); items <- strsplit(index_str, ",") for (item in items) { - indexes <- c(indexes, as.integer(item)); + s_indexes <- c(s_indexes, as.integer(item)); } # Split state_colors into a list of strings. - colors <- c(); + s_colors <- c(); color_str <- as.character(state_colors); items <- strsplit(color_str, ","); for (item in items) { - colors <- c(colors, item); + s_colors <- c(s_colors, item); } } track_db = NULL; @@ -138,7 +139,7 @@ color_hex_code <- viridis_vector[color_index]; } else { # Use the selected color for the current state. - color_hex_code <- colors[i]; + color_hex_code <- s_colors[i]; } big_data_url <- get_big_data_url(galaxy_url, encoded_dataset_id, tracks_dir, i, build); # trackDb.txt track entry.