add: original GDE support

This commit is contained in:
kuoi 2023-04-12 03:34:30 +08:00
parent b307d12174
commit d58cb7c457
11 changed files with 4665 additions and 0 deletions

2223
SUPPORT/CAP2.c Normal file

File diff suppressed because it is too large Load diff

149
SUPPORT/Flatio.c Normal file
View file

@ -0,0 +1,149 @@
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TRUE 1
#define FALSE 0
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
struct data_format {
int length;
char *nuc;
int offset;
char name[64];
char type;
};
char *Realloc(char *block, int size);
char *Calloc(int count, int size);
int ErrorOut(int code, char *string);
int Errorout(char *string);
int ReadFlat(FILE *file, struct data_format align[], int maxseqs);
int WriteData(FILE *file, struct data_format data[], int count);
int ReadFlat(FILE *file, struct data_format align[], int maxseqs)
{
int j, len = 0, count = -1, offset;
unsigned maxlen = 1024;
char cinline[1025];
extern char *Calloc(), *Realloc();
if (file == NULL) Errorout("Cannot open data file");
for (; fgets(cinline, 1024, file) != NULL;) {
cinline[strlen(cinline) - 1] = '\0';
switch (cinline[0]) {
case '>':
case '#':
case '%':
case '"':
case '@':
offset = 0;
for (j = 0; j < strlen(cinline); j++) {
if (cinline[j] == '(') {
sscanf(
(char *)(cinline + j + 1),
"%d", &offset);
cinline[j] = '\0';
}
}
if (count != -1) {
align[count].length = len;
align[count].nuc[len] = '\0';
maxlen = len;
}
count++;
if (count > maxseqs)
Errorout(
"Sorry, alignment is too large");
align[count].nuc = Calloc(maxlen, sizeof(char));
align[count].type = cinline[0];
align[count].offset = offset;
if (align[count].nuc == NULL)
Errorout("Calloc problem");
sscanf((char *)(cinline + 1), "%s",
align[count].name);
len = 0;
break;
default:
if (len + strlen(cinline) > maxlen) {
maxlen = (maxlen + strlen(cinline)) * 2;
align[count].nuc =
Realloc(align[count].nuc, maxlen);
}
for (j = 0; j < strlen(cinline); j++)
align[count].nuc[j + len] = cinline[j];
len += strlen(cinline);
break;
}
}
if (count == -1) exit(1);
align[count].length = len;
align[count].nuc[len] = '\0';
return (++count);
}
int Errorout(char *string)
{
fprintf(stderr, "%s\n", string);
exit(1);
}
int WriteData(FILE *file, struct data_format data[], int count)
{
int i, j;
for (j = 0; j < count; j++) {
if (data[j].offset)
fprintf(file, "\n%c%s(%d)", data[j].type, data[j].name,
data[j].offset);
else
fprintf(file, "\n%c%s", data[j].type, data[j].name);
for (i = 0; i < data[j].length; i++) {
if (i % 60 == 0) fputc('\n', file);
fputc(data[j].nuc[i], file);
}
}
return 0;
}
int ErrorOut(int code, char *string)
{
if (code == 0) {
fprintf(stderr, "Error:%s\n", string);
exit(1);
}
return 0;
}
char *Calloc(int count, int size)
{
char *temp;
temp = (char *)calloc(count, size);
if (temp == NULL) {
fprintf(stdout, "Error in Calloc\n");
exit(-1);
}
else
return (temp);
}
char *Realloc(char *block, int size)
{
char *temp;
temp = (char *)realloc(block, size);
if (temp == NULL) {
fprintf(stdout, "Error in Calloc\n");
exit(-1);
}
else
return (temp);
}

21
SUPPORT/Makefile Normal file
View file

@ -0,0 +1,21 @@
CC = cc
FLAGS = -lm
all:CAP2 Restriction count findall varpos lsadt sho_helix Zuk_to_gen
CAP2: CAP2.c
$(CC) CAP2.c -O -o CAP2
Restriction: Restriction.c
$(CC) Restriction.c -O -o Restriction
Zuk_to_gen: Zuk_to_gen.c
$(CC) Zuk_to_gen.c -O -o Zuk_to_gen
count: count.c
$(CC) count.c -O -o count $(FLAGS)
findall: findall.c
$(CC) findall.c -O -o findall
lsadt: lsadt.c
$(CC) lsadt.c -O -o lsadt $(FLAGS)
sho_helix: sho_helix.c
$(CC) sho_helix.c -O -o sho_helix
varpos: varpos.c
$(CC) varpos.c -O -o varpos

