-
- //done with listvector from matrix
- if (list != NULL) { delete list; }
-
- input = new InputData(listfile, "list");
- list = input->getListVector();
- string lastLabel = list->getLabel();
-
- //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
- set<string> processedLabels;
- set<string> userLabels = labels;
-
- if (m->control_pressed) {
- if (large) { inRow.close(); m->mothurRemove(distFile); }
- delete input; delete list; return 0;
- }
-
- if ((!weighted) && (namefile != "")) { readNamesFile(weighted); }
-
- while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-
- if (allLines == 1 || labels.count(list->getLabel()) == 1){
- m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
- error = process(list);
- if (error == 1) { return 0; } //there is an error in hte input files, abort command
-
- if (m->control_pressed) {
- if (large) { inRow.close(); m->mothurRemove(distFile); }
- for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- delete input; delete list; return 0;
- }
-
- processedLabels.insert(list->getLabel());
- userLabels.erase(list->getLabel());
- }
-
- if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
- string saveLabel = list->getLabel();
-
- delete list;
- list = input->getListVector(lastLabel);
- m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
- error = process(list);
- if (error == 1) { return 0; } //there is an error in hte input files, abort command
-
- if (m->control_pressed) {
- if (large) { inRow.close(); m->mothurRemove(distFile); }
- for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- delete input; delete list; return 0;
- }
-
- processedLabels.insert(list->getLabel());
- userLabels.erase(list->getLabel());
-
- //restore real lastlabel to save below
- list->setLabel(saveLabel);
- }
-
- lastLabel = list->getLabel();
-
- delete list;
- list = input->getListVector();
- }
-
- //output error messages about any remaining user labels
- bool needToRun = false;
- for (set<string>::iterator it = userLabels.begin(); it != userLabels.end(); it++) {
- m->mothurOut("Your file does not include the label " + (*it));
- if (processedLabels.count(lastLabel) != 1) {
- m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
- needToRun = true;
- }else {
- m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
- }
- }
-
- //run last label if you need to
- if (needToRun == true) {
- if (list != NULL) { delete list; }
- list = input->getListVector(lastLabel);
- m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
- error = process(list);
- delete list;
- if (error == 1) { return 0; } //there is an error in hte input files, abort command
-
- if (m->control_pressed) {
- if (large) { inRow.close(); m->mothurRemove(distFile); }
- for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- delete input; delete list; return 0;
- }
- }
-
- //close and remove formatted matrix file
- if (large) {
- inRow.close();
- m->mothurRemove(distFile);
- }
-
- delete input;
-
- if (!weighted) { nameFileMap.clear(); }
-
-
- if (fastafile != "") {
- //read fastafile
- fasta = new FastaMap();
- fasta->readFastaFile(fastafile);
-
- //if user gave a namesfile then use it
- if (namefile != "") { readNamesFile(); }
-
- //output create and output the .rep.fasta files
- map<string, string>::iterator itNameFile;
- for (itNameFile = outputNameFiles.begin(); itNameFile != outputNameFiles.end(); itNameFile++) {
- processFastaNames(itNameFile->first, itNameFile->second);
- }
- }else {
- //output create and output the .rep.fasta files
- map<string, string>::iterator itNameFile;
- for (itNameFile = outputNameFiles.begin(); itNameFile != outputNameFiles.end(); itNameFile++) {
- processNames(itNameFile->first, itNameFile->second);
- }
- }
-
-
- if (groupfile != "") { delete groupMap; }
+
+ //done with listvector from matrix
+ if (list != NULL) { delete list; }
+
+ InputData input(listfile, "list");
+ list = input.getListVector();
+ string lastLabel = list->getLabel();
+
+ //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
+ set<string> processedLabels;
+ set<string> userLabels = labels;
+
+ if (m->control_pressed) { if (method=="distance") { if (large) { inRow.close(); m->mothurRemove(distFile); } } delete list; return 0; }
+
+ while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
+
+ if (allLines == 1 || labels.count(list->getLabel()) == 1){
+ m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
+ error = process(list);
+ if (error == 1) { return 0; } //there is an error in hte input files, abort command
+
+ if (m->control_pressed) {
+ if (method=="distance") { if (large) { inRow.close(); m->mothurRemove(distFile); } }
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
+ delete list; return 0;
+ }
+
+ processedLabels.insert(list->getLabel());
+ userLabels.erase(list->getLabel());
+ }
+
+ if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ string saveLabel = list->getLabel();
+
+ delete list;
+ list = input.getListVector(lastLabel);
+ m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
+ error = process(list);
+ if (error == 1) { return 0; } //there is an error in hte input files, abort command
+
+ if (m->control_pressed) {
+ if (method=="distance") { if (large) { inRow.close(); m->mothurRemove(distFile); } }
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
+ delete list; return 0;
+ }
+
+ processedLabels.insert(list->getLabel());
+ userLabels.erase(list->getLabel());
+
+ //restore real lastlabel to save below
+ list->setLabel(saveLabel);
+ }
+
+ lastLabel = list->getLabel();
+
+ delete list;
+ list = input.getListVector();
+ }
+
+ //output error messages about any remaining user labels
+ bool needToRun = false;
+ for (set<string>::iterator it = userLabels.begin(); it != userLabels.end(); it++) {
+ m->mothurOut("Your file does not include the label " + (*it));
+ if (processedLabels.count(lastLabel) != 1) {
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
+ needToRun = true;
+ }else {
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
+ }
+ }
+
+ //run last label if you need to
+ if (needToRun == true) {
+ if (list != NULL) { delete list; }
+ list = input.getListVector(lastLabel);
+ m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
+ error = process(list);
+ delete list;
+ if (error == 1) { return 0; } //there is an error in hte input files, abort command
+
+ if (m->control_pressed) {
+ if (method=="distance") { if (large) { inRow.close(); m->mothurRemove(distFile); } }
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
+ delete list; return 0;
+ }
+ }
+
+ //close and remove formatted matrix file
+ if (method=="distance") { if (large) { inRow.close(); m->mothurRemove(distFile); } if (!weighted) { nameFileMap.clear(); } }
+
+ if (fastafile != "") {
+ //read fastafile
+ FastaMap* fasta = new FastaMap();
+ fasta->readFastaFile(fastafile);
+
+ //if user gave a namesfile then use it
+ if (namefile != "") { readNamesFile(fasta); }
+
+ //output create and output the .rep.fasta files
+ map<string, string>::iterator itNameFile;
+ for (itNameFile = outputNameFiles.begin(); itNameFile != outputNameFiles.end(); itNameFile++) {
+ processFastaNames(itNameFile->first, itNameFile->second, fasta);
+ }
+ delete fasta;
+ }else {
+ //output create and output the .rep.fasta files
+ map<string, string>::iterator itNameFile;
+ for (itNameFile = outputNameFiles.begin(); itNameFile != outputNameFiles.end(); itNameFile++) {
+ processNames(itNameFile->first, itNameFile->second);
+ }
+ }
+
+
+ if (groupfile != "") { delete groupMap; }