/* Analyze 4d - read zoo raw alignment, read 4d sites and do analysis of changes at 4d sites. The zoo alignments are read in using Webb's routine from read_malign.h Trevor Bruen 2002 */ #include "util.h" #include "ctype.h" #include "string.h" #include "read_malign.h" #define SAME_STRING(x,y) (!strcasecmp(x,y)) #define ALPHA_SIZE 4 /* Print the totals for each type of base */ void print_totals(int, int, int***, char *); /* Translate a base to an integer */ int translate(char ); /* Print the program usage */ void print_usage(); int main( int argc, char **argv) { /* Index default to -1 as flage for special human consideration */ int i,j,k,nrow, ncol, *sites, **site_members,nsites, nspecies,*table,index=-1,total_columns=0,column_differs=0,column_4d_differs=0,*spec_breakdown,same; int **base_count,**bases_in_4d; char **seq_name, **site_species, **species,*token,*spec_name,ref; /* Needed for Webb's library functions */ argv0 = "analyze"; if ((argc != 3) && (argc != 4) ) print_usage(); /* Determine which species to use as reference */ if(argc == 4) { token = strtok(argv[3], "="); spec_name = strtok(NULL, " \n"); } else spec_name="human"; /* Read the alignment */ site_species = read_malign(argv[1], &nrow, &ncol, &seq_name); /* Now read the 4d sites... */ site_members = read_sites(argv[2], &nspecies, &nsites, &species, &sites); /* Make sure nspecies and nrow correspond -subtract one because of implicit human in 4d*/ if(nspecies != (nrow-1)) fatal("Species in alignment must correspond to number of species in 4d sites"); /* Build conversion table */ table=ckalloc(nspecies * sizeof(int)); for(i=0;i