]> git.donarmstrong.com Git - mothur.git/blobdiff - eachgapdist.h
altered venn command to make use of sharedchao for any number of groups, fixed window...
[mothur.git] / eachgapdist.h
diff --git a/eachgapdist.h b/eachgapdist.h
new file mode 100644 (file)
index 0000000..767c4bf
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef EACHGAPDIST_H
+#define EACHGAPDIST_H
+/*
+ *  eachgapdist.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 5/7/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "dist.h"
+
+/**************************************************************************************************/
+
+class eachGapDist : public Dist {
+       
+public:
+       void calcDist(Sequence A, Sequence B){          
+               int diff = 0;
+               int length = 0;
+               int start = 0;
+               
+               for(int i=0; i<A.getLength(); i++){
+                       if(A.getAligned()[i] != '.' || B.getAligned()[i] != '.'){
+                               start = i;
+                               break;
+                       }
+               }
+               
+               for(int i=start;i<A.getLength();i++){
+                       if((A.getAligned()[i] == '-' || B.getAligned()[i] == '-') && (A.getAligned()[i] == '.' || B.getAligned()[i] == '.')){}
+                       else if(A.getAligned()[i] == '.' && B.getAligned()[i] == '.'){
+                               break;  
+                       }
+                       else if(A.getAligned()[i] != '-' && B.getAligned()[i] != '-'){
+                               if(A.getAligned()[i] != B.getAligned()[i]){
+                                       diff++;
+                               }
+                               length++;
+                       }
+                       else if(A.getAligned()[i] != '-' || B.getAligned()[i] != '-'){
+                               diff++;
+                               length++;
+                       }
+               }
+               
+               if(length == 0) {       dist = 1.0000;                                                          }
+               else                    {       dist = ((double)diff  / (double)length);        }
+               
+       }
+};
+
+/**************************************************************************************************/
+
+#endif
\ No newline at end of file