]> git.donarmstrong.com Git - mothur.git/blob - eachgapdistignorens.h
changes while testing
[mothur.git] / eachgapdistignorens.h
1 #ifndef EACHGAPDISTIGNORENS_H
2 #define EACHGAPDISTIGNORENS_H
3
4 /*
5  *  eachgapdistignorens.h
6  *  Mothur
7  *
8  *  Created by Pat Schloss on 4/20/11.
9  *  Copyright 2011 Schloss Lab. All rights reserved.
10  *
11  */
12
13
14 #include "dist.h"
15
16 /**************************************************************************************************/
17
18 class eachGapDistIgnoreNs : public Dist {
19         
20 public:
21         void calcDist(Sequence A, Sequence B){          
22                 int diff = 0;
23                 int length = 0;
24                 int start = 0;
25                 
26                 string seqA = A.getAligned();
27                 string seqB = B.getAligned();
28                 
29                 int alignLength = seqA.length();
30                 
31                 for(int i=0; i<alignLength; i++){
32                         if(seqA[i] != '.' || seqB[i] != '.'){
33                                 start = i;
34                                 break;
35                         }
36                 }
37                 
38                 for(int i=start;i<alignLength;i++){
39                         if(seqA[i] == '.' && seqB[i] == '.'){
40                                 break;  
41                         }
42                         else if((seqA[i] == '-' && seqB[i] == '-') || (seqA[i] == '-' && seqB[i] == '.') || (seqA[i] == '.' && seqB[i] == '-') || seqA[i] == 'N' || seqB[i] == 'N'){;}
43                         else{
44                                 if(seqA[i] != seqB[i]){
45                                         diff++;
46                                 }
47                                 length++;
48                         }
49                 }
50                 
51                 if(length == 0) {       dist = 1.0000;                                                          }
52                 else                    {       dist = ((double)diff  / (double)length);        }
53         }
54 };
55
56 /**************************************************************************************************/
57
58 #endif