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,44 +15,41 @@ 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;
@ -59,28 +57,28 @@ int maxseqs;
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;
} }
} }
@ -91,59 +89,45 @@ int maxseqs;
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('\n',file);
fputc(data[j].nuc[i], file); fputc(data[j].nuc[i], file);
} }
} }
return; return 0;
} }
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; return 0;
} }
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);
} }
@ -151,14 +135,11 @@ int count,size;
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);
} }

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,54 +1,47 @@
#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) {
{
if(pos3!=0)
{
if(pos1<pos3)
{
b[pos1 - 1] = '['; b[pos1 - 1] = '[';
b[pos3 - 1] = ']'; b[pos3 - 1] = ']';
} }
else else {
{
b[pos3 - 1] = '['; b[pos3 - 1] = '[';
b[pos1 - 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].name, "Sequence");
strcpy(pair[1].type, "RNA"); strcpy(pair[1].type, "RNA");
@ -64,37 +57,28 @@ main()
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++) for (i = strlen(temp); i < 13; i++) temp[i] = ' ';
temp[i] = ' ';
temp[i] = '\0'; temp[i] = '\0';
fprintf(file, "LOCUS %-.12s %s %d BP\n", temp, fprintf(file, "LOCUS %-.12s %s %d BP\n", temp,
seq[j].type, seq[j].len); 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);
if(i%10 == 0)
fprintf(file," ");
fprintf(file, "%c", seq[j].nuc[i]); fprintf(file, "%c", seq[j].nuc[i]);
} }
fprintf(file, "\n//\n"); fprintf(file, "\n//\n");

View File

@ -2,9 +2,10 @@
* 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
@ -25,8 +26,7 @@ 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;
@ -35,29 +35,25 @@ char **av;
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>] ",
av[0]);
fprintf(stderr, "[-t] alignment_flat_file\n"); 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);
} }
@ -67,8 +63,7 @@ char **av;
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;
@ -85,51 +80,49 @@ char **av;
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;
@ -139,10 +132,8 @@ 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);
} }
@ -153,8 +144,7 @@ char **av;
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);
} }
@ -163,9 +153,7 @@ char **av;
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;
@ -180,62 +168,69 @@ int a,b,*num,*denom;
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') if (ac == 't') ac = 'u';
ac = 'u'; if (ac == 'T') ac = 'U';
if(ac == 'T') if (bc == 't') bc = 'u';
ac = 'U'; if (bc == 'T') bc = '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') fnum+=acwt; if (bc == 'c')
else if(bc == 'g') fnum+=agwt; fnum += acwt;
else if(bc == 'u') fnum+=auwt; else if (bc == 'g')
fnum += agwt;
else if (bc == 'u')
fnum += auwt;
break; 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')
fnum += gcwt;
else if (bc == 'u')
fnum += ucwt;
break; 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')
fnum += gcwt;
else if (bc == 'u')
fnum += ugwt;
break; 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')
fnum += ucwt;
else if (bc == 'g')
fnum += ugwt;
break; 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')
fnum += ucwt;
else if (bc == 'g')
fnum += ugwt;
break; break;
default: default:
@ -244,8 +239,7 @@ int a,b,*num,*denom;
} }
} }
if((blank == FALSE) && match) if ((blank == FALSE) && match) {
{
(*num)++; (*num)++;
(*denom)++; (*denom)++;
} }
@ -253,23 +247,18 @@ int a,b,*num,*denom;
(*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]+ cor = parta[a] * parta[b] + partc[a] * partc[b] +
partc[a]*partc[b]+ partg[a] * partg[b] + partu[a] * partu[b];
partg[a]*partg[b]+
partu[a]*partu[b];
break; break;
case JUKES: case JUKES:
@ -288,36 +277,32 @@ int num,denom,a,b;
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()
@ -325,19 +310,16 @@ 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': case 'a':
a++; a++;
tot++; tot++;
@ -369,23 +351,18 @@ 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
@ -394,10 +371,9 @@ Report()
printf("\n"); printf("\n");
jj++; jj++;
} }
return; return 0;
} }
int find(b, a) int find(b, a)
char *a, *b; char *a, *b;
{ {
@ -407,9 +383,9 @@ char *a,*b;
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

@ -4,8 +4,7 @@
*/ */
#include "Flatio.c" #include "Flatio.c"
int main(ac, av)
main(ac,av)
int ac; int ac;
char **av; char **av;
{ {
@ -15,22 +14,19 @@ char **av;
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 "
"color] [-mismatch color]\n",
av[0]); av[0]);
fprintf(stderr, " [-u=t]\n"); 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)
Case = 0;
if (strcmp("-match", av[j]) == 0) if (strcmp("-match", av[j]) == 0)
sscanf(av[j + 1], "%d", &Match); sscanf(av[j + 1], "%d", &Match);
if(strcmp("-u=t",av[j]) == 0) if (strcmp("-u=t", av[j]) == 0) UT = TRUE;
UT = TRUE;
if (strcmp("-mismatch", av[j]) == 0) if (strcmp("-mismatch", av[j]) == 0)
sscanf(av[j + 1], "%d", &Mismatch); sscanf(av[j + 1], "%d", &Mismatch);
} }
@ -42,19 +38,14 @@ char **av;
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')
@ -63,32 +54,27 @@ char **av;
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++)
printf("%d\n",Match);
j = pos - 1; j = pos - 1;
} }
else else
@ -98,7 +84,6 @@ char **av;
exit(0); exit(0);
} }
int CompIUP(a, b) int CompIUP(a, b)
char a, b; char a, b;
{ {
@ -106,19 +91,22 @@ char a,b;
'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) if (a & 32 != b & 32) return (FALSE);
return(FALSE);
testa = matr[(int)a]; testa = matr[(int)a];
testb = matr[(int)b]; testb = matr[(int)b];

File diff suppressed because it is too large Load Diff