]> git.donarmstrong.com Git - mothur.git/blobdiff - ignoregaps.h
altered venn command to make use of sharedchao for any number of groups, fixed window...
[mothur.git] / ignoregaps.h
diff --git a/ignoregaps.h b/ignoregaps.h
new file mode 100644 (file)
index 0000000..8127b62
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef IGNOREGAPS_H
+#define IGNOREGAPS_H
+/*
+ *  ignoregaps.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 5/7/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "dist.h"
+
+/**************************************************************************************************/
+
+//     this class calculates distances by ignoring all gap characters.  so if seq a has an "A" and seq
+//     b has a '-', there is no penalty
+
+class ignoreGaps : public Dist {
+       
+public:
+       
+       void calcDist(Sequence A, Sequence B){          
+               int diff = 0;
+               int length = 0;
+               int start = 0;
+               int end = 0;
+               
+               for(int i=0;i<A.getLength();i++){
+                       if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){
+                       }
+                       else{
+                               start = i;
+                               break;
+                       }
+               }
+               for(int i=A.getLength()-1;i>=0;i--){
+                       if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){
+                       }
+                       else{
+                               end = i;
+                               break;
+                       }
+               }
+               
+               for(int i=start; i<=end; i++){
+                       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++;
+                       }
+               }
+               
+               if(length == 0)         {       dist = 1.0000;                                                          }
+               else                            {       dist = ((double)diff  / (double)length);        }
+               
+       }
+       
+};
+
+/**************************************************************************************************/
+#endif
+