+ if (abort == true) { if (calledHelp) { return 0; } return 2; }
+
+ //phylip file given and cutoff not given - use cluster.classic because it uses less memory and is faster
+ if ((format == "phylip") && (cutoff > 10.0)) {
+ m->mothurOutEndLine(); m->mothurOut("You are using a phylip file and no cutoff. I will run cluster.classic to save memory and time."); m->mothurOutEndLine();
+
+ //run unique.seqs for deconvolute results
+ string inputString = "phylip=" + distfile;
+ if (namefile != "") { inputString += ", name=" + namefile; }
+ else if (countfile != "") { inputString += ", count=" + countfile; }
+ inputString += ", precision=" + toString(precision);
+ inputString += ", method=" + method;
+ if (hard) { inputString += ", hard=T"; }
+ else { inputString += ", hard=F"; }
+ if (sim) { inputString += ", sim=T"; }
+ else { inputString += ", sim=F"; }
+
+
+ m->mothurOutEndLine();
+ m->mothurOut("/------------------------------------------------------------/"); m->mothurOutEndLine();
+ m->mothurOut("Running command: cluster.classic(" + inputString + ")"); m->mothurOutEndLine();
+
+ Command* clusterClassicCommand = new ClusterDoturCommand(inputString);
+ clusterClassicCommand->execute();
+ delete clusterClassicCommand;
+
+ m->mothurOut("/------------------------------------------------------------/"); m->mothurOutEndLine();
+
+ return 0;
+ }
+
+ ReadMatrix* read;
+ if (format == "column") { read = new ReadColumnMatrix(columnfile, sim); } //sim indicates whether its a similarity matrix
+ else if (format == "phylip") { read = new ReadPhylipMatrix(phylipfile, sim); }
+
+ read->setCutoff(cutoff);
+
+ NameAssignment* nameMap = NULL;
+ CountTable* ct = NULL;
+ if(namefile != ""){
+ nameMap = new NameAssignment(namefile);
+ nameMap->readMap();
+ read->read(nameMap);
+ }else if (countfile != "") {
+ ct = new CountTable();
+ ct->readTable(countfile);
+ read->read(ct);
+ }else { read->read(nameMap); }
+
+ list = read->getListVector();
+ matrix = read->getDMatrix();
+
+ if(countfile != "") {
+ rabund = new RAbundVector();
+ createRabund(ct, list, rabund); //creates an rabund that includes the counts for the unique list
+ delete ct;
+ }else { rabund = new RAbundVector(list->getRAbundVector()); }
+ delete read;
+
+ if (m->control_pressed) { //clean up
+ delete list; delete matrix; delete rabund; if(countfile == ""){rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund")); }
+ listFile.close(); m->mothurRemove((fileroot+ tag + ".list")); outputTypes.clear(); return 0;
+ }
+
+ //create cluster
+ if (method == "furthest") { cluster = new CompleteLinkage(rabund, list, matrix, cutoff, method); }
+ else if(method == "nearest"){ cluster = new SingleLinkage(rabund, list, matrix, cutoff, method); }
+ else if(method == "average"){ cluster = new AverageLinkage(rabund, list, matrix, cutoff, method); }
+ else if(method == "weighted"){ cluster = new WeightedLinkage(rabund, list, matrix, cutoff, method); }
+ tag = cluster->getTag();
+
+ if (outputDir == "") { outputDir += m->hasPath(distfile); }
+ fileroot = outputDir + m->getRootName(m->getSimpleName(distfile));
+
+ map<string, string> variables;
+ variables["[filename]"] = fileroot;
+ variables["[clustertag]"] = tag;
+ string sabundFileName = getOutputFileName("sabund", variables);
+ string rabundFileName = getOutputFileName("rabund", variables);
+ if (countfile != "") { variables["[tag2]"] = "unique_list"; }
+ string listFileName = getOutputFileName("list", variables);
+
+ if (countfile == "") {
+ m->openOutputFile(sabundFileName, sabundFile);
+ m->openOutputFile(rabundFileName, rabundFile);
+ outputNames.push_back(sabundFileName); outputTypes["sabund"].push_back(sabundFileName);
+ outputNames.push_back(rabundFileName); outputTypes["rabund"].push_back(rabundFileName);
+
+ }
+ m->openOutputFile(listFileName, listFile);
+ outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
+