X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=ignoregaps.h;fp=ignoregaps.h;h=8127b6205e42d18516561565e8a4eb29ccd56ab6;hb=3117b1c3109121dff476997d3c5db5b47a77729b;hp=0000000000000000000000000000000000000000;hpb=a5a908953ab2ebb9386a895e5ddddf0135ad1f99;p=mothur.git diff --git a/ignoregaps.h b/ignoregaps.h new file mode 100644 index 0000000..8127b62 --- /dev/null +++ b/ignoregaps.h @@ -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=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 +