]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed bug with trim.seqs- when a file is blank for a grouping mothur removed it,...
authorwestcott <westcott>
Fri, 17 Dec 2010 13:47:10 +0000 (13:47 +0000)
committerwestcott <westcott>
Fri, 17 Dec 2010 13:47:10 +0000 (13:47 +0000)
38 files changed:
Mothur.xcodeproj/project.pbxproj
calculator.h
canberra.cpp [new file with mode: 0644]
canberra.h [new file with mode: 0644]
collect.cpp
collectdisplay.h
collectorscurvedata.h
collectsharedcommand.cpp
display.h
hamming.cpp [new file with mode: 0644]
hamming.h [new file with mode: 0644]
hellinger.cpp [new file with mode: 0644]
hellinger.h [new file with mode: 0644]
manhattan.cpp [new file with mode: 0644]
manhattan.h [new file with mode: 0644]
mothur
mothurout.cpp
odum.cpp [new file with mode: 0644]
odum.h [new file with mode: 0644]
soergel.cpp [new file with mode: 0644]
soergel.h [new file with mode: 0644]
spearman.cpp [new file with mode: 0644]
spearman.h [new file with mode: 0644]
speciesprofile.cpp [new file with mode: 0644]
speciesprofile.h [new file with mode: 0644]
strictchi2.cpp [new file with mode: 0644]
strictchi2.h [new file with mode: 0644]
strictchord.cpp [new file with mode: 0644]
strictchord.h [new file with mode: 0644]
stricteuclidean.cpp [new file with mode: 0644]
stricteuclidean.h [new file with mode: 0644]
strictkulczynski.cpp [new file with mode: 0644]
strictkulczynski.h [new file with mode: 0644]
strictpearson.cpp [new file with mode: 0644]
strictpearson.h [new file with mode: 0644]
summarysharedcommand.cpp
trimseqscommand.cpp
validcalculator.cpp

index 86fdbc366011e3f8b5578bd9b4f33a4c82b2a01e..c1ab7985173339083b027b13df94194ac6fbd01e 100644 (file)
                A732505F11E49EF100484B90 /* sffinfocommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sffinfocommand.cpp; sourceTree = "<group>"; };
                A73953DA11987ED100B0B160 /* chopseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chopseqscommand.h; sourceTree = "<group>"; };
                A73953DB11987ED100B0B160 /* chopseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chopseqscommand.cpp; sourceTree = "<group>"; };
+               A7460A3F12B8EF1C00866BB6 /* strictchord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strictchord.h; sourceTree = "<group>"; };
+               A7460A4012B8EF1C00866BB6 /* strictchord.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = strictchord.cpp; sourceTree = "<group>"; };
+               A7460A7312B8FCDC00866BB6 /* hellinger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hellinger.h; sourceTree = "<group>"; };
+               A7460A7412B8FCDC00866BB6 /* hellinger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = hellinger.cpp; sourceTree = "<group>"; };
+               A7460A9812B9061B00866BB6 /* manhattan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = manhattan.h; sourceTree = "<group>"; };
+               A7460A9912B9061B00866BB6 /* manhattan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = manhattan.cpp; sourceTree = "<group>"; };
+               A7460AC912B90C5600866BB6 /* strictpearson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strictpearson.h; sourceTree = "<group>"; };
+               A7460ACA12B90C5600866BB6 /* strictpearson.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = strictpearson.cpp; sourceTree = "<group>"; };
+               A7460ADB12B914B700866BB6 /* soergel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = soergel.h; sourceTree = "<group>"; };
+               A7460ADC12B914B700866BB6 /* soergel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = soergel.cpp; sourceTree = "<group>"; };
+               A7460AF712B9218400866BB6 /* spearman.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spearman.h; sourceTree = "<group>"; };
+               A7460AF812B9218400866BB6 /* spearman.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = spearman.cpp; sourceTree = "<group>"; };
+               A7460B3612B9377400866BB6 /* strictkulczynski.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strictkulczynski.h; sourceTree = "<group>"; };
+               A7460B3712B9377400866BB6 /* strictkulczynski.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = strictkulczynski.cpp; sourceTree = "<group>"; };
+               A7460B5912B93F1F00866BB6 /* speciesprofile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = speciesprofile.h; sourceTree = "<group>"; };
+               A7460B5A12B93F1F00866BB6 /* speciesprofile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = speciesprofile.cpp; sourceTree = "<group>"; };
+               A7460B7812B9444800866BB6 /* hamming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hamming.h; sourceTree = "<group>"; };
+               A7460B7912B9444800866BB6 /* hamming.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = hamming.cpp; sourceTree = "<group>"; };
                A747E79B1163442A00FB9042 /* chimeracheckcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimeracheckcommand.h; sourceTree = "<group>"; };
                A747E79C1163442A00FB9042 /* chimeracheckcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimeracheckcommand.cpp; sourceTree = "<group>"; };
                A747E81C116365E000FB9042 /* chimeraslayercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimeraslayercommand.h; sourceTree = "<group>"; };
                A798626E1240D91B005FC847 /* normalizesharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = normalizesharedcommand.cpp; sourceTree = "<group>"; };
                A7AE6302121C3408001DE6FC /* sharedrabundfloatvector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedrabundfloatvector.h; sourceTree = "<group>"; };
                A7AE6303121C3408001DE6FC /* sharedrabundfloatvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedrabundfloatvector.cpp; sourceTree = "<group>"; };
+               A7BB555212BB87F30041F26F /* strictchi2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strictchi2.h; sourceTree = "<group>"; };
+               A7BB555312BB87F30041F26F /* strictchi2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = strictchi2.cpp; sourceTree = "<group>"; };
                A7BBDA7B11B5694E006E6551 /* classifyotucommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = classifyotucommand.h; sourceTree = "<group>"; };
                A7BBDA7C11B5694E006E6551 /* classifyotucommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = classifyotucommand.cpp; sourceTree = "<group>"; };
                A7D215C811996C6E00F13F13 /* clearcutcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clearcutcommand.h; sourceTree = "<group>"; };
                A7DF0AE2121EBB14004A03EA /* prng.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = prng.h; sourceTree = "<group>"; };
                A7E8338B115BBDAA00739EC4 /* parsesffcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parsesffcommand.cpp; sourceTree = "<group>"; };
                A7E8338C115BBDAA00739EC4 /* parsesffcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parsesffcommand.h; sourceTree = "<group>"; };
+               A7F0C06412B7D64F0048BC64 /* odum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = odum.h; sourceTree = "<group>"; };
+               A7F0C06512B7D64F0048BC64 /* odum.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = odum.cpp; sourceTree = "<group>"; };
+               A7F0C08A12B7EAE80048BC64 /* canberra.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = canberra.h; sourceTree = "<group>"; };
+               A7F0C08B12B7EAE80048BC64 /* canberra.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = canberra.cpp; sourceTree = "<group>"; };
+               A7F0C10112B80EEC0048BC64 /* stricteuclidean.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stricteuclidean.h; sourceTree = "<group>"; };
+               A7F0C10212B80EEC0048BC64 /* stricteuclidean.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stricteuclidean.cpp; sourceTree = "<group>"; };
                A7F139481247C3CB0033324C /* splitgroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = splitgroupscommand.h; sourceTree = "<group>"; };
                A7F139491247C3CB0033324C /* splitgroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = splitgroupscommand.cpp; sourceTree = "<group>"; };
                A7F6C8E1124229F900299875 /* fisher2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fisher2.c; sourceTree = "<group>"; };
                                A7DA2006113FECD400BF472F /* bootstrap.h */,
                                A7DA2009113FECD400BF472F /* bstick.cpp */,
                                A7DA200A113FECD400BF472F /* bstick.h */,
