37AD4CE40F28AEA300AA2D49 /* sharedlistvector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AD4CE30F28AEA300AA2D49 /* sharedlistvector.cpp */; };
37AD4DBB0F28E2FE00AA2D49 /* tree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AD4DBA0F28E2FE00AA2D49 /* tree.cpp */; };
37AD4DCA0F28F3DD00AA2D49 /* readtree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AD4DC90F28F3DD00AA2D49 /* readtree.cpp */; };
+ 37AFC71F0F445386005F492D /* sharedsobscollectsummary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AFC71E0F445386005F492D /* sharedsobscollectsummary.cpp */; };
37B28F680F27590100808A62 /* deconvolutecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37B28F670F27590100808A62 /* deconvolutecommand.cpp */; };
37D928550F21331F001D4494 /* ace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927B80F21331F001D4494 /* ace.cpp */; };
37D928560F21331F001D4494 /* averagelinkage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927BA0F21331F001D4494 /* averagelinkage.cpp */; };
37AD4DBA0F28E2FE00AA2D49 /* tree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tree.cpp; sourceTree = "<group>"; };
37AD4DC80F28F3DD00AA2D49 /* readtree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readtree.h; sourceTree = "<group>"; };
37AD4DC90F28F3DD00AA2D49 /* readtree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readtree.cpp; sourceTree = "<group>"; };
+ 37AFC71D0F445386005F492D /* sharedsobscollectsummary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedsobscollectsummary.h; sourceTree = "<group>"; };
+ 37AFC71E0F445386005F492D /* sharedsobscollectsummary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedsobscollectsummary.cpp; sourceTree = "<group>"; };
37B28F660F27590100808A62 /* deconvolutecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deconvolutecommand.h; sourceTree = "<group>"; };
37B28F670F27590100808A62 /* deconvolutecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deconvolutecommand.cpp; sourceTree = "<group>"; };
37D927B80F21331F001D4494 /* ace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ace.cpp; sourceTree = "<group>"; };
37D9282C0F21331F001D4494 /* sharedjest.cpp */,
37D928350F21331F001D4494 /* sharedsobs.h */,
37D928340F21331F001D4494 /* sharedsobs.cpp */,
+ 37AFC71D0F445386005F492D /* sharedsobscollectsummary.h */,
+ 37AFC71E0F445386005F492D /* sharedsobscollectsummary.cpp */,
37D928370F21331F001D4494 /* sharedsorabund.h */,
37D928360F21331F001D4494 /* sharedsorabund.cpp */,
37D928390F21331F001D4494 /* sharedsorclass.h */,
3746107E0F4064D100460C57 /* weighted.cpp in Sources */,
374610830F40652400460C57 /* unweighted.cpp in Sources */,
3746109D0F40657600460C57 /* unifracunweightedcommand.cpp in Sources */,
+ 37AFC71F0F445386005F492D /* sharedsobscollectsummary.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins());
temp->setLabel(sharedorder->getLabel());
temp->setGroup(globaldata->gGroupmap->namesOfGroups[i]);
+ temp->setGroupIndex(globaldata->gGroupmap->groupIndex[globaldata->gGroupmap->namesOfGroups[i]]);
lookup.push_back(temp);
}
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++) {
- ccd->updateSharedData(lookup[k], lookup[l], i+1, numGroupComb);
+ ccd->updateSharedData(lookup[k], lookup[l], i+1, globaldata->gGroupmap->namesOfGroups.size());
}
n++;
}
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++) {
- ccd->updateSharedData(lookup[k], lookup[l], totalNumSeq, numGroupComb);
+ ccd->updateSharedData(lookup[k], lookup[l], totalNumSeq, globaldata->gGroupmap->namesOfGroups.size());
}
n++;
}
output->output(nSeqs, data);
};
- void update(SharedRAbundVector* shared1, SharedRAbundVector* shared2, int numSeqs, int numGroupComb){
+ void update(SharedRAbundVector* shared1, SharedRAbundVector* shared2, int numSeqs, int numGroups){
timesCalled++;
data = estimate->getValues(shared1, shared2); //passes estimators a shared vector from each group to be compared
+
+ //figure out what groups are being compared in getValues
+ //because the jumble parameter randomizes the order we need to put the results in the correct column in the output file
+ int group1Index, group2Index, pos;
+ group1Index = shared1->getGroupIndex();
+ group2Index = shared2->getGroupIndex();
+
+ numGroupComb = 0;
+ int n = 1;
+ for (int i = 0; i < (numGroups - 1); i++) {
+ for (int l = n; l < numGroups; l++) {
+ if ((group1Index == i) && (group2Index == l)) {
+ pos = numGroupComb; //pos tells you which column in the output file you are in
+ }else if ((group1Index == l) && (group2Index == i)) {
+ pos = numGroupComb;
+ }
+ numGroupComb++;
+ }
+ n++;
+ }
+
+ groupData.resize((numGroupComb*data.size()), 0);
+
//fills groupdata with datas info
for (int i = 0; i < data.size(); i++) {
- groupData.push_back(data[i]);
+ groupData[pos+i] = data[i];
}
+
//when you get all your groups info then output
if ((timesCalled % numGroupComb) == 0) {
output->output(numSeqs, groupData);
- groupData.clear();
}
};
private:
Calculator* estimate;
FileOutput* output;
- int nSeqs, timesCalled;
+ int nSeqs, timesCalled, numGroupComb;
vector<double> data;
vector<double> groupData;
};
*/
#include "collectsharedcommand.h"
-#include "sharedsobs.h"
+#include "sharedsobscollectsummary.h"
#include "sharedchao1.h"
#include "sharedace.h"
#include "sharedjabund.h"
if (globaldata->sharedEstimators[i] == "sharedChao") {
cDisplays.push_back(new CollectDisplay(new SharedChao1(), new SharedOneColumnFile(fileNameRoot+"shared.chao")));
}else if (globaldata->sharedEstimators[i] == "sharedSobs") {
- cDisplays.push_back(new CollectDisplay(new SharedSobs(), new SharedOneColumnFile(fileNameRoot+"shared.sobs")));
+ cDisplays.push_back(new CollectDisplay(new SharedSobsCS(), new SharedOneColumnFile(fileNameRoot+"shared.sobs")));
}else if (globaldata->sharedEstimators[i] == "sharedAce") {
cDisplays.push_back(new CollectDisplay(new SharedAce(), new SharedOneColumnFile(fileNameRoot+"shared.ace")));
}else if (globaldata->sharedEstimators[i] == "sharedJabund") {
/*******************************************************/
/******************************************************/
-//This function separates the key value from the option value i.e. distfile = "96_..."
+//This function separates the key value from the option value i.e. dist=96_...
void GlobalData::splitAtEquals(string& key, string& value){
try {
if(value.find_first_of('=') != -1){
GroupMap::GroupMap(string filename) {
groupFileName = filename;
openInputFile(filename, fileHandle);
+ index = 0;
}
/************************************************************/
}
if (count == namesOfGroups.size()) {
namesOfGroups.push_back(seqGroup); //new group
+ groupIndex[seqGroup] = index;
+ index++;
}
}
int getNumGroups();
string getGroup(string);
vector<string> namesOfGroups;
+ map<string, int> groupIndex; //groupname, vectorIndex in namesOfGroups. - used by collectdisplays.
private:
ifstream fileHandle;
string groupFileName;
- int numGroups;
+ int numGroups, index;
map<string, string>::iterator it;
void setNamesOfGroups(string);
map<string, string> groupmap; //sequence name and groupname
void SharedRAbundVector::setGroup(string groupName){
group = groupName;
}
-
+/***********************************************************************/
+int SharedRAbundVector::getGroupIndex() { return index; }
+/***********************************************************************/
+void SharedRAbundVector::setGroupIndex(int vIndex) { index = vIndex; }
/***********************************************************************/
int SharedRAbundVector::getNumBins(){
return numBins;
int getNumSeqs();
int getMaxRank();
string getGroup();
- void setGroup(string);
+ void setGroup(string);
+ int getGroupIndex();
+ void setGroupIndex(int);
void set(int, int, string); //OTU, abundance, groupname
individual get(int);
int maxRank;
int numBins;
int numSeqs;
- string group;
+ string group;
+ int index;
};
*
*/
-/* This class implements the SharedSobs estimator on two groups.
+/* This class implements the SharedSobs estimator on two groups for the shared rarefaction command.
It is a child of the calculator class. */
--- /dev/null
+/*
+ * sharedsobscollectsummary.cpp
+ * Mothur
+ *
+ * Created by Sarah Westcott on 2/12/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "sharedsobscollectsummary.h"
+
+/***********************************************************************/
+//This returns the number of shared species observed in several groups.
+//The shared vector is each groups sharedrabundvector.
+
+EstOutput SharedSobsCS::getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2){
+ try {
+ data.resize(1,0);
+ int observed = 0;
+ int tempA, tempB;
+
+ //loop through the species in each group
+ for (int k = 0; k < shared1->size(); k++) {
+ tempA = shared1->getAbundance(k); //store in temps to avoid calling getAbundance multiple times
+ tempB = shared2->getAbundance(k);
+
+ //if you have found a new species
+ if ((tempA != 0) && (tempB != 0)) {//they are shared
+ observed++;
+ }
+ }
+
+ data[0] = observed;
+ return data;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedSobsCS class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedSobsCS class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+/***********************************************************************/
\ No newline at end of file
--- /dev/null
+#ifndef SHAREDSOBSCOLLECTSUMMARY_H
+#define SHAREDSOBSCOLLECTSUMMARY_H
+
+/*
+ * sharedsobscollectsummary.h
+ * Mothur
+ *
+ * Created by Sarah Westcott on 2/12/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+
+#include "calculator.h"
+
+/***********************************************************************/
+class SharedSobsCS : public Calculator {
+
+public:
+ SharedSobsCS() : Calculator("SharedSobs", 1) {};
+ EstOutput getValues(SAbundVector* rank){ return data; };
+ EstOutput getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2);
+};
+
+/***********************************************************************/
+
+#endif
*/
#include "summarysharedcommand.h"
-#include "sharedsobs.h"
+#include "sharedsobscollectsummary.h"
#include "sharedchao1.h"
#include "sharedace.h"
#include "sharedjabund.h"
int i;
for (i=0; i<globaldata->sharedSummaryEstimators.size(); i++) {
if (globaldata->sharedSummaryEstimators[i] == "sharedSobs") {
- sumCalculators.push_back(new SharedSobs());
+ sumCalculators.push_back(new SharedSobsCS());
}else if (globaldata->sharedSummaryEstimators[i] == "sharedChao") {
sumCalculators.push_back(new SharedChao1());
}else if (globaldata->sharedSummaryEstimators[i] == "sharedAce") {
SharedList = globaldata->gSharedList;
input = globaldata->ginput;
order = SharedList->getSharedOrderVector();
- getGroupComb();
int count = 1;
while(order != NULL){
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' << groupComb[n-1] << '\t' << '\t'; //print out label and group
+ outputFileHandle << order->getLabel() << '\t' << (lookup[k]->getGroup() + lookup[l]->getGroup()) << '\t' << '\t'; //print out label and group
for(int i=0;i<sumCalculators.size();i++){
sumCalculators[i]->getValues(lookup[k], lookup[l]); //saves the calculator outputs
outputFileHandle << '\t';
}
-/**************************************************************************************/
-void SummarySharedCommand::getGroupComb() {
- try {
- string group;
-
- int n = 1;
- for (int i = 0; i < (globaldata->gGroupmap->getNumGroups() - 1); i++) {
- for (int l = n; l < globaldata->gGroupmap->getNumGroups(); l++) {
- group = globaldata->gGroupmap->namesOfGroups[i] + globaldata->gGroupmap->namesOfGroups[l];
- groupComb.push_back(group);
- }
- n++;
- }
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the SummarySharedCommand class Function getGroupComb. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the SummarySharedCommand class function getGroupComb. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-
-}
-
+//**********************************************************************************************************************
int execute();
private:
- void getGroupComb();
void getSharedVectors();
GlobalData* globaldata;
SharedRAbundVector* shared1, shared2;
string outputFileName;
ofstream outputFileHandle;
- vector<string> groupComb;
};