RNAlib-2.4.18
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 
34 typedef struct vrna_hc_s vrna_hc_t;
35 
40 typedef struct vrna_hc_up_s vrna_hc_up_t;
41 
42 typedef struct vrna_hc_depot_s vrna_hc_depot_t;
43 
46 
78 typedef unsigned char (vrna_callback_hc_evaluate)(int i,
79  int j,
80  int k,
81  int l,
82  unsigned char d,
83  void *data);
84 
90 #define VRNA_CONSTRAINT_NO_HEADER 0
91 
100 #define VRNA_CONSTRAINT_DB 16384U
101 
113 #define VRNA_CONSTRAINT_DB_ENFORCE_BP 32768U
114 
126 #define VRNA_CONSTRAINT_DB_PIPE 65536U
127 
136 #define VRNA_CONSTRAINT_DB_DOT 131072U
145 #define VRNA_CONSTRAINT_DB_X 262144U
152 #define VRNA_CONSTRAINT_DB_ANG_BRACK 524288U
161 #define VRNA_CONSTRAINT_DB_RND_BRACK 1048576U
162 
174 #define VRNA_CONSTRAINT_DB_INTRAMOL 2097152U
175 
187 #define VRNA_CONSTRAINT_DB_INTERMOL 4194304U
188 
199 #define VRNA_CONSTRAINT_DB_GQUAD 8388608U
200 
201 #define VRNA_CONSTRAINT_DB_CANONICAL_BP 16777216U
202 
211 #define VRNA_CONSTRAINT_DB_WUSS 33554432U
212 
213 
225 #define VRNA_CONSTRAINT_DB_DEFAULT \
226  (VRNA_CONSTRAINT_DB \
227  | VRNA_CONSTRAINT_DB_PIPE \
228  | VRNA_CONSTRAINT_DB_DOT \
229  | VRNA_CONSTRAINT_DB_X \
230  | VRNA_CONSTRAINT_DB_ANG_BRACK \
231  | VRNA_CONSTRAINT_DB_RND_BRACK \
232  | VRNA_CONSTRAINT_DB_INTRAMOL \
233  | VRNA_CONSTRAINT_DB_INTERMOL \
234  | VRNA_CONSTRAINT_DB_GQUAD \
235  )
236 
243 #define VRNA_CONSTRAINT_CONTEXT_EXT_LOOP (unsigned char)0x01
244 
251 #define VRNA_CONSTRAINT_CONTEXT_HP_LOOP (unsigned char)0x02
252 
259 #define VRNA_CONSTRAINT_CONTEXT_INT_LOOP (unsigned char)0x04
260 
267 #define VRNA_CONSTRAINT_CONTEXT_INT_LOOP_ENC (unsigned char)0x08
268 
275 #define VRNA_CONSTRAINT_CONTEXT_MB_LOOP (unsigned char)0x10
276 
283 #define VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC (unsigned char)0x20
284 
288 #define VRNA_CONSTRAINT_CONTEXT_ENFORCE (unsigned char)0x40
289 
293 #define VRNA_CONSTRAINT_CONTEXT_NO_REMOVE (unsigned char)0x80
294 
295 
299 #define VRNA_CONSTRAINT_CONTEXT_NONE (unsigned char)0
300 
304 #define VRNA_CONSTRAINT_CONTEXT_CLOSING_LOOPS (unsigned char)(VRNA_CONSTRAINT_CONTEXT_EXT_LOOP | \
305  VRNA_CONSTRAINT_CONTEXT_HP_LOOP | \
306  VRNA_CONSTRAINT_CONTEXT_INT_LOOP | \
307  VRNA_CONSTRAINT_CONTEXT_MB_LOOP)
308 
312 #define VRNA_CONSTRAINT_CONTEXT_ENCLOSED_LOOPS (unsigned char)(VRNA_CONSTRAINT_CONTEXT_INT_LOOP_ENC | \
313  VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC)
314 
321 #define VRNA_CONSTRAINT_CONTEXT_ALL_LOOPS (unsigned char)(VRNA_CONSTRAINT_CONTEXT_CLOSING_LOOPS | \
322  VRNA_CONSTRAINT_CONTEXT_ENCLOSED_LOOPS)
323 
324 
325 #define VRNA_CONSTRAINT_WINDOW_UPDATE_5 1U
326 
327 #define VRNA_CONSTRAINT_WINDOW_UPDATE_3 2U
328 
335 typedef enum {
342 
343 
368 struct vrna_hc_s {
369  vrna_hc_type_e type;
370  unsigned int n;
371 
372  unsigned char state;
373 
374 #ifndef VRNA_DISABLE_C11_FEATURES
375  /* C11 support for unnamed unions/structs */
376  union {
377  struct {
378 #endif
379  unsigned char *mx;
380 #ifndef VRNA_DISABLE_C11_FEATURES
381  };
382  struct {
383 #endif
384  unsigned char **matrix_local;
385 #ifndef VRNA_DISABLE_C11_FEATURES
386  };
387  };
388 #endif
389 
390  int *up_ext;
393  int *up_hp;
396  int *up_int;
399  int *up_ml;
407  void *data;
423  vrna_hc_depot_t *depot;
424 };
425 
431 struct vrna_hc_up_s {
432  int position;
433  int strand;
434  unsigned char options;
435 };
436 
459 void vrna_message_constraint_options(unsigned int option);
460 
461 
473 
474 
490 
491 
492 void vrna_hc_init_window(vrna_fold_compound_t *vc);
493 
494 
495 int
496 vrna_hc_prepare(vrna_fold_compound_t *fc,
497  unsigned int options);
498 
499 void
500 vrna_hc_update(vrna_fold_compound_t *fc,
501  unsigned int i,
502  unsigned int options);
503 
504 
520  int i,
521  unsigned char option);
522 
523 
524 int
525 vrna_hc_add_up_strand(vrna_fold_compound_t *fc,
526  unsigned int i,
527  unsigned int strand,
528  unsigned char option);
529 
539 int
541  vrna_hc_up_t *constraints);
542 
543 int
544 vrna_hc_add_up_strand_batch(vrna_fold_compound_t *fc,
545  vrna_hc_up_t *constraints);
546 
564  int i,
565  int j,
566  unsigned char option);
567 
568 
569 int
570 vrna_hc_add_bp_strand(vrna_fold_compound_t *fc,
571  unsigned int i,
572  unsigned int strand_i,
573  unsigned int j,
574  unsigned int strand_j,
575  unsigned char option);
576 
595  int i,
596  int d,
597  unsigned char option);
598 
599 
612 
613 
620 
621 
634  void *data,
636 
637 
656 int
658  const char *constraint,
659  unsigned int options);
660 
661 
662 #ifndef VRNA_DISABLE_BACKWARD_COMPATIBILITY
663 
671 DEPRECATED(void print_tty_constraint(unsigned int option),
672  "Use vrna_message_constraint_options() instead");
673 
680 DEPRECATED(void print_tty_constraint_full(void),
681  "Use vrna_message_constraint_options_all() instead");
682 
695 DEPRECATED(void constrain_ptypes(const char *constraint,
696  unsigned int length,
697  char *ptype,
698  int *BP,
699  int min_loop_size,
700  unsigned int idx_type),
701  "Use the new API and the hard constraint framework instead");
702 
703 #endif
704 
705 #endif
Functions and data structures for constraining secondary structure predictions and evaluation.
The Basic Fold Compound API.
void vrna_message_constraint_options(unsigned int option)
Print a help message for pseudo dot-bracket structure constraint characters to stdout....
void vrna_message_constraint_options_all(void)
Print structure constraint characters to stdout (full constraint support)
void() vrna_callback_free_auxdata(void *data)
Callback to free memory allocated for auxiliary user-provided data.
Definition: fold_compound.h:46
The most basic data structure required by many functions throughout the RNAlib.
Definition: fold_compound.h:137
int * up_int
A linear array that holds the number of allowed unpaired nucleotides in an interior loop.
Definition: hard.h:396
unsigned char options
The hard constraint option
Definition: hard.h:434
int * up_ext
A linear array that holds the number of allowed unpaired nucleotides in an exterior loop.
Definition: hard.h:390
int position
The sequence position (1-based)
Definition: hard.h:432
int * up_hp
A linear array that holds the number of allowed unpaired nucleotides in a hairpin loop.
Definition: hard.h:393
vrna_callback_hc_evaluate * f
A function pointer that returns whether or not a certain decomposition may be evaluated.
Definition: hard.h:403
vrna_callback_free_auxdata * free_data
A pointer to a function to free memory occupied by auxiliary data.
Definition: hard.h:412
int * up_ml
A linear array that holds the number of allowed unpaired nucleotides in a multi branched loop.
Definition: hard.h:399
void * data
A pointer to some structure where the user may store necessary data to evaluate its generic hard cons...
Definition: hard.h:407
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.
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 vrna_hc_add_from_db(vrna_fold_compound_t *vc, const char *constraint, unsigned int options)
Add hard constraints from pseudo dot-bracket notation.
void vrna_hc_free(vrna_hc_t *hc)
Free the memory allocated by a vrna_hc_t data structure.
int vrna_hc_add_bp(vrna_fold_compound_t *vc, int i, int j, unsigned char option)
Favorize/Enforce a certain base pair (i,j)
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: hard.h:78
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)
The hard constraints data structure.
Definition: hard.h:368
A single hard constraint for a single nucleotide.
Definition: hard.h:431
vrna_hc_type_e
The hard constraints type.
Definition: hard.h:335
@ VRNA_HC_DEFAULT
Default Hard Constraints.
Definition: hard.h:336
@ VRNA_HC_WINDOW
Hard Constraints suitable for local structure prediction using window approach.
Definition: hard.h:337
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 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 print_tty_constraint(unsigned int option)
Print structure constraint characters to stdout. (constraint support is specified by option parameter...
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.