Add missing binaty and statis library
[jabaws.git] / binaries / src / ViennaRNA / Cluster / AD_main.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "split.h"
5 #include "cluster.h"
6 #include "distance_matrix.h"
7 #include "treeplot.h"
8 #include "utils.h"
9
10
11 #define PUBLIC
12 #define PRIVATE   static
13
14 PRIVATE void usage(void);
15
16 main(int argc, char *argv[])
17 {
18    int     i,j;
19    float **dm;
20    Split  *S;
21    Union  *U;
22    char    type[5];
23
24    short   Do_Split=1, Do_Wards=0, Do_Nj=0;
25
26    for (i=1; i<argc; i++) {
27       if (argv[i][0]=='-') {
28          switch ( argv[i][1] ) {
29           case 'X':  if (argv[i][2]=='\0') { Do_Split = 1 ; break; }
30             Do_Split = 0;
31             Do_Wards = 0;
32             Do_Nj    = 0;
33             for(j=2;j<strlen(argv[i]);j++) {
34                switch(argv[i][j]) {
35                 case 's' :  Do_Split = 1; 
36                   break;
37                 case 'w' :  Do_Wards = 1;
38                   break;
39                 case 'n' :  Do_Nj    = 1;
40                   break;
41                   default :
42                   usage();
43                }
44             }
45             break;
46             default : 
47             usage();
48          }
49       }
50    }
51
52    while ((dm=read_distance_matrix(type))!=NULL) {
53
54       printf_taxa_list();
55       printf("> %s\n",type);
56       
57       if(Do_Split) {
58          S = split_decomposition(dm);
59          sort_Split(S);
60          print_Split(S);
61          free_Split(S);
62       }
63       if(Do_Wards) {
64          U = wards_cluster(dm);
65
66          printf_phylogeny(U,"W");
67          PSplot_phylogeny(U,"wards.ps","Ward's Method");
68          free(U);
69       }
70       if(Do_Nj) {
71          U = neighbour_joining(dm);
72          printf_phylogeny(U,"Nj");
73          PSplot_phylogeny(U,"nj.ps","Neighbor Joining");
74          free(U);
75       }
76       free_distance_matrix(dm);
77    }
78    return 0;
79 }
80
81
82 PRIVATE void usage(void)
83 {
84    nrerror("usage: AnalyseDist [-X[swn]]");
85 }