]> git.donarmstrong.com Git - mothur.git/commitdiff
added sharedochiai and sharedanderberg calculators
authorwestcott <westcott>
Mon, 23 Mar 2009 18:34:44 +0000 (18:34 +0000)
committerwestcott <westcott>
Mon, 23 Mar 2009 18:34:44 +0000 (18:34 +0000)
Mothur.xcodeproj/project.pbxproj
collectsharedcommand.cpp
coverage.cpp
sharedanderberg.cpp [new file with mode: 0644]
sharedanderberg.h [new file with mode: 0644]
sharedochiai.cpp [new file with mode: 0644]
sharedochiai.h [new file with mode: 0644]
summarysharedcommand.cpp
validcalculator.cpp

index 57af531c164b323c10eef636b574d969a7c7ee48..7e2a8e4ab2789ca0ae233b6bb5d6fa25d07b2902 100644 (file)
@@ -17,6 +17,8 @@
                374CD63F0F65832000D90B4A /* libshuffcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 374CD63E0F65832000D90B4A /* libshuffcommand.cpp */; };
                374CD6F10F65A4C100D90B4A /* coverage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 374CD6F00F65A4C100D90B4A /* coverage.cpp */; };
                3765B47A0F77D15900C3EDC5 /* nocommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3765B4780F77D15900C3EDC5 /* nocommands.cpp */; };
+               3765B4E20F78055000C3EDC5 /* sharedochiai.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3765B4E10F78055000C3EDC5 /* sharedochiai.cpp */; };
+               3765B5160F780A7F00C3EDC5 /* sharedanderberg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3765B5150F780A7F00C3EDC5 /* sharedanderberg.cpp */; };
                3782163D0F616079008E1F6D /* fullmatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3782163C0F616079008E1F6D /* fullmatrix.cpp */; };
                379293C30F2DE73400B9034A /* treemap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379293C20F2DE73400B9034A /* treemap.cpp */; };
                379294700F2E191800B9034A /* parsimonycommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3792946F0F2E191800B9034A /* parsimonycommand.cpp */; };
                374CD6F00F65A4C100D90B4A /* coverage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = coverage.cpp; sourceTree = "<group>"; };
                3765B4780F77D15900C3EDC5 /* nocommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = nocommands.cpp; sourceTree = "<group>"; };
                3765B4790F77D15900C3EDC5 /* nocommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nocommands.h; sourceTree = "<group>"; };
+               3765B4E00F78055000C3EDC5 /* sharedochiai.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedochiai.h; sourceTree = "<group>"; };
+               3765B4E10F78055000C3EDC5 /* sharedochiai.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedochiai.cpp; sourceTree = "<group>"; };
+               3765B5140F780A7F00C3EDC5 /* sharedanderberg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedanderberg.h; sourceTree = "<group>"; };
+               3765B5150F780A7F00C3EDC5 /* sharedanderberg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedanderberg.cpp; sourceTree = "<group>"; };
                3782163B0F616079008E1F6D /* fullmatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fullmatrix.h; sourceTree = "<group>"; };
                3782163C0F616079008E1F6D /* fullmatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fullmatrix.cpp; sourceTree = "<group>"; };
                379293C10F2DE73400B9034A /* treemap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = treemap.h; sourceTree = "<group>"; };
                                37D9281E0F21331F001D4494 /* shannon.cpp */,
                                37D928230F21331F001D4494 /* sharedace.h */,
                                37D928220F21331F001D4494 /* sharedace.cpp */,
+                               3765B5140F780A7F00C3EDC5 /* sharedanderberg.h */,
+                               3765B5150F780A7F00C3EDC5 /* sharedanderberg.cpp */,
                                37D928250F21331F001D4494 /* sharedchao1.h */,
                                37D928240F21331F001D4494 /* sharedchao1.cpp */,
                                37D928290F21331F001D4494 /* sharedjabund.h */,
                                37D9282D0F21331F001D4494 /* sharedjest.h */,
                                37D9282C0F21331F001D4494 /* sharedjest.cpp */,
                                3709370A0F6E7FC100EB4C2C /* sharednseqs.h */,
+                               3765B4E00F78055000C3EDC5 /* sharedochiai.h */,
+                               3765B4E10F78055000C3EDC5 /* sharedochiai.cpp */,
                                37D928350F21331F001D4494 /* sharedsobs.h */,
                                37D928340F21331F001D4494 /* sharedsobs.cpp */,
                                37AFC71D0F445386005F492D /* sharedsobscollectsummary.h */,
                                374CD63F0F65832000D90B4A /* libshuffcommand.cpp in Sources */,
                                374CD6F10F65A4C100D90B4A /* coverage.cpp in Sources */,
                                3765B47A0F77D15900C3EDC5 /* nocommands.cpp in Sources */,
