\hypertarget{group__consensus__fold}{
\section{Predicting Consensus Structures from Alignment(s)}
\label{group__consensus__fold}\index{Predicting Consensus Structures from Alignment(s)@{Predicting Consensus Structures from Alignment(s)}}
}


compute various properties (consensus MFE structures, partition function, Boltzmann distributed stochastic samples, ...) for RNA sequence alignments  


Collaboration diagram for Predicting Consensus Structures from Alignment(s):\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=420pt]{group__consensus__fold}
\end{center}
\end{figure}
\subsection*{Modules}
\begin{DoxyCompactItemize}
\item 
\hyperlink{group__consensus__mfe__fold}{MFE Consensus Structures for Sequence Alignment(s)}
\item 
\hyperlink{group__consensus__pf__fold}{Partition Function and Base Pair Probabilities for Sequence Alignment(s)}
\item 
\hyperlink{group__consensus__stochbt}{Stochastic Backtracking of Consensus Structures from Sequence Alignment(s)}
\item 
\hyperlink{group__local__consensus__fold}{Local MFE consensus structures for Sequence Alignments}
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{group__consensus__fold_gaa2d600be90844094ec145ea14a314d2f}{get\_\-mpi} (char $\ast$Alseq\mbox{[}$\,$\mbox{]}, int n\_\-seq, int length, int $\ast$mini)
\begin{DoxyCompactList}\small\item\em Get the mean pairwise identity in steps from ?to?(ident). \item\end{DoxyCompactList}\item 
\hypertarget{group__consensus__fold_ga5e125c9586fcd4e2e1559fe76f7289cc}{
float $\ast$$\ast$ \hyperlink{group__consensus__fold_ga5e125c9586fcd4e2e1559fe76f7289cc}{readribosum} (char $\ast$name)}
\label{group__consensus__fold_ga5e125c9586fcd4e2e1559fe76f7289cc}

\begin{DoxyCompactList}\small\item\em Read a ribosum or other user-\/defined scoring matrix. \item\end{DoxyCompactList}\item 
float \hyperlink{group__consensus__fold_ga1c48869c03b49a342bf4cbdd61900081}{energy\_\-of\_\-alistruct} (const char $\ast$$\ast$sequences, const char $\ast$structure, int n\_\-seq, float $\ast$energy)
\begin{DoxyCompactList}\small\item\em Calculate the free energy of a consensus structure given a set of aligned sequences. \item\end{DoxyCompactList}\item 
void \hyperlink{group__consensus__fold_gaa3e40277c837d6f7603afe319884c786}{encode\_\-ali\_\-sequence} (const char $\ast$sequence, short $\ast$S, short $\ast$s5, short $\ast$s3, char $\ast$ss, unsigned short $\ast$as, int \hyperlink{fold__vars_8h_af9202a1a09f5828dc731e2d9a10fa111}{circ})
\begin{DoxyCompactList}\small\item\em Get arrays with encoded sequence of the alignment. \item\end{DoxyCompactList}\item 
void \hyperlink{group__consensus__fold_ga8a560930f7f2582cc3967723a86cfdfa}{alloc\_\-sequence\_\-arrays} (const char $\ast$$\ast$sequences, short $\ast$$\ast$$\ast$S, short $\ast$$\ast$$\ast$S5, short $\ast$$\ast$$\ast$S3, unsigned short $\ast$$\ast$$\ast$a2s, char $\ast$$\ast$$\ast$Ss, int \hyperlink{fold__vars_8h_af9202a1a09f5828dc731e2d9a10fa111}{circ})
\begin{DoxyCompactList}\small\item\em Allocate memory for sequence array used to deal with aligned sequences. \item\end{DoxyCompactList}\item 
void \hyperlink{group__consensus__fold_ga298a420a8c879202e2617b3f724fde38}{free\_\-sequence\_\-arrays} (unsigned int n\_\-seq, short $\ast$$\ast$$\ast$S, short $\ast$$\ast$$\ast$S5, short $\ast$$\ast$$\ast$S3, unsigned short $\ast$$\ast$$\ast$a2s, char $\ast$$\ast$$\ast$Ss)
\begin{DoxyCompactList}\small\item\em Free the memory of the sequence arrays used to deal with aligned sequences. \item\end{DoxyCompactList}\item 
int \hyperlink{group__consensus__fold_ga5349960075b1847720a2e9df021e2675}{get\_\-alipf\_\-arrays} (short $\ast$$\ast$$\ast$S\_\-p, short $\ast$$\ast$$\ast$S5\_\-p, short $\ast$$\ast$$\ast$S3\_\-p, unsigned short $\ast$$\ast$$\ast$a2s\_\-p, char $\ast$$\ast$$\ast$Ss\_\-p, FLT\_\-OR\_\-DBL $\ast$$\ast$qb\_\-p, FLT\_\-OR\_\-DBL $\ast$$\ast$qm\_\-p, FLT\_\-OR\_\-DBL $\ast$$\ast$q1k\_\-p, FLT\_\-OR\_\-DBL $\ast$$\ast$qln\_\-p, short $\ast$$\ast$pscore)
\begin{DoxyCompactList}\small\item\em Get pointers to (almost) all relavant arrays used in alifold's partition function computation. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
double \hyperlink{group__consensus__fold_gaf3cbac6ff5d706d6e414677841ddf94c}{cv\_\-fact}
\begin{DoxyCompactList}\small\item\em This variable controls the weight of the covariance term in the energy function of alignment folding algorithms. \item\end{DoxyCompactList}\item 
double \hyperlink{group__consensus__fold_ga502948a122a2af5b914355b1f3ea2f61}{nc\_\-fact}
\begin{DoxyCompactList}\small\item\em This variable controls the magnitude of the penalty for non-\/compatible sequences in the covariance term of alignment folding algorithms. \item\end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
compute various properties (consensus MFE structures, partition function, Boltzmann distributed stochastic samples, ...) for RNA sequence alignments Consensus structures can be predicted by a modified version of the \hyperlink{group__mfe__fold_gaadafcb0f140795ae62e5ca027e335a9b}{fold()} algorithm that takes a set of aligned sequences instead of a single sequence. The energy function consists of the mean energy averaged over the sequences, plus a covariance term that favors pairs with consistent and compensatory mutations and penalizes pairs that cannot be formed by all structures. For details see  hofacker:2002 and  bernhart:2008. 