70
SUPPORT/PrintContig.c Normal file
View file

@ -0,0 +1,70 @@
#include "Flatio.c"
#define WIDTH 50
main()
{
struct data_format data[10000];
int i,j,k,numseqs,maxlen = 0,minlen=999999999;
int lines_printed;
int len[1000];
char a,b;
numseqs = ReadFlat(stdin,data,10000);
if(numseqs == 0)
exit(1);
for(k=0;k<numseqs;k++)
{
minlen = MIN(minlen,data[k].offset);
maxlen = MAX(maxlen,data[j].length+data[k].offset);
}
for(j=minlen;j<maxlen;j+=WIDTH)
{
lines_printed = FALSE;
for (i=0;i<numseqs;i++)
{
data[i].name[19] = '\0';
if(((data[i].offset > j+WIDTH) ||
(data[i].offset+data[i].length<j)));
else
{
lines_printed = TRUE;
printf("\n%20s%5d ", data[i].name,
indx(j,&(data[i])));
for(k=j;k<j+WIDTH;k++)
{
if((k<data[i].length+data[i].offset)
&& (k>=data[i].offset))
putchar(data[i].nuc[k-data[i].offset]);
else putchar(' ');
}
}
}
if(lines_printed)
{
printf("\n |---------|---------|---------|---------|---------\n");
printf(" %6d %6d %6d %6d %6d\n\n",j+1,j+11,j+21,j+31,j+41);
}
}
putchar('\n');
exit(0);
}
int indx(pos,seq)
int pos;
struct data_format *seq;
{
int j,count=0;
if(pos < seq->offset)
return (0);
if(pos>seq->offset+seq->length)
pos = seq->offset+seq->length;
pos -= seq->offset;
for(j=0;j<pos;j++)
if(seq->nuc[j] != '-')
if(seq->nuc[j] != '~')
count++;
return (count);
}

130
SUPPORT/Restriction.c Normal file
View file

@ -0,0 +1,130 @@
/*
* Copyright 1991 Steven Smith at the Harvard Genome Lab.
* All rights reserved.
*/
#include "Flatio.c"
main(ac,av)
int ac;
char **av;
{
struct data_format data[10000];
FILE *file;
int i,j,k,color,numseqs,numenzymes,nextpos,len;
char enzymes[80][80],dummy[80];
if(ac<3)
{
fprintf(stderr,"Usage: %s enzyme_file seq_file\n",av[0]);
exit(-1);
}
file = fopen(av[2],"r");
if(file == NULL)
exit(-1);
numseqs = ReadFlat(file,data,10000);
file = fopen(av[1],"r");
if(file == NULL)
exit(-1);
for(numenzymes = 0;
fscanf(file,"%s %s",enzymes[numenzymes],dummy)>0;
numenzymes++);
for(i=0;i<numseqs;i++)
{
/*
if(numseqs>1)
*/
printf("name:%s\n",data[i].name);
printf("length:%d\n",strlen(data[i].nuc));
if(numseqs>1)
printf("nodash:\n");
printf("start:\n");
for(j=0;j<data[i].length;)
{
for(;data[i].nuc[j] == '-' && j<data[i].length;)
{
printf("8\n");
j++;
}
if((nextpos = FindNext(data[i].nuc,j,enzymes,numenzymes
,&len,&color)) != -1)
{
for(k=j;k<nextpos;k++)
printf("8\n");
for(k=j+nextpos;k<j+nextpos+len;k++)
printf("%d\n",color);
j=nextpos+len;
}
else
for(;j<data[i].length;j++)
printf("8\n");
}
}
exit(0);
}
FindNext(target,offset,enzymes,numenzymes,match_len,color)
char *target,enzymes[][80];
int numenzymes,*match_len,*color;
{
int i,j,k,closest,len1,dif,flag = FALSE;
closest = strlen(target);
*match_len = 0;
for(k=0;k<numenzymes;k++)
{
dif = (strlen(target)) - (len1 = strlen(enzymes[k])) +1;
if(len1>0)
for(flag = FALSE,j=offset;j<dif && flag == FALSE;j++)
{
flag = TRUE;
for(i=0;i<len1 && flag;i++)
{
flag = Comp(enzymes[k][i],target[i+j])?
TRUE:FALSE;
}
}
if(j-1<closest)
{
closest = j-1;
*color = k%6+1;
*match_len = strlen(enzymes[k]);
}
}
if(closest + *match_len < strlen(target))
return(closest);
else
return(-1);
}
Comp(a,b)
char a,b;
{
static int CtoB[128]={
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,0,0,0x00,
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,0,0,0,0,
0x01,0xe,0x02,0x0d,0,0,0x04,0x0b,0,0,0x0c,0,0x03,0x0f,0,0,0,0x05,0x06,
0x08,0x08,0x07,0,0x09,0xa,0,0,0,0,0,0,0,0x01,0x0e,0x02,0x0d,0,0,0x04,
0x0b,0,0,0x0c,0,0x03,0x0f,0,0,0,0x05,0x06,0x08,0x08,0x07,0,0x09,0x0a,
0,0,0,0,0x00,0
};
static int BtoC[128] =
{
'-','A','C','M','G','R','S','V','T','W','Y','H','K','D','B','N',
'~','a','c','m','g','r','s','v','t','w','y','h','k','d','b','n',
'-','A','C','M','G','R','S','V','T','W','Y','H','K','D','B','N',
'~','a','c','m','g','r','s','v','t','w','y','h','k','d','b','n',
'-','A','C','M','G','R','S','V','T','W','Y','H','K','D','B','N',
'~','a','c','m','g','r','s','v','t','w','y','h','k','d','b','n',
'-','A','C','M','G','R','S','V','T','W','Y','H','K','D','B','N',
'~','a','c','m','g','r','s','v','t','w','y','h','k','d','b','n',
};
return ((CtoB[a]) & (CtoB[b]));
}