+                               A7F0C08A12B7EAE80048BC64 /* canberra.h */,
+                               A7F0C08B12B7EAE80048BC64 /* canberra.cpp */,
                                A7DA200F113FECD400BF472F /* chao1.cpp */,
                                A7DA2010113FECD400BF472F /* chao1.h */,
                                A7DA2033113FECD400BF472F /* coverage.cpp */,
                                A7DA2059113FECD400BF472F /* geom.h */,
                                A7DA206C113FECD400BF472F /* goodscoverage.cpp */,
                                A7DA206D113FECD400BF472F /* goodscoverage.h */,
+                               A7460B7812B9444800866BB6 /* hamming.h */,
+                               A7460B7912B9444800866BB6 /* hamming.cpp */,
                                7E5B2917121FF53C0005339C /* heip.h */,
                                7E5B2918121FF53C0005339C /* heip.cpp */,
+                               A7460A7312B8FCDC00866BB6 /* hellinger.h */,
+                               A7460A7412B8FCDC00866BB6 /* hellinger.cpp */,
                                A7DA2080113FECD400BF472F /* ignoregaps.h */,
                                7E962A40121F76B1007464B5 /* invsimpson.h */,
                                7E962A41121F76B1007464B5 /* invsimpson.cpp */,
                                A7DA2084113FECD400BF472F /* jackknife.h */,
                                A7DA2093113FECD400BF472F /* logsd.cpp */,
                                A7DA2094113FECD400BF472F /* logsd.h */,
+                               A7460A9812B9061B00866BB6 /* manhattan.h */,
+                               A7460A9912B9061B00866BB6 /* manhattan.cpp */,
                                A7DA20AE113FECD400BF472F /* npshannon.cpp */,
                                A7DA20AF113FECD400BF472F /* npshannon.h */,
                                A7DA20B0113FECD400BF472F /* nseqs.h */,
+                               A7F0C06412B7D64F0048BC64 /* odum.h */,
+                               A7F0C06512B7D64F0048BC64 /* odum.cpp */,
                                A7DA20B2113FECD400BF472F /* onegapdist.h */,
                                A7DA20B3113FECD400BF472F /* onegapignore.h */,
                                A72B3A7B118B4D1B004B9F8D /* phylodiversity.h */,
                                7E4EBD44122018FB00D85E7B /* simpsoneven.cpp */,
                                7E5B294A121FFADC0005339C /* smithwilson.h */,
                                7E5B294B121FFADC0005339C /* smithwilson.cpp */,
-                               A7DA2142113FECD400BF472F /* simpson.cpp */,
                                A7DA2143113FECD400BF472F /* simpson.h */,
+                               A7DA2142113FECD400BF472F /* simpson.cpp */,
                                A7DA2149113FECD400BF472F /* sobs.h */,
+                               A7460ADB12B914B700866BB6 /* soergel.h */,
+                               A7460ADC12B914B700866BB6 /* soergel.cpp */,
                                A7DA214A113FECD400BF472F /* solow.cpp */,
                                A7DA214B113FECD400BF472F /* solow.h */,
+                               A7460B5912B93F1F00866BB6 /* speciesprofile.h */,
+                               A7460B5A12B93F1F00866BB6 /* speciesprofile.cpp */,
+                               A7460AF712B9218400866BB6 /* spearman.h */,
+                               A7460AF812B9218400866BB6 /* spearman.cpp */,
+                               A7BB555212BB87F30041F26F /* strictchi2.h */,
+                               A7BB555312BB87F30041F26F /* strictchi2.cpp */,
+                               A7460A3F12B8EF1C00866BB6 /* strictchord.h */,
+                               A7460A4012B8EF1C00866BB6 /* strictchord.cpp */,
+                               A7F0C10112B80EEC0048BC64 /* stricteuclidean.h */,
+                               A7F0C10212B80EEC0048BC64 /* stricteuclidean.cpp */,
+                               A7460B3612B9377400866BB6 /* strictkulczynski.h */,
+                               A7460B3712B9377400866BB6 /* strictkulczynski.cpp */,
+                               A7460AC912B90C5600866BB6 /* strictpearson.h */,
+                               A7460ACA12B90C5600866BB6 /* strictpearson.cpp */,
                                A7DA2160113FECD400BF472F /* treecalculator.h */,
                                A7DA216D113FECD400BF472F /* unweighted.cpp */,
                                A7DA216E113FECD400BF472F /* unweighted.h */,
