RNAlib-2.2.1
constraints.h
Go to the documentation of this file.
1 #ifndef VIENNA_RNA_PACKAGE_CONSTRAINTS_H
2 #define VIENNA_RNA_PACKAGE_CONSTRAINTS_H
3 
4 #ifdef DEPRECATION_WARNINGS
5 # ifdef __GNUC__
6 # define DEPRECATED(func) func __attribute__ ((deprecated))
7 # else
8 # define DEPRECATED(func) func
9 # endif
10 #else
11 # define DEPRECATED(func) func
12 #endif
13 
14 
15 /* make this interface backward compatible with RNAlib < 2.2.0 */
16 #define VRNA_BACKWARD_COMPAT
17 
19 
46 typedef struct vrna_hc_s vrna_hc_t;
47 
51 typedef struct vrna_sc_s vrna_sc_t;
52 
66 typedef char (vrna_callback_hc_evaluate)(int i, int j, int k, int l, char d, void *data);
67 
81 typedef int (vrna_callback_sc_energy)(int i, int j, int k, int l, char d, void *data);
82 
96 typedef FLT_OR_DBL (vrna_callback_sc_exp_energy)(int i, int j, int k, int l, char d, void *data);
97 
111 typedef vrna_basepair_t *(vrna_callback_sc_backtrack)(int i, int j, int k, int l, char d, void *data);
112 
114 
126 #define VRNA_CONSTRAINT_DB_PIPE 1U
127 
136 #define VRNA_CONSTRAINT_DB_DOT 2U
137 
145 #define VRNA_CONSTRAINT_DB_X 4U
146 
154 #define VRNA_CONSTRAINT_DB_ANG_BRACK 8U
155 
163 #define VRNA_CONSTRAINT_DB_RND_BRACK 16U
164 
176 #define VRNA_CONSTRAINT_DB_INTRAMOL 2048U
177 
189 #define VRNA_CONSTRAINT_DB_INTERMOL 4096U
190 
199 #define VRNA_CONSTRAINT_DB_GQUAD 8192U
200 
211 #define VRNA_CONSTRAINT_DB_ENFORCE_BP 16384U
212 
219 #define VRNA_CONSTRAINT_MULTILINE 32U
220 
226 #define VRNA_CONSTRAINT_NO_HEADER 64U
227 
233 #define VRNA_CONSTRAINT_ALL 128U
234 
243 #define VRNA_CONSTRAINT_DB 256U
244 
253 #define VRNA_CONSTRAINT_FILE 512U
254 
261 #define VRNA_CONSTRAINT_SOFT_MFE 8192U
262 
269 #define VRNA_CONSTRAINT_SOFT_PF 16384U
270 
271 
278 #define VRNA_CONSTRAINT_CONTEXT_EXT_LOOP (char)0x01
279 
286 #define VRNA_CONSTRAINT_CONTEXT_HP_LOOP (char)0x02
287 
294 #define VRNA_CONSTRAINT_CONTEXT_INT_LOOP (char)0x04
295 
302 #define VRNA_CONSTRAINT_CONTEXT_INT_LOOP_ENC (char)0x08
303 
310 #define VRNA_CONSTRAINT_CONTEXT_MB_LOOP (char)0x10
311 
318 #define VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC (char)0x20
319 
320 #define VRNA_CONSTRAINT_CONTEXT_ENFORCE (char)0x40
321 
322 #define VRNA_CONSTRAINT_CONTEXT_NO_REMOVE (char)0x80
323 
330 #define VRNA_CONSTRAINT_CONTEXT_ALL_LOOPS (char)( VRNA_CONSTRAINT_CONTEXT_EXT_LOOP \
331  | VRNA_CONSTRAINT_CONTEXT_HP_LOOP \
332  | VRNA_CONSTRAINT_CONTEXT_INT_LOOP \
333  | VRNA_CONSTRAINT_CONTEXT_INT_LOOP_ENC \
334  | VRNA_CONSTRAINT_CONTEXT_MB_LOOP \
335  | VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC)
336 
343 #define VRNA_DECOMP_PAIR_HP 1
344 
351 #define VRNA_DECOMP_PAIR_IL 2
352 
357 #define VRNA_DECOMP_PAIR_ML 3
358 
363 #define VRNA_DECOMP_ML_ML_ML 5
364 
369 #define VRNA_DECOMP_ML_STEM 4
370 
375 #define VRNA_DECOMP_ML_ML 6
376 
381 #define VRNA_DECOMP_ML_UP 11
382 
387 #define VRNA_DECOMP_ML_COAXIAL 13
388 
393 #define VRNA_DECOMP_EXT_EXT 9
394 
399 #define VRNA_DECOMP_EXT_UP 8
400 
405 #define VRNA_DECOMP_EXT_STEM 14
406 
411 #define VRNA_DECOMP_EXT_EXT_EXT 15
412 
417 #define VRNA_DECOMP_EXT_STEM_EXT 16
418 
423 #define VRNA_DECOMP_EXT_STEM_OUTSIDE 17
424 
429 #define VRNA_DECOMP_EXT_EXT_STEM 18
430 
435 #define VRNA_DECOMP_EXT_EXT_STEM1 19
436 
441 #define VRNA_DECOMP_ML_ML_STEM 20
442 
468 struct vrna_hc_s {
469  char *matrix;
472  int *up_ext;
475  int *up_hp;
478  int *up_int;
481  int *up_ml;
489  void *data;
504 };
505 
511 struct vrna_sc_s {
512  int **energy_up;
513  int *energy_bp;
520  /* generalized soft contraints below */
538  void *data;
543 };
544 
567 void vrna_message_constraint_options(unsigned int option);
568 
580 
614  const char *constraint,
615  unsigned int options);
616 
632 
648  int i,
649  char option);
650 
668  int i,
669  int j,
670  char option);
671 
690  int i,
691  int d,
692  char option);
693 
705 void vrna_hc_free(vrna_hc_t *hc);
706 
707 #ifdef WITH_GEN_HC
708 
713 void vrna_hc_add_f( vrna_fold_compound_t *vc,
715 
716 void vrna_hc_add_data(vrna_fold_compound_t *vc,
717  void *data,
719 
720 #endif
721 
739 
750  const FLT_OR_DBL **constraints,
751  unsigned int options);
752 
763  const FLT_OR_DBL *constraints,
764  unsigned int options);
765 
776 
784 void vrna_sc_free(vrna_sc_t *sc);
785 
812  const double *reactivities,
813  double m,
814  double b,
815  unsigned int options);
816 
830  const char **shape_files,
831  const int *shape_file_association,
832  double m,
833  double b,
834  unsigned int options);
835 
857  const double *reactivities,
858  double b,
859  double default_value,
860  const char *shape_conversion,
861  unsigned int options);
862 
875 int vrna_sc_SHAPE_parse_method( const char *method_string,
876  char *method,
877  float *param_1,
878  float *param_2);
879 
894 int vrna_sc_SHAPE_to_pr(const char *shape_conversion,
895  double *values,
896  int length,
897  double default_value);
898 
899 void vrna_sc_add_data(vrna_fold_compound_t *vc,
900  void *data,
902 
919 
937 
955 
956 #ifdef VRNA_BACKWARD_COMPAT
957 
965 DEPRECATED(void print_tty_constraint(unsigned int option));
966 
973 DEPRECATED(void print_tty_constraint_full(void));
974 
987 DEPRECATED(void constrain_ptypes(const char *constraint, unsigned int length, char *ptype, int *BP, int min_loop_size, unsigned int idx_type));
988 
989 #endif
990 
991 #endif
void vrna_hc_add_up(vrna_fold_compound_t *vc, int i, char option)
Make a certain nucleotide unpaired.
int( vrna_callback_sc_energy)(int i, int j, int k, int l, char d, void *data)
Callback to retrieve pseudo energy contribution for soft constraint feature.
Definition: constraints.h:81
int vrna_sc_add_SHAPE_zarringhalam(vrna_fold_compound_t *vc, const double *reactivities, double b, double default_value, const char *shape_conversion, unsigned int options)
Add SHAPE reactivity data as soft constraints (Zarringhalam et al. method)
int vrna_sc_SHAPE_to_pr(const char *shape_conversion, double *values, int length, double default_value)
Convert SHAPE reactivity values to probabilities for being unpaired.
int * up_hp
A linear array that holds the number of allowed unpaired nucleotides in a hairpin loop...
Definition: constraints.h:475
void constrain_ptypes(const char *constraint, unsigned int length, char *ptype, int *BP, int min_loop_size, unsigned int idx_type)
Insert constraining pair types according to constraint structure string.
void vrna_sc_free(vrna_sc_t *sc)
Free memory occupied by a vrna_sc_t data structure.
void vrna_constraints_add(vrna_fold_compound_t *vc, const char *constraint, unsigned int options)
Add constraints to a vrna_fold_compound_t data structure.
void vrna_sc_add_up(vrna_fold_compound_t *vc, const FLT_OR_DBL *constraints, unsigned int options)
Add soft constraints for unpaired nucleotides.
void vrna_sc_add_bp(vrna_fold_compound_t *vc, const FLT_OR_DBL **constraints, unsigned int options)
Add soft constraints for paired nucleotides.
void print_tty_constraint_full(void)
Print structure constraint characters to stdout (full constraint support)
double FLT_OR_DBL
Typename for floating point number in partition function computations.
Definition: data_structures.h:39
The most basic data structure required by many functions throughout the RNAlib.
Definition: data_structures.h:389
char * matrix
Upper triangular matrix that encodes where a base pair or unpaired nucleotide is allowed.
Definition: constraints.h:469
int * energy_stack
Pseudo Energy contribution per base pair involved in a stack.
Definition: constraints.h:517
vrna_callback_sc_backtrack * bt
A function pointer used to obtain backtraced base pairs in loop regions that were altered by soft con...
Definition: constraints.h:526
void vrna_sc_add_f(vrna_fold_compound_t *vc, vrna_callback_sc_energy *f)
Bind a function pointer for generalized soft constraint feature (MFE version)
int * up_ml
A linear array that holds the number of allowed unpaired nucleotides in a multi branched loop...
Definition: constraints.h:481
vrna_callback_sc_energy * f
A function pointer used for pseudo energy contribution in MFE calculations.
Definition: constraints.h:521
void vrna_hc_add_bp(vrna_fold_compound_t *vc, int i, int j, char option)
Favorize/Enforce a certain base pair (i,j)
char( vrna_callback_hc_evaluate)(int i, int j, int k, int l, char d, void *data)
Callback to evaluate whether or not a particular decomposition step is contributing to the solution s...
Definition: constraints.h:66
void vrna_message_constraint_options_all(void)
Print structure constraint characters to stdout (full constraint support)
FLT_OR_DBL * exp_energy_bp
Boltzmann Factors of the energy contribution for base pairs.
Definition: constraints.h:515
Base pair data structure used in subopt.c.
Definition: data_structures.h:155
FLT_OR_DBL ** exp_energy_up
Boltzmann Factors of the energy contributions for unpaired sequence stretches.
Definition: constraints.h:514
The soft constraints data structure.
Definition: constraints.h:511
vrna_callback_hc_evaluate * f
A function pointer that returns whether or not a certain decomposition may be evaluated.
Definition: constraints.h:485
void * data
A pointer to some structure where the user may store necessary data to evaluate its generalized hard ...
Definition: constraints.h:489
void( vrna_callback_free_auxdata)(void *data)
Callback to free memory allocated for auxiliary user-provided data.
Definition: data_structures.h:51
vrna_callback_sc_exp_energy * exp_f
A function pointer used for pseudo energy contribution boltzmann factors in PF calculations.
Definition: constraints.h:532
The hard constraints data structure.
Definition: constraints.h:468
FLT_OR_DBL( vrna_callback_sc_exp_energy)(int i, int j, int k, int l, char d, void *data)
Callback to retrieve pseudo energy contribution as Boltzmann Factors for soft constraint feature...
Definition: constraints.h:96
int ** energy_up
Energy contribution for stretches of unpaired nucleotides.
Definition: constraints.h:512
vrna_basepair_t *( vrna_callback_sc_backtrack)(int i, int j, int k, int l, char d, void *data)
Callback to retrieve auxiliary base pairs for soft constraint feature.
Definition: constraints.h:111
int vrna_sc_add_SHAPE_deigan_ali(vrna_fold_compound_t *vc, const char **shape_files, const int *shape_file_association, double m, double b, unsigned int options)
Add SHAPE reactivity data from files as soft constraints for consensus structure prediction (Deigan e...
int * up_ext
A linear array that holds the number of allowed unpaired nucleotides in an exterior loop...
Definition: constraints.h:472
FLT_OR_DBL * exp_energy_stack
Boltzmann weighted pseudo energy contribution per nucleotide involved in a stack. ...
Definition: constraints.h:518
int * up_int
A linear array that holds the number of allowed unpaired nucleotides in an interior loop...
Definition: constraints.h:478
void vrna_sc_add_exp_f(vrna_fold_compound_t *vc, vrna_callback_sc_exp_energy *exp_f)
Bind a function pointer for generalized soft constraint feature (PF version)
void vrna_hc_add_bp_nonspecific(vrna_fold_compound_t *vc, int i, int d, char option)
Enforce a nucleotide to be paired (upstream/downstream)
void vrna_sc_init(vrna_fold_compound_t *vc)
Initialize an empty soft constraints data structure within a vrna_fold_compound_t.
void vrna_message_constraint_options(unsigned int option)
Print a help message for pseudo dot-bracket structure constraint characters to stdout. (constraint support is specified by option parameter)
vrna_callback_free_auxdata * free_data
A pointer to a function to free memory occupied by auxiliary data.
Definition: constraints.h:494
int * energy_bp
Energy contribution for base pairs.
Definition: constraints.h:513
void vrna_sc_remove(vrna_fold_compound_t *vc)
Remove soft constraints from vrna_fold_compound_t.
int vrna_sc_SHAPE_parse_method(const char *method_string, char *method, float *param_1, float *param_2)
Parse a character string and extract the encoded SHAPE reactivity conversion method and possibly the ...
void vrna_hc_init(vrna_fold_compound_t *vc)
Initialize/Reset hard constraints to default values.
void vrna_sc_add_bt(vrna_fold_compound_t *vc, vrna_callback_sc_backtrack *f)
Bind a backtracking function pointer for generalized soft constraint feature.
void vrna_hc_free(vrna_hc_t *hc)
Free the memory allocated by a vrna_hc_t data structure.
void print_tty_constraint(unsigned int option)
Print structure constraint characters to stdout. (constraint support is specified by option parameter...
void * data
A pointer to the data object provided for for pseudo energy contribution functions of the generalized...
Definition: constraints.h:538
int vrna_sc_add_SHAPE_deigan(vrna_fold_compound_t *vc, const double *reactivities, double m, double b, unsigned int options)
Add SHAPE reactivity data as soft constraints (Deigan et al. method)