]> git.donarmstrong.com Git - mothur.git/commitdiff
added sharedbraycurtis, sharedmorisirahorn, sharedkulczynski, sharedkulczynskicody...
authorwestcott <westcott>
Tue, 24 Mar 2009 15:11:00 +0000 (15:11 +0000)
committerwestcott <westcott>
Tue, 24 Mar 2009 15:11:00 +0000 (15:11 +0000)
15 files changed:
Mothur.xcodeproj/project.pbxproj
collectsharedcommand.cpp
sharedbraycurtis.cpp [new file with mode: 0644]
sharedbraycurtis.h [new file with mode: 0644]
sharedkulczynski.cpp [new file with mode: 0644]
sharedkulczynski.h [new file with mode: 0644]
sharedkulczynskicody.cpp [new file with mode: 0644]
sharedkulczynskicody.h [new file with mode: 0644]
sharedlennon.cpp [new file with mode: 0644]
sharedlennon.h [new file with mode: 0644]
sharedmorisitahorn.cpp [new file with mode: 0644]
sharedmorisitahorn.h [new file with mode: 0644]
sharedthetayc.cpp
summarysharedcommand.cpp
validcalculator.cpp

index 7e2a8e4ab2789ca0ae233b6bb5d6fa25d07b2902..41493108bc37806da61b2b6e6d09479df92881e9 100644 (file)
@@ -7,6 +7,11 @@
        objects = {
 
 /* Begin PBXBuildFile section */
+               217595330F791EEE001CC3C6 /* sharedkulczynski.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 217595320F791EEE001CC3C6 /* sharedkulczynski.cpp */; };
+               2175953F0F792111001CC3C6 /* sharedkulczynskicody.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2175953E0F792111001CC3C6 /* sharedkulczynskicody.cpp */; };
+               217595590F792490001CC3C6 /* sharedlennon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 217595580F792490001CC3C6 /* sharedlennon.cpp */; };
+               217595640F7927BB001CC3C6 /* sharedmorisitahorn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 217595630F7927BB001CC3C6 /* sharedmorisitahorn.cpp */; };
+               217595710F792A33001CC3C6 /* sharedbraycurtis.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 217595700F792A33001CC3C6 /* sharedbraycurtis.cpp */; };
                372E12700F26365B0095CF7E /* readotucommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 372E126F0F26365B0095CF7E /* readotucommand.cpp */; };
                372E12960F263D5A0095CF7E /* readdistcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 372E12950F263D5A0095CF7E /* readdistcommand.cpp */; };
                372E12ED0F264D320095CF7E /* commandfactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 372E12EC0F264D320095CF7E /* commandfactory.cpp */; };
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
+               217595310F791EEE001CC3C6 /* sharedkulczynski.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedkulczynski.h; sourceTree = "<group>"; };
+               217595320F791EEE001CC3C6 /* sharedkulczynski.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedkulczynski.cpp; sourceTree = "<group>"; };
+               2175953D0F792111001CC3C6 /* sharedkulczynskicody.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedkulczynskicody.h; sourceTree = "<group>"; };
+               2175953E0F792111001CC3C6 /* sharedkulczynskicody.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedkulczynskicody.cpp; sourceTree = "<group>"; };
+               217595570F792490001CC3C6 /* sharedlennon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedlennon.h; sourceTree = "<group>"; };
+               217595580F792490001CC3C6 /* sharedlennon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedlennon.cpp; sourceTree = "<group>"; };
+               217595620F7927BB001CC3C6 /* sharedmorisitahorn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedmorisitahorn.h; sourceTree = "<group>"; };
+               217595630F7927BB001CC3C6 /* sharedmorisitahorn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedmorisitahorn.cpp; sourceTree = "<group>"; };
+               2175956F0F792A33001CC3C6 /* sharedbraycurtis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedbraycurtis.h; sourceTree = "<group>"; };
+               217595700F792A33001CC3C6 /* sharedbraycurtis.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedbraycurtis.cpp; sourceTree = "<group>"; };
                370936DE0F6E7A4A00EB4C2C /* nseqs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nseqs.h; sourceTree = "<group>"; };
                3709370A0F6E7FC100EB4C2C /* sharednseqs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharednseqs.h; sourceTree = "<group>"; };
                372E126E0F26365B0095CF7E /* readotucommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readotucommand.h; sourceTree = "<group>"; };
                                37D928220F21331F001D4494 /* sharedace.cpp */,
                                3765B5140F780A7F00C3EDC5 /* sharedanderberg.h */,
                                3765B5150F780A7F00C3EDC5 /* sharedanderberg.cpp */,
