WSTester updated to work plus hopefully all the other changes that need to go into...
[jabaws.git] / binaries / src / ViennaRNA / doc / html / mp_example.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5 <meta http-equiv="X-UA-Compatible" content="IE=9"/>
6 <title>RNAlib-2.1.2: Example - A Small Example Program</title>
7 <link href="tabs.css" rel="stylesheet" type="text/css"/>
8 <script type="text/javascript" src="jquery.js"></script>
9 <script type="text/javascript" src="dynsections.js"></script>
10 <link href="navtree.css" rel="stylesheet" type="text/css"/>
11 <script type="text/javascript" src="resize.js"></script>
12 <script type="text/javascript" src="navtree.js"></script>
13 <script type="text/javascript">
14   $(document).ready(initResizable);
15 </script>
16 <link href="doxygen.css" rel="stylesheet" type="text/css" />
17 </head>
18 <body>
19 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
20 <div id="titlearea">
21 <table cellspacing="0" cellpadding="0">
22  <tbody>
23  <tr style="height: 56px;">
24   <td style="padding-left: 0.5em;">
25    <div id="projectname">RNAlib-2.1.2
26    </div>
27   </td>
28  </tr>
29  </tbody>
30 </table>
31 </div>
32 <!-- end header part -->
33 <!-- Generated by Doxygen 1.8.1.1 -->
34   <div id="navrow1" class="tabs">
35     <ul class="tablist">
36       <li><a href="index.html"><span>Main&#160;Page</span></a></li>
37       <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
38       <li><a href="modules.html"><span>Modules</span></a></li>
39       <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
40       <li><a href="files.html"><span>Files</span></a></li>
41     </ul>
42   </div>
43 </div><!-- top -->
44 <div id="side-nav" class="ui-resizable side-nav-resizable">
45   <div id="nav-tree">
46     <div id="nav-tree-contents">
47     </div>
48   </div>
49   <div id="splitbar" style="-moz-user-select:none;" 
50        class="ui-resizable-handle">
51   </div>
52 </div>
53 <script type="text/javascript">
54 $(document).ready(function(){initNavTree('mp_example.html','');});
55 </script>
56 <div id="doc-content">
57 <div class="header">
58   <div class="headertitle">
59 <div class="title">Example - A Small Example Program </div>  </div>
60 </div><!--header-->
61 <div class="contents">
62 <div class="textblock"><p>The following program exercises most commonly used functions of the library. The program folds two sequences using both the mfe and partition function algorithms and calculates the tree edit and profile distance of the resulting structures and base pairing probabilities.</p>
63 <div class="fragment"><div class="line"><span class="preprocessor">#include  &lt;stdio.h&gt;</span></div>
64 <div class="line"><span class="preprocessor">#include  &lt;stdlib.h&gt;</span></div>
65 <div class="line"><span class="preprocessor">#include  &lt;math.h&gt;</span></div>
66 <div class="line"><span class="preprocessor">#include  &lt;string.h&gt;</span></div>
67 <div class="line"><span class="preprocessor">#include  &quot;<a class="code" href="utils_8h.html" title="Various utility- and helper-functions used throughout the Vienna RNA package.">utils.h</a>&quot;</span></div>
68 <div class="line"><span class="preprocessor">#include  &quot;<a class="code" href="fold__vars_8h.html" title="Here all all declarations of the global variables used throughout RNAlib.">fold_vars.h</a>&quot;</span></div>
69 <div class="line"><span class="preprocessor">#include  &quot;<a class="code" href="fold_8h.html" title="MFE calculations and energy evaluations for single RNA sequences.">fold.h</a>&quot;</span></div>
70 <div class="line"><span class="preprocessor">#include  &quot;<a class="code" href="part__func_8h.html" title="Partition function of single RNA sequences.">part_func.h</a>&quot;</span></div>
71 <div class="line"><span class="preprocessor">#include  &quot;<a class="code" href="inverse_8h.html" title="Inverse folding routines.">inverse.h</a>&quot;</span></div>
72 <div class="line"><span class="preprocessor">#include  &quot;<a class="code" href="RNAstruct_8h.html" title="Parsing and Coarse Graining of Structures.">RNAstruct.h</a>&quot;</span></div>
73 <div class="line"><span class="preprocessor">#include  &quot;<a class="code" href="treedist_8h.html" title="Functions for Tree Edit Distances.">treedist.h</a>&quot;</span></div>
74 <div class="line"><span class="preprocessor">#include  &quot;<a class="code" href="stringdist_8h.html" title="Functions for String Alignment.">stringdist.h</a>&quot;</span></div>
75 <div class="line"><span class="preprocessor">#include  &quot;<a class="code" href="profiledist_8h.html">profiledist.h</a>&quot;</span></div>
76 <div class="line"></div>
77 <div class="line"><span class="keywordtype">void</span> main()</div>
78 <div class="line">{</div>
79 <div class="line">   <span class="keywordtype">char</span> *seq1=<span class="stringliteral">&quot;CGCAGGGAUACCCGCG&quot;</span>, *seq2=<span class="stringliteral">&quot;GCGCCCAUAGGGACGC&quot;</span>,</div>
80 <div class="line">        *struct1,* struct2,* xstruc;</div>
81 <div class="line">   <span class="keywordtype">float</span> e1, e2, tree_dist, string_dist, profile_dist, kT;</div>
82 <div class="line">   <a class="code" href="structTree.html">Tree</a> *T1, *T2;</div>
83 <div class="line">   <a class="code" href="structswString.html">swString</a> *S1, *S2;</div>
84 <div class="line">   <span class="keywordtype">float</span> *pf1, *pf2;</div>
85 <div class="line">   FLT_OR_DBL *bppm;</div>
86 <div class="line">   <span class="comment">/* fold at 30C instead of the default 37C */</span></div>
87 <div class="line">   <a class="code" href="fold__vars_8h.html#ab4b11c8d9c758430960896bc3fe82ead" title="Rescale energy parameters to a temperature in degC.">temperature</a> = 30.;      <span class="comment">/* must be set *before* initializing  */</span></div>
88 <div class="line"></div>
89 <div class="line">   <span class="comment">/* allocate memory for structure and fold */</span></div>
90 <div class="line">   struct1 = (<span class="keywordtype">char</span>* ) <a class="code" href="utils_8h.html#ad7e1e137b3bf1f7108933d302a7f0177" title="Allocate space safely.">space</a>(<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>)*(strlen(seq1)+1));</div>
91 <div class="line">   e1 =  <a class="code" href="group__mfe__fold.html#gaadafcb0f140795ae62e5ca027e335a9b" title="Compute minimum free energy and an appropriate secondary structure of an RNA sequence.">fold</a>(seq1, struct1);</div>
92 <div class="line"></div>
93 <div class="line">   struct2 = (<span class="keywordtype">char</span>* ) <a class="code" href="utils_8h.html#ad7e1e137b3bf1f7108933d302a7f0177" title="Allocate space safely.">space</a>(<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>)*(strlen(seq2)+1));</div>
94 <div class="line">   e2 =  <a class="code" href="group__mfe__fold.html#gaadafcb0f140795ae62e5ca027e335a9b" title="Compute minimum free energy and an appropriate secondary structure of an RNA sequence.">fold</a>(seq2, struct2);</div>
95 <div class="line"></div>
96 <div class="line">   <a class="code" href="group__mfe__fold.html#ga107fdfe5fd641868156bfd849f6866c7" title="Free arrays for mfe folding.">free_arrays</a>();     <span class="comment">/* free arrays used in fold() */</span></div>
97 <div class="line"></div>
98 <div class="line">   <span class="comment">/* produce tree and string representations for comparison */</span></div>
99 <div class="line">   xstruc = <a class="code" href="RNAstruct_8h.html#a78d73cd54a068ef2812812771cdddc6f" title="Convert the full structure from bracket notation to the expanded notation including root...">expand_Full</a>(struct1);</div>
100 <div class="line">   T1 = <a class="code" href="treedist_8h.html#a08fe4d5afd385dce593b86eaf010c6e3" title="Constructs a Tree ( essentially the postorder list ) of the structure &#39;struc&#39;, for use in tree_edit_d...">make_tree</a>(xstruc);</div>
101 <div class="line">   S1 = <a class="code" href="stringdist_8h.html#a3125991b3a403b3f89230474deb3f22e" title="Convert a structure into a format suitable for string_edit_distance().">Make_swString</a>(xstruc);</div>
102 <div class="line">   free(xstruc);</div>
103 <div class="line"></div>
104 <div class="line">   xstruc = <a class="code" href="RNAstruct_8h.html#a78d73cd54a068ef2812812771cdddc6f" title="Convert the full structure from bracket notation to the expanded notation including root...">expand_Full</a>(struct2);</div>
105 <div class="line">   T2 = <a class="code" href="treedist_8h.html#a08fe4d5afd385dce593b86eaf010c6e3" title="Constructs a Tree ( essentially the postorder list ) of the structure &#39;struc&#39;, for use in tree_edit_d...">make_tree</a>(xstruc);</div>
106 <div class="line">   S2 = <a class="code" href="stringdist_8h.html#a3125991b3a403b3f89230474deb3f22e" title="Convert a structure into a format suitable for string_edit_distance().">Make_swString</a>(xstruc);</div>
107 <div class="line">   free(xstruc);</div>
108 <div class="line"></div>
109 <div class="line">   <span class="comment">/* calculate tree edit distance and aligned structures with gaps */</span></div>
110 <div class="line">   <a class="code" href="dist__vars_8h.html#aa03194c513af6b860e7b33e370b82bdb" title="Produce an alignment of the two structures being compared by tracing the editing path giving the mini...">edit_backtrack</a> = 1;</div>
111 <div class="line">   tree_dist = <a class="code" href="treedist_8h.html#a3b21f1925f7071f46d93431a835217bb" title="Calculates the edit distance of the two trees.">tree_edit_distance</a>(T1, T2);</div>
112 <div class="line">   <a class="code" href="treedist_8h.html#acbc1cb9bce582ea945e4a467c76a57aa" title="Free the memory allocated for Tree t.">free_tree</a>(T1); <a class="code" href="treedist_8h.html#acbc1cb9bce582ea945e4a467c76a57aa" title="Free the memory allocated for Tree t.">free_tree</a>(T2);</div>
113 <div class="line">   <a class="code" href="RNAstruct_8h.html#a1054c4477d53b31d79d4cb132100e87a" title="Converts two aligned structures in expanded notation.">unexpand_aligned_F</a>(aligned_line);</div>
114 <div class="line">   printf(<span class="stringliteral">&quot;%s\n%s  %3.2f\n&quot;</span>, aligned_line[0], aligned_line[1], tree_dist);</div>
115 <div class="line"></div>
116 <div class="line">   <span class="comment">/* same thing using string edit (alignment) distance */</span></div>
117 <div class="line">   string_dist = <a class="code" href="stringdist_8h.html#a89e3c335ef17780576d7c0e713830db9" title="Calculate the string edit distance of T1 and T2.">string_edit_distance</a>(S1, S2);</div>
118 <div class="line">   free(S1); free(S2);</div>
119 <div class="line">   printf(<span class="stringliteral">&quot;%s  mfe=%5.2f\n%s  mfe=%5.2f  dist=%3.2f\n&quot;</span>,</div>
120 <div class="line">          aligned_line[0], e1, aligned_line[1], e2, string_dist);</div>
121 <div class="line"></div>
122 <div class="line">   <span class="comment">/* for longer sequences one should also set a scaling factor for</span></div>
123 <div class="line"><span class="comment">      partition function folding, e.g: */</span></div>
124 <div class="line">   kT = (<a class="code" href="fold__vars_8h.html#ab4b11c8d9c758430960896bc3fe82ead" title="Rescale energy parameters to a temperature in degC.">temperature</a>+273.15)*1.98717/1000.;  <span class="comment">/* kT in kcal/mol */</span></div>
125 <div class="line">   <a class="code" href="fold__vars_8h.html#ad3b22044065acc6dee0af68931b52cfd" title="A scaling factor used by pf_fold() to avoid overflows.">pf_scale</a> = exp(-e1/kT/strlen(seq1));</div>
126 <div class="line"></div>
127 <div class="line">   <span class="comment">/* calculate partition function and base pair probabilities */</span></div>
128 <div class="line">   e1 = <a class="code" href="group__pf__fold.html#gadc3db3d98742427e7001a7fd36ef28c2" title="Compute the partition function  of an RNA sequence.">pf_fold</a>(seq1, struct1);</div>
129 <div class="line">   <span class="comment">/* get the base pair probability matrix for the previous run of pf_fold() */</span></div>
130 <div class="line">   bppm = <a class="code" href="group__pf__fold.html#ga6d463707d5f64bdc4d21515b7dd9b115" title="Get a pointer to the base pair probability arrayAccessing the base pair probabilities for a pair (i...">export_bppm</a>();</div>
131 <div class="line">   pf1 = <a class="code" href="profiledist_8h.html#a8822fd5268be115c6e6cdc92009436cc" title="condense pair probability matrix into a vector containing probabilities for unpaired, upstream paired and downstream paired.">Make_bp_profile_bppm</a>(bppm, strlen(seq1));</div>
132 <div class="line"></div>
133 <div class="line">   e2 = <a class="code" href="group__pf__fold.html#gadc3db3d98742427e7001a7fd36ef28c2" title="Compute the partition function  of an RNA sequence.">pf_fold</a>(seq2, struct2);</div>
134 <div class="line">   <span class="comment">/* get the base pair probability matrix for the previous run of pf_fold() */</span></div>
135 <div class="line">   bppm = <a class="code" href="group__pf__fold.html#ga6d463707d5f64bdc4d21515b7dd9b115" title="Get a pointer to the base pair probability arrayAccessing the base pair probabilities for a pair (i...">export_bppm</a>();</div>
136 <div class="line">   pf2 = <a class="code" href="profiledist_8h.html#a8822fd5268be115c6e6cdc92009436cc" title="condense pair probability matrix into a vector containing probabilities for unpaired, upstream paired and downstream paired.">Make_bp_profile_bppm</a>(bppm, strlen(seq2));</div>
137 <div class="line"></div>
138 <div class="line">   <a class="code" href="group__pf__fold.html#gae73db3f49a94f0f72e067ecd12681dbd" title="Free arrays for the partition function recursions.">free_pf_arrays</a>();  <span class="comment">/* free space allocated for pf_fold() */</span></div>
139 <div class="line"></div>
140 <div class="line">   profile_dist = <a class="code" href="profiledist_8h.html#abe75e90e00a1e5dd8862944ed53dad5d" title="Align the 2 probability profiles T1, T2 .">profile_edit_distance</a>(pf1, pf2);</div>
141 <div class="line">   printf(<span class="stringliteral">&quot;%s  free energy=%5.2f\n%s  free energy=%5.2f  dist=%3.2f\n&quot;</span>,</div>
142 <div class="line">          aligned_line[0], e1, aligned_line[1], e2, profile_dist);</div>
143 <div class="line"></div>
144 <div class="line">   <a class="code" href="profiledist_8h.html#a9b0b84a5a45761bf42d7c835dcdb3b85" title="free space allocated in Make_bp_profile">free_profile</a>(pf1); <a class="code" href="profiledist_8h.html#a9b0b84a5a45761bf42d7c835dcdb3b85" title="free space allocated in Make_bp_profile">free_profile</a>(pf2);</div>
145 <div class="line">}</div>
146 </div><!-- fragment --><p>In a typical Unix environment you would compile this program using: </p>
147 <pre class="fragment">cc ${OPENMP_CFLAGS} -c example.c -I${hpath}
148 </pre><p> and link using </p>
149 <pre class="fragment">cc ${OPENMP_CFLAGS} -o example -L${lpath} -lRNA -lm
150 </pre><p> where <em>${hpath}</em> and <em>${lpath}</em> point to the location of the header files and library, respectively. </p>
151 <dl class="section note"><dt>Note:</dt><dd>As default, the RNAlib is compiled with build-in <em>OpenMP</em> multithreading support. Thus, when linking your own object files to the library you have to pass the compiler specific <em>${OPENMP_CFLAGS}</em> (e.g. '-fopenmp' for <b>gcc</b>) even if your code does not use openmp specific code. However, in that case the <em>OpenMP</em> flags may be ommited when compiling example.c </dd></dl>
152 </div></div><!-- contents -->
153 </div><!-- doc-content -->
154 <!-- start footer part -->
155 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
156   <ul>
157     <li class="footer">Generated on Wed Jul 24 2013 13:38:59 for RNAlib-2.1.2 by
158     <a href="http://www.doxygen.org/index.html">
159     <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.1.1 </li>
160   </ul>
161 </div>
162 </body>
163 </html>