\subsection{Function Documentation}
\hypertarget{group__consensus__fold_gaa2d600be90844094ec145ea14a314d2f}{
\index{consensus\_\-fold@{consensus\_\-fold}!get\_\-mpi@{get\_\-mpi}}
\index{get\_\-mpi@{get\_\-mpi}!consensus_fold@{consensus\_\-fold}}
\subsubsection[{get\_\-mpi}]{\setlength{\rightskip}{0pt plus 5cm}int get\_\-mpi (char $\ast$ {\em Alseq}\mbox{[}$\,$\mbox{]}, \/  int {\em n\_\-seq}, \/  int {\em length}, \/  int $\ast$ {\em mini})}}
\label{group__consensus__fold_gaa2d600be90844094ec145ea14a314d2f}


Get the mean pairwise identity in steps from ?to?(ident). 
\begin{DoxyParams}{Parameters}
\item[{\em Alseq}]\item[{\em n\_\-seq}]The number of sequences in the alignment \item[{\em length}]The length of the alignment \item[{\em mini}]\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The mean pairwise identity 
\end{DoxyReturn}
\hypertarget{group__consensus__fold_ga1c48869c03b49a342bf4cbdd61900081}{
\index{consensus\_\-fold@{consensus\_\-fold}!energy\_\-of\_\-alistruct@{energy\_\-of\_\-alistruct}}
\index{energy\_\-of\_\-alistruct@{energy\_\-of\_\-alistruct}!consensus_fold@{consensus\_\-fold}}
\subsubsection[{energy\_\-of\_\-alistruct}]{\setlength{\rightskip}{0pt plus 5cm}float energy\_\-of\_\-alistruct (const char $\ast$$\ast$ {\em sequences}, \/  const char $\ast$ {\em structure}, \/  int {\em n\_\-seq}, \/  float $\ast$ {\em energy})}}
\label{group__consensus__fold_ga1c48869c03b49a342bf4cbdd61900081}


Calculate the free energy of a consensus structure given a set of aligned sequences. 
\begin{DoxyParams}{Parameters}
\item[{\em sequences}]The NULL terminated array of sequences \item[{\em structure}]The consensus structure \item[{\em n\_\-seq}]The number of sequences in the alignment \item[{\em energy}]A pointer to an array of at least two floats that will hold the free energies (energy\mbox{[}0\mbox{]} will contain the free energy, energy\mbox{[}1\mbox{]} will be filled with the covariance energy term) \end{DoxyParams}
\begin{DoxyReturn}{Returns}
free energy in kcal/mol 
\end{DoxyReturn}
\hypertarget{group__consensus__fold_gaa3e40277c837d6f7603afe319884c786}{
\index{consensus\_\-fold@{consensus\_\-fold}!encode\_\-ali\_\-sequence@{encode\_\-ali\_\-sequence}}
\index{encode\_\-ali\_\-sequence@{encode\_\-ali\_\-sequence}!consensus_fold@{consensus\_\-fold}}
\subsubsection[{encode\_\-ali\_\-sequence}]{\setlength{\rightskip}{0pt plus 5cm}void encode\_\-ali\_\-sequence (const char $\ast$ {\em sequence}, \/  short $\ast$ {\em S}, \/  short $\ast$ {\em s5}, \/  short $\ast$ {\em s3}, \/  char $\ast$ {\em ss}, \/  unsigned short $\ast$ {\em as}, \/  int {\em circ})}}
\label{group__consensus__fold_gaa3e40277c837d6f7603afe319884c786}


