/* This program computes the test statistic W on a data set: W=N5/N -(N3+N5)(N2+N5)/N^2 . Sites are divided into 5 types. N is the total number of sites with no gap or missing data. Needs - the number of sequences in each clade, or a additional header in the "phylip" datafile, specifying the clades names and the (abbreviated) names of sequences in those clades. - a Phylip Data file containing the sequences Result: W is written on the standard output Actually, as the program is now, it could take an invariable proportion of sites as an optional argument. It wouldn't be used. */ #include #include #include #include #include #include #ifdef __MWERKS__ #ifdef __DROP_CONSOLE__ #include "DropConsole.h" #else #include #endif #endif #include "global.h" /*#define MAX_NAME_LEN 64 /* or #include "tree.h" */ #define MAX_NAME_LEN 40 #define MAX_NUM_SEQ 256 int printHelp,verbose; char cladeFileName[256]; char treeFileName[256]; double proportionInvariable; /* argument of the program */ char **names; char **sequences; int numseq[2]; /* number of sequences in clade 1 and clade 2. */ int numSequences, numSites; int *clade1; /* numbers of the clade1's sequences */ int *clade2; char ***cladeNames; char cladeInfo; /* ='n' in case option -n, 'c' in case option -c and '0' in case no option (yet) */ FILE *clade_fv; FILE *tree_fv; static void PrintUsage() { fprintf(stderr, "Usage: test-stat [-h][-q][-n # # | -c filename | -t filename] < datafile\n"); fprintf(stderr, " -h: Give this help message\n"); fprintf(stderr, " -v: verbose\n"); fprintf(stderr, " -n: #1 #2 = number of sites in the first and second clade.\n"); fprintf(stderr, " Sequences from the first clade are supposed to come first,\n"); fprintf(stderr, " and sequences from the second clade are supposed to come next.\n"); fprintf(stderr, " -c: the clade names and the corresponding sequence names\n"); fprintf(stderr, " (possibly abbreviated) are to be read in a file\n"); fprintf(stderr, " -t: the clades definition are to be read in a tree file,\n"); fprintf(stderr, " a clade is represented by a internal node. \n"); fprintf(stderr, " (not implemented yet) \n"); fprintf(stderr, " datafile: name of sequence data file \n"); } void ReadParams(int argc, char **argv) { char *P, ch; int i; cladeInfo='0'; printHelp=0; verbose=0; for (i=1; i numSequences ) { fprintf(stderr, "Bad number of sequences, compared to the clades' sizes\n"); exit(0); } N3=N4=N5=0; N=0; P=sequences; for (i=0; i