2 * consensusseqscommand.cpp
5 * Created by westcott on 11/23/10.
6 * Copyright 2010 Schloss Lab. All rights reserved.
10 #include "consensusseqscommand.h"
11 #include "sequence.hpp"
12 #include "inputdata.h"
14 //**********************************************************************************************************************
15 vector<string> ConsensusSeqsCommand::getValidParameters(){
17 string Array[] = {"fasta", "list", "name", "label","outputdir","inputdir"};
18 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
22 m->errorOut(e, "ConsensusSeqsCommand", "getValidParameters");
26 //**********************************************************************************************************************
27 ConsensusSeqsCommand::ConsensusSeqsCommand(){
30 //initialize outputTypes
31 vector<string> tempOutNames;
32 outputTypes["fasta"] = tempOutNames;
33 outputTypes["name"] = tempOutNames;
34 outputTypes["summary"] = tempOutNames;
37 m->errorOut(e, "ConsensusSeqsCommand", "ConsensusSeqsCommand");
41 //**********************************************************************************************************************
42 vector<string> ConsensusSeqsCommand::getRequiredParameters(){
44 string Array[] = {"fasta", "list"};
45 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
49 m->errorOut(e, "ConsensusSeqsCommand", "getRequiredParameters");
53 //**********************************************************************************************************************
54 vector<string> ConsensusSeqsCommand::getRequiredFiles(){
56 vector<string> myArray;
60 m->errorOut(e, "DegapSeqsCommand", "getRequiredFiles");
64 //***************************************************************************************************************
65 ConsensusSeqsCommand::ConsensusSeqsCommand(string option) {
70 //allow user to run help
71 if(option == "help") { help(); abort = true; }
74 //valid paramters for this command
75 string Array[] = {"fasta","list","name","label", "outputdir","inputdir"};
76 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
78 OptionParser parser(option);
79 map<string,string> parameters = parser.getParameters();
81 ValidParameters validParameter;
82 map<string,string>::iterator it;
84 //check to make sure all parameters are valid for command
85 for (it = parameters.begin(); it != parameters.end(); it++) {
86 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
89 //initialize outputTypes
90 vector<string> tempOutNames;
91 outputTypes["fasta"] = tempOutNames;
92 outputTypes["name"] = tempOutNames;
93 outputTypes["summary"] = tempOutNames;
96 //if the user changes the input directory command factory will send this info to us in the output parameter
97 string inputDir = validParameter.validFile(parameters, "inputdir", false);
98 if (inputDir == "not found"){ inputDir = ""; }
101 it = parameters.find("fasta");
102 //user has given a template file
103 if(it != parameters.end()){
104 path = m->hasPath(it->second);
105 //if the user has not given a path then, add inputdir. else leave path alone.
106 if (path == "") { parameters["fasta"] = inputDir + it->second; }
109 it = parameters.find("name");
110 //user has given a template file
111 if(it != parameters.end()){
112 path = m->hasPath(it->second);
113 //if the user has not given a path then, add inputdir. else leave path alone.
114 if (path == "") { parameters["name"] = inputDir + it->second; }
117 it = parameters.find("list");
118 //user has given a template file
119 if(it != parameters.end()){
120 path = m->hasPath(it->second);
121 //if the user has not given a path then, add inputdir. else leave path alone.
122 if (path == "") { parameters["list"] = inputDir + it->second; }
127 //check for parameters
128 fastafile = validParameter.validFile(parameters, "fasta", true);
129 if (fastafile == "not open") { abort = true; }
130 else if (fastafile == "not found") { fastafile = ""; m->mothurOut("fasta is a required parameter for the consensus.seqs command."); m->mothurOutEndLine(); abort = true; }
132 namefile = validParameter.validFile(parameters, "name", true);
133 if (namefile == "not open") { abort = true; }
134 else if (namefile == "not found") { namefile = ""; }
136 listfile = validParameter.validFile(parameters, "list", true);
137 if (listfile == "not open") { abort = true; }
138 else if (listfile == "not found") { listfile = ""; }
140 label = validParameter.validFile(parameters, "label", false);
141 if (label == "not found") { label = ""; }
143 if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
144 else { allLines = 1; }
147 //if the user changes the output directory command factory will send this info to us in the output parameter
148 outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = m->hasPath(fastafile); }
152 catch(exception& e) {
153 m->errorOut(e, "ConsensusSeqsCommand", "ConsensusSeqsCommand");
157 //**********************************************************************************************************************
159 void ConsensusSeqsCommand::help(){
161 m->mothurOut("The consensus.seqs command can be used in 2 ways: create a consensus sequence from a fastafile, or with a listfile create a consensus sequence for each otu. Sequences must be aligned.\n");
162 m->mothurOut("The consensus.seqs command parameters are fasta, list, name and label.\n");
163 m->mothurOut("The fasta parameter allows you to enter the fasta file containing your sequences, and is required. \n");
164 m->mothurOut("The list parameter allows you to enter a your list file. \n");
165 m->mothurOut("The name parameter allows you to enter a names file associated with the fasta file. \n");
166 m->mothurOut("The label parameter allows you to select what distance levels you would like output files for, and are separated by dashes.\n");
167 m->mothurOut("The consensus.seqs command should be in the following format: \n");
168 m->mothurOut("consensus.seqs(fasta=yourFastaFile, list=yourListFile) \n");
169 m->mothurOut("Example: consensus.seqs(fasta=abrecovery.align, list=abrecovery.fn.list) \n");
170 m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n\n");
172 catch(exception& e) {
173 m->errorOut(e, "ConsensusSeqsCommand", "help");
178 //***************************************************************************************************************
180 ConsensusSeqsCommand::~ConsensusSeqsCommand(){ /* do nothing */ }
182 //***************************************************************************************************************
184 int ConsensusSeqsCommand::execute(){
187 if (abort == true) { return 0; }
191 if (m->control_pressed) { return 0; }
193 if (namefile != "") { readNames(); }
195 if (m->control_pressed) { return 0; }
198 if (listfile == "") {
201 string outputSummaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "cons.summary";
202 m->openOutputFile(outputSummaryFile, outSummary);
203 outSummary.setf(ios::fixed, ios::floatfield); outSummary.setf(ios::showpoint);
204 outputNames.push_back(outputSummaryFile); outputTypes["summary"].push_back(outputSummaryFile);
207 string outputFastaFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "cons.fasta";
208 m->openOutputFile(outputFastaFile, outFasta);
209 outputNames.push_back(outputFastaFile); outputTypes["fasta"].push_back(outputFastaFile);
213 for (map<string, string>::iterator it = nameMap.begin(); it != nameMap.end(); it++) {
215 if (m->control_pressed) { outSummary.close(); outFasta.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
217 string seq = fastaMap[it->second];
220 if (seqLength == 0) { seqLength = seq.length(); }
221 else if (seqLength != seq.length()) { m->mothurOut("[ERROR]: sequence are not the same length, please correct."); m->mothurOutEndLine(); m->control_pressed = true; }
225 vector< vector<float> > percentages; percentages.resize(5);
226 for (int j = 0; j < percentages.size(); j++) { percentages[j].resize(seqLength, 0.0); }
230 for (int j = 0; j < seqLength; j++) {
232 if (m->control_pressed) { outSummary.close(); outFasta.close(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
234 vector<int> counts; counts.resize(5, 0); //A,T,G,C,Gap
237 for (int i = 0; i < seqs.size(); i++) {
239 if (seqs[i][j] == '.') { numDots++; }
241 char base = toupper(seqs[i][j]);
242 if (base == 'A') { counts[0]++; }
243 else if (base == 'T') { counts[1]++; }
244 else if (base == 'G') { counts[2]++; }
245 else if (base == 'C') { counts[3]++; }
246 else { counts[4]++; }
250 if (numDots != seqs.size()) { conBase = getBase(counts); }
254 percentages[0][j] = counts[0] / (float) seqs.size();
255 percentages[1][j] = counts[1] / (float) seqs.size();
256 percentages[2][j] = counts[2] / (float) seqs.size();
257 percentages[3][j] = counts[3] / (float) seqs.size();
258 percentages[4][j] = counts[4] / (float) seqs.size();
262 outSummary << "A" << '\t';
263 for (int j = 0; j < seqLength; j++) { outSummary << percentages[0][j] << '\t'; }
265 outSummary << "T" << '\t';
266 for (int j = 0; j < seqLength; j++) { outSummary << percentages[1][j] << '\t'; }
268 outSummary << "G" << '\t';
269 for (int j = 0; j < seqLength; j++) { outSummary << percentages[2][j] << '\t'; }
271 outSummary << "C" << '\t';
272 for (int j = 0; j < seqLength; j++) { outSummary << percentages[3][j] << '\t'; }
274 outSummary << "Gap" << '\t';
275 for (int j = 0; j < seqLength; j++) { outSummary << percentages[4][j] << '\t'; }
279 outFasta << ">conseq" << endl << consSeq << endl;
281 outSummary.close(); outFasta.close();
287 InputData* input = new InputData(listfile, "list");
288 ListVector* list = input->getListVector();
290 string lastLabel = list->getLabel();
291 set<string> processedLabels;
292 set<string> userLabels = labels;
294 //as long as you are not at the end of the file or done wih the lines you want
295 while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
297 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete list; delete input; return 0; }
299 if(allLines == 1 || labels.count(list->getLabel()) == 1){
301 m->mothurOut(list->getLabel()); m->mothurOutEndLine();
305 processedLabels.insert(list->getLabel());
306 userLabels.erase(list->getLabel());
309 if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
310 string saveLabel = list->getLabel();
314 list = input->getListVector(lastLabel);
315 m->mothurOut(list->getLabel()); m->mothurOutEndLine();
319 processedLabels.insert(list->getLabel());
320 userLabels.erase(list->getLabel());
322 //restore real lastlabel to save below
323 list->setLabel(saveLabel);
326 lastLabel = list->getLabel();
328 delete list; list = NULL;
330 //get next line to process
331 list = input->getListVector();
335 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } if (list != NULL) { delete list; } delete input; return 0; }
337 //output error messages about any remaining user labels
338 set<string>::iterator it;
339 bool needToRun = false;
340 for (it = userLabels.begin(); it != userLabels.end(); it++) {
341 m->mothurOut("Your file does not include the label " + *it);
342 if (processedLabels.count(lastLabel) != 1) {
343 m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
346 m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
350 //run last label if you need to
351 if (needToRun == true) {
352 if (list != NULL) { delete list; }
354 list = input->getListVector(lastLabel);
356 m->mothurOut(list->getLabel()); m->mothurOutEndLine();
360 delete list; list = NULL;
363 if (list != NULL) { delete list; }
367 m->mothurOutEndLine();
368 m->mothurOut("Output File Name: "); m->mothurOutEndLine();
369 for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
370 m->mothurOutEndLine();
376 catch(exception& e) {
377 m->errorOut(e, "ConsensusSeqsCommand", "execute");
381 //***************************************************************************************************************
383 int ConsensusSeqsCommand::processList(ListVector*& list){
387 string outputSummaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + list->getLabel() + ".cons.summary";
388 m->openOutputFile(outputSummaryFile, outSummary);
389 outSummary.setf(ios::fixed, ios::floatfield); outSummary.setf(ios::showpoint);
390 outputNames.push_back(outputSummaryFile); outputTypes["summary"].push_back(outputSummaryFile);
393 string outputNameFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + list->getLabel() + ".cons.names";
394 m->openOutputFile(outputNameFile, outName);
395 outputNames.push_back(outputNameFile); outputTypes["name"].push_back(outputNameFile);
398 string outputFastaFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + list->getLabel() + ".cons.fasta";
399 m->openOutputFile(outputFastaFile, outFasta);
400 outputNames.push_back(outputFastaFile); outputTypes["fasta"].push_back(outputFastaFile);
402 for (int i = 0; i < list->getNumBins(); i++) {
404 if (m->control_pressed) { outSummary.close(); outName.close(); outFasta.close(); return 0; }
406 string bin = list->get(i);
409 string consSeq = getConsSeq(bin, outSummary, newName, i);
411 outFasta << ">seq" << (i+1) << endl << consSeq << endl;
412 outName << "seq" << (i+1) << '\t' << "seq" << (i+1) << "," << newName << endl;
415 outSummary.close(); outName.close(); outFasta.close();
420 catch(exception& e) {
421 m->errorOut(e, "ConsensusSeqsCommand", "processList");
426 //***************************************************************************************************************
427 //made this smart enough to owrk with unique or non unique list file
428 string ConsensusSeqsCommand::getConsSeq(string bin, ofstream& outSummary, string& name, int binNumber){
434 //the whole bin is the second column if no names file, otherwise build it
436 if (namefile != "") { name = ""; }
438 vector<string> binNames;
439 m->splitAtComma(bin, binNames);
441 //get sequence strings for each name in the bin
444 set<string> addedAlready;
446 for (int i = 0; i < binNames.size(); i++) {
448 map<string, string>::iterator it;
450 it = nameMap.find(binNames[i]);
451 if (it == nameMap.end()) {
452 if (namefile == "") { m->mothurOut("[ERROR]: " + binNames[i] + " is not in your fasta file, please correct."); m->mothurOutEndLine(); error = true; }
453 else { m->mothurOut("[ERROR]: " + binNames[i] + " is not in your fasta or name file, please correct."); m->mothurOutEndLine(); error = true; }
457 //add sequence string to seqs vector to process below
458 string seq = fastaMap[it->second];
461 if (seqLength == 0) { seqLength = seq.length(); }
462 else if (seqLength != seq.length()) { m->mothurOut("[ERROR]: sequence are not the same length, please correct."); m->mothurOutEndLine(); error = true; break; }
464 if (namefile != "") {
465 //did we add this line from name file already?
466 if (addedAlready.count(it->second) == 0) {
467 name += "," + nameFileMap[it->second];
468 addedAlready.insert(it->second);
475 if (error) { m->control_pressed = true; return consSeq; }
477 if (namefile != "") { name = name.substr(1); }
479 vector< vector<float> > percentages; percentages.resize(5);
480 for (int j = 0; j < percentages.size(); j++) { percentages[j].resize(seqLength, 0.0); }
483 for (int j = 0; j < seqLength; j++) {
485 if (m->control_pressed) { return consSeq; }
487 vector<int> counts; counts.resize(5, 0); //A,T,G,C,Gap
490 for (int i = 0; i < seqs.size(); i++) {
492 if (seqs[i][j] == '.') { numDots++; }
494 char base = toupper(seqs[i][j]);
495 if (base == 'A') { counts[0]++; }
496 else if (base == 'T') { counts[1]++; }
497 else if (base == 'G') { counts[2]++; }
498 else if (base == 'C') { counts[3]++; }
499 else { counts[4]++; }
503 if (numDots != seqs.size()) { conBase = getBase(counts); }
507 percentages[0][j] = counts[0] / (float) seqs.size();
508 percentages[1][j] = counts[1] / (float) seqs.size();
509 percentages[2][j] = counts[2] / (float) seqs.size();
510 percentages[3][j] = counts[3] / (float) seqs.size();
511 percentages[4][j] = counts[4] / (float) seqs.size();
515 outSummary << ">seq" << (binNumber + 1) << endl;
516 outSummary << "A" << '\t';
517 for (int j = 0; j < seqLength; j++) { outSummary << percentages[0][j] << '\t'; }
519 outSummary << "T" << '\t';
520 for (int j = 0; j < seqLength; j++) { outSummary << percentages[1][j] << '\t'; }
522 outSummary << "G" << '\t';
523 for (int j = 0; j < seqLength; j++) { outSummary << percentages[2][j] << '\t'; }
525 outSummary << "C" << '\t';
526 for (int j = 0; j < seqLength; j++) { outSummary << percentages[3][j] << '\t'; }
528 outSummary << "Gap" << '\t';
529 for (int j = 0; j < seqLength; j++) { outSummary << percentages[4][j] << '\t'; }
536 catch(exception& e) {
537 m->errorOut(e, "ConsensusSeqsCommand", "getConsSeq");
541 //***************************************************************************************************************
543 char ConsensusSeqsCommand::getBase(vector<int> counts){ //A,T,G,C,Gap
550 * Y = T C (pyrimidine)
553 * S = G C (strong bonds)
554 * W = A T (weak bonds)
555 * B = G T C (all but A)
556 * D = G A T (all but C)
557 * H = A C T (all but G)
558 * V = G C A (all but T)
559 * N = A G C T (any) */
564 if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] != 0)) { conBase = 'n'; }
566 else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] == 0)) { conBase = 'N'; }
568 else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] != 0)) { conBase = 'v'; }
570 else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] == 0)) { conBase = 'V'; }
572 else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] != 0)) { conBase = 'h'; }
574 else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] == 0)) { conBase = 'H'; }
576 else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] != 0)) { conBase = 'd'; }
578 else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] == 0)) { conBase = 'D'; }
580 else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] != 0)) { conBase = 'b'; }
582 else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] == 0)) { conBase = 'B'; }
583 //W = A T (weak bonds)
584 else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] != 0)) { conBase = 'w'; }
585 //W = A T (weak bonds) no gap
586 else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] == 0)) { conBase = 'W'; }
587 //S = G C (strong bonds)
588 else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] != 0)) { conBase = 's'; }
589 //S = G C (strong bonds) no gap
590 else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] == 0)) { conBase = 'S'; }
592 else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] != 0)) { conBase = 'm'; }
593 //M = A C (amino) no gap
594 else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] == 0)) { conBase = 'M'; }
596 else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] != 0)) { conBase = 'k'; }
597 //K = G T (keto) no gap
598 else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] == 0)) { conBase = 'K'; }
599 //Y = T C (pyrimidine)
600 else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] != 0)) { conBase = 'y'; }
601 //Y = T C (pyrimidine) no gap
602 else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] == 0)) { conBase = 'Y'; }
604 else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] != 0)) { conBase = 'r'; }
605 //R = G A (purine) no gap
606 else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] == 0)) { conBase = 'R'; }
608 else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] != 0)) { conBase = 'a'; }
610 else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] == 0)) { conBase = 'A'; }
612 else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] != 0)) { conBase = 't'; }
614 else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] == 0)) { conBase = 'T'; }
616 else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] != 0)) { conBase = 'g'; }
618 else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] == 0)) { conBase = 'G'; }
620 else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] != 0)) { conBase = 'c'; }
622 else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] == 0)) { conBase = 'C'; }
624 else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] != 0)) { conBase = '-'; }
625 else{ m->mothurOut("[ERROR]: cannot find consensus base."); m->mothurOutEndLine(); }
630 catch(exception& e) {
631 m->errorOut(e, "ConsensusSeqsCommand", "getBase");
636 //***************************************************************************************************************
638 int ConsensusSeqsCommand::readFasta(){
642 m->openInputFile(fastafile, in);
646 if (m->control_pressed) { break; }
648 Sequence seq(in); m->gobble(in);
649 string name = seq.getName();
652 fastaMap[name] = seq.getAligned();
653 nameMap[name] = name; //set nameMap incase no names file
654 nameFileMap[name] = name;
663 catch(exception& e) {
664 m->errorOut(e, "ConsensusSeqsCommand", "readFasta");
668 //***************************************************************************************************************
670 int ConsensusSeqsCommand::readNames(){
674 m->openInputFile(namefile, in);
676 string thisname, repnames;
677 map<string, string>::iterator it;
683 if (m->control_pressed) { break; }
685 in >> thisname; m->gobble(in); //read from first column
686 in >> repnames; //read from second column
688 it = nameMap.find(thisname);
689 if (it != nameMap.end()) { //then this sequence was in the fastafile
691 vector<string> splitRepNames;
692 m->splitAtComma(repnames, splitRepNames);
694 nameFileMap[thisname] = repnames; //for later when outputting the new namesFile if the list file is unique
695 for (int i = 0; i < splitRepNames.size(); i++) { nameMap[splitRepNames[i]] = thisname; }
697 }else{ m->mothurOut("[ERROR]: " + thisname + " is not in the fasta file, please correct."); m->mothurOutEndLine(); error = true; }
704 if (error) { m->control_pressed = true; }
709 catch(exception& e) {
710 m->errorOut(e, "ConsensusSeqsCommand", "readNames");
715 //***************************************************************************************************************