hmmer-3.3/src/impl_vmx/fwdback.c
/* Function:  p7_Backward()
 * Synopsis:  The Backward algorithm; full matrix fill version.
 * Incept:    SRE, Sat Aug 16 08:34:22 2008 [Janelia]
 *
 * Purpose:   Calculates the Backward algorithm for sequence <dsq> of
 *            length <L> residues, using optimized profile <om>, and a
 *            preallocated DP matrix <bck>. A filled Forward matrix
 *            must also be provided in <fwd>, because we need to use
 *            the same sparse scaling factors that Forward used. The
 *            <bck> matrix is filled in, and the Backward score (in
 *            nats) is optionally returned in <opt_sc>.
 *            
 *            This calculation requires $O(ML)$ memory and time. The
 *            caller must provide a suitably allocated full <bck> by
 *            calling <bck = p7_omx_Create(M, L, L)> or
 *            <p7_omx_GrowTo(bck, M, L, L)>.
 *            
 *            Because only the sparse scaling factors are needed from
 *            the <fwd> matrix, the caller may have this matrix
 *            calculated either in full or parsing mode.
 *            
 *            The model <om> must be configured in local alignment
 *            mode. The sparse rescaling method used to keep
 *            probability values within single-precision floating
 *            point dynamic range cannot be safely applied to models in
 *            glocal or global mode.
 *
 * Args:      dsq     - digital target sequence, 1..L
 *            L       - length of dsq in residues          
 *            om      - optimized profile
 *            fwd     - filled Forward DP matrix, for scale factors
 *            do_full - TRUE=full matrix; FALSE=linear memory parse mode
 *            bck     - RETURN: filled Backward matrix
 *            opt_sc  - optRETURN: Backward score (in nats)          
 *
 * Returns:   <eslOK> on success. 
 *
 * Throws:    <eslEINVAL> if <ox> allocation is too small, or if the profile
 *            isn't in local alignment mode.
 *            <eslERANGE> if the score exceeds the limited range of
 *            a probability-space odds ratio.
 *            In either case, <*opt_sc> is undefined.
 */
p7_Backward()
Synopsis:  The Backward algorithm; full matrix fill version.

Calculates the Backward algorithm for sequence  of
length  residues, using optimized profile , and a
preallocated DP matrix . A filled Forward matrix
must also be provided in , because we need to use
the same sparse scaling factors that Forward used. The
 matrix is filled in, and the Backward score (in
nats) is optionally returned in .

This calculation requires $O(ML)$ memory and time. The
caller must provide a suitably allocated full  by
calling  or
.

Because only the sparse scaling factors are needed from
the  matrix, the caller may have this matrix
calculated either in full or parsing mode.

The model  must be configured in local alignment
mode. The sparse rescaling method used to keep
probability values within single-precision floating
point dynamic range cannot be safely applied to models in
glocal or global mode.



 on success.

 if  allocation is too small, or if the profile
isn't in local alignment mode.
 if the score exceeds the limited range of
a probability-space odds ratio.
In either case, <*opt_sc> is undefined.
p7_Backward () Synopsis : The Backward algorithm ; full matrix fill version . Calculates the Backward algorithm for sequence of length residues using optimized profile and a preallocated DP matrix . A filled Forward matrix must also be provided in because we need to use the same sparse scaling factors that Forward used . The matrix is filled in and the Backward score ( in nats ) is optionally returned in . This calculation requires $O ( ML ) $ memory and time . The caller must provide a suitably allocated full by calling or . Because only the sparse scaling factors are needed from the matrix the caller may have this matrix calculated either in full or parsing mode . The model must be configured in local alignment mode . The sparse rescaling method used to keep probability values within single - precision floating point dynamic range cannot be safely applied to models in glocal or global mode . on success . if allocation is too small or if the profile isn ' t in local alignment mode . if the score exceeds the limited range of a probability - space odds ratio . In either case < * opt_sc > is undefined .
int 
p7_Backward(const ESL_DSQ *dsq, int L, const P7_OPROFILE *om, const P7_OMX *fwd, P7_OMX *bck, float *opt_sc)
{
#if eslDEBUGLEVEL > 0		
  if (om->M >  bck->allocQ4*4)    ESL_EXCEPTION(eslEINVAL, "DP matrix allocated too small (too few columns)");
  if (L     >= bck->validR)       ESL_EXCEPTION(eslEINVAL, "DP matrix allocated too small (too few MDI rows)");
  if (L     >= bck->allocXR)      ESL_EXCEPTION(eslEINVAL, "DP matrix allocated too small (too few X rows)");
  if (L     != fwd->L)            ESL_EXCEPTION(eslEINVAL, "fwd matrix size doesn't agree with length L");
  if (! p7_oprofile_IsLocal(om))  ESL_EXCEPTION(eslEINVAL, "Forward implementation makes assumptions that only work for local alignment");
#endif
 return backward_engine(TRUE, dsq, L, om, fwd, bck, opt_sc);
}
int p7_Backward ( const ESL_DSQ * dsq , int L , const P7_OPROFILE * om , const P7_OMX * fwd , P7_OMX * bck , float * opt_sc ) { #if eslDEBUGLEVEL > 0 if ( om -> M > bck -> allocQ4 * 4 ) ESL_EXCEPTION ( eslEINVAL , " " ) ; if ( L >= bck -> validR ) ESL_EXCEPTION ( eslEINVAL , " " ) ; if ( L >= bck -> allocXR ) ESL_EXCEPTION ( eslEINVAL , " " ) ; if ( L != fwd -> L ) ESL_EXCEPTION ( eslEINVAL , " " ) ; if ( ! p7_oprofile_IsLocal ( om ) ) ESL_EXCEPTION ( eslEINVAL , " " ) ; #endif return backward_engine ( TRUE , dsq , L , om , fwd , bck , opt_sc ) ; }
Function:  p7_Backward()
 Synopsis:  The Backward algorithm; full matrix fill version.
Function : p7_Backward () Synopsis : The Backward algorithm ; full matrix fill version .