/* Begin PBXBuildFile section */
372E12700F26365B0095CF7E /* readotucommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 372E126F0F26365B0095CF7E /* readotucommand.cpp */; };
372E12960F263D5A0095CF7E /* readdistcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 372E12950F263D5A0095CF7E /* readdistcommand.cpp */; };
- 372E12C10F2648250095CF7E /* readlistcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 372E12C00F2648250095CF7E /* readlistcommand.cpp */; };
372E12ED0F264D320095CF7E /* commandfactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 372E12EC0F264D320095CF7E /* commandfactory.cpp */; };
+ 37AD4CE40F28AEA300AA2D49 /* sharedlistvector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AD4CE30F28AEA300AA2D49 /* sharedlistvector.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 */; };
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>"; };
372E12950F263D5A0095CF7E /* readdistcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readdistcommand.cpp; sourceTree = "<group>"; };
- 372E12BF0F2648250095CF7E /* readlistcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readlistcommand.h; sourceTree = "<group>"; };
- 372E12C00F2648250095CF7E /* readlistcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readlistcommand.cpp; sourceTree = "<group>"; };
372E12EC0F264D320095CF7E /* commandfactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = commandfactory.cpp; sourceTree = "<group>"; };
+ 37AD4CE20F28AEA300AA2D49 /* sharedlistvector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedlistvector.h; sourceTree = "<group>"; };
+ 37AD4CE30F28AEA300AA2D49 /* sharedlistvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedlistvector.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>"; };
372E12950F263D5A0095CF7E /* readdistcommand.cpp */,
372E126E0F26365B0095CF7E /* readotucommand.h */,
372E126F0F26365B0095CF7E /* readotucommand.cpp */,
- 372E12BF0F2648250095CF7E /* readlistcommand.h */,
- 372E12C00F2648250095CF7E /* readlistcommand.cpp */,
37D928270F21331F001D4494 /* sharedcommand.h */,
37D928260F21331F001D4494 /* sharedcommand.cpp */,
37D928470F21331F001D4494 /* summarycommand.h */,
37D927FF0F21331F001D4494 /* rabundvector.cpp */,
37D9281B0F21331F001D4494 /* sabundvector.hpp */,
37D9281A0F21331F001D4494 /* sabundvector.cpp */,
+ 37AD4CE20F28AEA300AA2D49 /* sharedlistvector.h */,
+ 37AD4CE30F28AEA300AA2D49 /* sharedlistvector.cpp */,
37D9282F0F21331F001D4494 /* sharedordervector.h */,
37D9282E0F21331F001D4494 /* sharedordervector.cpp */,
37D928310F21331F001D4494 /* sharedrabundvector.h */,
37D9289F0F21331F001D4494 /* validparameter.cpp in Sources */,
372E12700F26365B0095CF7E /* readotucommand.cpp in Sources */,
372E12960F263D5A0095CF7E /* readdistcommand.cpp in Sources */,
- 372E12C10F2648250095CF7E /* readlistcommand.cpp in Sources */,
372E12ED0F264D320095CF7E /* commandfactory.cpp in Sources */,
37B28F680F27590100808A62 /* deconvolutecommand.cpp in Sources */,
+ 37AD4CE40F28AEA300AA2D49 /* sharedlistvector.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#include <Carbon/Carbon.h>
#include <iostream>
#include <fstream>
+#include "globaldata.hpp"
#include "command.hpp"
#include "rabundvector.hpp"
+#include "sabundvector.hpp"
#include "listvector.hpp"
#include "cluster.hpp"
#include "sparsematrix.hpp"
*/
#include "collectsharedcommand.h"
+#include "sharedsobs.h"
#include "sharedchao1.h"
#include "sharedace.h"
#include "sharedjabund.h"
int i;
for (i=0; i<globaldata->sharedEstimators.size(); i++) {
if (globaldata->sharedEstimators[i] == "sharedChao") {
- cDisplays.push_back(new CollectDisplay(new SharedChao1(), new SharedOneColumnFile(fileNameRoot+"sharedChao", groupmap->namesOfGroups)));
+ cDisplays.push_back(new CollectDisplay(new SharedChao1(), new SharedOneColumnFile(fileNameRoot+"shared.chao", groupmap->namesOfGroups)));
+ }else if (globaldata->sharedEstimators[i] == "sharedSobs") {
+ cDisplays.push_back(new CollectDisplay(new SharedSobs(), new SharedOneColumnFile(fileNameRoot+"shared.sobs", groupmap->namesOfGroups)));
}else if (globaldata->sharedEstimators[i] == "sharedAce") {
- cDisplays.push_back(new CollectDisplay(new SharedAce(), new SharedOneColumnFile(fileNameRoot+"sharedAce", groupmap->namesOfGroups)));
+ cDisplays.push_back(new CollectDisplay(new SharedAce(), new SharedOneColumnFile(fileNameRoot+"shared.ace", groupmap->namesOfGroups)));
}else if (globaldata->sharedEstimators[i] == "sharedJabund") {
- cDisplays.push_back(new CollectDisplay(new SharedJAbund(), new SharedOneColumnFile(fileNameRoot+"SharedJabund", groupmap->namesOfGroups)));
+ cDisplays.push_back(new CollectDisplay(new SharedJAbund(), new SharedOneColumnFile(fileNameRoot+"shared.jabund", groupmap->namesOfGroups)));
}else if (globaldata->sharedEstimators[i] == "sharedSorensonAbund") {
- cDisplays.push_back(new CollectDisplay(new SharedSorAbund(), new SharedOneColumnFile(fileNameRoot+"SharedSorensonAbund", groupmap->namesOfGroups)));
+ cDisplays.push_back(new CollectDisplay(new SharedSorAbund(), new SharedOneColumnFile(fileNameRoot+"shared.sorensonabund", groupmap->namesOfGroups)));
}else if (globaldata->sharedEstimators[i] == "sharedJclass") {
- cDisplays.push_back(new CollectDisplay(new SharedJclass(), new SharedOneColumnFile(fileNameRoot+"SharedJclass", groupmap->namesOfGroups)));
+ cDisplays.push_back(new CollectDisplay(new SharedJclass(), new SharedOneColumnFile(fileNameRoot+"shared.jclass", groupmap->namesOfGroups)));
}else if (globaldata->sharedEstimators[i] == "sharedSorClass") {
- cDisplays.push_back(new CollectDisplay(new SharedSorClass(), new SharedOneColumnFile(fileNameRoot+"SharedSorClass", groupmap->namesOfGroups)));
+ cDisplays.push_back(new CollectDisplay(new SharedSorClass(), new SharedOneColumnFile(fileNameRoot+"shared.sorclass", groupmap->namesOfGroups)));
}else if (globaldata->sharedEstimators[i] == "sharedJest") {
- cDisplays.push_back(new CollectDisplay(new SharedJest(), new SharedOneColumnFile(fileNameRoot+"SharedJest", groupmap->namesOfGroups)));
+ cDisplays.push_back(new CollectDisplay(new SharedJest(), new SharedOneColumnFile(fileNameRoot+"shared.jest", groupmap->namesOfGroups)));
}else if (globaldata->sharedEstimators[i] == "sharedSorEst") {
- cDisplays.push_back(new CollectDisplay(new SharedSorEst(), new SharedOneColumnFile(fileNameRoot+"SharedSorEst", groupmap->namesOfGroups)));
+ cDisplays.push_back(new CollectDisplay(new SharedSorEst(), new SharedOneColumnFile(fileNameRoot+"shared.sorest", groupmap->namesOfGroups)));
}else if (globaldata->sharedEstimators[i] == "SharedThetaYC") {
- cDisplays.push_back(new CollectDisplay(new SharedThetaYC(), new SharedOneColumnFile(fileNameRoot+"SharedThetaYC", groupmap->namesOfGroups)));
+ cDisplays.push_back(new CollectDisplay(new SharedThetaYC(), new SharedOneColumnFile(fileNameRoot+"shared.thetayc", groupmap->namesOfGroups)));
}else if (globaldata->sharedEstimators[i] == "SharedThetaN") {
- cDisplays.push_back(new CollectDisplay(new SharedThetaN(), new SharedOneColumnFile(fileNameRoot+"SharedThetaN", groupmap->namesOfGroups)));
+ cDisplays.push_back(new CollectDisplay(new SharedThetaN(), new SharedOneColumnFile(fileNameRoot+"shared.thetan", groupmap->namesOfGroups)));
}
}
}
read->read(&*globaldata);
input = globaldata->ginput;
- list = globaldata->glist;
- order = list->getSharedOrderVector();
+ SharedList = globaldata->gSharedList;
+ order = SharedList->getSharedOrderVector();
while(order != NULL){
cout << order->getLabel() << '\t' << count << endl;
}
- list = input->getListVector(); //get new list vector to process
- if (list != NULL) {
- order = list->getSharedOrderVector(); //gets new order vector with group info.
+ SharedList = input->getSharedListVector(); //get new list vector to process
+ if (SharedList != NULL) {
+ order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
count++;
}else {
break;
#include <vector>
#include "command.hpp"
#include "sharedordervector.h"
-#include "listvector.hpp"
+#include "sharedlistvector.h"
#include "inputdata.h"
#include "groupmap.h"
#include "collect.h"
private:
GlobalData* globaldata;
GroupMap* groupmap;
- ListVector* list;
+ SharedListVector* SharedList;
ReadMatrix* read;
SharedOrderVector* order;
InputData* input;
#include "command.hpp"
#include "readdistcommand.h"
#include "readotucommand.h"
-#include "readlistcommand.h"
#include "clustercommand.h"
#include "parselistcommand.h"
#include "collectcommand.h"
if(commandName == "read.dist") { command = new ReadDistCommand(); }
else if(commandName == "read.otu") { command = new ReadOtuCommand(); }
- else if(commandName == "read.list") { command = new ReadListFileCommand(); }
else if(commandName == "cluster") { command = new ClusterCommand(); }
else if(commandName == "deconvolute") { command = new DeconvoluteCommand(); }
else if(commandName == "help") { command = new HelpCommand(); }
#include <vector>
#include <map>
+/* This class is parent to listvector, ordervector, rabundvector, sabundvector, sharedordervector, sharedrabundvector, sharedsabundvector.
+ The child classes all contain OTU information in different forms. */
+
+
class RAbundVector;
class SAbundVector;
class OrderVector;
+class SharedListVector;
+class SharedOrderVector;
+class SharedSAbundVector;
+class SharedRAbundVector;
class DataVector {
validateReadFiles();
validateReadDist();
}else if (commandName == "read.otu") {
- validateReadFiles();
- validateReadPhil();
- }else if (commandName == "read.list") {
- validateParseFiles(); //checks the listfile and groupfile parameters
+ //you want to do shared commands
+ if ((listfile != "") && (groupfile != "")) {
+ validateParseFiles(); //checks the listfile and groupfile parameters
+ }else { //you want to do single commands
+ validateReadFiles();
+ validateReadPhil();
+ }
}else if (commandName == "deconvolute") {
validateReadFiles();
}
#include "utilities.hpp"
+/* This class represents the fasta file. It reads a fasta file a populates the internal data structure "data".
+Data is a map where the key is the sequence and the value is a struct containing the sequences groupname,
+a list of the sequences names who have the same sequence and a number of how many sequence names there are. */
+
+
class FastaMap {
public:
void set(string, string, string); //sequencename, groupname, groupnumber, names.
void clear();
int size(); //returns number of unique sequences
- void print(ostream&);
+ void print(ostream&); //produces a 2 column file with the groupname in the first column and the names in the second column.
void readFastaFile(ifstream&);
private:
splitAtComma(value, optionText);
splitAtEquals(key, value);
- if (key == "phylipfile" ) { phylipfile = value; inputFileName = value; fileroot = value; format = "phylip";}
- if (key == "columnfile" ) { columnfile = value; inputFileName = value; fileroot = value; format = "column";}
- if (key == "listfile" ) { listfile = value; inputFileName = value; fileroot = value; format = "list"; }
- if (key == "rabundfile" ) { rabundfile = value; inputFileName = value; fileroot = value; format = "rabund"; }
- if (key == "sabundfile" ) { sabundfile = value; inputFileName = value; fileroot = value; format = "sabund"; }
- if (key == "fastafile" ) { fastafile = value; inputFileName = value; fileroot = value; format = "fasta"; }
- if (key == "namefile" ) { namefile = value; }
- if (key == "orderfile" ) { orderfile = value; }
- if (key == "groupfile" ) { groupfile = value; }
- if (key == "cutoff" ) { cutoff = value; }
- if (key == "precision" ) { precision = value; }
- if (key == "iters" ) { iters = value; }
- if (key == "jumble" ) { jumble = value; }
- if (key == "freq" ) { freq = value; }
- if (key == "method" ) { method = value; }
- if (key == "fileroot" ) { fileroot = value; }
+ if (key == "phylipfile" ) { phylipfile = value; inputFileName = value; fileroot = value; format = "phylip"; }
+ if (key == "columnfile" ) { columnfile = value; inputFileName = value; fileroot = value; format = "column"; }
+ if (key == "listfile" ) { listfile = value; inputFileName = value; fileroot = value; format = "list"; }
+ if (key == "rabundfile" ) { rabundfile = value; inputFileName = value; fileroot = value; format = "rabund"; }
+ if (key == "sabundfile" ) { sabundfile = value; inputFileName = value; fileroot = value; format = "sabund"; }
+ if (key == "fastafile" ) { fastafile = value; inputFileName = value; fileroot = value; format = "fasta"; }
+ if (key == "namefile" ) { namefile = value; }
+ if (key == "orderfile" ) { orderfile = value; }
+ if (key == "groupfile" ) { groupfile = value; }
+ if (key == "cutoff" ) { cutoff = value; }
+ if (key == "precision" ) { precision = value; }
+ if (key == "iters" ) { iters = value; }
+ if (key == "jumble" ) { jumble = value; }
+ if (key == "freq" ) { freq = value; }
+ if (key == "method" ) { method = value; }
+ if (key == "fileroot" ) { fileroot = value; }
if (key == "single") {//stores estimators in a vector
singleEstimators.clear(); //clears out old values
//saves the last parameter
value = optionText;
splitAtEquals(key, value);
- if (key == "phylipfile" ) { phylipfile = value; inputFileName = value; fileroot = value; format = "phylip"; }
- if (key == "columnfile" ) { columnfile = value; inputFileName = value; fileroot = value; format = "column"; }
- if (key == "listfile" ) { listfile = value; inputFileName = value; fileroot = value; format = "list"; }
- if (key == "rabundfile" ) { rabundfile = value; inputFileName = value; fileroot = value; format = "rabund"; }
- if (key == "sabundfile" ) { sabundfile = value; inputFileName = value; fileroot = value; format = "sabund"; }
- if (key == "fastafile" ) { fastafile = value; inputFileName = value; fileroot = value; format = "fasta"; }
- if (key == "namefile" ) { namefile = value; }
- if (key == "orderfile" ) { orderfile = value; }
- if (key == "groupfile" ) { groupfile = value; }
- if (key == "cutoff" ) { cutoff = value; }
- if (key == "precision" ) { precision = value; }
- if (key == "iters" ) { iters = value; }
- if (key == "jumble" ) { jumble = value; }
- if (key == "freq" ) { freq = value; }
- if (key == "method" ) { method = value; }
- if (key == "fileroot" ) { fileroot = value; }
+ if (key == "phylipfile" ) { phylipfile = value; inputFileName = value; fileroot = value; format = "phylip"; }
+ if (key == "columnfile" ) { columnfile = value; inputFileName = value; fileroot = value; format = "column"; }
+ if (key == "listfile" ) { listfile = value; inputFileName = value; fileroot = value; format = "list"; }
+ if (key == "rabundfile" ) { rabundfile = value; inputFileName = value; fileroot = value; format = "rabund"; }
+ if (key == "sabundfile" ) { sabundfile = value; inputFileName = value; fileroot = value; format = "sabund"; }
+ if (key == "fastafile" ) { fastafile = value; inputFileName = value; fileroot = value; format = "fasta"; }
+ if (key == "namefile" ) { namefile = value; }
+ if (key == "orderfile" ) { orderfile = value; }
+ if (key == "groupfile" ) { groupfile = value; }
+ if (key == "cutoff" ) { cutoff = value; }
+ if (key == "precision" ) { precision = value; }
+ if (key == "iters" ) { iters = value; }
+ if (key == "jumble" ) { jumble = value; }
+ if (key == "freq" ) { freq = value; }
+ if (key == "method" ) { method = value; }
+ if (key == "fileroot" ) { fileroot = value; }
if (key == "single") {//stores estimators in a vector
singleEstimators.clear(); //clears out old values
}
}
+ //set format for shared
+ if ((listfile != "") && (groupfile != "")) { format = "shared"; }
//input defaults
if (commandString == "collect.single") {
fileroot = "";
single = "sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson-rarefraction";
rarefaction = "rarefaction";
- shared = "sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN";
- sharedsummary = "sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN";
+ shared = "sharedSobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN";
+ sharedsummary = "sharedSobs-sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN";
summary = "summary-chao-ace-jack-bootstrap-shannon-npshannon-simpson";
sharedrarefaction = "sharedobserved";
}
using namespace std;
class ListVector;
+class SharedListVector;
class SparseMatrix;
class OrderVector;
class InputData;
InputData* ginput;
OrderVector* gorder;
ListVector* glist;
+ SharedListVector* gSharedList;
SAbundVector* sabund;
GroupMap* gGroupmap;
string inputFileName, helpRequest, commandName;
ListVector* InputData::getListVector(){
try {
if(fileHandle){
- if((format == "list") || (format == "shared")){
+ if(format == "list") {
list = new ListVector(fileHandle);
}
}
}
+/***********************************************************************/
+
+SharedListVector* InputData::getSharedListVector(){
+ try {
+ if(fileHandle){
+ if (format == "shared"){
+ SharedList = new SharedListVector(fileHandle);
+ }
+
+ gobble(fileHandle);
+ return SharedList;
+ }
+ else{
+ return 0;
+ }
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the InputData class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the InputData class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
/***********************************************************************/
OrderVector* InputData::getOrderVector(){
try {
if(fileHandle){
- if((format == "list") || (format == "shared")){
+ if(format == "list") {
input = new ListVector(fileHandle);
}
+ else if(format == "shared") {
+ input = new SharedListVector(fileHandle);
+ }
else if(format == "rabund"){
input = new RAbundVector(fileHandle);
}
SAbundVector* InputData::getSAbundVector(){
try {
if(fileHandle){
- if((format == "list") || (format == "shared")){
+ if (format == "list") {
input = new ListVector(fileHandle);
}
+ else if(format == "shared") {
+ input = new SharedListVector(fileHandle);
+ }
else if(format == "rabund"){
input = new RAbundVector(fileHandle);
}
#include <string>
#include <fstream>
#include "ordervector.hpp"
+#include "sharedlistvector.h"
#include "listvector.hpp"
InputData(string, string, string);
~InputData();
ListVector* getListVector();
+ SharedListVector* getSharedListVector();
OrderVector* getOrderVector();
SAbundVector* getSAbundVector();
ifstream fileHandle;
DataVector* input;
ListVector* list;
+ SharedListVector* SharedList;
OrderVector* output;
SAbundVector* sabund;
map<string,int> orderMap;
}
}
-/***********************************************************************/
-SharedOrderVector* ListVector::getSharedOrderVector(){
- globaldata = GlobalData::getInstance();
- string groupName, names, name;
- groupmap = globaldata->gGroupmap;
- SharedOrderVector* order;
- order = new SharedOrderVector();
- order->setLabel(label);
-
- for(int i=0;i<numBins;i++){
- int binSize = getNumNames(get(i)); //find number of individual in given bin
- names = get(i);
- while (names.find_first_of(',') != -1) {
- name = names.substr(0,names.find_first_of(','));
- names = names.substr(names.find_first_of(',')+1, names.length());
- groupName = groupmap->getGroup(name);
- order->push_back(i, binSize, groupName); //i represents what bin you are in
- }
- //get last name
- groupName = groupmap->getGroup(names);
- order->push_back(i, binSize, groupName);
- }
- random_shuffle(order->begin(), order->end());
- return order;
-}
-
/***********************************************************************/
OrderVector ListVector::getOrderVector(map<string,int>* orderMap = NULL){
#ifndef LIST_H
#define LIST_H
+#include <Carbon/Carbon.h>
#include "datavector.hpp"
-#include "groupmap.h"
-#include "globaldata.hpp"
-#include "sharedordervector.h"
#include <iostream>
#include <map>
+/* This class is a child to datavector. It represents OTU information at a certain distance.
+ A list vector can be converted into and ordervector, rabundvector or sabundvector.
+ Each member of the internal container "data" represents an individual OTU.
+ So data[0] = "a,b,c,d,e,f".
+ example: listvector = a,b,c,d,e,f g,h,i j,k l m
+ rabundvector = 6 3 2 1 1
+ sabundvector = 2 1 1 0 0 1
+ ordervector = 1 1 1 1 1 1 2 2 2 3 3 4 5 */
class ListVector : public DataVector {
RAbundVector getRAbundVector();
SAbundVector getSAbundVector();
OrderVector getOrderVector(map<string,int>*);
- SharedOrderVector* getSharedOrderVector();
private:
- vector<string> data;
- GlobalData* globaldata;
- GroupMap* groupmap;
+ vector<string> data; //data[i] is a list of names of sequences in the ith OTU.
int maxRank;
int numBins;
int numSeqs;
#include "sabundvector.hpp"
#include "rabundvector.hpp"
+/* This class is a child to datavector. It represents OTU information at a certain distance.
+ A order vector can be converted into and listvector, rabundvector or sabundvector.
+ Each member of the internal container "data" represents the OTU from which it came.
+ So in the example below since there are 6 sequences in OTU 1 there are six 1's in the ordervector.
+ and since there are 2 sequences in OTU 3 there are two 3's in the ordervector.
+ example: listvector = a,b,c,d,e,f g,h,i j,k l m
+ rabundvector = 6 3 2 1 1
+ sabundvector = 2 1 1 0 0 1
+ ordervector = 1 1 1 1 1 1 2 2 2 3 3 4 5 */
+
class OrderVector : public DataVector {
#include "datavector.hpp"
+/* This class is a child to datavector. It represents OTU information at a certain distance.
+ A rabundvector can be converted into and ordervector, listvector or sabundvector.
+ Each member of the internal container "data" represents an individual OTU.
+ So data[0] = 6, because there are six member in that OTU.
+ example: listvector = a,b,c,d,e,f g,h,i j,k l m
+ rabundvector = 6 3 2 1 1
+ sabundvector = 2 1 1 0 0 1
+ ordervector = 1 1 1 1 1 1 2 2 2 3 3 4 5 */
+
class RAbundVector : public DataVector {
public:
int i;
for (i=0; i<globaldata->sharedRareEstimators.size(); i++) {
if (globaldata->sharedRareEstimators[i] == "sharedobserved") {
- rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+"sharedObserved", groups)));
+ rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+"r_shared.observed", groups)));
}
}
}
read->read(&*globaldata);
input = globaldata->ginput;
- list = globaldata->glist;
- order = list->getSharedOrderVector();
+ SharedList = globaldata->gSharedList;
+ order = SharedList->getSharedOrderVector();
while(order != NULL){
cout << order->getLabel() << '\t' << count << endl;
}
- list = input->getListVector(); //get new list vector to process
- if (list != NULL) {
- order = list->getSharedOrderVector(); //gets new order vector with group info.
+ SharedList = input->getSharedListVector(); //get new list vector to process
+ if (SharedList != NULL) {
+ order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
count++;
}else {
break;
#include <vector>
#include "command.hpp"
#include "sharedordervector.h"
-#include "listvector.hpp"
+#include "sharedlistvector.h"
#include "inputdata.h"
#include "groupmap.h"
#include "rarefact.h"
private:
GlobalData* globaldata;
GroupMap* groupmap;
- ListVector* list;
+ SharedListVector* SharedList;
ReadMatrix* read;
SharedOrderVector* order;
InputData* input;
+++ /dev/null
-/*
- * readlistcommand.h
- * Mothur
- *
- * Created by Sarah Westcott on 1/20/09.
- * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#ifndef READLISTFILECOMMAND_H
-#define READLISTFILECOMMAND_H
-/*
- * readlistcommand.h
- * Mothur
- *
- * Created by Sarah Westcott on 1/20/09.
- * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include <Carbon/Carbon.h>
-#include <iostream>
-#include <fstream>
-#include "command.hpp"
-#include "readmatrix.hpp"
-#include "inputdata.h"
-#include "groupmap.h"
-#include "sharedcommand.h"
-#include "parselistcommand.h"
-
-
-/* The read.list command parameter options are listfile and groupfile.
-The read.list command should be in the following format:
-read.shared(listfile=yourListFile, groupfile=yourGroupFile).
-The listfile parameter and groupfile paramaters are required. */
-
-
-class GlobalData;
-
-class ReadListFileCommand : public Command {
-public:
- ReadListFileCommand();
- ~ReadListFileCommand();
- int execute();
-
-private:
- GlobalData* globaldata;
- Command* shared;
- Command* parselist;
- GroupMap* groupMap;
- ReadMatrix* read;
- InputData* input;
- string filename;
-};
-
-#endif
\ No newline at end of file
sabund = inputSabund->getSAbundVector();
globaldata->sabund = sabund; //saving to be used by summary command.
}else {
- list = input->getListVector(); //you are reading for parselist command, or shared commands.
- globaldata->glist = list;
+ SharedList = input->getSharedListVector(); //you are reading for parselist command, or shared commands.
+ globaldata->gSharedList = SharedList;
}
}
catch(exception& e) {
#include "rabundvector.hpp"
#include "listvector.hpp"
+#include "sharedlistvector.h"
#include "sparsematrix.hpp"
#include "nameassignment.hpp"
#include "inputdata.h"
InputData* input;
InputData* inputSabund;
ListVector* list;
+ SharedListVector* SharedList;
OrderVector* order;
SAbundVector* sabund;
GlobalData* globaldata;
globaldata = GlobalData::getInstance();
filename = globaldata->inputFileName;
read = new ReadPhilFile(filename);
+ if (globaldata->getFormat() == "shared") {
+ //read in group map info.
+ groupMap = new GroupMap(globaldata->getGroupFile());
+ }
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the ReadOtuCommand class Function ReadOtuCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
int ReadOtuCommand::execute(){
try {
read->read(&*globaldata);
+ if (globaldata->getFormat() == "shared") {
+ groupMap->readMap();
+ globaldata->gGroupmap = groupMap;
+
+ shared = new SharedCommand();
+ shared->execute();
+ parselist = new ParseListCommand();
+ parselist->execute();
+ }
return 0;
}
catch(exception& e) {
#include "command.hpp"
#include "readmatrix.hpp"
#include "inputdata.h"
+#include "groupmap.h"
+#include "sharedcommand.h"
+#include "parselistcommand.h"
-/* The read.otu command parameter options are listfile, sabundfile, rabundfile and orderfile.
-The read.otu command should be in the following format:
-read.otu(listfile=yourListFile, orderfile=yourOrderFile). The listfile, sabundfile or rabundfile are required, but only one may be used. */
+/* The read.otu must be run before you execute a collect.single, rarefaction.single, summary.single,
+collect.shared, rarefaction.shared or summary.shared command. Mothur will generate a .list, .rabund and .sabund
+upon completion of the cluster command or you may use your own. The read.otu command parameter options are
+listfile, rabundfile, sabundfile, groupfile and orderfile. The reaad.otu command can be used in two ways.
+The first is to read a listfile, rabundfile or sabundfile and run the collect.single, rarefaction.single or summary.single.
+For this use the read.otu command should be in the following format: read.otu(listfile=yourListFile, orderfile=yourOrderFile).
+The listfile, rabundfile or sabundfile parameter is required, but you may only use one of them.
+The second way to use the read.otu command is to read a listfile and a groupfile so you can use the collect.shared,
+rarefaction.shared or summary.shared commands. In this case the read.otu command should be in the following format:
+read.otu(listfile=yourListFile, groupfile=yourGroupFile). The listfile parameter and groupfile paramaters are required.
+When using the command the second way read.otu command parses the .list file and separates it into groups.
+It outputs a .shared file containing the OTU information for each group. The read.otu command also outputs a .list file for each group. */
class GlobalData;
GlobalData* globaldata;
ReadMatrix* read;
InputData* input;
+ Command* shared;
+ Command* parselist;
+ GroupMap* groupMap;
string filename;
};
#include "rabundvector.hpp"
#include "ordervector.hpp"
+
+/* This class is a child to datavector. It represents OTU information at a certain distance.
+ A sabundvector can be converted into and ordervector, listvector or rabundvector.
+ Each member of the internal container "data" represents the number of OTU's with that many members, but staring at 1.
+ So data[1] = 2, because there are two OTUs with 1 member.
+ example: listvector = a,b,c,d,e,f g,h,i j,k l m
+ rabundvector = 6 3 2 1 1
+ sabundvector = 2 1 1 0 0 1
+ ordervector = 1 1 1 1 1 1 2 2 2 3 3 4 5 */
+
+
class SAbundVector : public DataVector {
public:
#include <map>
#include "sharedrabundvector.h"
#include "listvector.hpp"
+#include "globaldata.hpp"
class Shared {
public:
--- /dev/null
+/*
+ * sharedSharedListVector.cpp
+ * Mothur
+ *
+ * Created by Sarah Westcott on 1/22/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+
+using namespace std;
+
+#include <map>
+#include <exception>
+#include "sabundvector.hpp"
+#include "rabundvector.hpp"
+#include "ordervector.hpp"
+#include "datavector.hpp"
+#include "utilities.hpp"
+#include "sharedlistvector.h"
+#include "sharedordervector.h"
+
+
+/***********************************************************************/
+
+SharedListVector::SharedListVector(int n): DataVector(), data(n, "") , maxRank(0), numBins(0), numSeqs(0){};
+
+/***********************************************************************/
+SharedListVector::SharedListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
+ try {
+ globaldata = GlobalData::getInstance();
+
+ //set up groupmap for later.
+ groupmap = new GroupMap(globaldata->getGroupFile());
+ groupmap->readMap();
+
+ int hold;
+ f >> label >> hold;
+
+ data.assign(hold, "");
+ string inputData = "";
+
+ for(int i=0;i<hold;i++){
+ f >> inputData;
+ set(i, inputData);
+ }
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function SharedListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedListVector class function SharedListVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+void SharedListVector::set(int binNumber, string seqNames){
+ try {
+ int nNames_old = getNumNames(data[binNumber]);
+ data[binNumber] = seqNames;
+ int nNames_new = getNumNames(seqNames);
+
+ if(nNames_old == 0) { numBins++; }
+ if(nNames_new == 0) { numBins--; }
+ if(nNames_new > maxRank) { maxRank = nNames_new; }
+
+ numSeqs += (nNames_new - nNames_old);
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedListVector class function set. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+string SharedListVector::get(int index){
+ return data[index];
+}
+
+/***********************************************************************/
+
+void SharedListVector::push_back(string seqNames){
+ try {
+ data.push_back(seqNames);
+ int nNames = getNumNames(seqNames);
+
+ numBins++;
+
+ if(nNames > maxRank) { maxRank = nNames; }
+
+ numSeqs += nNames;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedListVector class function push_back. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+void SharedListVector::resize(int size){
+ data.resize(size);
+}
+
+/***********************************************************************/
+
+int SharedListVector::size(){
+ return data.size();
+}
+/***********************************************************************/
+
+void SharedListVector::clear(){
+ numBins = 0;
+ maxRank = 0;
+ numSeqs = 0;
+ return data.clear();
+
+}
+
+/***********************************************************************/
+
+void SharedListVector::print(ostream& output){
+ try {
+ output << label << '\t' << numBins << '\t';
+
+ for(int i=0;i<data.size();i++){
+ if(data[i] != ""){
+ output << data[i] << '\t';
+ }
+ }
+ output << endl;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedListVector class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+
+/***********************************************************************/
+
+RAbundVector SharedListVector::getRAbundVector(){
+ try {
+ RAbundVector rav;
+
+ for(int i=0;i<data.size();i++){
+ int binSize = getNumNames(data[i]);
+ rav.push_back(binSize);
+ }
+
+ // This was here before to output data in a nice format, but it screws up the name mapping steps
+ // sort(rav.rbegin(), rav.rend());
+ //
+ // for(int i=data.size()-1;i>=0;i--){
+ // if(rav.get(i) == 0){ rav.pop_back(); }
+ // else{
+ // break;
+ // }
+ // }
+ rav.setLabel(label);
+
+ return rav;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedListVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+SAbundVector SharedListVector::getSAbundVector(){
+ try {
+ SAbundVector sav(maxRank+1);
+
+ for(int i=0;i<data.size();i++){
+ int binSize = getNumNames(data[i]);
+ sav.set(binSize, sav.get(binSize) + 1);
+ }
+ sav.set(0, 0);
+ sav.setLabel(label);
+
+ return sav;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedListVector class function getSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+SharedOrderVector* SharedListVector::getSharedOrderVector(){
+ try {
+ string groupName, names, name;
+
+ SharedOrderVector* order = new SharedOrderVector();
+ order->setLabel(label);
+
+ for(int i=0;i<numBins;i++){
+ int binSize = getNumNames(get(i)); //find number of individual in given bin
+ names = get(i);
+ while (names.find_first_of(',') != -1) {
+ name = names.substr(0,names.find_first_of(','));
+ names = names.substr(names.find_first_of(',')+1, names.length());
+ groupName = groupmap->getGroup(name);
+ order->push_back(i, binSize, groupName); //i represents what bin you are in
+ }
+ //get last name
+ groupName = groupmap->getGroup(names);
+ order->push_back(i, binSize, groupName);
+ }
+ random_shuffle(order->begin(), order->end());
+ return order;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedListVector class function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
+/***********************************************************************/
+SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) {
+ try {
+ SharedRAbundVector rav(data.size());
+ string group, names, name;
+
+ for(int i=0;i<numBins;i++){
+ names = get(i);
+ while (names.find_first_of(',') != -1) {
+ name = names.substr(0,names.find_first_of(','));
+ names = names.substr(names.find_first_of(',')+1, names.length());
+ group = groupmap->getGroup(name);
+ if (group == groupName) { //this name is in the group you want the vector for.
+ rav.set(i, rav.getAbundance(i) + 1, group); //i represents what bin you are in
+ }
+ }
+
+ //get last name
+ groupName = groupmap->getGroup(names);
+ if (group == groupName) { //this name is in the group you want the vector for.
+ rav.set(i, rav.getAbundance(i) + 1, group); //i represents what bin you are in
+ }
+ }
+
+ rav.setLabel(label);
+ rav.setGroup(groupName);
+ return rav;
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedListVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+SharedSAbundVector SharedListVector::getSharedSAbundVector(string groupName) {
+ try {
+ SharedSAbundVector sav;
+ SharedRAbundVector rav;
+
+ rav = this->getSharedRAbundVector(groupName);
+ sav = rav.getSharedSAbundVector();
+
+ return sav;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getSharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedListVector class function getSharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+OrderVector SharedListVector::getOrderVector(map<string,int>* orderMap = NULL){
+
+ try {
+ if(orderMap == NULL){
+ OrderVector ov;
+
+ for(int i=0;i<data.size();i++){
+ int binSize = getNumNames(data[i]);
+ for(int j=0;j<binSize;j++){
+ ov.push_back(i);
+ }
+ }
+ random_shuffle(ov.begin(), ov.end());
+ ov.setLabel(label);
+ ov.getNumBins();
+
+ return ov;
+
+ }
+ else{
+ OrderVector ov(numSeqs);
+
+ for(int i=0;i<data.size();i++){
+ string listOTU = data[i];
+ int length = listOTU.size();
+
+ string seqName="";
+
+ for(int j=0;j<length;j++){
+
+ if(listOTU[j] != ','){
+ seqName += listOTU[j];
+ }
+ else{
+ if(orderMap->count(seqName) == 0){
+ cerr << seqName << " not found, check *.names file\n";
+ exit(1);
+ }
+
+ ov.set((*orderMap)[seqName], i);
+ seqName = "";
+ }
+ }
+
+ if(orderMap->count(seqName) == 0){
+ cerr << seqName << " not found, check *.names file\n";
+ exit(1);
+ }
+ ov.set((*orderMap)[seqName], i);
+ }
+
+ ov.setLabel(label);
+ ov.getNumBins();
+
+ return ov;
+ }
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedListVector class Function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedListVector class function getOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
--- /dev/null
+#ifndef SHAREDLIST_H
+#define SHAREDLIST_H
+
+/*
+ * sharedlistvector.h
+ * Mothur
+ *
+ * Created by Sarah Westcott on 1/22/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include <Carbon/Carbon.h>
+#include "datavector.hpp"
+#include "groupmap.h"
+#include "globaldata.hpp"
+#include "sharedrabundvector.h"
+#include "sharedsabundvector.h"
+#include <iostream>
+#include <map>
+
+/* This class is a child to datavector. It represents OTU information at a certain distance.
+ A sharedlistvector can be converted into a sharedordervector, sharedrabundvector or sharedsabundvectorand
+ as well as an ordervector, rabundvector or sabundvector.
+ Each member of the internal container "data" represents an individual OTU.
+ Each individual in the OTU belongs to a group.
+ So data[0] = "a,b,c,d,e,f".
+ example: listvector = a,b,c,d,e,f g,h,i j,k l m
+ rabundvector = 6 3 2 1 1
+ sabundvector = 2 1 1 0 0 1
+ ordervector = 1 1 1 1 1 1 2 2 2 3 3 4 5 */
+
+class SharedListVector : public DataVector {
+
+public:
+ SharedListVector(int);
+ SharedListVector(ifstream&);
+ SharedListVector(const SharedListVector& lv) : DataVector(lv.label), data(lv.data), maxRank(lv.maxRank), numBins(lv.numBins), numSeqs(lv.numSeqs){};
+ ~SharedListVector(){};
+
+ int getNumBins() { return numBins; }
+ int getNumSeqs() { return numSeqs; }
+ int getMaxRank() { return maxRank; }
+
+ void set(int, string);
+ string get(int);
+ void push_back(string);
+ void resize(int);
+ void clear();
+ int size();
+ void print(ostream&);
+
+ RAbundVector getRAbundVector();
+ SAbundVector getSAbundVector();
+ OrderVector getOrderVector(map<string,int>*);
+ SharedOrderVector* getSharedOrderVector();
+ SharedRAbundVector getSharedRAbundVector(string); //get sharedrabundvector for a certain group
+ SharedSAbundVector getSharedSAbundVector(string); //get sharedsabundvector for a certain group
+
+private:
+ vector<string> data; //data[i] is a list of names of sequences in the ith OTU.
+ GlobalData* globaldata;
+ GroupMap* groupmap;
+ int maxRank;
+ int numBins;
+ int numSeqs;
+
+};
+
+#endif
+
* Dotur
*
* Created by Sarah Westcott on 12/9/08.
- * Copyright 2008 __MyCompanyName__. All rights reserved.
+ * Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
#include "sharedordervector.h"
-#include "datavector.hpp"
#include "utilities.hpp"
#include <exception>
/***********************************************************************
+//does not work since we don't have a shared order file format yet.
+
SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {
try {
int hold;
for(int i=0;i<hold;i++){
f >> inputData;
- set(i, inputData);
+ set(i, inputData, inputData, group);
}
updateStats();
RAbundVector rav(this->getRAbundVector());
return rav.getSAbundVector();
+}
+/***********************************************************************/
+SharedRAbundVector SharedOrderVector::getSharedRAbundVector(string group) {
+ try {
+ SharedRAbundVector sharedRav(data.size());
+
+ sharedRav.setLabel(label);
+ sharedRav.setGroup(group);
+
+ for (int i = 0; i < data.size(); i++) {
+ if (data[i].group == group) {
+ sharedRav.set(data[i].abundance, sharedRav.getAbundance(data[i].abundance) + 1, data[i].group);
+ }
+ }
+ return sharedRav;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedOrderVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
+/***********************************************************************/
+SharedSAbundVector SharedOrderVector::getSharedSAbundVector(string group) {
+ try {
+
+ SharedRAbundVector sharedRav(this->getSharedRAbundVector(group));
+ return sharedRav.getSharedSAbundVector();
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedOrderVector class Function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedOrderVector class function getSharedRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
}
/***********************************************************************/
* Dotur
*
* Created by Sarah Westcott on 12/9/08.
- * Copyright 2008 __MyCompanyName__. All rights reserved.
+ * Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
+
+ /* This class is a child to datavector. It represents OTU information at a certain distance.
+ It is similiar to an order vector except each member of data knows which group it belongs to.
+ Each member of the internal container "data" represents is an individual which knows the OTU from which it came,
+ the group it is in and the abundance is equal to the OTU number. */
+
+
+using namespace std;
-#include <Carbon/Carbon.h>
#include "datavector.hpp"
-#include "sabundvector.hpp"
-#include "rabundvector.hpp"
struct individual {
string group;
int abundance;
};
+#include <Carbon/Carbon.h>
+#include "sabundvector.hpp"
+#include "rabundvector.hpp"
+#include "sharedrabundvector.h"
+#include "sharedsabundvector.h"
class SharedOrderVector : public DataVector {
// SharedOrderVector(ifstream&);
~SharedOrderVector(){};
- void set(int, int, int, string);
+ void set(int, int, int, string); //index, OTU, abundance, group
individual get(int);
- void push_back(int, int, string);
+ void push_back(int, int, string); //OTU, abundance, group
void resize(int);
int size();
void print(ostream&);
SAbundVector getSAbundVector();
OrderVector getOrderVector(map<string,int>*);
SharedOrderVector getSharedOrderVector();
+ SharedRAbundVector getSharedRAbundVector(string); //get the sharedRabundvector for a sepecific group
+ SharedSAbundVector getSharedSAbundVector(string); //get the sharedSabundvector for a sepecific group
private:
vector<individual> data;
group = groupName;
}
-
/***********************************************************************/
int SharedRAbundVector::getNumBins(){
return numBins;
SharedRAbundVector SharedRAbundVector::getSharedRAbundVector(){
return *this;
}
+/***********************************************************************/
+
+RAbundVector SharedRAbundVector::getRAbundVector() {
+ try {
+ RAbundVector rav(data.size());
+
+ for (int i = 0; i < data.size(); i++) {
+ rav.set(i, data[i].abundance);
+ }
+
+ return rav;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedRAbundVector class function getRAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+SharedSAbundVector SharedRAbundVector::getSharedSAbundVector(){
+ try {
+ SharedSAbundVector sav(maxRank+1);
+
+ for(int i=0;i<data.size();i++){
+ int abund = data[i].abundance;
+ sav.set(abund, sav.getAbundance(abund) + 1, group);
+ }
+
+ sav.set(0, 0, group);
+ sav.setLabel(label);
+ sav.setGroup(group);
+
+ return sav;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function getSharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedRAbundVector class function getSharedSAbundVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
/***********************************************************************/
SAbundVector SharedRAbundVector::getSAbundVector() {
-#ifndef SHAREDVECTOR_H
-#define SHAREDVECTOR_H
+#ifndef SHAREDRABUNDVECTOR_H
+#define SHAREDRABUNDVECTOR_H
/*
- * sharedvector.h
+ * sharedrabundvector.h
* Dotur
*
* Created by Sarah Westcott on 12/5/08.
#include <Carbon/Carbon.h>
#include "datavector.hpp"
#include "sharedordervector.h"
+#include "sharedsabundvector.h"
+#include "rabundvector.hpp"
+/* This class is a child to datavector. It represents OTU information at a certain distance.
+ It is similiar to an rabundvector except each member of data knows which group it belongs to.
+ Each member of the internal container "data" is a struct of type individual.
+ An individual which knows the OTU from which it came,
+ the group it is in and its abundance. */
string getGroup();
void setGroup(string);
- void set(int, int, string);
+ void set(int, int, string); //OTU, abundance, groupname
individual get(int);
int getAbundance(int);
- void push_back(int, int, string);
+ void push_back(int, int, string); //abundance, OTU, groupname
void pop_back();
void resize(int);
int size();
void print(ostream&);
- SharedRAbundVector getSharedRAbundVector();
+ RAbundVector getRAbundVector();
SAbundVector getSAbundVector();
OrderVector getOrderVector(map<string,int>*);
SharedOrderVector getSharedOrderVector();
+ SharedSAbundVector getSharedSAbundVector();
+ SharedRAbundVector getSharedRAbundVector();
private:
vector<individual> data;
}
/***********************************************************************/
-SharedRAbundVector SharedSAbundVector::getSharedVector(){
+SharedRAbundVector SharedSAbundVector::getSharedRAbundVector(){
try {
SharedRAbundVector rav;
}
/***********************************************************************/
-
+SharedOrderVector SharedSAbundVector::getSharedOrderVector() {
+ try {
+ SharedRAbundVector rav;
+ SharedOrderVector ov;
+
+ rav = this->getSharedRAbundVector();
+ ov = rav.getSharedOrderVector();
+
+ return ov;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the SharedSAbundVector class Function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the SharedSAbundVector class function getSharedOrderVector. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+/***********************************************************************/
OrderVector SharedSAbundVector::getOrderVector(map<string,int>* hold = NULL){
try {
OrderVector ov;
* Dotur
*
* Created by Sarah Westcott on 12/10/08.
- * Copyright 2008 __MyCompanyName__. All rights reserved.
+ * Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
*
*/
#include "sharedordervector.h"
#include "sharedrabundvector.h"
+/* This class is a child to datavector. It represents OTU information at a certain distance.
+ It is similiar to an sabundvector except each member of data knows which group it belongs to.
+ Each member of the internal container "data" is a struct of type individual.
+ An individual which knows the OTU from which it came,
+ the group it is in and its abundance. */
+
using namespace std;
class SharedSAbundVector : public DataVector {
string getGroup();
void setGroup(string);
- void set(int, int, string);
+ void set(int, int, string); //OTU, abundance, group
individual get(int);
int getAbundance(int);
- void push_back(int, int, string);
+ void push_back(int, int, string); //abundance, OTU, group
void pop_back();
void resize(int);
int size();
RAbundVector getRAbundVector();
SAbundVector getSAbundVector();
- SharedSAbundVector getSharedSAbundVector();
- SharedRAbundVector getSharedVector();
OrderVector getOrderVector(map<string,int>*);
+ SharedSAbundVector getSharedSAbundVector();
+ SharedRAbundVector getSharedRAbundVector();
+ SharedOrderVector getSharedOrderVector();
private:
vector<individual> data;
*/
#include "summarysharedcommand.h"
+#include "sharedsobs.h"
#include "sharedchao1.h"
#include "sharedace.h"
#include "sharedjabund.h"
int i;
for (i=0; i<globaldata->sharedSummaryEstimators.size(); i++) {
- if (globaldata->sharedSummaryEstimators[i] == "sharedChao") {
+ if (globaldata->sharedSummaryEstimators[i] == "sharedSobs") {
+ sumCalculators.push_back(new SharedSobs());
+ }else if (globaldata->sharedEstimators[i] == "sharedChao") {
sumCalculators.push_back(new SharedChao1());
}else if (globaldata->sharedSummaryEstimators[i] == "sharedAce") {
sumCalculators.push_back(new SharedAce());
int SummarySharedCommand::execute(){
try {
- outputFileName = ((getRootName(globaldata->inputFileName)) + "sharedSummary");
+ outputFileName = ((getRootName(globaldata->inputFileName)) + "shared.summary");
openOutputFile(outputFileName, outputFileHandle);
read = new ReadPhilFile(globaldata->inputFileName);
read->read(&*globaldata);
- outputFileHandle << '\t' << '\t' << '\t' << '\t'; //pads file for labels and groupnames
+ outputFileHandle << "label" <<'\t' << "comparison" << '\t';
for(int i=0;i<sumCalculators.size();i++){
outputFileHandle << '\t' << sumCalculators[i]->getName();
}
outputFileHandle << endl;
- list = globaldata->glist;
+ SharedList = globaldata->gSharedList;
input = globaldata->ginput;
- order = list->getSharedOrderVector();
+ order = SharedList->getSharedOrderVector();
getGroupComb();
int count = 1;
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'; //print out label and group
+ outputFileHandle << order->getLabel() << '\t' << groupComb[n-1] << '\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';
}
}
- list = input->getListVector(); //get new list vector to process
- if (list != NULL) {
- order = list->getSharedOrderVector(); //gets new order vector with group info.
+ SharedList = input->getSharedListVector(); //get new list vector to process
+ if (SharedList != NULL) {
+ order = SharedList->getSharedOrderVector(); //gets new order vector with group info.
count++;
}else {
break;
#include "inputdata.h"
#include "calculator.h"
#include "readmatrix.hpp"
+#include "sharedlistvector.h"
/*The summary.shared() command
The summary.shared command can only be executed after a successful read.shared command.
ReadMatrix* read;
vector<Calculator*> sumCalculators;
InputData* input;
- ListVector* list;
+ SharedListVector* SharedList;
SharedOrderVector* order;
vector<SharedRAbundVector*> lookup;
SharedRAbundVector* shared1, shared2;
/********************************************************************/
void ValidCalculators::initialShared() {
try {
+ shared["sharedSobs"] = "sharedSobs";
shared["sharedChao"] = "sharedChao";
shared["sharedAce"] = "sharedAce";
shared["sharedJabund"] = "sharedJabund";
/********************************************************************/
void ValidCalculators::initialSharedSummary() {
try {
+ sharedsummary["sharedSobs"] = "sharedSobs";
sharedsummary["sharedChao"] = "sharedChao";
sharedsummary["sharedAce"] = "sharedAce";
sharedsummary["sharedJabund"] = "sharedJabund";
commands["read.dist"] = "read.dist";
commands["read.otu"] = "read.otu";
- commands["read.list"] = "read.list";
commands["cluster"] = "cluster";
commands["deconvolute"] = "deconvolute";
commands["help"] = "help";
if ((commands.find(command)) != (commands.end())) {
return true;
}else{
- cout << command << " is not a valid command in Mothur. Valid commands are read.dist(), read.list(), cluster(), collect.single(), collect.shared(), rarefaction.single(), rarefaction.shared(), summary.single(), summary.shared(), quit(), help()." << endl;
+ cout << command << " is not a valid command in Mothur. Valid commands are read.dist(), read.otu(), cluster(), collect.single(), collect.shared(), rarefaction.single(), rarefaction.shared(), summary.single(), summary.shared(), quit(), help()." << endl;
return false;
}