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

View file

@ -1,18 +1,21 @@
CC = cc
FLAGS = -lm
all:CAP2 Restriction count findall varpos lsadt sho_helix Zuk_to_gen 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 CAP2: CAP2.c
cc CAP2.c -O -o CAP2 $(CC) CAP2.c -O -o CAP2
Restriction: Restriction.c Restriction: Restriction.c
cc Restriction.c -O -o Restriction $(CC) Restriction.c -O -o Restriction
Zuk_to_gen: Zuk_to_gen.c 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 count: count.c
cc count.c -O -o count -lm $(CC) count.c -O -o count $(FLAGS)
findall: findall.c findall: findall.c
cc findall.c -O -o findall $(CC) findall.c -O -o findall
lsadt: lsadt.c lsadt: lsadt.c
cc lsadt.c -O -o lsadt -lm $(CC) lsadt.c -O -o lsadt $(FLAGS)
sho_helix: sho_helix.c sho_helix: sho_helix.c
cc sho_helix.c -O -o sho_helix $(CC) sho_helix.c -O -o sho_helix
varpos: varpos.c 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 <stdio.h>
#include <string.h>
typedef struct Sequence typedef struct Sequence {
{ int len;
int len; char name[80];
char name[80]; char type[8];
char type[8]; char *nuc;
char *nuc;
} Sequence; } Sequence;
main() main()
{ {
char a[5000],b[5000],inline[132]; char a[5000], b[5000], cinline[132];
int pos1,pos2,pos3,i,j,k,FLAG; int pos1, pos2, pos3, i, j, k, FLAG;
Sequence pair[2]; Sequence pair[2];
for (j = 0; j < 5000; j++) b[j] = '-';
for(j=0;j<5000;j++) FLAG = (int)gets(cinline);
b[j]='-'; for (j = 0; FLAG; j++) {
FLAG = (int)gets(inline); FLAG = (int)gets(cinline);
for(j=0;FLAG;j++) sscanf(cinline, "%d", &pos1);
{ if ((sscanf(cinline, "%*6c %c %d %d %d", &(a[j]), &k, &pos2,
FLAG = (int)gets(inline); &pos3) == 4) &&
sscanf(inline,"%d",&pos1); (FLAG)) {
if((sscanf(inline,"%*6c %c %d %d %d",&(a[j]),&k,&pos2,&pos3) if (pos3 != 0) {
== 4) && (FLAG)) if (pos1 < pos3) {
{ b[pos1 - 1] = '[';
if(pos3!=0) b[pos3 - 1] = ']';
{ }
if(pos1<pos3) else {
{ b[pos3 - 1] = '[';
b[pos1-1] = '['; b[pos1 - 1] = ']';
b[pos3-1] = ']';
} }
else
{
b[pos3-1] = '[';
b[pos1-1] = ']';
}
} }
} }
else else {
{
pair[0].len = j; pair[0].len = j;
strcpy(pair[0].name,"HELIX"); strcpy(pair[0].name, "HELIX");
strcpy(pair[0].type,"TEXT"); strcpy(pair[0].type, "TEXT");
pair[1].len = j; pair[1].len = j;
/* /*
sscanf(inline,"%*24c %s",pair[1].name); sscanf(cinline,"%*24c
*/ %s",pair[1].name);
strcpy(pair[1].name,"Sequence"); */
strcpy(pair[1].type,"RNA"); strcpy(pair[1].name, "Sequence");
strcpy(pair[1].type, "RNA");
pair[0].nuc = b; pair[0].nuc = b;
pair[1].nuc = a; pair[1].nuc = a;
WriteGen(pair,stdout,2); WriteGen(pair, stdout, 2);
for(j=0;j<5000;j++) b[j]='-'; for (j = 0; j < 5000; j++) b[j] = '-';
j = -1; j = -1;
} }
} }
exit(0); exit(0);
} }
WriteGen(seq, file, numseq) Sequence *seq;
WriteGen(seq,file,numseq)
Sequence *seq;
FILE *file; FILE *file;
int numseq; int numseq;
{ {
register i,j; register i, j;
char temp[14]; char temp[14];
for(j=0;j<numseq;j++) for (j = 0; j < numseq; j++) fprintf(file, "%-.12s\n", seq[j].name);
fprintf(file,"%-.12s\n",seq[j].name);
fprintf(file,"ZZZZZZZZZZ\n"); fprintf(file, "ZZZZZZZZZZ\n");
for(j=0;j<numseq;j++) for (j = 0; j < numseq; j++) {
{ strcpy(temp, seq[j].name);
strcpy(temp,seq[j].name); for (i = strlen(temp); i < 13; i++) temp[i] = ' ';
for(i=strlen(temp);i<13;i++) temp[i] = '\0';
temp[i] = ' '; fprintf(file, "LOCUS %-.12s %s %d BP\n", temp,
temp[i] = '\0'; seq[j].type, seq[j].len);
fprintf(file,"LOCUS %-.12s %s %d BP\n",temp,
seq[j].type,seq[j].len);
fprintf(file,"ORIGIN"); fprintf(file, "ORIGIN");
for(i=0;i<seq[j].len;i++) for (i = 0; i < seq[j].len; i++) {
{ if (i % 60 == 0) fprintf(file, "\n%9d", i + 1);
if(i%60 == 0) if (i % 10 == 0) fprintf(file, " ");
fprintf(file,"\n%9d",i+1); fprintf(file, "%c", seq[j].nuc[i]);
if(i%10 == 0) }
fprintf(file," "); fprintf(file, "\n//\n");
fprintf(file,"%c",seq[j].nuc[i]); }
} return;
fprintf(file,"\n//\n");
}
return;
} }

View file

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

View file

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

File diff suppressed because it is too large Load diff