Get arrays with encoded sequence of the alignment. this function assumes that in S, S5, s3, ss and as enough space is already allocated (size must be at least sequence length+2)


\begin{DoxyParams}{Parameters}
\item[{\em sequence}]The gapped sequence from the alignment \item[{\em S}]pointer to an array that holds encoded sequence \item[{\em s5}]pointer to an array that holds the next base 5' of alignment position i \item[{\em s3}]pointer to an array that holds the next base 3' of alignment position i \item[{\em ss}]\item[{\em as}]\item[{\em circ}]assume the molecules to be circular instead of linear (circ=0) \end{DoxyParams}
\hypertarget{group__consensus__fold_ga8a560930f7f2582cc3967723a86cfdfa}{
\index{consensus\_\-fold@{consensus\_\-fold}!alloc\_\-sequence\_\-arrays@{alloc\_\-sequence\_\-arrays}}
\index{alloc\_\-sequence\_\-arrays@{alloc\_\-sequence\_\-arrays}!consensus_fold@{consensus\_\-fold}}
\subsubsection[{alloc\_\-sequence\_\-arrays}]{\setlength{\rightskip}{0pt plus 5cm}void alloc\_\-sequence\_\-arrays (const char $\ast$$\ast$ {\em sequences}, \/  short $\ast$$\ast$$\ast$ {\em S}, \/  short $\ast$$\ast$$\ast$ {\em S5}, \/  short $\ast$$\ast$$\ast$ {\em S3}, \/  unsigned short $\ast$$\ast$$\ast$ {\em a2s}, \/  char $\ast$$\ast$$\ast$ {\em Ss}, \/  int {\em circ})}}
\label{group__consensus__fold_ga8a560930f7f2582cc3967723a86cfdfa}


Allocate memory for sequence array used to deal with aligned sequences. Note that these arrays will also be initialized according to the sequence alignment given

\begin{DoxySeeAlso}{See also}
\hyperlink{group__consensus__fold_ga298a420a8c879202e2617b3f724fde38}{free\_\-sequence\_\-arrays()}
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
\item[{\em sequences}]The aligned sequences \item[{\em S}]A pointer to the array of encoded sequences \item[{\em S5}]A pointer to the array that contains the next 5' nucleotide of a sequence position \item[{\em S3}]A pointer to the array that contains the next 3' nucleotide of a sequence position \item[{\em a2s}]A pointer to the array that contains the alignment to sequence position mapping \item[{\em Ss}]A pointer to the array that contains the ungapped sequence \item[{\em circ}]assume the molecules to be circular instead of linear (circ=0) \end{DoxyParams}
\hypertarget{group__consensus__fold_ga298a420a8c879202e2617b3f724fde38}{
\index{consensus\_\-fold@{consensus\_\-fold}!free\_\-sequence\_\-arrays@{free\_\-sequence\_\-arrays}}
\index{free\_\-sequence\_\-arrays@{free\_\-sequence\_\-arrays}!consensus_fold@{consensus\_\-fold}}
\subsubsection[{free\_\-sequence\_\-arrays}]{\setlength{\rightskip}{0pt plus 5cm}void free\_\-sequence\_\-arrays (unsigned int {\em n\_\-seq}, \/  short $\ast$$\ast$$\ast$ {\em S}, \/  short $\ast$$\ast$$\ast$ {\em S5}, \/  short $\ast$$\ast$$\ast$ {\em S3}, \/  unsigned short $\ast$$\ast$$\ast$ {\em a2s}, \/  char $\ast$$\ast$$\ast$ {\em Ss})}}
\label{group__consensus__fold_ga298a420a8c879202e2617b3f724fde38}


Free the memory of the sequence arrays used to deal with aligned sequences. This function frees the memory previously allocated with \hyperlink{group__consensus__fold_ga8a560930f7f2582cc3967723a86cfdfa}{alloc\_\-sequence\_\-arrays()}

