1 /* make this interface backward compatible with RNAlib < 2.2.0 */ 2 #ifndef VRNA_DISABLE_BACKWARD_COMPATIBILITY 3 4 #define ggo_get_temperature(ggostruct, dest) ({ \ 5 if (ggostruct.temp_given) \ 6 dest = ggostruct.temp_arg; \ 7 temperature = (double)dest; \ 8 }) 9 10 #define ggo_get_dangles(ggostruct, dest) ({ \ 11 if (ggostruct.dangles_given) \ 12 dest = ggostruct.dangles_arg; \ 13 dangles = (int)dest; \ 14 }) 15 16 #define ggo_get_special_hp(ggostruct, dest) ({ \ 17 if (ggostruct.noTetra_given) \ 18 dest = 0; \ 19 tetra_loop = (int)dest; \ 20 }) 21 22 #define ggo_get_noLP(ggostruct, dest) ({ \ 23 if (ggostruct.noLP_given) \ 24 dest = 1; \ 25 noLonelyPairs = (int)dest; \ 26 }) 27 28 #define ggo_get_noGU(ggostruct, dest) ({ \ 29 if (ggostruct.noGU_given) \ 30 dest = 1; \ 31 noGU = (int)dest; \ 32 }) 33 34 #define ggo_get_noGUclosure(ggostruct, dest) ({ \ 35 if (ggostruct.noClosingGU_given) \ 36 dest = 1; \ 37 no_closingGU = (int)dest; \ 38 }) 39 40 #define ggo_get_gquad(ggostruct, dest) ({ \ 41 if (ggostruct.gquad_given) \ 42 dest = 1; \ 43 gquad = (int)dest; \ 44 }) 45 46 #define ggo_get_energyModel(ggostruct, dest) ({ \ 47 if (ggostruct.energyModel_given) \ 48 dest = ggostruct.energyModel_arg; \ 49 energy_set = (int)dest; \ 50 }) 51 52 #define ggo_get_maxBPspan(ggostruct, dest) ({ \ 53 if (ggostruct.maxBPspan_given) \ 54 dest = ggostruct.maxBPspan_arg; \ 55 max_bp_span = (int)dest; \ 56 }) 57 58 59 #else 60 61 #define ggo_get_temperature(ggostruct, dest) ({ \ 62 if (ggostruct.temp_given) \ 63 dest = ggostruct.temp_arg; \ 64 }) 65 66 #define ggo_get_dangles(ggostruct, dest) ({ \ 67 if (ggostruct.dangles_given) \ 68 dest = ggostruct.dangles_arg; \ 69 }) 70 71 #define ggo_get_special_hp(ggostruct, dest) ({ \ 72 if (ggostruct.noTetra_given) \ 73 dest = 0; \ 74 }) 75 76 #define ggo_get_noLP(ggostruct, dest) ({ \ 77 if (ggostruct.noLP_given) \ 78 dest = 1; \ 79 }) 80 81 #define ggo_get_noGUclosure(ggostruct, dest) ({ \ 82 if (ggostruct.noClosingGU_given) \ 83 dest = 1; \ 84 }) 85 86 #define ggo_get_gquad(ggostruct, dest) ({ \ 87 if (ggostruct.gquad_given) \ 88 dest = 1; \ 89 }) 90 91 #define ggo_get_energyModel(ggostruct, dest) ({ \ 92 if (ggostruct.energyModel_given) \ 93 dest = ggostruct.energyModel_arg; \ 94 }) 95 96 #define ggo_get_maxBPspan(ggostruct, dest) ({ \ 97 if (ggostruct.maxBPspan_given) \ 98 dest = ggostruct.maxBPspan_arg; \ 99 }) 100 101 #endif 102 103 104 #define ggo_get_pfScale(ggostruct, dest) ({ \ 105 if (ggostruct.pfScale_given) \ 106 dest = ggostruct.pfScale_arg; \ 107 }) 108 109 #define ggo_get_betaScale(ggostruct, dest) ({ \ 110 if (ggostruct.betaScale_given) \ 111 dest = ggostruct.betaScale_arg; \ 112 }) 113 114 /* assume RNA sequence to be circular */ 115 #define ggo_get_circ(ggostruct, dest) ({ \ 116 if (ggostruct.circ_given) \ 117 dest = 1; \ 118 }) 119 120 /* Allow other pairs in addition to the usual AU,GC,and GU pairs */ 121 #define ggo_get_nsp(ggostruct, dest) ({ \ 122 if (ggostruct.nsp_given) \ 123 dest = strdup(ggostruct.nsp_arg); \ 124 }) 125 126 #define ggo_get_read_paramFile(ggostruct) ({ \ 127 /* take another energy parameter set */ \ 128 if (ggostruct.paramFile_given) { \ 129 if (!strcmp(ggostruct.paramFile_arg, "DNA")) \ 130 vrna_params_load_DNA_Mathews2004();\ 131 else \ 132 vrna_params_load(ggostruct.paramFile_arg, VRNA_PARAMETER_FORMAT_DEFAULT); \ 133 } \ 134 }) 135 136 137 /* 138 * The following macro automatically sets a basic set of 139 * model details: 140 * - dangles 141 * - special_hp 142 * - gquad 143 * - energy_set 144 * - ns_bases 145 * - parameter file 146 */ 147 #define ggo_get_md_eval(ggostruct, md) ({ \ 148 /* dangles */ \ 149 ggo_get_dangles(ggostruct, md.dangles); \ 150 /* special_hp */ \ 151 ggo_get_special_hp(ggostruct, md.special_hp); \ 152 /* gquadruplex support */ \ 153 ggo_get_gquad(ggostruct, md.gquad); \ 154 /* set energy model */ \ 155 ggo_get_energyModel(ggostruct, md.energy_set); \ 156 /* Allow other pairs in addition to the usual AU,GC,and GU pairs */ \ 157 { char *ns_bases = NULL; \ 158 ggo_get_nsp(ggostruct, ns_bases); \ 159 if (ns_bases != NULL) \ 160 vrna_md_set_nonstandards(&md, ns_bases); \ 161 } \ 162 ggo_get_read_paramFile(ggostruct); \ 163 }) 164 165 166 /* 167 * The following macro automatically sets a basic set of 168 * model details required for RNA structure prediction: 169 * - noLP 170 * - noGU 171 * - noGUclosure 172 */ 173 #define ggo_get_md_fold(ggostruct, md) ({ \ 174 /* do not allow weak pairs */ \ 175 ggo_get_noLP(ggostruct, md.noLP); \ 176 /* do not allow wobble pairs (GU) */ \ 177 ggo_get_noGU(ggostruct, md.noGU); \ 178 /* do not allow weak closing pairs (AU,GU) */ \ 179 ggo_get_noGUclosure(ggostruct, md.noGUclosure); \ 180 /* set maximum base pair span */ \ 181 ggo_get_maxBPspan(ggostruct, md.max_bp_span); \ 182 }) 183 184 185 /* 186 * The following macro automatically sets a basic set of 187 * model details required for RNA structure prediction: 188 * - noLP 189 * - noGU 190 * - noGUclosure 191 */ 192 #define ggo_get_md_part(ggostruct, md) ({ \ 193 /* set pf scaling factor */ \ 194 ggo_get_pfScale(ggostruct, md.sfact); \ 195 ggo_get_betaScale(ggostruct, md.betaScale); \ 196 }) 197 198 199 /* 200 * HELPER MACRO FOR SHAPE REACTIVITY DATA INCORPORATION 201 */ 202 203 #define ggo_get_SHAPE(ggostruct, \ 204 SHAPE_switch, \ 205 SHAPE_files, \ 206 SHAPE_method, \ 207 SHAPE_conversion) ({ \ 208 /* SHAPE reactivity data */ \ 209 if (ggostruct.shape_given) { \ 210 SHAPE_switch = 1; \ 211 SHAPE_files = strdup(ggostruct.shape_arg); \ 212 SHAPE_method = strdup(ggostruct.shapeMethod_arg); \ 213 SHAPE_conversion = strdup(ggostruct.shapeConversion_arg); \ 214 } else { \ 215 SHAPE_switch = 0; \ 216 SHAPE_files = NULL; \ 217 SHAPE_method = NULL; \ 218 SHAPE_conversion = NULL; \ 219 } \ 220 }) 221 222 223 /* 224 * HELPER FUNCTIONS FOR AUTO-ID FEATURE 225 */ 226 227 #define ggo_get_ID_manipulation(ggostruct, \ 228 ID_auto_switch, \ 229 ID_prefix, ID_prefix_default, \ 230 ID_delimiter, ID_delimiter_default, \ 231 ID_digits, ID_digits_default, \ 232 ID_start, ID_start_default) ({ \ 233 if (ggostruct.auto_id_given) { ID_auto_switch = 1; } \ 234 if (ggostruct.id_prefix_given) { \ 235 ID_prefix = strdup(ggostruct.id_prefix_arg); \ 236 ID_auto_switch = 1; \ 237 } else { ID_prefix = strdup(ID_prefix_default); } \ 238 if (ggostruct.id_delim_given) { \ 239 ID_delimiter = strdup(ggostruct.id_delim_arg); \ 240 } else { ID_delimiter = strdup(ID_delimiter_default); } \ 241 if (ggostruct.id_digits_given) { \ 242 if ((ggostruct.id_digits_arg > 0) && (ggostruct.id_digits_arg < 19)) { \ 243 ID_digits = ggostruct.id_digits_arg; } \ 244 else { \ 245 vrna_message_warning("ID number digits out of allowed range! Using defaults..."); \ 246 ID_digits = ID_digits_default; \ 247 } \ 248 } else { ID_digits = ID_digits_default; } \ 249 if (ggostruct.id_start_given) { \ 250 ID_auto_switch = 1; \ 251 if ((ggostruct.id_start_arg >= 0) && (ggostruct.id_start_arg <= LONG_MAX)) { \ 252 ID_start = ggostruct.id_start_arg; \ 253 } else { \ 254 vrna_message_warning("ID number start out of allowed range! Using defaults..."); \ 255 ID_start = ID_start_default; \ 256 } \ 257 } else { ID_start = ID_start_default; } \ 258 }) 259 260 261 #define ggo_get_id_control(ggostruct,\ 262 id_ctrl,\ 263 identifier,\ 264 default_prefix,\ 265 default_delimiter,\ 266 default_digits,\ 267 default_start) ({ \ 268 id_ctrl = init_id_data(identifier, default_prefix, default_delimiter, default_digits, default_start); \ 269 if (ggostruct.auto_id_given) { set_auto_id(id_ctrl, 1); } \ 270 if (ggostruct.id_prefix_given) { set_id_prefix(id_ctrl, ggostruct.id_prefix_arg); set_auto_id(id_ctrl, 1); } \ 271 if (ggostruct.id_delim_given) { set_id_delim(id_ctrl, ggostruct.id_delim_arg); } \ 272 if (ggostruct.id_digits_given) { if ((ggostruct.id_digits_arg > 0) && (ggostruct.id_digits_arg < 19)) { \ 273 set_id_digits(id_ctrl, ggostruct.id_digits_arg); \ 274 } else { \ 275 vrna_message_warning("ID number digits (%d) out of allowed range! Using defaults...", ggostruct.id_digits_arg); \ 276 } \ 277 } \ 278 if (ggostruct.id_start_given) { set_auto_id(id_ctrl, 1); \ 279 if ((ggostruct.id_start_arg >= 0) && (ggostruct.id_start_arg <= LONG_MAX)) { \ 280 set_id_start(id_ctrl, ggostruct.id_start_arg); \ 281 } else { \ 282 vrna_message_warning("ID number start (%ld) out of allowed range! Using defaults...", ggostruct.id_start_arg); \ 283 } \ 284 } \ 285 }) 286 287 288 #define ggo_get_constraints_settings(ggostruct, \ 289 constraint_switch, \ 290 constraint_file, \ 291 constraint_enforce, \ 292 constraint_batch) ({ \ 293 /* structure constraint */ \ 294 if (ggostruct.constraint_given) { \ 295 constraint_switch = 1; \ 296 if (ggostruct.constraint_arg[0] != '\0') \ 297 constraint_file = strdup(ggostruct.constraint_arg); \ 298 else \ 299 constraint_file = NULL; \ 300 } else { constraint_switch = 0; constraint_file = NULL; } \ 301 /* enforce base pairs given in constraint string rather than weak enforce */ \ 302 if (ggostruct.enforceConstraint_given) \ 303 constraint_enforce = 1; \ 304 else \ 305 constraint_enforce = 0; \ 306 /* do batch jobs despite constraints read from input file */ \ 307 if (ggostruct.batch_given) \ 308 constraint_batch = 1; \ 309 else \ 310 constraint_batch = 0; \ 311 }) 312