+                               2175956F0F792A33001CC3C6 /* sharedbraycurtis.h */,
+                               217595700F792A33001CC3C6 /* sharedbraycurtis.cpp */,
                                37D928250F21331F001D4494 /* sharedchao1.h */,
                                37D928240F21331F001D4494 /* sharedchao1.cpp */,
                                37D928290F21331F001D4494 /* sharedjabund.h */,
                                37D9282A0F21331F001D4494 /* sharedjclass.cpp */,
                                37D9282D0F21331F001D4494 /* sharedjest.h */,
                                37D9282C0F21331F001D4494 /* sharedjest.cpp */,
+                               217595310F791EEE001CC3C6 /* sharedkulczynski.h */,
+                               217595320F791EEE001CC3C6 /* sharedkulczynski.cpp */,
+                               2175953D0F792111001CC3C6 /* sharedkulczynskicody.h */,
+                               2175953E0F792111001CC3C6 /* sharedkulczynskicody.cpp */,
+                               217595570F792490001CC3C6 /* sharedlennon.h */,
+                               217595580F792490001CC3C6 /* sharedlennon.cpp */,
+                               217595620F7927BB001CC3C6 /* sharedmorisitahorn.h */,
+                               217595630F7927BB001CC3C6 /* sharedmorisitahorn.cpp */,
                                3709370A0F6E7FC100EB4C2C /* sharednseqs.h */,
                                3765B4E00F78055000C3EDC5 /* sharedochiai.h */,
                                3765B4E10F78055000C3EDC5 /* sharedochiai.cpp */,
                                3765B47A0F77D15900C3EDC5 /* nocommands.cpp in Sources */,
                                3765B4E20F78055000C3EDC5 /* sharedochiai.cpp in Sources */,
                                3765B5160F780A7F00C3EDC5 /* sharedanderberg.cpp in Sources */,
