/* ################################# # BEGIN OF FUNCTION DEFINITIONS # ################################# */ PUBLIC void vrna_constraints_add( vrna_fold_compound_t *vc, const char *constraint, unsigned int options){ if(vc){ if(!vc->hc) vrna_hc_init(vc); if(options & VRNA_CONSTRAINT_DB){ /* apply hard constraints from dot-bracket notation */ vrna_hc_add_from_db(vc, constraint, options); } else { /* constraints from file is the default */ vrna_file_commands_apply(vc, constraint, VRNA_CMD_PARSE_HC | VRNA_CMD_PARSE_SC); } } }
PUBLIC vrna_fold_compound_t * vrna_fold_compound_TwoD(const char *sequence, const char *s1, const char *s2, vrna_md_t *md_p, unsigned int options){ int length, l, turn; vrna_fold_compound_t *vc; vrna_md_t md; if(sequence == NULL) return NULL; /* sanity check */ length = strlen(sequence); if(length == 0) vrna_message_error("vrna_fold_compound_TwoD: sequence length must be greater 0"); l = strlen(s1); if(l != length) vrna_message_error("vrna_fold_compound_TwoD: sequence and s1 differ in length"); l = strlen(s2); if(l != length) vrna_message_error("vrna_fold_compound_TwoD: sequence and s2 differ in length"); vc = vrna_alloc(sizeof(vrna_fold_compound_t)); vc->type = VRNA_VC_TYPE_SINGLE; vc->length = length; vc->sequence = strdup(sequence); /* get a copy of the model details */ if(md_p) md = *md_p; else /* this fallback relies on global parameters and thus is not threadsafe */ vrna_md_set_default(&md); /* always make uniq ML decomposition ! */ md.uniq_ML = 1; md.compute_bpp = 0; set_fold_compound(vc, &md, options, WITH_PTYPE | WITH_PTYPE_COMPAT); if(!(options & VRNA_OPTION_EVAL_ONLY)){ vrna_hc_init(vc); /* add default hard constraints */ /* add DP matrices */ vrna_mx_add(vc, VRNA_MX_2DFOLD, options); } /* set all fields that are unique to Distance class partitioning... */ turn = vc->params->model_details.min_loop_size; vc->reference_pt1 = vrna_ptable(s1); vc->reference_pt2 = vrna_ptable(s2); vc->referenceBPs1 = vrna_refBPcnt_matrix(vc->reference_pt1, turn); vc->referenceBPs2 = vrna_refBPcnt_matrix(vc->reference_pt2, turn); vc->bpdist = vrna_refBPdist_matrix(vc->reference_pt1, vc->reference_pt2, turn); /* compute maximum matching with reference structure 1 disallowed */ vc->mm1 = maximumMatchingConstraint(vc->sequence, vc->reference_pt1); /* compute maximum matching with reference structure 2 disallowed */ vc->mm2 = maximumMatchingConstraint(vc->sequence, vc->reference_pt2); vc->maxD1 = vc->mm1[vc->iindx[1]-length] + vc->referenceBPs1[vc->iindx[1]-length]; vc->maxD2 = vc->mm2[vc->iindx[1]-length] + vc->referenceBPs2[vc->iindx[1]-length]; return vc; }
PUBLIC vrna_fold_compound_t * vrna_fold_compound_comparative( const char **sequences, vrna_md_t *md_p, unsigned int options){ int s, n_seq, length; vrna_fold_compound_t *vc; vrna_md_t md; unsigned int aux_options; aux_options = 0L; if(sequences == NULL) return NULL; for(s=0;sequences[s];s++); /* count the sequences */ n_seq = s; length = strlen(sequences[0]); /* sanity check */ if(length == 0) vrna_message_error("vrna_fold_compound_comparative: sequence length must be greater 0"); for(s = 0; s < n_seq; s++) if(strlen(sequences[s]) != length) vrna_message_error("vrna_fold_compound_comparative: uneqal sequence lengths in alignment"); vc = vrna_alloc(sizeof(vrna_fold_compound_t)); vc->type = VRNA_VC_TYPE_ALIGNMENT; vc->n_seq = n_seq; vc->length = length; vc->sequences = vrna_alloc(sizeof(char *) * (vc->n_seq + 1)); for(s = 0; sequences[s]; s++) vc->sequences[s] = strdup(sequences[s]); /* get a copy of the model details */ if(md_p) md = *md_p; else /* this fallback relies on global parameters and thus is not threadsafe */ vrna_md_set_default(&md); aux_options |= WITH_PTYPE; if(options & VRNA_OPTION_PF) aux_options |= WITH_PTYPE_COMPAT; set_fold_compound(vc, &md, options, aux_options); make_pscores(vc); if(!(options & VRNA_OPTION_EVAL_ONLY)){ /* add default hard constraints */ vrna_hc_init(vc); /* add DP matrices (if required) */ vrna_mx_add(vc, VRNA_MX_DEFAULT, options); } return vc; }
PUBLIC vrna_fold_compound_t * vrna_fold_compound( const char *sequence, vrna_md_t *md_p, unsigned int options){ unsigned int i, length, aux_options; vrna_fold_compound_t *vc; vrna_md_t md; if(sequence == NULL) return NULL; /* sanity check */ length = strlen(sequence); if(length == 0) vrna_message_error("vrna_fold_compound: sequence length must be greater 0"); vc = vrna_alloc(sizeof(vrna_fold_compound_t)); vc->type = VRNA_VC_TYPE_SINGLE; vc->length = length; vc->sequence = strdup(sequence); aux_options = 0L; /* get a copy of the model details */ if(md_p) md = *md_p; else vrna_md_set_default(&md); if(options & VRNA_OPTION_WINDOW){ /* sliding window structure prediction */ if(md.window_size <= 0) md.window_size = (int)vc->length; else if(md.window_size > (int)vc->length) md.window_size = (int)vc->length; vc->window_size = md.window_size; if((md.max_bp_span <= 0) || (md.max_bp_span > md.window_size)) md.max_bp_span = md.window_size; set_fold_compound(vc, &md, options, aux_options); vc->ptype_local = vrna_alloc(sizeof(char *)*(vc->length+1)); for (i = vc->length; ( i > vc->length - vc->window_size - 5) && (i >= 0); i--){ vc->ptype_local[i] = vrna_alloc(sizeof(char)*(vc->window_size+5)); } if(!(options & VRNA_OPTION_EVAL_ONLY)){ /* add default hard constraints */ /* vrna_hc_init(vc); */ /* no hard constraints in Lfold, yet! */ /* add DP matrices */ vrna_mx_add(vc, VRNA_MX_WINDOW, options); } } else { /* regular global structure prediction */ /* set window size to entire sequence */ md.window_size = (int)vc->length; aux_options |= WITH_PTYPE; if(options & VRNA_OPTION_PF) aux_options |= WITH_PTYPE_COMPAT; set_fold_compound(vc, &md, options, aux_options); if(!(options & VRNA_OPTION_EVAL_ONLY)){ /* add default hard constraints */ vrna_hc_init(vc); /* add DP matrices (if required) */ vrna_mx_add(vc, VRNA_MX_DEFAULT, options); } } return vc; }