try {
CommandParameter pblast("blast", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pblast);
CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
try {
CommandParameter pblast("blast", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pblast);
CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
+ CommandParameter pcount("count", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pcount);
+ //CommandParameter plarge("large", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(plarge);
CommandParameter plength("length", "Number", "", "5", "", "", "",false,false); parameters.push_back(plength);
CommandParameter ppenalty("penalty", "Number", "", "0.10", "", "", "",false,false); parameters.push_back(ppenalty);
CommandParameter pcutoff("cutoff", "Number", "", "0.70", "", "", "",false,false); parameters.push_back(pcutoff);
CommandParameter plength("length", "Number", "", "5", "", "", "",false,false); parameters.push_back(plength);
CommandParameter ppenalty("penalty", "Number", "", "0.10", "", "", "",false,false); parameters.push_back(ppenalty);
CommandParameter pcutoff("cutoff", "Number", "", "0.70", "", "", "",false,false); parameters.push_back(pcutoff);
if (namefile == "not open") { abort = true; }
else if (namefile == "not found") { namefile = ""; }
else { m->setNameFile(namefile); }
if (namefile == "not open") { abort = true; }
else if (namefile == "not found") { namefile = ""; }
else { m->setNameFile(namefile); }
+
+ countfile = validParameter.validFile(parameters, "count", true);
+ if (countfile == "not open") { abort = true; }
+ else if (countfile == "not found") { countfile = ""; }
+ else { m->setCountTableFile(countfile); }
+
+ if (countfile != "" && namefile != "") { m->mothurOut("Cannot have both a name file and count file. Please use one or the other."); m->mothurOutEndLine(); abort = true; }
if ((blastfile == "")) { m->mothurOut("When executing a mgcluster command you must provide a blastfile."); m->mothurOutEndLine(); abort = true; }
//check for optional parameter and set defaults
string temp;
if ((blastfile == "")) { m->mothurOut("When executing a mgcluster command you must provide a blastfile."); m->mothurOutEndLine(); abort = true; }
//check for optional parameter and set defaults
string temp;
temp = validParameter.validFile(parameters, "precision", false); if (temp == "not found") { temp = "100"; }
precisionLength = temp.length();
m->mothurConvert(temp, precision);
temp = validParameter.validFile(parameters, "precision", false); if (temp == "not found") { temp = "100"; }
precisionLength = temp.length();
m->mothurConvert(temp, precision);
hclusterWanted = m->isTrue(temp);
temp = validParameter.validFile(parameters, "hard", false); if (temp == "not found") { temp = "T"; }
hclusterWanted = m->isTrue(temp);
temp = validParameter.validFile(parameters, "hard", false); if (temp == "not found") { temp = "T"; }
//**********************************************************************************************************************
int MGClusterCommand::execute(){
try {
//**********************************************************************************************************************
int MGClusterCommand::execute(){
try {
//read blastfile - creates sparsematrices for the distances and overlaps as well as a listvector
//must remember to delete those objects here since readBlast does not
read = new ReadBlast(blastfile, cutoff, penalty, length, minWanted, hclusterWanted);
//read blastfile - creates sparsematrices for the distances and overlaps as well as a listvector
//must remember to delete those objects here since readBlast does not
read = new ReadBlast(blastfile, cutoff, penalty, length, minWanted, hclusterWanted);
- if(large) {
- map<string, int> nameMapCounts = m->readNames(namefile);
- RAbundVector* rabund = createRabund(list, nameMapCounts);
+
+ if(countfile != "") {
+ //map<string, int> nameMapCounts = m->readNames(namefile);
+ ct = new CountTable();
+ ct->readTable(countfile);
+ createRabund(ct, list);
+ rabund = &rav;
-RAbundVector MGClusterCommand::createRabund(ListVector list, map<string, int> nameMapCounts){
- for(int i = 0; i < list->getNumBins(); i++) {
-
+void MGClusterCommand::createRabund(CountTable* ct, ListVector* list){
+ try {
+ //vector<string> names = ct.getNamesOfSeqs();
+
+ //for ( int i; i < ct.getNumGroups(); i++ ) { rav.push_back( ct.getNumSeqs(names[i]) ); }
+ //return rav;
+
+ for(int i = 0; i < list->getNumBins(); i++) {
+ vector<string> binNames;
+ string bin = list->get(i);
+ m->splitAtComma(bin, binNames);
+ int total = 0;
+ for (int j = 0; j < binNames.size(); j++) {
+ total += ct->getNumSeqs(binNames[j]);
+ }
+ rav.push_back(total);
+ }
+
+