\begin{DoxySeeAlso}{See also}
\hyperlink{group__consensus__fold_ga8a560930f7f2582cc3967723a86cfdfa}{alloc\_\-sequence\_\-arrays()}
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
\item[{\em n\_\-seq}]The number of aligned sequences \item[{\em S}]A pointer to the array of encoded sequences \item[{\em S5}]A pointer to the array that contains the next 5' nucleotide of a sequence position \item[{\em S3}]A pointer to the array that contains the next 3' nucleotide of a sequence position \item[{\em a2s}]A pointer to the array that contains the alignment to sequence position mapping \item[{\em Ss}]A pointer to the array that contains the ungapped sequence \end{DoxyParams}
\hypertarget{group__consensus__fold_ga5349960075b1847720a2e9df021e2675}{
\index{consensus\_\-fold@{consensus\_\-fold}!get\_\-alipf\_\-arrays@{get\_\-alipf\_\-arrays}}
\index{get\_\-alipf\_\-arrays@{get\_\-alipf\_\-arrays}!consensus_fold@{consensus\_\-fold}}
\subsubsection[{get\_\-alipf\_\-arrays}]{\setlength{\rightskip}{0pt plus 5cm}int get\_\-alipf\_\-arrays (short $\ast$$\ast$$\ast$ {\em S\_\-p}, \/  short $\ast$$\ast$$\ast$ {\em S5\_\-p}, \/  short $\ast$$\ast$$\ast$ {\em S3\_\-p}, \/  unsigned short $\ast$$\ast$$\ast$ {\em a2s\_\-p}, \/  char $\ast$$\ast$$\ast$ {\em Ss\_\-p}, \/  FLT\_\-OR\_\-DBL $\ast$$\ast$ {\em qb\_\-p}, \/  FLT\_\-OR\_\-DBL $\ast$$\ast$ {\em qm\_\-p}, \/  FLT\_\-OR\_\-DBL $\ast$$\ast$ {\em q1k\_\-p}, \/  FLT\_\-OR\_\-DBL $\ast$$\ast$ {\em qln\_\-p}, \/  short $\ast$$\ast$ {\em pscore})}}
\label{group__consensus__fold_ga5349960075b1847720a2e9df021e2675}


Get pointers to (almost) all relavant arrays used in alifold's partition function computation. \begin{DoxyNote}{Note}
To obtain meaningful pointers, call alipf\_\-fold first!
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
pf\_\-alifold(), \hyperlink{group__consensus__pf__fold_ga6b4dde1d43b79ab3753508c46cf50363}{alipf\_\-circ\_\-fold()}
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
\item[{\em S\_\-p}]A pointer to the 'S' array (integer representation of nucleotides) \item[{\em S5\_\-p}]A pointer to the 'S5' array \item[{\em S3\_\-p}]A pointer to the 'S3' array \item[{\em a2s\_\-p}]A pointer to the pair type matrix \item[{\em Ss\_\-p}]A pointer to the 'Ss' array \item[{\em qb\_\-p}]A pointer to the Q$^{\mbox{B}}$  matrix \item[{\em qm\_\-p}]A pointer to the Q$^{\mbox{M}}$  matrix \item[{\em q1k\_\-p}]A pointer to the 5' slice of the Q matrix ($q1k(k) = Q(1, k)$) \item[{\em qln\_\-p}]A pointer to the 3' slice of the Q matrix ($qln(l) = Q(l, n)$) \end{DoxyParams}
\begin{DoxyReturn}{Returns}
Non Zero if everything went fine, 0 otherwise 
\end{DoxyReturn}


\subsection{Variable Documentation}
\hypertarget{group__consensus__fold_gaf3cbac6ff5d706d6e414677841ddf94c}{
\index{consensus\_\-fold@{consensus\_\-fold}!cv\_\-fact@{cv\_\-fact}}
\index{cv\_\-fact@{cv\_\-fact}!consensus_fold@{consensus\_\-fold}}
\subsubsection[{cv\_\-fact}]{\setlength{\rightskip}{0pt plus 5cm}double {\bf cv\_\-fact}}}
\label{group__consensus__fold_gaf3cbac6ff5d706d6e414677841ddf94c}


This variable controls the weight of the covariance term in the energy function of alignment folding algorithms. Default is 1. \hypertarget{group__consensus__fold_ga502948a122a2af5b914355b1f3ea2f61}{
\index{consensus\_\-fold@{consensus\_\-fold}!nc\_\-fact@{nc\_\-fact}}
\index{nc\_\-fact@{nc\_\-fact}!consensus_fold@{consensus\_\-fold}}
\subsubsection[{nc\_\-fact}]{\setlength{\rightskip}{0pt plus 5cm}double {\bf nc\_\-fact}}}
\label{group__consensus__fold_ga502948a122a2af5b914355b1f3ea2f61}


This variable controls the magnitude of the penalty for non-\/compatible sequences in the covariance term of alignment folding algorithms. Default is 1. 