]> git.donarmstrong.com Git - mothur.git/commitdiff
added nseqs and sharednseqs calculators, removed excess tabs in output files.
authorwestcott <westcott>
Mon, 16 Mar 2009 13:13:53 +0000 (13:13 +0000)
committerwestcott <westcott>
Mon, 16 Mar 2009 13:13:53 +0000 (13:13 +0000)
14 files changed:
Mothur.xcodeproj/project.pbxproj
collectcommand.cpp
collectsharedcommand.cpp
fullmatrix.cpp
nseqs.h [new file with mode: 0644]
parsimonycommand.cpp
rarefactcommand.cpp
rarefactsharedcommand.cpp
sharednseqs.h [new file with mode: 0644]
summarycommand.cpp
summarysharedcommand.cpp
unifracunweightedcommand.cpp
unifracweightedcommand.cpp
validcalculator.cpp

index b5eaa8b0478456464b4098b8a9f05c46f2144923..d72922c68689a444662447f4964f9abcec521993 100644 (file)
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
+               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>"; };
                372E126F0F26365B0095CF7E /* readotucommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readotucommand.cpp; sourceTree = "<group>"; };
                372E12940F263D5A0095CF7E /* readdistcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readdistcommand.h; sourceTree = "<group>"; };
                                37D927E70F21331F001D4494 /* jackknife.cpp */,
                                37D927F50F21331F001D4494 /* npshannon.h */,
                                37D927F40F21331F001D4494 /* npshannon.cpp */,
+                               370936DE0F6E7A4A00EB4C2C /* nseqs.h */,
                                379294880F2E258500B9034A /* parsimony.h */,
                                379294890F2E258500B9034A /* parsimony.cpp */,
                                37D928020F21331F001D4494 /* rarecalc.h */,
                                37D9282A0F21331F001D4494 /* sharedjclass.cpp */,
                                37D9282D0F21331F001D4494 /* sharedjest.h */,
                                37D9282C0F21331F001D4494 /* sharedjest.cpp */,
+                               3709370A0F6E7FC100EB4C2C /* sharednseqs.h */,
                                37D928350F21331F001D4494 /* sharedsobs.h */,
                                37D928340F21331F001D4494 /* sharedsobs.cpp */,
                                37AFC71D0F445386005F492D /* sharedsobscollectsummary.h */,
index 95a79d5bc69f763688915ecb998bd47cff162f1e..000f85d1d91f3922766f024d71dc157640b2eabe 100644 (file)
@@ -10,6 +10,7 @@
 #include "collectcommand.h"
 #include "ace.h"
 #include "sobs.h"
+#include "nseqs.h"
 #include "chao1.h"
 #include "bootstrap.h"
 #include "simpson.h"
@@ -35,8 +36,10 @@ CollectCommand::CollectCommand(){
                                        cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+"sobs")));
                                }else if (globaldata->Estimators[i] == "chao") { 
                                        cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
+                               }else if (globaldata->Estimators[i] == "nseqs") { 
+                                       cDisplays.push_back(new CollectDisplay(new NSeqs(), new OneColumnFile(fileNameRoot+"nseqs")));
                                }else if (globaldata->Estimators[i] == "ace") { 
-                               convert(globaldata->getAbund(), abund);
+                                       convert(globaldata->getAbund(), abund);
                                        cDisplays.push_back(new CollectDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"ace")));
                                }else if (globaldata->Estimators[i] == "jack") { 
                                        cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
index e61fb9bd02bad10c693bab5ce8a54ffa2b66f03f..e989233c7b86c3efae39d5a7f1b5b0541a365bd5 100644 (file)
@@ -19,6 +19,7 @@
 #include "sharedsorest.h"
 #include "sharedthetayc.h"
 #include "sharedthetan.h"
+#include "sharednseqs.h"
 
 
 //**********************************************************************************************************************
@@ -56,7 +57,10 @@ CollectSharedCommand::CollectSharedCommand(){
                                        cDisplays.push_back(new CollectDisplay(new SharedThetaYC(), new SharedOneColumnFile(fileNameRoot+"shared.thetayc")));
                                }else if (globaldata->Estimators[i] == "sharedthetan") { 
                                        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")));
                                }
+
                        }
                }
                