index 8d9b8f01afcd580b70d92ccd1b83f0208532bb28..3be6488f8ee09be5fd0c3aa85aae960a49edb0de 100644 (file)
@@ -21,9 +21,10 @@ typedef vector<double> EstOutput;
 class Calculator {
 
 public:
-       Calculator(){ m = MothurOut::getInstance();  }
+       Calculator(){ m = MothurOut::getInstance(); needsAll = false; }
        virtual ~Calculator(){};
-       Calculator(string n, int c, bool f) : name(n), cols(c), multiple(f) {};
+       Calculator(string n, int c, bool f) : name(n), cols(c), multiple(f) { m = MothurOut::getInstance(); needsAll = false; };
+       Calculator(string n, int c, bool f, bool a) : name(n), cols(c), multiple(f), needsAll(a) { m = MothurOut::getInstance(); };
        virtual EstOutput getValues(SAbundVector*) = 0; 
        virtual EstOutput getValues(vector<SharedRAbundVector*>) = 0;
        virtual void print(ostream& f)  { f.setf(ios::fixed, ios::floatfield); f.setf(ios::showpoint);
@@ -31,12 +32,14 @@ public:
        virtual string getName()                {       return name;    }
        virtual int getCols()           {       return cols;    }
        virtual bool getMultiple()  {   return multiple;   }
+       virtual bool getNeedsAll()  {   return needsAll;   }
 protected:
        MothurOut* m;
        EstOutput data;
        string name;
        int cols;
        bool multiple;
+       bool needsAll;
 
 };
 
diff --git a/canberra.cpp b/canberra.cpp
new file mode 100644 (file)
index 0000000..2612e16
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ *  canberra.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 12/14/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "canberra.h"
+
+/***********************************************************************/
+
+EstOutput Canberra::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+               data.resize(1,0);
+               
+               int numSharedOTUS = 0;
+               
+               double sum = 0.0;
+               
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       
+                       int Aij = shared[0]->getAbundance(i);
+                       int Bij = shared[1]->getAbundance(i);
+                       
+                       //is this otu shared
+                       if ((Aij != 0) && (Bij != 0)) { numSharedOTUS++; }
+                       
+                       if ((Aij + Bij) != 0) { 
+                               sum += ((abs(Aij - Bij)) / (float) (Aij + Bij));
+                       }
+               }
+               
+               data[0] = (1 / (float) numSharedOTUS) * sum;
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "Canberra", "getValues");
+               exit(1);
+       }
+}
+
+/***********************************************************************/
diff --git a/canberra.h b/canberra.h
new file mode 100644 (file)
index 0000000..94caf85
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef CANBERRA_H
+#define CANBERRA_H
+
+/*
+ *  canberra.h
+ *  Mothur
+ *
+ *  Created by westcott on 12/14/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class Canberra : public Calculator  {
+       
+public:
+       Canberra() :  Calculator("canberra", 1, false) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
+
index 79e997de38bc8938bbcdb72d7134a566a7b9a2bb..ec5366b627d8e8f776ffd00c0bb63f98a748f4bc 100644 (file)
@@ -132,17 +132,25 @@ try {
                                                                //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
 
                                 int n = 1;
+                                                               bool pair = true;
                                 for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
                                         for (int l = n; l < lookup.size(); l++) {
                                                                                                subset.clear(); //clear out old pair of sharedrabunds
                                                                                                //add new pair of sharedrabund vectors
                                                                                                subset.push_back(lookup[k]); subset.push_back(lookup[l]);
-                                                ccd->updateSharedData(subset, i+1, globaldata->Groups.size());
+                                                                                       
+                                                                                               //load subset with rest of lookup for those calcs that need everyone to calc for a pair
+                                                                                               for (int w = 0; w < lookup.size(); w++) {
+                                                                                                       if ((w != k) && (w != l)) { subset.push_back(lookup[w]); }
+                                                                                               }
+                                                                                       
+                                                ccd->updateSharedData(subset, i+1, globaldata->Groups.size(), pair);
                                         }
                                         n++;
                                 }
                                                                //if this is a calculator that can do multiples then do them
-                                                               ccd->updateSharedData(lookup, i+1, globaldata->Groups.size()); 
+                                                               pair = false;
+                                                               ccd->updateSharedData(lookup, i+1, globaldata->Groups.size(), pair); 
                         }
                         totalNumSeq = i+1;
                 }
@@ -151,17 +159,25 @@ try {
                 if(numSeqs % increment != 0){
                         //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
                         int n = 1;
+                                               bool pair = true;
                         for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
                                 for (int l = n; l < lookup.size(); l++) {
                                                                                subset.clear(); //clear out old pair of sharedrabunds
                                                                                //add new pair of sharedrabund vectors
                                                                                subset.push_back(lookup[k]); subset.push_back(lookup[l]);
-                                                                               ccd->updateSharedData(subset, totalNumSeq, globaldata->Groups.size());
+                                                                       
+                                                                               //load subset with rest of lookup for those calcs that need everyone to calc for a pair
+                                                                               for (int w = 0; w < lookup.size(); w++) {
+                                                                                       if ((w != k) && (w != l)) { subset.push_back(lookup[w]); }
+                                                                               }
+                                                                       
+                                                                               ccd->updateSharedData(subset, totalNumSeq, globaldata->Groups.size(), pair);
                                 }
                                 n++;
                         }
                                                //if this is a calculator that can do multiples then do them
-                                               ccd->updateSharedData(lookup, totalNumSeq, globaldata->Groups.size()); 
+                                               pair = false;
+                                               ccd->updateSharedData(lookup, totalNumSeq, globaldata->Groups.size(), pair); 
                 }
                 
                 //resets output files
index d33efe9792332902559d4a600bc3c5581b557185..cf507f16a7d3ce960b3393ed1c751312c08b2094 100644 (file)
@@ -81,6 +81,7 @@ public:
        
        
        bool isCalcMultiple()   { return estimate->getMultiple(); }
+       bool calcNeedsAll()     { return estimate->getNeedsAll(); }
        bool hasLciHci()        {
                if (estimate->getCols() == 3) { return true; } 
                else{ return false; } 
index bde016a62c1c6adbbcc88bfec758530a0840e52d..d32a9e06480c72e5a00e5eaac5a123f407d759c0 100644 (file)
@@ -43,13 +43,23 @@ public:
        void registerDisplay(Display* o)                {       displays.insert(o);                     };
        void removeDisplay(Display* o)                  {       displays.erase(o);      delete o;       };
        void SharedDataChanged()                                {       notifyDisplays();                               };
-       void updateSharedData(vector<SharedRAbundVector*> s, int numSeqs, int numGroupComb)     {       shared = s; NumSeqs = numSeqs; NumGroupComb = numGroupComb; SharedDataChanged();        };
+       void updateSharedData(vector<SharedRAbundVector*> s, int numSeqs, int numGroupComb, bool p)     {       pairs = p; shared = s; NumSeqs = numSeqs; NumGroupComb = numGroupComb; SharedDataChanged();     };
        
        void notifyDisplays(){  
                for(set<Display*>::iterator pos=displays.begin();pos!=displays.end();pos++){
-//cout << (*pos)->getName() << endl;
-                       if ( ( ((*pos)->isCalcMultiple() == true) && ((*pos)->getAll() == true) ) || (shared.size() == 2)  ) {
+                       
+                       if ((*pos)->calcNeedsAll() == true) {
                                (*pos)->update(shared, NumSeqs, NumGroupComb);
+                       }else{
+                               
+                               if ( ((*pos)->isCalcMultiple() == true) && ((*pos)->getAll() == true) && (!pairs) ) {
+                                       (*pos)->update(shared, NumSeqs, NumGroupComb);
+                               }else {
+                                       vector<SharedRAbundVector*> temp; temp.push_back(shared[0]); temp.push_back(shared[1]);
+                                       shared = temp; 
+                                       
+                                       (*pos)->update(shared, NumSeqs, NumGroupComb);
+                               }
                        }
                }       
        };
@@ -59,6 +69,7 @@ private:
        vector<Display*> multiDisplays;
        vector<SharedRAbundVector*> shared;
        int NumSeqs, NumGroupComb;
+       bool pairs;
 };
 
 /***********************************************************************/
