X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=onegapignore.h;h=fdbc196e9f2f7ff539a9b61bf35a8120483ac66b;hp=6421741c0d4c153794ab40efc9318af6d64349a4;hb=cf9987b67aa49777a4c91c2d21f96e58bf17aa82;hpb=cdcf99b7760701e6869ca8e4e6e91c8e8c4ae186 diff --git a/onegapignore.h b/onegapignore.h index 6421741..fdbc196 100644 --- a/onegapignore.h +++ b/onegapignore.h @@ -9,6 +9,7 @@ * */ + #include "dist.h" /**************************************************************************************************/ @@ -16,6 +17,9 @@ class oneGapIgnoreTermGapDist : public Dist { public: + + oneGapIgnoreTermGapDist() {} + void calcDist(Sequence A, Sequence B){ int difference = 0; @@ -24,21 +28,26 @@ public: int minLength = 0; int start = 0; int end = 0; + bool overlap = false; string seqA = A.getAligned(); string seqB = B.getAligned(); int alignLength = seqA.length(); - + // this assumes that sequences start and end with '.'s instead of'-'s. for(int i=0;i=0;i--){ - if(seqA[i] != '.' && seqB[i] != '.'){ + if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){ end = i; +// cout << "end: " << end << endl; + overlap = true; break; } } @@ -70,7 +79,10 @@ public: openGapB = 0; } } - + + //non-overlapping sequences + if (!overlap) { minLength = 0; } + if(minLength == 0) { dist = 1.0000; } else { dist = (double)difference / minLength; } }