54 #if ! defined SCALAR_REPLACEMENT 55 #define SCALAR_REPLACEMENT 0 58 #if ! defined CHECK_DEPENDENCES 59 #define CHECK_DEPENDENCES false 63 #define eassert(EXPR) 1 65 #define eassert(EXPR) eassert_func(__STRING(EXPR), EXPR) 69 fprintf(
stderr,
"assertion failed: %s\n", expr);
80 #if ! defined FOUR_WAY_MAX_WITH_REDUNDANCY 81 #define FOUR_WAY_MAX_WITH_REDUNDANCY false 83 #if FOUR_WAY_MAX_WITH_REDUNDANCY 84 #define ZERO_IF_NO_REDUNDANCY 1 86 #define ZERO_IF_NO_REDUNDANCY 0 89 #if ! defined PRINT_SIZE 95 #if ! defined VERBOSE_OUT 96 #define VERBOSE_OUT stdout 99 #if ! defined REALLY_VERBOSE 100 #define REALLY_VERBOSE false 108 #define SLOWER (CHECK_DEPENDENCES | VERBOSE) 114 gettimeofday(&tv, &tz);
115 return tv.tv_sec + tv.tv_usec*1.0e-6;
125 return (b1+b2) == 3 ? 1 : 0;
130 return (s1 >= s2) ? s1 : s2;
135 #define debug_N(x, y) (N_array[x][y]) 137 #if ! CHECK_DEPENDENCES 138 #define N(x, y) (eassert(0 <= x && x < size && 0 <= y && y < size), N_array[x][y]) 139 #if SCALAR_REPLACEMENT 140 #define MAX_N_DECLS() int max_tmp_i, max_tmp_j; score max_tmp 141 #define MAX_N_START(x,y) ((max_tmp_i=x), (max_tmp_j=y), (max_tmp = 0)) 142 #define MAX_N(x, y, v) (eassert(max_tmp_i==x && max_tmp_j==y), eassert(0 <= x && x < size && 0 <= y && y < size), (max_tmp = max_score(max_tmp, v))) 143 #define MAX_N_END(x,y) (eassert(max_tmp_i==x && max_tmp_j==y), ((N_array[x][y]) = max_score(N_array[x][y], max_tmp))) 145 #define MAX_N(x, y, v) (eassert(0 <= x && x < size && 0 <= y && y < size), ((N_array[x][y]) = max_score(N_array[x][y], v))) 149 #define N(x, y) (eassert(0 <= x && x < size && 0 <= y && y < size), \ 150 (REALLY_VERBOSE?fprintf(VERBOSE_OUT, "i, j, k = %d, %d, %d: reading N[%d][%d]\n", i, j, k, x, y):1), \ 151 (N_array_has_been_read[x][y] = (true)), \ 153 #if SCALAR_REPLACEMENT 154 #error("Not yet ready to do scalar replacement and check_deps at the same time :-(") 156 #define MAX_N(x, y, v) (eassert(0 <= x && x < size && 0 <= y && y < size), \ 157 eassert(!N_array_has_been_read[x][y]), \ 158 (N_array[x][y] = max_score(N_array[x][y], v))) 161 #if ! SCALAR_REPLACEMENT 162 #define MAX_N_DECLS() 163 #define MAX_N_START(x,y) 164 #define MAX_N_END(x,y) 171 #if VERBOSE_OUT == stderr 172 char *terminate =
"\n";
174 char *terminate =
"";
179 fprintf(
stderr,
"%s%s", prompt, terminate),
180 result = scanf(
"%d", &i),
181 result != 1 && result != EOF
183 fprintf(
stderr,
"Sorry, I didn't understand that...\n");
188 fprintf(
stderr,
"Giving up ... can't read input\n");
194 int main(
int argc,
char *argv[])
197 double start_time, end_time;
200 int size =
getint(
"Enter length of random mRNA sequence (2200 is average for human mRNA): ");
207 #if CHECK_DEPENDENCES 213 #if CHECK_DEPENDENCES 220 printf(
"Running Nussinov RNA algorithm%s for sequence of length %d, random data with seed %d.\n",
221 options, size,
SEED);
230 for (i = 0; i < size; i++)
239 for (i = size-1; i >= 0; i--) {
240 for (j=i+1; j<size; j++) {
242 fprintf(
VERBOSE_OUT,
"i, j, k = %d, %d, %d\n", i, j, k);
245 #if FOUR_WAY_MAX_WITH_REDUNDANCY 246 if (j-1>=0)
MAX_N(i, j,
N(i, j-1));
247 if (i+1<size)
MAX_N(i, j,
N(i+1, j));
249 if (j-1>=0 && i+1<size) {
251 else MAX_N(i, j,
N(i+1, j-1));
258 fprintf(
VERBOSE_OUT,
"i, j, k = %d, %d, %d\n", i, j, k);
260 MAX_N(i, j,
N(i, k)+
N(k+1, j));
270 printf(
"done.\nTime elapsed: %fs\n", end_time-start_time);
272 printf(
"N(0, size-1) = %d\n",
N(0, size-1));
275 for (i=0; i<size; i++)
278 for(i = 0; i < size; i++) {
279 for(j = 0; j < size; j++) printf(
"%3d ",
debug_N(i, j));
char base
This version is stamped on May 10, 2016.
score N_array[MAX_SIZE][MAX_SIZE]
score match(base b1, base b2)
int main(int argc, char *argv[])
int bool
This version is stamped on May 10, 2016.
static const uint32_t k[]
#define ZERO_IF_NO_REDUNDANCY
score max_score(score s1, score s2)
void eassert_func(char *expr, bool value)
#define MAX_N_START(x, y)