index d63930d071da178e5ddcfdb82950ae37b03718cd..f31254828f421629270029c416428858293bfd59 100644 (file)
 #include "sharedbraycurtis.h"
 #include "sharedjackknife.h"
 #include "whittaker.h"
-
+#include "odum.h"
+#include "canberra.h"
+#include "stricteuclidean.h"
+#include "strictchord.h"
+#include "hellinger.h"
+#include "manhattan.h"
+#include "strictpearson.h"
+#include "soergel.h"
+#include "spearman.h"
+#include "strictkulczynski.h"
+#include "speciesprofile.h"
+#include "hamming.h"
 
 //**********************************************************************************************************************
 vector<string> CollectSharedCommand::getValidParameters(){     
@@ -95,6 +106,18 @@ CollectSharedCommand::CollectSharedCommand(){
                outputTypes["lennon"] = tempOutNames;
                outputTypes["morisitahorn"] = tempOutNames;
                outputTypes["braycurtis"] = tempOutNames;
+               outputTypes["odum"] = tempOutNames;
+               outputTypes["canberra"] = tempOutNames;
+               outputTypes["stricteuclidean"] = tempOutNames;
+               outputTypes["strictchord"] = tempOutNames;
+               outputTypes["hellinger"] = tempOutNames;
+               outputTypes["manhattan"] = tempOutNames;
+               outputTypes["strictpearson"] = tempOutNames;
+               outputTypes["soergel"] = tempOutNames;
+               outputTypes["spearman"] = tempOutNames;
+               outputTypes["strictkulczynski"] = tempOutNames;
+               outputTypes["speciesprofile"] = tempOutNames;
+               outputTypes["hamming"] = tempOutNames;
                
        }
        catch(exception& e) {
@@ -153,6 +176,18 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                        outputTypes["lennon"] = tempOutNames;
                        outputTypes["morisitahorn"] = tempOutNames;
                        outputTypes["braycurtis"] = tempOutNames;
+                       outputTypes["odum"] = tempOutNames;
+                       outputTypes["canberra"] = tempOutNames;
+                       outputTypes["stricteuclidean"] = tempOutNames;
+                       outputTypes["strictchord"] = tempOutNames;
+                       outputTypes["hellinger"] = tempOutNames;
+                       outputTypes["manhattan"] = tempOutNames;
+                       outputTypes["strictpearson"] = tempOutNames;
+                       outputTypes["soergel"] = tempOutNames;
+                       outputTypes["spearman"] = tempOutNames;
+                       outputTypes["strictkulczynski"] = tempOutNames;
+                       outputTypes["speciesprofile"] = tempOutNames;
+                       outputTypes["hamming"] = tempOutNames;
 
                        
                        //if the user changes the output directory command factory will send this info to us in the output parameter 
@@ -277,7 +312,44 @@ CollectSharedCommand::CollectSharedCommand(string option)  {
                                                }else if (Estimators[i] == "braycurtis") { 
                                                        cDisplays.push_back(new CollectDisplay(new BrayCurtis(), new SharedOneColumnFile(fileNameRoot+"braycurtis")));
                                                        outputNames.push_back(fileNameRoot+"braycurtis"); outputTypes["braycurtis"].push_back(fileNameRoot+"braycurtis");
+                                               }else if (Estimators[i] == "odum") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Odum(), new SharedOneColumnFile(fileNameRoot+"odum")));
+                                                       outputNames.push_back(fileNameRoot+"odum"); outputTypes["odum"].push_back(fileNameRoot+"odum");
+                                               }else if (Estimators[i] == "canberra") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Canberra(), new SharedOneColumnFile(fileNameRoot+"canberra")));
+                                                       outputNames.push_back(fileNameRoot+"canberra"); outputTypes["canberra"].push_back(fileNameRoot+"canberra");
+                                               }else if (Estimators[i] == "stricteuclidean") { 
+                                                       cDisplays.push_back(new CollectDisplay(new StrictEuclidean(), new SharedOneColumnFile(fileNameRoot+"stricteuclidean")));
+                                                       outputNames.push_back(fileNameRoot+"stricteuclidean"); outputTypes["stricteuclidean"].push_back(fileNameRoot+"stricteuclidean");
+                                               }else if (Estimators[i] == "strictchord") { 
+                                                       cDisplays.push_back(new CollectDisplay(new StrictChord(), new SharedOneColumnFile(fileNameRoot+"strictchord")));
+                                                       outputNames.push_back(fileNameRoot+"strictchord"); outputTypes["strictchord"].push_back(fileNameRoot+"strictchord");
+                                               }else if (Estimators[i] == "hellinger") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Hellinger(), new SharedOneColumnFile(fileNameRoot+"hellinger")));
+                                                       outputNames.push_back(fileNameRoot+"hellinger"); outputTypes["hellinger"].push_back(fileNameRoot+"hellinger");
+                                               }else if (Estimators[i] == "manhattan") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Manhattan(), new SharedOneColumnFile(fileNameRoot+"manhattan")));
+                                                       outputNames.push_back(fileNameRoot+"manhattan"); outputTypes["manhattan"].push_back(fileNameRoot+"manhattan");
+                                               }else if (Estimators[i] == "strictpearson") { 
+                                                       cDisplays.push_back(new CollectDisplay(new StrictPearson(), new SharedOneColumnFile(fileNameRoot+"strictpearson")));
+                                                       outputNames.push_back(fileNameRoot+"strictpearson"); outputTypes["strictpearson"].push_back(fileNameRoot+"strictpearson");
+                                               }else if (Estimators[i] == "soergel") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Soergel(), new SharedOneColumnFile(fileNameRoot+"soergel")));
+                                                       outputNames.push_back(fileNameRoot+"soergel"); outputTypes["soergel"].push_back(fileNameRoot+"soergel");
+                                               }else if (Estimators[i] == "spearman") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Spearman(), new SharedOneColumnFile(fileNameRoot+"spearman")));
+                                                       outputNames.push_back(fileNameRoot+"spearman"); outputTypes["spearman"].push_back(fileNameRoot+"spearman");
+                                               }else if (Estimators[i] == "strictkulczynski") { 
+                                                       cDisplays.push_back(new CollectDisplay(new StrictKulczynski(), new SharedOneColumnFile(fileNameRoot+"strictkulczynski")));
+                                                       outputNames.push_back(fileNameRoot+"strictkulczynski"); outputTypes["strictkulczynski"].push_back(fileNameRoot+"strictkulczynski");
+                                               }else if (Estimators[i] == "speciesprofile") { 
+                                                       cDisplays.push_back(new CollectDisplay(new SpeciesProfile(), new SharedOneColumnFile(fileNameRoot+"speciesprofile")));
+                                                       outputNames.push_back(fileNameRoot+"speciesprofile"); outputTypes["speciesprofile"].push_back(fileNameRoot+"speciesprofile");
+                                               }else if (Estimators[i] == "hamming") { 
+                                                       cDisplays.push_back(new CollectDisplay(new Hamming(), new SharedOneColumnFile(fileNameRoot+"hamming")));
+                                                       outputNames.push_back(fileNameRoot+"hamming"); outputTypes["hamming"].push_back(fileNameRoot+"hamming");
                                                }
