| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#include <esl_config.h> |
| 18 |
|
| 19 |
#include <string.h> |
| 20 |
#include <math.h> |
| 21 |
|
| 22 |
#include "easel.h" |
| 23 |
#include "esl_alphabet.h" |
| 24 |
#include "esl_composition.h" |
| 25 |
#include "esl_dmatrix.h" |
| 26 |
#include "esl_fileparser.h" |
| 27 |
#include "esl_rootfinder.h" |
| 28 |
#include "esl_ratematrix.h" |
| 29 |
#include "esl_vectorops.h" |
| 30 |
|
| 31 |
#include "esl_scorematrix.h" |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
ESL_SCOREMATRIX * |
| 50 |
esl_scorematrix_Create(const ESL_ALPHABET *abc) |
| 51 |
{ |
| 52 |
ESL_SCOREMATRIX *S = NULL; |
| 53 |
int status; |
| 54 |
int i; |
| 55 |
|
| 56 |
ESL_ALLOC(S, sizeof(ESL_SCOREMATRIX)); |
| 57 |
S->s = NULL; |
| 58 |
S->K = abc->K; |
| 59 |
S->Kp = abc->Kp; |
| 60 |
S->isval = NULL; |
| 61 |
S->abc_r = abc; |
| 62 |
S->nc = 0; |
| 63 |
S->outorder = NULL; |
| 64 |
S->name = NULL; |
| 65 |
S->path = NULL; |
| 66 |
|
| 67 |
ESL_ALLOC(S->s, sizeof(int *) * abc->Kp); |
| 68 |
S->s[0] = NULL; |
| 69 |
ESL_ALLOC(S->isval, sizeof(char) * abc->Kp); |
| 70 |
for (i = 0; i < abc->Kp; i++) S->isval[i] = FALSE; |
| 71 |
ESL_ALLOC(S->outorder, sizeof(char) * (abc->Kp+1)); |
| 72 |
S->outorder[0] = '\0'; |
| 73 |
|
| 74 |
ESL_ALLOC(S->s[0], sizeof(int) * abc->Kp * abc->Kp); |
| 75 |
for (i = 1; i < abc->Kp; i++) S->s[i] = S->s[0] + abc->Kp * i; |
| 76 |
|
| 77 |
for (i = 0; i < abc->Kp*abc->Kp; i++) S->s[0][i] = 0; |
| 78 |
return S; |
| 79 |
|
| 80 |
ERROR: |
| 81 |
esl_scorematrix_Destroy(S); |
| 82 |
return NULL; |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
int |
| 101 |
esl_scorematrix_Copy(const ESL_SCOREMATRIX *src, ESL_SCOREMATRIX *dest) |
| 102 |
{ |
| 103 |
int i,j; |
| 104 |
int status; |
| 105 |
|
| 106 |
if (src->abc_r->type != dest->abc_r->type || src->K != dest->K || src->Kp != dest->Kp) |
| 107 |
ESL_EXCEPTION(eslEINCOMPAT, "source and dest score matrix types don't match"); |
| 108 |
|
| 109 |
for (i = 0; i < src->Kp; i++) |
| 110 |
for (j = 0; j < src->Kp; j++) |
| 111 |
dest->s[i][j] = src->s[i][j]; |
| 112 |
for (i = 0; i < src->Kp; i++) |
| 113 |
dest->isval[i] = src->isval[i]; |
| 114 |
dest->nc = src->nc; |
| 115 |
for (i = 0; i < src->nc; i++) |
| 116 |
dest->outorder[i] = src->outorder[i]; |
| 117 |
dest->outorder[dest->nc] = '\0'; |
| 118 |
|
| 119 |
if ((status = esl_strdup(src->name, -1, &(dest->name))) != eslOK) return status; |
| 120 |
if ((status = esl_strdup(src->path, -1, &(dest->path))) != eslOK) return status; |
| 121 |
return eslOK; |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
ESL_SCOREMATRIX * |
| 133 |
esl_scorematrix_Clone(const ESL_SCOREMATRIX *S) |
| 134 |
{ |
| 135 |
ESL_SCOREMATRIX *dup = NULL; |
| 136 |
|
| 137 |
if ((dup = esl_scorematrix_Create(S->abc_r)) == NULL) return NULL; |
| 138 |
if (esl_scorematrix_Copy(S, dup) != eslOK) { esl_scorematrix_Destroy(dup); return NULL; } |
| 139 |
return dup; |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
int |
| 155 |
esl_scorematrix_Compare(const ESL_SCOREMATRIX *S1, const ESL_SCOREMATRIX *S2) |
| 156 |
{ |
| 157 |
int a,b; |
| 158 |
|
| 159 |
if (strcmp(S1->outorder, S2->outorder) != 0) return eslFAIL; |
| 160 |
if (S1->nc != S2->nc) return eslFAIL; |
| 161 |
|
| 162 |
for (a = 0; a < S1->nc; a++) |
| 163 |
if (S1->isval[a] != S2->isval[a]) return eslFAIL; |
| 164 |
|
| 165 |
for (a = 0; a < S1->Kp; a++) |
| 166 |
for (b = 0; b < S1->Kp; b++) |
| 167 |
if (S1->s[a][b] != S2->s[a][b]) return eslFAIL; |
| 168 |
|
| 169 |
return eslOK; |
| 170 |
} |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
int |
| 183 |
esl_scorematrix_CompareCanon(const ESL_SCOREMATRIX *S1, const ESL_SCOREMATRIX *S2) |
| 184 |
{ |
| 185 |
int a,b; |
| 186 |
|
| 187 |
for (a = 0; a < S1->K; a++) |
| 188 |
for (b = 0; b < S1->K; b++) |
| 189 |
if (S1->s[a][b] != S2->s[a][b]) return eslFAIL; |
| 190 |
return eslOK; |
| 191 |
} |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
int |
| 201 |
esl_scorematrix_Max(const ESL_SCOREMATRIX *S) |
| 202 |
{ |
| 203 |
int i,j; |
| 204 |
int max = S->s[0][0]; |
| 205 |
|
| 206 |
for (i = 0; i < S->K; i++) |
| 207 |
for (j = 0; j < S->K; j++) |
| 208 |
if (S->s[i][j] > max) max = S->s[i][j]; |
| 209 |
return max; |
| 210 |
} |
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
int |
| 218 |
esl_scorematrix_Min(const ESL_SCOREMATRIX *S) |
| 219 |
{ |
| 220 |
int i,j; |
| 221 |
int min = S->s[0][0]; |
| 222 |
|
| 223 |
for (i = 0; i < S->K; i++) |
| 224 |
for (j = 0; j < S->K; j++) |
| 225 |
if (S->s[i][j] < min) min = S->s[i][j]; |
| 226 |
return min; |
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
int |
| 237 |
esl_scorematrix_IsSymmetric(const ESL_SCOREMATRIX *S) |
| 238 |
{ |
| 239 |
int i,j; |
| 240 |
|
| 241 |
for (i = 0; i < S->K; i++) |
| 242 |
for (j = i; j < S->K; j++) |
| 243 |
if (S->s[i][j] != S->s[j][i]) return FALSE; |
| 244 |
return TRUE; |
| 245 |
} |
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
int |
| 270 |
esl_scorematrix_ExpectedScore(ESL_SCOREMATRIX *S, double *fi, double *fj, double *ret_E) |
| 271 |
{ |
| 272 |
double E = 0.; |
| 273 |
int a,b; |
| 274 |
|
| 275 |
for (a = 0; a < S->K; a++) |
| 276 |
for (b = 0; b < S->K; b++) |
| 277 |
E += fi[a] * fj[b] * (double) S->s[a][b]; |
| 278 |
|
| 279 |
*ret_E = E; |
| 280 |
return eslOK; |
| 281 |
} |
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
int |
| 314 |
esl_scorematrix_RelEntropy(const ESL_SCOREMATRIX *S, const double *fi, const double *fj, double lambda, double *ret_D) |
| 315 |
{ |
| 316 |
int status; |
| 317 |
double pij; |
| 318 |
double sum = 0.; |
| 319 |
int i,j; |
| 320 |
double D = 0; |
| 321 |
|
| 322 |
for (i = 0; i < S->K; i++) |
| 323 |
for (j = 0; j < S->K; j++) |
| 324 |
{ |
| 325 |
pij = fi[i] * fj[j] * exp(lambda * (double) S->s[i][j]); |
| 326 |
sum += pij; |
| 327 |
if (pij > 0.) D += pij * log(pij / (fi[i] * fj[j])); |
| 328 |
|
| 329 |
} |
| 330 |
if (esl_DCompare_old(sum, 1.0, 1e-3) != eslOK) |
| 331 |
ESL_XEXCEPTION(eslEINVAL, "pij's don't sum to one (%.4f): bad lambda or bad bg?", sum); |
| 332 |
|
| 333 |
D /= eslCONST_LOG2; |
| 334 |
*ret_D = D; |
| 335 |
return eslOK; |
| 336 |
|
| 337 |
ERROR: |
| 338 |
*ret_D = 0.; |
| 339 |
return status; |
| 340 |
} |
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
int |
| 369 |
esl_scorematrix_JointToConditionalOnQuery(const ESL_ALPHABET *abc, ESL_DMATRIX *P) |
| 370 |
{ |
| 371 |
int a,b; |
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
for (a = 0; a < abc->Kp-2; a++) |
| 377 |
for (b = 0; b < abc->Kp-2; b++) |
| 378 |
P->mx[a][b] = (P->mx[a][abc->Kp-3] == 0.0 ? 0.0 : P->mx[a][b] / P->mx[a][abc->Kp-3]); |
| 379 |
return eslOK; |
| 380 |
} |
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
void |
| 390 |
esl_scorematrix_Destroy(ESL_SCOREMATRIX *S) |
| 391 |
{ |
| 392 |
if (S == NULL) return; |
| 393 |
if (S->s != NULL) { |
| 394 |
if (S->s[0] != NULL) free(S->s[0]); |
| 395 |
free(S->s); |
| 396 |
} |
| 397 |
if (S->isval != NULL) free(S->isval); |
| 398 |
if (S->outorder != NULL) free(S->outorder); |
| 399 |
if (S->name != NULL) free(S->name); |
| 400 |
if (S->path != NULL) free(S->path); |
| 401 |
free(S); |
| 402 |
return; |
| 403 |
} |
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
#define eslAADIM 29 |
| 425 |
|
| 426 |
struct esl_scorematrix_aa_preload_s { |
| 427 |
char *name; |
| 428 |
int matrix[eslAADIM][eslAADIM]; |
| 429 |
}; |
| 430 |
|
| 431 |
static const struct esl_scorematrix_aa_preload_s ESL_SCOREMATRIX_AA_PRELOADS[] = { |
| 432 |
{ "PAM30", { |
| 433 |
|
| 434 |
{ 6, -6, -3, -2, -8, -2, -7, -5, -7, -6, -5, -4, -2, -4, -7, 0, -1, -2, -13, -8, 0, -3, 0, -3, 0, 0, -3, -17, 0, }, |
| 435 |
{ -6, 10, -14, -14, -13, -9, -7, -6, -14, -15, -13, -11, -8, -14, -8, -3, -8, -6, -15, -4, 0, -12, 0, -14, 0, 0, -9, -17, 0, }, |
| 436 |
{ -3, -14, 8, 2, -15, -3, -4, -7, -4, -12, -11, 2, -8, -2, -10, -4, -5, -8, -15, -11, 0, 6, 0, 1, 0, 0, -5, -17, 0, }, |
| 437 |
{ -2, -14, 2, 8, -14, -4, -5, -5, -4, -9, -7, -2, -5, 1, -9, -4, -6, -6, -17, -8, 0, 1, 0, 6, 0, 0, -5, -17, 0, }, |
| 438 |
{ -8, -13, -15, -14, 9, -9, -6, -2, -14, -3, -4, -9, -10, -13, -9, -6, -9, -8, -4, 2, 0, -10, 0, -13, 0, 0, -8, -17, 0, }, |
| 439 |
{ -2, -9, -3, -4, -9, 6, -9, -11, -7, -10, -8, -3, -6, -7, -9, -2, -6, -5, -15, -14, 0, -3, 0, -5, 0, 0, -5, -17, 0, }, |
| 440 |
{ -7, -7, -4, -5, -6, -9, 9, -9, -6, -6, -10, 0, -4, 1, -2, -6, -7, -6, -7, -3, 0, -1, 0, -1, 0, 0, -5, -17, 0, }, |
| 441 |
{ -5, -6, -7, -5, -2, -11, -9, 8, -6, -1, -1, -5, -8, -8, -5, -7, -2, 2, -14, -6, 0, -6, 0, -6, 0, 0, -5, -17, 0, }, |
| 442 |
{ -7, -14, -4, -4, -14, -7, -6, -6, 7, -8, -2, -1, -6, -3, 0, -4, -3, -9, -12, -9, 0, -2, 0, -4, 0, 0, -5, -17, 0, }, |
| 443 |
{ -6, -15, -12, -9, -3, -10, -6, -1, -8, 7, 1, -7, -7, -5, -8, -8, -7, -2, -6, -7, 0, -9, 0, -7, 0, 0, -6, -17, 0, }, |
| 444 |
{ -5, -13, -11, -7, -4, -8, -10, -1, -2, 1, 11, -9, -8, -4, -4, -5, -4, -1, -13, -11, 0, -10, 0, -5, 0, 0, -5, -17, 0, }, |
| 445 |
{ -4, -11, 2, -2, -9, -3, 0, -5, -1, -7, -9, 8, -6, -3, -6, 0, -2, -8, -8, -4, 0, 6, 0, -3, 0, 0, -3, -17, 0, }, |
| 446 |
{ -2, -8, -8, -5, -10, -6, -4, -8, -6, -7, -8, -6, 8, -3, -4, -2, -4, -6, -14, -13, 0, -7, 0, -4, 0, 0, -5, -17, 0, }, |
| 447 |
{ -4, -14, -2, 1, -13, -7, 1, -8, -3, -5, -4, -3, -3, 8, -2, -5, -5, -7, -13, -12, 0, -3, 0, 6, 0, 0, -5, -17, 0, }, |
| 448 |
{ -7, -8, -10, -9, -9, -9, -2, -5, 0, -8, -4, -6, -4, -2, 8, -3, -6, -8, -2, -10, 0, -7, 0, -4, 0, 0, -6, -17, 0, }, |
| 449 |
{ 0, -3, -4, -4, -6, -2, -6, -7, -4, -8, -5, 0, -2, -5, -3, 6, 0, -6, -5, -7, 0, -1, 0, -5, 0, 0, -3, -17, 0, }, |
| 450 |
{ -1, -8, -5, -6, -9, -6, -7, -2, -3, -7, -4, -2, -4, -5, -6, 0, 7, -3, -13, -6, 0, -3, 0, -6, 0, 0, -4, -17, 0, }, |
| 451 |
{ -2, -6, -8, -6, -8, -5, -6, 2, -9, -2, -1, -8, -6, -7, -8, -6, -3, 7, -15, -7, 0, -8, 0, -6, 0, 0, -5, -17, 0, }, |
| 452 |
{ -13, -15, -15, -17, -4, -15, -7, -14, -12, -6, -13, -8, -14, -13, -2, -5, -13, -15, 13, -5, 0, -10, 0, -14, 0, 0, -11, -17, 0, }, |
| 453 |
{ -8, -4, -11, -8, 2, -14, -3, -6, -9, -7, -11, -4, -13, -12, -10, -7, -6, -7, -5, 10, 0, -6, 0, -9, 0, 0, -7, -17, 0, }, |
| 454 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 455 |
{ -3, -12, 6, 1, -10, -3, -1, -6, -2, -9, -10, 6, -7, -3, -7, -1, -3, -8, -10, -6, 0, 6, 0, 0, 0, 0, -5, -17, 0, }, |
| 456 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 457 |
{ -3, -14, 1, 6, -13, -5, -1, -6, -4, -7, -5, -3, -4, 6, -4, -5, -6, -6, -14, -9, 0, 0, 0, 6, 0, 0, -5, -17, 0, }, |
| 458 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 459 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 460 |
{ -3, -9, -5, -5, -8, -5, -5, -5, -5, -6, -5, -3, -5, -5, -6, -3, -4, -5, -11, -7, 0, -5, 0, -5, 0, 0, -5, -17, 0, }, |
| 461 |
{ -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, 0, -17, 0, -17, 0, 0, -17, 1, 0, }, |
| 462 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 463 |
}}, |
| 464 |
|
| 465 |
{ "PAM70", { |
| 466 |
|
| 467 |
{ 5, -4, -1, -1, -6, 0, -4, -2, -4, -4, -3, -2, 0, -2, -4, 1, 1, -1, -9, -5, 0, -1, 0, -1, 0, 0, -2, -11, 0, }, |
| 468 |
{ -4, 9, -9, -9, -8, -6, -5, -4, -9, -10, -9, -7, -5, -9, -5, -1, -5, -4, -11, -2, 0, -8, 0, -9, 0, 0, -6, -11, 0, }, |
| 469 |
{ -1, -9, 6, 3, -10, -1, -1, -5, -2, -8, -7, 3, -4, 0, -6, -1, -2, -5, -10, -7, 0, 5, 0, 2, 0, 0, -3, -11, 0, }, |
| 470 |
{ -1, -9, 3, 6, -9, -2, -2, -4, -2, -6, -4, 0, -3, 2, -5, -2, -3, -4, -11, -6, 0, 2, 0, 5, 0, 0, -3, -11, 0, }, |
| 471 |
{ -6, -8, -10, -9, 8, -7, -4, 0, -9, -1, -2, -6, -7, -9, -7, -4, -6, -5, -2, 4, 0, -7, 0, -9, 0, 0, -5, -11, 0, }, |
| 472 |
{ 0, -6, -1, -2, -7, 6, -6, -6, -5, -7, -6, -1, -3, -4, -6, 0, -3, -3, -10, -9, 0, -1, 0, -3, 0, 0, -3, -11, 0, }, |
| 473 |
{ -4, -5, -1, -2, -4, -6, 8, -6, -3, -4, -6, 1, -2, 2, 0, -3, -4, -4, -5, -1, 0, 0, 0, 1, 0, 0, -3, -11, 0, }, |
| 474 |
{ -2, -4, -5, -4, 0, -6, -6, 7, -4, 1, 1, -3, -5, -5, -3, -4, -1, 3, -9, -4, 0, -4, 0, -4, 0, 0, -3, -11, 0, }, |
| 475 |
{ -4, -9, -2, -2, -9, -5, -3, -4, 6, -5, 0, 0, -4, -1, 2, -2, -1, -6, -7, -7, 0, -1, 0, -2, 0, 0, -3, -11, 0, }, |
| 476 |
{ -4, -10, -8, -6, -1, -7, -4, 1, -5, 6, 2, -5, -5, -3, -6, -6, -4, 0, -4, -4, 0, -6, 0, -4, 0, 0, -4, -11, 0, }, |
| 477 |
{ -3, -9, -7, -4, -2, -6, -6, 1, 0, 2, 10, -5, -5, -2, -2, -3, -2, 0, -8, -7, 0, -6, 0, -3, 0, 0, -3, -11, 0, }, |
| 478 |
{ -2, -7, 3, 0, -6, -1, 1, -3, 0, -5, -5, 6, -3, -1, -3, 1, 0, -5, -6, -3, 0, 5, 0, -1, 0, 0, -2, -11, 0, }, |
| 479 |
{ 0, -5, -4, -3, -7, -3, -2, -5, -4, -5, -5, -3, 7, -1, -2, 0, -2, -3, -9, -9, 0, -4, 0, -2, 0, 0, -3, -11, 0, }, |
| 480 |
{ -2, -9, 0, 2, -9, -4, 2, -5, -1, -3, -2, -1, -1, 7, 0, -3, -3, -4, -8, -8, 0, -1, 0, 5, 0, 0, -2, -11, 0, }, |
| 481 |
{ -4, -5, -6, -5, -7, -6, 0, -3, 2, -6, -2, -3, -2, 0, 8, -1, -4, -5, 0, -7, 0, -4, 0, -2, 0, 0, -3, -11, 0, }, |
| 482 |
{ 1, -1, -1, -2, -4, 0, -3, -4, -2, -6, -3, 1, 0, -3, -1, 5, 2, -3, -3, -5, 0, 0, 0, -2, 0, 0, -1, -11, 0, }, |
| 483 |
{ 1, -5, -2, -3, -6, -3, -4, -1, -1, -4, -2, 0, -2, -3, -4, 2, 6, -1, -8, -4, 0, -1, 0, -3, 0, 0, -2, -11, 0, }, |
| 484 |
{ -1, -4, -5, -4, -5, -3, -4, 3, -6, 0, 0, -5, -3, -4, -5, -3, -1, 6, -10, -5, 0, -5, 0, -4, 0, 0, -2, -11, 0, }, |
| 485 |
{ -9, -11, -10, -11, -2, -10, -5, -9, -7, -4, -8, -6, -9, -8, 0, -3, -8, -10, 13, -3, 0, -7, 0, -10, 0, 0, -7, -11, 0, }, |
| 486 |
{ -5, -2, -7, -6, 4, -9, -1, -4, -7, -4, -7, -3, -9, -8, -7, -5, -4, -5, -3, 9, 0, -4, 0, -7, 0, 0, -5, -11, 0, }, |
| 487 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 488 |
{ -1, -8, 5, 2, -7, -1, 0, -4, -1, -6, -6, 5, -4, -1, -4, 0, -1, -5, -7, -4, 0, 5, 0, 1, 0, 0, -2, -11, 0, }, |
| 489 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 490 |
{ -1, -9, 2, 5, -9, -3, 1, -4, -2, -4, -3, -1, -2, 5, -2, -2, -3, -4, -10, -7, 0, 1, 0, 5, 0, 0, -3, -11, 0, }, |
| 491 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 492 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 493 |
{ -2, -6, -3, -3, -5, -3, -3, -3, -3, -4, -3, -2, -3, -2, -3, -1, -2, -2, -7, -5, 0, -2, 0, -3, 0, 0, -3, -11, 0, }, |
| 494 |
{ -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, 0, -11, 0, -11, 0, 0, -11, 1, 0, }, |
| 495 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 496 |
}}, |
| 497 |
|
| 498 |
{ "PAM120", { |
| 499 |
|
| 500 |
{ 3, -3, 0, 0, -4, 1, -3, -1, -2, -3, -2, -1, 1, -1, -3, 1, 1, 0, -7, -4, 0, 0, 0, -1, 0, 0, -1, -8, 0, }, |
| 501 |
{ -3, 9, -7, -7, -6, -4, -4, -3, -7, -7, -6, -5, -4, -7, -4, 0, -3, -3, -8, -1, 0, -6, 0, -7, 0, 0, -4, -8, 0, }, |
| 502 |
{ 0, -7, 5, 3, -7, 0, 0, -3, -1, -5, -4, 2, -3, 1, -3, 0, -1, -3, -8, -5, 0, 4, 0, 3, 0, 0, -2, -8, 0, }, |
| 503 |
{ 0, -7, 3, 5, -7, -1, -1, -3, -1, -4, -3, 1, -2, 2, -3, -1, -2, -3, -8, -5, 0, 3, 0, 4, 0, 0, -1, -8, 0, }, |
| 504 |
{ -4, -6, -7, -7, 8, -5, -3, 0, -7, 0, -1, -4, -5, -6, -5, -3, -4, -3, -1, 4, 0, -5, 0, -6, 0, 0, -3, -8, 0, }, |
| 505 |
{ 1, -4, 0, -1, -5, 5, -4, -4, -3, -5, -4, 0, -2, -3, -4, 1, -1, -2, -8, -6, 0, 0, 0, -2, 0, 0, -2, -8, 0, }, |
| 506 |
{ -3, -4, 0, -1, -3, -4, 7, -4, -2, -3, -4, 2, -1, 3, 1, -2, -3, -3, -3, -1, 0, 1, 0, 1, 0, 0, -2, -8, 0, }, |
| 507 |
{ -1, -3, -3, -3, 0, -4, -4, 6, -3, 1, 1, -2, -3, -3, -2, -2, 0, 3, -6, -2, 0, -3, 0, -3, 0, 0, -1, -8, 0, }, |
| 508 |
{ -2, -7, -1, -1, -7, -3, -2, -3, 5, -4, 0, 1, -2, 0, 2, -1, -1, -4, -5, -5, 0, 0, 0, -1, 0, 0, -2, -8, 0, }, |
| 509 |
{ -3, -7, -5, -4, 0, -5, -3, 1, -4, 5, 3, -4, -3, -2, -4, -4, -3, 1, -3, -2, 0, -4, 0, -3, 0, 0, -2, -8, 0, }, |
| 510 |
{ -2, -6, -4, -3, -1, -4, -4, 1, 0, 3, 8, -3, -3, -1, -1, -2, -1, 1, -6, -4, 0, -4, 0, -2, 0, 0, -2, -8, 0, }, |
| 511 |
{ -1, -5, 2, 1, -4, 0, 2, -2, 1, -4, -3, 4, -2, 0, -1, 1, 0, -3, -4, -2, 0, 3, 0, 0, 0, 0, -1, -8, 0, }, |
| 512 |
{ 1, -4, -3, -2, -5, -2, -1, -3, -2, -3, -3, -2, 6, 0, -1, 1, -1, -2, -7, -6, 0, -2, 0, -1, 0, 0, -2, -8, 0, }, |
| 513 |
{ -1, -7, 1, 2, -6, -3, 3, -3, 0, -2, -1, 0, 0, 6, 1, -2, -2, -3, -6, -5, 0, 0, 0, 4, 0, 0, -1, -8, 0, }, |
| 514 |
{ -3, -4, -3, -3, -5, -4, 1, -2, 2, -4, -1, -1, -1, 1, 6, -1, -2, -3, 1, -5, 0, -2, 0, -1, 0, 0, -2, -8, 0, }, |
| 515 |
{ 1, 0, 0, -1, -3, 1, -2, -2, -1, -4, -2, 1, 1, -2, -1, 3, 2, -2, -2, -3, 0, 0, 0, -1, 0, 0, -1, -8, 0, }, |
| 516 |
{ 1, -3, -1, -2, -4, -1, -3, 0, -1, -3, -1, 0, -1, -2, -2, 2, 4, 0, -6, -3, 0, 0, 0, -2, 0, 0, -1, -8, 0, }, |
| 517 |
{ 0, -3, -3, -3, -3, -2, -3, 3, -4, 1, 1, -3, -2, -3, -3, -2, 0, 5, -8, -3, 0, -3, 0, -3, 0, 0, -1, -8, 0, }, |
| 518 |
{ -7, -8, -8, -8, -1, -8, -3, -6, -5, -3, -6, -4, -7, -6, 1, -2, -6, -8, 12, -2, 0, -6, 0, -7, 0, 0, -5, -8, 0, }, |
| 519 |
{ -4, -1, -5, -5, 4, -6, -1, -2, -5, -2, -4, -2, -6, -5, -5, -3, -3, -3, -2, 8, 0, -3, 0, -5, 0, 0, -3, -8, 0, }, |
| 520 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 521 |
{ 0, -6, 4, 3, -5, 0, 1, -3, 0, -4, -4, 3, -2, 0, -2, 0, 0, -3, -6, -3, 0, 4, 0, 2, 0, 0, -1, -8, 0, }, |
| 522 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 523 |
{ -1, -7, 3, 4, -6, -2, 1, -3, -1, -3, -2, 0, -1, 4, -1, -1, -2, -3, -7, -5, 0, 2, 0, 4, 0, 0, -1, -8, 0, }, |
| 524 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 525 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 526 |
{ -1, -4, -2, -1, -3, -2, -2, -1, -2, -2, -2, -1, -2, -1, -2, -1, -1, -1, -5, -3, 0, -1, 0, -1, 0, 0, -2, -8, 0, }, |
| 527 |
{ -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, 0, -8, 0, -8, 0, 0, -8, 1, 0, }, |
| 528 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 529 |
}}, |
| 530 |
|
| 531 |
{ "PAM240", { |
| 532 |
|
| 533 |
{ 2, -2, 0, 0, -4, 1, -1, -1, -1, -2, -1, 0, 1, 0, -2, 1, 1, 0, -6, -4, 0, 0, 0, 0, 0, 0, 0, -8, 0, }, |
| 534 |
{ -2, 12, -5, -6, -5, -4, -4, -2, -6, -6, -5, -4, -3, -6, -4, 0, -2, -2, -8, 0, 0, -5, 0, -6, 0, 0, -3, -8, 0, }, |
| 535 |
{ 0, -5, 4, 4, -6, 1, 1, -2, 0, -4, -3, 2, -1, 2, -1, 0, 0, -2, -7, -4, 0, 3, 0, 3, 0, 0, -1, -8, 0, }, |
| 536 |
{ 0, -6, 4, 4, -6, 0, 1, -2, 0, -3, -2, 1, -1, 3, -1, 0, 0, -2, -7, -4, 0, 3, 0, 3, 0, 0, -1, -8, 0, }, |
| 537 |
{ -4, -5, -6, -6, 9, -5, -2, 1, -5, 2, 0, -4, -5, -5, -5, -3, -3, -1, 0, 7, 0, -5, 0, -5, 0, 0, -2, -8, 0, }, |
| 538 |
{ 1, -4, 1, 0, -5, 5, -2, -3, -2, -4, -3, 0, -1, -1, -3, 1, 0, -1, -7, -5, 0, 0, 0, 0, 0, 0, -1, -8, 0, }, |
| 539 |
{ -1, -4, 1, 1, -2, -2, 7, -3, 0, -2, -2, 2, 0, 3, 2, -1, -1, -2, -3, 0, 0, 1, 0, 2, 0, 0, -1, -8, 0, }, |
| 540 |
{ -1, -2, -2, -2, 1, -3, -3, 5, -2, 2, 2, -2, -2, -2, -2, -1, 0, 4, -5, -1, 0, -2, 0, -2, 0, 0, -1, -8, 0, }, |
| 541 |
{ -1, -6, 0, 0, -5, -2, 0, -2, 5, -3, 0, 1, -1, 1, 3, 0, 0, -3, -4, -5, 0, 1, 0, 0, 0, 0, -1, -8, 0, }, |
| 542 |
{ -2, -6, -4, -3, 2, -4, -2, 2, -3, 6, 4, -3, -3, -2, -3, -3, -2, 2, -2, -1, 0, -4, 0, -3, 0, 0, -1, -8, 0, }, |
| 543 |
{ -1, -5, -3, -2, 0, -3, -2, 2, 0, 4, 7, -2, -2, -1, 0, -2, -1, 2, -4, -3, 0, -2, 0, -2, 0, 0, -1, -8, 0, }, |
| 544 |
{ 0, -4, 2, 1, -4, 0, 2, -2, 1, -3, -2, 2, -1, 1, 0, 1, 0, -2, -4, -2, 0, 2, 0, 1, 0, 0, 0, -8, 0, }, |
| 545 |
{ 1, -3, -1, -1, -5, -1, 0, -2, -1, -3, -2, -1, 6, 0, 0, 1, 0, -1, -6, -5, 0, -1, 0, 0, 0, 0, -1, -8, 0, }, |
| 546 |
{ 0, -6, 2, 3, -5, -1, 3, -2, 1, -2, -1, 1, 0, 4, 1, -1, -1, -2, -5, -4, 0, 1, 0, 3, 0, 0, -1, -8, 0, }, |
| 547 |
{ -2, -4, -1, -1, -5, -3, 2, -2, 3, -3, 0, 0, 0, 1, 6, 0, -1, -3, 2, -4, 0, -1, 0, 0, 0, 0, -1, -8, 0, }, |
| 548 |
{ 1, 0, 0, 0, -3, 1, -1, -1, 0, -3, -2, 1, 1, -1, 0, 2, 1, -1, -3, -3, 0, 0, 0, 0, 0, 0, 0, -8, 0, }, |
| 549 |
{ 1, -2, 0, 0, -3, 0, -1, 0, 0, -2, -1, 0, 0, -1, -1, 1, 3, 0, -5, -3, 0, 0, 0, -1, 0, 0, 0, -8, 0, }, |
| 550 |
{ 0, -2, -2, -2, -1, -1, -2, 4, -3, 2, 2, -2, -1, -2, -3, -1, 0, 4, -6, -3, 0, -2, 0, -2, 0, 0, -1, -8, 0, }, |
| 551 |
{ -6, -8, -7, -7, 0, -7, -3, -5, -4, -2, -4, -4, -6, -5, 2, -3, -5, -6, 17, 0, 0, -5, 0, -6, 0, 0, -4, -8, 0, }, |
| 552 |
{ -4, 0, -4, -4, 7, -5, 0, -1, -5, -1, -3, -2, -5, -4, -4, -3, -3, -3, 0, 10, 0, -3, 0, -4, 0, 0, -2, -8, 0, }, |
| 553 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 554 |
{ 0, -5, 3, 3, -5, 0, 1, -2, 1, -4, -2, 2, -1, 1, -1, 0, 0, -2, -5, -3, 0, 3, 0, 2, 0, 0, -1, -8, 0, }, |
| 555 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 556 |
{ 0, -6, 3, 3, -5, 0, 2, -2, 0, -3, -2, 1, 0, 3, 0, 0, -1, -2, -6, -4, 0, 2, 0, 3, 0, 0, -1, -8, 0, }, |
| 557 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 558 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 559 |
{ 0, -3, -1, -1, -2, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, 0, 0, -1, -4, -2, 0, -1, 0, -1, 0, 0, -1, -8, 0, }, |
| 560 |
{ -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, 0, -8, 0, -8, 0, 0, -8, 1, 0, }, |
| 561 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 562 |
}}, |
| 563 |
|
| 564 |
{ "BLOSUM45", { |
| 565 |
|
| 566 |
{ 5, -1, -2, -1, -2, 0, -2, -1, -1, -1, -1, -1, -1, -1, -2, 1, 0, 0, -2, -2, 0, -1, 0, -1, 0, 0, 0, -5, 0, }, |
| 567 |
{ -1, 12, -3, -3, -2, -3, -3, -3, -3, -2, -2, -2, -4, -3, -3, -1, -1, -1, -5, -3, 0, -2, 0, -3, 0, 0, -2, -5, 0, }, |
| 568 |
{ -2, -3, 7, 2, -4, -1, 0, -4, 0, -3, -3, 2, -1, 0, -1, 0, -1, -3, -4, -2, 0, 5, 0, 1, 0, 0, -1, -5, 0, }, |
| 569 |
{ -1, -3, 2, 6, -3, -2, 0, -3, 1, -2, -2, 0, 0, 2, 0, 0, -1, -3, -3, -2, 0, 1, 0, 4, 0, 0, -1, -5, 0, }, |
| 570 |
{ -2, -2, -4, -3, 8, -3, -2, 0, -3, 1, 0, -2, -3, -4, -2, -2, -1, 0, 1, 3, 0, -3, 0, -3, 0, 0, -1, -5, 0, }, |
| 571 |
{ 0, -3, -1, -2, -3, 7, -2, -4, -2, -3, -2, 0, -2, -2, -2, 0, -2, -3, -2, -3, 0, -1, 0, -2, 0, 0, -1, -5, 0, }, |
| 572 |
{ -2, -3, 0, 0, -2, -2, 10, -3, -1, -2, 0, 1, -2, 1, 0, -1, -2, -3, -3, 2, 0, 0, 0, 0, 0, 0, -1, -5, 0, }, |
| 573 |
{ -1, -3, -4, -3, 0, -4, -3, 5, -3, 2, 2, -2, -2, -2, -3, -2, -1, 3, -2, 0, 0, -3, 0, -3, 0, 0, -1, -5, 0, }, |
| 574 |
{ -1, -3, 0, 1, -3, -2, -1, -3, 5, -3, -1, 0, -1, 1, 3, -1, -1, -2, -2, -1, 0, 0, 0, 1, 0, 0, -1, -5, 0, }, |
| 575 |
{ -1, -2, -3, -2, 1, -3, -2, 2, -3, 5, 2, -3, -3, -2, -2, -3, -1, 1, -2, 0, 0, -3, 0, -2, 0, 0, -1, -5, 0, }, |
| 576 |
{ -1, -2, -3, -2, 0, -2, 0, 2, -1, 2, 6, -2, -2, 0, -1, -2, -1, 1, -2, 0, 0, -2, 0, -1, 0, 0, -1, -5, 0, }, |
| 577 |
{ -1, -2, 2, 0, -2, 0, 1, -2, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2, 0, 4, 0, 0, 0, 0, -1, -5, 0, }, |
| 578 |
{ -1, -4, -1, 0, -3, -2, -2, -2, -1, -3, -2, -2, 9, -1, -2, -1, -1, -3, -3, -3, 0, -2, 0, -1, 0, 0, -1, -5, 0, }, |
| 579 |
{ -1, -3, 0, 2, -4, -2, 1, -2, 1, -2, 0, 0, -1, 6, 1, 0, -1, -3, -2, -1, 0, 0, 0, 4, 0, 0, -1, -5, 0, }, |
| 580 |
{ -2, -3, -1, 0, -2, -2, 0, -3, 3, -2, -1, 0, -2, 1, 7, -1, -1, -2, -2, -1, 0, -1, 0, 0, 0, 0, -1, -5, 0, }, |
| 581 |
{ 1, -1, 0, 0, -2, 0, -1, -2, -1, -3, -2, 1, -1, 0, -1, 4, 2, -1, -4, -2, 0, 0, 0, 0, 0, 0, 0, -5, 0, }, |
| 582 |
{ 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 2, 5, 0, -3, -1, 0, 0, 0, -1, 0, 0, 0, -5, 0, }, |
| 583 |
{ 0, -1, -3, -3, 0, -3, -3, 3, -2, 1, 1, -3, -3, -3, -2, -1, 0, 5, -3, -1, 0, -3, 0, -3, 0, 0, -1, -5, 0, }, |
| 584 |
{ -2, -5, -4, -3, 1, -2, -3, -2, -2, -2, -2, -4, -3, -2, -2, -4, -3, -3, 15, 3, 0, -4, 0, -2, 0, 0, -2, -5, 0, }, |
| 585 |
{ -2, -3, -2, -2, 3, -3, 2, 0, -1, 0, 0, -2, -3, -1, -1, -2, -1, -1, 3, 8, 0, -2, 0, -2, 0, 0, -1, -5, 0, }, |
| 586 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 587 |
{ -1, -2, 5, 1, -3, -1, 0, -3, 0, -3, -2, 4, -2, 0, -1, 0, 0, -3, -4, -2, 0, 4, 0, 2, 0, 0, -1, -5, 0, }, |
| 588 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 589 |
{ -1, -3, 1, 4, -3, -2, 0, -3, 1, -2, -1, 0, -1, 4, 0, 0, -1, -3, -2, -2, 0, 2, 0, 4, 0, 0, -1, -5, 0, }, |
| 590 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 591 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 592 |
{ 0, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, -2, -1, 0, -1, 0, -1, 0, 0, -1, -5, 0, }, |
| 593 |
{ -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, 0, -5, 0, -5, 0, 0, -5, 1, 0, }, |
| 594 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 595 |
}}, |
| 596 |
|
| 597 |
{ "BLOSUM50", { |
| 598 |
|
| 599 |
{ 5, -1, -2, -1, -3, 0, -2, -1, -1, -2, -1, -1, -1, -1, -2, 1, 0, 0, -3, -2, 0, -2, 0, -1, 0, 0, -1, -5, 0, }, |
| 600 |
{ -1, 13, -4, -3, -2, -3, -3, -2, -3, -2, -2, -2, -4, -3, -4, -1, -1, -1, -5, -3, 0, -3, 0, -3, 0, 0, -2, -5, 0, }, |
| 601 |
{ -2, -4, 8, 2, -5, -1, -1, -4, -1, -4, -4, 2, -1, 0, -2, 0, -1, -4, -5, -3, 0, 5, 0, 1, 0, 0, -1, -5, 0, }, |
| 602 |
{ -1, -3, 2, 6, -3, -3, 0, -4, 1, -3, -2, 0, -1, 2, 0, -1, -1, -3, -3, -2, 0, 1, 0, 5, 0, 0, -1, -5, 0, }, |
| 603 |
{ -3, -2, -5, -3, 8, -4, -1, 0, -4, 1, 0, -4, -4, -4, -3, -3, -2, -1, 1, 4, 0, -4, 0, -4, 0, 0, -2, -5, 0, }, |
| 604 |
{ 0, -3, -1, -3, -4, 8, -2, -4, -2, -4, -3, 0, -2, -2, -3, 0, -2, -4, -3, -3, 0, -1, 0, -2, 0, 0, -2, -5, 0, }, |
| 605 |
{ -2, -3, -1, 0, -1, -2, 10, -4, 0, -3, -1, 1, -2, 1, 0, -1, -2, -4, -3, 2, 0, 0, 0, 0, 0, 0, -1, -5, 0, }, |
| 606 |
{ -1, -2, -4, -4, 0, -4, -4, 5, -3, 2, 2, -3, -3, -3, -4, -3, -1, 4, -3, -1, 0, -4, 0, -3, 0, 0, -1, -5, 0, }, |
| 607 |
{ -1, -3, -1, 1, -4, -2, 0, -3, 6, -3, -2, 0, -1, 2, 3, 0, -1, -3, -3, -2, 0, 0, 0, 1, 0, 0, -1, -5, 0, }, |
| 608 |
{ -2, -2, -4, -3, 1, -4, -3, 2, -3, 5, 3, -4, -4, -2, -3, -3, -1, 1, -2, -1, 0, -4, 0, -3, 0, 0, -1, -5, 0, }, |
| 609 |
{ -1, -2, -4, -2, 0, -3, -1, 2, -2, 3, 7, -2, -3, 0, -2, -2, -1, 1, -1, 0, 0, -3, 0, -1, 0, 0, -1, -5, 0, }, |
| 610 |
{ -1, -2, 2, 0, -4, 0, 1, -3, 0, -4, -2, 7, -2, 0, -1, 1, 0, -3, -4, -2, 0, 4, 0, 0, 0, 0, -1, -5, 0, }, |
| 611 |
{ -1, -4, -1, -1, -4, -2, -2, -3, -1, -4, -3, -2, 10, -1, -3, -1, -1, -3, -4, -3, 0, -2, 0, -1, 0, 0, -2, -5, 0, }, |
| 612 |
{ -1, -3, 0, 2, -4, -2, 1, -3, 2, -2, 0, 0, -1, 7, 1, 0, -1, -3, -1, -1, 0, 0, 0, 4, 0, 0, -1, -5, 0, }, |
| 613 |
{ -2, -4, -2, 0, -3, -3, 0, -4, 3, -3, -2, -1, -3, 1, 7, -1, -1, -3, -3, -1, 0, -1, 0, 0, 0, 0, -1, -5, 0, }, |
| 614 |
{ 1, -1, 0, -1, -3, 0, -1, -3, 0, -3, -2, 1, -1, 0, -1, 5, 2, -2, -4, -2, 0, 0, 0, 0, 0, 0, -1, -5, 0, }, |
| 615 |
{ 0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 2, 5, 0, -3, -2, 0, 0, 0, -1, 0, 0, 0, -5, 0, }, |
| 616 |
{ 0, -1, -4, -3, -1, -4, -4, 4, -3, 1, 1, -3, -3, -3, -3, -2, 0, 5, -3, -1, 0, -4, 0, -3, 0, 0, -1, -5, 0, }, |
| 617 |
{ -3, -5, -5, -3, 1, -3, -3, -3, -3, -2, -1, -4, -4, -1, -3, -4, -3, -3, 15, 2, 0, -5, 0, -2, 0, 0, -3, -5, 0, }, |
| 618 |
{ -2, -3, -3, -2, 4, -3, 2, -1, -2, -1, 0, -2, -3, -1, -1, -2, -2, -1, 2, 8, 0, -3, 0, -2, 0, 0, -1, -5, 0, }, |
| 619 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 620 |
{ -2, -3, 5, 1, -4, -1, 0, -4, 0, -4, -3, 4, -2, 0, -1, 0, 0, -4, -5, -3, 0, 5, 0, 2, 0, 0, -1, -5, 0, }, |
| 621 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 622 |
{ -1, -3, 1, 5, -4, -2, 0, -3, 1, -3, -1, 0, -1, 4, 0, 0, -1, -3, -2, -2, 0, 2, 0, 5, 0, 0, -1, -5, 0, }, |
| 623 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 624 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 625 |
{ -1, -2, -1, -1, -2, -2, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, 0, -1, -3, -1, 0, -1, 0, -1, 0, 0, -1, -5, 0, }, |
| 626 |
{ -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, 0, -5, 0, -5, 0, 0, -5, 1, 0, }, |
| 627 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 628 |
}}, |
| 629 |
|
| 630 |
{ "BLOSUM62", { |
| 631 |
|
| 632 |
{ 4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2, 0, -2, 0, -1, 0, 0, 0, -4, 0, }, |
| 633 |
{ 0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2, 0, -3, 0, -3, 0, 0, -2, -4, 0, }, |
| 634 |
{ -2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3, 0, 4, 0, 1, 0, 0, -1, -4, 0, }, |
| 635 |
{ -1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2, 0, 1, 0, 4, 0, 0, -1, -4, 0, }, |
| 636 |
{ -2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3, 0, -3, 0, -3, 0, 0, -1, -4, 0, }, |
| 637 |
{ 0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3, 0, -1, 0, -2, 0, 0, -1, -4, 0, }, |
| 638 |
{ -2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2, 0, 0, 0, 0, 0, 0, -1, -4, 0, }, |
| 639 |
{ -1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1, 0, -3, 0, -3, 0, 0, -1, -4, 0, }, |
| 640 |
{ -1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2, 0, 0, 0, 1, 0, 0, -1, -4, 0, }, |
| 641 |
{ -1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1, 0, -4, 0, -3, 0, 0, -1, -4, 0, }, |
| 642 |
{ -1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1, 0, -3, 0, -1, 0, 0, -1, -4, 0, }, |
| 643 |
{ -2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2, 0, 3, 0, 0, 0, 0, -1, -4, 0, }, |
| 644 |
{ -1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3, 0, -2, 0, -1, 0, 0, -2, -4, 0, }, |
| 645 |
{ -1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1, 0, 0, 0, 3, 0, 0, -1, -4, 0, }, |
| 646 |
{ -1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2, 0, -1, 0, 0, 0, 0, -1, -4, 0, }, |
| 647 |
{ 1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2, 0, 0, 0, 0, 0, 0, 0, -4, 0, }, |
| 648 |
{ 0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2, 0, -1, 0, -1, 0, 0, 0, -4, 0, }, |
| 649 |
{ 0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1, 0, -3, 0, -2, 0, 0, -1, -4, 0, }, |
| 650 |
{ -3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2, 0, -4, 0, -3, 0, 0, -2, -4, 0, }, |
| 651 |
{ -2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7, 0, -3, 0, -2, 0, 0, -1, -4, 0, }, |
| 652 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 653 |
{ -2, -3, 4, 1, -3, -1, 0, -3, 0, -4, -3, 3, -2, 0, -1, 0, -1, -3, -4, -3, 0, 4, 0, 1, 0, 0, -1, -4, 0, }, |
| 654 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 655 |
{ -1, -3, 1, 4, -3, -2, 0, -3, 1, -3, -1, 0, -1, 3, 0, 0, -1, -2, -3, -2, 0, 1, 0, 4, 0, 0, -1, -4, 0, }, |
| 656 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 657 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 658 |
{ 0, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, 0, 0, -1, -2, -1, 0, -1, 0, -1, 0, 0, -1, -4, 0, }, |
| 659 |
{ -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, 0, -4, 0, -4, 0, 0, -4, 1, 0, }, |
| 660 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 661 |
}}, |
| 662 |
|
| 663 |
{ "BLOSUM80", { |
| 664 |
|
| 665 |
{ 7, -1, -3, -2, -4, 0, -3, -3, -1, -3, -2, -3, -1, -2, -3, 2, 0, -1, -5, -4, 0, -3, 0, -2, 0, 0, -1, -8, 0, }, |
| 666 |
{ -1, 13, -7, -7, -4, -6, -7, -2, -6, -3, -3, -5, -6, -5, -6, -2, -2, -2, -5, -5, 0, -6, 0, -7, 0, 0, -4, -8, 0, }, |
| 667 |
{ -3, -7, 10, 2, -6, -3, -2, -7, -2, -7, -6, 2, -3, -1, -3, -1, -2, -6, -8, -6, 0, 6, 0, 1, 0, 0, -3, -8, 0, }, |
| 668 |
{ -2, -7, 2, 8, -6, -4, 0, -6, 1, -6, -4, -1, -2, 3, -1, -1, -2, -4, -6, -5, 0, 1, 0, 6, 0, 0, -2, -8, 0, }, |
| 669 |
{ -4, -4, -6, -6, 10, -6, -2, -1, -5, 0, 0, -6, -6, -5, -5, -4, -4, -2, 0, 4, 0, -6, 0, -6, 0, 0, -3, -8, 0, }, |
| 670 |
{ 0, -6, -3, -4, -6, 9, -4, -7, -3, -7, -5, -1, -5, -4, -4, -1, -3, -6, -6, -6, 0, -2, 0, -4, 0, 0, -3, -8, 0, }, |
| 671 |
{ -3, -7, -2, 0, -2, -4, 12, -6, -1, -5, -4, 1, -4, 1, 0, -2, -3, -5, -4, 3, 0, -1, 0, 0, 0, 0, -2, -8, 0, }, |
| 672 |
{ -3, -2, -7, -6, -1, -7, -6, 7, -5, 2, 2, -6, -5, -5, -5, -4, -2, 4, -5, -3, 0, -6, 0, -6, 0, 0, -2, -8, 0, }, |
| 673 |
{ -1, -6, -2, 1, -5, -3, -1, -5, 8, -4, -3, 0, -2, 2, 3, -1, -1, -4, -6, -4, 0, -1, 0, 1, 0, 0, -2, -8, 0, }, |
| 674 |
{ -3, -3, -7, -6, 0, -7, -5, 2, -4, 6, 3, -6, -5, -4, -4, -4, -3, 1, -4, -2, 0, -7, 0, -5, 0, 0, -2, -8, 0, }, |
| 675 |
{ -2, -3, -6, -4, 0, -5, -4, 2, -3, 3, 9, -4, -4, -1, -3, -3, -1, 1, -3, -3, 0, -5, 0, -3, 0, 0, -2, -8, 0, }, |
| 676 |
{ -3, -5, 2, -1, -6, -1, 1, -6, 0, -6, -4, 9, -4, 0, -1, 1, 0, -5, -7, -4, 0, 5, 0, -1, 0, 0, -2, -8, 0, }, |
| 677 |
{ -1, -6, -3, -2, -6, -5, -4, -5, -2, -5, -4, -4, 12, -3, -3, -2, -3, -4, -7, -6, 0, -4, 0, -2, 0, 0, -3, -8, 0, }, |
| 678 |
{ -2, -5, -1, 3, -5, -4, 1, -5, 2, -4, -1, 0, -3, 9, 1, -1, -1, -4, -4, -3, 0, -1, 0, 5, 0, 0, -2, -8, 0, }, |
| 679 |
{ -3, -6, -3, -1, -5, -4, 0, -5, 3, -4, -3, -1, -3, 1, 9, -2, -2, -4, -5, -4, 0, -2, 0, 0, 0, 0, -2, -8, 0, }, |
| 680 |
{ 2, -2, -1, -1, -4, -1, -2, -4, -1, -4, -3, 1, -2, -1, -2, 7, 2, -3, -6, -3, 0, 0, 0, -1, 0, 0, -1, -8, 0, }, |
| 681 |
{ 0, -2, -2, -2, -4, -3, -3, -2, -1, -3, -1, 0, -3, -1, -2, 2, 8, 0, -5, -3, 0, -1, 0, -2, 0, 0, -1, -8, 0, }, |
| 682 |
{ -1, -2, -6, -4, -2, -6, -5, 4, -4, 1, 1, -5, -4, -4, -4, -3, 0, 7, -5, -3, 0, -6, 0, -4, 0, 0, -2, -8, 0, }, |
| 683 |
{ -5, -5, -8, -6, 0, -6, -4, -5, -6, -4, -3, -7, -7, -4, -5, -6, -5, -5, 16, 3, 0, -8, 0, -5, 0, 0, -5, -8, 0, }, |
| 684 |
{ -4, -5, -6, -5, 4, -6, 3, -3, -4, -2, -3, -4, -6, -3, -4, -3, -3, -3, 3, 11, 0, -5, 0, -4, 0, 0, -3, -8, 0, }, |
| 685 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 686 |
{ -3, -6, 6, 1, -6, -2, -1, -6, -1, -7, -5, 5, -4, -1, -2, 0, -1, -6, -8, -5, 0, 6, 0, 0, 0, 0, -3, -8, 0, }, |
| 687 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 688 |
{ -2, -7, 1, 6, -6, -4, 0, -6, 1, -5, -3, -1, -2, 5, 0, -1, -2, -4, -5, -4, 0, 0, 0, 6, 0, 0, -1, -8, 0, }, |
| 689 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 690 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 691 |
{ -1, -4, -3, -2, -3, -3, -2, -2, -2, -2, -2, -2, -3, -2, -2, -1, -1, -2, -5, -3, 0, -3, 0, -1, 0, 0, -2, -8, 0, }, |
| 692 |
{ -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, 0, -8, 0, -8, 0, 0, -8, 1, 0, }, |
| 693 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 694 |
}}, |
| 695 |
|
| 696 |
{ "BLOSUM90", { |
| 697 |
|
| 698 |
{ 5, -1, -3, -1, -3, 0, -2, -2, -1, -2, -2, -2, -1, -1, -2, 1, 0, -1, -4, -3, 0, -2, 0, -1, 0, 0, -1, -6, 0, }, |
| 699 |
{ -1, 9, -5, -6, -3, -4, -5, -2, -4, -2, -2, -4, -4, -4, -5, -2, -2, -2, -4, -4, 0, -4, 0, -5, 0, 0, -3, -6, 0, }, |
| 700 |
{ -3, -5, 7, 1, -5, -2, -2, -5, -1, -5, -4, 1, -3, -1, -3, -1, -2, -5, -6, -4, 0, 4, 0, 0, 0, 0, -2, -6, 0, }, |
| 701 |
{ -1, -6, 1, 6, -5, -3, -1, -4, 0, -4, -3, -1, -2, 2, -1, -1, -1, -3, -5, -4, 0, 0, 0, 4, 0, 0, -2, -6, 0, }, |
| 702 |
{ -3, -3, -5, -5, 7, -5, -2, -1, -4, 0, -1, -4, -4, -4, -4, -3, -3, -2, 0, 3, 0, -4, 0, -4, 0, 0, -2, -6, 0, }, |
| 703 |
{ 0, -4, -2, -3, -5, 6, -3, -5, -2, -5, -4, -1, -3, -3, -3, -1, -3, -5, -4, -5, 0, -2, 0, -3, 0, 0, -2, -6, 0, }, |
| 704 |
{ -2, -5, -2, -1, -2, -3, 8, -4, -1, -4, -3, 0, -3, 1, 0, -2, -2, -4, -3, 1, 0, -1, 0, 0, 0, 0, -2, -6, 0, }, |
| 705 |
{ -2, -2, -5, -4, -1, -5, -4, 5, -4, 1, 1, -4, -4, -4, -4, -3, -1, 3, -4, -2, 0, -5, 0, -4, 0, 0, -2, -6, 0, }, |
| 706 |
{ -1, -4, -1, 0, -4, -2, -1, -4, 6, -3, -2, 0, -2, 1, 2, -1, -1, -3, -5, -3, 0, -1, 0, 1, 0, 0, -1, -6, 0, }, |
| 707 |
{ -2, -2, -5, -4, 0, -5, -4, 1, -3, 5, 2, -4, -4, -3, -3, -3, -2, 0, -3, -2, 0, -5, 0, -4, 0, 0, -2, -6, 0, }, |
| 708 |
{ -2, -2, -4, -3, -1, -4, -3, 1, -2, 2, 7, -3, -3, 0, -2, -2, -1, 0, -2, -2, 0, -4, 0, -2, 0, 0, -1, -6, 0, }, |
| 709 |
{ -2, -4, 1, -1, -4, -1, 0, -4, 0, -4, -3, 7, -3, 0, -1, 0, 0, -4, -5, -3, 0, 4, 0, -1, 0, 0, -2, -6, 0, }, |
| 710 |
{ -1, -4, -3, -2, -4, -3, -3, -4, -2, -4, -3, -3, 8, -2, -3, -2, -2, -3, -5, -4, 0, -3, 0, -2, 0, 0, -2, -6, 0, }, |
| 711 |
{ -1, -4, -1, 2, -4, -3, 1, -4, 1, -3, 0, 0, -2, 7, 1, -1, -1, -3, -3, -3, 0, -1, 0, 4, 0, 0, -1, -6, 0, }, |
| 712 |
{ -2, -5, -3, -1, -4, -3, 0, -4, 2, -3, -2, -1, -3, 1, 6, -1, -2, -3, -4, -3, 0, -2, 0, 0, 0, 0, -2, -6, 0, }, |
| 713 |
{ 1, -2, -1, -1, -3, -1, -2, -3, -1, -3, -2, 0, -2, -1, -1, 5, 1, -2, -4, -3, 0, 0, 0, -1, 0, 0, -1, -6, 0, }, |
| 714 |
{ 0, -2, -2, -1, -3, -3, -2, -1, -1, -2, -1, 0, -2, -1, -2, 1, 6, -1, -4, -2, 0, -1, 0, -1, 0, 0, -1, -6, 0, }, |
| 715 |
{ -1, -2, -5, -3, -2, -5, -4, 3, -3, 0, 0, -4, -3, -3, -3, -2, -1, 5, -3, -3, 0, -4, 0, -3, 0, 0, -2, -6, 0, }, |
| 716 |
{ -4, -4, -6, -5, 0, -4, -3, -4, -5, -3, -2, -5, -5, -3, -4, -4, -4, -3, 11, 2, 0, -6, 0, -4, 0, 0, -3, -6, 0, }, |
| 717 |
{ -3, -4, -4, -4, 3, -5, 1, -2, -3, -2, -2, -3, -4, -3, -3, -3, -2, -3, 2, 8, 0, -4, 0, -3, 0, 0, -2, -6, 0, }, |
| 718 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 719 |
{ -2, -4, 4, 0, -4, -2, -1, -5, -1, -5, -4, 4, -3, -1, -2, 0, -1, -4, -6, -4, 0, 4, 0, 0, 0, 0, -2, -6, 0, }, |
| 720 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 721 |
{ -1, -5, 0, 4, -4, -3, 0, -4, 1, -4, -2, -1, -2, 4, 0, -1, -1, -3, -4, -3, 0, 0, 0, 4, 0, 0, -1, -6, 0, }, |
| 722 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 723 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 724 |
{ -1, -3, -2, -2, -2, -2, -2, -2, -1, -2, -1, -2, -2, -1, -2, -1, -1, -2, -3, -2, 0, -2, 0, -1, 0, 0, -2, -6, 0, }, |
| 725 |
{ -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, 0, -6, 0, -6, 0, 0, -6, 1, 0, }, |
| 726 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 727 |
}}, |
| 728 |
}; |
| 729 |
|
| 730 |
|
| 731 |
#define eslNTDIM 18 |
| 732 |
|
| 733 |
struct esl_scorematrix_nt_preload_s { |
| 734 |
char *name; |
| 735 |
int matrix[eslNTDIM][eslNTDIM]; |
| 736 |
}; |
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
static const struct esl_scorematrix_nt_preload_s ESL_SCOREMATRIX_NT_PRELOADS[] = { |
| 763 |
{ "DNA1", { |
| 764 |
|
| 765 |
{ 41, -32, -26, -26, 0, 18, -29, 17, -26, -29, 18, 6, -28, 6, 7, 0, -38, 0, }, |
| 766 |
{ -32, 39, -38, -17, 0, -35, 18, 15, -26, 14, -24, 6, 6, 3, -28, -1, -38, 0, }, |
| 767 |
{ -26, -38, 46, -31, 0, 22, -34, -32, 21, 20, -29, -32, 8, 9, 10, 1, -38, 0, }, |
| 768 |
{ -26, -17, -31, 39, 0, -28, 18, -21, 15, -23, 16, 7, 7, -24, 5, 0, -38, 0, }, |
| 769 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 770 |
{ 18, -35, 22, -28, 0, 20, -32, -2, 3, 1, 0, -9, -7, 7, 8, 1, -38, 0, }, |
| 771 |
{ -29, 18, -34, 18, 0, -32, 18, 0, -1, -1, 0, 7, 6, -9, -9, -1, -38, 0, }, |
| 772 |
{ 17, 15, -32, -21, 0, -2, 0, 16, -26, -3, 1, 6, -8, 4, -7, -1, -38, 0, }, |
| 773 |
{ -26, -26, 21, 15, 0, 3, -1, -26, 18, 3, -1, -8, 7, -5, 7, 1, -38, 0, }, |
| 774 |
{ -29, 14, 20, -23, 0, 1, -1, -3, 3, 17, -26, -9, 7, 6, -6, 0, -38, 0, }, |
| 775 |
{ 18, -24, -29, 16, 0, 0, 0, 1, -1, -26, 17, 7, -8, -7, 6, 0, -38, 0, }, |
| 776 |
{ 6, 6, -32, 7, 0, -9, 7, 6, -8, -9, 7, 7, -3, -3, -3, 0, -38, 0, }, |
| 777 |
{ -28, 6, 8, 7, 0, -7, 6, -8, 7, 7, -8, -3, 7, -2, -2, 0, -38, 0, }, |
| 778 |
{ 6, 3, 9, -24, 0, 7, -9, 4, -5, 6, -7, -3, -2, 6, -1, 0, -38, 0, }, |
| 779 |
{ 7, -28, 10, 5, 0, 8, -9, -7, 7, -6, 6, -3, -2, -1, 7, 0, -38, 0, }, |
| 780 |
{ 0, -1, 1, 0, 0, 1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 781 |
{ -38, -38, -38, -38, 0, -38, -38, -38, -38, -38, -38, -38, -38, -38, -38, 0, -38, 0, }, |
| 782 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 783 |
}}, |
| 784 |
|
| 785 |
}; |
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
int |
| 814 |
esl_scorematrix_Set(const char *name, ESL_SCOREMATRIX *S) |
| 815 |
{ |
| 816 |
int which; |
| 817 |
int x, y; |
| 818 |
|
| 819 |
if (S->abc_r->type == eslAMINO) |
| 820 |
{ |
| 821 |
int nmat = sizeof(ESL_SCOREMATRIX_AA_PRELOADS) / sizeof(struct esl_scorematrix_aa_preload_s); |
| 822 |
for (which = 0; which < nmat; which++) |
| 823 |
if (strcmp(ESL_SCOREMATRIX_AA_PRELOADS[which].name, name) == 0) break; |
| 824 |
if (which >= nmat) return eslENOTFOUND; |
| 825 |
|
| 826 |
ESL_DASSERT1(( S->Kp >= 24 )); |
| 827 |
strcpy(S->outorder, "ARNDCQEGHILKMFPSTWYVBZX*"); |
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
for (x = 0; x < S->Kp; x++) |
| 835 |
for (y = 0; y < S->Kp; y++) |
| 836 |
S->s[x][y] = ESL_SCOREMATRIX_AA_PRELOADS[which].matrix[x][y]; |
| 837 |
|
| 838 |
} |
| 839 |
else if (S->abc_r->type == eslDNA || S->abc_r->type == eslRNA) |
| 840 |
{ |
| 841 |
int nmat = sizeof(ESL_SCOREMATRIX_NT_PRELOADS) / sizeof(struct esl_scorematrix_nt_preload_s); |
| 842 |
for (which = 0; which < nmat; which++) |
| 843 |
if (strcmp(ESL_SCOREMATRIX_NT_PRELOADS[which].name, name) == 0) break; |
| 844 |
if (which >= nmat) return eslENOTFOUND; |
| 845 |
|
| 846 |
ESL_DASSERT1(( S->Kp >= 15 )); |
| 847 |
strcpy(S->outorder, "ACGTRYMKSWHBVDN"); |
| 848 |
|
| 849 |
|
| 850 |
for (x = 0; x < S->Kp; x++) |
| 851 |
for (y = 0; y < S->Kp; y++) |
| 852 |
S->s[x][y] = ESL_SCOREMATRIX_NT_PRELOADS[which].matrix[x][y]; |
| 853 |
|
| 854 |
} |
| 855 |
else return eslENOTFOUND; |
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
S->nc = strlen(S->outorder); |
| 860 |
for (y = 0; y < S->nc; y++) { |
| 861 |
x = esl_abc_DigitizeSymbol(S->abc_r, S->outorder[y]); |
| 862 |
S->isval[x] = TRUE; |
| 863 |
} |
| 864 |
|
| 865 |
|
| 866 |
if (esl_strdup(name, -1, &(S->name)) != eslOK) return eslEMEM; |
| 867 |
return eslOK; |
| 868 |
} |
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
int |
| 883 |
esl_scorematrix_SetIdentity(ESL_SCOREMATRIX *S) |
| 884 |
{ |
| 885 |
int a; |
| 886 |
int x; |
| 887 |
|
| 888 |
for (a = 0; a < S->abc_r->Kp*S->abc_r->Kp; a++) S->s[0][a] = 0; |
| 889 |
for (a = 0; a < S->K; a++) S->s[a][a] = 1; |
| 890 |
|
| 891 |
for (x = 0; x < S->K; x++) S->isval[x] = TRUE; |
| 892 |
for (x = S->abc_r->K; x < S->Kp; x++) S->isval[x] = FALSE; |
| 893 |
|
| 894 |
strncpy(S->outorder, S->abc_r->sym, S->K); |
| 895 |
S->outorder[S->K] = '\0'; |
| 896 |
S->nc = S->K; |
| 897 |
return eslOK; |
| 898 |
} |
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
|
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
int |
| 929 |
esl_scorematrix_SetFromProbs(ESL_SCOREMATRIX *S, double lambda, const ESL_DMATRIX *P, const double *fi, const double *fj) |
| 930 |
{ |
| 931 |
int i,j; |
| 932 |
double sc; |
| 933 |
|
| 934 |
for (i = 0; i < S->abc_r->K; i++) |
| 935 |
for (j = 0; j < S->abc_r->K; j++) |
| 936 |
{ |
| 937 |
sc = log(P->mx[i][j] / (fi[i] * fj[j])) / lambda; |
| 938 |
S->s[i][j] = (int) (sc + (sc>0 ? 0.5 : -0.5)); |
| 939 |
} |
| 940 |
|
| 941 |
for (i = 0; i < S->abc_r->K; i++) |
| 942 |
S->isval[i] = TRUE; |
| 943 |
S->nc = S->abc_r->K; |
| 944 |
|
| 945 |
strncpy(S->outorder, S->abc_r->sym, S->abc_r->K); |
| 946 |
S->outorder[S->nc] = '\0'; |
| 947 |
return eslOK; |
| 948 |
} |
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
int |
| 970 |
esl_scorematrix_SetWAG(ESL_SCOREMATRIX *S, double lambda, double t) |
| 971 |
{ |
| 972 |
ESL_DMATRIX *Q = NULL; |
| 973 |
ESL_DMATRIX *P = NULL; |
| 974 |
static double wagpi[20]; |
| 975 |
int i,j; |
| 976 |
int status; |
| 977 |
|
| 978 |
if (S->K != 20) ESL_EXCEPTION(eslEINVAL, "Must be using an amino acid alphabet (K=20) to make WAG-based matrices"); |
| 979 |
|
| 980 |
if (( Q = esl_dmatrix_Create(20, 20)) == NULL) { status = eslEMEM; goto ERROR; } |
| 981 |
if (( P = esl_dmatrix_Create(20, 20)) == NULL) { status = eslEMEM; goto ERROR; } |
| 982 |
if ((status = esl_composition_WAG(wagpi)) != eslOK) goto ERROR; |
| 983 |
if ((status = esl_rmx_SetWAG(Q, wagpi)) != eslOK) goto ERROR; |
| 984 |
if ((status = esl_dmx_Exp(Q, t, P)) != eslOK) goto ERROR; |
| 985 |
|
| 986 |
for (i = 0; i < 20; i++) |
| 987 |
for (j = 0; j < 20; j++) |
| 988 |
P->mx[i][j] *= wagpi[i]; |
| 989 |
|
| 990 |
esl_scorematrix_SetFromProbs(S, lambda, P, wagpi, wagpi); |
| 991 |
|
| 992 |
if ((status = esl_strdup("WAG", -1, &(S->name))) != eslOK) goto ERROR; |
| 993 |
|
| 994 |
esl_dmatrix_Destroy(Q); |
| 995 |
esl_dmatrix_Destroy(P); |
| 996 |
return eslOK; |
| 997 |
|
| 998 |
ERROR: |
| 999 |
if (Q != NULL) esl_dmatrix_Destroy(Q); |
| 1000 |
if (Q != NULL) esl_dmatrix_Destroy(P); |
| 1001 |
return status; |
| 1002 |
} |
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
|
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
int |
| 1044 |
esl_scorematrix_Read(ESL_FILEPARSER *efp, const ESL_ALPHABET *abc, ESL_SCOREMATRIX **ret_S) |
| 1045 |
{ |
| 1046 |
int status; |
| 1047 |
ESL_SCOREMATRIX *S = NULL; |
| 1048 |
int *map = NULL; |
| 1049 |
char *tok; |
| 1050 |
int toklen; |
| 1051 |
int c, x; |
| 1052 |
int row,col; |
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
if ((S = esl_scorematrix_Create(abc)) == NULL) { status = eslEMEM; goto ERROR; } |
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
esl_fileparser_SetCommentChar(efp, '#'); |
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
if ((status = esl_fileparser_NextLine(efp)) != eslOK) ESL_XFAIL(eslEFORMAT, efp->errbuf, "file appears to be empty"); |
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
S->nc = 0; |
| 1072 |
while ((status = esl_fileparser_GetTokenOnLine(efp, &tok, &toklen)) == eslOK) |
| 1073 |
{ |
| 1074 |
if (S->nc >= abc->Kp) ESL_XFAIL(eslEFORMAT, efp->errbuf, "Header contains more residues than expected for alphabet"); |
| 1075 |
if (toklen != 1) ESL_XFAIL(eslEFORMAT, efp->errbuf, "Header can only contain single-char labels; %s is invalid", tok); |
| 1076 |
S->outorder[S->nc++] = *tok; |
| 1077 |
} |
| 1078 |
if (status != eslEOL) ESL_XFAIL(status, efp->errbuf, "Unexpected failure of esl_fileparser_GetTokenOnLine()"); |
| 1079 |
S->outorder[S->nc] = '\0'; |
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
ESL_ALLOC(map, sizeof(int) * S->nc); |
| 1086 |
for (c = 0; c < S->nc; c++) |
| 1087 |
{ |
| 1088 |
if (esl_abc_CIsValid(abc, S->outorder[c])) |
| 1089 |
{ |
| 1090 |
x = esl_abc_DigitizeSymbol(abc, S->outorder[c]); |
| 1091 |
map[c] = x; |
| 1092 |
S->isval[x] = TRUE; |
| 1093 |
} |
| 1094 |
else |
| 1095 |
ESL_XFAIL(eslEFORMAT, efp->errbuf, "Don't know how to deal with residue %c in matrix file", S->outorder[c]); |
| 1096 |
} |
| 1097 |
for (x = 0; x < abc->K; x++) |
| 1098 |
if (! S->isval[x]) ESL_XFAIL(eslEFORMAT, efp->errbuf, "Expected to see a column for residue %c", abc->sym[x]); |
| 1099 |
|
| 1100 |
|
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
for (row = 0; row < S->nc; row++) |
| 1105 |
{ |
| 1106 |
if ((status = esl_fileparser_NextLine(efp)) != eslOK) ESL_XFAIL(eslEFORMAT, efp->errbuf, "Unexpectedly ran out of lines in file"); |
| 1107 |
for (col = 0; col < S->nc; col++) |
| 1108 |
{ |
| 1109 |
if ((status = esl_fileparser_GetTokenOnLine(efp, &tok, &toklen)) != eslOK) ESL_XFAIL(eslEFORMAT, efp->errbuf, "Unexpectedly ran out of fields on line"); |
| 1110 |
if (col == 0 && *tok == S->outorder[row]) { col--; continue; } |
| 1111 |
|
| 1112 |
S->s[map[row]][map[col]] = atoi(tok); |
| 1113 |
} |
| 1114 |
if ((status = esl_fileparser_GetTokenOnLine(efp, &tok, &toklen)) != eslEOL) ESL_XFAIL(eslEFORMAT, efp->errbuf, "Too many fields on line"); |
| 1115 |
} |
| 1116 |
if ((status = esl_fileparser_NextLine(efp)) != eslEOF) ESL_XFAIL(eslEFORMAT, efp->errbuf, "Too many lines in file. (Make sure it's square & symmetric. E.g. use NUC.4.4 not NUC.4.2)"); |
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
if ((status = esl_strdup (efp->filename, -1, &(S->path))) != eslOK) goto ERROR; |
| 1121 |
if ((status = esl_FileTail(efp->filename, FALSE, &(S->name))) != eslOK) goto ERROR; |
| 1122 |
|
| 1123 |
free(map); |
| 1124 |
*ret_S = S; |
| 1125 |
return eslOK; |
| 1126 |
|
| 1127 |
ERROR: |
| 1128 |
esl_scorematrix_Destroy(S); |
| 1129 |
if (map != NULL) free(map); |
| 1130 |
*ret_S = NULL; |
| 1131 |
return status; |
| 1132 |
} |
| 1133 |
|
| 1134 |
|
| 1135 |
|
| 1136 |
|
| 1137 |
|
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
int |
| 1146 |
esl_scorematrix_Write(FILE *fp, const ESL_SCOREMATRIX *S) |
| 1147 |
{ |
| 1148 |
int a,b; |
| 1149 |
int x,y; |
| 1150 |
int nc = S->nc; |
| 1151 |
|
| 1152 |
|
| 1153 |
if (fprintf(fp, " ") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "score matrix write failed"); |
| 1154 |
for (a = 0; a < nc; a++) |
| 1155 |
{ if (fprintf(fp, " %c ", S->outorder[a]) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "score matrix write failed"); } |
| 1156 |
if (fprintf(fp, "\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "score matrix write failed"); |
| 1157 |
|
| 1158 |
|
| 1159 |
for (a = 0; a < nc; a++) |
| 1160 |
{ |
| 1161 |
if (fprintf(fp, "%c ", S->outorder[a]) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "score matrix write failed"); |
| 1162 |
for (b = 0; b < nc; b++) |
| 1163 |
{ |
| 1164 |
x = esl_abc_DigitizeSymbol(S->abc_r, S->outorder[a]); |
| 1165 |
y = esl_abc_DigitizeSymbol(S->abc_r, S->outorder[b]); |
| 1166 |
if (fprintf(fp, "%3d ", S->s[x][y]) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "score matrix write failed"); |
| 1167 |
} |
| 1168 |
if (fprintf(fp, "\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "score matrix write failed"); |
| 1169 |
} |
| 1170 |
return eslOK; |
| 1171 |
} |
| 1172 |
|
| 1173 |
|
| 1174 |
|
| 1175 |
|
| 1176 |
|
| 1177 |
|
| 1178 |
|
| 1179 |
|
| 1180 |
static int set_degenerate_probs(const ESL_ALPHABET *abc, ESL_DMATRIX *P, double *fi, double *fj); |
| 1181 |
|
| 1182 |
struct lambda_params { |
| 1183 |
const double *fi; |
| 1184 |
const double *fj; |
| 1185 |
const ESL_SCOREMATRIX *S; |
| 1186 |
}; |
| 1187 |
|
| 1188 |
static int |
| 1189 |
lambda_fdf(double lambda, void *params, double *ret_fx, double *ret_dfx) |
| 1190 |
{ |
| 1191 |
struct lambda_params *p = (struct lambda_params *) params; |
| 1192 |
int i,j; |
| 1193 |
double tmp; |
| 1194 |
|
| 1195 |
*ret_fx = 0.; |
| 1196 |
*ret_dfx = 0.; |
| 1197 |
for (i = 0; i < p->S->K; i++) |
| 1198 |
for (j = 0; j < p->S->K; j++) |
| 1199 |
{ |
| 1200 |
tmp = p->fi[i] * p->fj[j] * exp(lambda * (double) p->S->s[i][j]); |
| 1201 |
*ret_fx += tmp; |
| 1202 |
*ret_dfx += tmp * (double) p->S->s[i][j]; |
| 1203 |
} |
| 1204 |
*ret_fx -= 1.0; |
| 1205 |
return eslOK; |
| 1206 |
} |
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
|
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
|
| 1215 |
|
| 1216 |
|
| 1217 |
|
| 1218 |
|
| 1219 |
|
| 1220 |
|
| 1221 |
|
| 1222 |
|
| 1223 |
|
| 1224 |
|
| 1225 |
|
| 1226 |
|
| 1227 |
|
| 1228 |
|
| 1229 |
|
| 1230 |
|
| 1231 |
|
| 1232 |
|
| 1233 |
|
| 1234 |
|
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
|
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
|
| 1244 |
|
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
int |
| 1258 |
esl_scorematrix_ProbifyGivenBG(const ESL_SCOREMATRIX *S, const double *fi, const double *fj, |
| 1259 |
double *opt_lambda, ESL_DMATRIX **opt_P) |
| 1260 |
{ |
| 1261 |
ESL_ROOTFINDER *R = NULL; |
| 1262 |
ESL_DMATRIX *P = NULL; |
| 1263 |
struct lambda_params p; |
| 1264 |
double lambda_guess; |
| 1265 |
double lambda; |
| 1266 |
int i,j; |
| 1267 |
double fx, dfx; |
| 1268 |
int status; |
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
p.fi = fi; |
| 1273 |
p.fj = fj; |
| 1274 |
p.S = S; |
| 1275 |
|
| 1276 |
|
| 1277 |
|
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
fx = -1.0; |
| 1282 |
lambda_guess = 1. / (double) esl_scorematrix_Max(S); |
| 1283 |
for (; lambda_guess < 50.; lambda_guess *= 2.0) { |
| 1284 |
lambda_fdf(lambda_guess, &p, &fx, &dfx); |
| 1285 |
if (fx > 0) break; |
| 1286 |
} |
| 1287 |
if (fx <= 0) ESL_XEXCEPTION(eslEINVAL, "Failed to bracket root for solving lambda"); |
| 1288 |
|
| 1289 |
|
| 1290 |
if (( R = esl_rootfinder_CreateFDF(lambda_fdf, &p) ) == NULL) { status = eslEMEM; goto ERROR; } |
| 1291 |
if (( status = esl_root_NewtonRaphson(R, lambda_guess, &lambda)) != eslOK) goto ERROR; |
| 1292 |
|
| 1293 |
|
| 1294 |
if (opt_P != NULL) |
| 1295 |
{ |
| 1296 |
if ((P = esl_dmatrix_Create(S->Kp, S->Kp)) == NULL) { status = eslEMEM; goto ERROR; } |
| 1297 |
for (i = 0; i < S->K; i++) |
| 1298 |
for (j = 0; j < S->K; j++) |
| 1299 |
P->mx[i][j] = fi[i] * fj[j] * exp(lambda * (double) S->s[i][j]); |
| 1300 |
set_degenerate_probs(S->abc_r, P, NULL, NULL); |
| 1301 |
} |
| 1302 |
|
| 1303 |
esl_rootfinder_Destroy(R); |
| 1304 |
if (opt_lambda) *opt_lambda = lambda; |
| 1305 |
if (opt_P) *opt_P = P; |
| 1306 |
return eslOK; |
| 1307 |
|
| 1308 |
ERROR: |
| 1309 |
if (R) esl_rootfinder_Destroy(R); |
| 1310 |
if (opt_lambda) *opt_lambda = 0.; |
| 1311 |
if (opt_P) *opt_P = NULL; |
| 1312 |
return status; |
| 1313 |
} |
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
|
| 1338 |
|
| 1339 |
static int |
| 1340 |
set_degenerate_probs(const ESL_ALPHABET *abc, ESL_DMATRIX *P, double *fi, double *fj) |
| 1341 |
{ |
| 1342 |
int i,j; |
| 1343 |
int ip,jp; |
| 1344 |
|
| 1345 |
|
| 1346 |
|
| 1347 |
|
| 1348 |
for (i = 0; i < abc->K; i++) |
| 1349 |
{ |
| 1350 |
P->mx[i][abc->K] = 0.0; |
| 1351 |
for (jp = abc->K+1; jp < abc->Kp-2; jp++) |
| 1352 |
{ |
| 1353 |
P->mx[i][jp] = 0.0; |
| 1354 |
for (j = 0; j < abc->K; j++) |
| 1355 |
if (abc->degen[jp][j]) P->mx[i][jp] += P->mx[i][j]; |
| 1356 |
} |
| 1357 |
P->mx[i][abc->Kp-2] = 0.0; |
| 1358 |
P->mx[i][abc->Kp-1] = 0.0; |
| 1359 |
} |
| 1360 |
|
| 1361 |
esl_vec_DSet(P->mx[abc->K], abc->Kp, 0.0); |
| 1362 |
|
| 1363 |
|
| 1364 |
for (ip = abc->K+1; ip < abc->Kp-2; ip++) |
| 1365 |
{ |
| 1366 |
|
| 1367 |
for (j = 0; j < abc->K; j++) |
| 1368 |
{ |
| 1369 |
P->mx[ip][j] = 0.0; |
| 1370 |
for (i = 0; i < abc->K; i++) |
| 1371 |
if (abc->degen[ip][i]) P->mx[ip][j] += P->mx[i][j]; |
| 1372 |
} |
| 1373 |
P->mx[ip][abc->K] = 0.0; |
| 1374 |
|
| 1375 |
|
| 1376 |
for (jp = abc->K+1; jp < abc->Kp-2; jp++) |
| 1377 |
{ |
| 1378 |
P->mx[ip][jp] = 0.0; |
| 1379 |
for (j = 0; j < abc->K; j++) |
| 1380 |
if (abc->degen[jp][j]) P->mx[ip][jp] += P->mx[ip][j]; |
| 1381 |
} |
| 1382 |
P->mx[ip][abc->Kp-2] = 0.0; |
| 1383 |
P->mx[ip][abc->Kp-1] = 0.0; |
| 1384 |
} |
| 1385 |
|
| 1386 |
esl_vec_DSet(P->mx[abc->Kp-2], abc->Kp, 0.0); |
| 1387 |
esl_vec_DSet(P->mx[abc->Kp-1], abc->Kp, 0.0); |
| 1388 |
|
| 1389 |
if (fi != NULL) { |
| 1390 |
fi[abc->K] = 0.0; |
| 1391 |
for (ip = abc->K+1; ip < abc->Kp-2; ip++) fi[ip] = P->mx[ip][abc->Kp-3]; |
| 1392 |
fi[abc->Kp-2] = 0.0; |
| 1393 |
fi[abc->Kp-1] = 0.0; |
| 1394 |
} |
| 1395 |
|
| 1396 |
if (fj != NULL) { |
| 1397 |
fj[abc->K] = 0.0; |
| 1398 |
for (jp = abc->K+1; jp < abc->Kp-2; jp++) fj[jp] = P->mx[abc->Kp-3][jp]; |
| 1399 |
fj[abc->Kp-2] = 0.0; |
| 1400 |
fj[abc->Kp-1] = 0.0; |
| 1401 |
} |
| 1402 |
|
| 1403 |
return eslOK; |
| 1404 |
} |
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
|
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
|
| 1429 |
|
| 1430 |
|
| 1431 |
|
| 1432 |
|
| 1433 |
|
| 1434 |
|
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
|
| 1440 |
|
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
struct yualtschul_params { |
| 1445 |
ESL_DMATRIX *S; |
| 1446 |
ESL_DMATRIX *M; |
| 1447 |
ESL_DMATRIX *Y; |
| 1448 |
}; |
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
|
| 1453 |
|
| 1454 |
|
| 1455 |
static int |
| 1456 |
yualtschul_scorematrix_validate(const ESL_SCOREMATRIX *S) |
| 1457 |
{ |
| 1458 |
int i, j; |
| 1459 |
int has_neg, has_pos; |
| 1460 |
|
| 1461 |
|
| 1462 |
for (i = 0; i < S->K; i++) |
| 1463 |
{ |
| 1464 |
has_neg = has_pos = FALSE; |
| 1465 |
for (j = 0; j < S->K; j++) |
| 1466 |
{ |
| 1467 |
if (S->s[i][j] > 0) has_pos = TRUE; |
| 1468 |
if (S->s[i][j] < 0) has_neg = TRUE; |
| 1469 |
} |
| 1470 |
if (! has_pos || ! has_neg) return eslFAIL; |
| 1471 |
} |
| 1472 |
|
| 1473 |
|
| 1474 |
for (j = 0; j < S->K; j++) |
| 1475 |
{ |
| 1476 |
has_neg = has_pos = FALSE; |
| 1477 |
for (i = 0; i < S->K; i++) |
| 1478 |
{ |
| 1479 |
if (S->s[i][j] > 0) has_pos = TRUE; |
| 1480 |
if (S->s[i][j] < 0) has_neg = TRUE; |
| 1481 |
} |
| 1482 |
if (! has_pos || ! has_neg) return eslFAIL; |
| 1483 |
} |
| 1484 |
|
| 1485 |
return eslOK; |
| 1486 |
} |
| 1487 |
|
| 1488 |
|
| 1489 |
static double |
| 1490 |
yualtschul_upper_bound(const ESL_DMATRIX *Sd) |
| 1491 |
{ |
| 1492 |
int i; |
| 1493 |
double minimax; |
| 1494 |
double maxlambda; |
| 1495 |
|
| 1496 |
|
| 1497 |
minimax = esl_vec_DMax(Sd->mx[0], Sd->n); |
| 1498 |
for (i = 1; i < Sd->n; i++) |
| 1499 |
minimax = ESL_MIN(minimax, esl_vec_DMax(Sd->mx[i], Sd->n)); |
| 1500 |
|
| 1501 |
maxlambda = log((double) Sd->n) / minimax; |
| 1502 |
return maxlambda; |
| 1503 |
} |
| 1504 |
|
| 1505 |
static int |
| 1506 |
yualtschul_solution_validate(const ESL_DMATRIX *P, const double *fi, const double *fj) |
| 1507 |
{ |
| 1508 |
|
| 1509 |
if ( esl_dmx_Min(P) < 0.0) return eslFAIL; |
| 1510 |
if ( esl_vec_DMin(fi, P->n) < 0.0) return eslFAIL; |
| 1511 |
if ( esl_vec_DMin(fj, P->n) < 0.0) return eslFAIL; |
| 1512 |
|
| 1513 |
return eslOK; |
| 1514 |
} |
| 1515 |
|
| 1516 |
|
| 1517 |
|
| 1518 |
|
| 1519 |
|
| 1520 |
|
| 1521 |
static int |
| 1522 |
yualtschul_func(double lambda, void *params, double *ret_fx) |
| 1523 |
{ |
| 1524 |
int status; |
| 1525 |
struct yualtschul_params *p = (struct yualtschul_params *) params; |
| 1526 |
ESL_DMATRIX *S = p->S; |
| 1527 |
ESL_DMATRIX *M = p->M; |
| 1528 |
ESL_DMATRIX *Y = p->Y; |
| 1529 |
int i,j; |
| 1530 |
|
| 1531 |
|
| 1532 |
for (i = 0; i < S->n; i++) |
| 1533 |
for (j = 0; j < S->n; j++) |
| 1534 |
M->mx[i][j] = exp(lambda * S->mx[i][j]); |
| 1535 |
|
| 1536 |
|
| 1537 |
if ((status = esl_dmx_Invert(M, Y)) != eslOK) goto ERROR; |
| 1538 |
|
| 1539 |
|
| 1540 |
*ret_fx = esl_dmx_Sum(Y) - 1.; |
| 1541 |
return eslOK; |
| 1542 |
|
| 1543 |
ERROR: |
| 1544 |
*ret_fx = 0.; |
| 1545 |
return status; |
| 1546 |
} |
| 1547 |
|
| 1548 |
|
| 1549 |
|
| 1550 |
|
| 1551 |
|
| 1552 |
|
| 1553 |
|
| 1554 |
|
| 1555 |
|
| 1556 |
|
| 1557 |
|
| 1558 |
|
| 1559 |
|
| 1560 |
|
| 1561 |
|
| 1562 |
|
| 1563 |
static int |
| 1564 |
yualtschul_engine(ESL_DMATRIX *S, ESL_DMATRIX *P, double *fi, double *fj, double *ret_lambda) |
| 1565 |
{ |
| 1566 |
int status; |
| 1567 |
ESL_ROOTFINDER *R = NULL; |
| 1568 |
struct yualtschul_params p; |
| 1569 |
double lambda; |
| 1570 |
double xl, xr; |
| 1571 |
double fx = -1.0; |
| 1572 |
int i,j; |
| 1573 |
|
| 1574 |
|
| 1575 |
p.S = S; |
| 1576 |
p.M = p.Y = NULL; |
| 1577 |
if ((p.M = esl_dmatrix_Create(S->n, S->n)) == NULL) { status = eslEMEM; goto ERROR; } |
| 1578 |
if ((p.Y = esl_dmatrix_Create(S->n, S->n)) == NULL) { status = eslEMEM; goto ERROR; } |
| 1579 |
if ((R = esl_rootfinder_Create(yualtschul_func, &p)) == NULL) { status = eslEMEM; goto ERROR; } |
| 1580 |
|
| 1581 |
|
| 1582 |
xr = yualtschul_upper_bound(S); |
| 1583 |
|
| 1584 |
for (xl = xr; xl > 1e-10; xl /= 1.6) { |
| 1585 |
if ((status = yualtschul_func(xl, &p, &fx)) != eslOK) goto ERROR; |
| 1586 |
if (fx > 0.) break; |
| 1587 |
} |
| 1588 |
if (fx <= 0.) { status = eslEINVAL; goto ERROR; } |
| 1589 |
|
| 1590 |
for (; xr < 100.; xr *= 1.6) { |
| 1591 |
if ((status = yualtschul_func(xr, &p, &fx)) != eslOK) goto ERROR; |
| 1592 |
if (fx < 0.) break; |
| 1593 |
} |
| 1594 |
if (fx >= 0.) { status = eslEINVAL; goto ERROR; } |
| 1595 |
|
| 1596 |
|
| 1597 |
if (( status = esl_root_Bisection(R, xl, xr, &lambda)) != eslOK) goto ERROR; |
| 1598 |
|
| 1599 |
|
| 1600 |
for (i = 0; i < S->n; i++) { |
| 1601 |
fi[i] = 0.; |
| 1602 |
for (j = 0; j < S->n; j++) fi[i] += p.Y->mx[j][i]; |
| 1603 |
} |
| 1604 |
for (j = 0; j < S->n; j++) { |
| 1605 |
fj[j] = 0.; |
| 1606 |
for (i = 0; i < S->n; i++) fj[j] += p.Y->mx[j][i]; |
| 1607 |
} |
| 1608 |
|
| 1609 |
|
| 1610 |
for (i = 0; i < S->n; i++) |
| 1611 |
for (j = 0; j < S->n; j++) |
| 1612 |
P->mx[i][j] = fi[i] * fj[j] * p.M->mx[i][j]; |
| 1613 |
|
| 1614 |
*ret_lambda = lambda; |
| 1615 |
esl_dmatrix_Destroy(p.M); |
| 1616 |
esl_dmatrix_Destroy(p.Y); |
| 1617 |
esl_rootfinder_Destroy(R); |
| 1618 |
return eslOK; |
| 1619 |
|
| 1620 |
ERROR: |
| 1621 |
if (p.M) esl_dmatrix_Destroy(p.M); |
| 1622 |
if (p.Y) esl_dmatrix_Destroy(p.Y); |
| 1623 |
if (R) esl_rootfinder_Destroy(R); |
| 1624 |
return status; |
| 1625 |
} |
| 1626 |
|
| 1627 |
|
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
|
| 1637 |
|
| 1638 |
|
| 1639 |
|
| 1640 |
|
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
|
| 1650 |
|
| 1651 |
|
| 1652 |
|
| 1653 |
|
| 1654 |
|
| 1655 |
|
| 1656 |
|
| 1657 |
|
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
|
| 1670 |
|
| 1671 |
|
| 1672 |
|
| 1673 |
|
| 1674 |
|
| 1675 |
|
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
|
| 1680 |
|
| 1681 |
|
| 1682 |
int |
| 1683 |
esl_scorematrix_Probify(const ESL_SCOREMATRIX *S, ESL_DMATRIX **opt_P, double **opt_fi, double **opt_fj, double *opt_lambda) |
| 1684 |
{ |
| 1685 |
int status; |
| 1686 |
ESL_DMATRIX *Sd = NULL; |
| 1687 |
ESL_DMATRIX *P = NULL; |
| 1688 |
double *fi = NULL; |
| 1689 |
double *fj = NULL; |
| 1690 |
double lambda; |
| 1691 |
int i,j; |
| 1692 |
|
| 1693 |
|
| 1694 |
if ( yualtschul_scorematrix_validate(S) != eslOK) { status = eslEINVAL; goto ERROR; } |
| 1695 |
|
| 1696 |
if (( Sd = esl_dmatrix_Create(S->K, S->K)) == NULL) {status = eslEMEM; goto ERROR; } |
| 1697 |
if (( P = esl_dmatrix_Create(S->Kp, S->Kp)) == NULL) {status = eslEMEM; goto ERROR; } |
| 1698 |
ESL_ALLOC(fi, sizeof(double) * S->Kp); |
| 1699 |
ESL_ALLOC(fj, sizeof(double) * S->Kp); |
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
for (i = 0; i < S->K; i++) |
| 1707 |
for (j = 0; j < S->K; j++) |
| 1708 |
Sd->mx[i][j] = (double) S->s[i][j]; |
| 1709 |
|
| 1710 |
|
| 1711 |
if ((status = yualtschul_engine(Sd, P, fi, fj, &lambda)) != eslOK) goto ERROR; |
| 1712 |
set_degenerate_probs(S->abc_r, P, fi, fj); |
| 1713 |
|
| 1714 |
|
| 1715 |
if (yualtschul_solution_validate(P, fi, fj) != eslOK) status = eslENORESULT; |
| 1716 |
else status = eslOK; |
| 1717 |
|
| 1718 |
esl_dmatrix_Destroy(Sd); |
| 1719 |
if (opt_P != NULL) *opt_P = P; else esl_dmatrix_Destroy(P); |
| 1720 |
if (opt_fi != NULL) *opt_fi = fi; else free(fi); |
| 1721 |
if (opt_fj != NULL) *opt_fj = fj; else free(fj); |
| 1722 |
if (opt_lambda != NULL) *opt_lambda = lambda; |
| 1723 |
return status; |
| 1724 |
|
| 1725 |
ERROR: |
| 1726 |
if (Sd != NULL) esl_dmatrix_Destroy(Sd); |
| 1727 |
if (P != NULL) esl_dmatrix_Destroy(P); |
| 1728 |
if (fi != NULL) free(fi); |
| 1729 |
if (fj != NULL) free(fj); |
| 1730 |
if (opt_P != NULL) *opt_P = NULL; |
| 1731 |
if (opt_fi != NULL) *opt_fi = NULL; |
| 1732 |
if (opt_fj != NULL) *opt_fj = NULL; |
| 1733 |
if (opt_lambda != NULL) *opt_lambda = 0.; |
| 1734 |
return status; |
| 1735 |
} |
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
#ifdef eslSCOREMATRIX_EXPERIMENT |
| 1746 |
#include <stdio.h> |
| 1747 |
#include <stdlib.h> |
| 1748 |
|
| 1749 |
#include "easel.h" |
| 1750 |
#include "esl_alphabet.h" |
| 1751 |
#include "esl_dmatrix.h" |
| 1752 |
#include "esl_getopts.h" |
| 1753 |
#include "esl_scorematrix.h" |
| 1754 |
#include "esl_vectorops.h" |
| 1755 |
|
| 1756 |
static ESL_OPTIONS options[] = { |
| 1757 |
|
| 1758 |
{"-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show help and usage", 0}, |
| 1759 |
{"-l", eslARG_REAL, "0.3466", NULL, NULL, NULL, NULL, NULL, "set base lambda (units of score mx) to <x>", 0}, |
| 1760 |
{"-s", eslARG_REAL, "1.0", NULL, NULL, NULL, NULL, NULL, "additional scale factor applied to lambda", 0}, |
| 1761 |
{"-t", eslARG_REAL, "1.37", NULL, NULL, NULL, NULL, NULL, "set WAG time (branch length) to <x>", 0}, |
| 1762 |
{"--yfile", eslARG_OUTFILE, NULL, NULL, NULL, NULL, NULL, NULL, "save xy file of Yu/Altschul root eqn to <f>", 0}, |
| 1763 |
{"--mfile", eslARG_OUTFILE, NULL, NULL, NULL, NULL, NULL, NULL, "save WAG score matrix to <f>", 0}, |
| 1764 |
{ 0,0,0,0,0,0,0,0,0,0}, |
| 1765 |
}; |
| 1766 |
static char usage[] = "[-options]"; |
| 1767 |
static char banner[] = "Yu/Altschul experiment driver for scorematrix module"; |
| 1768 |
|
| 1769 |
|
| 1770 |
|
| 1771 |
|
| 1772 |
|
| 1773 |
static int |
| 1774 |
yualtschul_graph_dump(FILE *ofp, ESL_SCOREMATRIX *S, double scale, double lambda0, double lambda1, double stepsize) |
| 1775 |
{ |
| 1776 |
struct yualtschul_params p; |
| 1777 |
int a,b; |
| 1778 |
double fx; |
| 1779 |
double lambda; |
| 1780 |
|
| 1781 |
|
| 1782 |
p.S = esl_dmatrix_Create(S->K, S->K); |
| 1783 |
p.M = esl_dmatrix_Create(S->K, S->K); |
| 1784 |
p.Y = esl_dmatrix_Create(S->K, S->K); |
| 1785 |
|
| 1786 |
for (a = 0; a < S->K; a++) |
| 1787 |
for (b = 0; b < S->K; b++) |
| 1788 |
p.S->mx[a][b] = (double) S->s[a][b]; |
| 1789 |
|
| 1790 |
for (lambda = lambda0; lambda <= lambda1; lambda += stepsize) |
| 1791 |
{ |
| 1792 |
yualtschul_func(lambda/scale, &p, &fx); |
| 1793 |
fprintf(ofp, "%f %f\n", lambda, fx); |
| 1794 |
} |
| 1795 |
fprintf(ofp, "&\n"); |
| 1796 |
fprintf(ofp, "%f 0.0\n", lambda0); |
| 1797 |
fprintf(ofp, "%f 0.0\n", lambda1); |
| 1798 |
fprintf(ofp, "&\n"); |
| 1799 |
|
| 1800 |
esl_dmatrix_Destroy(p.S); |
| 1801 |
esl_dmatrix_Destroy(p.M); |
| 1802 |
esl_dmatrix_Destroy(p.Y); |
| 1803 |
return 0; |
| 1804 |
} |
| 1805 |
|
| 1806 |
int |
| 1807 |
main(int argc, char **argv) |
| 1808 |
{ |
| 1809 |
ESL_GETOPTS *go = esl_getopts_CreateDefaultApp(options, 0, argc, argv, banner, usage); |
| 1810 |
ESL_ALPHABET *abc = esl_alphabet_Create(eslAMINO); |
| 1811 |
ESL_DMATRIX *Q = esl_dmatrix_Create(abc->K, abc->K); |
| 1812 |
ESL_DMATRIX *P0 = esl_dmatrix_Create(abc->K, abc->K); |
| 1813 |
double *wagpi = malloc(sizeof(double) * abc->K); |
| 1814 |
ESL_SCOREMATRIX *S0 = esl_scorematrix_Create(abc); |
| 1815 |
double lambda0 = esl_opt_GetReal(go, "-l"); |
| 1816 |
double t = esl_opt_GetReal(go, "-t"); |
| 1817 |
double scale = esl_opt_GetReal(go, "-s"); |
| 1818 |
char *yfile = esl_opt_GetString(go, "--yfile"); |
| 1819 |
char *mfile = esl_opt_GetString(go, "--mfile"); |
| 1820 |
ESL_DMATRIX *P = NULL; |
| 1821 |
double *fi = NULL; |
| 1822 |
double *fj = NULL; |
| 1823 |
double lambda; |
| 1824 |
double D; |
| 1825 |
int status; |
| 1826 |
|
| 1827 |
|
| 1828 |
esl_scorematrix_SetWAG(S0, lambda0/scale, t); |
| 1829 |
esl_composition_WAG(wagpi); |
| 1830 |
printf("WAG matrix calculated at t=%.3f, lambda=%.4f (/%.1f)\n", t, lambda0, scale); |
| 1831 |
|
| 1832 |
|
| 1833 |
if (mfile) |
| 1834 |
{ |
| 1835 |
FILE *ofp = NULL; |
| 1836 |
if ( (ofp = fopen(mfile, "w")) == NULL) esl_fatal("failed to open %s for writing scorematrix", mfile); |
| 1837 |
ESL_DASSERT1(( S0->Kp >= 20 )); |
| 1838 |
strcpy(S0->outorder, "ARNDCQEGHILKMFPSTWYV"); |
| 1839 |
esl_scorematrix_Write(ofp, S0); |
| 1840 |
fclose(ofp); |
| 1841 |
} |
| 1842 |
|
| 1843 |
|
| 1844 |
esl_scorematrix_ProbifyGivenBG(S0, wagpi, wagpi, &lambda, NULL); |
| 1845 |
printf("Integer roundoff shifts implicit lambda (given wagpi's) to %.4f (/%.1f)\n", lambda*scale, scale); |
| 1846 |
printf("Scores in matrix range from %d to %d\n", esl_scorematrix_Min(S0), esl_scorematrix_Max(S0)); |
| 1847 |
|
| 1848 |
esl_scorematrix_RelEntropy(S0, wagpi, wagpi, lambda, &D); |
| 1849 |
printf("Relative entropy: %.3f bits\n", D); |
| 1850 |
|
| 1851 |
if (yfile) |
| 1852 |
{ |
| 1853 |
FILE *ofp = NULL; |
| 1854 |
if ( (ofp = fopen(yfile, "w")) == NULL) esl_fatal("failed to open XY file %s for writing\n", yfile); |
| 1855 |
yualtschul_graph_dump(ofp, S0, scale, 0.01, 1.0, 0.0001); |
| 1856 |
fclose(ofp); |
| 1857 |
printf("XY plot of Yu/Altschul rootfinding saved to : %s\n", yfile); |
| 1858 |
} |
| 1859 |
|
| 1860 |
status = esl_scorematrix_Probify(S0, &P, &fi, &fj, &lambda); |
| 1861 |
printf("Yu/Altschul reverse engineering gives lambda = %.4f (/%.1f)\n", lambda*scale, scale); |
| 1862 |
|
| 1863 |
|
| 1864 |
|
| 1865 |
if (status != eslOK) printf("however, the solution is INVALID!\n"); |
| 1866 |
else printf("and the joint and marginals are a valid probabilistic basis.\n"); |
| 1867 |
|
| 1868 |
free(fj); |
| 1869 |
free(fi); |
| 1870 |
esl_scorematrix_Destroy(S0); |
| 1871 |
esl_dmatrix_Destroy(P); |
| 1872 |
esl_dmatrix_Destroy(P0); |
| 1873 |
esl_dmatrix_Destroy(Q); |
| 1874 |
esl_alphabet_Destroy(abc); |
| 1875 |
esl_getopts_Destroy(go); |
| 1876 |
return 0; |
| 1877 |
} |
| 1878 |
#endif |
| 1879 |
|
| 1880 |
|
| 1881 |
|
| 1882 |
|
| 1883 |
|
| 1884 |
|
| 1885 |
|
| 1886 |
|
| 1887 |
|
| 1888 |
|
| 1889 |
|
| 1890 |
#ifdef eslSCOREMATRIX_UTILITY1 |
| 1891 |
|
| 1892 |
|
| 1893 |
|
| 1894 |
|
| 1895 |
#include "easel.h" |
| 1896 |
#include "esl_alphabet.h" |
| 1897 |
#include "esl_scorematrix.h" |
| 1898 |
#include "esl_fileparser.h" |
| 1899 |
|
| 1900 |
int |
| 1901 |
main(int argc, char **argv) |
| 1902 |
{ |
| 1903 |
char *infile = argv[1]; |
| 1904 |
ESL_ALPHABET *abc; |
| 1905 |
ESL_FILEPARSER *efp; |
| 1906 |
ESL_SCOREMATRIX *S; |
| 1907 |
int x,y; |
| 1908 |
|
| 1909 |
abc = esl_alphabet_Create(eslAMINO); |
| 1910 |
|
| 1911 |
if (esl_fileparser_Open(infile, NULL, &efp) != eslOK) esl_fatal("Failed to open %s\n", infile); |
| 1912 |
if (esl_scorematrix_Read(efp, abc, &S) != eslOK) esl_fatal("parse failed: %s", efp->errbuf); |
| 1913 |
|
| 1914 |
printf(" /*"); |
| 1915 |
for (y = 0; y < abc->Kp; y++) |
| 1916 |
printf(" %c ", abc->sym[y]); |
| 1917 |
printf(" */\n"); |
| 1918 |
|
| 1919 |
for (x = 0; x < abc->Kp; x++) { |
| 1920 |
printf(" { "); |
| 1921 |
for (y = 0; y < abc->Kp; y++) |
| 1922 |
printf("%3d, ", S->s[x][y]); |
| 1923 |
printf(" }, /* %c */\n", abc->sym[x]); |
| 1924 |
} |
| 1925 |
|
| 1926 |
esl_scorematrix_Destroy(S); |
| 1927 |
esl_fileparser_Close(efp); |
| 1928 |
esl_alphabet_Destroy(abc); |
| 1929 |
return eslOK; |
| 1930 |
} |
| 1931 |
#endif |
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
|
| 1937 |
|
| 1938 |
#ifdef eslSCOREMATRIX_UTILITY2 |
| 1939 |
|
| 1940 |
|
| 1941 |
|
| 1942 |
|
| 1943 |
#include "easel.h" |
| 1944 |
#include "esl_alphabet.h" |
| 1945 |
#include "esl_dmatrix.h" |
| 1946 |
#include "esl_scorematrix.h" |
| 1947 |
|
| 1948 |
int |
| 1949 |
main(int argc, char **argv) |
| 1950 |
{ |
| 1951 |
ESL_ALPHABET *abc = esl_alphabet_Create(eslAMINO); |
| 1952 |
ESL_SCOREMATRIX *S = esl_scorematrix_Create(abc); |
| 1953 |
ESL_DMATRIX *Q = NULL; |
| 1954 |
double *fa = NULL; |
| 1955 |
double *fb = NULL; |
| 1956 |
double slambda; |
| 1957 |
int a,b; |
| 1958 |
|
| 1959 |
esl_scorematrix_Set("BLOSUM62", S); |
| 1960 |
esl_scorematrix_Probify(S, &Q, &fa, &fb, &slambda); |
| 1961 |
#if 0 |
| 1962 |
esl_scorematrix_JointToConditionalOnQuery(abc, Q); |
| 1963 |
#endif |
| 1964 |
esl_dmatrix_Dump(stdout, Q, abc->sym, abc->sym); |
| 1965 |
|
| 1966 |
esl_dmatrix_Destroy(Q); |
| 1967 |
esl_scorematrix_Destroy(S); |
| 1968 |
esl_alphabet_Destroy(abc); |
| 1969 |
return eslOK; |
| 1970 |
} |
| 1971 |
#endif |
| 1972 |
|
| 1973 |
|
| 1974 |
|
| 1975 |
|
| 1976 |
|
| 1977 |
|
| 1978 |
|
| 1979 |
|
| 1980 |
|
| 1981 |
|
| 1982 |
#ifdef eslSCOREMATRIX_TESTDRIVE |
| 1983 |
#include "esl_dirichlet.h" |
| 1984 |
|
| 1985 |
static void |
| 1986 |
utest_ReadWrite(ESL_ALPHABET *abc, ESL_SCOREMATRIX *S) |
| 1987 |
{ |
| 1988 |
char tmpfile[16] = "esltmpXXXXXX"; |
| 1989 |
FILE *fp = NULL; |
| 1990 |
ESL_SCOREMATRIX *S2 = NULL; |
| 1991 |
ESL_FILEPARSER *efp = NULL; |
| 1992 |
|
| 1993 |
if (esl_tmpfile_named(tmpfile, &fp) != eslOK) esl_fatal("failed to open tmp file"); |
| 1994 |
if (esl_scorematrix_Write(fp, S) != eslOK) esl_fatal("failed to write test matrix"); |
| 1995 |
fclose(fp); |
| 1996 |
|
| 1997 |
if (esl_fileparser_Open(tmpfile, NULL, &efp) != eslOK) esl_fatal("failed to open tmpfile containing BLOSUM62 matrix"); |
| 1998 |
if (esl_scorematrix_Read(efp, abc, &S2) != eslOK) esl_fatal("failed to read tmpfile containing BLOSUM62 matrix"); |
| 1999 |
if (esl_scorematrix_Compare(S, S2) != eslOK) esl_fatal("the two test matrices aren't identical"); |
| 2000 |
|
| 2001 |
remove(tmpfile); |
| 2002 |
esl_fileparser_Close(efp); |
| 2003 |
esl_scorematrix_Destroy(S2); |
| 2004 |
return; |
| 2005 |
} |
| 2006 |
|
| 2007 |
|
| 2008 |
static void |
| 2009 |
utest_ProbifyGivenBG(ESL_SCOREMATRIX *S0, ESL_DMATRIX *P0, double *wagpi, double lambda0) |
| 2010 |
{ |
| 2011 |
char *msg = "ProbifyGivenBG() unit test failed"; |
| 2012 |
ESL_DMATRIX *P = NULL; |
| 2013 |
double sum = 0.0; |
| 2014 |
double lambda; |
| 2015 |
int a,b; |
| 2016 |
|
| 2017 |
if (esl_scorematrix_ProbifyGivenBG(S0, wagpi, wagpi, &lambda, &P) != eslOK) esl_fatal(msg); |
| 2018 |
|
| 2019 |
if (esl_DCompare_old(lambda0, lambda, 1e-3) != eslOK) esl_fatal("lambda is wrong"); |
| 2020 |
|
| 2021 |
for (a = 0; a < 20; a++) |
| 2022 |
for (b = 0; b < 20; b++) |
| 2023 |
sum += P->mx[a][b]; |
| 2024 |
|
| 2025 |
if (esl_DCompare_old(sum, 1.0, 1e-9) != eslOK) esl_fatal("P doesn't sum to 1"); |
| 2026 |
|
| 2027 |
for (a = 0; a < 20; a++) |
| 2028 |
for (b = 0; b < 20; b++) |
| 2029 |
if (esl_DCompare_old(P0->mx[a][b], P->mx[a][b], 1e-2) != eslOK) esl_fatal("P is wrong"); |
| 2030 |
|
| 2031 |
esl_dmatrix_Destroy(P); |
| 2032 |
return; |
| 2033 |
} |
| 2034 |
|
| 2035 |
|
| 2036 |
|
| 2037 |
|
| 2038 |
|
| 2039 |
|
| 2040 |
static void |
| 2041 |
utest_yualtschul(ESL_DMATRIX *P0, double *wagpi) |
| 2042 |
{ |
| 2043 |
char *msg = "reverse engineering engine test failed"; |
| 2044 |
ESL_DMATRIX *S = NULL; |
| 2045 |
ESL_DMATRIX *P = NULL; |
| 2046 |
double *fi = NULL; |
| 2047 |
double *fj = NULL; |
| 2048 |
double lambda0; |
| 2049 |
double lambda; |
| 2050 |
double sum = 0.0; |
| 2051 |
int i,j; |
| 2052 |
|
| 2053 |
|
| 2054 |
if (( S = esl_dmatrix_Create(20, 20)) == NULL) esl_fatal(msg); |
| 2055 |
if (( P = esl_dmatrix_Create(20, 20)) == NULL) esl_fatal(msg); |
| 2056 |
if ((fi = malloc(sizeof(double) * 20)) == NULL) esl_fatal(msg); |
| 2057 |
if ((fj = malloc(sizeof(double) * 20)) == NULL) esl_fatal(msg); |
| 2058 |
|
| 2059 |
|
| 2060 |
lambda0 = 0.3; |
| 2061 |
for (i = 0; i < 20; i++) |
| 2062 |
for (j = 0; j < 20; j++) |
| 2063 |
S->mx[i][j] = log(P0->mx[i][j] / (wagpi[i] * wagpi[j])) / lambda0; |
| 2064 |
|
| 2065 |
|
| 2066 |
if ( yualtschul_engine(S, P, fi, fj, &lambda) != eslOK) esl_fatal("reverse engineering engine failed"); |
| 2067 |
|
| 2068 |
|
| 2069 |
if (esl_DCompare_old(lambda0, lambda, 1e-4) != eslOK) esl_fatal("failed to get right lambda"); |
| 2070 |
|
| 2071 |
for (i = 0; i < 20; i++) |
| 2072 |
for (j = 0; j < 20; j++) |
| 2073 |
sum += P->mx[i][j]; |
| 2074 |
if (esl_DCompare_old(sum, 1.0, 1e-6) != eslOK) esl_fatal("reconstructed P doesn't sum to 1"); |
| 2075 |
|
| 2076 |
for (i = 0; i < 20; i++) |
| 2077 |
for (j = 0; j < 20; j++) |
| 2078 |
if (esl_DCompare_old(P0->mx[i][j], P->mx[i][j], 1e-2) != eslOK) esl_fatal("failed to recover correct P_ij"); |
| 2079 |
for (i = 0; i < 20; i++) |
| 2080 |
{ |
| 2081 |
if (esl_DCompare_old(fi[i], fj[i], 1e-6) != eslOK) esl_fatal("background fi, fj not the same"); |
| 2082 |
if (esl_DCompare_old(wagpi[i], fi[i], 1e-3) != eslOK) esl_fatal("failed to reconstruct WAG backgrounds"); |
| 2083 |
} |
| 2084 |
|
| 2085 |
free(fj); |
| 2086 |
free(fi); |
| 2087 |
esl_dmatrix_Destroy(S); |
| 2088 |
esl_dmatrix_Destroy(P); |
| 2089 |
return; |
| 2090 |
} |
| 2091 |
|
| 2092 |
|
| 2093 |
|
| 2094 |
|
| 2095 |
|
| 2096 |
|
| 2097 |
|
| 2098 |
static void |
| 2099 |
utest_Probify(ESL_SCOREMATRIX *S0, ESL_DMATRIX *P0, double *wagpi, double lambda0) |
| 2100 |
{ |
| 2101 |
ESL_DMATRIX *P = NULL; |
| 2102 |
double *fi = NULL; |
| 2103 |
double *fj = NULL; |
| 2104 |
double lambda; |
| 2105 |
double sum = 0.0; |
| 2106 |
int i,j; |
| 2107 |
|
| 2108 |
if (esl_scorematrix_Probify(S0, &P, &fi, &fj, &lambda) != eslOK) esl_fatal("reverse engineering failed"); |
| 2109 |
|
| 2110 |
|
| 2111 |
if (esl_DCompare_old(lambda0, lambda, 0.01) != eslOK) esl_fatal("failed to get right lambda"); |
| 2112 |
for (i = 0; i < 20; i++) |
| 2113 |
for (j = 0; j < 20; j++) |
| 2114 |
sum += P->mx[i][j]; |
| 2115 |
if (esl_DCompare_old(sum, 1.0, 1e-6) != eslOK) esl_fatal("reconstructed P doesn't sum to 1"); |
| 2116 |
|
| 2117 |
for (i = 0; i < 20; i++) |
| 2118 |
for (j = 0; j < 20; j++) |
| 2119 |
if (esl_DCompare_old(P0->mx[i][j], P->mx[i][j], 0.1) != eslOK) esl_fatal("failed to recover correct P_ij"); |
| 2120 |
free(fj); |
| 2121 |
free(fi); |
| 2122 |
esl_dmatrix_Destroy(P); |
| 2123 |
return; |
| 2124 |
} |
| 2125 |
|
| 2126 |
|
| 2127 |
|
| 2128 |
|
| 2129 |
|
| 2130 |
|
| 2131 |
|
| 2132 |
static void |
| 2133 |
utest_ProbifyBLOSUM(ESL_SCOREMATRIX *BL62) |
| 2134 |
{ |
| 2135 |
char *msg = "failure in ProbifyBLOSUM() unit test"; |
| 2136 |
ESL_DMATRIX *P = NULL; |
| 2137 |
double *fi = NULL; |
| 2138 |
double *fj = NULL; |
| 2139 |
double lambda; |
| 2140 |
ESL_SCOREMATRIX *S2 = NULL; |
| 2141 |
|
| 2142 |
if (( S2 = esl_scorematrix_Clone(BL62)) == NULL) esl_fatal(msg); |
| 2143 |
if (esl_scorematrix_Probify(BL62, &P, &fi, &fj, &lambda) != eslOK) esl_fatal(msg); |
| 2144 |
if (esl_scorematrix_SetFromProbs(S2, lambda, P, fi, fj) != eslOK) esl_fatal(msg); |
| 2145 |
if (esl_scorematrix_CompareCanon(BL62, S2) != eslOK) esl_fatal(msg); |
| 2146 |
|
| 2147 |
free(fj); |
| 2148 |
free(fi); |
| 2149 |
esl_scorematrix_Destroy(S2); |
| 2150 |
esl_dmatrix_Destroy(P); |
| 2151 |
return; |
| 2152 |
} |
| 2153 |
|
| 2154 |
#endif |
| 2155 |
|
| 2156 |
|
| 2157 |
|
| 2158 |
|
| 2159 |
|
| 2160 |
|
| 2161 |
|
| 2162 |
|
| 2163 |
|
| 2164 |
#ifdef eslSCOREMATRIX_TESTDRIVE |
| 2165 |
#include "easel.h" |
| 2166 |
#include "esl_scorematrix.h" |
| 2167 |
|
| 2168 |
int |
| 2169 |
main(int argc, char **argv) |
| 2170 |
{ |
| 2171 |
ESL_ALPHABET *abc = NULL; |
| 2172 |
ESL_SCOREMATRIX *BL62= NULL; |
| 2173 |
ESL_SCOREMATRIX *S0 = NULL; |
| 2174 |
ESL_DMATRIX *P0 = NULL; |
| 2175 |
ESL_DMATRIX *Q = NULL; |
| 2176 |
double lambda0; |
| 2177 |
double t; |
| 2178 |
int i,j; |
| 2179 |
static double wagpi[20]; |
| 2180 |
|
| 2181 |
|
| 2182 |
if ((abc = esl_alphabet_Create(eslAMINO)) == NULL) esl_fatal("allocation of alphabet failed"); |
| 2183 |
if ((BL62= esl_scorematrix_Create(abc)) == NULL) esl_fatal("allocation of BLOSUM62 failed"); |
| 2184 |
if ((S0 = esl_scorematrix_Create(abc)) == NULL) esl_fatal("allocation of scorematrix failed"); |
| 2185 |
if ((P0 = esl_dmatrix_Create(abc->K, abc->K)) == NULL) esl_fatal("P allocation failed"); |
| 2186 |
if ((Q = esl_dmatrix_Create(abc->K, abc->K)) == NULL) esl_fatal("Q allocation failed"); |
| 2187 |
|
| 2188 |
|
| 2189 |
if ( esl_scorematrix_Set("BLOSUM62", BL62) != eslOK) esl_fatal("failed to set a BLOSUM matrix"); |
| 2190 |
|
| 2191 |
|
| 2192 |
lambda0 = 0.00635; |
| 2193 |
t = 2.0; |
| 2194 |
esl_scorematrix_SetWAG(S0, lambda0, t); |
| 2195 |
esl_composition_WAG(wagpi); |
| 2196 |
|
| 2197 |
|
| 2198 |
if ( esl_rmx_SetWAG(Q, wagpi) != eslOK) esl_fatal("failed to set WAG"); |
| 2199 |
if ( esl_dmx_Exp(Q, t, P0) != eslOK) esl_fatal("failed to exponentiate WAG"); |
| 2200 |
for (i = 0; i < 20; i++) |
| 2201 |
for (j = 0; j < 20; j++) |
| 2202 |
P0->mx[i][j] *= wagpi[i]; |
| 2203 |
|
| 2204 |
|
| 2205 |
|
| 2206 |
utest_ReadWrite(abc, BL62); |
| 2207 |
utest_ReadWrite(abc, S0); |
| 2208 |
utest_ProbifyGivenBG(S0, P0, wagpi, lambda0); |
| 2209 |
utest_yualtschul(P0, wagpi); |
| 2210 |
utest_Probify(S0, P0, wagpi, lambda0); |
| 2211 |
utest_ProbifyBLOSUM(BL62); |
| 2212 |
|
| 2213 |
esl_dmatrix_Destroy(Q); |
| 2214 |
esl_dmatrix_Destroy(P0); |
| 2215 |
esl_scorematrix_Destroy(BL62); |
| 2216 |
esl_scorematrix_Destroy(S0); |
| 2217 |
esl_alphabet_Destroy(abc); |
| 2218 |
|
| 2219 |
return 0; |
| 2220 |
} |
| 2221 |
#endif |
| 2222 |
|
| 2223 |
|
| 2224 |
|
| 2225 |
|
| 2226 |
|
| 2227 |
#ifdef eslSCOREMATRIX_EXAMPLE |
| 2228 |
|
| 2229 |
#include "easel.h" |
| 2230 |
#include "esl_alphabet.h" |
| 2231 |
#include "esl_fileparser.h" |
| 2232 |
#include "esl_getopts.h" |
| 2233 |
#include "esl_dmatrix.h" |
| 2234 |
#include "esl_vectorops.h" |
| 2235 |
#include "esl_scorematrix.h" |
| 2236 |
|
| 2237 |
static ESL_OPTIONS options[] = { |
| 2238 |
|
| 2239 |
{ "-h", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "show brief help on version and usage", 0 }, |
| 2240 |
{ "--dna", eslARG_NONE, FALSE, NULL, NULL, "--dna,--amino", NULL, NULL, "use DNA alphabet", 0 }, |
| 2241 |
{ "--amino", eslARG_NONE, "TRUE", NULL, NULL, "--dna,--amino", NULL, NULL, "use protein alphabet", 0 }, |
| 2242 |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 2243 |
}; |
| 2244 |
static char usage[] = "[-options] <mxfile>"; |
| 2245 |
static char banner[] = "example of using easel scorematrix routines"; |
| 2246 |
|
| 2247 |
|
| 2248 |
int |
| 2249 |
main(int argc, char **argv) |
| 2250 |
{ |
| 2251 |
ESL_GETOPTS *go = esl_getopts_CreateDefaultApp(options, 1, argc, argv, banner, usage); |
| 2252 |
char *scorefile = esl_opt_GetArg(go, 1); |
| 2253 |
ESL_ALPHABET *abc = NULL; |
| 2254 |
ESL_FILEPARSER *efp = NULL; |
| 2255 |
ESL_SCOREMATRIX *S = NULL; |
| 2256 |
ESL_DMATRIX *P1 = NULL; |
| 2257 |
ESL_DMATRIX *P2 = NULL; |
| 2258 |
double *fi = NULL; |
| 2259 |
double *fj = NULL; |
| 2260 |
double lambda, D, E; |
| 2261 |
int vstatus; |
| 2262 |
|
| 2263 |
if (esl_opt_GetBoolean(go, "--dna")) abc = esl_alphabet_Create(eslDNA); |
| 2264 |
else if (esl_opt_GetBoolean(go, "--amino")) abc = esl_alphabet_Create(eslAMINO); |
| 2265 |
|
| 2266 |
|
| 2267 |
if ( esl_fileparser_Open(scorefile, NULL, &efp) != eslOK) esl_fatal("failed to open score file %s", scorefile); |
| 2268 |
if ( esl_scorematrix_Read(efp, abc, &S) != eslOK) esl_fatal("failed to read matrix from %s:\n %s", scorefile, efp->errbuf); |
| 2269 |
esl_fileparser_Close(efp); |
| 2270 |
|
| 2271 |
|
| 2272 |
vstatus = esl_scorematrix_Probify(S, &P1, &fi, &fj, &lambda); |
| 2273 |
|
| 2274 |
if (vstatus == eslOK) |
| 2275 |
{ |
| 2276 |
|
| 2277 |
esl_scorematrix_RelEntropy (S, fi, fj, lambda, &D); |
| 2278 |
esl_scorematrix_ExpectedScore(S, fi, fj, &E); |
| 2279 |
|
| 2280 |
printf("By Yu/Altschul (2003,2005) procedure:\n"); |
| 2281 |
printf("Lambda = %.4f\n", lambda); |
| 2282 |
printf("Relative entropy = %.4f bits\n", D); |
| 2283 |
printf("Expected score = %.4f bits\n", E * lambda * eslCONST_LOG2R); |
| 2284 |
|
| 2285 |
printf("p_ij's are:\n"); esl_dmatrix_Dump(stdout, P1, abc->sym, abc->sym); |
| 2286 |
printf("fi's are:\n"); esl_vec_DDump(stdout, fi, S->K, abc->sym); |
| 2287 |
printf("fj's are:\n"); esl_vec_DDump(stdout, fj, S->K, abc->sym); |
| 2288 |
printf("============================================================\n\n"); |
| 2289 |
} |
| 2290 |
else |
| 2291 |
{ |
| 2292 |
printf("Yu/Altschul procedure FAILS to find a valid implicit probability basis!\n"); |
| 2293 |
printf("Lambda = %.4f\n", lambda); |
| 2294 |
printf("p_ij's are:\n"); esl_dmatrix_Dump(stdout, P1, abc->sym, abc->sym); |
| 2295 |
printf("fi's are:\n"); esl_vec_DDump(stdout, fi, S->K, abc->sym); |
| 2296 |
printf("fj's are:\n"); esl_vec_DDump(stdout, fj, S->K, abc->sym); |
| 2297 |
printf("============================================================\n\n"); |
| 2298 |
|
| 2299 |
esl_composition_BL62(fi); esl_composition_BL62(fj); |
| 2300 |
} |
| 2301 |
|
| 2302 |
|
| 2303 |
esl_scorematrix_ProbifyGivenBG(S, fi, fj, &lambda, &P2); |
| 2304 |
esl_scorematrix_RelEntropy (S, fi, fj, lambda, &D); |
| 2305 |
esl_scorematrix_ExpectedScore(S, fi, fj, &E); |
| 2306 |
|
| 2307 |
printf("By solving for lambda from given background frequencies:\n"); |
| 2308 |
printf("Lambda = %.4f\n", lambda); |
| 2309 |
printf("Relative entropy = %.4f bits\n", D); |
| 2310 |
printf("Expected score = %.4f bits\n", E * lambda * eslCONST_LOG2R); |
| 2311 |
|
| 2312 |
printf("p_ij's are:\n"); esl_dmatrix_Dump(stdout, P2, abc->sym, abc->sym); |
| 2313 |
printf("fi's are:\n"); esl_vec_DDump(stdout, fi, S->K, abc->sym); |
| 2314 |
printf("fj's are:\n"); esl_vec_DDump(stdout, fj, S->K, abc->sym); |
| 2315 |
printf("============================================================\n\n"); |
| 2316 |
|
| 2317 |
|
| 2318 |
|
| 2319 |
printf("Before:\n"); |
| 2320 |
esl_scorematrix_Write(stdout, S); |
| 2321 |
printf("After:\n"); |
| 2322 |
esl_scorematrix_SetFromProbs(S, lambda, P2, fi, fj); |
| 2323 |
esl_scorematrix_Write(stdout, S); |
| 2324 |
|
| 2325 |
free(fi); free(fj); |
| 2326 |
esl_dmatrix_Destroy(P1); esl_dmatrix_Destroy(P2); |
| 2327 |
esl_scorematrix_Destroy(S); |
| 2328 |
esl_alphabet_Destroy(abc); |
| 2329 |
esl_getopts_Destroy(go); |
| 2330 |
return 0; |
| 2331 |
} |
| 2332 |
|
| 2333 |
#endif |