hmmer-3.3/src/fm_general.c
/* Function:  getSARangeForward()
 * Synopsis:  For a given query sequence, find its interval in the FM-index, using forward search
 * Purpose:   Implement Algorithm 4 (i371) of Simpson (Bioinformatics 2010). It's the forward
 *            search on a bi-directional BWT, as described by Lam 2009.
 *            All the meat is in the method of counting characters - bwt_getOccCount, which
 *            depends on compilation choices.
 *
 *            Note: it seems odd, but is correct, that the fm-index passed in to this function
 *            is the backward index corresponding to the forward index into which I want to
 *            do a forward search
 */
getSARangeForward()
Synopsis:  For a given query sequence, find its interval in the FM-index, using forward search
Purpose:   Implement Algorithm 4 (i371) of Simpson (Bioinformatics 2010). It's the forward
search on a bi-directional BWT, as described by Lam 2009.
All the meat is in the method of counting characters - bwt_getOccCount, which
depends on compilation choices.

it seems odd, but is correct, that the fm-index passed in to this function
is the backward index corresponding to the forward index into which I want to
do a forward search
getSARangeForward () Synopsis : For a given query sequence find its interval in the FM - index using forward search Purpose : Implement Algorithm 4 ( i371 ) of Simpson ( Bioinformatics 2010 ) . It ' s the forward search on a bi - directional BWT as described by Lam 2009 . All the meat is in the method of counting characters - bwt_getOccCount which depends on compilation choices . it seems odd but is correct that the fm - index passed in to this function is the backward index corresponding to the forward index into which I want to do a forward search
int
fm_getSARangeForward( const FM_DATA *fm, FM_CFG *cfg, char *query, char *inv_alph, FM_INTERVAL *interval)
{
  int i=0;
  FM_INTERVAL interval_bk;
  uint8_t c = inv_alph[(int)query[0]];
  interval->lower  = interval_bk.lower = abs((int)(fm->C[c]));
  interval->upper  = interval_bk.upper = abs((int)(fm->C[c+1]))-1;
  while (interval_bk.lower>=0 && interval_bk.lower <= interval_bk.upper) {
    c = query[++i];
    if (c == '\0')  
      break;
    c = inv_alph[c];
    fm_updateIntervalForward( fm, cfg, c, &interval_bk, interval);
    cfg->occCallCnt+=2;
  }
  return eslOK;
}
int fm_getSARangeForward ( const FM_DATA * fm , FM_CFG * cfg , char * query , char * inv_alph , FM_INTERVAL * interval ) { int i = 0 ; FM_INTERVAL interval_bk ; uint8_t c = inv_alph [ ( int ) query [ 0 ] ] ; interval -> lower = interval_bk . lower = abs ( ( int ) ( fm -> C [ c ] ) ) ; interval -> upper = interval_bk . upper = abs ( ( int ) ( fm -> C [ c + 1 ] ) ) - 1 ; while ( interval_bk . lower >= 0 && interval_bk . lower <= interval_bk . upper ) { c = query [ ++ i ] ; if ( c == ' \0 ' ) break ; c = inv_alph [ c ] ; fm_updateIntervalForward ( fm , cfg , c , & interval_bk , interval ) ; cfg -> occCallCnt += 2 ; } return eslOK ; }
Function:  getSARangeForward()
 Synopsis:  For a given query sequence, find its interval in the FM-index, using forward search
 Purpose:   Implement Algorithm 4 (i371) of Simpson (Bioinformatics 2010).
Function : getSARangeForward () Synopsis : For a given query sequence find its interval in the FM - index using forward search Purpose : Implement Algorithm 4 ( i371 ) of Simpson ( Bioinformatics 2010 ) .
// end of query - the current range defines the hits