index 090e2fee84b1ee6fcc85382eb6de047fdd43cc22..6151a65202901fa24ec6ff91166017a682483c62 100644 (file)
@@ -255,7 +255,6 @@ void FullMatrix::printMatrix(ostream& out) {
 void FullMatrix::getMinsForRowsVectors(){
        try{
                numGroups = globaldata->gGroupmap->namesOfGroups.size();
-               numUserGroups = globaldata->Groups.size();
                
                //sort globaldata->gGroupmap.namesOfGroups so that it will match the matrix
                sort(globaldata->gGroupmap->namesOfGroups.begin(), globaldata->gGroupmap->namesOfGroups.end());
@@ -263,28 +262,28 @@ void FullMatrix::getMinsForRowsVectors(){
                /*************************************************/
                //find where in matrix each group starts and stops
                /*************************************************/
-               vector<int> bounds;  //bounds[0] = 0, bounds[1] = starting row in matrix from group B, bounds[2] = starting row in matrix from group C, bounds[3] = no need to find C because its numSeqs.
+               vector<int> bounds;  //bounds[1] = starting row in matrix from group B, bounds[2] = starting row in matrix from group C, bounds[3] = no need to find upper bound of C because its numSeqs.
                bounds.resize(numGroups);
                
-               bounds[numGroups] = numSeqs;
+               bounds[0] = 0;
+               bounds[numGroups] = numSeqs-1;
                //for each group find bounds of subgroup/comparison
-               for (int i = 0; i < numGroups; i++) {
+               for (int i = 1; i < numGroups; i++) {
                        getBounds(bounds[i], globaldata->gGroupmap->namesOfGroups[i]);
                }
                
                /************************************************************/
                //fill the minsForRows vectors for each group the user wants
                /************************************************************/
-               int countx = bounds[0]; //where second group starts
-               int county = bounds[0]; 
+               int countx = bounds[1]; //where second group starts
+               int county = bounds[1]; 
                
                //go through the entire matrix
                for (int x = 0; x < numSeqs; x++) {
                        for (int y = 0; y < numSeqs; y++) {
                                //if have not changed groups
                                if ((x < countx) && (y < county)) {
-                                       if (inUsersGroups(index[x].groupname, globaldata->Groups)) {
-                                       }
+                                       
                                }
                        }
                }
diff --git a/nseqs.h b/nseqs.h
new file mode 100644 (file)
index 0000000..0a7b0c3
--- /dev/null
+++ b/nseqs.h
@@ -0,0 +1,33 @@
+#ifndef NSEQS_H
+#define NSEQS_H
+
+/*
+ *  nseqs.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/16/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+
+class NSeqs : public Calculator {
+
+public:
+       NSeqs() : Calculator("NSeqs", 1) {};
+       EstOutput getValues(SAbundVector* rank){
+               data.resize(1,0);
+               data[0] = (double)rank->getNumSeqs();
+               return data;
+       }
+       EstOutput getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {return data;};
+};
+
+/***********************************************************************/
+
+#endif
index c7340c7b1704c585b70e2677c0701aaf7edb4e33..e7d64e5201a5f1e29c3fce9c85d0622793138837 100644 (file)
@@ -237,8 +237,8 @@ void ParsimonyCommand::printUSummaryFile() {
                for (int i = 0; i< T.size(); i++) {
                        for(int a = 0; a < numComp; a++) {
                                if (UScoreSig[a][i] > (1/(float)iters)) {
-                                       outSum << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << '\t' << userTreeScores[a][i] << setprecision(globaldata->getIters().length()) << '\t' << UScoreSig[a][i] << endl;
-                                       cout << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << '\t' << userTreeScores[a][i] << setprecision(globaldata->getIters().length()) << '\t' << UScoreSig[a][i] << endl;
+                                       outSum << setprecision(6) << i+1 << '\t' << groupComb[a]  << '\t' << userTreeScores[a][i] << setprecision(globaldata->getIters().length()) << '\t' << UScoreSig[a][i] << endl;
+                                       cout << setprecision(6) << i+1 << '\t' << groupComb[a]  << '\t' << userTreeScores[a][i] << setprecision(globaldata->getIters().length()) << '\t' << UScoreSig[a][i] << endl;
                                }else {
                                        outSum << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << userTreeScores[a][i] << setprecision(globaldata->getIters().length())  << '\t' << "<" << (1/float(iters)) << endl;
                                        cout << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << userTreeScores[a][i] << setprecision(globaldata->getIters().length()) << '\t' << "<" << (1/float(iters)) << endl;
index 594b1dde19ee6f48bfbe6641133428513c22c27f..a83a750c5944aecfb3e740e5caca8bd231f11148 100644 (file)
@@ -10,6 +10,7 @@
 #include "rarefactcommand.h"
 #include "ace.h"
 #include "sobs.h"
+#include "nseqs.h"
 #include "chao1.h"
 #include "bootstrap.h"
 #include "simpson.h"
@@ -49,6 +50,8 @@ RareFactCommand::RareFactCommand(){
                                        rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"r_simpson")));
                                }else if (globaldata->Estimators[i] == "bootstrap") { 
                                        rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+"r_bootstrap")));
+                               }else if (globaldata->Estimators[i] == "nseqs") { 
+                                       rDisplays.push_back(new RareDisplay(new NSeqs(), new ThreeColumnFile(fileNameRoot+"r_nseqs")));
                                }
                        }
                }
index 58f73f34e45b61b30e5355ebd38cfa63f988448d..6a4fe85b76b56dd5903b98155f0b01121f0f0002 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "rarefactsharedcommand.h"
 #include "sharedsobs.h"
+#include "sharednseqs.h"
 
 //**********************************************************************************************************************
 
@@ -25,7 +26,10 @@ RareFactSharedCommand::RareFactSharedCommand(){
                        if (validCalculator->isValidCalculator("sharedrarefaction", globaldata->Estimators[i]) == true) { 
                                if (globaldata->Estimators[i] == "sharedobserved") { 
                                        rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+"shared.rarefaction", "")));
+                               }else if (globaldata->Estimators[i] == "sharednseqs") { 
+                                       rDisplays.push_back(new RareDisplay(new SharedNSeqs(), new SharedThreeColumnFile(fileNameRoot+"shared.r_nseqs", "")));
                                }
