| 1 | // This file is part of A2Amapper.cxx . . $ `<file>/atac-driver/chainer/localalign/GF_ALN_local.C`/ |
| 2 | // Copyright (c) 2004 Applera Corporation |
| 3 | // Author: Clark Mobarry |
| 4 | // |
| 5 | // This program is free software; you can redistribute it and/or modify |
| 6 | // it under the terms of the GNU General Public License as published by |
| 7 | // the Free Software Foundation; either version 2 of the License, or |
| 8 | // (at your option) any later version. |
| 9 | // |
| 10 | // This program is distributed in the hope that it will be useful, |
| 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | // GNU General Public License for more details. |
| 14 | // |
| 15 | // You should have received (LICENSE.txt) a copy of the GNU General Public |
| 16 | // License along with this program; if not, write to the Free Software |
| 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | |
| 19 | #include <stdio.h> |
| 20 | #include <stdlib.h> |
| 21 | #include <unistd.h> |
| 22 | #include <math.h> |
| 23 | #include <string.h> |
| 24 | #include <assert.h> |
| 25 | #include "GF_ALN_local.H"cxx . . $ `<file>/atac-driver/chainer/localalign/GF_ALN_local.H`/ |
| 26 | |
| 27 | // Note, KMERLEN 5, MINMATCH 20, MAXERROR 2, KTHRESH 6 is reasonable |
| 28 | // for performing fragment against fragment comparisons; it permits |
| 29 | // relatively small segments to be found; but it will not give |
| 30 | // acceptable run time for large comparisons such as a BAC against a |
| 31 | // BAC etc. So, ... |
| 32 | |
| 33 | #define KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`! 6 // Must be >= 1 |
| 34 | #define MINMATCHcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:34:9`! 20 // (MINMATCH-KMERLEN) is the maximum jump distance. |
| 35 | #define MAXERRORcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:35:9`! 2 // maximum slop in diagnols for chaining KMERLEN hits. |
| 36 | |
| 37 | // The minimum number kmer hits that constitutes an acceptable chain. |
| 38 | #define KTHRESHcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:38:9`! (MINMATCHcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:34:9`! - (KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!-1) - KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!*MAXERRORcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:35:9`!) |
| 39 | |
| 40 | #define mincxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:40:9`!(a,b) (a<b?a:b) |
| 41 | #define maxcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:41:9`!(a,b) (a>b?a:b) |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | /* D.P. extension alignment scoring */ |
| 47 | |
| 48 | /* N.B.: the larger MAXIGAP, the longer subpart of a trapezoid (potential |
| 49 | segment) can be missed; this occurs if (a) Align_Recursion starts |
| 50 | in the subpart, with a bad region on both sides of the subpart; |
| 51 | the forward pass extends across one of the low-quality regions |
| 52 | into a long high-quality region but then the reverse pass doesn't |
| 53 | get back across the low-quality region--or rather, it does, but the |
| 54 | best score doesn't. |
| 55 | |
| 56 | Of course, the smaller MAXIGAP, the shorter the segments and the |
| 57 | less the chance of extending alignments across gaps between trapezoids. |
| 58 | |
| 59 | Setting MAXIGAP small allows alignment extension to end relatively |
| 60 | early, so that a short high-quality region bounded by low-quality |
| 61 | regions can end up being its own segment. And, it also has the |
| 62 | effect that if a low-quality region is small enough to get through, |
| 63 | then it doesn't take that long a high-quality segment to increase |
| 64 | the score back up to a new maximum value. |
| 65 | */ |
| 66 | |
| 67 | #define MAXIGAP_DEFAULTcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:67:9`! 3 |
| 68 | |
| 69 | static int MAXIGAPcxx . . $ MAXIGAP.=MAXIGAP_DEFAULTcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:67:9`!; |
| 70 | |
| 71 | |
| 72 | /*amount to subtract from score for mismatch */ |
| 73 | //#define DIFFCOST 14 |
| 74 | // we can define it to 14 in order not to extend the alignment |
| 75 | // only at a high level of stringency |
| 76 | #define DIFFCOSTcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:76:9`! 3 |
| 77 | |
| 78 | /*amount to add to score for match*/ |
| 79 | #define SAMECOSTcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:79:9`! 1 |
| 80 | |
| 81 | static int diffcostcxx . . $ diffcost.=DIFFCOSTcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:76:9`!; |
| 82 | static int samecostcxx . . $ samecost.=SAMECOSTcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:79:9`!; |
| 83 | |
| 84 | /* Trapezoid merging padding */ |
| 85 | |
| 86 | #define DPADDINGcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:86:9`! 2 |
| 87 | #define BPADDINGcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:87:9`! KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!+2 |
| 88 | |
| 89 | static int BLOCKCOSTcxx . . $ BLOCKCOST. = DIFFCOSTcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:76:9`!*MAXIGAP_DEFAULTcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:67:9`!; |
| 90 | static int MATCHCOSTcxx . . $ MATCHCOST. = DIFFCOSTcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:76:9`!+SAMECOSTcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:79:9`!; |
| 91 | |
| 92 | |
| 93 | /* Major data types */ |
| 94 | |
| 95 | /* Hit Record: Description of indexed based seed-match */ |
| 96 | typedef structcxx . . $ $anonymous_type_76c1e511e60ee2c5_0# { |
| 97 | int diagonalcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#diagonal.; /* Diagonal of hit */ |
| 98 | int bstartcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bstart.; /* B position of start of hit */ |
| 99 | int bfinishcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bfinish.; /* B position of end of hit */ |
| 100 | } HitRecordcxx . . $ HitRecord#; |
| 101 | |
| 102 | /* Trapezoid Record: Description of trapezoidal match zone */ |
| 103 | typedef struct _Trap_Tagcxx . . $ _Trap_Tag# { |
| 104 | struct _Trap_Tagcxx . . $ _Trap_Tag# *nextcxx . . $ _Trap_Tag#next.; /* Organized in a list linked on this field */ |
| 105 | int topcxx . . $ _Trap_Tag#top., botcxx . . $ _Trap_Tag#bot.; /* B-coords of top and bottom of trapzoidal zone */ |
| 106 | int lftcxx . . $ _Trap_Tag#lft., rgtcxx . . $ _Trap_Tag#rgt.; /* Left and right diagonals of trapzoidal zone */ |
| 107 | } Trapezoidcxx . . $ Trapezoid#; |
| 108 | |
| 109 | |
| 110 | /*** UTILITY ROUTINES ***/ |
| 111 | |
| 112 | static |
| 113 | void |
| 114 | OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).(char const * const where) { |
| 115 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"COMPARE_LOCAL: Out of memory (%s)\n",where); |
| 116 | exitcxx . . $ exit(44ed87f96534fad7). (1); |
| 117 | } |
| 118 | |
| 119 | static void Complementcxx . . $ Complement(a07d8cccb7673f5a).(char * const seq, int const len) { |
| 120 | static char WCinvert[256]; |
| 121 | static int Firstime = 1; |
| 122 | |
| 123 | if (Firstime) { /* Setup complementation array */ |
| 124 | int i; |
| 125 | |
| 126 | Firstime = 0; |
| 127 | for(i = 0; i < 256;i++){ |
| 128 | WCinvert[i] = '?'; |
| 129 | } |
| 130 | WCinvert[(int)'a'] = 't'; |
| 131 | WCinvert[(int)'c'] = 'g'; |
| 132 | WCinvert[(int)'g'] = 'c'; |
| 133 | WCinvert[(int)'t'] = 'a'; |
| 134 | WCinvert[(int)'n'] = 'n'; |
| 135 | WCinvert[(int)'A'] = 'T'; |
| 136 | WCinvert[(int)'C'] = 'G'; |
| 137 | WCinvert[(int)'G'] = 'C'; |
| 138 | WCinvert[(int)'T'] = 'A'; |
| 139 | WCinvert[(int)'N'] = 'N'; |
| 140 | WCinvert[(int)'-'] = '-'; // added this to enable alignment of gapped consensi |
| 141 | } |
| 142 | |
| 143 | /* Complement and reverse sequence */ |
| 144 | |
| 145 | { |
| 146 | register char *s, *t; |
| 147 | int c; |
| 148 | |
| 149 | s = seq; |
| 150 | t = seq + (len-1); |
| 151 | while (s < t) |
| 152 | { c = *s; |
| 153 | *s++ = WCinvert[(int) *t]; |
| 154 | *t-- = WCinvert[c]; |
| 155 | } |
| 156 | if (s == t) |
| 157 | *s = WCinvert[(int) *s]; |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | |
| 162 | /*** INDEX CONSTRUCTION AND APPLICATION TO FILTERING ***/ |
| 163 | |
| 164 | /* Shared index and filter arrays used in this subsection */ |
| 165 | |
| 166 | typedef structcxx . . $ $anonymous_type_76c1e511e60ee2c5_1# { |
| 167 | int minimcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#minim.; |
| 168 | int maximcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#maxim.; |
| 169 | int countcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#count.; |
| 170 | } DiagRecordcxx . . $ DiagRecord#; |
| 171 | |
| 172 | static int Kmaskcxx . . $ Kmask. = -1; |
| 173 | static int *Tablecxx . . $ Table. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; /* [0..Kmask+1] */ |
| 174 | static int *Tuplescxx . . $ Tuples. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; /* [0..<Seqlen>-KMERLEN] */ |
| 175 | static int Mapcxx . . $ Map.[128]; |
| 176 | |
| 177 | static DiagRecordcxx . . $ DiagRecord# *DiagVeccxx . . $ DiagVec.; /* [-(Alen-KMERLEN)..(Blen-KMERLEN) + MAXERROR] */ |
| 178 | |
| 179 | |
| 180 | /* Reverse complement sequences -- so we do not recompute them over and over */ |
| 181 | static char *BrevCcxx . . $ BrevC.=NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 182 | |
| 183 | /* Build index table for sequence S of length Slen. */ |
| 184 | |
| 185 | static void TableBuildcxx . . $ TableBuild(34d26762b42c433a).(char const * const S, int const Slen) |
| 186 | { int i, c; |
| 187 | int x, h; |
| 188 | char const * const s = S+(KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!-1); |
| 189 | |
| 190 | for (c = 0; c <= Kmaskcxx . . $ Kmask.; c++) |
| 191 | Tablecxx . . $ Table.[c] = 0; |
| 192 | |
| 193 | h = -KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!; |
| 194 | c = 0; |
| 195 | for (i = 0; i < KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!-1; i++) |
| 196 | { x = Mapcxx . . $ Map.[(int) (S[i])]; |
| 197 | if (x >= 0) |
| 198 | c = (c << 2) | x; |
| 199 | else |
| 200 | { c <<= 2; h = i-(KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!-1); } |
| 201 | } |
| 202 | for (i = 0; i <= Slen-KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!; i++) |
| 203 | { x = Mapcxx . . $ Map.[(int) (s[i])]; |
| 204 | if (x >= 0) |
| 205 | c = ((c << 2) | x) & Kmaskcxx . . $ Kmask.; |
| 206 | else |
| 207 | { c = (c << 2) & Kmaskcxx . . $ Kmask.; h = i; } |
| 208 | if (i >= h+KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!) |
| 209 | Tablecxx . . $ Table.[c+1] += 1; |
| 210 | } |
| 211 | |
| 212 | for (c = 2; c <= Kmaskcxx . . $ Kmask.; c++) |
| 213 | Tablecxx . . $ Table.[c] += Tablecxx . . $ Table.[c-1]; |
| 214 | |
| 215 | h = -KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!; |
| 216 | c = 0; |
| 217 | for (i = 0; i < KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!-1; i++) |
| 218 | { x = Mapcxx . . $ Map.[(int) (S[i])]; |
| 219 | if (x >= 0) |
| 220 | c = (c << 2) | x; |
| 221 | else |
| 222 | { c <<= 2; h = i-(KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!-1); } |
| 223 | } |
| 224 | for (i = 0; i <= Slen-KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!; i++) |
| 225 | { x = Mapcxx . . $ Map.[(int) (s[i])]; |
| 226 | if (x >= 0) |
| 227 | c = ((c << 2) | x) & Kmaskcxx . . $ Kmask.; |
| 228 | else |
| 229 | { c = (c << 2) & Kmaskcxx . . $ Kmask.; h = i; } |
| 230 | if (i >= h+KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!) |
| 231 | Tuplescxx . . $ Tuples.[Tablecxx . . $ Table.[c]++] = i; |
| 232 | } |
| 233 | |
| 234 | for (c = Kmaskcxx . . $ Kmask.; c >= 0; c--) |
| 235 | Tablecxx . . $ Table.[c+1] = Tablecxx . . $ Table.[c]; |
| 236 | Tablecxx . . $ Table.[0] = 0; |
| 237 | } |
| 238 | |
| 239 | /* Apply index to find filtered hits between sequences, returning pointer to |
| 240 | array of HitRecords of length in the integer pointed at by Hitlen */ |
| 241 | |
| 242 | static int HSORTcxx . . $ HSORT(9148c8c3ff42c9d8).(const void *l, const void *r) |
| 243 | { HitRecordcxx . . $ HitRecord# *x, *y; |
| 244 | x = (HitRecordcxx . . $ HitRecord# *) l; |
| 245 | y = (HitRecordcxx . . $ HitRecord# *) r; |
| 246 | return (x->bstartcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bstart. - y->bstartcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bstart.); |
| 247 | } |
| 248 | |
| 249 | static HitRecordcxx . . $ HitRecord# *Find_Hitscxx . . $ Find_Hits(31e353e558cd1ecb). |
| 250 | (char const * const A, int const Alen, |
| 251 | char const * const B, int const Blen, int * const Hitlen) |
| 252 | { static int HitMax = -1; |
| 253 | static HitRecordcxx . . $ HitRecord# *HitList; |
| 254 | int hits, disconnect; |
| 255 | |
| 256 | if (HitMax < 0) |
| 257 | { HitMax = 10000; |
| 258 | HitList = (HitRecordcxx . . $ HitRecord# *) malloccxx . . $ malloc(9f008b2a9698428b).(sizeof(HitRecordcxx . . $ HitRecord#)*HitMax); |
| 259 | if (HitList == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 260 | OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).("Hit list"); |
| 261 | } |
| 262 | |
| 263 | { int i, j, c; |
| 264 | int x, h; |
| 265 | char const * const b = B + (KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!-1); |
| 266 | |
| 267 | for (j = -Alen; j <= Blen+MAXERRORcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:35:9`!; j++) |
| 268 | { DiagRecordcxx . . $ DiagRecord# *dp; |
| 269 | dp = DiagVeccxx . . $ DiagVec. + j; |
| 270 | dp->countcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#count. = dp->maximcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#maxim. = 0; |
| 271 | } |
| 272 | |
| 273 | hits = 0; |
| 274 | disconnect = MINMATCHcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:34:9`! - KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!; |
| 275 | h = -KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!; |
| 276 | c = 0; |
| 277 | for (i = 0; i < KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!-1; i++) |
| 278 | { x = Mapcxx . . $ Map.[(int) (B[i])]; |
| 279 | if (x >= 0) |
| 280 | c = (c << 2) | x; |
| 281 | else |
| 282 | { c <<= 2; h = i-(KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!-1); } |
| 283 | } |
| 284 | |
| 285 | for (i = 0; i <= Blen-KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!; i++) |
| 286 | { x = Mapcxx . . $ Map.[(int) (b[i])]; |
| 287 | if (x >= 0) |
| 288 | c = ((c << 2) | x) & Kmaskcxx . . $ Kmask.; |
| 289 | else |
| 290 | { c = (c << 2) & Kmaskcxx . . $ Kmask.; h = i; } |
| 291 | if (i >= h+KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!) |
| 292 | for (j = Tablecxx . . $ Table.[c]; j < Tablecxx . . $ Table.[c+1]; j++) |
| 293 | { DiagRecordcxx . . $ DiagRecord# *dp; |
| 294 | int e, k; |
| 295 | k = i-Tuplescxx . . $ Tuples.[j]; |
| 296 | dp = DiagVeccxx . . $ DiagVec. + k; |
| 297 | for (e = 0; e <= MAXERRORcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:35:9`!; e++) |
| 298 | { if (dp->maximcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#maxim. < i-disconnect) |
| 299 | { if (dp->countcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#count. >= KTHRESHcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:38:9`!) |
| 300 | { HitRecordcxx . . $ HitRecord# *hp; |
| 301 | if (hits >= HitMax) |
| 302 | { HitMax = (int)(1.2*hits) + 5000; |
| 303 | HitList = (HitRecordcxx . . $ HitRecord# *) realloccxx . . $ realloc(42b2a9dd8f084bf2).(HitList, |
| 304 | sizeof(HitRecordcxx . . $ HitRecord#)*HitMax); |
| 305 | if (HitList == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 306 | OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).("Hit list"); |
| 307 | } |
| 308 | hp = HitList + hits; |
| 309 | hp->diagonalcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#diagonal. = k; |
| 310 | hp->bstartcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bstart. = dp->minimcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#minim.; |
| 311 | hp->bfinishcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bfinish. = dp->maximcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#maxim. + KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!; |
| 312 | hits += 1; |
| 313 | } |
| 314 | dp->countcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#count. = 0; |
| 315 | } |
| 316 | if (dp->countcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#count. == 0) |
| 317 | dp->minimcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#minim. = i; |
| 318 | dp->countcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#count. += 1; |
| 319 | dp->maximcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#maxim. = i; |
| 320 | dp += 1; |
| 321 | } |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | for (j = -Alen; j <= Blen+MAXERRORcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:35:9`!; j++) |
| 326 | { DiagRecordcxx . . $ DiagRecord# *dp; |
| 327 | dp = DiagVeccxx . . $ DiagVec. + j; |
| 328 | if (dp->countcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#count. >= KTHRESHcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:38:9`!) |
| 329 | { HitRecordcxx . . $ HitRecord# *hp; |
| 330 | if (hits >= HitMax) |
| 331 | { HitMax = (int)(1.2*hits) + 5000; |
| 332 | HitList = (HitRecordcxx . . $ HitRecord# *)realloccxx . . $ realloc(42b2a9dd8f084bf2).(HitList,sizeof(HitRecordcxx . . $ HitRecord#)*HitMax); |
| 333 | if (HitList == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 334 | OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).("Hit list"); |
| 335 | } |
| 336 | hp = HitList + hits; |
| 337 | hp->diagonalcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#diagonal. = j; |
| 338 | hp->bstartcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bstart. = dp->minimcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#minim.; |
| 339 | hp->bfinishcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bfinish. = dp->maximcxx . . $ $anonymous_type_76c1e511e60ee2c5_1#maxim. + KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!; |
| 340 | hits += 1; |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(HitList,hits,sizeof(HitRecordcxx . . $ HitRecord#),HSORTcxx . . $ HSORT(9148c8c3ff42c9d8).); |
| 346 | |
| 347 | *Hitlen = hits; |
| 348 | return (HitList); |
| 349 | } |
| 350 | |
| 351 | |
| 352 | /*** FORWARD AND REVERSE D.P. EXTENSION ROUTINES ***/ |
| 353 | /* Called at the mid-point of trapezoid -- mid X [lo,hi], the extension |
| 354 | is computed to an end point and the lowest and highest diagonals |
| 355 | are recorded. These are returned in a partially filled Local_Segment |
| 356 | record, that will be merged with that returned for extension in the |
| 357 | opposite direction. |
| 358 | */ |
| 359 | |
| 360 | Local_Segmentcxx . . $ Local_Segment# *TraceForwardPathcxx . . $ TraceForwardPath(e4f4f112a411e3c). |
| 361 | ( char const * const A, int const Alen, |
| 362 | char const * const B, int const Blen, |
| 363 | int const mid, int lo, int hi) |
| 364 | { static Local_Segmentcxx . . $ Local_Segment# rez; |
| 365 | int *V; |
| 366 | int mxv, mxl, mxr, mxi, mxj; |
| 367 | int i, j; |
| 368 | int *Base1, *Base2; |
| 369 | |
| 370 | Base1 = ((int *) DiagVeccxx . . $ DiagVec.); |
| 371 | Base2 = Base1 + (Blen+1); |
| 372 | |
| 373 | /* Set basis from (mid,lo) .. (mid,hi) */ |
| 374 | |
| 375 | V = Base1; |
| 376 | if (lo < 0) lo = 0; |
| 377 | if (hi > Blen) hi = Blen; |
| 378 | |
| 379 | for (j = lo; j <= hi; j++) |
| 380 | V[j] = 0; |
| 381 | hi += MAXIGAPcxx . . $ MAXIGAP.; |
| 382 | if (hi > Blen) hi = Blen; |
| 383 | for (; j <= hi; j++) |
| 384 | V[j] = V[j-1] - diffcostcxx . . $ diffcost.; |
| 385 | mxv = 0; |
| 386 | mxr = mid - lo; |
| 387 | mxl = mid - hi; |
| 388 | mxi = mid; |
| 389 | mxj = lo; |
| 390 | |
| 391 | /* Advance to next row */ |
| 392 | |
| 393 | for (i = mid; lo <= hi && i < Alen; i++) |
| 394 | { int c, v; |
| 395 | int *W; |
| 396 | |
| 397 | W = V; |
| 398 | if (V == Base1) |
| 399 | V = Base2; |
| 400 | else |
| 401 | V = Base1; |
| 402 | |
| 403 | v = W[lo]; |
| 404 | c = V[lo] = v - diffcostcxx . . $ diffcost.; |
| 405 | for (j = lo+1; j <= hi; j++) |
| 406 | { int r, t; |
| 407 | |
| 408 | t = c; |
| 409 | c = v; |
| 410 | v = W[j]; |
| 411 | if (Mapcxx . . $ Map.[(int)A[i]] == Mapcxx . . $ Map.[(int)B[j-1]] && Mapcxx . . $ Map.[(int) (A[i])] >= 0) |
| 412 | c += MATCHCOSTcxx . . $ MATCHCOST.; |
| 413 | |
| 414 | r = c; |
| 415 | if (v > r) r = v; |
| 416 | if (t > r) r = t; |
| 417 | |
| 418 | V[j] = c = r - diffcostcxx . . $ diffcost.; |
| 419 | if (c >= mxv) |
| 420 | { mxv = c; |
| 421 | mxi = i+1; |
| 422 | mxj = j; |
| 423 | //printf("reset mxv = %d at [%d,%d]\n",mxv,mxi,mxj); |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | if (j <= Blen) |
| 428 | { int r; |
| 429 | |
| 430 | if (Mapcxx . . $ Map.[(int)A[i]] == Mapcxx . . $ Map.[(int)B[j-1]] && Mapcxx . . $ Map.[(int) (A[i])] >= 0) |
| 431 | v += MATCHCOSTcxx . . $ MATCHCOST.; |
| 432 | |
| 433 | r = v; |
| 434 | if (c > r) r = c; |
| 435 | |
| 436 | V[j] = v = r - diffcostcxx . . $ diffcost.; |
| 437 | if (v > mxv) |
| 438 | { mxv = v; |
| 439 | mxi = i+1; |
| 440 | mxj = j; |
| 441 | //printf("reset mxv = %d at [%d,%d]\n",mxv,mxi,mxj); |
| 442 | } |
| 443 | |
| 444 | for (j++; j <= Blen; j++) |
| 445 | { v -= diffcostcxx . . $ diffcost.; |
| 446 | if (v < mxv - BLOCKCOSTcxx . . $ BLOCKCOST.) break; |
| 447 | V[j] = v; |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | hi = j-1; |
| 452 | |
| 453 | while (lo <= hi && V[lo] < mxv - BLOCKCOSTcxx . . $ BLOCKCOST.) |
| 454 | lo += 1; |
| 455 | while (lo <= hi && V[hi] < mxv - BLOCKCOSTcxx . . $ BLOCKCOST.) |
| 456 | hi -= 1; |
| 457 | |
| 458 | if ((i+1) - lo > mxr) |
| 459 | mxr = (i+1) - lo; |
| 460 | if ((i+1) - hi < mxl) |
| 461 | mxl = (i+1) - hi; |
| 462 | } |
| 463 | |
| 464 | rez.aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos. = mxj; |
| 465 | rez.beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos. = mxi; |
| 466 | rez.ldiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#ldiag. = mxl; |
| 467 | rez.hdiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#hdiag. = mxr; |
| 468 | rez.scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score. = mxv; |
| 469 | return (&rez); |
| 470 | } |
| 471 | |
| 472 | Local_Segmentcxx . . $ Local_Segment# *TraceReversePathcxx . . $ TraceReversePath(a16f0c1660cd2fee).(char const * const A, int const Alen, |
| 473 | char const * const B, int const Blen, |
| 474 | int const top, int lo, int hi, |
| 475 | int const bot, int xfactor) { |
| 476 | static Local_Segmentcxx . . $ Local_Segment# rez; |
| 477 | int *V; |
| 478 | int mxv, mxl, mxr, mxi, mxj; |
| 479 | int i, j; |
| 480 | int *Base1, *Base2; |
| 481 | |
| 482 | Base1 = ((int *) DiagVeccxx . . $ DiagVec.); |
| 483 | Base2 = Base1 + (Blen+1); |
| 484 | |
| 485 | /* Set basis from (top,lo) .. (top,hi) */ |
| 486 | |
| 487 | V = Base1; |
| 488 | if (lo < 0) lo = 0; |
| 489 | if (hi > Blen) hi = Blen; |
| 490 | |
| 491 | for (j = hi; j >= lo; j--) |
| 492 | V[j] = 0; |
| 493 | lo -= MAXIGAPcxx . . $ MAXIGAP.; |
| 494 | if (lo < 0) lo = 0; |
| 495 | for (; j >= lo; j--) |
| 496 | V[j] = V[j+1] - diffcostcxx . . $ diffcost.; |
| 497 | mxv = 0; |
| 498 | mxr = top - lo; |
| 499 | mxl = top - hi; |
| 500 | mxi = top; |
| 501 | mxj = lo; |
| 502 | |
| 503 | /* Advance to next row */ |
| 504 | |
| 505 | if (top-1 <= bot) xfactor = BLOCKCOSTcxx . . $ BLOCKCOST.; |
| 506 | |
| 507 | for (i = top-1; lo <= hi && i >= 0; i--) |
| 508 | { int c, v; |
| 509 | int *W; |
| 510 | |
| 511 | W = V; |
| 512 | if (V == Base1) |
| 513 | V = Base2; |
| 514 | else |
| 515 | V = Base1; |
| 516 | |
| 517 | |
| 518 | v = W[hi]; |
| 519 | c = V[hi] = v - diffcostcxx . . $ diffcost.; |
| 520 | for (j = hi-1; j >= lo; j--) |
| 521 | { int r, t; |
| 522 | |
| 523 | t = c; |
| 524 | c = v; |
| 525 | v = W[j]; |
| 526 | if (Mapcxx . . $ Map.[(int)A[i]] == Mapcxx . . $ Map.[(int)B[j]] && Mapcxx . . $ Map.[(int) (A[i])] >= 0) |
| 527 | c += MATCHCOSTcxx . . $ MATCHCOST.; |
| 528 | |
| 529 | r = c; |
| 530 | if (v > r) r = v; |
| 531 | if (t > r) r = t; |
| 532 | |
| 533 | V[j] = c = r - diffcostcxx . . $ diffcost.; |
| 534 | if (c >= mxv) |
| 535 | { mxv = c; |
| 536 | mxi = i; |
| 537 | mxj = j; |
| 538 | //printf("reset mxv = %d at [%d,%d]\n",mxv,mxi,mxj); |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | if (j >= 0) |
| 543 | { int r; |
| 544 | |
| 545 | if (Mapcxx . . $ Map.[(int)A[i]] == Mapcxx . . $ Map.[(int)B[j]] && Mapcxx . . $ Map.[(int) (A[i])] >= 0) |
| 546 | v += MATCHCOSTcxx . . $ MATCHCOST.; |
| 547 | |
| 548 | r = v; |
| 549 | if (c > r) r = c; |
| 550 | |
| 551 | V[j] = v = r - diffcostcxx . . $ diffcost.; |
| 552 | if (v > mxv) |
| 553 | { mxv = v; |
| 554 | mxi = i; |
| 555 | mxj = j; |
| 556 | //printf("reset mxv = %d at [%d,%d]\n",mxv,mxi,mxj); |
| 557 | } |
| 558 | |
| 559 | for (j--; j >= 0; j--) |
| 560 | { v -= diffcostcxx . . $ diffcost.; |
| 561 | if (v < mxv - xfactor) break; |
| 562 | V[j] = v; |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | lo = j+1; |
| 567 | |
| 568 | while (lo <= hi && V[lo] < mxv - xfactor) |
| 569 | lo += 1; |
| 570 | while (lo <= hi && V[hi] < mxv - xfactor) |
| 571 | hi -= 1; |
| 572 | |
| 573 | if (i == bot) xfactor = BLOCKCOSTcxx . . $ BLOCKCOST.; |
| 574 | |
| 575 | if (i-lo > mxr) |
| 576 | mxr = i-lo; |
| 577 | if (i-hi < mxl) |
| 578 | mxl = i-hi; |
| 579 | } |
| 580 | |
| 581 | rez.abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos. = mxj; |
| 582 | rez.bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos. = mxi; |
| 583 | rez.ldiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#ldiag. = mxl; |
| 584 | rez.hdiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#hdiag. = mxr; |
| 585 | rez.scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score. = mxv; |
| 586 | return (&rez); |
| 587 | } |
| 588 | |
| 589 | |
| 590 | /*** MERGING INDEX HITS INTO TRAPEZOIDAL ZONES ***/ |
| 591 | |
| 592 | static Trapezoidcxx . . $ Trapezoid# *Build_Trapezoidscxx . . $ Build_Trapezoids(fa5870b410bd1ac8).(char const * const A, int const Alen, |
| 593 | char const * const B, int const Blen, |
| 594 | HitRecordcxx . . $ HitRecord# const * const list, int const Hitlen, int * const Traplen) { |
| 595 | static Trapezoidcxx . . $ Trapezoid# *free = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 596 | |
| 597 | Trapezoidcxx . . $ Trapezoid# *traporder, *traplist, *tailend; |
| 598 | Trapezoidcxx . . $ Trapezoid# *b, *f, *t; |
| 599 | int i, inserted; |
| 600 | int trapcount, traparea; |
| 601 | |
| 602 | trapcount = 0; |
| 603 | traparea = 0; |
| 604 | traporder = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 605 | traplist = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 606 | for (i = 0; i < Hitlen; i++) { |
| 607 | inserted = 0; |
| 608 | f = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 609 | for (b = traporder; b != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; b = t) { |
| 610 | t = b->nextcxx . . $ _Trap_Tag#next.; |
| 611 | if (b->topcxx . . $ _Trap_Tag#top. < list[i].bstartcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bstart. - BPADDINGcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:87:9`!) { |
| 612 | trapcount += 1; |
| 613 | traparea += (b->topcxx . . $ _Trap_Tag#top. - b->botcxx . . $ _Trap_Tag#bot. + 1) * (b->rgtcxx . . $ _Trap_Tag#rgt. - b->lftcxx . . $ _Trap_Tag#lft. + 1); |
| 614 | if (f == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 615 | traporder = t; |
| 616 | else |
| 617 | f->nextcxx . . $ _Trap_Tag#next. = t; |
| 618 | b->nextcxx . . $ _Trap_Tag#next. = traplist; |
| 619 | traplist = b; |
| 620 | } |
| 621 | else if (list[i].diagonalcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#diagonal. > b->rgtcxx . . $ _Trap_Tag#rgt. + DPADDINGcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:86:9`!) |
| 622 | f = b; |
| 623 | else if (list[i].diagonalcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#diagonal. >= b->lftcxx . . $ _Trap_Tag#lft. - DPADDINGcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:86:9`!) { |
| 624 | if (list[i].diagonalcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#diagonal. < b->lftcxx . . $ _Trap_Tag#lft.) |
| 625 | b->lftcxx . . $ _Trap_Tag#lft. = list[i].diagonalcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#diagonal.; |
| 626 | if (list[i].diagonalcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#diagonal. > b->rgtcxx . . $ _Trap_Tag#rgt.) |
| 627 | b->rgtcxx . . $ _Trap_Tag#rgt. = list[i].diagonalcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#diagonal.; |
| 628 | if (list[i].bfinishcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bfinish. > b->topcxx . . $ _Trap_Tag#top.) |
| 629 | b->topcxx . . $ _Trap_Tag#top. = list[i].bfinishcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bfinish.; |
| 630 | |
| 631 | if (f != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`! && f->rgtcxx . . $ _Trap_Tag#rgt. + DPADDINGcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:86:9`! >= b->lftcxx . . $ _Trap_Tag#lft.) { |
| 632 | f->rgtcxx . . $ _Trap_Tag#rgt. = b->rgtcxx . . $ _Trap_Tag#rgt.; |
| 633 | if (f->botcxx . . $ _Trap_Tag#bot. > b->botcxx . . $ _Trap_Tag#bot.) f->botcxx . . $ _Trap_Tag#bot. = b->botcxx . . $ _Trap_Tag#bot.; |
| 634 | if (f->topcxx . . $ _Trap_Tag#top. < b->topcxx . . $ _Trap_Tag#top.) f->topcxx . . $ _Trap_Tag#top. = b->topcxx . . $ _Trap_Tag#top.; |
| 635 | f->nextcxx . . $ _Trap_Tag#next. = t; |
| 636 | b->nextcxx . . $ _Trap_Tag#next. = free; |
| 637 | free = b; |
| 638 | } |
| 639 | else if (t != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`! && t->lftcxx . . $ _Trap_Tag#lft. - DPADDINGcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:86:9`! <= b->rgtcxx . . $ _Trap_Tag#rgt.) { |
| 640 | b->rgtcxx . . $ _Trap_Tag#rgt. = t->rgtcxx . . $ _Trap_Tag#rgt.; |
| 641 | if (b->botcxx . . $ _Trap_Tag#bot. > t->botcxx . . $ _Trap_Tag#bot.) b->botcxx . . $ _Trap_Tag#bot. = t->botcxx . . $ _Trap_Tag#bot.; |
| 642 | if (b->topcxx . . $ _Trap_Tag#top. < t->topcxx . . $ _Trap_Tag#top.) b->topcxx . . $ _Trap_Tag#top. = t->topcxx . . $ _Trap_Tag#top.; |
| 643 | b->nextcxx . . $ _Trap_Tag#next. = t->nextcxx . . $ _Trap_Tag#next.; |
| 644 | t->nextcxx . . $ _Trap_Tag#next. = free; |
| 645 | free = t; |
| 646 | t = b->nextcxx . . $ _Trap_Tag#next.; |
| 647 | f = b; |
| 648 | } |
| 649 | else |
| 650 | f = b; |
| 651 | inserted = 1; |
| 652 | } else if (! inserted) { |
| 653 | if (free == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) { |
| 654 | free = (Trapezoidcxx . . $ Trapezoid# *)malloccxx . . $ malloc(9f008b2a9698428b).(sizeof(Trapezoidcxx . . $ Trapezoid#)); |
| 655 | if (free == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 656 | OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).("Trapezoid scan list"); |
| 657 | free->nextcxx . . $ _Trap_Tag#next. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 658 | } |
| 659 | if (f == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 660 | f = traporder = free; |
| 661 | else |
| 662 | f = f->nextcxx . . $ _Trap_Tag#next. = free; |
| 663 | free = f->nextcxx . . $ _Trap_Tag#next.; |
| 664 | f->nextcxx . . $ _Trap_Tag#next. = b; |
| 665 | f->topcxx . . $ _Trap_Tag#top. = list[i].bfinishcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bfinish.; |
| 666 | f->botcxx . . $ _Trap_Tag#bot. = list[i].bstartcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bstart.; |
| 667 | f->lftcxx . . $ _Trap_Tag#lft. = f->rgtcxx . . $ _Trap_Tag#rgt. = list[i].diagonalcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#diagonal.; |
| 668 | f = b; |
| 669 | inserted = 1; |
| 670 | } else |
| 671 | f = b; |
| 672 | } |
| 673 | if (! inserted) { |
| 674 | if (free == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) { |
| 675 | free = (Trapezoidcxx . . $ Trapezoid# *)malloccxx . . $ malloc(9f008b2a9698428b).(sizeof(Trapezoidcxx . . $ Trapezoid#)); |
| 676 | if (free == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 677 | OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).("Trapezoid scan list"); |
| 678 | free->nextcxx . . $ _Trap_Tag#next. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 679 | } |
| 680 | if (f == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 681 | f = traporder = free; |
| 682 | else |
| 683 | f = f->nextcxx . . $ _Trap_Tag#next. = free; |
| 684 | free = f->nextcxx . . $ _Trap_Tag#next.; |
| 685 | f->nextcxx . . $ _Trap_Tag#next. = b; |
| 686 | f->topcxx . . $ _Trap_Tag#top. = list[i].bfinishcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bfinish.; |
| 687 | f->botcxx . . $ _Trap_Tag#bot. = list[i].bstartcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#bstart.; |
| 688 | f->lftcxx . . $ _Trap_Tag#lft. = f->rgtcxx . . $ _Trap_Tag#rgt. = list[i].diagonalcxx . . $ $anonymous_type_76c1e511e60ee2c5_0#diagonal.; |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | for (b = traporder; b != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; b = t) { |
| 693 | t = b->nextcxx . . $ _Trap_Tag#next.; |
| 694 | trapcount += 1; |
| 695 | traparea += (b->topcxx . . $ _Trap_Tag#top. - b->botcxx . . $ _Trap_Tag#bot. + 1) * (b->rgtcxx . . $ _Trap_Tag#rgt. - b->lftcxx . . $ _Trap_Tag#lft. + 1); |
| 696 | b->nextcxx . . $ _Trap_Tag#next. = traplist; |
| 697 | traplist = b; |
| 698 | } |
| 699 | |
| 700 | { |
| 701 | int lag, lst, lclip; |
| 702 | int abot, atop; |
| 703 | |
| 704 | for (b = traplist; b != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; b = b->nextcxx . . $ _Trap_Tag#next.) { |
| 705 | lag = (b->botcxx . . $ _Trap_Tag#bot.-MAXIGAPcxx . . $ MAXIGAP.)+1; |
| 706 | if (lag < 0) lag = 0; |
| 707 | lst = b->topcxx . . $ _Trap_Tag#top.+MAXIGAPcxx . . $ MAXIGAP.; |
| 708 | if (lst > Blen) |
| 709 | lst = Blen; |
| 710 | |
| 711 | for (i = lag; i < lst; i++) { |
| 712 | if (Mapcxx . . $ Map.[(int) (B[i])] >= 0) { |
| 713 | if (i-lag >= MAXIGAPcxx . . $ MAXIGAP.) { |
| 714 | if (lag - b->botcxx . . $ _Trap_Tag#bot. > 0) { |
| 715 | if (free == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) { |
| 716 | free = (Trapezoidcxx . . $ Trapezoid# *)malloccxx . . $ malloc(9f008b2a9698428b).(sizeof(Trapezoidcxx . . $ Trapezoid#)); |
| 717 | if (free == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 718 | OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).("Trapezoid cutter"); |
| 719 | free->nextcxx . . $ _Trap_Tag#next. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 720 | } |
| 721 | t = free->nextcxx . . $ _Trap_Tag#next.; |
| 722 | *free =cxx . . $ _Trap_Tag#`operator=`(afe4f613b40eec51). *b; |
| 723 | b->nextcxx . . $ _Trap_Tag#next. = free; |
| 724 | free = t; |
| 725 | b->topcxx . . $ _Trap_Tag#top. = lag; |
| 726 | b = b->nextcxx . . $ _Trap_Tag#next.; |
| 727 | b->botcxx . . $ _Trap_Tag#bot. = i; |
| 728 | trapcount += 1; |
| 729 | } |
| 730 | else |
| 731 | b->botcxx . . $ _Trap_Tag#bot. = i; |
| 732 | } |
| 733 | lag = i+1; |
| 734 | } |
| 735 | } |
| 736 | if (i-lag >= MAXIGAPcxx . . $ MAXIGAP.) |
| 737 | b->topcxx . . $ _Trap_Tag#top. = lag; |
| 738 | } |
| 739 | |
| 740 | tailend = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 741 | for (b = traplist; b != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; b = b->nextcxx . . $ _Trap_Tag#next.) { |
| 742 | if (b->topcxx . . $ _Trap_Tag#top. - b->botcxx . . $ _Trap_Tag#bot. < KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!) continue; |
| 743 | |
| 744 | abot = b->botcxx . . $ _Trap_Tag#bot. - b->rgtcxx . . $ _Trap_Tag#rgt.; |
| 745 | atop = b->topcxx . . $ _Trap_Tag#top. - b->lftcxx . . $ _Trap_Tag#lft.; |
| 746 | |
| 747 | |
| 748 | lag = (abot - MAXIGAPcxx . . $ MAXIGAP.) + 1; |
| 749 | if (lag < 0) lag = 0; |
| 750 | lst = atop + MAXIGAPcxx . . $ MAXIGAP.; |
| 751 | if (lst > Alen) lst = Alen; |
| 752 | |
| 753 | lclip = abot; |
| 754 | for (i = lag; i < lst; i++) { |
| 755 | if (Mapcxx . . $ Map.[(int) (A[i])] >= 0) { |
| 756 | if (i-lag >= MAXIGAPcxx . . $ MAXIGAP.) { |
| 757 | if (lag > lclip) { |
| 758 | if (free == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) { |
| 759 | free = (Trapezoidcxx . . $ Trapezoid# *)malloccxx . . $ malloc(9f008b2a9698428b).(sizeof(Trapezoidcxx . . $ Trapezoid#)); |
| 760 | if (free == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 761 | OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).("Trapezoid cutter"); |
| 762 | free->nextcxx . . $ _Trap_Tag#next. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 763 | } |
| 764 | t = free->nextcxx . . $ _Trap_Tag#next.; |
| 765 | *free =cxx . . $ _Trap_Tag#`operator=`(afe4f613b40eec51). *b; |
| 766 | b->nextcxx . . $ _Trap_Tag#next. = free; |
| 767 | free = t; |
| 768 | |
| 769 | { |
| 770 | int x, m; |
| 771 | x = lclip + b->lftcxx . . $ _Trap_Tag#lft.; |
| 772 | if (b->botcxx . . $ _Trap_Tag#bot. < x) |
| 773 | b->botcxx . . $ _Trap_Tag#bot. = x; |
| 774 | x = lag + b->rgtcxx . . $ _Trap_Tag#rgt.; |
| 775 | if (b->topcxx . . $ _Trap_Tag#top. > x) |
| 776 | b->topcxx . . $ _Trap_Tag#top. = x; |
| 777 | m = (b->botcxx . . $ _Trap_Tag#bot. + b->topcxx . . $ _Trap_Tag#top.) / 2; |
| 778 | x = m - lag; |
| 779 | if (b->lftcxx . . $ _Trap_Tag#lft. < x) |
| 780 | b->lftcxx . . $ _Trap_Tag#lft. = x; |
| 781 | x = m - lclip; |
| 782 | if (b->rgtcxx . . $ _Trap_Tag#rgt. > x) |
| 783 | b->rgtcxx . . $ _Trap_Tag#rgt. = x; |
| 784 | } |
| 785 | |
| 786 | b = b->nextcxx . . $ _Trap_Tag#next.; |
| 787 | trapcount += 1; |
| 788 | } |
| 789 | lclip = i; |
| 790 | } |
| 791 | lag = i+1; |
| 792 | } |
| 793 | } |
| 794 | |
| 795 | if (i-lag < MAXIGAPcxx . . $ MAXIGAP.) |
| 796 | lag = atop; |
| 797 | |
| 798 | { |
| 799 | int x, m; |
| 800 | x = lclip + b->lftcxx . . $ _Trap_Tag#lft.; |
| 801 | if (b->botcxx . . $ _Trap_Tag#bot. < x) |
| 802 | b->botcxx . . $ _Trap_Tag#bot. = x; |
| 803 | x = lag + b->rgtcxx . . $ _Trap_Tag#rgt.; |
| 804 | if (b->topcxx . . $ _Trap_Tag#top. > x) |
| 805 | b->topcxx . . $ _Trap_Tag#top. = x; |
| 806 | m = (b->botcxx . . $ _Trap_Tag#bot. + b->topcxx . . $ _Trap_Tag#top.) / 2; |
| 807 | x = m - lag; |
| 808 | if (b->lftcxx . . $ _Trap_Tag#lft. < x) |
| 809 | b->lftcxx . . $ _Trap_Tag#lft. = x; |
| 810 | x = m - lclip; |
| 811 | if (b->rgtcxx . . $ _Trap_Tag#rgt. > x) |
| 812 | b->rgtcxx . . $ _Trap_Tag#rgt. = x; |
| 813 | } |
| 814 | |
| 815 | tailend = b; |
| 816 | } |
| 817 | } |
| 818 | |
| 819 | if (tailend != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) { |
| 820 | tailend->nextcxx . . $ _Trap_Tag#next. = free; |
| 821 | free = traplist; |
| 822 | } |
| 823 | |
| 824 | *Traplen = trapcount; |
| 825 | return (traplist); |
| 826 | } |
| 827 | |
| 828 | |
| 829 | /*** FINDING ALIGNMENTS WITHIN A TRAPEZOIDAL ZONE ***/ |
| 830 | |
| 831 | static int TSORTcxx . . $ TSORT(9148c8c3ff42c9d8).(const void *l, const void *r) { |
| 832 | Trapezoidcxx . . $ Trapezoid# *x, *y; |
| 833 | x = *((Trapezoidcxx . . $ Trapezoid# **) l); |
| 834 | y = *((Trapezoidcxx . . $ Trapezoid# **) r); |
| 835 | return (x->botcxx . . $ _Trap_Tag#bot. - y->botcxx . . $ _Trap_Tag#bot.); |
| 836 | } |
| 837 | |
| 838 | static int StSORTcxx . . $ StSORT(9148c8c3ff42c9d8).(const void *l, const void *r) { |
| 839 | Local_Segmentcxx . . $ Local_Segment# *x, *y; |
| 840 | x = (Local_Segmentcxx . . $ Local_Segment# *) l; |
| 841 | y = (Local_Segmentcxx . . $ Local_Segment# *) r; |
| 842 | if (x->abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos. < y->abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos.) |
| 843 | return (-1); |
| 844 | else if (x->abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos. > y->abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos.) |
| 845 | return (1); |
| 846 | else |
| 847 | return (x->bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos. - y->bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.); |
| 848 | } |
| 849 | |
| 850 | static int FnSORTcxx . . $ FnSORT(9148c8c3ff42c9d8).(const void *l, const void *r) { |
| 851 | Local_Segmentcxx . . $ Local_Segment# *x, *y; |
| 852 | x = (Local_Segmentcxx . . $ Local_Segment# *) l; |
| 853 | y = (Local_Segmentcxx . . $ Local_Segment# *) r; |
| 854 | if (x->aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos. < y->aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos.) |
| 855 | return (-1); |
| 856 | else if (x->aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos. > y->aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos.) |
| 857 | return (1); |
| 858 | else |
| 859 | return (x->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos. - y->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.); |
| 860 | } |
| 861 | |
| 862 | static Trapezoidcxx . . $ Trapezoid# **Tarraycxx . . $ Tarray. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 863 | static int *Coveredcxx . . $ Covered.; |
| 864 | static Local_Segmentcxx . . $ Local_Segment# *SegSolscxx . . $ SegSols. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 865 | static int SegMaxcxx . . $ SegMax. = -1; |
| 866 | static int NumSegscxx . . $ NumSegs.; |
| 867 | |
| 868 | static void Align_Recursioncxx . . $ Align_Recursion(ce63f78a9e86e27).(char const * const A, int const Alen, |
| 869 | char const * const B, int const Blen, |
| 870 | Trapezoidcxx . . $ Trapezoid# const * const b, int const current, int const comp, |
| 871 | int const MinLen, double const MaxDiff, int const Traplen) { |
| 872 | int j, mid, indel; |
| 873 | double pcnt; |
| 874 | Local_Segmentcxx . . $ Local_Segment# *hend, *lend; |
| 875 | Trapezoidcxx . . $ Trapezoid# ltrp, htrp; |
| 876 | |
| 877 | mid = (b->botcxx . . $ _Trap_Tag#bot. + b->topcxx . . $ _Trap_Tag#top.) / 2; |
| 878 | |
| 879 | lend = TraceForwardPathcxx . . $ TraceForwardPath(e4f4f112a411e3c).(B,Blen,A,Alen,mid,mid-b->rgtcxx . . $ _Trap_Tag#rgt.,mid-b->lftcxx . . $ _Trap_Tag#lft.); |
| 880 | |
| 881 | { |
| 882 | int x = 0; |
| 883 | |
| 884 | do { |
| 885 | x += 1; |
| 886 | |
| 887 | hend = TraceReversePathcxx . . $ TraceReversePath(a16f0c1660cd2fee).(B,Blen,A,Alen, |
| 888 | lend->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.,lend->aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos.,lend->aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos., |
| 889 | mid+MAXIGAPcxx . . $ MAXIGAP.,BLOCKCOSTcxx . . $ BLOCKCOST.+2*x*diffcostcxx . . $ diffcost.); |
| 890 | } while (hend->bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos. > mid + x*MAXIGAPcxx . . $ MAXIGAP. && hend->scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score. < lend->scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score.); |
| 891 | |
| 892 | hend->aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos. = lend->aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos.; |
| 893 | hend->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos. = lend->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.; |
| 894 | } |
| 895 | |
| 896 | |
| 897 | ltrp =cxx . . $ _Trap_Tag#`operator=`(afe4f613b40eec51). htrp =cxx . . $ _Trap_Tag#`operator=`(afe4f613b40eec51). *b; |
| 898 | ltrp.topcxx . . $ _Trap_Tag#top. = mincxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:40:9`!(b->top,hend->bbpos) - MAXIGAPcxx . . $ MAXIGAP.; |
| 899 | |
| 900 | |
| 901 | htrp.botcxx . . $ _Trap_Tag#bot. = maxcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:41:9`!(b->bot,hend->bepos) + MAXIGAPcxx . . $ MAXIGAP.; |
| 902 | |
| 903 | if (hend->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos. - hend->bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos. >= MinLen && |
| 904 | hend->aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos. - hend->abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos. >= MinLen) { |
| 905 | |
| 906 | indel = abscxx . . $ abs(a1851578aea3f541).( (hend->abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos. - hend->bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.) |
| 907 | - (hend->aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos. - hend->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.) ); |
| 908 | |
| 909 | pcnt = (-hend->scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score.+samecostcxx . . $ samecost.*(hend->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.-hend->bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.))*1./ |
| 910 | (1.*(MATCHCOSTcxx . . $ MATCHCOST.)*(hend->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.-hend->bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.)); |
| 911 | |
| 912 | if (pcnt <= MaxDiff) { |
| 913 | hend->errorcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#error. = pcnt; |
| 914 | |
| 915 | for (j = current+1; j < Traplen; j++) |
| 916 | { Trapezoidcxx . . $ Trapezoid# *t; |
| 917 | int ta, tb, ua, ub; |
| 918 | |
| 919 | t = Tarraycxx . . $ Tarray.[j]; |
| 920 | if (t->botcxx . . $ _Trap_Tag#bot. >= hend->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.) break; |
| 921 | |
| 922 | tb = t->topcxx . . $ _Trap_Tag#top. - t->botcxx . . $ _Trap_Tag#bot. + 1; |
| 923 | ta = t->rgtcxx . . $ _Trap_Tag#rgt. - t->lftcxx . . $ _Trap_Tag#lft. + 1; |
| 924 | if (t->lftcxx . . $ _Trap_Tag#lft. < hend->ldiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#ldiag.) |
| 925 | ua = hend->ldiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#ldiag.; |
| 926 | else |
| 927 | ua = t->lftcxx . . $ _Trap_Tag#lft.; |
| 928 | if (t->rgtcxx . . $ _Trap_Tag#rgt. > hend->hdiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#hdiag.) |
| 929 | ub = hend->hdiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#hdiag.; |
| 930 | else |
| 931 | ub = t->rgtcxx . . $ _Trap_Tag#rgt.; |
| 932 | |
| 933 | if (ua > ub) continue; |
| 934 | |
| 935 | ua = ub - ua + 1; |
| 936 | if (t->topcxx . . $ _Trap_Tag#top. > hend->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.) |
| 937 | ub = hend->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos. - t->botcxx . . $ _Trap_Tag#bot. + 1; |
| 938 | else |
| 939 | ub = tb; |
| 940 | |
| 941 | if (((1.*ua)/ta)*((1.*ub)/tb) > .99) |
| 942 | Coveredcxx . . $ Covered.[j] = 1; |
| 943 | } |
| 944 | |
| 945 | if (NumSegscxx . . $ NumSegs. >= SegMaxcxx . . $ SegMax.) |
| 946 | { SegMaxcxx . . $ SegMax. = (int)(1.2*NumSegscxx . . $ NumSegs.) + 500; |
| 947 | SegSolscxx . . $ SegSols. = (Local_Segmentcxx . . $ Local_Segment# *) realloccxx . . $ realloc(42b2a9dd8f084bf2).(SegSolscxx . . $ SegSols., |
| 948 | sizeof(Local_Segmentcxx . . $ Local_Segment#)*SegMaxcxx . . $ SegMax.); |
| 949 | if (SegSolscxx . . $ SegSols. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 950 | OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).("Segment Alignment array"); |
| 951 | } |
| 952 | |
| 953 | { int d; |
| 954 | |
| 955 | d = hend->hdiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#hdiag.; /* Oops, diags to this point are b-a, not a-b. */ |
| 956 | hend->hdiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#hdiag. = - (hend->ldiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#ldiag.); |
| 957 | hend->ldiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#ldiag. = - d; |
| 958 | if (comp) |
| 959 | { hend->bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos. = Blen - hend->bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.; |
| 960 | hend->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos. = Blen - hend->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.; |
| 961 | hend->ldiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#ldiag. = Blen + hend->ldiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#ldiag.; |
| 962 | hend->hdiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#hdiag. = Blen + hend->hdiagcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#hdiag.; |
| 963 | } |
| 964 | } |
| 965 | |
| 966 | SegSolscxx . . $ SegSols.[NumSegscxx . . $ NumSegs.++] =cxx . . $ $anonymous_type_48ac8bda34bc2e3_0#`operator=`(293f35f642e88d81). *hend; |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | if (ltrp.topcxx . . $ _Trap_Tag#top. - ltrp.botcxx . . $ _Trap_Tag#bot. > MinLen && ltrp.topcxx . . $ _Trap_Tag#top. < b->topcxx . . $ _Trap_Tag#top. - MAXIGAPcxx . . $ MAXIGAP.) |
| 971 | Align_Recursioncxx . . $ Align_Recursion(ce63f78a9e86e27).(A,Alen,B,Blen,<rp,current,comp,MinLen,MaxDiff,Traplen); |
| 972 | |
| 973 | if (htrp.topcxx . . $ _Trap_Tag#top. - htrp.botcxx . . $ _Trap_Tag#bot. > MinLen) |
| 974 | Align_Recursioncxx . . $ Align_Recursion(ce63f78a9e86e27).(A,Alen,B,Blen,&htrp,current,comp,MinLen,MaxDiff,Traplen); |
| 975 | } |
| 976 | |
| 977 | |
| 978 | |
| 979 | static Local_Segmentcxx . . $ Local_Segment# *Align_Trapezoidscxx . . $ Align_Trapezoids(636c0a4c0da4150c).(char const * const A, int const Alen, |
| 980 | char const * const B, int const Blen, |
| 981 | Trapezoidcxx . . $ Trapezoid# const * const Traplist, int const Traplen, |
| 982 | int const start, int const comp, |
| 983 | int const MinLen, double const MaxDiff, int * const Seglen) { |
| 984 | static int fseg; |
| 985 | static int TarMax = -1; |
| 986 | |
| 987 | if (Traplen >= TarMax) { |
| 988 | TarMax = (int)(1.2*Traplen) + 500; |
| 989 | Tarraycxx . . $ Tarray. = (Trapezoidcxx . . $ Trapezoid# **) |
| 990 | realloccxx . . $ realloc(42b2a9dd8f084bf2).(Tarraycxx . . $ Tarray.,(sizeof(Trapezoidcxx . . $ Trapezoid# *) + sizeof(int))*TarMax); |
| 991 | if (Tarraycxx . . $ Tarray. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 992 | OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).("Trapezoid array"); |
| 993 | Coveredcxx . . $ Covered. = (int *) (Tarraycxx . . $ Tarray. + TarMax); |
| 994 | } |
| 995 | if (SegMaxcxx . . $ SegMax. < 0) { |
| 996 | SegMaxcxx . . $ SegMax. = 1000; |
| 997 | SegSolscxx . . $ SegSols. = (Local_Segmentcxx . . $ Local_Segment# *) malloccxx . . $ malloc(9f008b2a9698428b).(sizeof(Local_Segmentcxx . . $ Local_Segment#)*SegMaxcxx . . $ SegMax.); |
| 998 | if (SegSolscxx . . $ SegSols. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 999 | OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).("Segment Alignment array"); |
| 1000 | } |
| 1001 | |
| 1002 | { |
| 1003 | Trapezoidcxx . . $ Trapezoid# * b = (Trapezoidcxx . . $ Trapezoid# *)Traplist; |
| 1004 | int i; |
| 1005 | for (i = 0; i < Traplen; i++) { |
| 1006 | Tarraycxx . . $ Tarray.[i] = b; |
| 1007 | Coveredcxx . . $ Covered.[i] = 0; |
| 1008 | b = b->nextcxx . . $ _Trap_Tag#next.; |
| 1009 | } |
| 1010 | } |
| 1011 | |
| 1012 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(Tarraycxx . . $ Tarray.,Traplen,sizeof(Trapezoidcxx . . $ Trapezoid# *),TSORTcxx . . $ TSORT(9148c8c3ff42c9d8).); |
| 1013 | |
| 1014 | if (start) |
| 1015 | NumSegscxx . . $ NumSegs. = 0; |
| 1016 | fseg = NumSegscxx . . $ NumSegs.; |
| 1017 | { |
| 1018 | int i; |
| 1019 | for (i = 0; i < Traplen; i++) |
| 1020 | if (! Coveredcxx . . $ Covered.[i]) { |
| 1021 | Trapezoidcxx . . $ Trapezoid# * b = Tarraycxx . . $ Tarray.[i]; |
| 1022 | if (b->topcxx . . $ _Trap_Tag#top. - b->botcxx . . $ _Trap_Tag#bot. < KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!) continue; |
| 1023 | //printf("Trying hit %d\n",i); |
| 1024 | Align_Recursioncxx . . $ Align_Recursion(ce63f78a9e86e27).(A,Alen,B,Blen,b,i,comp,MinLen,MaxDiff,Traplen); |
| 1025 | } |
| 1026 | } |
| 1027 | |
| 1028 | if (NumSegscxx . . $ NumSegs. > fseg) { |
| 1029 | int i; |
| 1030 | int j=0; |
| 1031 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(SegSolscxx . . $ SegSols.+fseg,NumSegscxx . . $ NumSegs.-fseg,sizeof(Local_Segmentcxx . . $ Local_Segment#),StSORTcxx . . $ StSORT(9148c8c3ff42c9d8).); |
| 1032 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(j==0); |
| 1033 | for (i = fseg; i < NumSegscxx . . $ NumSegs.; i = j) { |
| 1034 | for (j = i+1; j < NumSegscxx . . $ NumSegs.; j++) { |
| 1035 | |
| 1036 | if (SegSolscxx . . $ SegSols.[j].abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos. != SegSolscxx . . $ SegSols.[i].abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos.) break; |
| 1037 | if (SegSolscxx . . $ SegSols.[j].bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos. != SegSolscxx . . $ SegSols.[i].bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.) break; |
| 1038 | if (/* segments in opposite orientations */ |
| 1039 | ((SegSolscxx . . $ SegSols.[j].beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.-SegSolscxx . . $ SegSols.[j].bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.) > 0 && |
| 1040 | (SegSolscxx . . $ SegSols.[i].beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.-SegSolscxx . . $ SegSols.[i].bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.) < 0 ) |
| 1041 | || |
| 1042 | ((SegSolscxx . . $ SegSols.[j].beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.-SegSolscxx . . $ SegSols.[j].bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.) < 0 && |
| 1043 | (SegSolscxx . . $ SegSols.[i].beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.-SegSolscxx . . $ SegSols.[i].bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.) > 0 ) )break; |
| 1044 | |
| 1045 | if (SegSolscxx . . $ SegSols.[j].errorcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#error. <= MaxDiff && |
| 1046 | SegSolscxx . . $ SegSols.[i].errorcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#error. <= MaxDiff){ |
| 1047 | |
| 1048 | if (abscxx . . $ abs(a1851578aea3f541).(SegSolscxx . . $ SegSols.[i].beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.-SegSolscxx . . $ SegSols.[i].bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.)+abscxx . . $ abs(a1851578aea3f541).(SegSolscxx . . $ SegSols.[i].aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos.-SegSolscxx . . $ SegSols.[i].abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos.) < |
| 1049 | abscxx . . $ abs(a1851578aea3f541).(SegSolscxx . . $ SegSols.[j].beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.-SegSolscxx . . $ SegSols.[j].bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.)+abscxx . . $ abs(a1851578aea3f541).(SegSolscxx . . $ SegSols.[j].aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos.-SegSolscxx . . $ SegSols.[j].abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos.)) { |
| 1050 | SegSolscxx . . $ SegSols.[i].scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score.=-1;i=j; |
| 1051 | } else { |
| 1052 | SegSolscxx . . $ SegSols.[j].scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score.=-1; |
| 1053 | } |
| 1054 | } else { |
| 1055 | if(SegSolscxx . . $ SegSols.[j].errorcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#error.<=MaxDiff){ |
| 1056 | SegSolscxx . . $ SegSols.[i].scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score.=-1; |
| 1057 | i=j; |
| 1058 | } else { |
| 1059 | SegSolscxx . . $ SegSols.[j].scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score.=-1; |
| 1060 | } |
| 1061 | } |
| 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(SegSolscxx . . $ SegSols.+fseg,NumSegscxx . . $ NumSegs.-fseg,sizeof(Local_Segmentcxx . . $ Local_Segment#),FnSORTcxx . . $ FnSORT(9148c8c3ff42c9d8).); |
| 1066 | for ( i = fseg; i < NumSegscxx . . $ NumSegs.; i = j) { |
| 1067 | for (j = i+1; j < NumSegscxx . . $ NumSegs.; j++) { |
| 1068 | if (SegSolscxx . . $ SegSols.[j].abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos. != SegSolscxx . . $ SegSols.[i].abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos.) break; |
| 1069 | if (SegSolscxx . . $ SegSols.[j].bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos. != SegSolscxx . . $ SegSols.[i].bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.) break; |
| 1070 | if (SegSolscxx . . $ SegSols.[j].scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score. > SegSolscxx . . $ SegSols.[i].scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score.) { |
| 1071 | SegSolscxx . . $ SegSols.[i].scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score. = -1; |
| 1072 | i = j; |
| 1073 | } else |
| 1074 | SegSolscxx . . $ SegSols.[j].scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score. = -1; |
| 1075 | } |
| 1076 | } |
| 1077 | |
| 1078 | for (i = fseg; i < NumSegscxx . . $ NumSegs.; i++) |
| 1079 | if (SegSolscxx . . $ SegSols.[i].scorecxx . . $ $anonymous_type_48ac8bda34bc2e3_0#score. >= 0) |
| 1080 | SegSolscxx . . $ SegSols.[fseg++] =cxx . . $ $anonymous_type_48ac8bda34bc2e3_0#`operator=`(293f35f642e88d81). SegSolscxx . . $ SegSols.[i]; |
| 1081 | NumSegscxx . . $ NumSegs. = fseg; |
| 1082 | } |
| 1083 | |
| 1084 | *Seglen = NumSegscxx . . $ NumSegs.; |
| 1085 | return (SegSolscxx . . $ SegSols.); |
| 1086 | } |
| 1087 | |
| 1088 | |
| 1089 | |
| 1090 | |
| 1091 | |
| 1092 | |
| 1093 | |
| 1094 | |
| 1095 | |
| 1096 | |
| 1097 | |
| 1098 | |
| 1099 | /*** MASTER ROUTINE ***/ |
| 1100 | |
| 1101 | Local_Segmentcxx . . $ Local_Segment# *Find_Local_Segmentscxx . . $ Find_Local_Segments(37817bc7f7be279f).(char const * const A, int const Alen, |
| 1102 | char const * const B, int const Blen, |
| 1103 | int const Action, |
| 1104 | int const MinLen, double const MaxDiff, int * const Seglen) { |
| 1105 | static int DagMax = -1; |
| 1106 | static int BseqLen = -1; |
| 1107 | |
| 1108 | int numhit = 0; |
| 1109 | HitRecordcxx . . $ HitRecord# *hits = 0L; |
| 1110 | int numtrap = 0; |
| 1111 | Trapezoidcxx . . $ Trapezoid# *traps = 0L; |
| 1112 | int numseg = 0; |
| 1113 | Local_Segmentcxx . . $ Local_Segment# *segs = 0L; |
| 1114 | |
| 1115 | |
| 1116 | // Defining this causes scoring to be set so that nearly all |
| 1117 | // extensions terminate within the user-defined error rate; this |
| 1118 | // means we don't completely miss a high-quality segment that is |
| 1119 | // part of a larger segment of lower quality--e.g., we could find |
| 1120 | // more-conserved portions of a repeat even if the repeat as a |
| 1121 | // whole was lower fidelity, due to varying selectional pressure at |
| 1122 | // different positions; the down-side to this is that we won't |
| 1123 | // chain together perfect matches across a few bases of |
| 1124 | // lower-fidelity sequence. Leaving it undefined uses the #define |
| 1125 | // values of DIFFCOST and SAMECOST |
| 1126 | // |
| 1127 | samecostcxx . . $ samecost. = (int)ceilcxx . . $ ceil(fee4f1d22bc8e617).(100.0 * MaxDiff); |
| 1128 | diffcostcxx . . $ diffcost. = 100 - samecostcxx . . $ samecost.; |
| 1129 | MATCHCOSTcxx . . $ MATCHCOST. = samecostcxx . . $ samecost. + diffcostcxx . . $ diffcost.; |
| 1130 | BLOCKCOSTcxx . . $ BLOCKCOST. = diffcostcxx . . $ diffcost. * MAXIGAPcxx . . $ MAXIGAP.; |
| 1131 | |
| 1132 | if (Action != LOCAL_FORWcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.H:86:9`!) { |
| 1133 | if(BseqLen<Blen){ |
| 1134 | BrevCcxx . . $ BrevC. = (char*) realloccxx . . $ realloc(42b2a9dd8f084bf2).(BrevCcxx . . $ BrevC.,sizeof(char)*(Blen+1)); |
| 1135 | BseqLen=Blen; |
| 1136 | if(BrevCcxx . . $ BrevC.==NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!){OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).("B sequence reverse complement");} |
| 1137 | } |
| 1138 | strcpy(BrevCcxx . . $ BrevC.,B); |
| 1139 | Complementcxx . . $ Complement(a07d8cccb7673f5a).(BrevCcxx . . $ BrevC.,Blen); |
| 1140 | } |
| 1141 | |
| 1142 | if (Alen >= DagMax || Blen >= DagMax) { |
| 1143 | if (Kmaskcxx . . $ Kmask. < 0) { |
| 1144 | int i; |
| 1145 | for (i = 0; i < 128; i++) |
| 1146 | Mapcxx . . $ Map.[i] = -1; |
| 1147 | Mapcxx . . $ Map.[(int)'a'] = Mapcxx . . $ Map.[(int)'A'] = 0; |
| 1148 | Mapcxx . . $ Map.[(int)'c'] = Mapcxx . . $ Map.[(int)'C'] = 1; |
| 1149 | Mapcxx . . $ Map.[(int)'g'] = Mapcxx . . $ Map.[(int)'G'] = 2; |
| 1150 | Mapcxx . . $ Map.[(int)'t'] = Mapcxx . . $ Map.[(int)'T'] = 3; |
| 1151 | Kmaskcxx . . $ Kmask. = (1 << (2*KMERLENcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:33:9`!)) - 1; |
| 1152 | Tablecxx . . $ Table. = (int *)malloccxx . . $ malloc(9f008b2a9698428b).(sizeof(int)*(Kmaskcxx . . $ Kmask.+2)); |
| 1153 | if (Tablecxx . . $ Table. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 1154 | OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).("K-mer index"); |
| 1155 | } |
| 1156 | if (Alen > Blen) |
| 1157 | DagMax = (int)(1.2*Alen) + 5000; |
| 1158 | else |
| 1159 | DagMax = (int)(1.2*Blen) + 5000; |
| 1160 | DagMax += sizeof(DiagRecordcxx . . $ DiagRecord#) - (DagMax % sizeof(DiagRecordcxx . . $ DiagRecord#)); |
| 1161 | Tuplescxx . . $ Tuples. = (int *)realloccxx . . $ realloc(42b2a9dd8f084bf2).(Tuplescxx . . $ Tuples.,sizeof(int)*DagMax + |
| 1162 | sizeof(DiagRecordcxx . . $ DiagRecord#)*(2*DagMax+MAXERRORcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.C:35:9`!+1)); |
| 1163 | if (Tuplescxx . . $ Tuples. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 1164 | OutOfMemorycxx . . $ OutOfMemory(85c52e162fed56f9).("K-mer index"); |
| 1165 | DiagVeccxx . . $ DiagVec. = ((DiagRecordcxx . . $ DiagRecord# *) (Tuplescxx . . $ Tuples. + DagMax)) + (DagMax+1); |
| 1166 | } |
| 1167 | |
| 1168 | TableBuildcxx . . $ TableBuild(34d26762b42c433a).(A,Alen); |
| 1169 | |
| 1170 | int start = 1; |
| 1171 | |
| 1172 | if (Action != LOCAL_REVRcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.H:87:9`!) { |
| 1173 | hits = Find_Hitscxx . . $ Find_Hits(31e353e558cd1ecb).(A,Alen,B,Blen,&numhit); |
| 1174 | traps = Build_Trapezoidscxx . . $ Build_Trapezoids(fa5870b410bd1ac8).(A,Alen,B,Blen,hits,numhit,&numtrap); |
| 1175 | segs = Align_Trapezoidscxx . . $ Align_Trapezoids(636c0a4c0da4150c).(A,Alen,B,Blen,traps,numtrap, |
| 1176 | start,0,MinLen,MaxDiff,&numseg); |
| 1177 | start = 0; |
| 1178 | } |
| 1179 | |
| 1180 | if (Action != LOCAL_FORWcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.H:86:9`!) { |
| 1181 | hits = Find_Hitscxx . . $ Find_Hits(31e353e558cd1ecb).(A,Alen,BrevCcxx . . $ BrevC.,Blen,&numhit); |
| 1182 | traps = Build_Trapezoidscxx . . $ Build_Trapezoids(fa5870b410bd1ac8).(A,Alen,BrevCcxx . . $ BrevC.,Blen,hits,numhit,&numtrap); |
| 1183 | segs = Align_Trapezoidscxx . . $ Align_Trapezoids(636c0a4c0da4150c).(A,Alen,BrevCcxx . . $ BrevC.,Blen,traps,numtrap, |
| 1184 | start,1,MinLen,MaxDiff,&numseg); |
| 1185 | } |
| 1186 | |
| 1187 | *Seglen = numseg; |
| 1188 | return (segs); |
| 1189 | } |