RNAlib-2.4.0
constraints_hard.h
Go to the documentation of this file.
1 #ifndef VIENNA_RNA_PACKAGE_CONSTRAINTS_HARD_H
2 #define VIENNA_RNA_PACKAGE_CONSTRAINTS_HARD_H
3 
4 #ifdef VRNA_WARN_DEPRECATED
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 
24 
36 typedef struct vrna_hc_s vrna_hc_t;
37 
42 typedef struct vrna_hc_up_s vrna_hc_up_t;
43 
75 typedef unsigned char (vrna_callback_hc_evaluate)(int i,
76  int j,
77  int k,
78  int l,
79  unsigned char d,
80  void *data);
81 
87 #define VRNA_CONSTRAINT_NO_HEADER 0
88 
97 #define VRNA_CONSTRAINT_DB 16384U
98 
110 #define VRNA_CONSTRAINT_DB_ENFORCE_BP 32768U
111 
123 #define VRNA_CONSTRAINT_DB_PIPE 65536U
124 
133 #define VRNA_CONSTRAINT_DB_DOT 131072U
134 
142 #define VRNA_CONSTRAINT_DB_X 262144U
143 
149 #define VRNA_CONSTRAINT_DB_ANG_BRACK 524288U
150 
158 #define VRNA_CONSTRAINT_DB_RND_BRACK 1048576U
159 
171 #define VRNA_CONSTRAINT_DB_INTRAMOL 2097152U
172 
184 #define VRNA_CONSTRAINT_DB_INTERMOL 4194304U
185 
196 #define VRNA_CONSTRAINT_DB_GQUAD 8388608U
197 
198 #define VRNA_CONSTRAINT_DB_CANONICAL_BP 16777216U
199 
210 #define VRNA_CONSTRAINT_DB_DEFAULT \
211  (VRNA_CONSTRAINT_DB \
212  | VRNA_CONSTRAINT_DB_PIPE \
213  | VRNA_CONSTRAINT_DB_DOT \
214  | VRNA_CONSTRAINT_DB_X \
215  | VRNA_CONSTRAINT_DB_ANG_BRACK \
216  | VRNA_CONSTRAINT_DB_RND_BRACK \
217  | VRNA_CONSTRAINT_DB_INTRAMOL \
218  | VRNA_CONSTRAINT_DB_INTERMOL \
219  | VRNA_CONSTRAINT_DB_GQUAD \
220  )
221 
228 #define VRNA_CONSTRAINT_CONTEXT_EXT_LOOP (unsigned char)0x01
229 
236 #define VRNA_CONSTRAINT_CONTEXT_HP_LOOP (unsigned char)0x02
237 
244 #define VRNA_CONSTRAINT_CONTEXT_INT_LOOP (unsigned char)0x04
245 
252 #define VRNA_CONSTRAINT_CONTEXT_INT_LOOP_ENC (unsigned char)0x08
253 
260 #define VRNA_CONSTRAINT_CONTEXT_MB_LOOP (unsigned char)0x10
261 
268 #define VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC (unsigned char)0x20
269 
273 #define VRNA_CONSTRAINT_CONTEXT_ENFORCE (unsigned char)0x40
274 
278 #define VRNA_CONSTRAINT_CONTEXT_NO_REMOVE (unsigned char)0x80
279 
286 #define VRNA_CONSTRAINT_CONTEXT_ALL_LOOPS (unsigned char)(VRNA_CONSTRAINT_CONTEXT_EXT_LOOP \
287  | VRNA_CONSTRAINT_CONTEXT_HP_LOOP \
288  | VRNA_CONSTRAINT_CONTEXT_INT_LOOP \
289  | VRNA_CONSTRAINT_CONTEXT_INT_LOOP_ENC \
290  | VRNA_CONSTRAINT_CONTEXT_MB_LOOP \
291  | VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC)
292 
299 typedef enum {
306 
307 
311 typedef struct {
312  int interval_start;
313  int interval_end;
314  unsigned char loop_type;
316 
341 struct vrna_hc_s {
342  vrna_hc_type_e type;
343  unsigned int n;
344 
345 #ifndef VRNA_DISABLE_C11_FEATURES
346  /* C11 support for unnamed unions/structs */
347  union {
348  struct {
349 #endif
350  unsigned char *matrix;
353 #ifndef VRNA_DISABLE_C11_FEATURES
354  };
355  struct {
356 #endif
357  unsigned char **matrix_local;
358  unsigned char *up_storage;
359  vrna_hc_bp_storage_t **bp_storage;
360 #ifndef VRNA_DISABLE_C11_FEATURES
361  };
362  };
363 #endif
364 
365  int *up_ext;
368  int *up_hp;
371  int *up_int;
374  int *up_ml;
382  void *data;
397 };
398 
404 struct vrna_hc_up_s {
405  int position;
406  unsigned char options;
407 };
408 
431 void vrna_message_constraint_options(unsigned int option);
432 
433 
445 
446 
462 
463 
464 void vrna_hc_init_window(vrna_fold_compound_t *vc);
465 
466 
467 void
468 vrna_hc_update(vrna_fold_compound_t *vc,
469  int i);
470 
471 
487  int i,
488  unsigned char option);
489 
490 
500 int
502  vrna_hc_up_t *constraints);
503 
504 
522  int i,
523  int j,
524  unsigned char option);
525 
526 
545  int i,
546  int d,
547  unsigned char option);
548 
549 
561 void vrna_hc_free(vrna_hc_t *hc);
562 
563 
570 
571 
584  void *data,
586 
587 
606 int
608  const char *constraint,
609  unsigned int options);
610 
611 
612 #ifdef VRNA_BACKWARD_COMPAT
613 
621 DEPRECATED(void print_tty_constraint(unsigned int option));
622 
629 DEPRECATED(void print_tty_constraint_full(void));
630 
643 DEPRECATED(void constrain_ptypes(const char *constraint,
644  unsigned int length,
645  char *ptype,
646  int *BP,
647  int min_loop_size,
648  unsigned int idx_type));
649 
650 #endif
651 
652 #endif
unsigned char options
The hard constraint option.
Definition: constraints_hard.h:406
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.
int * up_hp
A linear array that holds the number of allowed unpaired nucleotides in a hairpin loop...
Definition: constraints_hard.h:368
vrna_hc_type_e
The hard constraints type.
Definition: constraints_hard.h:299
int vrna_hc_add_from_db(vrna_fold_compound_t *vc, const char *constraint, unsigned int options)
Add hard constraints from pseudo dot-bracket notation.
The most basic data structure required by many functions throughout the RNAlib.
Definition: data_structures.h:463
void print_tty_constraint_full(void)
Print structure constraint characters to stdout (full constraint support)
unsigned char( vrna_callback_hc_evaluate)(int i, int j, int k, int l, unsigned char d, void *data)
Callback to evaluate whether or not a particular decomposition step is contributing to the solution s...
Definition: constraints_hard.h:75
void vrna_hc_add_f(vrna_fold_compound_t *vc, vrna_callback_hc_evaluate *f)
Add a function pointer pointer for the generic hard constraint feature.
int * up_ml
A linear array that holds the number of allowed unpaired nucleotides in a multi branched loop...
Definition: constraints_hard.h:374
void vrna_hc_add_data(vrna_fold_compound_t *vc, void *data, vrna_callback_free_auxdata *f)
Add an auxiliary data structure for the generic hard constraints callback function.
void vrna_hc_add_bp_nonspecific(vrna_fold_compound_t *vc, int i, int d, unsigned char option)
Enforce a nucleotide to be paired (upstream/downstream)
Hard Constraints suitable for local structure prediction using window approach.
Definition: constraints_hard.h:301
void vrna_message_constraint_options_all(void)
Print structure constraint characters to stdout (full constraint support)
Various data structures and pre-processor macros.
A single hard constraint for a single nucleotide.
Definition: constraints_hard.h:404
vrna_callback_hc_evaluate * f
A function pointer that returns whether or not a certain decomposition may be evaluated.
Definition: constraints_hard.h:378
void * data
A pointer to some structure where the user may store necessary data to evaluate its generic hard cons...
Definition: constraints_hard.h:382
unsigned char * matrix
Upper triangular matrix that encodes where a base pair or unpaired nucleotide is allowed.
Definition: constraints_hard.h:350
void( vrna_callback_free_auxdata)(void *data)
Callback to free memory allocated for auxiliary user-provided data.
Definition: data_structures.h:71
The hard constraints data structure.
Definition: constraints_hard.h:341
int * up_ext
A linear array that holds the number of allowed unpaired nucleotides in an exterior loop...
Definition: constraints_hard.h:365
int vrna_hc_add_up_batch(vrna_fold_compound_t *vc, vrna_hc_up_t *constraints)
Apply a list of hard constraints for single nucleotides.
int * up_int
A linear array that holds the number of allowed unpaired nucleotides in an interior loop...
Definition: constraints_hard.h:371
A base pair hard constraint.
Definition: constraints_hard.h:311
void print_tty_constraint(unsigned int option)
Print structure constraint characters to stdout. (constraint support is specified by option parameter...
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)
void vrna_hc_add_bp(vrna_fold_compound_t *vc, int i, int j, unsigned char option)
Favorize/Enforce a certain base pair (i,j)
vrna_callback_free_auxdata * free_data
A pointer to a function to free memory occupied by auxiliary data.
Definition: constraints_hard.h:387
Default Hard Constraints.
Definition: constraints_hard.h:300
int position
The sequence position (1-based)
Definition: constraints_hard.h:405
void vrna_hc_init(vrna_fold_compound_t *vc)
Initialize/Reset hard constraints to default values.
void vrna_hc_add_up(vrna_fold_compound_t *vc, int i, unsigned char option)
Make a certain nucleotide unpaired.
void vrna_hc_free(vrna_hc_t *hc)
Free the memory allocated by a vrna_hc_t data structure.