deps/kb_meme/meme-5.0.1/src/substmatrix-table.c
/*************************************************************************
  This function populates a trans_matix_array with pointers to matrices 
  and the corresponding time values indexed by the edge number of the 
  phylogenetic tree.  The edges are numbered in depth-first order.

  The three parameters are an evolutinary model, a phylogentic
  tree, and a pointer to substmatrix_array structure.

  The function returns an integer containing the number of matrices
  added to the substmatrix_array structure.
 *************************************************************************/
This function populates a trans_matix_array with pointers to matrices
and the corresponding time values indexed by the edge number of the
phylogenetic tree.  The edges are numbered in depth-first order.

The three parameters are an evolutinary model, a phylogentic
tree, and a pointer to substmatrix_array structure.

The function returns an integer containing the number of matrices
added to the substmatrix_array structure.
This function populates a trans_matix_array with pointers to matrices and the corresponding time values indexed by the edge number of the phylogenetic tree . The edges are numbered in depth - first order . The three parameters are an evolutinary model a phylogentic tree and a pointer to substmatrix_array structure . The function returns an integer containing the number of matrices added to the substmatrix_array structure .
static int populate_substmatrix_array(
  ALPH_T* alph, 
  EVOMODEL_T* model, 
  TREE_T* tree, 
  int current_position, 
  SUBSTMATRIX_ARRAY_T* array 
) {
  int num_children = get_num_children(tree);
  if (is_leaf(tree) != true) {
    int c = 0;
    for (c = 0; c < num_children; c++) {
      TREE_T* child = get_nth_child(c, tree);
      double t = get_length(child);
      set_substmatrix_time(array, current_position, t);
      MATRIX_T* prob_matrix = get_model_prob_matrix(alph, t, model);
      set_substmatrix_matrix(array, current_position, prob_matrix);
      free_matrix(prob_matrix);
      current_position = populate_substmatrix_array(
        alph,
        model, 
        child, 
        current_position + 1,
        array
      );
    }
  }
  return current_position;
}
static int populate_substmatrix_array ( ALPH_T * alph , EVOMODEL_T * model , TREE_T * tree , int current_position , SUBSTMATRIX_ARRAY_T * array ) { int num_children = get_num_children ( tree ) ; if ( is_leaf ( tree ) != true ) { int c = 0 ; for ( c = 0 ; c < num_children ; c ++ ) { TREE_T * child = get_nth_child ( c , tree ) ; double t = get_length ( child ) ; set_substmatrix_time ( array , current_position , t ) ; MATRIX_T * prob_matrix = get_model_prob_matrix ( alph , t , model ) ; set_substmatrix_matrix ( array , current_position , prob_matrix ) ; free_matrix ( prob_matrix ) ; current_position = populate_substmatrix_array ( alph , model , child , current_position + 1 , array ) ; } } return current_position ; }
This function populates a trans_matix_array with pointers to matrices
and the corresponding time values indexed by the edge number of the
phylogenetic tree.
This function populates a trans_matix_array with pointers to matrices and the corresponding time values indexed by the edge number of the phylogenetic tree .
// IN // IN // IN // IN // OUT // Recursively descend the tree, depth first