1 /*
2  *                minimum free energy
3  *                RNA secondary structure prediction
4  *                with maximum distance base pairs
5  *
6  *                c Ivo Hofacker, Peter Stadler
7  *
8  *                ViennaRNA package
9  */
10 
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
14 
15 #ifndef VRNA_DISABLE_BACKWARD_COMPATIBILITY
16 
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <ctype.h>
20 
21 #include "ViennaRNA/utils/basic.h"
22 #include "ViennaRNA/datastructures/basic.h"
23 #include "ViennaRNA/mfe_window.h"
24 #include "ViennaRNA/Lfold.h"
25 
26 
27 /*
28  #################################
29  # BEGIN OF FUNCTION DEFINITIONS #
30  #################################
31  */
32 
33 
34 /*###########################################*/
35 /*# deprecated functions below              #*/
36 /*###########################################*/
37 
38 PUBLIC float
Lfold(const char * string,const char * structure,int window_size)39 Lfold(const char  *string,
40       const char  *structure,
41       int         window_size)
42 {
43   float                 energy;
44   vrna_fold_compound_t  *vc;
45   vrna_md_t             md;
46 
47   set_model_details(&md);
48 
49   md.window_size  = window_size;
50   md.max_bp_span  = window_size;
51 
52   vc = vrna_fold_compound(string, &md, VRNA_OPTION_WINDOW);
53 
54   energy = vrna_mfe_window(vc, NULL);
55 
56   vrna_fold_compound_free(vc);
57 
58   return energy;
59 }
60 
61 
62 #ifdef VRNA_WITH_SVM
63 
64 PUBLIC float
Lfoldz(const char * string,const char * structure,int window_size,int zsc,double min_z)65 Lfoldz(const char *string,
66        const char *structure,
67        int        window_size,
68        int        zsc,
69        double     min_z)
70 {
71   float                 energy;
72   vrna_fold_compound_t  *vc;
73   vrna_md_t             md;
74 
75   set_model_details(&md);
76 
77   md.window_size  = window_size;
78   md.max_bp_span  = window_size;
79 
80   vc = vrna_fold_compound(string, &md, VRNA_OPTION_WINDOW);
81 
82   energy = (zsc) ? vrna_mfe_window_zscore(vc, min_z, NULL) : vrna_mfe_window(vc, NULL);
83 
84   vrna_fold_compound_free(vc);
85 
86   return energy;
87 }
88 
89 
90 #endif
91 
92 
93 PUBLIC float
aliLfold(const char * AS[],const char * structure,int maxdist)94 aliLfold(const char *AS[],
95          const char *structure,
96          int        maxdist)
97 {
98   float                 en;
99   vrna_fold_compound_t  *fc;
100   vrna_md_t             md;
101 
102   set_model_details(&md);
103 
104   md.max_bp_span = md.window_size = maxdist;
105 
106   fc = vrna_fold_compound_comparative((const char **)AS, &md, VRNA_OPTION_MFE | VRNA_OPTION_WINDOW);
107 
108   en = vrna_mfe_window(fc, NULL);
109 
110   vrna_fold_compound_free(fc);
111 
112   return en;
113 }
114 
115 
116 PUBLIC float
aliLfold_cb(const char ** AS,int maxdist,vrna_mfe_window_callback * cb,void * data)117 aliLfold_cb(const char                **AS,
118             int                       maxdist,
119             vrna_mfe_window_callback  *cb,
120             void                      *data)
121 {
122   float                 en;
123   vrna_fold_compound_t  *fc;
124   vrna_md_t             md;
125 
126   set_model_details(&md);
127 
128   md.max_bp_span = md.window_size = maxdist;
129 
130   fc = vrna_fold_compound_comparative(AS, &md, VRNA_OPTION_MFE | VRNA_OPTION_WINDOW);
131 
132   en = vrna_mfe_window_cb(fc, cb, data);
133 
134   vrna_fold_compound_free(fc);
135 
136   return en;
137 }
138 
139 
140 #endif
141