From: westcott Date: Mon, 16 Mar 2009 13:13:53 +0000 (+0000) Subject: added nseqs and sharednseqs calculators, removed excess tabs in output files. X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=9ca2caadbeac83bb84b3330d9204b1b659d62941 added nseqs and sharednseqs calculators, removed excess tabs in output files. --- diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index b5eaa8b..d72922c 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -115,6 +115,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 370936DE0F6E7A4A00EB4C2C /* nseqs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nseqs.h; sourceTree = ""; }; + 3709370A0F6E7FC100EB4C2C /* sharednseqs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharednseqs.h; sourceTree = ""; }; 372E126E0F26365B0095CF7E /* readotucommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readotucommand.h; sourceTree = ""; }; 372E126F0F26365B0095CF7E /* readotucommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readotucommand.cpp; sourceTree = ""; }; 372E12940F263D5A0095CF7E /* readdistcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readdistcommand.h; sourceTree = ""; }; @@ -419,6 +421,7 @@ 37D927E70F21331F001D4494 /* jackknife.cpp */, 37D927F50F21331F001D4494 /* npshannon.h */, 37D927F40F21331F001D4494 /* npshannon.cpp */, + 370936DE0F6E7A4A00EB4C2C /* nseqs.h */, 379294880F2E258500B9034A /* parsimony.h */, 379294890F2E258500B9034A /* parsimony.cpp */, 37D928020F21331F001D4494 /* rarecalc.h */, @@ -435,6 +438,7 @@ 37D9282A0F21331F001D4494 /* sharedjclass.cpp */, 37D9282D0F21331F001D4494 /* sharedjest.h */, 37D9282C0F21331F001D4494 /* sharedjest.cpp */, + 3709370A0F6E7FC100EB4C2C /* sharednseqs.h */, 37D928350F21331F001D4494 /* sharedsobs.h */, 37D928340F21331F001D4494 /* sharedsobs.cpp */, 37AFC71D0F445386005F492D /* sharedsobscollectsummary.h */, diff --git a/collectcommand.cpp b/collectcommand.cpp index 95a79d5..000f85d 100644 --- a/collectcommand.cpp +++ b/collectcommand.cpp @@ -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"))); diff --git a/collectsharedcommand.cpp b/collectsharedcommand.cpp index e61fb9b..e989233 100644 --- a/collectsharedcommand.cpp +++ b/collectsharedcommand.cpp @@ -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"))); } + } } diff --git a/fullmatrix.cpp b/fullmatrix.cpp index 090e2fe..6151a65 100644 --- a/fullmatrix.cpp +++ b/fullmatrix.cpp @@ -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 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 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 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 diff --git a/parsimonycommand.cpp b/parsimonycommand.cpp index c7340c7..e7d64e5 100644 --- a/parsimonycommand.cpp +++ b/parsimonycommand.cpp @@ -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; diff --git a/rarefactcommand.cpp b/rarefactcommand.cpp index 594b1dd..a83a750 100644 --- a/rarefactcommand.cpp +++ b/rarefactcommand.cpp @@ -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"))); } } } diff --git a/rarefactsharedcommand.cpp b/rarefactsharedcommand.cpp index 58f73f3..6a4fe85 100644 --- a/rarefactsharedcommand.cpp +++ b/rarefactsharedcommand.cpp @@ -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 index 0000000..f2ac5a7 --- /dev/null +++ b/sharednseqs.h @@ -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 diff --git a/summarycommand.cpp b/summarycommand.cpp index 36a4e0e..5adf44f 100644 --- a/summarycommand.cpp +++ b/summarycommand.cpp @@ -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()); } } } diff --git a/summarysharedcommand.cpp b/summarysharedcommand.cpp index 18470d0..9e2c668 100644 --- a/summarysharedcommand.cpp +++ b/summarysharedcommand.cpp @@ -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;igetValues(lookup[k], lookup[l]); //saves the calculator outputs outputFileHandle << '\t'; diff --git a/unifracunweightedcommand.cpp b/unifracunweightedcommand.cpp index cf1cbce..75ab996 100644 --- a/unifracunweightedcommand.cpp +++ b/unifracunweightedcommand.cpp @@ -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; } } diff --git a/unifracweightedcommand.cpp b/unifracweightedcommand.cpp index 69b32aa..7cb8f05 100644 --- a/unifracweightedcommand.cpp +++ b/unifracweightedcommand.cpp @@ -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; diff --git a/validcalculator.cpp b/validcalculator.cpp index e75613f..7f83ac7 100644 --- a/validcalculator.cpp +++ b/validcalculator.cpp @@ -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) {