#include "clustersplitcommand.h"
#include "classifyotucommand.h"
#include "degapseqscommand.h"
+#include "getrelabundcommand.h"
/*******************************************************/
commands["split.abund"] = "split.abund";
commands["classify.otu"] = "classify.otu";
commands["degap.seqs"] = "degap.seqs";
+ commands["get.relabund"] = "get.relabund";
commands["classify.seqs"] = "MPIEnabled";
commands["dist.seqs"] = "MPIEnabled";
commands["filter.seqs"] = "MPIEnabled";
else if(commandName == "cluster.split") { command = new ClusterSplitCommand(optionString); }
else if(commandName == "classify.otu") { command = new ClassifyOtuCommand(optionString); }
else if(commandName == "degap.seqs") { command = new DegapSeqsCommand(optionString); }
+ else if(commandName == "get.relabund") { command = new GetRelAbundCommand(optionString); }
else { command = new NoCommand(optionString); }
return command;
m->mothurOut("The label parameter allows you to select what distance levels you would like, and are also separated by dashes.\n");
m->mothurOut("The scale parameter allows you to select what scale you would like to use. Choices are totalgroup, totalotu, averagegroup, averageotu, default is totalgroup.\n");
m->mothurOut("The get.relabund command should be in the following format: get.relabund(groups=yourGroups, label=yourLabels).\n");
- m->mothurOut("Example get.relabund(groups=A-B-C, scale=log10).\n");
+ m->mothurOut("Example get.relabund(groups=A-B-C, scale=averagegroup).\n");
m->mothurOut("The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n");
m->mothurOut("The get.relabund command outputs a .relabund file.\n");
m->mothurOut("Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n\n");
InputData* input;
vector<SharedRAbundVector*> lookup;
- bool abort, allLines;
+ bool abort, allLines, pickedGroups;
set<string> labels; //holds labels to be used
string groups, label, outputDir, scale;
vector<string> Groups;
- int getRelAbundance(vector<SharedRAbundVector*>, ofstream&);
+ int getRelAbundance(vector<SharedRAbundVector*>&, ofstream&);
+ int eliminateZeroOTUS(vector<SharedRAbundVector*>& thislookup);
};
/**************************************************************************************************/
-string PhyloTree::getNextTaxon(string& heirarchy){
+string PhyloTree::getNextTaxon(string& heirarchy, string seqname){
try {
string currentLevel = "";
if(heirarchy != ""){
int pos = heirarchy.find_first_of(';');
- currentLevel=heirarchy.substr(0,pos);
- if (pos != (heirarchy.length()-1)) { heirarchy=heirarchy.substr(pos+1); }
- else { heirarchy = ""; }
+
+ if (pos == -1) { //you can't find another ;
+ currentLevel = heirarchy;
+ heirarchy = "";
+ m->mothurOut(seqname + " is missing a ;, please check for other errors."); m->mothurOutEndLine();
+ }else{
+ currentLevel=heirarchy.substr(0,pos);
+ if (pos != (heirarchy.length()-1)) { heirarchy=heirarchy.substr(pos+1); }
+ else { heirarchy = ""; }
+ }
+
}
return currentLevel;
}
tree[0].accessions.push_back(seqName);
string taxon;// = getNextTaxon(seqTaxonomy);
-
+
while(seqTaxonomy != ""){
level++;
-
+
if (m->control_pressed) { return 0; }
//somehow the parent is getting one too many accnos
//use print to reassign the taxa id
- taxon = getNextTaxon(seqTaxonomy);
+ taxon = getNextTaxon(seqTaxonomy, seqName);
if (taxon == "") { m->mothurOut(seqName + " has an error in the taxonomy. This may be due to a ;;"); m->mothurOutEndLine(); if (currentNode != 0) { uniqueTaxonomies[currentNode] = currentNode; } break; }
tree[currentNode].children[taxon] = numNodes-1;
tree[numNodes-1].parent = currentNode;
- // int numChildren = tree[currentNode].children.size();
- // string heirarchyID = tree[currentNode].heirarchyID;
- // tree[currentNode].accessions.push_back(seqName);
-
currentNode = tree[currentNode].children[taxon];
tree[currentNode].accessions.push_back(seqName);
name2Taxonomy[seqName] = currentNode;
- // tree[currentNode].level = level;
- // tree[currentNode].childNumber = numChildren;
- // tree[currentNode].heirarchyID = heirarchyID + '.' + toString(tree[currentNode].childNumber);
}
if (seqTaxonomy == "") { uniqueTaxonomies[currentNode] = currentNode; }
}
-
}
catch(exception& e) {
m->errorOut(e, "PhyloTree", "addSeqToTree");
bool ErrorCheck(vector<string>);
private:
- string getNextTaxon(string&);
+ string getNextTaxon(string&, string);
void print(ofstream&, vector<TaxNode>&); //used to create static reference taxonomy file
void fillOutTree(int, vector<TaxNode>&); //used to create static reference taxonomy file
void binUnclassified(string);
*/
#include "sharedcommand.h"
-
+//********************************************************************************************************************
+//sorts lowest to highest
+inline bool compareSharedRabunds(SharedRAbundVector* left, SharedRAbundVector* right){
+ return (left->getGroup() < right->getGroup());
+}
//**********************************************************************************************************************
SharedCommand::SharedCommand(string o) : outputDir(o) {
if(globaldata->allLines == 1 || globaldata->labels.count(SharedList->getLabel()) == 1){
lookup = SharedList->getSharedRAbundVector();
+
m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
if (pickedGroups) { //check for otus with no seqs in them
eliminateZeroOTUS(lookup);
void SharedCommand::printSharedData(vector<SharedRAbundVector*> thislookup) {
try {
+ sort(thislookup.begin(), thislookup.end(), compareSharedRabunds);
+
//initialize bin values
for (int i = 0; i < thislookup.size(); i++) {
//cout << "in printData " << thislookup[i]->getLabel() << '\t' << thislookup[i]->getGroup() << endl;