2 * removelineagecommand.cpp
5 * Created by westcott on 9/24/10.
6 * Copyright 2010 Schloss Lab. All rights reserved.
10 #include "removelineagecommand.h"
11 #include "sequence.hpp"
12 #include "listvector.hpp"
14 //**********************************************************************************************************************
15 vector<string> RemoveLineageCommand::setParameters(){
17 CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
18 CommandParameter pname("name", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pname);
19 CommandParameter pgroup("group", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pgroup);
20 CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
21 CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,true); parameters.push_back(ptaxonomy);
22 CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(palignreport);
23 CommandParameter ptaxon("taxon", "String", "", "", "", "", "",false,true); parameters.push_back(ptaxon);
24 CommandParameter pdups("dups", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pdups);
25 CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
26 CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
28 vector<string> myArray;
29 for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
33 m->errorOut(e, "RemoveLineageCommand", "setParameters");
37 //**********************************************************************************************************************
38 string RemoveLineageCommand::getHelpString(){
40 string helpString = "";
41 helpString += "The remove.lineage command reads a taxonomy file and any of the following file types: fasta, name, group, list or alignreport file.\n";
42 helpString += "It outputs a file containing only the sequences from the taxonomy file that are not from the taxon you requested to be removed.\n";
43 helpString += "The remove.lineage command parameters are taxon, fasta, name, group, list, taxonomy, alignreport and dups. You must provide taxonomy unless you have a valid current taxonomy file.\n";
44 helpString += "The dups parameter allows you to add the entire line from a name file if you add any name from the line. default=false. \n";
45 helpString += "The taxon parameter allows you to select the taxons you would like to remove, and is required.\n";
46 helpString += "You may enter your taxons with confidence scores, doing so will remove only those sequences that belong to the taxonomy and whose cofidence scores fall below the scores you give.\n";
47 helpString += "If they belong to the taxonomy and have confidences above those you provide the sequence will not be removed.\n";
48 helpString += "The remove.lineage command should be in the following format: remove.lineage(taxonomy=yourTaxonomyFile, taxon=yourTaxons).\n";
49 helpString += "Example remove.lineage(taxonomy=amazon.silva.taxonomy, taxon=Bacteria;Firmicutes;Bacilli;Lactobacillales;).\n";
50 helpString += "Note: If you are running mothur in script mode you must wrap the taxon in ' characters so mothur will ignore the ; in the taxon.\n";
51 helpString += "Example remove.lineage(taxonomy=amazon.silva.taxonomy, taxon='Bacteria;Firmicutes;Bacilli;Lactobacillales;').\n";
52 helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
56 m->errorOut(e, "RemoveLineageCommand", "getHelpString");
62 //**********************************************************************************************************************
63 RemoveLineageCommand::RemoveLineageCommand(){
65 abort = true; calledHelp = true;
67 vector<string> tempOutNames;
68 outputTypes["fasta"] = tempOutNames;
69 outputTypes["taxonomy"] = tempOutNames;
70 outputTypes["name"] = tempOutNames;
71 outputTypes["group"] = tempOutNames;
72 outputTypes["alignreport"] = tempOutNames;
73 outputTypes["list"] = tempOutNames;
76 m->errorOut(e, "RemoveLineageCommand", "RemoveLineageCommand");
80 //**********************************************************************************************************************
81 RemoveLineageCommand::RemoveLineageCommand(string option) {
83 abort = false; calledHelp = false;
85 //allow user to run help
86 if(option == "help") { help(); abort = true; calledHelp = true; }
87 else if(option == "citation") { citation(); abort = true; calledHelp = true;}
90 vector<string> myArray = setParameters();
92 OptionParser parser(option);
93 map<string,string> parameters = parser.getParameters();
95 ValidParameters validParameter;
96 map<string,string>::iterator it;
98 //check to make sure all parameters are valid for command
99 for (it = parameters.begin(); it != parameters.end(); it++) {
100 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
103 //initialize outputTypes
104 vector<string> tempOutNames;
105 outputTypes["fasta"] = tempOutNames;
106 outputTypes["taxonomy"] = tempOutNames;
107 outputTypes["name"] = tempOutNames;
108 outputTypes["group"] = tempOutNames;
109 outputTypes["alignreport"] = tempOutNames;
110 outputTypes["list"] = tempOutNames;
112 //if the user changes the output directory command factory will send this info to us in the output parameter
113 outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; }
115 //if the user changes the input directory command factory will send this info to us in the output parameter
116 string inputDir = validParameter.validFile(parameters, "inputdir", false);
117 if (inputDir == "not found"){ inputDir = ""; }
120 it = parameters.find("alignreport");
121 //user has given a template file
122 if(it != parameters.end()){
123 path = m->hasPath(it->second);
124 //if the user has not given a path then, add inputdir. else leave path alone.
125 if (path == "") { parameters["alignreport"] = inputDir + it->second; }
128 it = parameters.find("fasta");
129 //user has given a template file
130 if(it != parameters.end()){
131 path = m->hasPath(it->second);
132 //if the user has not given a path then, add inputdir. else leave path alone.
133 if (path == "") { parameters["fasta"] = inputDir + it->second; }
136 it = parameters.find("list");
137 //user has given a template file
138 if(it != parameters.end()){
139 path = m->hasPath(it->second);
140 //if the user has not given a path then, add inputdir. else leave path alone.
141 if (path == "") { parameters["list"] = inputDir + it->second; }
144 it = parameters.find("name");
145 //user has given a template file
146 if(it != parameters.end()){
147 path = m->hasPath(it->second);
148 //if the user has not given a path then, add inputdir. else leave path alone.
149 if (path == "") { parameters["name"] = inputDir + it->second; }
152 it = parameters.find("group");
153 //user has given a template file
154 if(it != parameters.end()){
155 path = m->hasPath(it->second);
156 //if the user has not given a path then, add inputdir. else leave path alone.
157 if (path == "") { parameters["group"] = inputDir + it->second; }
160 it = parameters.find("taxonomy");
161 //user has given a template file
162 if(it != parameters.end()){
163 path = m->hasPath(it->second);
164 //if the user has not given a path then, add inputdir. else leave path alone.
165 if (path == "") { parameters["taxonomy"] = inputDir + it->second; }
170 //check for required parameters
171 fastafile = validParameter.validFile(parameters, "fasta", true);
172 if (fastafile == "not open") { fastafile = ""; abort = true; }
173 else if (fastafile == "not found") { fastafile = ""; }
174 else { m->setFastaFile(fastafile); }
176 namefile = validParameter.validFile(parameters, "name", true);
177 if (namefile == "not open") { namefile = ""; abort = true; }
178 else if (namefile == "not found") { namefile = ""; }
179 else { m->setNameFile(namefile); }
181 groupfile = validParameter.validFile(parameters, "group", true);
182 if (groupfile == "not open") { abort = true; }
183 else if (groupfile == "not found") { groupfile = ""; }
184 else { m->setGroupFile(groupfile); }
186 alignfile = validParameter.validFile(parameters, "alignreport", true);
187 if (alignfile == "not open") { abort = true; }
188 else if (alignfile == "not found") { alignfile = ""; }
190 listfile = validParameter.validFile(parameters, "list", true);
191 if (listfile == "not open") { abort = true; }
192 else if (listfile == "not found") { listfile = ""; }
193 else { m->setListFile(listfile); }
195 taxfile = validParameter.validFile(parameters, "taxonomy", true);
196 if (taxfile == "not open") { taxfile = ""; abort = true; }
197 else if (taxfile == "not found") {
198 taxfile = m->getTaxonomyFile();
199 if (taxfile != "") { m->mothurOut("Using " + taxfile + " as input file for the taxonomy parameter."); m->mothurOutEndLine(); }
200 else { m->mothurOut("You have no current taxonomy file and the taxonomy parameter is required."); m->mothurOutEndLine(); abort = true; }
201 }else { m->setTaxonomyFile(taxfile); }
203 string usedDups = "true";
204 string temp = validParameter.validFile(parameters, "dups", false);
205 if (temp == "not found") {
206 if (namefile != "") { temp = "true"; }
207 else { temp = "false"; usedDups = ""; }
209 dups = m->isTrue(temp);
211 taxons = validParameter.validFile(parameters, "taxon", false);
212 if (taxons == "not found") { taxons = ""; m->mothurOut("No taxons given, please correct."); m->mothurOutEndLine(); abort = true; }
215 if (taxons[0] == '\'') { taxons = taxons.substr(1); }
216 if (taxons[(taxons.length()-1)] == '\'') { taxons = taxons.substr(0, (taxons.length()-1)); }
218 m->splitAtChar(taxons, listOfTaxons, '-');
220 if ((fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "") && (taxfile == "")) { m->mothurOut("You must provide one of the following: fasta, name, group, alignreport, taxonomy or listfile."); m->mothurOutEndLine(); abort = true; }
222 if ((usedDups != "") && (namefile == "")) { m->mothurOut("You may only use dups with the name option."); m->mothurOutEndLine(); abort = true; }
224 if ((namefile == "") && ((fastafile != "") || (taxfile != ""))){
225 vector<string> files; files.push_back(fastafile); files.push_back(taxfile);
226 parser.getNameFile(files);
232 catch(exception& e) {
233 m->errorOut(e, "RemoveLineageCommand", "RemoveLineageCommand");
237 //**********************************************************************************************************************
239 int RemoveLineageCommand::execute(){
242 if (abort == true) { if (calledHelp) { return 0; } return 2; }
244 if (m->control_pressed) { return 0; }
246 //read through the correct file and output lines you want to keep
247 if (taxfile != "") { readTax(); } //fills the set of names to remove
248 if (namefile != "") { readName(); }
249 if (fastafile != "") { readFasta(); }
250 if (groupfile != "") { readGroup(); }
251 if (alignfile != "") { readAlign(); }
252 if (listfile != "") { readList(); }
255 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
257 if (outputNames.size() != 0) {
258 m->mothurOutEndLine();
259 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
260 for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
261 m->mothurOutEndLine();
263 //set fasta file as new current fastafile
265 itTypes = outputTypes.find("fasta");
266 if (itTypes != outputTypes.end()) {
267 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
270 itTypes = outputTypes.find("name");
271 if (itTypes != outputTypes.end()) {
272 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
275 itTypes = outputTypes.find("group");
276 if (itTypes != outputTypes.end()) {
277 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
280 itTypes = outputTypes.find("list");
281 if (itTypes != outputTypes.end()) {
282 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
285 itTypes = outputTypes.find("taxonomy");
286 if (itTypes != outputTypes.end()) {
287 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
294 catch(exception& e) {
295 m->errorOut(e, "RemoveLineageCommand", "execute");
300 //**********************************************************************************************************************
301 int RemoveLineageCommand::readFasta(){
303 string thisOutputDir = outputDir;
304 if (outputDir == "") { thisOutputDir += m->hasPath(fastafile); }
305 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
308 m->openOutputFile(outputFileName, out);
311 m->openInputFile(fastafile, in);
314 bool wroteSomething = false;
317 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
319 Sequence currSeq(in);
320 name = currSeq.getName();
323 //if this name is in the accnos file
324 if (names.count(name) == 0) {
325 wroteSomething = true;
327 currSeq.printSequence(out);
335 if (wroteSomething == false) { m->mothurOut("Your fasta file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
336 outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName);
341 catch(exception& e) {
342 m->errorOut(e, "RemoveLineageCommand", "readFasta");
346 //**********************************************************************************************************************
347 int RemoveLineageCommand::readList(){
349 string thisOutputDir = outputDir;
350 if (outputDir == "") { thisOutputDir += m->hasPath(listfile); }
351 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" + m->getExtension(listfile);
354 m->openOutputFile(outputFileName, out);
357 m->openInputFile(listfile, in);
359 bool wroteSomething = false;
362 //read in list vector
365 //make a new list vector
367 newList.setLabel(list.getLabel());
370 for (int i = 0; i < list.getNumBins(); i++) {
371 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
373 //parse out names that are in accnos file
374 string binnames = list.get(i);
376 string newNames = "";
377 while (binnames.find_first_of(',') != -1) {
378 string name = binnames.substr(0,binnames.find_first_of(','));
379 binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
381 //if that name is in the .accnos file, add it
382 if (names.count(name) == 0) { newNames += name + ","; }
386 if (names.count(binnames) == 0) { newNames += binnames + ","; }
388 //if there are names in this bin add to new list
389 if (newNames != "") {
390 newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
391 newList.push_back(newNames);
395 //print new listvector
396 if (newList.getNumBins() != 0) {
397 wroteSomething = true;
406 if (wroteSomething == false) { m->mothurOut("Your list file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
407 outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName);
412 catch(exception& e) {
413 m->errorOut(e, "RemoveLineageCommand", "readList");
417 //**********************************************************************************************************************
418 int RemoveLineageCommand::readName(){
420 string thisOutputDir = outputDir;
421 if (outputDir == "") { thisOutputDir += m->hasPath(namefile); }
422 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
425 m->openOutputFile(outputFileName, out);
428 m->openInputFile(namefile, in);
429 string name, firstCol, secondCol;
431 bool wroteSomething = false;
434 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
439 vector<string> parsedNames;
440 m->splitAtComma(secondCol, parsedNames);
442 vector<string> validSecond; validSecond.clear();
443 for (int i = 0; i < parsedNames.size(); i++) {
444 if (names.count(parsedNames[i]) == 0) {
445 validSecond.push_back(parsedNames[i]);
449 if ((dups) && (validSecond.size() != parsedNames.size())) { //if dups is true and we want to get rid of anyone, get rid of everyone
450 for (int i = 0; i < parsedNames.size(); i++) { names.insert(parsedNames[i]); }
452 //if the name in the first column is in the set then print it and any other names in second column also in set
453 if (names.count(firstCol) == 0) {
455 wroteSomething = true;
457 out << firstCol << '\t';
459 //you know you have at least one valid second since first column is valid
460 for (int i = 0; i < validSecond.size()-1; i++) { out << validSecond[i] << ','; }
461 out << validSecond[validSecond.size()-1] << endl;
463 //make first name in set you come to first column and then add the remaining names to second column
466 //you want part of this row
467 if (validSecond.size() != 0) {
469 wroteSomething = true;
471 out << validSecond[0] << '\t';
473 //you know you have at least one valid second since first column is valid
474 for (int i = 0; i < validSecond.size()-1; i++) { out << validSecond[i] << ','; }
475 out << validSecond[validSecond.size()-1] << endl;
484 if (wroteSomething == false) { m->mothurOut("Your name file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
485 outputNames.push_back(outputFileName); outputTypes["name"].push_back(outputFileName);
489 catch(exception& e) {
490 m->errorOut(e, "RemoveLineageCommand", "readName");
495 //**********************************************************************************************************************
496 int RemoveLineageCommand::readGroup(){
498 string thisOutputDir = outputDir;
499 if (outputDir == "") { thisOutputDir += m->hasPath(groupfile); }
500 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
503 m->openOutputFile(outputFileName, out);
506 m->openInputFile(groupfile, in);
509 bool wroteSomething = false;
512 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
514 in >> name; //read from first column
515 in >> group; //read from second column
517 //if this name is in the accnos file
518 if (names.count(name) == 0) {
519 wroteSomething = true;
520 out << name << '\t' << group << endl;
528 if (wroteSomething == false) { m->mothurOut("Your group file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
529 outputNames.push_back(outputFileName); outputTypes["group"].push_back(outputFileName);
533 catch(exception& e) {
534 m->errorOut(e, "RemoveLineageCommand", "readGroup");
538 //**********************************************************************************************************************
539 int RemoveLineageCommand::readTax(){
541 string thisOutputDir = outputDir;
542 if (outputDir == "") { thisOutputDir += m->hasPath(taxfile); }
543 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
545 m->openOutputFile(outputFileName, out);
548 m->openInputFile(taxfile, in);
551 bool wroteSomething = false;
553 vector<bool> taxonsHasConfidence; taxonsHasConfidence.resize(listOfTaxons.size(), false);
554 vector< vector< map<string, float> > > searchTaxons; searchTaxons.resize(listOfTaxons.size());
555 vector<string> noConfidenceTaxons; noConfidenceTaxons.resize(listOfTaxons.size(), "");
557 for (int i = 0; i < listOfTaxons.size(); i++) {
558 noConfidenceTaxons[i] = listOfTaxons[i];
559 int hasConPos = listOfTaxons[i].find_first_of('(');
560 if (hasConPos != string::npos) {
561 taxonsHasConfidence[i] = true;
562 searchTaxons[i] = getTaxons(listOfTaxons[i]);
563 noConfidenceTaxons[i] = listOfTaxons[i];
564 m->removeConfidences(noConfidenceTaxons[i]);
571 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
573 in >> name; //read from first column
574 in >> tax; //read from second column
578 for (int j = 0; j < listOfTaxons.size(); j++) {
581 //if the users file contains confidence scores we want to ignore them when searching for the taxons, unless the taxon has them
582 if (!taxonsHasConfidence[j]) {
584 int hasConfidences = tax.find_first_of('(');
585 if (hasConfidences != string::npos) {
587 m->removeConfidences(newtax);
590 int pos = newtax.find(noConfidenceTaxons[j]);
592 if (pos == string::npos) {
593 //wroteSomething = true;
594 //out << name << '\t' << tax << endl;
595 }else{ //this sequence contains the taxon the user wants to remove
600 }else{//if taxons has them and you don't them remove taxons
601 int hasConfidences = tax.find_first_of('(');
602 if (hasConfidences == string::npos) {
604 int pos = newtax.find(noConfidenceTaxons[j]);
606 if (pos == string::npos) {
607 //wroteSomething = true;
608 //out << name << '\t' << tax << endl;
609 }else{ //this sequence contains the taxon the user wants to remove
613 }else { //both have confidences so we want to make sure the users confidences are greater then or equal to the taxons
614 //first remove confidences from both and see if the taxonomy exists
616 string noNewTax = tax;
617 int hasConfidences = tax.find_first_of('(');
618 if (hasConfidences != string::npos) {
620 m->removeConfidences(noNewTax);
623 int pos = noNewTax.find(noConfidenceTaxons[j]);
625 if (pos != string::npos) { //if yes, then are the confidences okay
627 vector< map<string, float> > usersTaxon = getTaxons(newtax);
629 //the usersTaxon is most likely longer than the searchTaxons, and searchTaxon[0] may relate to userTaxon[4]
630 //we want to "line them up", so we will find the the index where the searchstring starts
632 for (int i = 0; i < usersTaxon.size(); i++) {
634 if (usersTaxon[i].begin()->first == searchTaxons[j][0].begin()->first) {
637 bool goodspot = true;
638 //is this really the start, or are we dealing with a taxon of the same name?
639 while ((spot < searchTaxons[j].size()) && ((i+spot) < usersTaxon.size())) {
640 if (usersTaxon[i+spot].begin()->first != searchTaxons[j][spot].begin()->first) { goodspot = false; break; }
644 if (goodspot) { break; }
648 for (int i = 0; i < searchTaxons[j].size(); i++) {
650 if ((i+index) < usersTaxon.size()) { //just in case, should never be false
651 if (usersTaxon[i+index].begin()->second < searchTaxons[j][i].begin()->second) { //is the users cutoff less than the search taxons
661 //passed the test so remove you
666 //wroteSomething = true;
667 //out << name << '\t' << tax << endl;
670 //wroteSomething = true;
671 //out << name << '\t' << tax << endl;
678 if (!remove) { wroteSomething = true; out << name << '\t' << tax << endl; }
684 if (!wroteSomething) { m->mothurOut("Your taxonomy file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
685 outputNames.push_back(outputFileName); outputTypes["taxonomy"].push_back(outputFileName);
690 catch(exception& e) {
691 m->errorOut(e, "RemoveLineageCommand", "readTax");
695 /**************************************************************************************************/
696 vector< map<string, float> > RemoveLineageCommand::getTaxons(string tax) {
699 vector< map<string, float> > t;
701 int taxLength = tax.length();
702 for(int i=0;i<taxLength;i++){
705 int openParen = taxon.find_first_of('(');
706 int closeParen = taxon.find_last_of(')');
708 string newtaxon, confidence;
709 if ((openParen != string::npos) && (closeParen != string::npos)) {
710 newtaxon = taxon.substr(0, openParen); //rip off confidence
711 confidence = taxon.substr((openParen+1), (closeParen-openParen-1));
717 convert(confidence, con);
719 map<string, float> temp;
720 temp[newtaxon] = con;
732 catch(exception& e) {
733 m->errorOut(e, "RemoveLineageCommand", "getTaxons");
737 //**********************************************************************************************************************
738 //alignreport file has a column header line then all other lines contain 16 columns. we just want the first column since that contains the name
739 int RemoveLineageCommand::readAlign(){
741 string thisOutputDir = outputDir;
742 if (outputDir == "") { thisOutputDir += m->hasPath(alignfile); }
743 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
746 m->openOutputFile(outputFileName, out);
749 m->openInputFile(alignfile, in);
752 bool wroteSomething = false;
754 //read column headers
755 for (int i = 0; i < 16; i++) {
756 if (!in.eof()) { in >> junk; out << junk << '\t'; }
762 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
764 in >> name; //read from first column
766 //if this name is in the accnos file
767 if (names.count(name) == 0) {
768 wroteSomething = true;
773 for (int i = 0; i < 15; i++) {
774 if (!in.eof()) { in >> junk; out << junk << '\t'; }
779 }else {//still read just don't do anything with it
782 for (int i = 0; i < 15; i++) {
783 if (!in.eof()) { in >> junk; }
793 if (wroteSomething == false) { m->mothurOut("Your align file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
794 outputNames.push_back(outputFileName); outputTypes["alignreport"].push_back(outputFileName);
799 catch(exception& e) {
800 m->errorOut(e, "RemoveLineageCommand", "readAlign");
804 //**********************************************************************************************************************