/* * Copyright 1991 Steven Smith at the Harvard Genome Lab. * All rights reserved. */ #include "Flatio.c" #include #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=] ",av[0]); fprintf(stderr,"[-t] alignment_flat_file\n"); exit(1); } for(j=1;jlength,db->length); for(j=0;jnuc[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; } 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; } SetPart() { int a,c,g,u,tot,i,j; char nuc; for(j=0;j