int mut_init(FILE *mpfile) { int i, j; char line_buf[BUF_MAX]; while (fgets(line_buf, BUF_MAX, mpfile)) { char trpl_buf[4]; char new_nucl; int mut_ind; double p; if (!sscanf(line_buf, "%s %c %lf", trpl_buf, &new_nucl, &p)) return 0; mut_ind = nuc_ind((int)new_nucl); if (!chck_triplet(trpl_buf) || mut_ind < 0 || mut_ind > 3 || p < 0.0 || p > 1.0) return 0; pm[triplet_ind(trpl_buf)][mut_ind] = (uint32_t)(p * XS128_MAX); } /* make probability matrix cumulative */ for (i = 0; i < 64; i++) { uint32_t pchg_tot = 0; for (j = 0; j < 4; j++) pchg_tot += pm[i][j]; pm[i][(i&0xc)>>2] = XS128_MAX - pchg_tot; for (j = 1; j < 4; j++) pm[i][j] += pm[i][j-1]; } return 1; }
char conv(const char *s) { static const char Conv_Table[64] = { 'F','L','I','V','S','P','T','A','Y','H','N','D','C','R','S','G', 'F','L','I','V','S','P','T','A','Y','H','N','D','C','R','S','G', 'L','L','I','V','S','P','T','A','*','Q','K','E','*','R','R','G', 'L','L','M','V','S','P','T','A','*','Q','K','E','W','R','R','G' }; return Conv_Table[triplet_ind(s)]; }
char mut(const char *ntp) { uint32_t dice = xs128(); int trpl = triplet_ind(ntp); if (dice < pm[trpl][0]) return nuc(0); if (dice < pm[trpl][1]) return nuc(1); if (dice < pm[trpl][2]) return nuc(2); return nuc(3); }
static int chck_triplet(const char *s) { return triplet_ind(s) & E ? 0 : 1; }