+                               217595330F791EEE001CC3C6 /* sharedkulczynski.cpp in Sources */,
+                               2175953F0F792111001CC3C6 /* sharedkulczynskicody.cpp in Sources */,
+                               217595590F792490001CC3C6 /* sharedlennon.cpp in Sources */,
+                               217595640F7927BB001CC3C6 /* sharedmorisitahorn.cpp in Sources */,
+                               217595710F792A33001CC3C6 /* sharedbraycurtis.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 93c15f6d5812ffe1a1c800e36fd55557b004dcf7..6ee2943777f4053bb89f6d86e400269f3af30789 100644 (file)
 #include "sharednseqs.h"
 #include "sharedochiai.h"
 #include "sharedanderberg.h"
+#include "sharedkulczynski.h"
+#include "sharedkulczynskicody.h"
+#include "sharedlennon.h"
+#include "sharedmorisitahorn.h"
+#include "sharedbraycurtis.h"
 
 
 //**********************************************************************************************************************
@@ -65,8 +70,17 @@ CollectSharedCommand::CollectSharedCommand(){
                                        cDisplays.push_back(new CollectDisplay(new SharedOchiai(), new SharedOneColumnFile(fileNameRoot+"shared.ochiai")));
                                }else if (globaldata->Estimators[i] == "sharedanderberg") { 
                                        cDisplays.push_back(new CollectDisplay(new SharedAnderberg(), new SharedOneColumnFile(fileNameRoot+"shared.anderberg")));
+                               }else if (globaldata->Estimators[i] == "sharedkulczynski") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedKulczynski(), new SharedOneColumnFile(fileNameRoot+"shared.kulczynski")));
+                               }else if (globaldata->Estimators[i] == "sharedkulczynskicody") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedKulczynskiCody(), new SharedOneColumnFile(fileNameRoot+"shared.kulczynskicody")));
+                               }else if (globaldata->Estimators[i] == "sharedlennon") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedLennon(), new SharedOneColumnFile(fileNameRoot+"shared.lennon")));
+                               }else if (globaldata->Estimators[i] == "sharedmorisitahorn") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedMorHorn(), new SharedOneColumnFile(fileNameRoot+"shared.morisitahorn")));
+                               }else if (globaldata->Estimators[i] == "sharedbraycurtis") { 
+                                       cDisplays.push_back(new CollectDisplay(new SharedBrayCurtis(), new SharedOneColumnFile(fileNameRoot+"shared.braycurtis")));
                                }
-
                        }
                }
                
diff --git a/sharedbraycurtis.cpp b/sharedbraycurtis.cpp
new file mode 100644 (file)
index 0000000..3cc3177
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ *  sharedbraycurtis.cpp
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/24/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "sharedbraycurtis.h"
+
+/***********************************************************************/
+//This is used by SharedJAbund and SharedSorAbund
+EstOutput SharedBrayCurtis::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+       try {   
+               EstOutput data;
+               data.resize(1,0);
+               
+               int sumSharedA, sumSharedB, sumSharedAB, tempA, tempB;
+               sumSharedA = 0; sumSharedB = 0; sumSharedAB = 0; 
+               
+               /*Xi, Yi = abundance of the ith shared OTU in A and B 
+               sumSharedA = the sum of all shared otus in A
+               sumSharedB = the sum of all shared otus in B
+               sumSharedAB = the sum of the minimum otus int all shared otus in AB.
+               */
+               
+               for (int i = 0; i < shared1->size(); i++) {
+                       //store in temps to avoid multiple repetitive function calls
+                       tempA = shared1->getAbundance(i);
+                       tempB = shared2->getAbundance(i);
+
+                       
+                       if ((tempA != 0) && (tempB != 0)) {//they are shared
+                               sumSharedA += tempA;
+                               sumSharedB += tempB;
+                               
+                               //sum the min of tempA and tempB
+                               if (tempA < tempB) { sumSharedAB += tempA; }
+                               else  { sumSharedAB += tempB; }                         
+                       }
+               }
+               
+               data[0] = (2 * sumSharedAB) / (float)( sumSharedA + sumSharedB);
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+                               
+               return data;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the SharedBrayCurtis class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SharedBrayCurtis class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+
+
+}
+
+/***********************************************************************/
diff --git a/sharedbraycurtis.h b/sharedbraycurtis.h
new file mode 100644 (file)
index 0000000..ba36729
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef SHAREDBRAYCURTIS_H
+#define SHAREDBRAYCURTIS_H
+/*
+ *  sharedbraycurtis.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/24/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+#include "calculator.h"
+
+/***********************************************************************/
+
+class SharedBrayCurtis : public Calculator  {
+       
+public:
+       SharedBrayCurtis() :  Calculator("SharedBrayCurtis", 1) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+private:
+       
+};
+
+/***********************************************************************/
+
+
+
+#endif
diff --git a/sharedkulczynski.cpp b/sharedkulczynski.cpp
new file mode 100644 (file)
index 0000000..30c8c7a
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *  sharedkulczynski.cpp
+ *  Mothur
+ *
+ *  Created by John Westcott on 3/24/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "sharedkulczynski.h"
+
+/***********************************************************************/
+
+EstOutput SharedKulczynski::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+       try {
+               int S1, S2, S12, tempA, tempB;
+               S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
+               
+               /*S1, S2 = number of OTUs observed or estimated in A and B 
+               S12=number of OTUs shared between A and B */
+
+               data.resize(1,0);
+               
+               for (int i = 0; i < shared1->size(); i++) {
+                       //store in temps to avoid multiple repetitive function calls
+                       tempA = shared1->getAbundance(i);
+                       tempB = shared2->getAbundance(i);
+                       
+                       if (tempA != 0) { S1++; }
+                       if (tempB != 0) { S2++; } 
+
+                       //they are shared
+                       if ((tempA != 0) && (tempB != 0)) {     S12++; }
+               }
+               
+               data[0] = S12 / (float)(S1 + S2 - (2 * S12));
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the SharedKulczynski class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SharedKulczynski class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
+/***********************************************************************/
diff --git a/sharedkulczynski.h b/sharedkulczynski.h
new file mode 100644 (file)
index 0000000..91a19ca
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef SHAREDKULCZYNSKI_H
+#define SHAREDKULCZYNSKI_H
+/*
+ *  sharedkulczynski.h
+ *  Mothur
+ *
+ *  Created by John Westcott on 3/24/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class SharedKulczynski : public Calculator  {
+       
+public:
+       SharedKulczynski() :  Calculator("SharedKulczynski", 1) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+private:
+       
+};
+
+/***********************************************************************/
+
+
+
+#endif
\ No newline at end of file
diff --git a/sharedkulczynskicody.cpp b/sharedkulczynskicody.cpp
new file mode 100644 (file)
index 0000000..3de7e76
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *  sharedkulczynskicody.cpp
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/24/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "sharedkulczynskicody.h"
+
+/***********************************************************************/
+
+EstOutput SharedKulczynskiCody::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+       try {
+               int S1, S2, S12, tempA, tempB;
+               S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
+               
+               /*S1, S2 = number of OTUs observed or estimated in A and B 
+               S12=number of OTUs shared between A and B */
+
+               data.resize(1,0);
+               
+               for (int i = 0; i < shared1->size(); i++) {
+                       //store in temps to avoid multiple repetitive function calls
+                       tempA = shared1->getAbundance(i);
+                       tempB = shared2->getAbundance(i);
+                       
+                       if (tempA != 0) { S1++; }
+                       if (tempB != 0) { S2++; } 
+
+                       //they are shared
+                       if ((tempA != 0) && (tempB != 0)) {     S12++; }
+               }
+               
+               data[0] = 0.5 * ((S12 / (float)S1) + (S12 / (float)S2));
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the SharedKulczynskiCody class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SharedKulczynskiCody class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
+/***********************************************************************/
diff --git a/sharedkulczynskicody.h b/sharedkulczynskicody.h
new file mode 100644 (file)
index 0000000..7fb30ce
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef SHAREDKULCZYNSKICODY_H
+#define SHAREDKULCZYNSKICODY_H
+
+/*
+ *  sharedkulczynskicody.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/24/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class SharedKulczynskiCody : public Calculator  {
+       
+public:
+       SharedKulczynskiCody() :  Calculator("SharedKulczynskiCody", 1) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+private:
+       
+};
+
+/***********************************************************************/
+
+
+
+#endif
\ No newline at end of file
diff --git a/sharedlennon.cpp b/sharedlennon.cpp
new file mode 100644 (file)
index 0000000..45dfc6a
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ *  sharedlennon.cpp
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/24/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "sharedlennon.h"
+
+/***********************************************************************/
+
+EstOutput SharedLennon::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+       try {
+               int S1, S2, S12, tempA, tempB, min;
+               S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; min = 0;
+               
+               /*S1, S2 = number of OTUs observed or estimated in A and B 
+               S12=number of OTUs shared between A and B */
+
+               data.resize(1,0);
+               
+               for (int i = 0; i < shared1->size(); i++) {
+                       //store in temps to avoid multiple repetitive function calls
+                       tempA = shared1->getAbundance(i);
+                       tempB = shared2->getAbundance(i);
+                       
+                       if (tempA != 0) { S1++; }
+                       if (tempB != 0) { S2++; } 
+
+                       //they are shared
+                       if ((tempA != 0) && (tempB != 0)) {     S12++; }
+               }
+               
+               
+               tempA = S1 - S12;  tempB = S2 - S12;
+               
+               if (tempA < tempB) { min = tempA; }
+               else { min = tempB; }
+               
+               data[0] = S12 / (float)(S12 + min);
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the SharedLennon class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SharedLennon class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
+/***********************************************************************/
diff --git a/sharedlennon.h b/sharedlennon.h
new file mode 100644 (file)
index 0000000..57a6355
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef SHAREDLENNON_H
+#define SHAREDLENNON_H
+
+/*
+ *  sharedlennon.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/24/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class SharedLennon : public Calculator  {
+       
+public:
+       SharedLennon() :  Calculator("SharedLennon", 1) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+private:
+       
+};
+
+/***********************************************************************/
+
+
+
+#endif
\ No newline at end of file
diff --git a/sharedmorisitahorn.cpp b/sharedmorisitahorn.cpp
new file mode 100644 (file)
index 0000000..6ceac75
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ *  sharedmorisitahorn.cpp
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/24/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "sharedmorisitahorn.h"
+
+/***********************************************************************/
+EstOutput SharedMorHorn::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+       try {   
+               data.resize(1,0);
+               
+               int Atotal, Btotal, tempA, tempB;
+               Atotal = 0; Btotal = 0; 
+               float  morhorn, sumSharedA, sumSharedB, a, b, d;
+               morhorn = 0.0; sumSharedA = 0.0; sumSharedB = 0.0; a = 0.0; b = 0.0; d = 0.0;
+               
+               //get the total values we need to calculate the theta denominator sums
+               for (int i = 0; i < shared1->size(); i++) {
+                       //store in temps to avoid multiple repetitive function calls
+                       Atotal += shared1->getAbundance(i);
+                       Btotal += shared2->getAbundance(i);
+               }
+               
+               //calculate the theta denominator sums
+               for (int j = 0; j < shared1->size(); j++) {
+                       //store in temps to avoid multiple repetitive function calls
+                       tempA = shared1->getAbundance(j);
+                       tempB = shared2->getAbundance(j);
+                       
+                       //they are shared
+                       if ((tempA != 0) && (tempB != 0)) {
+                               if (Atotal != 0)        { sumSharedA = (tempA / (float)Atotal); }
+                               if (Btotal != 0)        { sumSharedB = (tempB / (float)Btotal); }
+                       
+                               a += sumSharedA * sumSharedA;
+                               b += sumSharedB * sumSharedB;
+                               d += sumSharedA * sumSharedB;
+                       }
+               }
+
+               morhorn = (2 * d) / (float) (a + b);
+               
+               if (isnan(morhorn) || isinf(morhorn)) { morhorn = 0; }
+               
+               data[0] = morhorn;
+               
+               return data;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the SharedMorHorn class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SharedMorHorn class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
+/***********************************************************************/
\ No newline at end of file
diff --git a/sharedmorisitahorn.h b/sharedmorisitahorn.h
new file mode 100644 (file)
index 0000000..9c2f755
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef SHAREDMORHORN_H
+#define SHAREDMORHORN_H
+/*
+ *  sharedmorisitahorn.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/24/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class SharedMorHorn : public Calculator  {
+       
+public:
+       SharedMorHorn() :  Calculator("SharedMorisitaHorn", 1) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+private:
+       
+};
+
+/***********************************************************************/
+
+#endif
+
index a055b664728f16c852459da8fc9a0946b093215e..ad2e1c574302b678f9d503dc235ef3b5a6b38db2 100644 (file)
@@ -16,8 +16,8 @@ EstOutput SharedThetaYC::getValues(SharedRAbundVector* shared1, SharedRAbundVect
                
                int Atotal, Btotal, tempA, tempB;
                Atotal = 0; Btotal = 0; 
-               float numerator, denominator, thetaYC, sumSharedA, sumSharedB, a, b, d;
-               numerator = 0.0; denominator = 0.0; thetaYC = 0.0; sumSharedA = 0.0; sumSharedB = 0.0; a = 0.0; b = 0.0; d = 0.0;
+               float thetaYC, sumSharedA, sumSharedB, a, b, d;
+               thetaYC = 0.0; sumSharedA = 0.0; sumSharedB = 0.0; a = 0.0; b = 0.0; d = 0.0;
                
                //get the total values we need to calculate the theta denominator sums
                for (int i = 0; i < shared1->size(); i++) {
index 7698704a44ae46ff5dfd10eb9bde13b56b4c1a08..44bd581929a28ae16890530d4963fba1e730d328 100644 (file)
 #include "sharedthetan.h"
 #include "sharedochiai.h"
 #include "sharedanderberg.h"
+#include "sharedkulczynski.h"
+#include "sharedkulczynskicody.h"
+#include "sharedlennon.h"
+#include "sharedmorisitahorn.h"
+#include "sharedbraycurtis.h"
 
 
 //**********************************************************************************************************************
@@ -65,9 +70,17 @@ SummarySharedCommand::SummarySharedCommand(){
                                        sumCalculators.push_back(new SharedOchiai());
                                }else if (globaldata->Estimators[i] == "sharedanderberg") { 
                                        sumCalculators.push_back(new SharedAnderberg());
+                               }else if (globaldata->Estimators[i] == "sharedkulczynski") { 
+                                       sumCalculators.push_back(new SharedKulczynski());
+                               }else if (globaldata->Estimators[i] == "sharedkulczynskicody") { 
+                                       sumCalculators.push_back(new SharedKulczynskiCody());
+                               }else if (globaldata->Estimators[i] == "sharedlennon") { 
+                                       sumCalculators.push_back(new SharedLennon());
+                               }else if (globaldata->Estimators[i] == "sharedmorisitahorn") { 
+                                       sumCalculators.push_back(new SharedMorHorn());
+                               }else if (globaldata->Estimators[i] == "sharedbraycurtis") { 
+                                       sumCalculators.push_back(new SharedBrayCurtis());
                                }
-
-
                        }
                }
                
index b29ff5797f9db61b3c3cb31e32628cc251c3b95e..0ffa216411077e94a02f69fada77e9421e2d378b 100644 (file)
@@ -164,6 +164,11 @@ void ValidCalculators::initialShared() {
                shared["sharednseqs"]                   = "sharednseqs";
                shared["sharedochiai"]                  = "sharedochiai";
                shared["sharedanderberg"]               = "sharedanderberg";
+               shared["sharedkulczynski"]              = "sharedkulczynski";
+               shared["sharedkulczynskicody"]  = "sharedkulczynskicody";
+               shared["sharedlennon"]                  = "sharedlennon";
+               shared["sharedmorisitahorn"]    = "sharedmorisitahorn";
+               shared["sharedbraycurtis"]              = "sharedbraycurtis";
                shared["default"]                   = "default";
        }
        catch(exception& e) {
@@ -242,6 +247,11 @@ void ValidCalculators::initialSharedSummary() {
                sharedsummary["sharednseqs"]                    = "sharednseqs";
                sharedsummary["sharedochiai"]                   = "sharedochiai";
                sharedsummary["sharedanderberg"]                = "sharedanderberg";
+               sharedsummary["sharedkulczynski"]               = "sharedkulczynski";
+               sharedsummary["sharedkulczynskicody"]   = "sharedkulczynskicody";
+               sharedsummary["sharedlennon"]                   = "sharedlennon";
+               sharedsummary["sharedmorisitahorn"]             = "sharedmorisitahorn";
+               sharedsummary["sharedbraycurtis"]               = "sharedbraycurtis";
                sharedsummary["default"]                                = "default";
        }
        catch(exception& e) {