css_error css__compose_min_width(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { css_fixed length = 0; css_unit unit = CSS_UNIT_PX; uint8_t type = get_min_width(child, &length, &unit); if (type == CSS_MIN_WIDTH_INHERIT) { type = get_min_width(parent, &length, &unit); } return set_min_width(result, type, length, unit); }
/** * get_s_point * * Retrieve the spoint with the given width and nsites. * * \return A pointer to the apporpriate S_POINT object * */ S_POINT *get_s_point ( SP_MATRIX *sp_mat, ///< The s_point matrix int width, ///< The width the desired s_point int nsites ///< The nsites of the desired s_point ) { S_POINT **matrix = get_sp_matrix(sp_mat); // get the minimum width and nsites int min_w = get_min_width(sp_mat); int min_ns = get_min_nsites(sp_mat); // adjust width and nsites index the correct position in the sp_matrix return &(matrix[width-min_w][nsites-min_ns]); }
/** * get_sp_arr * * Retrieves a row from the spoint matrix. The row number is equal to the * width of the starting points/seeds considered in that row. * * \return An array of all S_POINTS with the specified seed width. * */ S_POINT *get_sp_arr ( SP_MATRIX *sp_mat, ///< The spoint matrix int seed_width ///< The number of the desired row ) { S_POINT **matrix = get_sp_matrix(sp_mat); // Index in the matrix is found by calculating index of the specified width // relative to the smallest width: int row_idx = seed_width - (get_min_width(sp_mat)); return matrix[row_idx]; }
/** * search_matrix_partition * * Searches the specified partition of the matrix, for the S_POINT with the * smallest significance value. * * \return The S_POINT with the smallest significance value. Returns NULL if no * S_POINT (in the partition) had a significance less than BIG. */ static S_POINT *search_matrix_partition ( SP_MATRIX *sp_mat, ///< The matrix containing the partition of interest DATASET *data, ///< Sequence dataset. MODEL *model, ///< The nascent motif model. Contains parameters needed ///< in order to calculate significance of scores PARTITION *part ///< The coordinates of the partition within the matrix ) { // Consider each S_POINT in the partition. Find the S_POINT with the // smallest significance value... double curr_best_sig = BIG; S_POINT *curr_best_sp = NULL; int curr_w, curr_n; for (curr_w = part->min_w; curr_w <= part->max_w; curr_w++) { assert (curr_w <= get_max_width(sp_mat)); for (curr_n = part->min_n; curr_n <= part->max_n; curr_n++) { assert (curr_n <= get_max_nsites(sp_mat)); int w_idx = curr_w - get_min_width(sp_mat); int n_idx = curr_n - get_min_nsites(sp_mat); // Get the current S_POINT from the SP_MATRIX: S_POINT *curr_sp = get_spoint(sp_mat, w_idx, n_idx); // Only consider the current s_point if it has been initialised. Note // that (spoint initialised <==> contains non-empty cons0 string): double curr_sig = BIG; // s_point is non-significant by default. if ((curr_sp->cons0 != NULL) && (strcmp(curr_sp->cons0, "") != 0)) { curr_sig = get_log_sig( curr_sp->score, model->mtype, curr_sp->w0, curr_sp->wgt_nsites, curr_sp->nsites0, model->invcomp, model->pal, data ); curr_sp->sig = curr_sig; if (curr_sig <= curr_best_sig) { curr_best_sig = curr_sig; curr_best_sp = curr_sp; } } // Only considering s_point if initialised } // curr_n } // curr_w return curr_best_sp; } // search_matrix_partition
/** * create_partitions * * Generate a list of PARTITION objects, which store the coordinates of blocks * in the matrix. These blocks can then be considered in the future - eg * for the purpose of choosing a list of EM starts from the matrix. The * array of partitions objects is referenced by the sp_matrix. * */ static void create_partitions ( SP_MATRIX *sp_mat ///< The sp_matrix object ///< Currently no parameters. May allow user manipulation later. ) { /* For every central s_point (ie s_point with central w and n) in the * matrix, calculate the boundaries of the current partition and then * generate a partition that fits within those bounds... */ int *central_widths = get_central_ws(sp_mat); int *central_nsites = get_central_ns(sp_mat); int w_idx; int n_partitions = 0; PARTITION **part_array = NULL; for (w_idx = 0; w_idx < get_num_central_widths(sp_mat); w_idx++) { int n_idx; for (n_idx = 0; n_idx < get_num_central_nsites(sp_mat); n_idx++) { int curr_w = central_widths[w_idx]; int curr_n = central_nsites[n_idx]; /* Calculate the boundaries within which the current partition must * be located. The boundaries are half way between the current * value and the adjacent value, unless there is no adjacent value * (in which case the boundary IS the current value): */ double min_w_bounds, max_w_bounds, min_n_bounds, max_n_bounds; if (curr_w == get_min_width(sp_mat)) { min_w_bounds = curr_w; } else { int prev_w = central_widths[w_idx - 1]; min_w_bounds = (curr_w + prev_w)/(double)2; } if (curr_w == get_max_width(sp_mat)) { max_w_bounds = curr_w; } else { int next_w = central_widths[w_idx + 1]; max_w_bounds = (curr_w + next_w)/(double)2; } if (curr_n == get_min_nsites(sp_mat)) { min_n_bounds = curr_n; } else { int prev_n = central_nsites[n_idx - 1]; min_n_bounds = (curr_n + prev_n)/(double)2; } if (curr_n == get_max_nsites(sp_mat)) { max_n_bounds = curr_n; } else { int next_n = central_nsites[n_idx + 1]; max_n_bounds = (curr_n + next_n)/(double)2; } /* Calculate the minimum and maximum w and n values which define the current partition. The minimum value is the smallest integer that is >= the minimum boundary. The maximum value is the largest integer that is < the maximum boundary, unless the maximum boundary is the max value in the sp_matrix (in which case the maximum value is the maximum boundary itself). This ensures that every s_point in the matrix will be assigned to a partition. */ int part_min_w, part_max_w, part_min_n, part_max_n; part_min_w = (int)ceil(min_w_bounds); part_min_n = (int)ceil(min_n_bounds); if (curr_w == get_max_width(sp_mat)) { part_max_w = curr_w; } else { // Largest integer LESS than max bounds: if (max_w_bounds == ceil(max_w_bounds)) { part_max_w = (int)max_w_bounds - 1; } else { part_max_w = (int)floor(max_w_bounds); } } if (curr_n == get_max_nsites(sp_mat)) { part_max_n = curr_n; } else { // Largest integer LESS than max bounds: if (max_n_bounds == ceil(max_n_bounds)) { part_max_n = (int)max_n_bounds - 1; } else { part_max_n = (int)floor(max_n_bounds); } } // Generate the current partition and add it to the growing array: PARTITION *curr_part = new_partition(part_min_w, part_max_w, curr_w, part_min_n, part_max_n, curr_n); (n_partitions)++; Resize(part_array, n_partitions, PARTITION *); part_array[(n_partitions) - 1] = curr_part; } // n_idx } // w_idx assert(sp_mat->partitions == NULL); sp_mat->partitions = part_array; sp_mat->n_parts = n_partitions; } // create_partitions
/** * sp_get_num_rows * * \return The number of different widths encompassed by this matrix. This * is equal to the number of rows in the matrix. * */ int sp_get_num_rows ( SP_MATRIX *sp_mat ) { return (get_max_width(sp_mat) - get_min_width(sp_mat) + 1); }