1 #include <stdlib.h>
2 #include <stdio.h>
3 
4 #include <ViennaRNA/fold_compound.h>
5 #include <ViennaRNA/utils/basic.h>
6 #include <ViennaRNA/utils/strings.h>
7 #include <ViennaRNA/constraints/soft.h>
8 #include <ViennaRNA/mfe.h>
9 
10 int
main()11 main()
12 {
13   /* initialize random number generator */
14   vrna_init_rand();
15 
16   /* Generate a random sequence of 50 nucleotides */
17   char                  *seq = vrna_random_string(50, "ACGU");
18 
19   /* Create a fold compound for the sequence */
20   vrna_fold_compound_t  *fc = vrna_fold_compound(seq, NULL, VRNA_OPTION_DEFAULT);
21 
22   /* Add soft constraint of -1.7 kcal/mol to nucleotide 5 whenever it appears in an unpaired context */
23   vrna_sc_add_up(fc, 5, -1.7, VRNA_OPTION_DEFAULT);
24 
25   /* allocate memory for MFE structure (length + 1) */
26   char  *structure = (char *)vrna_alloc(sizeof(char) * 51);
27 
28   /* predict Minmum Free Energy and corresponding secondary structure */
29   float mfe = vrna_mfe(fc, structure);
30 
31   /* print seqeunce, structure and MFE */
32   printf("%s\n%s [ %6.2f ]\n", seq, structure, mfe);
33 
34   /* cleanup memory */
35   free(seq);
36   free(structure);
37   vrna_fold_compound_free(fc);
38 
39   return 0;
40 }
41