From 79a7d3273749b08d4f9f8dfe350c964ff0c4351e Mon Sep 17 00:00:00 2001 From: Sarah Westcott Date: Tue, 6 Nov 2012 10:23:48 -0500 Subject: [PATCH] changed added group output to indicator command. a few changes to work with the guy --- Mothur.xcodeproj/project.pbxproj | 20 ++--- chopseqscommand.cpp | 2 +- classifyotucommand.cpp | 149 +++++++++++++++++++++++++++---- classifyotucommand.h | 6 +- clustersplitcommand.cpp | 21 ++++- clustersplitcommand.h | 2 +- consensusseqscommand.cpp | 2 +- countseqscommand.cpp | 2 +- degapseqscommand.cpp | 2 +- distancecommand.cpp | 2 +- getgroupcommand.cpp | 2 +- getrabundcommand.cpp | 2 +- getsabundcommand.cpp | 2 +- indicatorcommand.cpp | 87 ++++++++++++------ indicatorcommand.h | 7 +- listseqscommand.cpp | 2 +- makegroupcommand.cpp | 2 +- mergefilecommand.cpp | 2 +- otuhierarchycommand.cpp | 2 +- pairwiseseqscommand.cpp | 2 +- parsefastaqcommand.cpp | 4 +- reversecommand.cpp | 2 +- secondarystructurecommand.cpp | 2 +- sensspeccommand.cpp | 2 +- seqsummarycommand.cpp | 2 +- subsamplecommand.h | 2 +- summaryqualcommand.cpp | 2 +- summarytaxcommand.cpp | 2 +- 28 files changed, 252 insertions(+), 84 deletions(-) diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index d360d2f..064019c 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -449,7 +449,7 @@ A76CDD7F1510F09A004C8458 /* pcrseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pcrseqscommand.h; sourceTree = ""; }; A76CDD811510F143004C8458 /* prcseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = prcseqscommand.cpp; sourceTree = ""; }; A7730EFD13967241007433A3 /* countseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = countseqscommand.h; sourceTree = ""; }; - A7730EFE13967241007433A3 /* countseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = countseqscommand.cpp; sourceTree = ""; }; + A7730EFE13967241007433A3 /* countseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = countseqscommand.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; A774101214695AF60098E6AC /* shhhseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shhhseqscommand.h; sourceTree = ""; }; A774101314695AF60098E6AC /* shhhseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shhhseqscommand.cpp; sourceTree = ""; }; A774104614696F320098E6AC /* myseqdist.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = myseqdist.cpp; sourceTree = ""; }; @@ -556,7 +556,7 @@ A7E9B68912D37EC400DA6239 /* chimeraslayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimeraslayer.h; sourceTree = ""; }; A7E9B68A12D37EC400DA6239 /* chimeraslayercommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimeraslayercommand.cpp; sourceTree = ""; }; A7E9B68B12D37EC400DA6239 /* chimeraslayercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimeraslayercommand.h; sourceTree = ""; }; - A7E9B68C12D37EC400DA6239 /* chopseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chopseqscommand.cpp; sourceTree = ""; }; + A7E9B68C12D37EC400DA6239 /* chopseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = chopseqscommand.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; A7E9B68D12D37EC400DA6239 /* chopseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chopseqscommand.h; sourceTree = ""; }; A7E9B68E12D37EC400DA6239 /* classify.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = classify.cpp; sourceTree = ""; }; A7E9B68F12D37EC400DA6239 /* classify.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = classify.h; sourceTree = ""; }; @@ -599,7 +599,7 @@ A7E9B6B412D37EC400DA6239 /* completelinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = completelinkage.cpp; sourceTree = SOURCE_ROOT; }; A7E9B6B512D37EC400DA6239 /* consensus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = consensus.cpp; sourceTree = ""; }; A7E9B6B612D37EC400DA6239 /* consensus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = consensus.h; sourceTree = ""; }; - A7E9B6B712D37EC400DA6239 /* consensusseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = consensusseqscommand.cpp; sourceTree = ""; }; + A7E9B6B712D37EC400DA6239 /* consensusseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = consensusseqscommand.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; A7E9B6B812D37EC400DA6239 /* consensusseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = consensusseqscommand.h; sourceTree = ""; }; A7E9B6B912D37EC400DA6239 /* corraxescommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = corraxescommand.cpp; sourceTree = ""; }; A7E9B6BA12D37EC400DA6239 /* corraxescommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = corraxescommand.h; sourceTree = ""; }; @@ -613,13 +613,13 @@ A7E9B6C212D37EC400DA6239 /* decalc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = decalc.h; sourceTree = ""; }; A7E9B6C312D37EC400DA6239 /* deconvolutecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deconvolutecommand.cpp; sourceTree = ""; }; A7E9B6C412D37EC400DA6239 /* deconvolutecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deconvolutecommand.h; sourceTree = ""; }; - A7E9B6C512D37EC400DA6239 /* degapseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = degapseqscommand.cpp; sourceTree = ""; }; + A7E9B6C512D37EC400DA6239 /* degapseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = degapseqscommand.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; A7E9B6C612D37EC400DA6239 /* degapseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = degapseqscommand.h; sourceTree = ""; }; A7E9B6C712D37EC400DA6239 /* deuniqueseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deuniqueseqscommand.cpp; sourceTree = ""; }; A7E9B6C812D37EC400DA6239 /* deuniqueseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deuniqueseqscommand.h; sourceTree = ""; }; A7E9B6C912D37EC400DA6239 /* display.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = display.h; sourceTree = SOURCE_ROOT; }; A7E9B6CA12D37EC400DA6239 /* dist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dist.h; sourceTree = ""; }; - A7E9B6CB12D37EC400DA6239 /* distancecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = distancecommand.cpp; sourceTree = ""; }; + A7E9B6CB12D37EC400DA6239 /* distancecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = distancecommand.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; A7E9B6CC12D37EC400DA6239 /* distancecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = distancecommand.h; sourceTree = ""; }; A7E9B6CD12D37EC400DA6239 /* distancedb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = distancedb.cpp; sourceTree = ""; }; A7E9B6CE12D37EC400DA6239 /* distancedb.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = distancedb.hpp; sourceTree = ""; }; @@ -656,7 +656,7 @@ A7E9B6EF12D37EC400DA6239 /* fullmatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fullmatrix.h; sourceTree = ""; }; A7E9B6F012D37EC400DA6239 /* geom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = geom.cpp; sourceTree = ""; }; A7E9B6F112D37EC400DA6239 /* geom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = geom.h; sourceTree = ""; }; - A7E9B6F212D37EC400DA6239 /* getgroupcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getgroupcommand.cpp; sourceTree = ""; }; + A7E9B6F212D37EC400DA6239 /* getgroupcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = getgroupcommand.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; A7E9B6F312D37EC400DA6239 /* getgroupcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getgroupcommand.h; sourceTree = ""; }; A7E9B6F412D37EC400DA6239 /* getgroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getgroupscommand.cpp; sourceTree = ""; }; A7E9B6F512D37EC400DA6239 /* getgroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getgroupscommand.h; sourceTree = ""; }; @@ -672,11 +672,11 @@ A7E9B6FF12D37EC400DA6239 /* getoturepcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getoturepcommand.h; sourceTree = ""; }; A7E9B70012D37EC400DA6239 /* getotuscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getotuscommand.cpp; sourceTree = ""; }; A7E9B70112D37EC400DA6239 /* getotuscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getotuscommand.h; sourceTree = ""; }; - A7E9B70212D37EC400DA6239 /* getrabundcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getrabundcommand.cpp; sourceTree = ""; }; + A7E9B70212D37EC400DA6239 /* getrabundcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = getrabundcommand.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; A7E9B70312D37EC400DA6239 /* getrabundcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getrabundcommand.h; sourceTree = ""; }; A7E9B70412D37EC400DA6239 /* getrelabundcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getrelabundcommand.cpp; sourceTree = ""; }; A7E9B70512D37EC400DA6239 /* getrelabundcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getrelabundcommand.h; sourceTree = ""; }; - A7E9B70612D37EC400DA6239 /* getsabundcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getsabundcommand.cpp; sourceTree = ""; }; + A7E9B70612D37EC400DA6239 /* getsabundcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = getsabundcommand.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; A7E9B70712D37EC400DA6239 /* getsabundcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getsabundcommand.h; sourceTree = ""; }; A7E9B70812D37EC400DA6239 /* getseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getseqscommand.cpp; sourceTree = ""; }; A7E9B70912D37EC400DA6239 /* getseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getseqscommand.h; sourceTree = ""; }; @@ -729,13 +729,13 @@ A7E9B73A12D37EC400DA6239 /* libshuff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libshuff.h; sourceTree = SOURCE_ROOT; }; A7E9B73B12D37EC400DA6239 /* libshuffcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = libshuffcommand.cpp; sourceTree = ""; }; A7E9B73C12D37EC400DA6239 /* libshuffcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libshuffcommand.h; sourceTree = ""; }; - A7E9B73D12D37EC400DA6239 /* listseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = listseqscommand.cpp; sourceTree = ""; }; + A7E9B73D12D37EC400DA6239 /* listseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = listseqscommand.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; A7E9B73E12D37EC400DA6239 /* listseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = listseqscommand.h; sourceTree = ""; }; A7E9B73F12D37EC400DA6239 /* listvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = listvector.cpp; sourceTree = ""; }; A7E9B74012D37EC400DA6239 /* listvector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = listvector.hpp; sourceTree = ""; }; A7E9B74112D37EC400DA6239 /* logsd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = logsd.cpp; sourceTree = ""; }; A7E9B74212D37EC400DA6239 /* logsd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = logsd.h; sourceTree = ""; }; - A7E9B74312D37EC400DA6239 /* makegroupcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = makegroupcommand.cpp; sourceTree = ""; }; + A7E9B74312D37EC400DA6239 /* makegroupcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = makegroupcommand.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; A7E9B74412D37EC400DA6239 /* makegroupcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = makegroupcommand.h; sourceTree = ""; }; A7E9B74512D37EC400DA6239 /* maligner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = maligner.cpp; sourceTree = ""; }; A7E9B74612D37EC400DA6239 /* maligner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = maligner.h; sourceTree = ""; }; diff --git a/chopseqscommand.cpp b/chopseqscommand.cpp index 4bcd707..1761efc 100644 --- a/chopseqscommand.cpp +++ b/chopseqscommand.cpp @@ -203,7 +203,7 @@ int ChopSeqsCommand::execute(){ if (m->control_pressed) { return 0; } m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName); if (wroteAccnos) { m->mothurOut(outputFileNameAccnos); m->mothurOutEndLine(); outputNames.push_back(outputFileNameAccnos); outputTypes["accnos"].push_back(outputFileNameAccnos); } diff --git a/classifyotucommand.cpp b/classifyotucommand.cpp index 660d53c..0ada1c8 100644 --- a/classifyotucommand.cpp +++ b/classifyotucommand.cpp @@ -10,6 +10,7 @@ #include "classifyotucommand.h" #include "phylotree.h" #include "phylosummary.h" +#include "sharedutilities.h" //********************************************************************************************************************** vector ClassifyOtuCommand::setParameters(){ @@ -20,7 +21,8 @@ vector ClassifyOtuCommand::setParameters(){ CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none",false,false); parameters.push_back(pname); CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount); CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup); - CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel); + CommandParameter ppersample("persample", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ppersample); + CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel); CommandParameter pbasis("basis", "Multiple", "otu-sequence", "otu", "", "", "",false,false); parameters.push_back(pbasis); CommandParameter pcutoff("cutoff", "Number", "", "51", "", "", "",false,true); parameters.push_back(pcutoff); CommandParameter pprobs("probs", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pprobs); @@ -244,7 +246,7 @@ ClassifyOtuCommand::ClassifyOtuCommand(string option) { if(label != "all") { m->splitAtDash(label, labels); allLines = 0; } else { allLines = 1; } } - + basis = validParameter.validFile(parameters, "basis", false); if (basis == "not found") { basis = "otu"; } @@ -255,7 +257,18 @@ ClassifyOtuCommand::ClassifyOtuCommand(string option) { temp = validParameter.validFile(parameters, "probs", false); if (temp == "not found"){ temp = "true"; } probs = m->isTrue(temp); + + temp = validParameter.validFile(parameters, "persample", false); if (temp == "not found"){ temp = "f"; } + persample = m->isTrue(temp); + if ((groupfile == "") && (countfile == "")) { if (persample) { m->mothurOut("persample is only valid with a group file, or count file with group information. Setting persample=f.\n"); persample = false; } + } + if (countfile != "") { + CountTable cts; + if (!cts.testGroups(countfile)) { + if (persample) { m->mothurOut("persample is only valid with a group file, or count file with group information. Setting persample=f.\n"); persample = false; } + } + } if ((cutoff < 51) || (cutoff > 100)) { m->mothurOut("cutoff must be above 50, and no greater than 100."); m->mothurOutEndLine(); abort = true; } @@ -282,11 +295,11 @@ int ClassifyOtuCommand::execute(){ //if user gave a namesfile then use it if (namefile != "") { m->readNames(namefile, nameMap, true); } - if (groupfile != "") { groupMap = new GroupMap(groupfile); groupMap->readMap(); } + if (groupfile != "") { groupMap = new GroupMap(groupfile); groupMap->readMap(); groups = groupMap->getNamesOfGroups(); } else { groupMap = NULL; } - if (countfile != "") { ct = new CountTable(); ct->readTable(countfile); } + if (countfile != "") { ct = new CountTable(); ct->readTable(countfile); if (ct->hasGroupInfo()) { groups = ct->getNamesOfGroups(); } } else { ct = NULL; } - + //read taxonomy file and save in map for easy access in building bin trees m->readTax(taxfile, taxMap); @@ -381,18 +394,13 @@ int ClassifyOtuCommand::execute(){ } } //********************************************************************************************************************** -vector ClassifyOtuCommand::findConsensusTaxonomy(int bin, ListVector* thisList, int& size, string& conTax) { +vector ClassifyOtuCommand::findConsensusTaxonomy(vector names, int& size, string& conTax) { try{ conTax = ""; - vector names; vector allNames; map::iterator it; map::iterator it2; - //parse names into vector - string binnames = thisList->get(bin); - m->splitAtComma(binnames, names); - //create a tree containing sequences from this bin PhyloTree* phylo = new PhyloTree(); @@ -543,7 +551,39 @@ int ClassifyOtuCommand::process(ListVector* processList) { if (refTaxonomy != "") { taxaSum = new PhyloSummary(refTaxonomy, groupMap); } else { taxaSum = new PhyloSummary(groupMap); } } - + + vector outSums; + vector outs; + vector taxaSums; + map groupIndex; + if (persample) { + for (int i = 0; i < groups.size(); i++) { + groupIndex[groups[i]] = i; + ofstream* temp = new ofstream(); + string outputFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + "." + groups[i] + "." +getOutputFileNameTag("constaxonomy"); + m->openOutputFile(outputFile, *temp); + (*temp) << "OTU\tSize\tTaxonomy" << endl; + outs.push_back(temp); + outputNames.push_back(outputFile); outputTypes["constaxonomy"].push_back(outputFile); + + ofstream* tempSum = new ofstream(); + string outputSumFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + "." + groups[i] + "." +getOutputFileNameTag("taxsummary"); + m->openOutputFile(outputSumFile, *tempSum); + outSums.push_back(tempSum); + outputNames.push_back(outputSumFile); outputTypes["taxsummary"].push_back(outputSumFile); + + PhyloSummary* taxaSumt; + if (countfile != "") { + if (refTaxonomy != "") { taxaSumt = new PhyloSummary(refTaxonomy, ct); } + else { taxaSumt = new PhyloSummary(ct); } + }else { + if (refTaxonomy != "") { taxaSumt = new PhyloSummary(refTaxonomy, groupMap); } + else { taxaSumt = new PhyloSummary(groupMap); } + } + taxaSums.push_back(taxaSumt); + } + } + //for each bin in the list vector string snumBins = toString(processList->getNumBins()); for (int i = 0; i < processList->getNumBins(); i++) { @@ -551,9 +591,13 @@ int ClassifyOtuCommand::process(ListVector* processList) { if (m->control_pressed) { break; } vector names; - names = findConsensusTaxonomy(i, processList, size, conTax); + string binnames = processList->get(i); + vector thisNames; + m->splitAtComma(binnames, thisNames); + + names = findConsensusTaxonomy(thisNames, size, conTax); - if (m->control_pressed) { out.close(); return 0; } + if (m->control_pressed) { break; } //output to new names file string binLabel = "Otu"; @@ -571,7 +615,11 @@ int ClassifyOtuCommand::process(ListVector* processList) { //add this bins taxonomy to summary if (basis == "sequence") { - for(int j = 0; j < names.size(); j++) { taxaSum->addSeqToTree(names[j], noConfidenceConTax); } + for(int j = 0; j < names.size(); j++) { + int numReps = 1; + if (countfile != "") { numReps = ct->getNumSeqs(names[j]); } + for(int k = 0; k < numReps; k++) { taxaSum->addSeqToTree(names[j], noConfidenceConTax); } + } }else { //otu map containsGroup; if (countfile != "") { @@ -602,6 +650,66 @@ int ClassifyOtuCommand::process(ListVector* processList) { } taxaSum->addSeqToTree(noConfidenceConTax, containsGroup); } + + + if (persample) { + //divide names by group + map > parsedNames; + map >::iterator itParsed; + + //parse names by group + for (int j = 0; j < names.size(); j++) { + if (groupfile != "") { + string group = groupMap->getGroup(names[j]); + itParsed = parsedNames.find(group); + + if (itParsed != parsedNames.end()) { itParsed->second.push_back(names[j]); } + else { vector tempNames; tempNames.push_back(names[j]); parsedNames[group] = tempNames; } + }else { //count file was used + vector thisSeqsGroups = ct->getGroups(names[j]); + for (int k = 0; k < thisSeqsGroups.size(); k++) { + string group = thisSeqsGroups[k]; + itParsed = parsedNames.find(group); + + if (itParsed != parsedNames.end()) { itParsed->second.push_back(names[j]); } + else { vector tempNames; tempNames.push_back(names[j]); parsedNames[group] = tempNames; } + } + } + } + + for (itParsed = parsedNames.begin(); itParsed != parsedNames.end(); itParsed++) { + vector theseNames = findConsensusTaxonomy(itParsed->second, size, conTax); + + if (m->control_pressed) { break; } + + //output to new names file + string binLabel = "Otu"; + string sbinNumber = toString(i+1); + if (sbinNumber.length() < snumBins.length()) { + int diff = snumBins.length() - sbinNumber.length(); + for (int h = 0; h < diff; h++) { binLabel += "0"; } + } + binLabel += sbinNumber; + + (*outs[groupIndex[itParsed->first]]) << binLabel << '\t' << size << '\t' << conTax << endl; + + string noConfidenceConTax = conTax; + m->removeConfidences(noConfidenceConTax); + + //add this bins taxonomy to summary + if (basis == "sequence") { + for(int j = 0; j < theseNames.size(); j++) { + int numReps = 1; + if (countfile != "") { numReps = ct->getGroupCount(theseNames[j], itParsed->first); } //get num seqs for this seq from this group + for(int k = 0; k < numReps; k++) { (taxaSums[groupIndex[itParsed->first]])->addSeqToTree(theseNames[j], noConfidenceConTax); } + } + }else { //otu + map containsGroup; + containsGroup[itParsed->first] = true; + (taxaSums[groupIndex[itParsed->first]])->addSeqToTree(noConfidenceConTax, containsGroup); + } + } + } } out.close(); @@ -609,6 +717,17 @@ int ClassifyOtuCommand::process(ListVector* processList) { //print summary file taxaSum->print(outSum); outSum.close(); + + if (persample) { + for (int i = 0; i < groups.size(); i++) { + (*outs[i]).close(); + taxaSums[i]->print(*outSums[i]); + (*outSums[i]).close(); + delete outs[i]; + delete outSums[i]; + delete taxaSums[i]; + } + } delete taxaSum; diff --git a/classifyotucommand.h b/classifyotucommand.h index 2e76057..c08a29b 100644 --- a/classifyotucommand.h +++ b/classifyotucommand.h @@ -40,16 +40,16 @@ private: ListVector* list; InputData* input; string listfile, namefile, taxfile, label, outputDir, refTaxonomy, groupfile, basis, countfile; - bool abort, allLines, probs; + bool abort, allLines, probs, persample; int cutoff; set labels; //holds labels to be used - vector outputNames; + vector outputNames, groups; map nameMap; map taxMap; int process(ListVector*); string addUnclassifieds(string, int); - vector findConsensusTaxonomy(int, ListVector*, int&, string&); // returns the name of the "representative" taxonomy of given bin + vector findConsensusTaxonomy(vector, int&, string&); // returns the name of the "representative" taxonomy of given bin }; diff --git a/clustersplitcommand.cpp b/clustersplitcommand.cpp index 09c2da8..277e4a2 100644 --- a/clustersplitcommand.cpp +++ b/clustersplitcommand.cpp @@ -23,6 +23,7 @@ vector ClusterSplitCommand::setParameters(){ CommandParameter psplitmethod("splitmethod", "Multiple", "classify-fasta-distance", "distance", "", "", "",false,false); parameters.push_back(psplitmethod); CommandParameter plarge("large", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(plarge); CommandParameter pshowabund("showabund", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pshowabund); + CommandParameter pcluster("cluster", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pcluster); CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ptiming); CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors); CommandParameter pcutoff("cutoff", "Number", "", "0.25", "", "", "",false,false); parameters.push_back(pcutoff); @@ -46,7 +47,7 @@ vector ClusterSplitCommand::setParameters(){ string ClusterSplitCommand::getHelpString(){ try { string helpString = ""; - helpString += "The cluster.split command parameter options are fasta, phylip, column, name, count, cutoff, precision, method, splitmethod, taxonomy, taxlevel, showabund, timing, hard, large, processors. Fasta or Phylip or column and name are required.\n"; + helpString += "The cluster.split command parameter options are fasta, phylip, column, name, count, cutoff, precision, method, splitmethod, taxonomy, taxlevel, showabund, timing, hard, large, cluster, processors. Fasta or Phylip or column and name are required.\n"; helpString += "The cluster.split command can split your files in 3 ways. Splitting by distance file, by classification, or by classification also using a fasta file. \n"; helpString += "For the distance file method, you need only provide your distance file and mothur will split the file into distinct groups. \n"; helpString += "For the classification method, you need to provide your distance file and taxonomy file, and set the splitmethod to classify. \n"; @@ -57,6 +58,7 @@ string ClusterSplitCommand::getHelpString(){ helpString += "The fasta parameter allows you to enter your aligned fasta file. \n"; helpString += "The name parameter allows you to enter your name file. \n"; helpString += "The count parameter allows you to enter your count file. \n A count or name file is required if your distance file is in column format"; + helpString += "The cluster parameter allows you to indicate whether you want to run the clustering or just split the distance matrix, default=t"; helpString += "The cutoff parameter allow you to set the distance you want to cluster to, default is 0.25. \n"; helpString += "The precision parameter allows you specify the precision of the precision of the distances outputted, default=100, meaning 2 decimal places. \n"; helpString += "The method allows you to specify what clustering algorythm you want to use, default=average, option furthest, nearest, or average. \n"; @@ -350,6 +352,9 @@ ClusterSplitCommand::ClusterSplitCommand(string option) { showabund = validParameter.validFile(parameters, "showabund", false); if (showabund == "not found") { showabund = "T"; } + + temp = validParameter.validFile(parameters, "cluster", false); if (temp == "not found") { temp = "T"; } + runCluster = m->isTrue(temp); timing = validParameter.validFile(parameters, "timing", false); if (timing == "not found") { timing = "F"; } @@ -447,7 +452,19 @@ int ClusterSplitCommand::execute(){ m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to split the distance file."); m->mothurOutEndLine(); estart = time(NULL); - + + if (!runCluster) { +#ifdef USE_MPI + } +#endif + m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); + for (int i = 0; i < distName.size(); i++) { m->mothurOut(distName[i].begin()->first); m->mothurOutEndLine(); m->mothurOut(distName[i].begin()->second); m->mothurOutEndLine(); } + m->mothurOutEndLine(); + return 0; + + } + //****************** break up files between processes and cluster each file set ******************************// #ifdef USE_MPI ////you are process 0 from above//// diff --git a/clustersplitcommand.h b/clustersplitcommand.h index 936ae6f..d88a934 100644 --- a/clustersplitcommand.h +++ b/clustersplitcommand.h @@ -50,7 +50,7 @@ private: string method, fileroot, tag, outputDir, phylipfile, columnfile, namefile, countfile, distfile, format, showabund, timing, splitmethod, taxFile, fastafile; double cutoff, splitcutoff; int precision, length, processors, taxLevelCutoff; - bool print_start, abort, hard, large, classic; + bool print_start, abort, hard, large, classic, runCluster; time_t start; ofstream outList, outRabund, outSabund; diff --git a/consensusseqscommand.cpp b/consensusseqscommand.cpp index 36df8c0..4134a52 100644 --- a/consensusseqscommand.cpp +++ b/consensusseqscommand.cpp @@ -396,7 +396,7 @@ int ConsensusSeqsCommand::execute(){ } m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); diff --git a/countseqscommand.cpp b/countseqscommand.cpp index fa6fd4f..e4aa253 100644 --- a/countseqscommand.cpp +++ b/countseqscommand.cpp @@ -188,7 +188,7 @@ int CountSeqsCommand::execute(){ m->mothurOutEndLine(); m->mothurOut("Total number of sequences: " + toString(total)); m->mothurOutEndLine(); m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(outputFileName); m->mothurOutEndLine(); m->mothurOutEndLine(); diff --git a/degapseqscommand.cpp b/degapseqscommand.cpp index 318a05e..095eef3 100644 --- a/degapseqscommand.cpp +++ b/degapseqscommand.cpp @@ -241,7 +241,7 @@ int DegapSeqsCommand::execute(){ } m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); diff --git a/distancecommand.cpp b/distancecommand.cpp index 16407d5..2a4398b 100644 --- a/distancecommand.cpp +++ b/distancecommand.cpp @@ -505,7 +505,7 @@ int DistanceCommand::execute(){ } m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(outputFile); m->mothurOutEndLine(); m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - startTime) + " to calculate the distances for " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); diff --git a/getgroupcommand.cpp b/getgroupcommand.cpp index faef2ac..b92924c 100644 --- a/getgroupcommand.cpp +++ b/getgroupcommand.cpp @@ -126,7 +126,7 @@ int GetgroupCommand::execute(){ } m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOutEndLine(); return 0; diff --git a/getrabundcommand.cpp b/getrabundcommand.cpp index 5f33f3a..3534293 100644 --- a/getrabundcommand.cpp +++ b/getrabundcommand.cpp @@ -274,7 +274,7 @@ int GetRAbundCommand::execute(){ } m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(filename); m->mothurOutEndLine(); outputNames.push_back(filename); outputTypes["rabund"].push_back(filename); m->mothurOutEndLine(); diff --git a/getsabundcommand.cpp b/getsabundcommand.cpp index 5425c41..5069249 100644 --- a/getsabundcommand.cpp +++ b/getsabundcommand.cpp @@ -268,7 +268,7 @@ int GetSAbundCommand::execute(){ delete input; m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(filename); m->mothurOutEndLine(); outputNames.push_back(filename); outputTypes["sabund"].push_back(filename); m->mothurOutEndLine(); diff --git a/indicatorcommand.cpp b/indicatorcommand.cpp index dc9f121..3c461d7 100644 --- a/indicatorcommand.cpp +++ b/indicatorcommand.cpp @@ -416,7 +416,7 @@ int IndicatorCommand::GetIndicatorSpecies(){ ofstream out; m->openOutputFile(outputFileName, out); out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint); - m->mothurOutEndLine(); m->mothurOut("Species\tIndicatorValue\tpValue\n"); + m->mothurOutEndLine(); m->mothurOut("Species\tIndicator_Groups\tIndicatorValue\tpValue\n"); int numBins = 0; if (sharedfile != "") { numBins = lookup[0]->getNumBins(); } @@ -430,6 +430,7 @@ int IndicatorCommand::GetIndicatorSpecies(){ vector indicatorValues; //size of numBins vector pValues; + vector indicatorGroups; map< vector, vector > randomGroupingsMap; //maps location in groupings to location in groupings, ie, [0][0] -> [1][2]. This is so we don't have to actually move the sharedRabundVectors. if (sharedfile != "") { @@ -453,7 +454,7 @@ int IndicatorCommand::GetIndicatorSpecies(){ if (groupsAlreadyAdded.size() != lookup.size()) { m->mothurOut("[ERROR]: could not make proper groupings."); m->mothurOutEndLine(); } - indicatorValues = getValues(groupings, randomGroupingsMap); + indicatorValues = getValues(groupings, indicatorGroups, randomGroupingsMap); pValues = getPValues(groupings, randomGroupingsMap, lookup.size(), indicatorValues); }else { @@ -476,7 +477,7 @@ int IndicatorCommand::GetIndicatorSpecies(){ if (groupsAlreadyAdded.size() != lookupFloat.size()) { m->mothurOut("[ERROR]: could not make proper groupings."); m->mothurOutEndLine(); } - indicatorValues = getValues(groupings, randomGroupingsMap); + indicatorValues = getValues(groupings, indicatorGroups, randomGroupingsMap); pValues = getPValues(groupings, randomGroupingsMap, lookupFloat.size(), indicatorValues); } @@ -487,22 +488,22 @@ int IndicatorCommand::GetIndicatorSpecies(){ /******************************************************/ //output indicator values to table form // /*****************************************************/ - out << "OTU\tIndicator_Value\tpValue" << endl; + out << "OTU\tIndicator_Groups\tIndicator_Value\tpValue" << endl; for (int j = 0; j < indicatorValues.size(); j++) { if (m->control_pressed) { out.close(); return 0; } - out << m->currentBinLabels[j] << '\t' << indicatorValues[j] << '\t'; + out << m->currentBinLabels[j] << '\t' << indicatorGroups[j] << '\t' << indicatorValues[j] << '\t'; if (pValues[j] > (1/(float)iters)) { out << pValues[j] << endl; } else { out << "<" << (1/(float)iters) << endl; } if (pValues[j] <= 0.05) { - cout << m->currentBinLabels[j] << '\t' << indicatorValues[j] << '\t'; + cout << m->currentBinLabels[j] << '\t' << indicatorGroups[j] << '\t' << indicatorValues[j] << '\t'; string pValueString = "<" + toString((1/(float)iters)); if (pValues[j] > (1/(float)iters)) { pValueString = toString(pValues[j]); cout << pValues[j];} else { cout << "<" << (1/(float)iters); } - m->mothurOutJustToLog(m->currentBinLabels[j] + "\t" + toString(indicatorValues[j]) + "\t" + pValueString); + m->mothurOutJustToLog(m->currentBinLabels[j] + "\t" + indicatorGroups[j] + "\t" + toString(indicatorValues[j]) + "\t" + pValueString); m->mothurOutEndLine(); } } @@ -538,10 +539,10 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){ //print headings out << "TreeNode\t"; - for (int i = 0; i < numBins; i++) { out << m->currentBinLabels[i] << "_IndValue" << '\t' << "pValue" << '\t'; } + for (int i = 0; i < numBins; i++) { out << m->currentBinLabels[i] << "_IndGroups" << '\t' << m->currentBinLabels[i] << "_IndValue" << '\t' << "pValue" << '\t'; } out << endl; - m->mothurOutEndLine(); m->mothurOut("Node\tSpecies\tIndicatorValue\tpValue\n"); + m->mothurOutEndLine(); m->mothurOut("Node\tSpecies\tIndicator_Groups\tIndicatorValue\tpValue\n"); string treeOutputDir = outputDir; if (outputDir == "") { treeOutputDir += m->hasPath(treefile); } @@ -572,6 +573,7 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){ vector indicatorValues; //size of numBins vector pValues; + vector indicatorGroups; map< vector, vector > randomGroupingsMap; //maps location in groupings to location in groupings, ie, [0][0] -> [1][2]. This is so we don't have to actually move the sharedRabundVectors. if (sharedfile != "") { @@ -623,7 +625,7 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){ if (groupsAlreadyAdded.size() != lookup.size()) { m->mothurOut("[ERROR]: could not make proper groupings."); m->mothurOutEndLine(); } - indicatorValues = getValues(groupings, randomGroupingsMap); + indicatorValues = getValues(groupings, indicatorGroups, randomGroupingsMap); pValues = getPValues(groupings, randomGroupingsMap, lookup.size(), indicatorValues); }else { @@ -672,7 +674,7 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){ if (groupsAlreadyAdded.size() != lookupFloat.size()) { m->mothurOut("[ERROR]: could not make proper groupings."); m->mothurOutEndLine(); } - indicatorValues = getValues(groupings, randomGroupingsMap); + indicatorValues = getValues(groupings, indicatorGroups, randomGroupingsMap); pValues = getPValues(groupings, randomGroupingsMap, lookupFloat.size(), indicatorValues); } @@ -689,17 +691,17 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){ if (m->control_pressed) { out.close(); return 0; } if (pValues[j] < (1/(float)iters)) { - out << indicatorValues[j] << '\t' << '<' << (1/(float)iters) << '\t'; + out << indicatorGroups[j] << '\t' << indicatorValues[j] << '\t' << '<' << (1/(float)iters) << '\t'; }else { - out << indicatorValues[j] << '\t' << pValues[j] << '\t'; + out << indicatorGroups[j] << '\t' << indicatorValues[j] << '\t' << pValues[j] << '\t'; } if (pValues[j] <= 0.05) { - cout << i+1 << '\t' << m->currentBinLabels[j] << '\t' << indicatorValues[j] << '\t'; + cout << i+1 << '\t' << m->currentBinLabels[j] << '\t' << indicatorGroups[j] << '\t' << indicatorValues[j] << '\t'; string pValueString = "<" + toString((1/(float)iters)); if (pValues[j] > (1/(float)iters)) { pValueString = toString(pValues[j]); cout << pValues[j];} else { cout << "<" << (1/(float)iters); } - m->mothurOutJustToLog(toString(i) + "\t" + m->currentBinLabels[j] + "\t" + toString(indicatorValues[j]) + "\t" + pValueString); + m->mothurOutJustToLog(toString(i) + "\t" + m->currentBinLabels[j] + "\t" + indicatorGroups[j] + "\t" + toString(indicatorValues[j]) + "\t" + pValueString); m->mothurOutEndLine(); } } @@ -724,11 +726,25 @@ int IndicatorCommand::GetIndicatorSpecies(Tree*& T){ } } //********************************************************************************************************************** -vector IndicatorCommand::getValues(vector< vector >& groupings, map< vector, vector > groupingsMap){ +vector IndicatorCommand::getValues(vector< vector >& groupings, vector& indicatorGroupings, map< vector, vector > groupingsMap){ try { vector values; map< vector, vector >::iterator it; - + + indicatorGroupings.clear(); + + //create grouping strings + vector groupingsGroups; + for (int j = 0; j < groupings.size(); j++) { + string tempGrouping = ""; + for (int k = 0; k < groupings[j].size()-1; k++) { + tempGrouping += groupings[j][k]->getGroup() + "-"; + } + tempGrouping += groupings[j][groupings[j].size()-1]->getGroup(); + groupingsGroups.push_back(tempGrouping); + } + + //for each otu for (int i = 0; i < groupings[0][0]->getNumBins(); i++) { @@ -768,15 +784,17 @@ vector IndicatorCommand::getValues(vector< vector maxIndVal) { maxIndVal = thisValue; } + if (thisValue > maxIndVal) { maxIndVal = thisValue; maxGrouping = groupingsGroups[j]; } } values.push_back(maxIndVal); + indicatorGroupings.push_back(maxGrouping); } return values; @@ -788,17 +806,24 @@ vector IndicatorCommand::getValues(vector< vector IndicatorCommand::getValues(vector< vector >& groupings, map< vector, vector > groupingsMap){ +vector IndicatorCommand::getValues(vector< vector >& groupings, vector& indicatorGroupings, map< vector, vector > groupingsMap){ try { vector values; - - /*for (int j = 0; j < groupings.size(); j++) { - cout << "grouping " << j << endl; - for (int k = 0; k < groupings[j].size(); k++) { - cout << groupings[j][k]->getGroup() << endl; - } - }*/ map< vector, vector >::iterator it; + + indicatorGroupings.clear(); + + //create grouping strings + vector groupingsGroups; + for (int j = 0; j < groupings.size(); j++) { + string tempGrouping = ""; + for (int k = 0; k < groupings[j].size()-1; k++) { + tempGrouping += groupings[j][k]->getGroup() + "-"; + } + tempGrouping += groupings[j][groupings[j].size()-1]->getGroup(); + groupingsGroups.push_back(tempGrouping); + } + //for each otu for (int i = 0; i < groupings[0][0]->getNumBins(); i++) { @@ -835,15 +860,17 @@ vector IndicatorCommand::getValues(vector< vector >& } float maxIndVal = 0.0; + string maxGrouping = ""; for (int j = 0; j < terms.size(); j++) { float thisAij = (terms[j] / AijDenominator); //relative abundance float thisValue = thisAij * Bij[j] * 100.0; //save largest - if (thisValue > maxIndVal) { maxIndVal = thisValue; } + if (thisValue > maxIndVal) { maxIndVal = thisValue; maxGrouping = groupingsGroups[j]; } } values.push_back(maxIndVal); + indicatorGroupings.push_back(maxGrouping); } return values; @@ -1119,11 +1146,12 @@ vector IndicatorCommand::driver(vector< vector try { vector pvalues; pvalues.resize(indicatorValues.size(), 0); + vector notUsedGroupings; //we dont care about the grouping for the pvalues since they are randomized, but we need to pass the function something to make it work. for(int i=0;icontrol_pressed) { break; } groupingsMap = randomizeGroupings(groupings, num); - vector randomIndicatorValues = getValues(groupings, groupingsMap); + vector randomIndicatorValues = getValues(groupings, notUsedGroupings, groupingsMap); for (int j = 0; j < indicatorValues.size(); j++) { if (randomIndicatorValues[j] >= indicatorValues[j]) { pvalues[j]++; } @@ -1232,11 +1260,12 @@ vector IndicatorCommand::driver(vector< vector >& gr try { vector pvalues; pvalues.resize(indicatorValues.size(), 0); + vector notUsedGroupings; //we dont care about the grouping for the pvalues since they are randomized, but we need to pass the function something to make it work. for(int i=0;icontrol_pressed) { break; } groupingsMap = randomizeGroupings(groupings, num); - vector randomIndicatorValues = getValues(groupings, groupingsMap); + vector randomIndicatorValues = getValues(groupings, notUsedGroupings, groupingsMap); for (int j = 0; j < indicatorValues.size(); j++) { if (randomIndicatorValues[j] >= indicatorValues[j]) { pvalues[j]++; } diff --git a/indicatorcommand.h b/indicatorcommand.h index 3c24dfb..b058af3 100644 --- a/indicatorcommand.h +++ b/indicatorcommand.h @@ -50,13 +50,16 @@ private: int GetIndicatorSpecies(Tree*&); int GetIndicatorSpecies(); set getDescendantList(Tree*&, int, map >, map >&); - vector getValues(vector< vector >&, map< vector, vector >); - vector getValues(vector< vector >&, map< vector, vector >); + vector getValues(vector< vector >&, vector&, map< vector, vector >); + vector getValues(vector< vector >&, vector&, map< vector, vector >); + map getDistToRoot(Tree*&); map< vector, vector > randomizeGroupings(vector< vector >&, int); map< vector, vector > randomizeGroupings(vector< vector >&, int); + vector driver(vector< vector >&, map< vector, vector >, int, vector, int); vector driver(vector< vector >&, map< vector, vector >, int, vector, int); + vector getPValues(vector< vector >&, map< vector, vector >, int, vector); vector getPValues(vector< vector >&, map< vector, vector >, int, vector); diff --git a/listseqscommand.cpp b/listseqscommand.cpp index 7c3f07f..4bc33a3 100644 --- a/listseqscommand.cpp +++ b/listseqscommand.cpp @@ -269,7 +269,7 @@ int ListSeqsCommand::execute(){ m->setAccnosFile(outputFileName); m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(outputFileName); m->mothurOutEndLine(); m->mothurOutEndLine(); diff --git a/makegroupcommand.cpp b/makegroupcommand.cpp index 77c2a29..a3aca93 100644 --- a/makegroupcommand.cpp +++ b/makegroupcommand.cpp @@ -245,7 +245,7 @@ int MakeGroupCommand::execute(){ out.close(); m->mothurOutEndLine(); - m->mothurOut("Output File Name: " + filename); m->mothurOutEndLine(); outputNames.push_back(filename); outputTypes["group"].push_back(filename); + m->mothurOut("Output File Names: " + filename); m->mothurOutEndLine(); outputNames.push_back(filename); outputTypes["group"].push_back(filename); m->mothurOutEndLine(); //set group file as new current groupfile diff --git a/mergefilecommand.cpp b/mergefilecommand.cpp index 0501859..f68bbbe 100644 --- a/mergefilecommand.cpp +++ b/mergefilecommand.cpp @@ -135,7 +135,7 @@ int MergeFileCommand::execute(){ if (m->control_pressed) { m->mothurRemove(outputFileName); return 0; } m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["merge"].push_back(outputFileName); m->mothurOutEndLine(); diff --git a/otuhierarchycommand.cpp b/otuhierarchycommand.cpp index e32e0b6..091bf9b 100644 --- a/otuhierarchycommand.cpp +++ b/otuhierarchycommand.cpp @@ -241,7 +241,7 @@ int OtuHierarchyCommand::execute(){ if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); return 0; } m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["otuheirarchy"].push_back(outputFileName); m->mothurOutEndLine(); diff --git a/pairwiseseqscommand.cpp b/pairwiseseqscommand.cpp index f69faff..dd82431 100644 --- a/pairwiseseqscommand.cpp +++ b/pairwiseseqscommand.cpp @@ -499,7 +499,7 @@ int PairwiseSeqsCommand::execute(){ } m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); diff --git a/parsefastaqcommand.cpp b/parsefastaqcommand.cpp index 816bdb5..ba23ae3 100644 --- a/parsefastaqcommand.cpp +++ b/parsefastaqcommand.cpp @@ -14,8 +14,8 @@ vector ParseFastaQCommand::setParameters(){ try { CommandParameter pfastq("fastq", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfastq); - CommandParameter pfasta("fasta", "Bool", "", "T", "", "", "",false,false); parameters.push_back(pfasta); - CommandParameter pqual("qfile", "Bool", "", "T", "", "", "",false,false); parameters.push_back(pqual); + CommandParameter pfasta("fasta", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pfasta); + CommandParameter pqual("qfile", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pqual); CommandParameter pformat("format", "Multiple", "sanger-illumina-solexa", "sanger", "", "", "",false,false); parameters.push_back(pformat); CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir); CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir); diff --git a/reversecommand.cpp b/reversecommand.cpp index cde88b7..96a216a 100644 --- a/reversecommand.cpp +++ b/reversecommand.cpp @@ -240,7 +240,7 @@ int ReverseSeqsCommand::execute(){ m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for(int i=0;imothurOut(outputNames[i]); m->mothurOutEndLine(); diff --git a/secondarystructurecommand.cpp b/secondarystructurecommand.cpp index 4d04270..870283c 100644 --- a/secondarystructurecommand.cpp +++ b/secondarystructurecommand.cpp @@ -303,7 +303,7 @@ int AlignCheckCommand::execute(){ m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(outfile); m->mothurOutEndLine(); outputNames.push_back(outfile); outputTypes["aligncheck"].push_back(outfile); m->mothurOutEndLine(); diff --git a/sensspeccommand.cpp b/sensspeccommand.cpp index b62bb00..5a1ead5 100644 --- a/sensspeccommand.cpp +++ b/sensspeccommand.cpp @@ -223,7 +223,7 @@ int SensSpecCommand::execute(){ if (m->control_pressed) { m->mothurRemove(sensSpecFileName); return 0; } m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(sensSpecFileName); m->mothurOutEndLine(); m->mothurOutEndLine(); diff --git a/seqsummarycommand.cpp b/seqsummarycommand.cpp index a250094..fb43503 100644 --- a/seqsummarycommand.cpp +++ b/seqsummarycommand.cpp @@ -410,7 +410,7 @@ int SeqSummaryCommand::execute(){ if (m->control_pressed) { m->mothurRemove(summaryFile); return 0; } m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(summaryFile); m->mothurOutEndLine(); outputNames.push_back(summaryFile); outputTypes["summary"].push_back(summaryFile); m->mothurOutEndLine(); diff --git a/subsamplecommand.h b/subsamplecommand.h index d1fb122..7116909 100644 --- a/subsamplecommand.h +++ b/subsamplecommand.h @@ -28,7 +28,7 @@ public: vector setParameters(); string getCommandName() { return "sub.sample"; } - string getCommandCategory() { return "General"; } + string getCommandCategory() { return "Sequence Processing"; } string getOutputFileNameTag(string, string); string getHelpString(); string getCitation() { return "http://www.mothur.org/wiki/Sub.sample"; } diff --git a/summaryqualcommand.cpp b/summaryqualcommand.cpp index 5a07367..48852a7 100644 --- a/summaryqualcommand.cpp +++ b/summaryqualcommand.cpp @@ -251,7 +251,7 @@ int SummaryQualCommand::execute(){ m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to create the summary file for " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine(); m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(summaryFile); m->mothurOutEndLine(); outputNames.push_back(summaryFile); outputTypes["summary"].push_back(summaryFile); m->mothurOutEndLine(); diff --git a/summarytaxcommand.cpp b/summarytaxcommand.cpp index 7f5e5e5..d33b4f0 100644 --- a/summarytaxcommand.cpp +++ b/summarytaxcommand.cpp @@ -296,7 +296,7 @@ int SummaryTaxCommand::execute(){ m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to create the summary file for " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine(); m->mothurOutEndLine(); - m->mothurOut("Output File Name: "); m->mothurOutEndLine(); + m->mothurOut("Output File Names: "); m->mothurOutEndLine(); m->mothurOut(summaryFile); m->mothurOutEndLine(); outputNames.push_back(summaryFile); outputTypes["summary"].push_back(summaryFile); m->mothurOutEndLine(); -- 2.39.2