hmmer-3.3/src/fm_general.c
/* Function:  getSARangeReverse()
 * Synopsis:  For a given query sequence, find its interval in the FM-index, using backward search
 * Purpose:   Implement Algorithm 3.6 (p17) of Firth paper (A Comparison of BWT Approaches
 *            to String Pattern Matching). This is what Simpson and Lam call "Reverse Search".
 *            All the meat is in the method of counting characters - bwt_getOccCount, which
 *            depends on compilation choices.
 */
getSARangeReverse()
Synopsis:  For a given query sequence, find its interval in the FM-index, using backward search
Purpose:   Implement Algorithm 3.6 (p17) of Firth paper (A Comparison of BWT Approaches
to String Pattern Matching). This is what Simpson and Lam call "Reverse Search".
All the meat is in the method of counting characters - bwt_getOccCount, which
depends on compilation choices.
getSARangeReverse () Synopsis : For a given query sequence find its interval in the FM - index using backward search Purpose : Implement Algorithm 3 . 6 ( p17 ) of Firth paper ( A Comparison of BWT Approaches to String Pattern Matching ) . This is what Simpson and Lam call " Reverse Search " . All the meat is in the method of counting characters - bwt_getOccCount which depends on compilation choices .
int
fm_getSARangeReverse( const FM_DATA *fm, FM_CFG *cfg, char *query, char *inv_alph, FM_INTERVAL *interval)
{
  int i=0;
  char c = inv_alph[(int)query[0]];
  interval->lower  = abs((int)(fm->C[(int)c]));
  interval->upper  = abs((int)(fm->C[(int)c+1]))-1;
  while (interval->lower>=0 && interval->lower <= interval->upper) {
    c = query[++i];
    if (c == '\0')  
      break;
    c = inv_alph[(int)c];
    fm_updateIntervalReverse(fm, cfg, c, interval);
    cfg->occCallCnt+=2;
  }
  return eslOK;
}
int fm_getSARangeReverse ( const FM_DATA * fm , FM_CFG * cfg , char * query , char * inv_alph , FM_INTERVAL * interval ) { int i = 0 ; char c = inv_alph [ ( int ) query [ 0 ] ] ; interval -> lower = abs ( ( int ) ( fm -> C [ ( int ) c ] ) ) ; interval -> upper = abs ( ( int ) ( fm -> C [ ( int ) c + 1 ] ) ) - 1 ; while ( interval -> lower >= 0 && interval -> lower <= interval -> upper ) { c = query [ ++ i ] ; if ( c == ' \0 ' ) break ; c = inv_alph [ ( int ) c ] ; fm_updateIntervalReverse ( fm , cfg , c , interval ) ; cfg -> occCallCnt += 2 ; } return eslOK ; }
Function:  getSARangeReverse()
 Synopsis:  For a given query sequence, find its interval in the FM-index, using backward search
 Purpose:   Implement Algorithm 3.6 (p17) of Firth paper (A Comparison of BWT Approaches
            to String Pattern Matching).
Function : getSARangeReverse () Synopsis : For a given query sequence find its interval in the FM - index using backward search Purpose : Implement Algorithm 3 . 6 ( p17 ) of Firth paper ( A Comparison of BWT Approaches to String Pattern Matching ) .
// end of query - the current range defines the hits