RNAlib-2.4.4
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 # if defined(__clang__)
6 # define DEPRECATED(func, msg) func __attribute__ ((deprecated("", msg)))
7 # elif defined(__GNUC__)
8 # define DEPRECATED(func, msg) func __attribute__ ((deprecated(msg)))
9 # else
10 # define DEPRECATED(func, msg) func
11 # endif
12 #else
13 # define DEPRECATED(func, msg) func
14 #endif
15 
16 
23 
35 typedef struct vrna_hc_s vrna_hc_t;
36 
41 typedef struct vrna_hc_up_s vrna_hc_up_t;
42 
74 typedef unsigned char (vrna_callback_hc_evaluate)(int i,
75  int j,
76  int k,
77  int l,
78  unsigned char d,
79  void *data);
80 
86 #define VRNA_CONSTRAINT_NO_HEADER 0
87 
96 #define VRNA_CONSTRAINT_DB 16384U
97 
109 #define VRNA_CONSTRAINT_DB_ENFORCE_BP 32768U
110 
122 #define VRNA_CONSTRAINT_DB_PIPE 65536U
123 
132 #define VRNA_CONSTRAINT_DB_DOT 131072U
133 
141 #define VRNA_CONSTRAINT_DB_X 262144U
142 
148 #define VRNA_CONSTRAINT_DB_ANG_BRACK 524288U
149 
157 #define VRNA_CONSTRAINT_DB_RND_BRACK 1048576U
158 
170 #define VRNA_CONSTRAINT_DB_INTRAMOL 2097152U
171 
183 #define VRNA_CONSTRAINT_DB_INTERMOL 4194304U
184 
195 #define VRNA_CONSTRAINT_DB_GQUAD 8388608U
196 
197 #define VRNA_CONSTRAINT_DB_CANONICAL_BP 16777216U
198 
209 #define VRNA_CONSTRAINT_DB_WUSS 33554432U
210 
211 
223 #define VRNA_CONSTRAINT_DB_DEFAULT \
224  (VRNA_CONSTRAINT_DB \
225  | VRNA_CONSTRAINT_DB_PIPE \
226  | VRNA_CONSTRAINT_DB_DOT \
227  | VRNA_CONSTRAINT_DB_X \
228  | VRNA_CONSTRAINT_DB_ANG_BRACK \
229  | VRNA_CONSTRAINT_DB_RND_BRACK \
230  | VRNA_CONSTRAINT_DB_INTRAMOL \
231  | VRNA_CONSTRAINT_DB_INTERMOL \
232  | VRNA_CONSTRAINT_DB_GQUAD \
233  )
234 
241 #define VRNA_CONSTRAINT_CONTEXT_EXT_LOOP (unsigned char)0x01
242 
249 #define VRNA_CONSTRAINT_CONTEXT_HP_LOOP (unsigned char)0x02
250 
257 #define VRNA_CONSTRAINT_CONTEXT_INT_LOOP (unsigned char)0x04
258 
265 #define VRNA_CONSTRAINT_CONTEXT_INT_LOOP_ENC (unsigned char)0x08
266 
273 #define VRNA_CONSTRAINT_CONTEXT_MB_LOOP (unsigned char)0x10
274 
281 #define VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC (unsigned char)0x20
282 
286 #define VRNA_CONSTRAINT_CONTEXT_ENFORCE (unsigned char)0x40
287 
291 #define VRNA_CONSTRAINT_CONTEXT_NO_REMOVE (unsigned char)0x80
292 
293 
297 #define VRNA_CONSTRAINT_CONTEXT_NONE (unsigned char)0
298 
302 #define VRNA_CONSTRAINT_CONTEXT_CLOSING_LOOPS (unsigned char)(VRNA_CONSTRAINT_CONTEXT_EXT_LOOP | \
303  VRNA_CONSTRAINT_CONTEXT_HP_LOOP | \
304  VRNA_CONSTRAINT_CONTEXT_INT_LOOP | \
305  VRNA_CONSTRAINT_CONTEXT_MB_LOOP)
306 
310 #define VRNA_CONSTRAINT_CONTEXT_ENCLOSED_LOOPS (unsigned char)(VRNA_CONSTRAINT_CONTEXT_INT_LOOP_ENC | \
311  VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC)
312 
319 #define VRNA_CONSTRAINT_CONTEXT_ALL_LOOPS (unsigned char)(VRNA_CONSTRAINT_CONTEXT_CLOSING_LOOPS | \
320  VRNA_CONSTRAINT_CONTEXT_ENCLOSED_LOOPS)
321 
322 
329 typedef enum {
336 
337 
341 typedef struct {
342  int interval_start;
343  int interval_end;
344  unsigned char loop_type;
345  unsigned char replace : 1;
347 
372 struct vrna_hc_s {
373  vrna_hc_type_e type;
374  unsigned int n;
375 
376 #ifndef VRNA_DISABLE_C11_FEATURES
377  /* C11 support for unnamed unions/structs */
378  union {
379  struct {
380 #endif
381  unsigned char *matrix;
384 #ifndef VRNA_DISABLE_C11_FEATURES
385  };
386  struct {
387 #endif
388  unsigned char **matrix_local;
389  unsigned char *up_storage;
390  vrna_hc_bp_storage_t **bp_storage;
391 #ifndef VRNA_DISABLE_C11_FEATURES
392  };
393  };
394 #endif
395 
396  int *up_ext;
399  int *up_hp;
402  int *up_int;
405  int *up_ml;
413  void *data;
428 };
429 
435 struct vrna_hc_up_s {
436  int position;
437  unsigned char options;
438 };
439 
462 void vrna_message_constraint_options(unsigned int option);
463 
464 
476 
477 
493 
494 
495 void vrna_hc_init_window(vrna_fold_compound_t *vc);
496 
497 
498 void
499 vrna_hc_update(vrna_fold_compound_t *fc,
500  unsigned int i);
501 
502 
518  int i,
519  unsigned char option);
520 
521 
531 int
533  vrna_hc_up_t *constraints);
534 
535 
553  int i,
554  int j,
555  unsigned char option);
556 
557 
576  int i,
577  int d,
578  unsigned char option);
579 
580 
592 void vrna_hc_free(vrna_hc_t *hc);
593 
594 
601 
602 
615  void *data,
617 
618 
637 int
639  const char *constraint,
640  unsigned int options);
641 
642 
643 #ifndef VRNA_DISABLE_BACKWARD_COMPATIBILITY
644 
652 DEPRECATED(void print_tty_constraint(unsigned int option),
653  "Use vrna_message_constraint_options() instead");
654 
661 DEPRECATED(void print_tty_constraint_full(void),
662  "Use vrna_message_constraint_options_all() instead");
663 
676 DEPRECATED(void constrain_ptypes(const char *constraint,
677  unsigned int length,
678  char *ptype,
679  int *BP,
680  int min_loop_size,
681  unsigned int idx_type),
682  "Use the new API and the hard constraint framework instead");
683 
684 #endif
685 
686 #endif
unsigned char options
The hard constraint option.
Definition: constraints_hard.h:437
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:399
vrna_hc_type_e
The hard constraints type.
Definition: constraints_hard.h:329
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: fold_compound.h:131
void print_tty_constraint_full(void)
Print structure constraint characters to stdout (full constraint support)
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:405
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.
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:74
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:331
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:435
vrna_callback_hc_evaluate * f
A function pointer that returns whether or not a certain decomposition may be evaluated.
Definition: constraints_hard.h:409
void * data
A pointer to some structure where the user may store necessary data to evaluate its generic hard cons...
Definition: constraints_hard.h:413
unsigned char * matrix
Upper triangular matrix that encodes where a base pair or unpaired nucleotide is allowed.
Definition: constraints_hard.h:381
The hard constraints data structure.
Definition: constraints_hard.h:372
int * up_ext
A linear array that holds the number of allowed unpaired nucleotides in an exterior loop...
Definition: constraints_hard.h:396
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.
void() vrna_callback_free_auxdata(void *data)
Callback to free memory allocated for auxiliary user-provided data.
Definition: fold_compound.h:46
int * up_int
A linear array that holds the number of allowed unpaired nucleotides in an interior loop...
Definition: constraints_hard.h:402
A base pair hard constraint.
Definition: constraints_hard.h:341
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:418
Default Hard Constraints.
Definition: constraints_hard.h:330
int position
The sequence position (1-based)
Definition: constraints_hard.h:436
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.