+
                        }
                }
                
diff --git a/sharednseqs.h b/sharednseqs.h
new file mode 100644 (file)
index 0000000..f2ac5a7
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef SHAREDNSEQS_H
+#define SHAREDNSEQS_H
+
+/*
+ *  sharednseqs.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 3/16/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+class SharedNSeqs : public Calculator {
+
+public:
+       SharedNSeqs() : Calculator("SharedNSeqs", 1) {};
+       EstOutput getValues(SAbundVector* rank){ return data; };
+       EstOutput getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
+               data.resize(1,0);
+               data[0] = (double)shared1->getNumSeqs() + (double)shared2->getNumSeqs();
+               return data;
+       }
+};
+
+/***********************************************************************/
+
+#endif
index 36a4e0efb5fc9fdbbe8587eca17886c8b5c55ea4..5adf44ff8621e5ea6e5231abc9417cdb3ff93e80 100644 (file)
@@ -10,6 +10,7 @@
 #include "summarycommand.h"
 #include "ace.h"
 #include "sobs.h"
+#include "nseqs.h"
 #include "chao1.h"
 #include "bootstrap.h"
 #include "simpson.h"
@@ -46,6 +47,8 @@ SummaryCommand::SummaryCommand(){
                                        sumCalculators.push_back(new Simpson());
                                }else if(globaldata->Estimators[i] == "bootstrap"){
                                        sumCalculators.push_back(new Bootstrap());
+                               }else if (globaldata->Estimators[i] == "nseqs") { 
+                                       sumCalculators.push_back(new NSeqs());
                                }
                        }
                }