+                                               
                                        }
                                }       
                        }
index 806773733d4704aa6432a71f21e2188602853b71..979caa512d2767910f5f5b33cab9024fdc06a648 100644 (file)
--- a/display.h
+++ b/display.h
@@ -23,6 +23,7 @@ public:
        virtual void setAll(bool){}
        virtual bool hasLciHci(){ return false; }
        virtual bool getAll()   {       bool a; return a;       }
+       virtual bool calcNeedsAll()    { bool a; return a;      }
        virtual string getName() { return ""; };
        virtual ~Display() {}
        Display() {  m = MothurOut::getInstance();  }
diff --git a/hamming.cpp b/hamming.cpp
new file mode 100644 (file)
index 0000000..6131bfc
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *  hamming.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "hamming.h"
+
+/***********************************************************************/
+EstOutput Hamming::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+               data.resize(1,0);
+               
+               int numA = 0;
+               int numB = 0;
+               int numShared = 0;
+               
+               //calc the 2 denominators
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       int A = shared[0]->getAbundance(i);
+                       int B = shared[1]->getAbundance(i);
+                       
+                       if (A != 0) { numA++; }
+                       if (B != 0) { numB++; }
+                       if ((A != 0) && (B != 0)) { numShared++; }
+               }
+               
+               data[0] = numA + numB - (2 * numShared);
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "Hamming", "getValues");
+               exit(1);
+       }
+}
+/***********************************************************************/
+
diff --git a/hamming.h b/hamming.h
new file mode 100644 (file)
index 0000000..6d89292
--- /dev/null
+++ b/hamming.h
@@ -0,0 +1,32 @@
+#ifndef HAMMING_H
+#define HAMMING_H
+
+/*
+ *  hamming.h
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class Hamming : public Calculator  {
+       
+public:
+       Hamming() :  Calculator("hamming", 1, false) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
+
diff --git a/hellinger.cpp b/hellinger.cpp
new file mode 100644 (file)
index 0000000..43d33de
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  hellinger.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "hellinger.h"
+
+/***********************************************************************/
+EstOutput Hellinger::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+               data.resize(1,0);
+               
+               double sumA = 0.0;
+               double sumB = 0.0;
+               
+               //calc the 2 denominators
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       sumA += shared[0]->getAbundance(i);
+                       sumB += shared[1]->getAbundance(i);
+               }
+               
+               
+               //calc sum
+               double sum = 0.0;
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       
+                       int Aij = shared[0]->getAbundance(i);
+                       int Bij = shared[1]->getAbundance(i);
+                       
+                       double term1 = sqrt((Aij / sumA));
+                       double term2 = sqrt((Bij / sumB));
+                       
+                       sum += ((term1 - term2) * (term1 - term2));
+               }
+               
+               data[0] = sqrt(sum);
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "Hellinger", "getValues");
+               exit(1);
+       }
+}
+/***********************************************************************/
+
+
diff --git a/hellinger.h b/hellinger.h
new file mode 100644 (file)
index 0000000..6382685
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef HELLINGER_H
+#define HELLINGER_H
+
+/*
+ *  hellinger.h
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class Hellinger : public Calculator  {
+       
+public:
+       Hellinger() :  Calculator("hellinger", 1, false) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
+
+
diff --git a/manhattan.cpp b/manhattan.cpp
new file mode 100644 (file)
index 0000000..134dd91
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *  manhattan.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "manhattan.h"
+
+/***********************************************************************/
+EstOutput Manhattan::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+               data.resize(1,0);
+               
+               double sum = 0.0;
+               
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       
+                       int Aij = shared[0]->getAbundance(i);
+                       int Bij = shared[1]->getAbundance(i);
+                       
+                       sum += abs((Aij - Bij));
+               }
+               
+               data[0] = sum;
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "Manhattan", "getValues");
+               exit(1);
+       }
+}
+/***********************************************************************/
diff --git a/manhattan.h b/manhattan.h
new file mode 100644 (file)
index 0000000..3115da6
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef MANHATTAN_H
+#define MANHATTAN_H
+
+/*
+ *  manhattan.h
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class Manhattan : public Calculator  {
+       
+public:
+       Manhattan() :  Calculator("manhattan", 1, false) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
diff --git a/mothur b/mothur
index b34ee26305ab9c07ec73f682caa1c33ec3608f08..cf280b7d8f8759918e81680e9f5b9154c488ce06 100755 (executable)
Binary files a/mothur and b/mothur differ
index eb452b19a681e5ebe83d71ca7975a4140f703a55..54cf25d891e4528b1a6c1f08bc350a58b8aeb9e6 100644 (file)
@@ -489,6 +489,7 @@ bool MothurOut::isBlank(string fileName){
                        //check for blank file
                        gobble(fileHandle);
                        if (fileHandle.eof()) { fileHandle.close(); return true;  }
+                       fileHandle.close();
                }
                return false;
        }
diff --git a/odum.cpp b/odum.cpp
new file mode 100644 (file)
index 0000000..e9cc5b8
--- /dev/null
+++ b/odum.cpp
@@ -0,0 +1,42 @@
+/*
+ *  odum.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 12/14/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "odum.h"
+
+/***********************************************************************/
+
+EstOutput Odum::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+               data.resize(1,0);
+               
+               double sumNum = 0.0;
+               double sumDenom = 0.0;
+               
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       
+                       int Aij = shared[0]->getAbundance(i);
+                       int Bij = shared[1]->getAbundance(i);
+                       
+                       sumNum += abs(Aij - Bij);
+                       sumDenom += Aij + Bij;
+               }
+               
+               data[0] = sumNum / sumDenom;
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "Odum", "getValues");
+               exit(1);
+       }
+}
+
+/***********************************************************************/
diff --git a/odum.h b/odum.h
new file mode 100644 (file)
index 0000000..14641fd
--- /dev/null
+++ b/odum.h
@@ -0,0 +1,32 @@
+#ifndef ODUM_H
+#define ODUM_H
+
+/*
+ *  odum.h
+ *  Mothur
+ *
+ *  Created by westcott on 12/14/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class Odum : public Calculator  {
+       
+public:
+       Odum() :  Calculator("odum", 1, false) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
+
diff --git a/soergel.cpp b/soergel.cpp
new file mode 100644 (file)
index 0000000..b2fdf84
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  soergel.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "soergel.h"
+
+/***********************************************************************/
+EstOutput Soergel::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+               data.resize(1,0);
+               
+               double sumNum = 0.0;
+               double sumMax = 0.0;
+               
+               //calc the 2 denominators
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       
+                       int Aij = shared[0]->getAbundance(i);
+                       int Bij = shared[1]->getAbundance(i);
+                       
+                       sumNum += abs((Aij - Bij));
+                       sumMax += max(Aij, Bij);
+               }
+               
+               data[0] = sumNum / sumMax;
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "Soergel", "getValues");
+               exit(1);
+       }
+}
+/***********************************************************************/
+
diff --git a/soergel.h b/soergel.h
new file mode 100644 (file)
index 0000000..7156ee7
--- /dev/null
+++ b/soergel.h
@@ -0,0 +1,30 @@
+#ifndef SOERGEL_H
+#define SOERGEL_H
+
+/*
+ *  soergel.h
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class Soergel : public Calculator  {
+       
+public:
+       Soergel() :  Calculator("soergel", 1, false) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
\ No newline at end of file
diff --git a/spearman.cpp b/spearman.cpp
new file mode 100644 (file)
index 0000000..72d5667
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ *  spearman.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "spearman.h"
+
+/***********************************************************************/
+EstOutput Spearman::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+               data.resize(1,0);
+               
+               SAbundVector savA = shared[0]->getSAbundVector();
+               SAbundVector savB = shared[1]->getSAbundVector();
+               
+               double sumRanks = 0.0;
+               int numOTUS = shared[0]->getNumBins();
+               
+               //calc the 2 denominators
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       
+                       int Aij = shared[0]->getAbundance(i);
+                       int Bij = shared[1]->getAbundance(i);
+                       
+                       int rankA = savA.get(Aij);
+                       int rankB = savB.get(Bij);
+                       
+                       sumRanks += ((rankA - rankB) * (rankA - rankB));
+               }
+               
+               data[0] = 1.0 - ((6 * sumRanks) / (float) (numOTUS * (numOTUS-1)));
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "Soergel", "getValues");
+               exit(1);
+       }
+}
+/***********************************************************************/
+
diff --git a/spearman.h b/spearman.h
new file mode 100644 (file)
index 0000000..084514e
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef SPEARMAN_H
+#define SPEARMAN_H
+
+/*
+ *  spearman.h
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class Spearman : public Calculator  {
+       
+public:
+       Spearman() :  Calculator("spearman", 1, false) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
\ No newline at end of file
diff --git a/speciesprofile.cpp b/speciesprofile.cpp
new file mode 100644 (file)
index 0000000..c225a8a
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  speciesprofile.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "speciesprofile.h"
+
+/***********************************************************************/
+EstOutput SpeciesProfile::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+               data.resize(1,0);
+               
+               double sumA = 0.0;
+               double sumB = 0.0;
+               
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       sumA += shared[0]->getAbundance(i);
+                       sumB += shared[1]->getAbundance(i);
+               }
+               
+               double sum = 0.0;
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       int A = shared[0]->getAbundance(i);
+                       int B = shared[1]->getAbundance(i);
+                       
+                       sum += (((A / sumA) - (B / sumB)) * ((A / sumA) - (B / sumB)));
+               }
+               
+               data[0] = sqrt(sum);
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SpeciesProfile", "getValues");
+               exit(1);
+       }
+}
+/***********************************************************************/
+
diff --git a/speciesprofile.h b/speciesprofile.h
new file mode 100644 (file)
index 0000000..1ec8dd6
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef SPECIESPROFILE_H
+#define SPECIESPROFILE_H
+
+/*
+ *  speciesprofile.h
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class SpeciesProfile : public Calculator  {
+       
+public:
+       SpeciesProfile() :  Calculator("speciesprofile", 1, false) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
+
+
diff --git a/strictchi2.cpp b/strictchi2.cpp
new file mode 100644 (file)
index 0000000..9719aa8
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  strictchi2.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 12/17/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "strictchi2.h"
+
+/***********************************************************************/
+EstOutput StrictChi2::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+               data.resize(1,0);
+               
+               double sumA = shared[0]->getNumSeqs();
+               double sumB = shared[1]->getNumSeqs();
+               double totalSum = 0.0;
+               
+               for (int i = 0; i < shared.size(); i++) { totalSum += shared[i]->getNumSeqs();  }
+               
+               vector<int> sumOtus; sumOtus.resize(shared[0]->getNumBins(), 0);
+               //for each otu
+               for (int i = 0; i < shared[0]->getNumBins(); i++) {
+                       //for each group
+                       for (int j = 0; j < shared.size(); j++) { 
+                               
+                       }
+               }
+                               
+               
+                               
+               //data[0] = sqrt(sum);
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "StrictChi2", "getValues");
+               exit(1);
+       }
+}
+/***********************************************************************/
diff --git a/strictchi2.h b/strictchi2.h
new file mode 100644 (file)
index 0000000..1099d73
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef STRICTCHI2_H
+#define STRICTCHI2_H
+
+/*
+ *  strictchi2.h
+ *  Mothur
+ *
+ *  Created by westcott on 12/17/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class StrictChi2 : public Calculator  {
+       
+public:
+       StrictChi2() :  Calculator("strictchi2", 1, false, true) {};  //the true means this calculator needs all groups to calculate the pair value
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
\ No newline at end of file
diff --git a/strictchord.cpp b/strictchord.cpp
new file mode 100644 (file)
index 0000000..ef99354
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ *  strictchord.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "strictchord.h"
+
+/***********************************************************************/
+EstOutput StrictChord::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+               data.resize(1,0);
+               
+               double sumAj2 = 0.0;
+               double sumBj2 = 0.0;
+               
+               //calc the 2 denominators
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       
+                       int Aij = shared[0]->getAbundance(i);
+                       int Bij = shared[1]->getAbundance(i);
+                       
+                       //(Aij) ^ 2
+                       sumAj2 += (Aij * Aij);
+                       sumBj2 += (Bij * Bij);
+               }
+               
+               sumAj2 = sqrt(sumAj2);
+               sumBj2 = sqrt(sumBj2);
+               
+               //calc sum
+               double sum = 0.0;
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       
+                       int Aij = shared[0]->getAbundance(i);
+                       int Bij = shared[1]->getAbundance(i);
+                       
+                       sum += (((Aij / sumAj2) - (Bij / sumBj2)) * ((Aij / sumAj2) - (Bij / sumBj2)));
+               }
+               
+               data[0] = sqrt(sum);
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "StrictChord", "getValues");
+               exit(1);
+       }
+}
+/***********************************************************************/
diff --git a/strictchord.h b/strictchord.h
new file mode 100644 (file)
index 0000000..ef96d82
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef STRICTCHORD_H
+#define STRICTCHORD_H
+
+/*
+ *  strictchord.h
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class StrictChord : public Calculator  {
+       
+public:
+       StrictChord() :  Calculator("strictchord", 1, false) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
+
+
+
diff --git a/stricteuclidean.cpp b/stricteuclidean.cpp
new file mode 100644 (file)
index 0000000..3f40363
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ *  stricteuclidean.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 12/14/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "stricteuclidean.h"
+
+/***********************************************************************/
+EstOutput StrictEuclidean::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+               data.resize(1,0);
+               
+               double sum = 0.0;
+               
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       
+                       int Aij = shared[0]->getAbundance(i);
+                       int Bij = shared[1]->getAbundance(i);
+                       
+                       //(Aij - Bij) ^ 2
+                       sum += ((Aij - Bij) * (Aij - Bij));
+               }
+               
+               data[0] = sqrt(sum);
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "StrictEuclidean", "getValues");
+               exit(1);
+       }
+}
+/***********************************************************************/
+
diff --git a/stricteuclidean.h b/stricteuclidean.h
new file mode 100644 (file)
index 0000000..52f0538
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef STRICTEUCLIDEAN_H
+#define STRICTEUCLIDEAN_H
+
+/*
+ *  stricteuclidean.h
+ *  Mothur
+ *
+ *  Created by westcott on 12/14/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class StrictEuclidean : public Calculator  {
+       
+public:
+       StrictEuclidean() :  Calculator("stricteuclidean", 1, false) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
+
+
diff --git a/strictkulczynski.cpp b/strictkulczynski.cpp
new file mode 100644 (file)
index 0000000..edc2b71
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ *  strictkulczynski.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "strictkulczynski.h"
+
+/***********************************************************************/
+EstOutput StrictKulczynski::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+               data.resize(1,0);
+               
+               double sumA = 0.0;
+               double sumB = 0.0;
+               double sumMin = 0.0;
+               
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       
+                       int A = shared[0]->getAbundance(i);
+                       int B = shared[1]->getAbundance(i);
+                       
+                       sumA += A;
+                       sumB += B;
+                       sumMin += min(A, B);
+               }
+               
+               data[0] = 1.0 - (0.5 * ((sumMin / sumA) + (sumMin / sumB)));
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "StrictKulczynski", "getValues");
+               exit(1);
+       }
+}
+/***********************************************************************/
+
+
diff --git a/strictkulczynski.h b/strictkulczynski.h
new file mode 100644 (file)
index 0000000..c9395de
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef STRICTKULCZYNSKI_H
+#define STRICTKULCZYNSKI_H
+
+/*
+ *  strictkulczynski.h
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class StrictKulczynski : public Calculator  {
+       
+public:
+       StrictKulczynski() :  Calculator("strictkulczynski", 1, false) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
+
+
+
diff --git a/strictpearson.cpp b/strictpearson.cpp
new file mode 100644 (file)
index 0000000..6bfa44f
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ *  strictpearson.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "strictpearson.h"
+
+/***********************************************************************/
+EstOutput StrictPearson::getValues(vector<SharedRAbundVector*> shared) {
+       try {
+               data.resize(1,0);
+               
+               double sumA = 0.0;
+               double sumB = 0.0;
+               int numOTUS = shared[0]->getNumBins();
+               
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       sumA += shared[0]->getAbundance(i);
+                       sumB += shared[1]->getAbundance(i);
+               }
+               
+               double numTerm1 = 0.0;
+               double numTerm2 = 0.0;
+               double denomTerm1 = 0.0;
+               double denomTerm2 = 0.0;
+               
+               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
+                       int Aij =  shared[0]->getAbundance(i);
+                       int Bij =  shared[1]->getAbundance(i);
+                       
+                       numTerm1 += (Aij - (sumA / (float) numOTUS));
+                       numTerm2 += (Bij - (sumB / (float) numOTUS));
+                       
+                       denomTerm1 += ((Aij - (sumA / (float) numOTUS)) * (Aij - (sumA / (float) numOTUS)));
+                       denomTerm2 += ((Bij - (sumB / (float) numOTUS)) * (Bij - (sumB / (float) numOTUS)));
+               }
+               
+               denomTerm1 = sqrt(denomTerm1);
+               denomTerm2 = sqrt(denomTerm2);
+               
+               double denom = denomTerm1 * denomTerm2;
+               double numerator = numTerm1 * numTerm2;
+               
+               data[0] = 1.0 - (numerator / denom);
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "StrictPearson", "getValues");
+               exit(1);
+       }
+}
+/***********************************************************************/
diff --git a/strictpearson.h b/strictpearson.h
new file mode 100644 (file)
index 0000000..70d728d
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef STRICTPEARSON_H
+#define STRICTPEARSON_H
+
+/*
+ *  strictpearson.h
+ *  Mothur
+ *
+ *  Created by westcott on 12/15/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class StrictPearson : public Calculator  {
+       
+public:
+       StrictPearson() :  Calculator("strictpearson", 1, false) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(vector<SharedRAbundVector*>);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
+
+
index 956e0805ee7a20ff5266cf4eba67632dbec7d722..4d982fa630168cf51bb1bfdf5943473795925add 100644 (file)
 #include "sharedbraycurtis.h"
 #include "sharedjackknife.h"
 #include "whittaker.h"
+#include "odum.h"
+#include "canberra.h"
+#include "stricteuclidean.h"
+#include "strictchord.h"
+#include "hellinger.h"
+#include "manhattan.h"
+#include "strictpearson.h"
+#include "soergel.h"
+#include "spearman.h"
+#include "strictkulczynski.h"
+#include "speciesprofile.h"
+#include "hamming.h"
 
 //**********************************************************************************************************************
 vector<string> SummarySharedCommand::getValidParameters(){     
@@ -210,6 +222,30 @@ SummarySharedCommand::SummarySharedCommand(string option)  {
                                                        sumCalculators.push_back(new BrayCurtis());
                                                }else if (Estimators[i] == "whittaker") { 
                                                        sumCalculators.push_back(new Whittaker());
+                                               }else if (Estimators[i] == "odum") { 
+                                                       sumCalculators.push_back(new Odum());
+                                               }else if (Estimators[i] == "canberra") { 
+                                                       sumCalculators.push_back(new Canberra());
+                                               }else if (Estimators[i] == "stricteuclidean") { 
+                                                       sumCalculators.push_back(new StrictEuclidean());
+                                               }else if (Estimators[i] == "strictchord") { 
+                                                       sumCalculators.push_back(new StrictChord());
+                                               }else if (Estimators[i] == "hellinger") { 
+                                                       sumCalculators.push_back(new Hellinger());
+                                               }else if (Estimators[i] == "manhattan") { 
+                                                       sumCalculators.push_back(new Manhattan());
+                                               }else if (Estimators[i] == "strictpearson") { 
+                                                       sumCalculators.push_back(new StrictPearson());
+                                               }else if (Estimators[i] == "soergel") { 
+                                                       sumCalculators.push_back(new Soergel());
+                                               }else if (Estimators[i] == "spearman") { 
+                                                       sumCalculators.push_back(new Spearman());
+                                               }else if (Estimators[i] == "strictkulczynski") { 
+                                                       sumCalculators.push_back(new StrictKulczynski());
+                                               }else if (Estimators[i] == "speciesprofile") { 
+                                                       sumCalculators.push_back(new SpeciesProfile());
+                                               }else if (Estimators[i] == "hamming") { 
+                                                       sumCalculators.push_back(new Hamming());
                                                }
                                        }
                                }
index 5e0541f9cb954575d39d277cdf4a50d6931c21c2..acbead2ed3a77171980ab49e4d8e098dce3c52d8 100644 (file)
@@ -360,10 +360,10 @@ int TrimSeqsCommand::execute(){
                #endif
                
                if (m->control_pressed) {  return 0; }                  
-                                                                               
-               for(int i=0;i<fastaFileNames.size();i++){
                        
-                       if (m->isBlank(fastaFileNames[i])) {  remove(fastaFileNames[i].c_str());        }
+               set<string> blanks;
+               for(int i=0;i<fastaFileNames.size();i++){
+                       if (m->isBlank(fastaFileNames[i])) {   blanks.insert(fastaFileNames[i]);        }
                        else if (filesToRemove.count(fastaFileNames[i]) > 0) {  remove(fastaFileNames[i].c_str()); }
                        else {
                                ifstream inFASTA;
@@ -371,6 +371,10 @@ int TrimSeqsCommand::execute(){
                                m->openInputFile(fastaFileNames[i], inFASTA);
                                ofstream outGroups;
                                string outGroupFilename = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) + "groups";
+                               
+                               //if the fastafile is on the blanks list then the groups file should be as well
+                               if (blanks.count(fastaFileNames[i]) != 0) { blanks.insert(outGroupFilename); }
+                               
                                m->openOutputFile(outGroupFilename, outGroups);
                                outputNames.push_back(outGroupFilename); outputTypes["group"].push_back(outGroupFilename);  
                                
@@ -394,30 +398,17 @@ int TrimSeqsCommand::execute(){
                        }
                }
                
+               for (set<string>::iterator itBlanks = blanks.begin(); itBlanks != blanks.end(); itBlanks++) {  remove((*(itBlanks)).c_str()); }
+               
+               blanks.clear();
                if(qFileName != ""){
                        for(int i=0;i<qualFileNames.size();i++){
-                               if (m->isBlank(qualFileNames[i])) {  remove(qualFileNames[i].c_str());  }
+                               if (m->isBlank(qualFileNames[i])) {  blanks.insert(qualFileNames[i]);   }
                                else if (filesToRemove.count(qualFileNames[i]) > 0) {  remove(qualFileNames[i].c_str()); }
-                               else {
-                                       ifstream inQual;
-                                       string seqName;
-                                       m->openInputFile(qualFileNames[i], inQual);
-//                                     ofstream outGroups;
-//                                     
-//                                     string thisGroup = "";
-//                                     if (i > comboStarts) {
-//                                             map<string, int>::iterator itCombo;
-//                                             for(itCombo=combos.begin();itCombo!=combos.end(); itCombo++){
-//                                                     if(itCombo->second == i){       thisGroup = itCombo->first;     combos.erase(itCombo);  break;  }
-//                                             }
-//                                     }
-//                                     else{ thisGroup = groupVector[i]; }
-                                       
-                                       inQual.close();
-                               }
                        }
                }
                
+               for (set<string>::iterator itBlanks = blanks.begin(); itBlanks != blanks.end(); itBlanks++) {  remove((*(itBlanks)).c_str()); }
                
                if (m->control_pressed) { 
                        for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }
index bc8c4b8d7ab4b753cfa3f75a7c7da0b8ba740bc0..d3a641f0b9c37286d241f126e01d708a144569c6 100644 (file)
@@ -260,6 +260,18 @@ void ValidCalculators::initialShared() {
                shared["lennon"]                                = "lennon";
                shared["morisitahorn"]                  = "morisitahorn";
                shared["braycurtis"]                    = "braycurtis";
+               shared["odum"]                                  = "odum";
+               shared["canberra"]                              = "canberra";
+               shared["stricteuclidean"]               = "stricteuclidean";
+               shared["strictchord"]                   = "strictchord";
+               shared["hellinger"]                             = "hellinger";
+               shared["manhattan"]                             = "manhattan";
+               shared["strictpearson"]                 = "strictpearson";
+               shared["soergel"]                               = "soergel";
+               shared["spearman"]                              = "spearman";
+               shared["strictkulczynski"]              = "strictkulczynski";
+               shared["speciesprofile"]                = "speciesprofile";
+               shared["hamming"]                               = "hamming";
                shared["default"]                   = "default";
        }
        catch(exception& e) {
@@ -338,7 +350,7 @@ void ValidCalculators::initialSharedSummary() {
                sharedsummary["sharedchao"]                             = "sharedchao";
                sharedsummary["sharedace"]                              = "sharedace";
                sharedsummary["jabund"]                                 = "jabund";
-               sharedsummary["sorabund"]                       = "sorabund";
+               sharedsummary["sorabund"]                               = "sorabund";
                sharedsummary["jclass"]                                 = "jclass";
                sharedsummary["sorclass"]                               = "sorclass";
                sharedsummary["jest"]                                   = "jest";
@@ -355,6 +367,18 @@ void ValidCalculators::initialSharedSummary() {
                sharedsummary["lennon"]                                 = "lennon";
                sharedsummary["morisitahorn"]                   = "morisitahorn";
                sharedsummary["braycurtis"]                             = "braycurtis";
+               sharedsummary["odum"]                                   = "odum";
+               sharedsummary["canberra"]                               = "canberra";
+               sharedsummary["stricteuclidean"]                = "stricteuclidean";
+               sharedsummary["strictchord"]                    = "strictchord";
+               sharedsummary["hellinger"]                              = "hellinger";
+               sharedsummary["manhattan"]                              = "manhattan";
+               sharedsummary["strictpearson"]                  = "strictpearson";
+               sharedsummary["strictkulczynski"]               = "strictkulczynski";
+               sharedsummary["soergel"]                                = "soergel";
+               sharedsummary["spearman"]                               = "spearman";
+               sharedsummary["speciesprofile"]                 = "speciesprofile";
+               sharedsummary["hamming"]                                = "hamming";
                sharedsummary["default"]                                = "default";
        }
        catch(exception& e) {