energy_evaluation.ts
#include <ViennaRNA/params/basic.h>
#include <ViennaRNA/utils/basic.h>
#include <ViennaRNA/loops/all.h>
#suite EnergyEvaluation
/*
* check for properly working E_Hairpin() function
*/
#test HairpinLoops
{
vrna_param_t param = {
0
};
int i, j, k, l;
for (i = 0; i <= 30; ++i)
param.hairpin[i] = i + 100;
for (i = 0, l = 0; i <= NBPAIRS; ++i)
for (j = 0; j <= 4; ++j)
for (k = 0; k <= 4; ++k)
param.mismatchH[i][j][k] = ++l;
strcpy(param.Triloops, "CGGGG GCCCC");
param.Triloop_E[0] = 1000;
param.Triloop_E[1] = 2000;
strcpy(param.Tetraloops, "CGGGGG GCCCCC");
param.Tetraloop_E[0] = 3000;
param.Tetraloop_E[1] = 4000;
strcpy(param.Hexaloops, "CGGGGGGG GCCCCCCC");
param.Hexaloop_E[0] = 5000;
param.Hexaloop_E[1] = 6000;
param.TerminalAU = 10000;
ck_assert_int_eq(E_Hairpin(0, 0, 0, 0, NULL, ¶m), 100);
ck_assert_int_eq(E_Hairpin(1, 0, 0, 0, NULL, ¶m), 101);
ck_assert_int_eq(E_Hairpin(2, 0, 0, 0, NULL, ¶m), 102);
ck_assert_int_eq(E_Hairpin(3, 0, 0, 0, NULL, ¶m), 104);
ck_assert_int_eq(E_Hairpin(3, 1, 2, 3, NULL, ¶m), 142);
ck_assert_int_eq(E_Hairpin(3, 0, 0, 0, "CGGGG", ¶m), 104);
param.model_details.special_hp = 1;
ck_assert_int_eq(E_Hairpin(3, 0, 0, 0, "CGGGG", ¶m), 1000);
ck_assert_int_eq(E_Hairpin(3, 0, 0, 0, "GCCCC", ¶m), 2000);
ck_assert_int_eq(E_Hairpin(3, 0, 0, 0, "AUUUU", ¶m), 103); //mismatchH is ignored
ck_assert_int_eq(E_Hairpin(3, 1, 0, 0, "AUUUU", ¶m), 103);
ck_assert_int_eq(E_Hairpin(3, 2, 0, 0, "AUUUU", ¶m), 103);
ck_assert_int_eq(E_Hairpin(3, 3, 0, 0, "AUUUU", ¶m), 10103);
ck_assert_int_eq(E_Hairpin(3, 4, 0, 0, "AUUUU", ¶m), 10103);
ck_assert_int_eq(E_Hairpin(4, 0, 0, 0, "CGGGGG", ¶m), 3000);
ck_assert_int_eq(E_Hairpin(4, 0, 0, 0, "GCCCCC", ¶m), 4000);
ck_assert_int_eq(E_Hairpin(4, 0, 0, 0, "AUUUUU", ¶m), 105);
ck_assert_int_eq(E_Hairpin(6, 0, 0, 0, "CGGGGGGG", ¶m), 5000);
ck_assert_int_eq(E_Hairpin(6, 0, 0, 0, "GCCCCCCC", ¶m), 6000);
ck_assert_int_eq(E_Hairpin(6, 0, 0, 0, "AUUUUUUU", ¶m), 107);
}
/*
* check for properly working E_Stem() function
*/
#test eval_E_stem
{
vrna_param_t param = {
0
};
param.dangle3[1][1] = 3;
param.dangle3[3][1] = 2;
param.dangle5[1][1] = 5;
param.dangle5[1][2] = 12;
param.mismatchExt[1][1][1] = 100;
param.mismatchM[1][1][1] = 200;
param.TerminalAU = 1000;
param.MLintern[1] = 10000;
param.MLintern[3] = 100000;
ck_assert_int_eq(E_Stem(1, -1, -1, 0, ¶m), 10000);
ck_assert_int_eq(E_Stem(1, -1, -1, 1, ¶m), 0);
ck_assert_int_eq(E_Stem(3, -1, -1, 0, ¶m), 101000);
ck_assert_int_eq(E_Stem(3, -1, -1, 1, ¶m), 1000);
ck_assert_int_eq(E_Stem(1, 1, -1, 0, ¶m), 10005);
ck_assert_int_eq(E_Stem(1, 1, -1, 1, ¶m), 5);
ck_assert_int_eq(E_Stem(1, -1, 1, 0, ¶m), 10003);
ck_assert_int_eq(E_Stem(1, -1, 1, 1, ¶m), 3);
ck_assert_int_eq(E_Stem(1, 1, 1, 0, ¶m), 10200);
ck_assert_int_eq(E_Stem(1, 1, 1, 1, ¶m), 100);
}
/*
* check for properly working E_MLstem() function
*/
#test eval_E_MLstem
{
vrna_param_t param = {
0
};
param.MLintern[1] = 1;
param.dangle3[1][0] = 3;
param.dangle5[1][0] = 5;
param.mismatchM[1][0][0] = 100;
ck_assert_int_eq(E_MLstem(1, -1, -1, ¶m), 1);
ck_assert_int_eq(E_MLstem(1, 0, -1, ¶m), 6);
ck_assert_int_eq(E_MLstem(1, -1, 0, ¶m), 4);
ck_assert_int_eq(E_MLstem(1, 0, 0, ¶m), 101);
param.TerminalAU = 10000;
param.MLintern[3] = 10;
param.dangle3[3][0] = 33;
param.dangle5[3][0] = 55;
param.mismatchM[3][0][0] = 1000;
ck_assert_int_eq(E_MLstem(3, -1, -1, ¶m), 10010);
ck_assert_int_eq(E_MLstem(3, 0, -1, ¶m), 10065);
ck_assert_int_eq(E_MLstem(3, -1, 0, ¶m), 10043);
ck_assert_int_eq(E_MLstem(3, 0, 0, ¶m), 11010);
}
/*
* check for properly working E_ExtLoop() function
*/
#test eval_E_ExtLoop
{
vrna_param_t param = {
0
};
param.dangle3[1][0] = 3;
param.dangle5[1][0] = 5;
param.mismatchExt[1][0][0] = 100;
ck_assert_int_eq(E_ExtLoop(1, -1, -1, ¶m), 0);
ck_assert_int_eq(E_ExtLoop(1, 0, -1, ¶m), 5);
ck_assert_int_eq(E_ExtLoop(1, -1, 0, ¶m), 3);
ck_assert_int_eq(E_ExtLoop(1, 0, 0, ¶m), 100);
param.TerminalAU = 10000;
param.dangle3[3][0] = 33;
param.dangle5[3][0] = 55;
param.mismatchExt[3][0][0] = 1000;
ck_assert_int_eq(E_ExtLoop(3, -1, -1, ¶m), 10000);
ck_assert_int_eq(E_ExtLoop(3, 0, -1, ¶m), 10055);
ck_assert_int_eq(E_ExtLoop(3, -1, 0, ¶m), 10033);
ck_assert_int_eq(E_ExtLoop(3, 0, 0, ¶m), 11000);
}
/*
* check for properly working E_IntLoop() function
*/
#test eval_E_IntLoop
{
vrna_param_t param = {
0
};
param.stack[1][2] = 1;
ck_assert_int_eq(E_IntLoop(0, 0, 1, 2, -1, -1, -1, -1, ¶m), 1);
param.TerminalAU = 100;
param.bulge[1] = 10;
param.bulge[2] = 20;
ck_assert_int_eq(E_IntLoop(0, 1, 1, 2, -1, -1, -1, -1, ¶m), 11);
ck_assert_int_eq(E_IntLoop(1, 0, 1, 2, -1, -1, -1, -1, ¶m), 11);
ck_assert_int_eq(E_IntLoop(0, 2, 1, 2, -1, -1, -1, -1, ¶m), 20);
ck_assert_int_eq(E_IntLoop(2, 0, 1, 2, -1, -1, -1, -1, ¶m), 20);
ck_assert_int_eq(E_IntLoop(0, 2, 3, 2, -1, -1, -1, -1, ¶m), 120);
ck_assert_int_eq(E_IntLoop(0, 2, 2, 3, -1, -1, -1, -1, ¶m), 120);
ck_assert_int_eq(E_IntLoop(0, 2, 3, 3, -1, -1, -1, -1, ¶m), 220);
param.int11[1][2][3][4] = 11;
ck_assert_int_eq(E_IntLoop(1, 1, 1, 2, 3, 4, -1, -1, ¶m), 11);
param.int21[1][2][1][2][3] = 21;
ck_assert_int_eq(E_IntLoop(1, 2, 1, 2, 1, 3, -1, 2, ¶m), 21);
ck_assert_int_eq(E_IntLoop(2, 1, 2, 1, 2, -1, 3, 1, ¶m), 21);
param.internal_loop[4] = 10;
param.ninio[2] = 100;
param.mismatch1nI[1][1][2] = 1;
param.mismatch1nI[2][4][3] = 2;
ck_assert_int_eq(E_IntLoop(1, 3, 1, 2, 1, 2, 3, 4, ¶m), 213);
ck_assert_int_eq(E_IntLoop(3, 1, 1, 2, 1, 2, 3, 4, ¶m), 213);
param.int22[1][2][1][2][3][4] = 22;
ck_assert_int_eq(E_IntLoop(2, 2, 1, 2, 1, 4, 2, 3, ¶m), 22);
param.internal_loop[5] = 20;
param.mismatch23I[1][1][2] = 3;
param.mismatch23I[2][4][3] = 4;
ck_assert_int_eq(E_IntLoop(2, 3, 1, 2, 1, 2, 3, 4, ¶m), 127);
ck_assert_int_eq(E_IntLoop(3, 2, 1, 2, 1, 2, 3, 4, ¶m), 127);
param.internal_loop[8] = 30;
param.mismatchI[1][1][2] = 2;
param.mismatchI[2][4][3] = 3;
ck_assert_int_eq(E_IntLoop(3, 5, 1, 2, 1, 2, 3, 4, ¶m), 235);
ck_assert_int_eq(E_IntLoop(5, 3, 1, 2, 1, 2, 3, 4, ¶m), 235);
}
#main-pre
srunner_set_tap(sr, "-");