X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=eachgapignore.h;fp=eachgapignore.h;h=2e7fbd6bd228d3ed625cd1904ecd7d15075d9234;hp=0000000000000000000000000000000000000000;hb=0caf3fbabaa3ece404f8ce77f4c883dc5b1bf1dc;hpb=1b73ff67c83892a025e597dabd9df6fe7b58206a diff --git a/eachgapignore.h b/eachgapignore.h new file mode 100644 index 0000000..2e7fbd6 --- /dev/null +++ b/eachgapignore.h @@ -0,0 +1,77 @@ +#ifndef EACHGAPIGNORE_H +#define EACHGAPIGNORE_H +/* + * eachgapignore.h + * Mothur + * + * Created by Sarah Westcott on 5/7/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + + +#include "dist.h" + +/**************************************************************************************************/ + +class eachGapIgnoreTermGapDist : public Dist { + +public: + eachGapIgnoreTermGapDist() {} + eachGapIgnoreTermGapDist(const eachGapIgnoreTermGapDist& ddb) {} + + void calcDist(Sequence A, Sequence B){ + int diff = 0; + int length = 0; + int start = 0; + int end = 0; + bool overlap = false; + + string seqA = A.getAligned(); + string seqB = B.getAligned(); + int alignLength = seqA.length(); + + for(int i=0;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(seqA[i] == '.' || seqB[i] == '.'){ + break; + } + else if(seqA[i] != '-' || seqB[i] != '-'){ + if(seqA[i] != seqB[i]){ + diff++; + } + length++; + } + } + + //non-overlapping sequences + if (!overlap) { length = 0; } + + if(length == 0) { dist = 1.0000; } + else { dist = ((double)diff / (double)length); } + + } + +}; + +/**************************************************************************************************/ + +#endif + +