88
SUPPORT/Zuk_to_gen.c Executable file
View file

@ -0,0 +1,88 @@
#include <stdio.h>
#include <string.h>
typedef struct Sequence {
int len;
char name[80];
char type[8];
char *nuc;
} Sequence;
main()
{
char a[5000], b[5000], cinline[132];
int pos1, pos2, pos3, i, j, k, FLAG;
Sequence pair[2];
for (j = 0; j < 5000; j++) b[j] = '-';
FLAG = (int)gets(cinline);
for (j = 0; FLAG; j++) {
FLAG = (int)gets(cinline);
sscanf(cinline, "%d", &pos1);
if ((sscanf(cinline, "%*6c %c %d %d %d", &(a[j]), &k, &pos2,
&pos3) == 4) &&
(FLAG)) {
if (pos3 != 0) {
if (pos1 < pos3) {
b[pos1 - 1] = '[';
b[pos3 - 1] = ']';
}
else {
b[pos3 - 1] = '[';
b[pos1 - 1] = ']';
}
}
}
else {
pair[0].len = j;
strcpy(pair[0].name, "HELIX");
strcpy(pair[0].type, "TEXT");
pair[1].len = j;
/*
sscanf(cinline,"%*24c
%s",pair[1].name);
*/
strcpy(pair[1].name, "Sequence");
strcpy(pair[1].type, "RNA");
pair[0].nuc = b;
pair[1].nuc = a;
WriteGen(pair, stdout, 2);
for (j = 0; j < 5000; j++) b[j] = '-';
j = -1;
}
}
exit(0);
}
WriteGen(seq, file, numseq) Sequence *seq;
FILE *file;
int numseq;
{
register i, j;
char temp[14];
for (j = 0; j < numseq; j++) fprintf(file, "%-.12s\n", seq[j].name);
fprintf(file, "ZZZZZZZZZZ\n");
for (j = 0; j < numseq; j++) {
strcpy(temp, seq[j].name);
for (i = strlen(temp); i < 13; i++) temp[i] = ' ';
temp[i] = '\0';
fprintf(file, "LOCUS %-.12s %s %d BP\n", temp,
seq[j].type, seq[j].len);
fprintf(file, "ORIGIN");
for (i = 0; i < seq[j].len; i++) {
if (i % 60 == 0) fprintf(file, "\n%9d", i + 1);
if (i % 10 == 0) fprintf(file, " ");
fprintf(file, "%c", seq[j].nuc[i]);
}
fprintf(file, "\n//\n");
}
return;
}

393
SUPPORT/count.c Normal file
View file

