deps/kb_meme/meme-5.0.1/src/build-hmm.c
/*************************************************************************
 * Find the index of the starting or ending state of a given motif in
 * a given HMM.
 * 0 = START_STATE and nmotifs+1 = END_STATE
 *************************************************************************/
Find the index of the starting or ending state of a given motif in
a given HMM.
0 = START_STATE and nmotifs+1 = END_STATE
Find the index of the starting or ending state of a given motif in a given HMM . 0 = START_STATE and nmotifs + 1 = END_STATE
static int motif_index
  (const int       motif_num,
   const bool start_or_end,
   const int       num_spacers,
   const int       spacer_states,
   const MOTIF_T*  motifs,
   const int       nmotifs)
{
  int i_motif;
  int return_value;
  assert(motif_num >= 0);
  assert((motif_num - 1) <= nmotifs);
  if (motif_num == 0) return START_INDEX;
  return_value = (num_spacers * spacer_states) + 1;
  for (i_motif = 0; i_motif < motif_num - 1; i_motif++)
    return_value += get_motif_length(motif_at((MOTIF_T*)motifs, i_motif));
  if (start_or_end && motif_num != (nmotifs + 1))
    return_value += get_motif_length(motif_at((MOTIF_T*)motifs, i_motif)) - 1;
  return(return_value);
}
static int motif_index ( const int motif_num , const bool start_or_end , const int num_spacers , const int spacer_states , const MOTIF_T * motifs , const int nmotifs ) { int i_motif ; int return_value ; assert ( motif_num >= 0 ) ; assert ( ( motif_num - 1 ) <= nmotifs ) ; if ( motif_num == 0 ) return START_INDEX ; return_value = ( num_spacers * spacer_states ) + 1 ; for ( i_motif = 0 ; i_motif < motif_num - 1 ; i_motif ++ ) return_value += get_motif_length ( motif_at ( ( MOTIF_T * ) motifs , i_motif ) ) ; if ( start_or_end && motif_num != ( nmotifs + 1 ) ) return_value += get_motif_length ( motif_at ( ( MOTIF_T * ) motifs , i_motif ) ) - 1 ; return ( return_value ) ; }
Find the index of the starting or ending state of a given motif in
 a given HMM.
Find the index of the starting or ending state of a given motif in a given HMM .
// Skip the spacer states. // Add the lengths of the preceding motifs. // If we're looking for the end of this motif, add its length as well.  // unless it is the end state we're after which has only one state // fprintf(stderr, "Motif %d -> %d\n", motif_num, return_value);