+                               3765B4E20F78055000C3EDC5 /* sharedochiai.cpp in Sources */,
+                               3765B5160F780A7F00C3EDC5 /* sharedanderberg.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index e989233c7b86c3efae39d5a7f1b5b0541a365bd5..93c15f6d5812ffe1a1c800e36fd55557b004dcf7 100644 (file)
@@ -20,6 +20,8 @@
 #include "sharedthetayc.h"
 #include "sharedthetan.h"
 #include "sharednseqs.h"
+#include "sharedochiai.h"
+#include "sharedanderberg.h"
 
 
 //**********************************************************************************************************************
@@ -59,6 +61,10 @@ CollectSharedCommand::CollectSharedCommand(){
                                        cDisplays.push_back(new CollectDisplay(new SharedThetaN(), new SharedOneColumnFile(fileNameRoot+"shared.thetan")));
                                }else if (globaldata->Estimators[i] == "sharednseqs") { 
                                        cDisplays.push_back(new CollectDisplay(new SharedNSeqs(), new SharedOneColumnFile(fileNameRoot+"shared.nseqs")));
+                               }else if (globaldata->Estimators[i] == "sharedochiai") { 
+                                       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")));
                                }
 
                        }
index e0f26c944a93c7559a7672320dc513526c9923c5..dea8dff84c4d50676a179f486bd4c805c73c3632 100644 (file)
@@ -100,10 +100,7 @@ void Coverage::getValues(FullMatrix* matrix, vector< vector< vector<float> > >&
                                data[l][k].push_back(0.0);
                        }
                }
-
-               /**************************************/
-               //get the minimums for each comparision
-               /**************************************/
+               
                int count = 0;
                int count2 = 0;
                
@@ -169,7 +166,6 @@ void Coverage::getValues(FullMatrix* matrix, vector< vector< vector<float> > >&
                                                matrix->restore();
                                        }
                                }
-                               
                                count2++;
                        }
                        count += numGroups+1; //go from AA to BB to CC
diff --git a/sharedanderberg.cpp b/sharedanderberg.cpp
new file mode 100644 (file)
index 0000000..52745ec
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *  sharedanderberg.cpp
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/23/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "sharedanderberg.h"
+
+/***********************************************************************/
+
+EstOutput SharedAnderberg::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)((2 * S1) + (2 * S2) - (3 * 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 SharedAnderberg class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SharedAnderberg class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
+/***********************************************************************/
diff --git a/sharedanderberg.h b/sharedanderberg.h
new file mode 100644 (file)
index 0000000..44a1e6d
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef SHAREDANDERBERG_H
+#define SHAREDANDERBERG_H
+/*
+ *  sharedanderberg.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/23/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class SharedAnderberg : public Calculator  {
+       
+public:
+       SharedAnderberg() :  Calculator("SharedAnderberg", 1) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+private:
+       
+};
+
+/***********************************************************************/
+
+
+
+#endif
\ No newline at end of file
diff --git a/sharedochiai.cpp b/sharedochiai.cpp
new file mode 100644 (file)
index 0000000..9a64a2c
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *  sharedochiai.cpp
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/23/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "sharedochiai.h"
+
+/***********************************************************************/
+
+EstOutput SharedOchiai::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)pow((S1 * S2), 0.5));
+               
+               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
+               
+               return data;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the SharedOchiai class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the SharedOchiai class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
+/***********************************************************************/
diff --git a/sharedochiai.h b/sharedochiai.h
new file mode 100644 (file)
index 0000000..27de375
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef SHAREDOCHIAI_H
+#define SHAREDOCHIAI_H
+/*
+ *  sharedochiai.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/23/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class SharedOchiai : public Calculator  {
+       
+public:
+       SharedOchiai() :  Calculator("SharedOchiai", 1) {};
+       EstOutput getValues(SAbundVector*) {return data;};
+       EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
+private:
+       
+};
+
+/***********************************************************************/
+
+
+#endif
\ No newline at end of file
index 9e2c6681afbad503c02f7116bf797ccd99d5e488..7698704a44ae46ff5dfd10eb9bde13b56b4c1a08 100644 (file)
@@ -20,6 +20,8 @@
 #include "sharedsorest.h"
 #include "sharedthetayc.h"
 #include "sharedthetan.h"
+#include "sharedochiai.h"
+#include "sharedanderberg.h"
 
 
 //**********************************************************************************************************************
@@ -59,7 +61,13 @@ SummarySharedCommand::SummarySharedCommand(){
                                        sumCalculators.push_back(new SharedThetaN());
                                }else if (globaldata->Estimators[i] == "sharednseqs") { 
                                        sumCalculators.push_back(new SharedNSeqs());
+                               }else if (globaldata->Estimators[i] == "sharedochiai") { 
+                                       sumCalculators.push_back(new SharedOchiai());
+                               }else if (globaldata->Estimators[i] == "sharedanderberg") { 
+                                       sumCalculators.push_back(new SharedAnderberg());
                                }
+
+
                        }
                }
                
index 7f83ac7107757f35f5e29fe8b4de5b99237f4f8c..b29ff5797f9db61b3c3cb31e32628cc251c3b95e 100644 (file)
@@ -162,6 +162,8 @@ void ValidCalculators::initialShared() {
                shared["sharedthetayc"]                 = "sharedthetayc";
                shared["sharedthetan"]                  = "sharedthetan";
                shared["sharednseqs"]                   = "sharednseqs";
+               shared["sharedochiai"]                  = "sharedochiai";
+               shared["sharedanderberg"]               = "sharedanderberg";
                shared["default"]                   = "default";
        }
        catch(exception& e) {
@@ -238,6 +240,8 @@ void ValidCalculators::initialSharedSummary() {
                sharedsummary["sharedthetayc"]                  = "sharedthetayc";
                sharedsummary["sharedthetan"]                   = "sharedthetan";
                sharedsummary["sharednseqs"]                    = "sharednseqs";
+               sharedsummary["sharedochiai"]                   = "sharedochiai";
+               sharedsummary["sharedanderberg"]                = "sharedanderberg";
                sharedsummary["default"]                                = "default";
        }
        catch(exception& e) {