fix: fix the support direcotry

This commit is contained in:
kuoi 2023-04-12 03:41:11 +08:00
parent 30b16b2a1e
commit 339d05a4d8
7 changed files with 2170 additions and 2347 deletions

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

@ -1,126 +1,114 @@
/*
* Copyright 1991 Steven Smith at the Harvard Genome Lab.
* All rights reserved.
*/
/*
* Copyright 1991 Steven Smith at the Harvard Genome Lab.
* All rights reserved.
*/
#include "Flatio.c"
main(ac,av)
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 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)
{
if (ac < 3) {
fprintf(stderr,
"usage: %s search_string %%mismatch [-case] [-match color] [-mismatch color]\n",
av[0]);
fprintf(stderr," [-u=t]\n");
"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);
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);
numseqs = ReadFlat(stdin, data, 10000);
slen = strlen(av[1]);
sscanf(av[2],"%d",&pcnt);
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';
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')
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')
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("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++)
{
for (j = 0; j < data[i].length; j++) {
mis = 0;
for(k=0,pos=j;k<slen && pos<data[i].length;k++,pos++)
{
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;)
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++;
if (data[i].type == '#') {
if (CompIUP(c, (av[1][k] | Case)) ==
FALSE)
mis++;
}
else
{
if(c!=(av[1][k]|Case))
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;
if (k == slen && mis <= pcnt) {
for (k = j; k < pos; k++) printf("%d\n", Match);
j = pos - 1;
}
else
printf("%d\n",Mismatch);
printf("%d\n", Mismatch);
}
}
exit(0);
}
int CompIUP(a,b)
char a,b;
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
};
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;
int testa, testb;
if(a&32 != b&32)
return(FALSE);
if (a & 32 != b & 32) return (FALSE);
testa = matr[(int)a];
testb = matr[(int)b];
return(testa&testb);
return (testa & testb);
}

File diff suppressed because it is too large Load Diff