index 18470d0df300f3b37249b9e4fc7fb05a8211518f..9e2c6681afbad503c02f7116bf797ccd99d5e488 100644 (file)
@@ -11,6 +11,7 @@
 #include "sharedsobscollectsummary.h"
 #include "sharedchao1.h"
 #include "sharedace.h"
+#include "sharednseqs.h"
 #include "sharedjabund.h"
 #include "sharedsorabund.h"
 #include "sharedjclass.h"
@@ -56,6 +57,8 @@ SummarySharedCommand::SummarySharedCommand(){
                                        sumCalculators.push_back(new SharedThetaYC());
                                }else if (globaldata->Estimators[i] == "sharedthetan") { 
                                        sumCalculators.push_back(new SharedThetaN());
+                               }else if (globaldata->Estimators[i] == "sharednseqs") { 
+                                       sumCalculators.push_back(new SharedNSeqs());
                                }
                        }
                }
@@ -128,7 +131,15 @@ int SummarySharedCommand::execute(){
                                int n = 1; 
                                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++) {
-                                               outputFileHandle << order->getLabel() << '\t' << (lookup[k]->getGroup() + lookup[l]->getGroup()) << '\t' << '\t'; //print out label and group
+                                               outputFileHandle << order->getLabel() << '\t';
+                                               
+                                               //sort groups to be alphanumeric
+                                               if (lookup[k]->getGroup() > lookup[l]->getGroup()) {
+                                                       outputFileHandle << (lookup[l]->getGroup() +'\t' + lookup[k]->getGroup()) << '\t'; //print out groups
+                                               }else{
+                                                       outputFileHandle << (lookup[k]->getGroup() +'\t' + lookup[l]->getGroup()) << '\t'; //print out groups
+                                               }
+                                               
                                                for(int i=0;i<sumCalculators.size();i++){
                                                        sumCalculators[i]->getValues(lookup[k], lookup[l]); //saves the calculator outputs
                                                        outputFileHandle << '\t';
index cf1cbce05dfce301409d3b80d861f0fb9dc0a0bd..75ab99682974b3152d3c5020130855788ef5f151 100644 (file)
@@ -168,11 +168,11 @@ void UnifracUnweightedCommand::printUWSummaryFile() {
 
                for(int a = 0; a < numComp; a++) {
                        if (UWScoreSig[a][0] > (1/(float)iters)) {
-                               outSum << setprecision(6) << groupComb[a] << '\t' << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << UWScoreSig[a][0] << endl;
-                               cout << setprecision(6)  << groupComb[a] << '\t' << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << UWScoreSig[a][0] << endl; 
+                               outSum << setprecision(6) << groupComb[a]  << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << UWScoreSig[a][0] << endl;
+                               cout << setprecision(6)  << groupComb[a]  << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << UWScoreSig[a][0] << endl; 
                        }else {
-                               outSum << setprecision(6) << groupComb[a] << '\t' << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << "<" << (1/float(iters)) << endl;
-                               cout << setprecision(6)  << groupComb[a] << '\t' << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << "<" << (1/float(iters)) << endl; 
+                               outSum << setprecision(6) << groupComb[a]  << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << "<" << (1/float(iters)) << endl;
+                               cout << setprecision(6)  << groupComb[a]  << '\t' << utreeScores[a][0] << '\t' << setprecision(globaldata->getIters().length()) << "<" << (1/float(iters)) << endl; 
                        }
                }
                
index 69b32aa11a84f2c435651e52dec92f400a868a8b..7cb8f058e8a36cea95dcefd32196b3acab024b5e 100644 (file)
@@ -175,8 +175,8 @@ void UnifracWeightedCommand::printWSummaryFile() {
                for (int i = 0; i < T.size(); i++) { 
                        for (int j = 0; j < numComp; j++) {
                                if (WScoreSig[count] > (1/(float)iters)) {
-                                       outSum << setprecision(6) << i+1 << '\t' << '\t' << groupComb[j] << '\t' << '\t'  << utreeScores[count] << '\t' << setprecision(globaldata->getIters().length()) << WScoreSig[count] << endl; 
-                                       cout << setprecision(6) << i+1 << '\t' << '\t' << groupComb[j] << '\t' << '\t'  << utreeScores[count] << '\t' << setprecision(globaldata->getIters().length()) << WScoreSig[count] << endl; 
+                                       outSum << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(globaldata->getIters().length()) << WScoreSig[count] << endl; 
+                                       cout << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(globaldata->getIters().length()) << WScoreSig[count] << endl; 
                                }else{
                                        outSum << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(globaldata->getIters().length()) << "<" << (1/float(iters)) << endl; 
                                        cout << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(globaldata->getIters().length()) << "<" << (1/float(iters)) << endl; 
index e75613f3044cb7bb6c6ec1798e850f0617243936..7f83ac7107757f35f5e29fe8b4de5b99237f4f8c 100644 (file)
@@ -126,7 +126,7 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
 void ValidCalculators::initialSingle() {
        try {   
        
-               single["sobs"]  = "sobs";
+               single["sobs"]          = "sobs";
                single["chao"]          = "chao";
                single["ace"]           = "ace";
                single["jack"]          = "jack";
@@ -135,6 +135,7 @@ void ValidCalculators::initialSingle() {
                single["simpson"]       = "simpson";
                single["bootstrap"]     = "bootstrap";
                single["default"]       = "default";
+               single["nseqs"]         = "nseqs";
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -160,6 +161,7 @@ void ValidCalculators::initialShared() {
                shared["sharedsorest"]                  = "sharedsorest";
                shared["sharedthetayc"]                 = "sharedthetayc";
                shared["sharedthetan"]                  = "sharedthetan";
+               shared["sharednseqs"]                   = "sharednseqs";
                shared["default"]                   = "default";
        }
        catch(exception& e) {
@@ -183,6 +185,7 @@ void ValidCalculators::initialRarefaction() {
                rarefaction["npshannon"]        = "npshannon";
                rarefaction["simpson"]          = "simpson";
                rarefaction["bootstrap"]        = "bootstrap";
+               rarefaction["nseqs"]            = "nseqs";
                rarefaction["default"]      = "default";
        }
        catch(exception& e) {
@@ -207,6 +210,7 @@ void ValidCalculators::initialSummary() {
                summary["npshannon"]    = "npshannon";
                summary["simpson"]              = "simpson";
                summary["bootstrap"]    = "bootstrap";
+               summary["nseqs"]                = "nseqs";
                summary["default"]          = "default";
        }
        catch(exception& e) {
@@ -233,6 +237,7 @@ void ValidCalculators::initialSharedSummary() {
                sharedsummary["sharedsorest"]                   = "sharedsorest";
                sharedsummary["sharedthetayc"]                  = "sharedthetayc";
                sharedsummary["sharedthetan"]                   = "sharedthetan";
+               sharedsummary["sharednseqs"]                    = "sharednseqs";
                sharedsummary["default"]                                = "default";
        }
        catch(exception& e) {
@@ -251,6 +256,7 @@ void ValidCalculators::initialSharedSummary() {
 void ValidCalculators::initialSharedRarefact() {
        try {   
                sharedrarefaction["sharedobserved"]     = "sharedobserved";
+               sharedrarefaction["sharednseqs"]        = "sharednseqs";
                sharedrarefaction["default"]        = "default";
        }
        catch(exception& e) {