1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 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 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
#include <stdio.h>
#include <stdlib.h>
#include "align.h"
/* Turn vector into single (most likely) nucleotide */
char consen_6(FastInt B[6]) {
FastInt a = B[0], b = 0;
if (B[1] > a)
a = B[1], b = 1;
if (B[2] > a)
a = B[2], b = 2;
if (B[3] > a)
a = B[3], b = 3;
if (B[4] > a)
a = B[4], b = 4;
if (B[5] > a)
a = B[5], b = 5;
return a == 0 ? '-' : "ACGT*-"[b];
}
void expand(char *A, char *B, int M, int N,
char *A2, char *B2, int *AL, int *BL, FastInt *S, int keep_pads)
{
register int i, j, op;
char *a = A2, *b = B2;
A--; B--;
i = j = op = 0;
/* fpad= abs(S[0]);
for(i=0; i<M; i++){
if (S[i] !=0 )
lpad = i;
}
i=0;*/
while (i < M || j < N)
{
if (op == 0 && *S == 0)
{
op = *S++;
*a++ = A[++i];
*b++ = B[++j];
} else {
if (op == 0)
op = *S++;
if (op > 0)
{
*a++ = '.';
*b++ = B[++j];
op--;
} else {
*a++ = A[++i];
*b++ = '.';
op++;
}
}
}
/* Strip back expanded sequences to first non pad character */
if (!keep_pads) {
while (*--a == '.');
while (*--b == '.');
} else {
--a;
--b;
}
/* & NULL terminate */
*++a = 0;
*++b = 0;
*AL = (int)(a - A2);
*BL = (int)(b - B2);
}
void expand_6(char *A, FastInt (*B)[6], int M, int N,
char *A2, FastInt (*B2)[6], int *AL, int *BL, FastInt *S,
int keep_pads)
{
register int i, j, k, op;
char *a = A2;
FastInt (*b)[6] = B2;
extern char base_val[128];
A--; B--;
i = j = op = 0;
while (i < M || j < N)
{
if (op == 0 && *S == 0)
{
op = *S++;
*a++ = A[++i];
for (k=0; k<6; k++) {
(*b)[k] = B[j][k];
}
b++;j++;
} else {
if (op == 0)
op = *S++;
if (op > 0)
{
*a++ = ' ';
for (k=0; k<6; k++) {
(*b)[k] = B[j][k];
}
b++;j++;
op--;
} else {
*a++ = A[++i];
for (k=0; k<6; k++) {
(*b)[k] = base_val['*'];
}
b++;j++;
op++;
}
}
}
/* Strip back expanded sequences to first non pad character */
if (!keep_pads) {
while (*--a == '*');
while ((*b)[0] == base_val['*']) b--;
} else {
--a;
--b;
}
*AL = (int)(a - A2);
*BL = (int)(b - B2);
}
|