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 pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
- CommandParameter pmethod("method", "Multiple", "furthest-nearest-average", "furthest", "", "", "",false,false); parameters.push_back(pmethod);
- CommandParameter phard("hard", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(phard);
+ CommandParameter pmethod("method", "Multiple", "furthest-nearest-average", "average", "", "", "",false,false); parameters.push_back(pmethod);
+ CommandParameter phard("hard", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(phard);
CommandParameter pmin("min", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pmin);
CommandParameter pmerge("merge", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pmerge);
CommandParameter phcluster("hcluster", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(phcluster);
helpString += "This command outputs a .list, .rabund and .sabund file that can be used with mothur other commands to estimate richness.\n";
helpString += "The cutoff parameter is used to specify the maximum distance you would like to cluster to. The default is 0.70.\n";
helpString += "The precision parameter's default value is 100. \n";
- helpString += "The acceptable mgcluster methods are furthest, nearest and average. If no method is provided then furthest is assumed.\n\n";
+ helpString += "The acceptable mgcluster methods are furthest, nearest and average. If no method is provided then average is assumed.\n";
helpString += "The min parameter allows you to specify is you want the minimum or maximum blast score ratio used in calculating the distance. The default is true, meaning you want the minimum.\n";
helpString += "The length parameter is used to specify the minimum overlap required. The default is 5.\n";
helpString += "The penalty parameter is used to adjust the error rate. The default is 0.10.\n";
helpString += "The hcluster parameter allows you to use the hcluster algorithm when clustering. This may be neccessary if your file is too large to fit into RAM. The default is false.\n";
helpString += "The mgcluster command should be in the following format: \n";
helpString += "mgcluster(blast=yourBlastfile, name=yourNameFile, cutoff=yourCutOff).\n";
- helpString += "Note: No spaces between parameter labels (i.e. balst), '=' and parameters (i.e.yourBlastfile).\n\n";
+ helpString += "Note: No spaces between parameter labels (i.e. balst), '=' and parameters (i.e.yourBlastfile).\n";
return helpString;
}
catch(exception& e) {
//allow user to run help
if(option == "help") { help(); abort = true; calledHelp = true; }
+ else if(option == "citation") { citation(); abort = true; calledHelp = true;}
else {
vector<string> myArray = setParameters();
namefile = validParameter.validFile(parameters, "name", true);
if (namefile == "not open") { abort = true; }
else if (namefile == "not found") { namefile = ""; }
+ else { m->setNameFile(namefile); }
if ((blastfile == "")) { m->mothurOut("When executing a mgcluster command you must provide a blastfile."); m->mothurOutEndLine(); abort = true; }
string temp;
temp = validParameter.validFile(parameters, "precision", false); if (temp == "not found") { temp = "100"; }
precisionLength = temp.length();
- convert(temp, precision);
+ m->mothurConvert(temp, precision);
temp = validParameter.validFile(parameters, "cutoff", false); if (temp == "not found") { temp = "0.70"; }
- convert(temp, cutoff);
+ m->mothurConvert(temp, cutoff);
cutoff += (5 / (precision * 10.0));
method = validParameter.validFile(parameters, "method", false);
- if (method == "not found") { method = "furthest"; }
+ if (method == "not found") { method = "average"; }
if ((method == "furthest") || (method == "nearest") || (method == "average")) { }
else { m->mothurOut("Not a valid clustering method. Valid clustering algorithms are furthest, nearest or average."); m->mothurOutEndLine(); abort = true; }
temp = validParameter.validFile(parameters, "length", false); if (temp == "not found") { temp = "5"; }
- convert(temp, length);
+ m->mothurConvert(temp, length);
temp = validParameter.validFile(parameters, "penalty", false); if (temp == "not found") { temp = "0.10"; }
- convert(temp, penalty);
+ m->mothurConvert(temp, penalty);
temp = validParameter.validFile(parameters, "min", false); if (temp == "not found") { temp = "true"; }
minWanted = m->isTrue(temp);
temp = validParameter.validFile(parameters, "hcluster", false); if (temp == "not found") { temp = "false"; }
hclusterWanted = m->isTrue(temp);
- temp = validParameter.validFile(parameters, "hard", false); if (temp == "not found") { temp = "F"; }
+ temp = validParameter.validFile(parameters, "hard", false); if (temp == "not found") { temp = "T"; }
hard = m->isTrue(temp);
}
if (m->control_pressed) {
delete nameMap; delete read; delete list; delete rabund;
- listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+ listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
outputTypes.clear();
return 0;
}
+ double saveCutoff = cutoff;
+
if (!hclusterWanted) {
//get distmatrix and overlap
SparseMatrix* distMatrix = read->getDistMatrix();
if (m->control_pressed) {
delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster;
- listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+ listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
outputTypes.clear();
return 0;
}
if (m->control_pressed) {
delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster;
- listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+ listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
outputTypes.clear();
return 0;
}
if (m->control_pressed) {
delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster; delete temp;
- listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+ listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
outputTypes.clear();
return 0;
}
if (m->control_pressed) {
delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster; delete temp;
- listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+ listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
outputTypes.clear();
return 0;
}
if (m->control_pressed) {
delete nameMap; delete list; delete rabund;
- listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+ listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
outputTypes.clear();
return 0;
}
if (m->control_pressed) {
delete nameMap; delete list; delete rabund; delete hcluster;
- listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+ listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
outputTypes.clear();
return 0;
}
seqs = hcluster->getSeqs();
+ //to account for cutoff change in average neighbor
+ if (seqs.size() != 0) {
+ if (seqs[0].dist > cutoff) { break; }
+ }
+
if (m->control_pressed) {
delete nameMap; delete list; delete rabund; delete hcluster;
- listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
- remove(distFile.c_str());
- remove(overlapFile.c_str());
+ listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
+ m->mothurRemove(distFile);
+ m->mothurRemove(overlapFile);
outputTypes.clear();
return 0;
}
if (seqs[i].seq1 != seqs[i].seq2) {
- hcluster->update(seqs[i].seq1, seqs[i].seq2, seqs[i].dist);
+ cutoff = hcluster->update(seqs[i].seq1, seqs[i].seq2, seqs[i].dist);
if (m->control_pressed) {
delete nameMap; delete list; delete rabund; delete hcluster;
- listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
- remove(distFile.c_str());
- remove(overlapFile.c_str());
+ listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
+ m->mothurRemove(distFile);
+ m->mothurRemove(overlapFile);
outputTypes.clear();
return 0;
}
if (m->control_pressed) {
delete nameMap; delete list; delete rabund; delete hcluster; delete temp;
- listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
- remove(distFile.c_str());
- remove(overlapFile.c_str());
+ listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
+ m->mothurRemove(distFile);
+ m->mothurRemove(overlapFile);
outputTypes.clear();
return 0;
}
if (m->control_pressed) {
delete nameMap; delete list; delete rabund; delete hcluster; delete temp;
- listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
- remove(distFile.c_str());
- remove(overlapFile.c_str());
+ listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
+ m->mothurRemove(distFile);
+ m->mothurRemove(overlapFile);
outputTypes.clear();
return 0;
}
}
delete hcluster;
- remove(distFile.c_str());
- remove(overlapFile.c_str());
+ m->mothurRemove(distFile);
+ m->mothurRemove(overlapFile);
}
delete list;
if (m->control_pressed) {
delete nameMap;
- listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
+ listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
outputTypes.clear();
return 0;
}
m->mothurOut(fileroot+ tag + ".sabund"); m->mothurOutEndLine(); outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund");
m->mothurOutEndLine();
+ if (saveCutoff != cutoff) {
+ if (hard) { saveCutoff = m->ceilDist(saveCutoff, precision); }
+ else { saveCutoff = m->roundDist(saveCutoff, precision); }
+
+ m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine();
+ }
+
//set list file as new current listfile
string current = "";
itTypes = outputTypes.find("list");
try {
//sort distFile
string sortedDistFile = m->sortFile(unsortedDist, outputDir);
- remove(unsortedDist.c_str()); //delete unsorted file
+ m->mothurRemove(unsortedDist); //delete unsorted file
distFile = sortedDistFile;
//sort overlap file
string sortedOverlapFile = m->sortFile(unsortedOverlap, outputDir);
- remove(unsortedOverlap.c_str()); //delete unsorted file
+ m->mothurRemove(unsortedOverlap); //delete unsorted file
overlapFile = sortedOverlapFile;
}
catch(exception& e) {