deps/kb_meme/meme-5.0.1/src/beadstring.c
/*************************************************************************
 *  Build a linear HMM model for the motifs
 *************************************************************************/
Build a linear HMM model for the motifs
Build a linear HMM model for the motifs
MHMM_T* build_linear_model(OPTIONS_T *options) {
  int num_motifs = 0;              
  RBTREE_T  *motifs; 
  bool has_reverse_strand = false; 
  ARRAY_T* background = NULL;      
  ORDER_T* order_spacing = NULL;   
  MATRIX_T* transp_freq = NULL;    
  MATRIX_T* spacer_ave = NULL;     
  MHMM_T* the_hmm = NULL;          
  if (options->spacer_states <= 0) {
    die("Negative spacer length (%d).\n", options->spacer_states);
  }
  load_filter_process_motifs_for_hmm(
      0, 
      options->request_nums,
      options->request_ids,
      options->motif_e_threshold,
      0.0, 
      options->order_string,
      options->motif_p_threshold, 
      options->meme_filename,
      options->bg_filename,
      options->motif_pseudo,
      options->trans_pseudo,
      options->spacer_pseudo,
      false, 
      &(options->alphabet),
      &motifs,
      &background,
      &order_spacing,
      &transp_freq,
      &spacer_ave
      );
  if (order_spacing == NULL) {
    die("No order specified for the motifs.\n"
        "For the linear model the motif file must contain motif occurence\n"
        "data or the motif order must be specified using the --order option.");
  }
  build_linear_hmm(
    background,
    order_spacing,
    options->spacer_states,
    motifs,
    options->fim,
    &the_hmm
  );
  fix_trans_in(the_hmm);
  free_array(background);
  free_order(order_spacing);
  free_matrix(transp_freq);
  free_matrix(spacer_ave);
  rbtree_destroy(motifs);
  copy_string(&(the_hmm->motif_file), options->meme_filename);
  return the_hmm;
}
MHMM_T * build_linear_model ( OPTIONS_T * options ) { int num_motifs = 0 ; RBTREE_T * motifs ; bool has_reverse_strand = false ; ARRAY_T * background = NULL ; ORDER_T * order_spacing = NULL ; MATRIX_T * transp_freq = NULL ; MATRIX_T * spacer_ave = NULL ; MHMM_T * the_hmm = NULL ; if ( options -> spacer_states <= 0 ) { die ( " \n " , options -> spacer_states ) ; } load_filter_process_motifs_for_hmm ( 0 , options -> request_nums , options -> request_ids , options -> motif_e_threshold , 0.0 , options -> order_string , options -> motif_p_threshold , options -> meme_filename , options -> bg_filename , options -> motif_pseudo , options -> trans_pseudo , options -> spacer_pseudo , false , & ( options -> alphabet ) , & motifs , & background , & order_spacing , & transp_freq , & spacer_ave ) ; if ( order_spacing == NULL ) { die ( " \n " " \n " " " ) ; } build_linear_hmm ( background , order_spacing , options -> spacer_states , motifs , options -> fim , & the_hmm ) ; fix_trans_in ( the_hmm ) ; free_array ( background ) ; free_order ( order_spacing ) ; free_matrix ( transp_freq ) ; free_matrix ( spacer_ave ) ; rbtree_destroy ( motifs ) ; copy_string ( & ( the_hmm -> motif_file ) , options -> meme_filename ) ; return the_hmm ; }
Build a linear HMM model for the motifs
Build a linear HMM model for the motifs
// The number of motifs in the model. // The motifs. // MEME file contained both strands // Background probs for alphabet. // Linear HMM order and spacing. // Matrix of inter-motif transitions freqs. // Matrix of average spacer lengths. // The HMM being constructed. // Gotta have positive number of spacer states. /**********************************************
   * READING THE MOTIFS
   **********************************************/ // no top n motifs // no complexity threshold // for filtering occurrence list // keep unused motifs /**********************************************
   * BUILDING THE HMM
   **********************************************/ // Add some global information.