| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#include <stdio.h> |
| 22 |
#include <stdlib.h> |
| 23 |
|
| 24 |
#include <xmmintrin.h> |
| 25 |
#include <emmintrin.h> |
| 26 |
|
| 27 |
#include "easel.h" |
| 28 |
#include "esl_vectorops.h" |
| 29 |
#include "esl_sse.h" |
| 30 |
|
| 31 |
#include "hmmer.h" |
| 32 |
|
| 33 |
#include "infernal.h" |
| 34 |
|
| 35 |
#include "impl_sse.h" |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
GammaHitMx_epu8 * |
| 54 |
CreateGammaHitMx_epu8(int L, int i0, int be_greedy, int offset_zero, float cutoff, int do_backward) |
| 55 |
{ |
| 56 |
int status; |
| 57 |
GammaHitMx_epu8 *gamma; |
| 58 |
ESL_ALLOC(gamma, sizeof(GammaHitMx_epu8)); |
| 59 |
|
| 60 |
gamma->L = L; |
| 61 |
gamma->i0 = i0; |
| 62 |
gamma->iamgreedy = be_greedy; |
| 63 |
gamma->cutoff = cutoff; |
| 64 |
|
| 65 |
ESL_ALLOC(gamma->mx, sizeof(int) * (L+1)); |
| 66 |
ESL_ALLOC(gamma->gback, sizeof(int) * (L+1)); |
| 67 |
ESL_ALLOC(gamma->savesc, sizeof(float) * (L+1)); |
| 68 |
|
| 69 |
if(do_backward) { |
| 70 |
gamma->mx[L] = offset_zero; |
| 71 |
gamma->gback[L] = -1; |
| 72 |
} |
| 73 |
else { |
| 74 |
gamma->mx[0] = offset_zero; |
| 75 |
gamma->gback[0] = -1; |
| 76 |
} |
| 77 |
return gamma; |
| 78 |
|
| 79 |
ERROR: |
| 80 |
cm_Fail("memory allocation error in cm_CreateGammaHitMx().\n"); |
| 81 |
return NULL; |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
void |
| 92 |
FreeGammaHitMx_epu8(GammaHitMx_epu8 *gamma) |
| 93 |
{ |
| 94 |
free(gamma->mx); |
| 95 |
free(gamma->gback); |
| 96 |
free(gamma->savesc); |
| 97 |
free(gamma); |
| 98 |
|
| 99 |
return; |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
int |
| 125 |
UpdateGammaHitMx_epu8(CM_CONSENSUS *ccm, char *errbuf, GammaHitMx_epu8 *gamma, int j, __m128i *alpha_row, |
| 126 |
CM_TOPHITS *hitlist, int W, int sW) |
| 127 |
{ |
| 128 |
int i, d; |
| 129 |
|
| 130 |
int ip, jp; |
| 131 |
int do_report_hit; |
| 132 |
uint8_t hit_sc, bestd_sc; |
| 133 |
float fhit_sc; |
| 134 |
int cumulative_sc; |
| 135 |
CM_HIT *hit = NULL; |
| 136 |
|
| 137 |
|
| 138 |
if(! gamma->iamgreedy || alpha_row == NULL) { |
| 139 |
gamma->mx[j] = gamma->mx[j-1] + 0; |
| 140 |
gamma->gback[j] = -1; |
| 141 |
gamma->savesc[j] = -eslINFINITY; |
| 142 |
|
| 143 |
if(alpha_row != NULL) { |
| 144 |
for (d = 1; d <= W && d <= j; d++) { |
| 145 |
i = j-d+1; |
| 146 |
hit_sc = *(((uint8_t *) &alpha_row[d%sW])+d/sW); |
| 147 |
fhit_sc = ((float) (hit_sc - ccm->base_b))/ccm->scale_b; |
| 148 |
cumulative_sc = gamma->mx[i-1] + hit_sc - ccm->base_b; |
| 149 |
if (cumulative_sc < 0) cumulative_sc = 0; |
| 150 |
if (cumulative_sc >= gamma->mx[j]) { |
| 151 |
do_report_hit = TRUE; |
| 152 |
if(do_report_hit) { |
| 153 |
gamma->mx[j] = cumulative_sc; |
| 154 |
gamma->gback[j] = i + (gamma->i0-1); |
| 155 |
gamma->savesc[j] = fhit_sc; |
| 156 |
} |
| 157 |
} |
| 158 |
} |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
if(gamma->iamgreedy) { |
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
d = 1; |
| 170 |
hit_sc = *((uint8_t *) &alpha_row[d%sW] + d/sW); |
| 171 |
fhit_sc = ((float) (hit_sc - ccm->base_b))/ccm->scale_b; |
| 172 |
if (fhit_sc >= gamma->cutoff && NOT_IMPOSSIBLE(hit_sc)) { |
| 173 |
do_report_hit = TRUE; |
| 174 |
ip = j-d+gamma->i0; |
| 175 |
jp = j-1+gamma->i0; |
| 176 |
assert(ip >= gamma->i0); |
| 177 |
assert(jp >= gamma->i0); |
| 178 |
if(do_report_hit) { |
| 179 |
cm_tophits_CreateNextHit(hitlist, &hit); |
| 180 |
hit->start = ip; |
| 181 |
hit->stop = jp; |
| 182 |
hit->score = fhit_sc; |
| 183 |
hit->root = 0; |
| 184 |
hit->mode = TRMODE_J; |
| 185 |
hit->hmmonly = FALSE; |
| 186 |
} |
| 187 |
} |
| 188 |
|
| 189 |
bestd_sc = hit_sc; |
| 190 |
|
| 191 |
|
| 192 |
for (d = 2; d <= W; d++) { |
| 193 |
hit_sc = *(((uint8_t *) &alpha_row[d%sW]) + d/sW); |
| 194 |
fhit_sc = ((float) (hit_sc - ccm->base_b))/ccm->scale_b; |
| 195 |
if (hit_sc > bestd_sc) { |
| 196 |
if (fhit_sc >= gamma->cutoff && NOT_IMPOSSIBLE(hit_sc)) { |
| 197 |
do_report_hit = TRUE; |
| 198 |
ip = j-d+gamma->i0; |
| 199 |
jp = j-1+gamma->i0; |
| 200 |
assert(ip >= gamma->i0); |
| 201 |
assert(jp >= gamma->i0); |
| 202 |
if(do_report_hit) { |
| 203 |
cm_tophits_CreateNextHit(hitlist, &hit); |
| 204 |
hit->start = ip; |
| 205 |
hit->stop = jp; |
| 206 |
hit->score = fhit_sc; |
| 207 |
hit->root = 0; |
| 208 |
hit->mode = TRMODE_J; |
| 209 |
hit->hmmonly = FALSE; |
| 210 |
} |
| 211 |
} |
| 212 |
|
| 213 |
bestd_sc = hit_sc; |
| 214 |
} |
| 215 |
} |
| 216 |
} |
| 217 |
return eslOK; |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
void |
| 231 |
TBackGammaHitMx_epu8(GammaHitMx_epu8 *gamma, CM_TOPHITS *hitlist, int i0, int j0) |
| 232 |
{ |
| 233 |
int j, jp_g; |
| 234 |
CM_HIT *hit = NULL; |
| 235 |
|
| 236 |
if(gamma->iamgreedy) cm_Fail("cm_TBackGammaHitMx(), gamma->iamgreedy is TRUE.\n"); |
| 237 |
if(hitlist == NULL) cm_Fail("cm_TBackGammaHitMx(), hitlist == NULL"); |
| 238 |
|
| 239 |
|
| 240 |
j = j0; |
| 241 |
while (j >= i0) { |
| 242 |
jp_g = j-i0+1; |
| 243 |
if (gamma->gback[jp_g] == -1) j--; |
| 244 |
else { |
| 245 |
if(gamma->savesc[jp_g] >= gamma->cutoff) { |
| 246 |
cm_tophits_CreateNextHit(hitlist, &hit); |
| 247 |
hit->start = gamma->gback[jp_g]; |
| 248 |
hit->stop = j; |
| 249 |
hit->score = gamma->savesc[jp_g]; |
| 250 |
hit->root = 0; |
| 251 |
hit->mode = TRMODE_J; |
| 252 |
hit->hmmonly = FALSE; |
| 253 |
} |
| 254 |
j = gamma->gback[jp_g]-1; |
| 255 |
} |
| 256 |
} |
| 257 |
return; |
| 258 |
} |
| 259 |
|