@ -0,0 +1,393 @@
/*
* Copyright 1991 Steven Smith at the Harvard Genome Lab.
* All rights reserved.
*/
#include <math.h>
#include "Flatio.c"
#define FALSE 0
#define TRUE 1
#define JUKES 0
#define OLSEN 1
#define NONE 2
#define Min(a, b) (a) < (b) ? (a) : (b)
int width, start, jump, usecase, sim, correction;
int tbl, numseq, num, denom, special;
char argtyp[255], argval[255];
float acwt = 1.0, agwt = 1.0, auwt = 1.0, ucwt = 1.0, ugwt = 1.0, gcwt = 1.0;
float dist[200][200];
struct data_format data[10000];
float parta[200], partc[200], partg[200], partu[200], setdist();
main(ac, av) int ac;
char **av;
{
int i, j, k;
extern int ReadFlat();
FILE *file;
width = 1;
jump = 1;
if (ac == 1) {
fprintf(stderr,
"usage: %s [-sim] [-case] [-c=<none,olsen,jukes>] ",
av[0]);
fprintf(stderr, "[-t] alignment_flat_file\n");
exit(1);
}
for (j = 1; j < ac - 1; j++) {
getarg(av, j, argtyp, argval);
if (strcmp(argtyp, "-s=") == 0) {
j++;
sscanf(argval, "%d", &start);
start--;
}
else if (strcmp(argtyp, "-m=") == 0) {
j++;
sscanf(argval, "%d", &width);
}
else if (strcmp(argtyp, "-j=") == 0) {
j++;
sscanf(argval, "%d", &jump);
}
else if (strcmp(argtyp, "-case") == 0)
usecase = TRUE;
else if (strcmp(argtyp, "-sim") == 0)
sim = TRUE;
else if (strcmp(argtyp, "-c=") == 0) {
if (strcmp(argval, "olsen") == 0)
correction = OLSEN;
else if (strcmp(argval, "none") == 0)
correction = NONE;
else if (strcmp(argval, "jukes") == 0)
correction = JUKES;
else
fprintf(stderr, "Correction type %s %s\n",
argval, "unknown, using JUKES");
}
else if (strcmp("-t", argtyp) == 0)
tbl = TRUE;
else if (strcmp("-ac=", argtyp) == 0 ||
strcmp("-ca=", argtyp) == 0) {
j++;
sscanf(argval, "%f", &acwt);
special = TRUE;
}
else if (strcmp("-au=", argtyp) == 0 ||
strcmp("-ua=", argtyp) == 0) {
j++;
sscanf(argval, "%f", &auwt);
special = TRUE;
}
else if (strcmp("-ag=", argtyp) == 0 ||
strcmp("-ga=", argtyp) == 0) {
j++;
sscanf(argval, "%f", &agwt);
special = TRUE;
}
else if (strcmp("-uc=", argtyp) == 0 ||
strcmp("-cu=", argtyp) == 0) {
j++;
sscanf(argval, "%f", &ucwt);
special = TRUE;
}
else if (strcmp("-ug=", argtyp) == 0 ||
strcmp("-gu=", argtyp) == 0) {
j++;
sscanf(argval, "%f", &ugwt);
special = TRUE;
}
else if (strcmp("-gc=", argtyp) == 0 ||
strcmp("-cg=", argtyp) == 0) {
j++;
sscanf(argval, "%f", &gcwt);
special = TRUE;
}
else if (strcmp("-transition=", argtyp) == 0) {
j++;
sscanf(argval, "%f", &ucwt);
agwt = ucwt;
special = TRUE;
}
else if (strcmp("-transversion=", argtyp) == 0) {
j++;
sscanf(argval, "%f", &gcwt);
ugwt = gcwt;
acwt = gcwt;
auwt = gcwt;
special = TRUE;
}
}
file = fopen(av[ac - 1], "r");
if ((file == NULL) || (ac == 1)) {
fprintf(stderr, "Error opening input file %s\n", av[ac - 1]);
exit(1);
}
numseq = ReadFlat(file, data, 10000);
fclose(file);
SetPart();
for (j = 0; j < numseq - 1; j++)
for (k = j + 1; k < numseq; k++) {
Compare(j, k, &num, &denom);
dist[j][k] = setdist(num, denom, j, k);
}
Report();
exit(0);
}
Compare(a, b, num, denom) int a, b, *num, *denom;
{
int mn, i, j, casefix, match, blank;
float fnum = 0.0;
struct data_format *da, *db;
char ac, bc;
casefix = (usecase) ? 0 : 32;
*num = 0;
*denom = 0;
da = &data[a];
db = &data[b];
mn = Min(da->length, db->length);
for (j = 0; j < mn; j += jump) {
match = TRUE;
blank = TRUE;
for (i = 0; i < width; i++) {
ac = da->nuc[j + i] | casefix;
bc = db->nuc[j + i] | casefix;
if (ac == 't') ac = 'u';
if (ac == 'T') ac = 'U';
if (bc == 't') bc = 'u';
if (bc == 'T') bc = 'U';
if ((ac == '-') || (ac | 32) == 'n' || (ac == ' ') ||
(bc == '-') || (bc | 32) == 'n' || (bc == ' '))
;
else {
blank = FALSE;
if (ac != bc) {
match = FALSE;
switch (ac) {
case 'a':
if (bc == 'c')
fnum += acwt;
else if (bc == 'g')
fnum += agwt;
else if (bc == 'u')
fnum += auwt;
break;
case 'c':
if (bc == 'a')
fnum += acwt;
else if (bc == 'g')
fnum += gcwt;
else if (bc == 'u')
fnum += ucwt;
break;
case 'g':
if (bc == 'a')
fnum += agwt;
else if (bc == 'c')
fnum += gcwt;
else if (bc == 'u')
fnum += ugwt;
break;
case 'u':
if (bc == 'a')
fnum += auwt;
else if (bc == 'c')
fnum += ucwt;
else if (bc == 'g')
fnum += ugwt;
break;
case 't':
if (bc == 'a')
fnum += auwt;
else if (bc == 'c')
fnum += ucwt;
else if (bc == 'g')
fnum += ugwt;
break;
default:
break;
};
}
}
if ((blank == FALSE) && match) {
(*num)++;
(*denom)++;
}
else if (!blank)
(*denom)++;
}
}
if (special) (*num) = *denom - (int)fnum;
return 0;
}
float setdist(num, denom, a, b)
int num, denom, a, b;
{
float cor;
switch (correction) {
case OLSEN:
cor = parta[a] * parta[b] + partc[a] * partc[b] +
partg[a] * partg[b] + partu[a] * partu[b];
break;
case JUKES:
cor = 0.25;
break;
case NONE:
cor = 0.0;
break;
default:
cor = 0.0;
break;
};
if (correction == NONE)
return (1.0 - (float)num / (float)denom);
else
return (-(1.0 - cor) * log(1.0 / (1.0 - cor) *
((float)num / (float)denom - cor)));
}
getarg(av, ndx, atype, aval) char **av, atype[], aval[];
int ndx;
{
int i, j;
char c;
for (j = 0; (c = av[ndx][j]) != ' ' && c != '=' && c != '\0'; j++)
atype[j] = c;
if (c == '=') {
atype[j++] = c;
atype[j] = '\0';
}
else {
atype[j] = '\0';
j++;
}
if (c == '=') {
for (i = 0; (c = av[ndx][j]) != '\0' && c != ' '; i++, j++)
aval[i] = c;
aval[i] = '\0';
}
return 0;
}
SetPart()
{
int a, c, g, u, tot, i, j;
char nuc;
for (j = 0; j < numseq; j++) {
a = 0;
c = 0;
g = 0;
u = 0;
tot = 0;
for (i = 0; i < data[j].length; i++) {
nuc = data[j].nuc[i] | 32;
switch (nuc) {
case 'a':
a++;
tot++;
break;
case 'c':
c++;
tot++;
break;
case 'g':
g++;
tot++;
break;
case 'u':
u++;
tot++;
break;
case 't':
u++;
tot++;
break;
};
}
parta[j] = (float)a / (float)tot;
partc[j] = (float)c / (float)tot;
partg[j] = (float)g / (float)tot;
partu[j] = (float)u / (float)tot;
}
return 0;
}
Report()
{
int i, ii, jj, j, k;
if (tbl) printf("#\n#-\n#-\n#-\n#-\n");
for (jj = 0, j = 0; j < numseq; j++) {
if (tbl) printf("%2d: %-.15s|", jj + 1, data[j].name);
for (i = 0; i < j; i++) {
if (sim)
printf("%6.1f", 100 - dist[i][j] * 100.0);
else
printf("%6.1f", dist[i][j] * 100.0);
}
printf("\n");
jj++;
}
return 0;
}
int find(b, a)
char *a, *b;
{
int flag, lenb, lena;
register i, j;
flag = 0;
lenb = strlen(b);
lena = strlen(a);
for (i = 0; ((i < lena) && flag == 0); i++) {
for (j = 0; (j < lenb) && (a[i + j] == b[j]); j++)
;
flag = ((j == lenb) ? 1 : 0);
}
return flag;
}

