RNAlib-2.4.15
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 
24 
36 typedef struct vrna_hc_s vrna_hc_t;
37 
42 typedef struct vrna_hc_up_s vrna_hc_up_t;
43 
44 typedef struct vrna_hc_depot_s vrna_hc_depot_t;
45 
77 typedef unsigned char (vrna_callback_hc_evaluate)(int i,
78  int j,
79  int k,
80  int l,
81  unsigned char d,
82  void *data);
83 
89 #define VRNA_CONSTRAINT_NO_HEADER 0
90 
99 #define VRNA_CONSTRAINT_DB 16384U
100 
112 #define VRNA_CONSTRAINT_DB_ENFORCE_BP 32768U
113 
125 #define VRNA_CONSTRAINT_DB_PIPE 65536U
126 
135 #define VRNA_CONSTRAINT_DB_DOT 131072U
136 
144 #define VRNA_CONSTRAINT_DB_X 262144U
145 
151 #define VRNA_CONSTRAINT_DB_ANG_BRACK 524288U
152 
160 #define VRNA_CONSTRAINT_DB_RND_BRACK 1048576U
161 
173 #define VRNA_CONSTRAINT_DB_INTRAMOL 2097152U
174 
186 #define VRNA_CONSTRAINT_DB_INTERMOL 4194304U
187 
198 #define VRNA_CONSTRAINT_DB_GQUAD 8388608U
199 
200 #define VRNA_CONSTRAINT_DB_CANONICAL_BP 16777216U
201 
210 #define VRNA_CONSTRAINT_DB_WUSS 33554432U
211 
212 
224 #define VRNA_CONSTRAINT_DB_DEFAULT \
225  (VRNA_CONSTRAINT_DB \
226  | VRNA_CONSTRAINT_DB_PIPE \
227  | VRNA_CONSTRAINT_DB_DOT \
228  | VRNA_CONSTRAINT_DB_X \
229  | VRNA_CONSTRAINT_DB_ANG_BRACK \
230  | VRNA_CONSTRAINT_DB_RND_BRACK \
231  | VRNA_CONSTRAINT_DB_INTRAMOL \
232  | VRNA_CONSTRAINT_DB_INTERMOL \
233  | VRNA_CONSTRAINT_DB_GQUAD \
234  )
235 
242 #define VRNA_CONSTRAINT_CONTEXT_EXT_LOOP (unsigned char)0x01
243 
250 #define VRNA_CONSTRAINT_CONTEXT_HP_LOOP (unsigned char)0x02
251 
258 #define VRNA_CONSTRAINT_CONTEXT_INT_LOOP (unsigned char)0x04
259 
266 #define VRNA_CONSTRAINT_CONTEXT_INT_LOOP_ENC (unsigned char)0x08
267 
274 #define VRNA_CONSTRAINT_CONTEXT_MB_LOOP (unsigned char)0x10
275 
282 #define VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC (unsigned char)0x20
283 
287 #define VRNA_CONSTRAINT_CONTEXT_ENFORCE (unsigned char)0x40
288 
292 #define VRNA_CONSTRAINT_CONTEXT_NO_REMOVE (unsigned char)0x80
293 
294 
298 #define VRNA_CONSTRAINT_CONTEXT_NONE (unsigned char)0
299 
303 #define VRNA_CONSTRAINT_CONTEXT_CLOSING_LOOPS (unsigned char)(VRNA_CONSTRAINT_CONTEXT_EXT_LOOP | \
304  VRNA_CONSTRAINT_CONTEXT_HP_LOOP | \
305  VRNA_CONSTRAINT_CONTEXT_INT_LOOP | \
306  VRNA_CONSTRAINT_CONTEXT_MB_LOOP)
307 
311 #define VRNA_CONSTRAINT_CONTEXT_ENCLOSED_LOOPS (unsigned char)(VRNA_CONSTRAINT_CONTEXT_INT_LOOP_ENC | \
312  VRNA_CONSTRAINT_CONTEXT_MB_LOOP_ENC)
313 
320 #define VRNA_CONSTRAINT_CONTEXT_ALL_LOOPS (unsigned char)(VRNA_CONSTRAINT_CONTEXT_CLOSING_LOOPS | \
321  VRNA_CONSTRAINT_CONTEXT_ENCLOSED_LOOPS)
322 
323 
324 #define VRNA_CONSTRAINT_WINDOW_UPDATE_5 1U
325 
326 #define VRNA_CONSTRAINT_WINDOW_UPDATE_3 2U
327 
334 typedef enum {
341 
342 
367 struct vrna_hc_s {
368  vrna_hc_type_e type;
369  unsigned int n;
370 
371  unsigned char state;
372 
373 #ifndef VRNA_DISABLE_C11_FEATURES
374  /* C11 support for unnamed unions/structs */
375  union {
376  struct {
377 #endif
378  unsigned char *matrix;
381  unsigned char *mx;
382 #ifndef VRNA_DISABLE_C11_FEATURES
383  };
384  struct {
385 #endif
386  unsigned char **matrix_local;
387 #ifndef VRNA_DISABLE_C11_FEATURES
388  };
389  };
390 #endif
391 
392  int *up_ext;
395  int *up_hp;
398  int *up_int;
401  int *up_ml;
409  void *data;
425  vrna_hc_depot_t *depot;
426 };
427 
433 struct vrna_hc_up_s {
434  int position;
435  int strand;
436  unsigned char options;
437 };
438 
461 void vrna_message_constraint_options(unsigned int option);
462 
463 
475 
476 
492 
493 
494 void vrna_hc_init_window(vrna_fold_compound_t *vc);
495 
496 
497 int
498 vrna_hc_prepare(vrna_fold_compound_t *fc,
499  unsigned int options);
500 
501 void
502 vrna_hc_update(vrna_fold_compound_t *fc,
503  unsigned int i,
504  unsigned int options);
505 
506 
522  int i,
523  unsigned char option);
524 
525 
526 int
527 vrna_hc_add_up_strand(vrna_fold_compound_t *fc,
528  unsigned int i,
529  unsigned int strand,
530  unsigned char option);
531 
541 int
543  vrna_hc_up_t *constraints);
544 
545 int
546 vrna_hc_add_up_strand_batch(vrna_fold_compound_t *fc,
547  vrna_hc_up_t *constraints);
548 
566  int i,
567  int j,
568  unsigned char option);
569 
570 
571 int
572 vrna_hc_add_bp_strand(vrna_fold_compound_t *fc,
573  unsigned int i,
574  unsigned int strand_i,
575  unsigned int j,
576  unsigned int strand_j,
577  unsigned char option);
578 
597  int i,
598  int d,
599  unsigned char option);
600 
601 
613 void vrna_hc_free(vrna_hc_t *hc);
614 
615 
622 
623 
636  void *data,
638 
639 
658 int
660  const char *constraint,
661  unsigned int options);
662 
663 
664 #ifndef VRNA_DISABLE_BACKWARD_COMPATIBILITY
665 
673 DEPRECATED(void print_tty_constraint(unsigned int option),
674  "Use vrna_message_constraint_options() instead");
675 
682 DEPRECATED(void print_tty_constraint_full(void),
683  "Use vrna_message_constraint_options_all() instead");
684 
697 DEPRECATED(void constrain_ptypes(const char *constraint,
698  unsigned int length,
699  char *ptype,
700  int *BP,
701  int min_loop_size,
702  unsigned int idx_type),
703  "Use the new API and the hard constraint framework instead");
704 
705 #endif
706 
707 #endif
unsigned char options
The hard constraint option.
Definition: hard.h:436
void print_tty_constraint(unsigned int option)
Print structure constraint characters to stdout. (constraint support is specified by option parameter...
int * up_hp
A linear array that holds the number of allowed unpaired nucleotides in a hairpin loop.
Definition: hard.h:395
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.
Hard Constraints suitable for local structure prediction using window approach.
Definition: hard.h:336
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:132
Default Hard Constraints.
Definition: hard.h:335
int * up_ml
A linear array that holds the number of allowed unpaired nucleotides in a multi branched loop.
Definition: hard.h:401
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:77
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)
void vrna_message_constraint_options_all(void)
Print structure constraint characters to stdout (full constraint support)
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)
Functions and data structures for constraining secondary structure predictions and evaluation.
A single hard constraint for a single nucleotide.
Definition: hard.h:433
vrna_callback_hc_evaluate * f
A function pointer that returns whether or not a certain decomposition may be evaluated.
Definition: hard.h:405
void * data
A pointer to some structure where the user may store necessary data to evaluate its generic hard cons...
Definition: hard.h:409
unsigned char * matrix
Upper triangular matrix that encodes where a base pair or unpaired nucleotide is allowed.
Definition: hard.h:378
The hard constraints data structure.
Definition: hard.h:367
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_ext
A linear array that holds the number of allowed unpaired nucleotides in an exterior loop.
Definition: hard.h:392
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: hard.h:398
vrna_hc_type_e
The hard constraints type.
Definition: hard.h:334
void print_tty_constraint_full(void)
Print structure constraint characters to stdout (full constraint support)
void vrna_message_constraint_options(unsigned int option)
Print a help message for pseudo dot-bracket structure constraint characters to stdout....
vrna_callback_free_auxdata * free_data
A pointer to a function to free memory occupied by auxiliary data.
Definition: hard.h:414
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.
The Basic Fold Compound API.
int position
The sequence position (1-based)
Definition: hard.h:434
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.