X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=onegapignore.h;h=32818e3df6fce4bc5ab8a4ddda975572146a2a53;hb=cdf9083dc32543cc640e72e9ca3aee0323cbad45;hp=ee6cc5267931816a654c99f4e748d19bb2940901;hpb=b01e4c8527e66f227eff16cf296eeadf060306b6;p=mothur.git diff --git a/onegapignore.h b/onegapignore.h index ee6cc52..32818e3 100644 --- a/onegapignore.h +++ b/onegapignore.h @@ -9,6 +9,7 @@ * */ + #include "dist.h" /**************************************************************************************************/ @@ -24,28 +25,33 @@ public: int minLength = 0; int start = 0; int end = 0; + bool overlap = false; - for(int i=0;i=0;i--){ - if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){ - } - else{ + for(int i=alignLength-1;i>=0;i--){ + if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){ end = i; +// cout << "end: " << end << endl; + overlap = true; break; } } - for(int i=start;i<=end;i++){ - if(A.getAligned()[i] == '-' && B.getAligned()[i] == '-'){} - else if(A.getAligned()[i] == '-' && B.getAligned()[i] != '-'){ + if(seqA[i] == '-' && seqB[i] == '-'){ ; } + else if(seqB[i] != '-' && seqA[i] == '-'){ if(openGapA == 0){ difference++; minLength++; @@ -53,7 +59,7 @@ public: openGapB = 0; } } - else if(A.getAligned()[i] != '-' && B.getAligned()[i] == '-'){ + else if(seqA[i] != '-' && seqB[i] == '-'){ if(openGapB == 0){ difference++; minLength++; @@ -61,20 +67,19 @@ public: openGapB = 1; } } - else if(A.getAligned()[i] != '-' && B.getAligned()[i] != '-'){ - if(A.getAligned()[i] != B.getAligned()[i]){ + else if(seqA[i] != '-' && seqB[i] != '-'){ + if(seqA[i] != seqB[i]){ difference++; - minLength++; - openGapA = 0; - openGapB = 0; - } - else{ - minLength++; - openGapA = 0; - openGapB = 0; } + minLength++; + openGapA = 0; + openGapB = 0; } } + + //non-overlapping sequences + if (!overlap) { minLength = 0; } + if(minLength == 0) { dist = 1.0000; } else { dist = (double)difference / minLength; } }