114
SUPPORT/findall.c Normal file
View file

@ -0,0 +1,114 @@
/*
* Copyright 1991 Steven Smith at the Harvard Genome Lab.
* All rights reserved.
*/
#include "Flatio.c"
int main(ac, av)
int ac;
char **av;
{
struct data_format data[10000];
int Match = 2, Mismatch = 8;
int i, j, k, l, numseqs, mis, Case = 32;
int slen, pcnt, pos;
int UT = FALSE;
char c;
if (ac < 3) {
fprintf(stderr,
"usage: %s search_string %%mismatch [-case] [-match "
"color] [-mismatch color]\n",
av[0]);
fprintf(stderr, " [-u=t]\n");
exit(0);
}
for (j = 3; j < ac; j++) {
if (strcmp("-case", av[j]) == 0) Case = 0;
if (strcmp("-match", av[j]) == 0)
sscanf(av[j + 1], "%d", &Match);
if (strcmp("-u=t", av[j]) == 0) UT = TRUE;
if (strcmp("-mismatch", av[j]) == 0)
sscanf(av[j + 1], "%d", &Mismatch);
}
numseqs = ReadFlat(stdin, data, 10000);
slen = strlen(av[1]);
sscanf(av[2], "%d", &pcnt);
pcnt *= slen;
pcnt /= 100;
if (UT)
for (j = 0; j <= strlen(av[1]); j++) {
if (av[1][j] == 't') av[1][j] = 'u';
if (av[1][j] == 'T') av[1][j] = 'U';
}
for (i = 0; i < numseqs; i++) {
if (UT)
for (j = 0; data[i].nuc[j] != '\0'; j++) {
if (data[i].nuc[j] == 't')
data[i].nuc[j] = 'u';
else if (data[i].nuc[j] == 'T')
data[i].nuc[j] = 'U';
}
printf("name:%s\n", data[i].name);
printf("length:%d\n", strlen(data[i].nuc));
printf("start:\n");
for (j = 0; j < data[i].length; j++) {
mis = 0;
for (k = 0, pos = j; k < slen && pos < data[i].length;
k++, pos++) {
c = data[i].nuc[pos];
for (; (c == ' ' || c == '-' || c == '~') &&
pos < data[i].length;)
c = data[i].nuc[++pos];
c |= Case;
if (data[i].type == '#') {
if (CompIUP(c, (av[1][k] | Case)) ==
FALSE)
mis++;
}
else {
if (c != (av[1][k] | Case)) mis++;
}
}
if (k == slen && mis <= pcnt) {
for (k = j; k < pos; k++) printf("%d\n", Match);
j = pos - 1;
}
else
printf("%d\n", Mismatch);
}
}
exit(0);
}
int CompIUP(a, b)
char a, b;
{
static int tmatr[16] = {'-', 'a', 'c', 'm', 'g', 'r', 's', 'v',
't', 'w', 'y', 'h', 'k', 'd', 'b', 'n'};
static int matr[128] = {
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, 0, 0, 0x00, 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, 0, 0, 0, 0, 0x01,
0xe, 0x02, 0x0d, 0, 0, 0x04, 0x0b, 0, 0, 0x0c, 0,
0x03, 0x0f, 0, 0, 0, 0x05, 0x06, 0x08, 0x08, 0x07, 0x09,
0x00, 0xa, 0, 0, 0, 0, 0, 0, 0, 0x01, 0x0e,
0x02, 0x0d, 0, 0, 0x04, 0x0b, 0, 0, 0x0c, 0, 0x03,
0x0f, 0, 0, 0, 0x05, 0x06, 0x08, 0x08, 0x07, 0x09, 0x00,
0x0a, 0, 0, 0, 0, 0x00, 0};
int testa, testb;
if (a & 32 != b & 32) return (FALSE);
testa = matr[(int)a];
testb = matr[(int)b];
return (testa & testb);
}

