source: tags/initial/DIST/distanalyse.cxx

Last change on this file was 2, checked in by oldcode, 24 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <memory.h>
4#include <malloc.h>
5#include <string.h>
6
7#include <math.h>
8
9#include <arbdb.h>
10#include <arbdbt.h>
11
12#include <aw_root.hxx>
13#include <aw_device.hxx>
14#include <aw_window.hxx>
15
16#include <awt.hxx>
17
18#include <awt_tree.hxx>
19#include "dist.hxx"
20#include "BI_helix.hxx"
21#include "ph_matr.hxx"
22
23
24
25char *PHMATRIX::analyse(AW_root *awrdummy)
26{
27        AWUSE(awrdummy);
28        long  row, pos;
29        char *sequ, ch, dummy[280];
30
31        long    act_gci, mean_gci=0;
32        float   act_gc, mean_gc, min_gc=9999.9, max_gc=0.0;
33        long    act_len, mean_len=0, min_len=9999999, max_len=0;
34
35        if (is_AA) {
36                if (nentries> 100) {
37                        aw_message("A lot of sequences!\n   ==> fast Kimura selected! (instead of PAM)");
38                        aw_root->awar("dist/correction/trans")->write_int(PH_TRANSFORMATION_KIMURA);
39                }else{
40                        aw_message(     "Only limited number of sequences!\n"
41                                        "   ==> slow PAM selected! (instead of Kimura)");
42                        aw_root->awar("dist/correction/trans")->write_int(PH_TRANSFORMATION_PAM);
43                }
44                return 0;
45        }
46
47
48        //calculate meanvalue of sequencelength:
49
50        for(row=0; row<nentries; row++) {
51                act_gci = 0;
52                act_len = 0;
53                sequ = entries[row]->sequence_parsimony->sequence;
54                for(pos=0; pos<tree_root->filter->real_len; pos++) {
55                        ch = sequ[pos];
56                        if(ch == AP_C || ch == AP_G) act_gci++;
57                        if(ch == AP_A || ch == AP_C || ch == AP_G || ch == AP_T) act_len++;
58                }
59                mean_gci += act_gci;
60                act_gc = ((float) act_gci) / act_len;
61                if(act_gc < min_gc) min_gc = act_gc;
62                if(act_gc > max_gc) max_gc = act_gc;
63                mean_len += act_len;
64                if(act_len < min_len) min_len = act_len;
65                if(act_len > max_len) max_len = act_len;
66        }
67
68        if (min_len * 1.3 < max_len) {
69            aw_message("Warning: The length of sequences differ significantly\n"
70                       "        be carefull, neighbour joining is sensitiv to\n"
71                       "        this kind of error");
72        }
73        mean_gc = ((float) mean_gci) / mean_len / nentries;
74        mean_len /= nentries;
75
76
77        if(mean_len < 100) {
78                aw_root->awar("dist/correction/trans")->write_int(PH_TRANSFORMATION_NONE);
79                aw_message("Too short sequences!\n   ==> No correction selected!");
80                return NULL;
81        }
82
83        if(mean_len < 300) {
84                aw_root->awar("dist/correction/trans")->write_int(PH_TRANSFORMATION_JUKES_CANTOR);
85                aw_message("Meanlength shorter than 300\n   ==> Jukes Cantor selected!");
86                return NULL;
87        }
88
89        if((mean_len < 1000) || ((max_gc / min_gc) < 1.2)) {
90                if(mean_len < 1000)
91                        sprintf(dummy, "Too short sequences for Olsen! \n");
92                else
93                        sprintf(dummy, "Maximal GC (%f) : Minimal GC (%f) < 1.2\n", max_gc, min_gc);
94                sprintf(dummy, "%s   ==> Felsenstein selected!", dummy);
95                aw_root->awar("dist/correction/trans")->write_int(PH_TRANSFORMATION_FELSENSTEIN);
96                aw_message(dummy);
97                return NULL;
98        }
99
100        aw_root->awar("dist/correction/trans")->write_int(PH_TRANSFORMATION_OLSEN);
101        aw_message("Olsen selected!");
102        return NULL;
103
104}
105       
106       
107               
Note: See TracBrowser for help on using the repository browser.