/* Function: p7_Forward() * Synopsis: The Forward algorithm, full matrix fill version. * Incept: SRE, Fri Aug 15 18:59:43 2008 [Casa de Gatos] * * Purpose: Calculates the Forward algorithm for sequence <dsq> of * length <L> residues, using optimized profile <om>, and a * preallocated DP matrix <ox>. Upon successful return, <ox> * contains the filled Forward matrix, and <*opt_sc> * optionally contains the raw Forward score in nats. * * This calculation requires $O(ML)$ memory and time. * The caller must provide a suitably allocated full <ox> * by calling <ox = p7_omx_Create(M, L, L)> or * <p7_omx_GrowTo(ox, M, L, L)>. * * 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 * ox - RETURN: Forward DP matrix * opt_sc - RETURN: Forward 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. */ int p7_Forward(const ESL_DSQ *dsq, int L, const P7_OPROFILE *om, P7_OMX *ox, float *opt_sc) { #ifdef p7_DEBUGGING if (om->M > ox->allocQ4*4) ESL_EXCEPTION(eslEINVAL, "DP matrix allocated too small (too few columns)"); if (L >= ox->validR) ESL_EXCEPTION(eslEINVAL, "DP matrix allocated too small (too few MDI rows)"); if (L >= ox->allocXR) ESL_EXCEPTION(eslEINVAL, "DP matrix allocated too small (too few X rows)"); if (! p7_oprofile_IsLocal(om)) ESL_EXCEPTION(eslEINVAL, "Forward implementation makes assumptions that only work for local alignment"); #endif return forward_engine(TRUE, dsq, L, om, ox, opt_sc); }
/* Function: p7_BackwardParser() * Synopsis: The Backward algorithm, linear memory parsing version. * Incept: SRE, Sat Aug 16 08:34:13 2008 [Janelia] * * Purpose: Same as <p7_Backward()> except that the full matrix isn't * kept. Instead, a linear $O(M+L)$ memory algorithm is * used, keeping only the DP matrix values for the special * (BENCJ) states. These are sufficient to do posterior * decoding to identify high-probability regions where * domains are. * * The caller must provide a suitably allocated "parsing" * <bck> by calling <bck = p7_omx_Create(M, 0, L)> or * <p7_omx_GrowTo(bck, M, 0, L)>. * * Args: dsq - digital target sequence, 1..L * L - length of dsq in residues * om - optimized profile * fwd - filled Forward DP matrix, for scale factors * 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. */ int p7_BackwardParser(const ESL_DSQ *dsq, int L, const P7_OPROFILE *om, const P7_OMX *fwd, P7_OMX *bck, float *opt_sc) { #ifdef p7_DEBUGGING if (om->M > bck->allocQ4*4) ESL_EXCEPTION(eslEINVAL, "DP matrix allocated too small (too few columns)"); if (bck->validR < 1) 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(FALSE, dsq, L, om, fwd, bck, opt_sc); }