1305
SUPPORT/lsadt.c Normal file

File diff suppressed because it is too large Load diff

87
SUPPORT/sho_helix.c Normal file
View file

@ -0,0 +1,87 @@
#include "Flatio.c"
#define BLACK 8
#define RED 3
#define BLUE 6
#define YELLOW 1
#define AQUA 4
main()
{
struct data_format data[10000];
int i,j,k,numseqs,mask = -1;
int pair[20000],stack[20000],spt = 0;
char ch;
numseqs = ReadFlat(stdin,data,10000);
if(numseqs == 0)
exit(1);
for(j=0;j<numseqs;j++)
if(data[j].type == '"')
mask = j;
if(mask == -1)
exit(1);
for(j=0;j<data[mask].length;j++)
{
if(data[mask].nuc[j] == '[')
stack[spt++] = j;
else if(data[mask].nuc[j] == ']')
{
i = stack[--spt];
pair[j] = i;
pair[i] = j;
}
else
pair[j] = -1;
}
for(j=0;j<numseqs;j++)
if(j!=mask)
{
printf("name:%s\nlength:%d\nstart:\n",
data[j].name,data[j].length);
i = MIN(data[mask].length,data[j].length);
for(k=0;k<i;k++)
if(pair[k] != -1)
printf("%d\n",match(data[j].nuc[k],
data[j].nuc[pair[k]]));
else
printf("8\n");
for(k=0;k<data[j].length - data[mask].length;k++)
printf("8\n");
}
exit(0);
}
int match(a,b)
char a,b;
{
char aa,bb;
aa=a|32;
bb=b|32;
printf(stderr,"%c %c\n",aa,bb);
if(a=='-' || a=='~')
{
if((b=='-') || (b=='~'))
return(BLACK);
else
return(RED);
}
else if(aa=='a' && (bb=='t' || bb=='u'))
return(BLUE);
else if(bb=='a' && (aa=='t' || aa=='u'))
return(BLUE);
else if(bb=='c' && aa=='g' )
return(BLUE);
else if(bb=='g' && aa=='c' )
return(BLUE);
else if(aa=='g' && (bb=='t' || bb=='u'))
return(AQUA);
else if(bb=='g' && (aa=='t' || aa=='u'))
return(AQUA);
else return(YELLOW);
}

