]> git.donarmstrong.com Git - mothur.git/blob - eachgapdist.h
altered venn command to make use of sharedchao for any number of groups, fixed window...
[mothur.git] / eachgapdist.h
1 #ifndef EACHGAPDIST_H
2 #define EACHGAPDIST_H
3 /*
4  *  eachgapdist.h
5  *  Mothur
6  *
7  *  Created by Sarah Westcott on 5/7/09.
8  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
9  *
10  */
11
12 #include "dist.h"
13
14 /**************************************************************************************************/
15
16 class eachGapDist : public Dist {
17         
18 public:
19         void calcDist(Sequence A, Sequence B){          
20                 int diff = 0;
21                 int length = 0;
22                 int start = 0;
23                 
24                 for(int i=0; i<A.getLength(); i++){
25                         if(A.getAligned()[i] != '.' || B.getAligned()[i] != '.'){
26                                 start = i;
27                                 break;
28                         }
29                 }
30                 
31                 for(int i=start;i<A.getLength();i++){
32                         if((A.getAligned()[i] == '-' || B.getAligned()[i] == '-') && (A.getAligned()[i] == '.' || B.getAligned()[i] == '.')){}
33                         else if(A.getAligned()[i] == '.' && B.getAligned()[i] == '.'){
34                                 break;  
35                         }
36                         else if(A.getAligned()[i] != '-' && B.getAligned()[i] != '-'){
37                                 if(A.getAligned()[i] != B.getAligned()[i]){
38                                         diff++;
39                                 }
40                                 length++;
41                         }
42                         else if(A.getAligned()[i] != '-' || B.getAligned()[i] != '-'){
43                                 diff++;
44                                 length++;
45                         }
46                 }
47                 
48                 if(length == 0) {       dist = 1.0000;                                                          }
49                 else                    {       dist = ((double)diff  / (double)length);        }
50                 
51         }
52 };
53
54 /**************************************************************************************************/
55
56 #endif