1
2\begin{DoxyItemize}
3\item \mbox{\hyperlink{install}{Installation and Configuration}} describes how to install and configure {\ttfamily RNAlib} for your requirements
4\item \mbox{\hyperlink{helloworld}{Hello\+World}} presents some small example programs to get a first impression on how to use this library
5\item \mbox{\hyperlink{helloworld_swig}{Hello\+World (Perl/\+Python)}} contains small examples that show how to use RNAlib even without C/\+C++ programming skills from within your favorite scripting language
6\end{DoxyItemize}\hypertarget{install}{}\doxysection{Installation and Configuration}\label{install}
7A documentation on how to configure the different features of {\ttfamily RNAlib}, how to install the Vienna\+RNA Package, and finally, how to link you own programs against {\ttfamily RNAlib}.\hypertarget{install_installation}{}\doxysubsection{Installing the Vienna\+RNA Package}\label{install_installation}
8For best portability the Vienna\+RNA package uses the GNU autoconf and automake tools. The instructions below are for installing the Vienna\+RNA package from source. However, pre-\/compiled binaries for various Linux distributions, as well as for Windows users are available from Download section of the \href{https://www.tbi.univie.ac.at/RNA}{\texttt{ main Vienna\+RNA homepage}}.\hypertarget{install_quickstart}{}\doxysubsubsection{Quick-\/start}\label{install_quickstart}
9Usually you\textquotesingle{}ll just unpack, configure and make. To do this type\+:
10
11\begin{DoxyVerb}tar -zxvf ViennaRNA-2.4.18.tar.gz
12cd ViennaRNA-2.4.18
13./configure
14make
15sudo make install
16\end{DoxyVerb}
17\hypertarget{install_userdir_install}{}\doxysubsubsection{Installation without root privileges}\label{install_userdir_install}
18If you do not have root privileges on your computer, you might want to install the Vienna\+RNA Package to a location where you actually have write access to. To do so, you can set the installation prefix of the ./configure script like so\+:
19
20\begin{DoxyVerb}./configure --prefix=/home/username/ViennaRNA
21make install
22\end{DoxyVerb}
23
24
25This will install the entire Vienna\+RNA Package into a new directory Vienna\+RNA directly into the users username home directory.\hypertarget{install_macosx_notes}{}\doxysubsubsection{Notes for Mac\+OS X users}\label{install_macosx_notes}
26\hypertarget{install_macosx_notes_compiler}{}\doxyparagraph{Compilation}\label{install_macosx_notes_compiler}
27Although users will find /usr/bin/gcc and /usr/bin/g++ executables in their directory tree, these programs are not at all what they pretend to be. Instead of including the GNU programs, Apple decided to install clang/llvm in disguise. Unfortunately, the default version of clang/llvm does not support Open\+MP (yet), but only complains at a late stage of the build process when this support is required. Therefore, it seems necessary to deactivate Open\+MP support by passing the option --disable-\/openmp to the ./configure script.\hypertarget{install_macosx_notes_perl}{}\doxyparagraph{Missing EXTERN.\+h include file}\label{install_macosx_notes_perl}
28Furthermore, as far as we are informed, users are discouraged to use the Perl 5 interpreter that is shipped with Mac OS X. Instead, one should install a more recent version from another source, e.\+g. {\ttfamily homebrew}. If, however, for any reason you do not want to install your own Perl 5 interpreter but use the one from Apple, you need to specify its include path to enable building the Vienna\+RNA Perl interface. Otherwise, the file {\ttfamily EXTERN.\+h} will be missing at compile time. To fix this problem, you first need to find out where {\ttfamily EXTERN.\+h} is located\+:
29
30\begin{DoxyVerb}sudo find /Library -type f -name EXTERN.h
31\end{DoxyVerb}
32
33
34Then choose the one that corresponds to your default perl interpreter (find out the version number with {\ttfamily perl -\/v $\vert$ grep version}), simply execute the following before running the {\ttfamily ./configure} script, e.\+g.\+:
35
36\begin{DoxyVerb}export CPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE
37\end{DoxyVerb}
38
39
40if your default perl is v5.\+18 running on Mac\+OSX10.\+15. Change the paths according to your current setup. After that, running {\ttfamily ./configure} and compilation should run fine.
41
42See also \href{https://stackoverflow.com/questions/52682304/fatal-error-extern-h-file-not-found-while-installing-perl-modules/52997962}{\texttt{ https\+://stackoverflow.\+com/questions/52682304/fatal-\/error-\/extern-\/h-\/file-\/not-\/found-\/while-\/installing-\/perl-\/modules/52997962}}\hypertarget{install_macosx_notes_universal}{}\doxyparagraph{Universal binaries}\label{install_macosx_notes_universal}
43Additionally, if you intend to build the Vienna\+RNA such that it runs on both, x86\+\_\+64 and the armv8 (such as for the M1 processors in recent Mac\+Books), architectures, you need to build a so-\/called universal binary. Note, however, that to accomplish this task, you might need to deactivate any third-\/party library dependency as in most cases, only one architecture will be available at link time. This includes the Perl 5 and Python interfaces but also MPFR and GSL support, possibly even more. In order to compile and link the programs, library, and scripting language interfaces of the Vienna\+RNA Package for multiple architectures, we\textquotesingle{}ve added a new configure switch that sets up the required changes automatically\+:
44
45\begin{DoxyVerb}./configure --enable-universal-binary
46\end{DoxyVerb}
47
48
49\begin{DoxyNote}{Note}
50Note, that with link time optimization turned on, Mac\+OS X\textquotesingle{}s default compiler (llvm/clang) generates an intermediary binary format that can not easily be combined into a multi-\/architecture library. Therefore, the --enable-\/universal-\/binary switch turns off link time optimization!
51\end{DoxyNote}
52\hypertarget{install_configuration}{}\doxysubsection{Configuring RNAlib features}\label{install_configuration}
53The Vienna\+RNA Package includes additional executable programs such as RNAforester, Kinfold, and Kinwalker. Furthermore, we include several features in our C-\/library that may be activated by default, or have to be explicitly turned on at configure-\/time. Below we list a selection of the available configure options that affect the features included in all executable programs, the RNAlib C-\/library, and the corresponding scripting language interface(s).\hypertarget{install_config_simd}{}\doxysubsubsection{Streaming SIMD Extension (\+SSE) support}\label{install_config_simd}
54Since version 2.\+3.\+5 our sources contain code that implements a faster multibranch loop decomposition in global MFE predictions, as used e.\+g. in RNAfold. This implementation makes use of modern processors capability to execute particular instructions on multiple data simultaneously (SIMD -\/ single instruction multiple data, thanks to W. B. Langdon for providing the modified code). Consequently, the time required to assess the minimum of all multibranch loop decompositions is reduced up to about one half compared to the runtime of the original implementation. This feature is enabled by default since version 2.\+4.\+11 and a dispatcher ensures that the correct implementation will be selected at runtime. If for any reason you want to disable this feature at compile-\/time use the following configure flag\+:
55
56\begin{DoxyVerb}./configure --disable-simd
57\end{DoxyVerb}
58\hypertarget{install_config_swig}{}\doxysubsubsection{Scripting Interfaces}\label{install_config_swig}
59The Vienna\+RNA Package comes with scripting language interfaces for Perl 5, Python 2, and Python 3 (provided by swig), that allow one to use the implemented algorithms directly without the need of calling an executable program. The interfaces are build by default whenever the autoconf tool-\/chain detects the required build tools on your system. You may, however, explicitly turn off particular scripting language interface support at configure-\/time, for instance for Perl 5 and Python 2, before the actual installation.
60
61Example\+:
62
63\begin{DoxyVerb}./configure --without-perl --without-python
64\end{DoxyVerb}
65
66
67Disabling the scripting language support all-\/together can be accomplished using the following switch\+: \begin{DoxyVerb}./configure --without-swig
68\end{DoxyVerb}
69\hypertarget{install_config_cluster}{}\doxysubsubsection{Cluster Analysis}\label{install_config_cluster}
70The programs Analyse\+Seqs and Analyse\+Dists offer some cluster analysis tools (split decomposition, statistical geometry, neighbor joining, Ward\textquotesingle{}s method) for sequences and distance data. To also build these programs add
71
72\begin{DoxyVerb}--with-cluster
73\end{DoxyVerb}
74
75
76to your configure options.\hypertarget{install_config_kinfold}{}\doxysubsubsection{Kinfold}\label{install_config_kinfold}
77The Kinfold program can be used to simulate the folding dynamics of an RNA molecule, and is compiled by default. Use the
78
79\begin{DoxyVerb}--without-kinfold
80\end{DoxyVerb}
81
82
83option to skip compilation and installation of Kinfold.\hypertarget{install_config_forester}{}\doxysubsubsection{RNAforester}\label{install_config_forester}
84The RNAforester program is used for comparing secondary structures using tree alignment. Similar to Kinfold, use the
85
86\begin{DoxyVerb}--without-forester
87\end{DoxyVerb}
88
89
90option to skip compilation and installation of RNAforester.\hypertarget{install_config_kinwalker}{}\doxysubsubsection{Kinwalker}\label{install_config_kinwalker}
91The Kinwalker algorithm performs co-\/transcriptional folding of RNAs, starting at a user specified structure (default\+: open chain) and ending at the minimum free energy structure. Compilation and installation of this program is deactivated by default. Use the
92
93\begin{DoxyVerb}--with-kinwalker
94\end{DoxyVerb}
95
96
97option to enable building and installation of Kinwalker.\hypertarget{install_config_lto}{}\doxysubsubsection{Link Time Optimization (\+LTO)}\label{install_config_lto}
98To increase the performance of our implementations, the Vienna\+RNA Package tries to make use of the Link Time Optimization (LTO) feature of modern C-\/compilers. If you are experiencing any troubles at make-\/time or run-\/time, or the configure script for some reason detects that your compiler supports this feature although it doesn\textquotesingle{}t, you can deactivate it using the flag
99
100\begin{DoxyVerb}./configure --disable-lto
101\end{DoxyVerb}
102
103
104Note, that GCC before version 5 is known to produce unreliable LTO code, especially in combination with SIMD (see \mbox{\hyperlink{install_config_simd}{Streaming SIMD Extension (SSE) support}}). We therefore recommend using a more recent compiler (GCC 5 or above) or to turn off one of the two features, LTO or SIMD optimized code.\hypertarget{install_config_openmp}{}\doxysubsubsection{Open\+MP support}\label{install_config_openmp}
105To enable concurrent computation of our implementations and in some cases parallelization of the algorithms we make use of the Open\+MP API. This interface is well understood by most modern compilers. However, in some cases it might be necessary to deactivate Open\+MP support and therefore transform {\itshape RNAlib} into a C-\/library that is not entirely {\itshape thread-\/safe}. To do so, add the following configure option
106
107\begin{DoxyVerb}./configure --disable-openmp
108\end{DoxyVerb}
109\hypertarget{install_config_pthread}{}\doxysubsubsection{POSIX threads (pthread) support}\label{install_config_pthread}
110To enable concurrent computation of multiple input data in RNAfold, and for our implementation of the concurrent unordered insert, ordered output flush data structure vrna\+\_\+ostream\+\_\+t we make use of POSIX threads. This should be supported on all modern platforms and usually does not pose any problems. Unfortunately, we use a threadpool implementation that is not compatible with Microsoft Windows yet. Thus, POSIX thread support can not be activated for Windows builds until we have fixed this problem. If you want to compile RNAfold and RNAlib without POSIX threads support for any other reasons, add the following configure option
111
112\begin{DoxyVerb}./configure --disable-pthreads
113\end{DoxyVerb}
114\hypertarget{install_config_boustrophedon}{}\doxysubsubsection{Stochastic backtracking using Boustrophedon scheme}\label{install_config_boustrophedon}
115Stochastic backtracking for single RNA sequences, e.\+g. available through the RNAsubopt program, received a major speedup by implementing a Boustrophedon scheme (see this article for details). If for some reason you want to deactivate this feature, you can do that by adding the following switch to the configure script\+:
116
117\begin{DoxyVerb}./configure --disable-boustrophedon
118\end{DoxyVerb}
119\hypertarget{install_config_svm}{}\doxysubsubsection{SVM Z-\/score filter in RNALfold}\label{install_config_svm}
120By default, RNALfold that comes with the Vienna\+RNA Package allows for z-\/score filtering of its predicted results using a support vector machine (SVM). However, the library we use to implement this feature (libsvm) is statically linked to our own RNAlib. If this introduces any problems for your own third-\/party programs that link against RNAlib, you can safely switch off the z-\/scoring implementation using
121
122\begin{DoxyVerb}./configure --without-svm
123\end{DoxyVerb}
124\hypertarget{install_config_gsl}{}\doxysubsubsection{GNU Scientific Library}\label{install_config_gsl}
125The new program RNApvmin computes a pseudo-\/energy perturbation vector that aims to minimize the discrepancy of predicted, and observed pairing probabilities. For that purpose it implements several methods to solve the optimization problem. Many of them are provided by the GNU Scientific Library, which is why the RNApvmin program, and the RNAlib C-\/library are required to be linked against libgsl. If this introduces any problems in your own third-\/party programs that link against RNAlib, you can turn off a larger portion of available minimizers in RNApvmin and linking against libgsl all-\/together, using the switch
126
127\begin{DoxyVerb}./configure --without-gsl
128\end{DoxyVerb}
129\hypertarget{install_config_c11}{}\doxysubsubsection{Disable C11/\+C++11 feature support}\label{install_config_c11}
130By default, we use C11/\+C++11 features in our implementations. This mainly accounts for unnamed unions/structs within {\itshape RNAlib}. The configure script automatically detects whether or not your compiler understands these features. In case you are using an older compiler, these features will be deactivated by setting a specific pre-\/processor directive. If for some reason you want to deactivate C11/\+C++11 features despite the capabilities of your compiler, use the following configure option\+:
131
132\begin{DoxyVerb}./configure --disable-c11
133\end{DoxyVerb}
134\hypertarget{install_config_deprecated}{}\doxysubsubsection{Enable warnings for use of deprecated symbols}\label{install_config_deprecated}
135Since version 2.\+2 we are in the process of transforming the API of our {\itshape RNAlib}. Hence, several symbols are marked as {\itshape deprecated} whenever they have been replaced by the new API. By default, deprecation warnings at compile time are deactivated. If you want to get your terminal spammed by tons of deprecation warnings, enable them using\+:
136
137\begin{DoxyVerb}./configure --enable-warn-deprecated
138\end{DoxyVerb}
139\hypertarget{install_config_float_pf}{}\doxysubsubsection{Single precision partition function}\label{install_config_float_pf}
140Calculation of partition functions (via RNAfold -\/p) uses double precision floats by default, to avoid overflow errors on longer sequences. If your machine has little memory and you don\textquotesingle{}t plan to fold sequences over 1000 bases in length you can compile the package to do the computations in single precision by running
141
142\begin{DoxyVerb}./configure --enable-floatpf
143\end{DoxyVerb}
144
145
146\begin{DoxyNote}{Note}
147Using this option is discouraged and not necessary on most modern computers.
148\end{DoxyNote}
149\hypertarget{install_config_help}{}\doxysubsubsection{Help}\label{install_config_help}
150For a complete list of all ./configure options and important environment variables, type
151
152\begin{DoxyVerb}./configure --help
153\end{DoxyVerb}
154
155
156For more general information on the build process see the INSTALL file.\hypertarget{install_linking}{}\doxysubsection{Linking against RNAlib}\label{install_linking}
157In order to use our implemented algorithms you simply need to link your program to our {\itshape RNAlib} C-\/library that usually comes along with the Vienna\+RNA Package installation. If you\textquotesingle{}ve installed the Vienna\+RNA Package as a pre-\/build binary package, you probably need the corresponding development package, e.\+g. {\itshape viennarna-\/devel}, or {\itshape viennarna-\/dev}. The only thing that is left is to include the Vienna\+RNA header files into your source code, e.\+g.\+:
158
159\begin{DoxyVerb}#include <ViennaRNA/mfe.h>
160\end{DoxyVerb}
161
162
163and start using our fast and efficient algorithm implementations.
164
165\begin{DoxySeeAlso}{See also}
166In the \mbox{\hyperlink{examples_c}{C Examples}} and \mbox{\hyperlink{newAPI_newAPI_examples}{Some Examples using RNAlib API v3.\+0}} sections, we list a small set of example code that usually is a good starting point for your application.
167\end{DoxySeeAlso}
168\hypertarget{install_linking_flags}{}\doxysubsubsection{Compiler and Linker flags}\label{install_linking_flags}
169Of course, simply adding the Vienna\+RNA header files into your source code is usually not enough. You probably need to tell your compiler where to find the header files, and sometimes add additional pre-\/processor directives. Whenever your installation of {\itshape RNAlib} was build with default settings and the header files were installed into their default location, a simple
170
171\begin{DoxyVerb}-I/usr/include
172\end{DoxyVerb}
173
174
175pre-\/processor/compile flag should suffice. It can even be omitted in this case, since your compiler should search this directory by default anyway. You only need to change the path from {\itshape /usr/include} to the correct location whenever the header files have been installed into a non-\/standard directory.
176
177On the other hand, if you\textquotesingle{}ve compiled {\itshape RNAlib} with some non-\/default settings then you probably need to define some additional pre-\/processor macros\+:
178
179
180\begin{DoxyItemize}
181\item {\itshape VRNA\+\_\+\+DISABLE\+\_\+\+C11\+\_\+\+FEATURES} $\ldots$ Disable C11/\+C++11 features. \begin{DoxyWarning}{Warning}
182Add this directive to your pre-\/processor/compile flags only if {\itshape RNAlib} was build with the {\itshape --disable-\/c11} configure option.
183\end{DoxyWarning}
184\begin{DoxySeeAlso}{See also}
185\mbox{\hyperlink{install_config_c11}{Disable C11/\+C++11 feature support}} and \mbox{\hyperlink{group__data__structures_ga21744ae2d6a17309f9327d3547cef0cb}{vrna\+\_\+\+C11\+\_\+features()}}
186\end{DoxySeeAlso}
187
188\item {\itshape VRNA\+\_\+\+WARN\+\_\+\+DEPRECATED} $\ldots$ Enable warnings for using deprecated symbols. \begin{DoxyNote}{Note}
189Adding this directive enables compiler warnings whenever you use symbols in {\itshape RNAlib} that are marked {\itshape deprecated}.
190\end{DoxyNote}
191\begin{DoxySeeAlso}{See also}
192\mbox{\hyperlink{install_config_deprecated}{Enable warnings for use of deprecated symbols}} and \mbox{\hyperlink{deprecated}{Deprecated List}}
193\end{DoxySeeAlso}
194
195\item {\itshape USE\+\_\+\+FLOAT\+\_\+\+PF} $\ldots$ Use single precision floating point operations instead of double precision in partition function computations. \begin{DoxyWarning}{Warning}
196Define this macro only if {\itshape RNAlib} was build with the {\itshape --enable-\/floatpf} configure option!
197\end{DoxyWarning}
198\begin{DoxySeeAlso}{See also}
199\mbox{\hyperlink{install_config_float_pf}{Single precision partition function}}
200\end{DoxySeeAlso}
201
202\end{DoxyItemize}Simply add the corresponding definition(s) to your pre-\/processor/compile flags, for instance\+:
203
204\begin{DoxyVerb}-DVRNA_DISABLE_C11_FEATURES
205\end{DoxyVerb}
206
207
208Finally, linking against {\itshape RNAlib} is achieved by adding the following linker flag
209
210\begin{DoxyVerb}-L/usr/lib -lRNA -fopenmp
211\end{DoxyVerb}
212
213
214Again, the path to the library, {\itshape /usr/lib}, may be omitted if this path is searched for libraries by default. The second flag tells the linker to include {\itshape lib\+RNA.\+a}, and the remaining two flags activate \mbox{\hyperlink{install_config_lto}{Link Time Optimization (LTO)}} and \mbox{\hyperlink{install_config_openmp}{Open\+MP support}} support, respectively. \begin{DoxyNote}{Note}
215Depending on your linker, the last two flags may differ.
216
217Depending on your configure time decisions, you can drop one or both of the last flags.
218
219In case you\textquotesingle{}ve compiled {\itshape RNAlib} with LTO support (See \mbox{\hyperlink{install_config_lto}{Link Time Optimization (LTO)}}) and you are using the same compiler for your third-\/party project that links against our library, you may add the
220\begin{DoxyCode}{0}
221\DoxyCodeLine{-\/flto }
222
223\end{DoxyCode}
224 flag to enable Link Time Optimization.
225\end{DoxyNote}
226\hypertarget{install_linking_pkgconfig}{}\doxysubsubsection{The pkg-\/config tool}\label{install_linking_pkgconfig}
227Instead of hard-\/coding the required compiler and linker flags, you can also let the {\itshape pkg-\/config} tool automatically determine the required flags. This tool is usually packaged for any Linux distribution and should be available for Mac\+OS X and Min\+GW as well. We ship a file {\itshape RNAlib2.\+pc} which is installed along with the static {\itshape lib\+RNA.\+a} C-\/library and populated with all required compiler and linker flags that correspond to your configure time decisions.
228
229The compiler flags required for properly building your code that uses {\itshape RNAlib} can be easily obtained via
230
231\begin{DoxyVerb}pkg-config --cflags RNAlib2
232\end{DoxyVerb}
233
234
235You get the corresponding linker flags using
236
237\begin{DoxyVerb}pkg-config --libs RNAlib2
238\end{DoxyVerb}
239
240
241With this widely accepted standard it is also very easy to integrate {\itshape RNAlib} in your {\itshape autotools} project, just have a look at the {\itshape PKG\+\_\+\+CHECK\+\_\+\+MODULES} macro.
242
243 \hypertarget{helloworld}{}\doxysection{Hello\+World}\label{helloworld}
244Below, you\textquotesingle{}ll find some more or less simple C programs showing first steps into using {\itshape RNAlib}. A complete list of example C programs can be found in the \mbox{\hyperlink{examples_c}{C Examples}} section.
245
246\doxysubsection*{Simple MFE prediction for a given sequence }
247
248
249\begin{DoxyCodeInclude}{0}
250\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdlib.h>}}
251\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdio.h>}}
252\DoxyCodeLine{\textcolor{preprocessor}{\#include <string.h>}}
253\DoxyCodeLine{}
254\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{fold_8h}{ViennaRNA/fold.h}}>}}
255\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{utils_2basic_8h}{ViennaRNA/utils/basic.h}}>}}
256\DoxyCodeLine{}
257\DoxyCodeLine{\textcolor{keywordtype}{int}}
258\DoxyCodeLine{main()}
259\DoxyCodeLine{\{}
260\DoxyCodeLine{  \textcolor{comment}{/* The RNA sequence */}}
261\DoxyCodeLine{  \textcolor{keywordtype}{char}  *seq = \textcolor{stringliteral}{"{}GAGUAGUGGAACCAGGCUAUGUUUGUGACUCGCAGACUAACA"{}};}
262\DoxyCodeLine{}
263\DoxyCodeLine{  \textcolor{comment}{/* allocate memory for MFE structure (length + 1) */}}
264\DoxyCodeLine{  \textcolor{keywordtype}{char}  *structure = (\textcolor{keywordtype}{char} *)\mbox{\hyperlink{group__utils_gaf37a0979367c977edfb9da6614eebe99}{vrna\_alloc}}(\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}) * (strlen(seq) + 1));}
265\DoxyCodeLine{}
266\DoxyCodeLine{  \textcolor{comment}{/* predict Minmum Free Energy and corresponding secondary structure */}}
267\DoxyCodeLine{  \textcolor{keywordtype}{float} mfe = \mbox{\hyperlink{group__mfe__global_ga29a33b2895f4e67b0480271ff289afdc}{vrna\_fold}}(seq, structure);}
268\DoxyCodeLine{}
269\DoxyCodeLine{  \textcolor{comment}{/* print sequence, structure and MFE */}}
270\DoxyCodeLine{  printf(\textcolor{stringliteral}{"{}\%s\(\backslash\)n\%s [ \%6.2f ]\(\backslash\)n"{}}, seq, structure, mfe);}
271\DoxyCodeLine{}
272\DoxyCodeLine{  \textcolor{comment}{/* cleanup memory */}}
273\DoxyCodeLine{  free(structure);}
274\DoxyCodeLine{}
275\DoxyCodeLine{  \textcolor{keywordflow}{return} 0;}
276\DoxyCodeLine{\}}
277
278\end{DoxyCodeInclude}
279 \begin{DoxySeeAlso}{See also}
280{\ttfamily examples/helloworld\+\_\+mfe.\+c} in the source code tarball
281\end{DoxySeeAlso}
282\doxysubsection*{Simple MFE prediction for a multiple sequence alignment }
283
284
285\begin{DoxyCodeInclude}{0}
286\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdlib.h>}}
287\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdio.h>}}
288\DoxyCodeLine{\textcolor{preprocessor}{\#include <string.h>}}
289\DoxyCodeLine{}
290\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{alifold_8h}{ViennaRNA/alifold.h}}>}}
291\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{utils_2basic_8h}{ViennaRNA/utils/basic.h}}>}}
292\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{utils_2alignments_8h}{ViennaRNA/utils/alignments.h}}>}}
293\DoxyCodeLine{}
294\DoxyCodeLine{\textcolor{keywordtype}{int}}
295\DoxyCodeLine{main()}
296\DoxyCodeLine{\{}
297\DoxyCodeLine{  \textcolor{comment}{/* The RNA sequence alignment */}}
298\DoxyCodeLine{  \textcolor{keyword}{const} \textcolor{keywordtype}{char}  *sequences[] = \{}
299\DoxyCodeLine{    \textcolor{stringliteral}{"{}CUGCCUCACAACGUUUGUGCCUCAGUUACCCGUAGAUGUAGUGAGGGU"{}},}
300\DoxyCodeLine{    \textcolor{stringliteral}{"{}CUGCCUCACAACAUUUGUGCCUCAGUUACUCAUAGAUGUAGUGAGGGU"{}},}
301\DoxyCodeLine{    \textcolor{stringliteral}{"{}-\/-\/-\/CUCGACACCACU-\/-\/-\/GCCUCGGUUACCCAUCGGUGCAGUGCGGGU"{}},}
302\DoxyCodeLine{    NULL \textcolor{comment}{/* indicates end of alignment */}}
303\DoxyCodeLine{  \};}
304\DoxyCodeLine{}
305\DoxyCodeLine{  \textcolor{comment}{/* compute the consensus sequence */}}
306\DoxyCodeLine{  \textcolor{keywordtype}{char}        *cons = consensus(sequences);}
307\DoxyCodeLine{}
308\DoxyCodeLine{  \textcolor{comment}{/* allocate memory for MFE consensus structure (length + 1) */}}
309\DoxyCodeLine{  \textcolor{keywordtype}{char}        *structure = (\textcolor{keywordtype}{char} *)\mbox{\hyperlink{group__utils_gaf37a0979367c977edfb9da6614eebe99}{vrna\_alloc}}(\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}) * (strlen(sequences[0]) + 1));}
310\DoxyCodeLine{}
311\DoxyCodeLine{  \textcolor{comment}{/* predict Minmum Free Energy and corresponding secondary structure */}}
312\DoxyCodeLine{  \textcolor{keywordtype}{float}       mfe = \mbox{\hyperlink{group__mfe__global_ga6c9d3bef3e92c6d423ffac9f981418c1}{vrna\_alifold}}(sequences, structure);}
313\DoxyCodeLine{}
314\DoxyCodeLine{  \textcolor{comment}{/* print consensus sequence, structure and MFE */}}
315\DoxyCodeLine{  printf(\textcolor{stringliteral}{"{}\%s\(\backslash\)n\%s [ \%6.2f ]\(\backslash\)n"{}}, cons, structure, mfe);}
316\DoxyCodeLine{}
317\DoxyCodeLine{  \textcolor{comment}{/* cleanup memory */}}
318\DoxyCodeLine{  free(cons);}
319\DoxyCodeLine{  free(structure);}
320\DoxyCodeLine{}
321\DoxyCodeLine{  \textcolor{keywordflow}{return} 0;}
322\DoxyCodeLine{\}}
323
324\end{DoxyCodeInclude}
325 \begin{DoxySeeAlso}{See also}
326{\ttfamily examples/helloworld\+\_\+mfe\+\_\+comparative.\+c} in the source code tarball
327\end{DoxySeeAlso}
328\doxysubsection*{Simple Base Pair Probability computation }
329
330
331\begin{DoxyCodeInclude}{0}
332\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdlib.h>}}
333\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdio.h>}}
334\DoxyCodeLine{\textcolor{preprocessor}{\#include <string.h>}}
335\DoxyCodeLine{}
336\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{fold_8h}{ViennaRNA/fold.h}}>}}
337\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{part__func_8h}{ViennaRNA/part\_func.h}}>}}
338\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{utils_2basic_8h}{ViennaRNA/utils/basic.h}}>}}
339\DoxyCodeLine{}
340\DoxyCodeLine{\textcolor{keywordtype}{int}}
341\DoxyCodeLine{main()}
342\DoxyCodeLine{\{}
343\DoxyCodeLine{  \textcolor{comment}{/* The RNA sequence */}}
344\DoxyCodeLine{  \textcolor{keywordtype}{char}      *seq = \textcolor{stringliteral}{"{}GAGUAGUGGAACCAGGCUAUGUUUGUGACUCGCAGACUAACA"{}};}
345\DoxyCodeLine{}
346\DoxyCodeLine{  \textcolor{comment}{/* allocate memory for pairing propensity string (length + 1) */}}
347\DoxyCodeLine{  \textcolor{keywordtype}{char}      *propensity = (\textcolor{keywordtype}{char} *)\mbox{\hyperlink{group__utils_gaf37a0979367c977edfb9da6614eebe99}{vrna\_alloc}}(\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}) * (strlen(seq) + 1));}
348\DoxyCodeLine{}
349\DoxyCodeLine{  \textcolor{comment}{/* pointers for storing and navigating through base pair probabilities */}}
350\DoxyCodeLine{  \mbox{\hyperlink{group__struct__utils__plist_structvrna__elem__prob__s}{vrna\_ep\_t}} *ptr, *pair\_probabilities = NULL;}
351\DoxyCodeLine{}
352\DoxyCodeLine{  \textcolor{keywordtype}{float}     en = \mbox{\hyperlink{group__part__func__global_gac4a2a74a79e49818bc35412a2b392c7e}{vrna\_pf\_fold}}(seq, propensity, \&pair\_probabilities);}
353\DoxyCodeLine{}
354\DoxyCodeLine{  \textcolor{comment}{/* print sequence, pairing propensity string and ensemble free energy */}}
355\DoxyCodeLine{  printf(\textcolor{stringliteral}{"{}\%s\(\backslash\)n\%s [ \%6.2f ]\(\backslash\)n"{}}, seq, propensity, en);}
356\DoxyCodeLine{}
357\DoxyCodeLine{  \textcolor{comment}{/* print all base pairs with probability above 50\% */}}
358\DoxyCodeLine{  \textcolor{keywordflow}{for} (ptr = pair\_probabilities; ptr-\/>\mbox{\hyperlink{group__struct__utils__plist_a0f8bb11ded4e605f816d7ad92eb568f6}{i}} != 0; ptr++)}
359\DoxyCodeLine{    \textcolor{keywordflow}{if} (ptr-\/>\mbox{\hyperlink{group__struct__utils__plist_a9c09385582d8a7ab00485181f4e868b7}{p}} > 0.5)}
360\DoxyCodeLine{      printf(\textcolor{stringliteral}{"{}p(\%d, \%d) = \%g\(\backslash\)n"{}}, ptr-\/>\mbox{\hyperlink{group__struct__utils__plist_a0f8bb11ded4e605f816d7ad92eb568f6}{i}}, ptr-\/>\mbox{\hyperlink{group__struct__utils__plist_acada5be62ed6843334a918ca543f0c0d}{j}}, ptr-\/>\mbox{\hyperlink{group__struct__utils__plist_a9c09385582d8a7ab00485181f4e868b7}{p}});}
361\DoxyCodeLine{}
362\DoxyCodeLine{  \textcolor{comment}{/* cleanup memory */}}
363\DoxyCodeLine{  free(pair\_probabilities);}
364\DoxyCodeLine{  free(propensity);}
365\DoxyCodeLine{}
366\DoxyCodeLine{  \textcolor{keywordflow}{return} 0;}
367\DoxyCodeLine{\}}
368
369\end{DoxyCodeInclude}
370 \begin{DoxySeeAlso}{See also}
371{\ttfamily examples/helloworld\+\_\+probabilities.\+c} in the source code tarball
372\end{DoxySeeAlso}
373\doxysubsection*{Deviating from the Default Model }
374
375
376\begin{DoxyCodeInclude}{0}
377\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdlib.h>}}
378\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdio.h>}}
379\DoxyCodeLine{\textcolor{preprocessor}{\#include <string.h>}}
380\DoxyCodeLine{}
381\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{model_8h}{ViennaRNA/model.h}}>}}
382\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{fold__compound_8h}{ViennaRNA/fold\_compound.h}}>}}
383\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{utils_2basic_8h}{ViennaRNA/utils/basic.h}}>}}
384\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{strings_8h}{ViennaRNA/utils/strings.h}}>}}
385\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{mfe_8h}{ViennaRNA/mfe.h}}>}}
386\DoxyCodeLine{}
387\DoxyCodeLine{\textcolor{keywordtype}{int}}
388\DoxyCodeLine{main()}
389\DoxyCodeLine{\{}
390\DoxyCodeLine{  \textcolor{comment}{/* initialize random number generator */}}
391\DoxyCodeLine{  \mbox{\hyperlink{group__utils_ga0ad1f40ea316e5c5918695c35613027a}{vrna\_init\_rand}}();}
392\DoxyCodeLine{}
393\DoxyCodeLine{  \textcolor{comment}{/* Generate a random sequence of 50 nucleotides */}}
394\DoxyCodeLine{  \textcolor{keywordtype}{char}      *seq = \mbox{\hyperlink{group__string__utils_ga4eeb3750dcf860b9f3158249f95dbd7f}{vrna\_random\_string}}(50, \textcolor{stringliteral}{"{}ACGU"{}});}
395\DoxyCodeLine{}
396\DoxyCodeLine{  \textcolor{comment}{/* allocate memory for MFE structure (length + 1) */}}
397\DoxyCodeLine{  \textcolor{keywordtype}{char}      *structure = (\textcolor{keywordtype}{char} *)\mbox{\hyperlink{group__utils_gaf37a0979367c977edfb9da6614eebe99}{vrna\_alloc}}(\textcolor{keyword}{sizeof}(\textcolor{keywordtype}{char}) * (strlen(seq) + 1));}
398\DoxyCodeLine{}
399\DoxyCodeLine{  \textcolor{comment}{/* create a new model details structure to store the Model Settings */}}
400\DoxyCodeLine{  \mbox{\hyperlink{group__model__details_structvrna__md__s}{vrna\_md\_t}} md;}
401\DoxyCodeLine{}
402\DoxyCodeLine{  \textcolor{comment}{/* ALWAYS set default model settings first! */}}
403\DoxyCodeLine{  \mbox{\hyperlink{group__model__details_ga8ac6ff84936282436f822644bf841f66}{vrna\_md\_set\_default}}(\&md);}
404\DoxyCodeLine{}
405\DoxyCodeLine{  \textcolor{comment}{/* change temperature and activate G-\/Quadruplex prediction */}}
406\DoxyCodeLine{  md.\mbox{\hyperlink{group__model__details_a5f7e5c2b65bada5188443470e576aa4b}{temperature}}  = 25.0; \textcolor{comment}{/* 25 Deg Celcius */}}
407\DoxyCodeLine{  md.\mbox{\hyperlink{group__model__details_af88a511a2b1f526b4c6213de6cb8fd6e}{gquad}}        = 1;    \textcolor{comment}{/* Turn-\/on G-\/Quadruples support */}}
408\DoxyCodeLine{}
409\DoxyCodeLine{  \textcolor{comment}{/* create a fold compound */}}
410\DoxyCodeLine{  \mbox{\hyperlink{group__fold__compound_structvrna__fc__s}{vrna\_fold\_compound\_t}}  *fc = \mbox{\hyperlink{group__fold__compound_ga283cf113a37614a75c1388c4ec6d7b2f}{vrna\_fold\_compound}}(seq, \&md, \mbox{\hyperlink{group__fold__compound_gacea5b7ee6181c485f36e2afa0e9089e4}{VRNA\_OPTION\_DEFAULT}});}
411\DoxyCodeLine{}
412\DoxyCodeLine{  \textcolor{comment}{/* predict Minmum Free Energy and corresponding secondary structure */}}
413\DoxyCodeLine{  \textcolor{keywordtype}{float}                 mfe = \mbox{\hyperlink{group__mfe__global_gabd3b147371ccf25c577f88bbbaf159fd}{vrna\_mfe}}(fc, structure);}
414\DoxyCodeLine{}
415\DoxyCodeLine{  \textcolor{comment}{/* print sequence, structure and MFE */}}
416\DoxyCodeLine{  printf(\textcolor{stringliteral}{"{}\%s\(\backslash\)n\%s [ \%6.2f ]\(\backslash\)n"{}}, seq, structure, mfe);}
417\DoxyCodeLine{}
418\DoxyCodeLine{  \textcolor{comment}{/* cleanup memory */}}
419\DoxyCodeLine{  free(structure);}
420\DoxyCodeLine{  \mbox{\hyperlink{group__fold__compound_ga576a077b418a9c3650e06f8e5d296fc2}{vrna\_fold\_compound\_free}}(fc);}
421\DoxyCodeLine{}
422\DoxyCodeLine{  \textcolor{keywordflow}{return} 0;}
423\DoxyCodeLine{\}}
424
425\end{DoxyCodeInclude}
426 \begin{DoxySeeAlso}{See also}
427{\ttfamily examples/fold\+\_\+compound\+\_\+md.\+c} in the source code tarball
428\end{DoxySeeAlso}
429\hypertarget{helloworld_swig}{}\doxysection{Hello\+World (Perl/\+Python)}\label{helloworld_swig}
430\hypertarget{helloworld_swig_helloworld_perl}{}\doxysubsection{Perl5}\label{helloworld_swig_helloworld_perl}
431\doxysubsection*{Simple MFE prediction for a given sequence }
432
433
434\begin{DoxyCodeInclude}{0}
435\DoxyCodeLine{use RNA;}
436\DoxyCodeLine{}
437\DoxyCodeLine{\# The RNA sequence}
438\DoxyCodeLine{my \$seq = "{}GAGUAGUGGAACCAGGCUAUGUUUGUGACUCGCAGACUAACA"{};}
439\DoxyCodeLine{}
440\DoxyCodeLine{\# compute minimum free energy (MFE) and corresponding structure}
441\DoxyCodeLine{my (\$ss, \$mfe) = RNA::fold(\$seq);}
442\DoxyCodeLine{}
443\DoxyCodeLine{\# print output}
444\DoxyCodeLine{printf "{}\%s\(\backslash\)n\%s [ \%6.2f ]\(\backslash\)n"{}, \$seq, \$ss, \$mfe;}
445
446\end{DoxyCodeInclude}
447
448
449\doxysubsection*{Simple MFE prediction for a multiple sequence alignment }
450
451
452\begin{DoxyCodeInclude}{0}
453\DoxyCodeLine{use RNA;}
454\DoxyCodeLine{}
455\DoxyCodeLine{\# The RNA sequence alignment}
456\DoxyCodeLine{my @sequences = (}
457\DoxyCodeLine{    "{}CUGCCUCACAACGUUUGUGCCUCAGUUACCCGUAGAUGUAGUGAGGGU"{},}
458\DoxyCodeLine{    "{}CUGCCUCACAACAUUUGUGCCUCAGUUACUCAUAGAUGUAGUGAGGGU"{},}
459\DoxyCodeLine{    "{}-\/-\/-\/CUCGACACCACU-\/-\/-\/GCCUCGGUUACCCAUCGGUGCAGUGCGGGU"{}}
460\DoxyCodeLine{);}
461\DoxyCodeLine{}
462\DoxyCodeLine{\# compute the consensus sequence}
463\DoxyCodeLine{my \$cons = RNA::consensus(\(\backslash\)@sequences);}
464\DoxyCodeLine{}
465\DoxyCodeLine{\# predict Minmum Free Energy and corresponding secondary structure}
466\DoxyCodeLine{my (\$ss, \$mfe) = RNA::alifold(\(\backslash\)@sequences);}
467\DoxyCodeLine{}
468\DoxyCodeLine{\# print output}
469\DoxyCodeLine{printf "{}\%s\(\backslash\)n\%s [ \%6.2f ]\(\backslash\)n"{}, \$cons, \$ss, \$mfe;}
470
471\end{DoxyCodeInclude}
472
473
474\doxysubsection*{Deviating from the Default Model }
475
476
477\begin{DoxyCodeInclude}{0}
478\DoxyCodeLine{use RNA;}
479\DoxyCodeLine{}
480\DoxyCodeLine{\# The RNA sequence}
481\DoxyCodeLine{my \$seq = "{}GAGUAGUGGAACCAGGCUAUGUUUGUGACUCGCAGACUAACA"{};}
482\DoxyCodeLine{}
483\DoxyCodeLine{\# create a new model details structure}
484\DoxyCodeLine{my \$md = new RNA::md();}
485\DoxyCodeLine{}
486\DoxyCodeLine{\# change temperature and dangle model}
487\DoxyCodeLine{\$md-\/>\{temperature\} = 20.0; \# 20 Deg Celcius}
488\DoxyCodeLine{\$md-\/>\{dangles\}     = 1;    \# Dangle Model 1}
489\DoxyCodeLine{}
490\DoxyCodeLine{\# create a fold compound}
491\DoxyCodeLine{my \$fc = new RNA::fold\_compound(\$seq, \$md);}
492\DoxyCodeLine{}
493\DoxyCodeLine{\# predict Minmum Free Energy and corresponding secondary structure}
494\DoxyCodeLine{my (\$ss, \$mfe) = \$fc-\/>mfe();}
495\DoxyCodeLine{}
496\DoxyCodeLine{\# print sequence, structure and MFE}
497\DoxyCodeLine{printf "{}\%s\(\backslash\)n\%s [ \%6.2f ]\(\backslash\)n"{}, \$seq, \$ss, \$mfe;}
498\DoxyCodeLine{}
499
500\end{DoxyCodeInclude}
501\hypertarget{helloworld_swig_helloworld_python}{}\doxysubsection{Python}\label{helloworld_swig_helloworld_python}
502\doxysubsection*{Simple MFE prediction for a given sequence }
503
504
505\begin{DoxyCodeInclude}{0}
506\DoxyCodeLine{\textcolor{keyword}{import} RNA}
507\DoxyCodeLine{}
508\DoxyCodeLine{\textcolor{comment}{\# The RNA sequence}}
509\DoxyCodeLine{seq = \textcolor{stringliteral}{"{}GAGUAGUGGAACCAGGCUAUGUUUGUGACUCGCAGACUAACA"{}}}
510\DoxyCodeLine{}
511\DoxyCodeLine{\textcolor{comment}{\# compute minimum free energy (MFE) and corresponding structure}}
512\DoxyCodeLine{(ss, mfe) = RNA.fold(seq)}
513\DoxyCodeLine{}
514\DoxyCodeLine{\textcolor{comment}{\# print output}}
515\DoxyCodeLine{\textcolor{keywordflow}{print} \textcolor{stringliteral}{"{}\%s\(\backslash\)n\%s [ \%6.2f ]"{}} \% (seq, ss, mfe)}
516
517\end{DoxyCodeInclude}
518
519
520\doxysubsection*{Simple MFE prediction for a multiple sequence alignment }
521
522
523\begin{DoxyCodeInclude}{0}
524\DoxyCodeLine{\textcolor{keyword}{import} RNA}
525\DoxyCodeLine{}
526\DoxyCodeLine{\textcolor{comment}{\# The RNA sequence alignment}}
527\DoxyCodeLine{sequences = [}
528\DoxyCodeLine{    \textcolor{stringliteral}{"{}CUGCCUCACAACGUUUGUGCCUCAGUUACCCGUAGAUGUAGUGAGGGU"{}},}
529\DoxyCodeLine{    \textcolor{stringliteral}{"{}CUGCCUCACAACAUUUGUGCCUCAGUUACUCAUAGAUGUAGUGAGGGU"{}},}
530\DoxyCodeLine{    \textcolor{stringliteral}{"{}-\/-\/-\/CUCGACACCACU-\/-\/-\/GCCUCGGUUACCCAUCGGUGCAGUGCGGGU"{}}}
531\DoxyCodeLine{]}
532\DoxyCodeLine{}
533\DoxyCodeLine{\textcolor{comment}{\# compute the consensus sequence}}
534\DoxyCodeLine{cons = RNA.consensus(sequences)}
535\DoxyCodeLine{}
536\DoxyCodeLine{\textcolor{comment}{\# predict Minmum Free Energy and corresponding secondary structure}}
537\DoxyCodeLine{(ss, mfe) = RNA.alifold(sequences);}
538\DoxyCodeLine{}
539\DoxyCodeLine{\textcolor{comment}{\# print output}}
540\DoxyCodeLine{\textcolor{keywordflow}{print} \textcolor{stringliteral}{"{}\%s\(\backslash\)n\%s [ \%6.2f ]"{}} \% (cons, ss, mfe)}
541
542\end{DoxyCodeInclude}
543
544
545\doxysubsection*{Deviating from the Default Model }
546
547
548\begin{DoxyCodeInclude}{0}
549\DoxyCodeLine{\textcolor{keyword}{import} RNA}
550\DoxyCodeLine{}
551\DoxyCodeLine{\textcolor{comment}{\# The RNA sequence}}
552\DoxyCodeLine{seq = \textcolor{stringliteral}{"{}GAGUAGUGGAACCAGGCUAUGUUUGUGACUCGCAGACUAACA"{}}}
553\DoxyCodeLine{}
554\DoxyCodeLine{\textcolor{comment}{\# create a new model details structure}}
555\DoxyCodeLine{md = RNA.md()}
556\DoxyCodeLine{}
557\DoxyCodeLine{\textcolor{comment}{\# change temperature and dangle model}}
558\DoxyCodeLine{md.temperature = 20.0 \textcolor{comment}{\# 20 Deg Celcius}}
559\DoxyCodeLine{md.dangles     = 1    \textcolor{comment}{\# Dangle Model 1}}
560\DoxyCodeLine{}
561\DoxyCodeLine{\textcolor{comment}{\# create a fold compound}}
562\DoxyCodeLine{fc = RNA.fold\_compound(seq, md)}
563\DoxyCodeLine{}
564\DoxyCodeLine{\textcolor{comment}{\# predict Minmum Free Energy and corresponding secondary structure}}
565\DoxyCodeLine{(ss, mfe) = fc.mfe()}
566\DoxyCodeLine{}
567\DoxyCodeLine{\textcolor{comment}{\# print sequence, structure and MFE}}
568\DoxyCodeLine{\textcolor{keywordflow}{print} \textcolor{stringliteral}{"{}\%s\(\backslash\)n\%s [ \%6.2f ]\(\backslash\)n"{}} \% (seq, ss, mfe)}
569
570\end{DoxyCodeInclude}
571