85
SUPPORT/varpos.c Normal file
View file

@ -0,0 +1,85 @@
#include "Flatio.c"
#define MAX(a,b) ((a)>(b)?(a):(b))
/*
* Varpos.c- An extremely simple program for showing which positions
* are varying in an alignment. Use this as a model for other
* external functions.
*
* Read in a flat file alignment, pass back an alignment color
* mask.
*
* Copyright 1991/1992 Steven Smith, Harvard Genome lab.
*
*/
main(ac,av)
int ac;
char **av;
{
struct data_format data[10000];
int i,j,k,numseqs,rev = FALSE;
int maxlen = -99999,
score = 0,
minoffset = 99999;
char ch;
if(ac>2)
{
fprintf(stderr,"Usage %s [-rev]<gde_flat_file>gde_color_mask\n", av[0]);
exit(1);
}
if(ac == 2)
if(strcmp(av[1],"-rev") == 0)
rev = TRUE;
numseqs = ReadFlat(stdin,data,10000);
if(numseqs == 0)
exit(1);
for(j=0;j<numseqs;j++)
{
if(data[j].length+data[j].offset > maxlen)
maxlen = data[j].length+data[j].offset;
if(data[j].offset < minoffset)
minoffset = data[j].offset;
}
printf("length:%d\n",maxlen);
printf("offset:%d\n",minoffset);
printf("start:\n");
for(j=0;j<maxlen;j++)
{
int a=0,c=0,g=0,u=0;
for(k=0;k<numseqs;k++)
if(data[k].length+data[k].offset > j)
{
if(j>data[k].offset)
ch=data[k].nuc[j-data[k].offset] | 32;
else
ch = '-';
if(ch=='a')a++;
if(ch=='c')c++;
if(ch=='g')g++;
if(ch=='u')u++;
if(ch=='t')u++;
}
score=MAX(a,c);
score=MAX(score,g);
score=MAX(score,u);
if(a+c+g+u)
{
if(rev)
score=(score*6/(a+c+g+u)+8);
else
score=((8-score*6/(a+c+g+u))+8);
}
else
score=8;
printf("%d\n",score);
}
exit(0);
}