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"
13 #include "counttable.h"
14 #include "inputdata.h"
16 //**********************************************************************************************************************
17 vector<string> RemoveLineageCommand::setParameters(){
19 CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none","fasta",false,false,true); parameters.push_back(pfasta);
20 CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none","name",false,false,true); parameters.push_back(pname);
21 CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "FNGLT", "none","count",false,false,true); parameters.push_back(pcount);
22 CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "FNGLT", "none","group",false,false,true); parameters.push_back(pgroup);
23 CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none","list",false,false,true); parameters.push_back(plist);
24 CommandParameter pshared("shared", "InputTypes", "", "", "none", "FNGLT", "none","shared",false,false, true); parameters.push_back(pshared);
25 CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "tax", "FNGLT", "none","taxonomy",false,false, true); parameters.push_back(ptaxonomy);
26 CommandParameter pconstaxonomy("constaxonomy", "InputTypes", "", "", "tax", "FNGLT", "none","constaxonomy",false,false, true); parameters.push_back(pconstaxonomy);
27 CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none","alignreport",false,false); parameters.push_back(palignreport);
28 CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
29 CommandParameter ptaxon("taxon", "String", "", "", "", "", "","",false,true,true); parameters.push_back(ptaxon);
30 CommandParameter pdups("dups", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pdups);
31 CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
32 CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
34 vector<string> myArray;
35 for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
39 m->errorOut(e, "RemoveLineageCommand", "setParameters");
43 //**********************************************************************************************************************
44 string RemoveLineageCommand::getHelpString(){
46 string helpString = "";
47 helpString += "The remove.lineage command reads a taxonomy or constaxonomy file and any of the following file types: fasta, name, group, count, list, shared or alignreport file. The constaxonomy can only be used with a shared or list file.\n";
48 helpString += "It outputs a file containing only the sequences or OTUS from the taxonomy file that are not from the taxon you requested to be removed.\n";
49 helpString += "The remove.lineage command parameters are taxon, fasta, name, group, count, list, shared, taxonomy, alignreport, label and dups. You must provide taxonomy or constaxonomy unless you have a valid current taxonomy file.\n";
50 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";
51 helpString += "The taxon parameter allows you to select the taxons you would like to remove, and is required.\n";
52 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";
53 helpString += "If they belong to the taxonomy and have confidences above those you provide the sequence will not be removed.\n";
54 helpString += "The label parameter is used to analyze specific labels in your input. \n";
55 helpString += "The remove.lineage command should be in the following format: remove.lineage(taxonomy=yourTaxonomyFile, taxon=yourTaxons).\n";
56 helpString += "Example remove.lineage(taxonomy=amazon.silva.taxonomy, taxon=Bacteria;Firmicutes;Bacilli;Lactobacillales;).\n";
57 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";
58 helpString += "Example remove.lineage(taxonomy=amazon.silva.taxonomy, taxon='Bacteria;Firmicutes;Bacilli;Lactobacillales;').\n";
59 helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
63 m->errorOut(e, "RemoveLineageCommand", "getHelpString");
67 //**********************************************************************************************************************
68 string RemoveLineageCommand::getOutputPattern(string type) {
72 if (type == "fasta") { pattern = "[filename],pick,[extension]"; }
73 else if (type == "taxonomy") { pattern = "[filename],pick,[extension]"; }
74 else if (type == "constaxonomy") { pattern = "[filename],pick,[extension]"; }
75 else if (type == "name") { pattern = "[filename],pick,[extension]"; }
76 else if (type == "group") { pattern = "[filename],pick,[extension]"; }
77 else if (type == "count") { pattern = "[filename],pick,[extension]"; }
78 else if (type == "list") { pattern = "[filename],[distance],pick,[extension]"; }
79 else if (type == "shared") { pattern = "[filename],[distance],pick,[extension]"; }
80 else if (type == "alignreport") { pattern = "[filename],pick.align.report"; }
81 else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; }
86 m->errorOut(e, "RemoveLineageCommand", "getOutputPattern");
91 //**********************************************************************************************************************
92 RemoveLineageCommand::RemoveLineageCommand(){
94 abort = true; calledHelp = true;
96 vector<string> tempOutNames;
97 outputTypes["fasta"] = tempOutNames;
98 outputTypes["taxonomy"] = tempOutNames;
99 outputTypes["name"] = tempOutNames;
100 outputTypes["group"] = tempOutNames;
101 outputTypes["alignreport"] = tempOutNames;
102 outputTypes["list"] = tempOutNames;
103 outputTypes["count"] = tempOutNames;
104 outputTypes["constaxonomy"] = tempOutNames;
105 outputTypes["shared"] = tempOutNames;
108 catch(exception& e) {
109 m->errorOut(e, "RemoveLineageCommand", "RemoveLineageCommand");
113 //**********************************************************************************************************************
114 RemoveLineageCommand::RemoveLineageCommand(string option) {
116 abort = false; calledHelp = false;
118 //allow user to run help
119 if(option == "help") { help(); abort = true; calledHelp = true; }
120 else if(option == "citation") { citation(); abort = true; calledHelp = true;}
123 vector<string> myArray = setParameters();
125 OptionParser parser(option);
126 map<string,string> parameters = parser.getParameters();
128 ValidParameters validParameter;
129 map<string,string>::iterator it;
131 //check to make sure all parameters are valid for command
132 for (it = parameters.begin(); it != parameters.end(); it++) {
133 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
136 //initialize outputTypes
137 vector<string> tempOutNames;
138 outputTypes["fasta"] = tempOutNames;
139 outputTypes["taxonomy"] = tempOutNames;
140 outputTypes["name"] = tempOutNames;
141 outputTypes["group"] = tempOutNames;
142 outputTypes["alignreport"] = tempOutNames;
143 outputTypes["list"] = tempOutNames;
144 outputTypes["count"] = tempOutNames;
145 outputTypes["constaxonomy"] = tempOutNames;
146 outputTypes["shared"] = tempOutNames;
149 //if the user changes the output directory command factory will send this info to us in the output parameter
150 outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; }
152 //if the user changes the input directory command factory will send this info to us in the output parameter
153 string inputDir = validParameter.validFile(parameters, "inputdir", false);
154 if (inputDir == "not found"){ inputDir = ""; }
157 it = parameters.find("alignreport");
158 //user has given a template file
159 if(it != parameters.end()){
160 path = m->hasPath(it->second);
161 //if the user has not given a path then, add inputdir. else leave path alone.
162 if (path == "") { parameters["alignreport"] = inputDir + it->second; }
165 it = parameters.find("fasta");
166 //user has given a template file
167 if(it != parameters.end()){
168 path = m->hasPath(it->second);
169 //if the user has not given a path then, add inputdir. else leave path alone.
170 if (path == "") { parameters["fasta"] = inputDir + it->second; }
173 it = parameters.find("list");
174 //user has given a template file
175 if(it != parameters.end()){
176 path = m->hasPath(it->second);
177 //if the user has not given a path then, add inputdir. else leave path alone.
178 if (path == "") { parameters["list"] = inputDir + it->second; }
181 it = parameters.find("name");
182 //user has given a template file
183 if(it != parameters.end()){
184 path = m->hasPath(it->second);
185 //if the user has not given a path then, add inputdir. else leave path alone.
186 if (path == "") { parameters["name"] = inputDir + it->second; }
189 it = parameters.find("group");
190 //user has given a template file
191 if(it != parameters.end()){
192 path = m->hasPath(it->second);
193 //if the user has not given a path then, add inputdir. else leave path alone.
194 if (path == "") { parameters["group"] = inputDir + it->second; }
197 it = parameters.find("taxonomy");
198 //user has given a template file
199 if(it != parameters.end()){
200 path = m->hasPath(it->second);
201 //if the user has not given a path then, add inputdir. else leave path alone.
202 if (path == "") { parameters["taxonomy"] = inputDir + it->second; }
205 it = parameters.find("count");
206 //user has given a template file
207 if(it != parameters.end()){
208 path = m->hasPath(it->second);
209 //if the user has not given a path then, add inputdir. else leave path alone.
210 if (path == "") { parameters["count"] = inputDir + it->second; }
213 it = parameters.find("constaxonomy");
214 //user has given a template file
215 if(it != parameters.end()){
216 path = m->hasPath(it->second);
217 //if the user has not given a path then, add inputdir. else leave path alone.
218 if (path == "") { parameters["constaxonomy"] = inputDir + it->second; }
221 it = parameters.find("shared");
222 //user has given a template file
223 if(it != parameters.end()){
224 path = m->hasPath(it->second);
225 //if the user has not given a path then, add inputdir. else leave path alone.
226 if (path == "") { parameters["shared"] = inputDir + it->second; }
231 //check for required parameters
232 fastafile = validParameter.validFile(parameters, "fasta", true);
233 if (fastafile == "not open") { fastafile = ""; abort = true; }
234 else if (fastafile == "not found") { fastafile = ""; }
235 else { m->setFastaFile(fastafile); }
237 namefile = validParameter.validFile(parameters, "name", true);
238 if (namefile == "not open") { namefile = ""; abort = true; }
239 else if (namefile == "not found") { namefile = ""; }
240 else { m->setNameFile(namefile); }
242 groupfile = validParameter.validFile(parameters, "group", true);
243 if (groupfile == "not open") { abort = true; }
244 else if (groupfile == "not found") { groupfile = ""; }
245 else { m->setGroupFile(groupfile); }
247 alignfile = validParameter.validFile(parameters, "alignreport", true);
248 if (alignfile == "not open") { abort = true; }
249 else if (alignfile == "not found") { alignfile = ""; }
251 listfile = validParameter.validFile(parameters, "list", true);
252 if (listfile == "not open") { abort = true; }
253 else if (listfile == "not found") { listfile = ""; }
254 else { m->setListFile(listfile); }
256 taxfile = validParameter.validFile(parameters, "taxonomy", true);
257 if (taxfile == "not open") { taxfile = ""; abort = true; }
258 else if (taxfile == "not found") { taxfile = ""; }
259 else { m->setTaxonomyFile(taxfile); }
261 sharedfile = validParameter.validFile(parameters, "shared", true);
262 if (sharedfile == "not open") { sharedfile = ""; abort = true; }
263 else if (sharedfile == "not found") { sharedfile = ""; }
264 else { m->setSharedFile(sharedfile); }
267 constaxonomy = validParameter.validFile(parameters, "constaxonomy", true);
268 if (constaxonomy == "not open") { constaxonomy = ""; abort = true; }
269 else if (constaxonomy == "not found") { constaxonomy = ""; }
271 if ((constaxonomy == "") && (taxfile == "")) {
272 taxfile = m->getTaxonomyFile();
273 if (taxfile != "") { m->mothurOut("Using " + taxfile + " as input file for the taxonomy parameter."); m->mothurOutEndLine(); }
275 m->mothurOut("You have no current taxonomy file and did not provide a constaxonomy file. The taxonomy or constaxonomy parameter is required."); m->mothurOutEndLine(); abort = true; }
279 countfile = validParameter.validFile(parameters, "count", true);
280 if (countfile == "not open") { countfile = ""; abort = true; }
281 else if (countfile == "not found") { countfile = ""; }
282 else { m->setCountTableFile(countfile); }
284 if ((namefile != "") && (countfile != "")) {
285 m->mothurOut("[ERROR]: you may only use one of the following: name or count."); m->mothurOutEndLine(); abort = true;
288 if ((groupfile != "") && (countfile != "")) {
289 m->mothurOut("[ERROR]: you may only use one of the following: group or count."); m->mothurOutEndLine(); abort=true;
292 string usedDups = "true";
293 string temp = validParameter.validFile(parameters, "dups", false);
294 if (temp == "not found") {
295 if (namefile != "") { temp = "true"; }
296 else { temp = "false"; usedDups = ""; }
298 dups = m->isTrue(temp);
300 taxons = validParameter.validFile(parameters, "taxon", false);
301 if (taxons == "not found") { taxons = ""; m->mothurOut("No taxons given, please correct."); m->mothurOutEndLine(); abort = true; }
304 if (taxons[0] == '\'') { taxons = taxons.substr(1); }
305 if (taxons[(taxons.length()-1)] == '\'') { taxons = taxons.substr(0, (taxons.length()-1)); }
307 m->splitAtChar(taxons, listOfTaxons, '-');
309 if ((fastafile == "") && (constaxonomy == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "") && (taxfile == "") && (countfile == "")) { m->mothurOut("You must provide one of the following: fasta, name, group, count, alignreport, taxonomy, constaxonomy, shared or listfile."); m->mothurOutEndLine(); abort = true; }
311 if ((constaxonomy != "") && ((fastafile != "") || (namefile != "") || (groupfile != "") || (alignfile != "") || (taxfile != "") || (countfile != ""))) {
312 m->mothurOut("[ERROR]: can only use constaxonomy file with a list or shared file, aborting.\n"); abort = true;
315 if ((constaxonomy != "") && (taxfile != "")) {
316 m->mothurOut("[ERROR]: Choose only one: taxonomy or constaxonomy, aborting.\n"); abort = true;
319 if ((sharedfile != "") && (taxfile != "")) {
320 m->mothurOut("[ERROR]: sharedfile can only be used with constaxonomy file, aborting.\n"); abort = true;
323 if ((sharedfile != "") || (listfile != "")) {
324 label = validParameter.validFile(parameters, "label", false);
325 if (label == "not found") { label = ""; m->mothurOut("You did not provide a label, I will use the first label in your inputfile."); m->mothurOutEndLine(); label=""; }
329 if ((usedDups != "") && (namefile == "")) { m->mothurOut("You may only use dups with the name option."); m->mothurOutEndLine(); abort = true; }
331 if (countfile == "") {
332 if ((namefile == "") && ((fastafile != "") || (taxfile != ""))){
333 vector<string> files; files.push_back(fastafile); files.push_back(taxfile);
334 parser.getNameFile(files);
341 catch(exception& e) {
342 m->errorOut(e, "RemoveLineageCommand", "RemoveLineageCommand");
346 //**********************************************************************************************************************
348 int RemoveLineageCommand::execute(){
351 if (abort == true) { if (calledHelp) { return 0; } return 2; }
353 if (m->control_pressed) { return 0; }
355 if (countfile != "") {
356 if ((fastafile != "") || (listfile != "") || (taxfile != "")) {
357 m->mothurOut("\n[NOTE]: The count file should contain only unique names, so mothur assumes your fasta, list and taxonomy files also contain only uniques.\n\n");
361 //read through the correct file and output lines you want to keep
363 readTax(); //fills the set of names to get
364 if (namefile != "") { readName(); }
365 if (fastafile != "") { readFasta(); }
366 if (countfile != "") { readCount(); }
367 if (groupfile != "") { readGroup(); }
368 if (alignfile != "") { readAlign(); }
369 if (listfile != "") { readList(); }
373 if (listfile != "") { readConsList(); }
374 if (sharedfile != "") { readShared(); }
378 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
380 if (outputNames.size() != 0) {
381 m->mothurOutEndLine();
382 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
383 for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
384 m->mothurOutEndLine();
386 //set fasta file as new current fastafile
388 itTypes = outputTypes.find("fasta");
389 if (itTypes != outputTypes.end()) {
390 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
393 itTypes = outputTypes.find("name");
394 if (itTypes != outputTypes.end()) {
395 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
398 itTypes = outputTypes.find("group");
399 if (itTypes != outputTypes.end()) {
400 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
403 itTypes = outputTypes.find("list");
404 if (itTypes != outputTypes.end()) {
405 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
408 itTypes = outputTypes.find("taxonomy");
409 if (itTypes != outputTypes.end()) {
410 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
413 itTypes = outputTypes.find("count");
414 if (itTypes != outputTypes.end()) {
415 if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setCountTableFile(current); }
422 catch(exception& e) {
423 m->errorOut(e, "RemoveLineageCommand", "execute");
428 //**********************************************************************************************************************
429 int RemoveLineageCommand::readFasta(){
431 string thisOutputDir = outputDir;
432 if (outputDir == "") { thisOutputDir += m->hasPath(fastafile); }
433 map<string, string> variables;
434 variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(fastafile));
435 variables["[extension]"] = m->getExtension(fastafile);
436 string outputFileName = getOutputFileName("fasta", variables);
438 m->openOutputFile(outputFileName, out);
441 m->openInputFile(fastafile, in);
444 bool wroteSomething = false;
447 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
449 Sequence currSeq(in);
450 name = currSeq.getName();
453 //if this name is in the accnos file
454 if (names.count(name) == 0) {
455 wroteSomething = true;
457 currSeq.printSequence(out);
465 if (wroteSomething == false) { m->mothurOut("Your fasta file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
466 outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName);
471 catch(exception& e) {
472 m->errorOut(e, "RemoveLineageCommand", "readFasta");
476 //**********************************************************************************************************************
477 int RemoveLineageCommand::readList(){
479 string thisOutputDir = outputDir;
480 if (outputDir == "") { thisOutputDir += m->hasPath(listfile); }
481 map<string, string> variables;
482 variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
483 variables["[extension]"] = m->getExtension(listfile);
486 m->openInputFile(listfile, in);
488 bool wroteSomething = false;
492 //read in list vector
495 //make a new list vector
497 newList.setLabel(list.getLabel());
499 variables["[distance]"] = list.getLabel();
500 string outputFileName = getOutputFileName("list", variables);
503 m->openOutputFile(outputFileName, out);
504 outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
506 if (m->control_pressed) { in.close(); out.close(); return 0; }
508 vector<string> binLabels = list.getLabels();
509 vector<string> newBinLabels;
512 for (int i = 0; i < list.getNumBins(); i++) {
513 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
515 //parse out names that are in accnos file
516 string binnames = list.get(i);
517 vector<string> bnames;
518 m->splitAtComma(binnames, bnames);
520 string newNames = "";
521 for (int j = 0; j < bnames.size(); j++) {
522 string name = bnames[j];
523 //if that name is in the .accnos file, add it
524 if (names.count(name) == 0) { newNames += name + ","; }
527 //if there are names in this bin add to new list
528 if (newNames != "") {
529 newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
530 newList.push_back(newNames);
531 newBinLabels.push_back(binLabels[i]);
535 //print new listvector
536 if (newList.getNumBins() != 0) {
537 wroteSomething = true;
538 newList.setLabels(newBinLabels);
539 newList.printHeaders(out);
549 if (wroteSomething == false) { m->mothurOut("Your list file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
554 catch(exception& e) {
555 m->errorOut(e, "RemoveLineageCommand", "readList");
559 //**********************************************************************************************************************
560 int RemoveLineageCommand::readName(){
562 string thisOutputDir = outputDir;
563 if (outputDir == "") { thisOutputDir += m->hasPath(namefile); }
564 map<string, string> variables;
565 variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(namefile));
566 variables["[extension]"] = m->getExtension(namefile);
567 string outputFileName = getOutputFileName("name", variables);
569 m->openOutputFile(outputFileName, out);
572 m->openInputFile(namefile, in);
573 string name, firstCol, secondCol;
575 bool wroteSomething = false;
578 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
583 vector<string> parsedNames;
584 m->splitAtComma(secondCol, parsedNames);
586 vector<string> validSecond; validSecond.clear();
587 for (int i = 0; i < parsedNames.size(); i++) {
588 if (names.count(parsedNames[i]) == 0) {
589 validSecond.push_back(parsedNames[i]);
593 if ((dups) && (validSecond.size() != parsedNames.size())) { //if dups is true and we want to get rid of anyone, get rid of everyone
594 for (int i = 0; i < parsedNames.size(); i++) { names.insert(parsedNames[i]); }
596 //if the name in the first column is in the set then print it and any other names in second column also in set
597 if (names.count(firstCol) == 0) {
599 wroteSomething = true;
601 out << firstCol << '\t';
603 //you know you have at least one valid second since first column is valid
604 for (int i = 0; i < validSecond.size()-1; i++) { out << validSecond[i] << ','; }
605 out << validSecond[validSecond.size()-1] << endl;
607 //make first name in set you come to first column and then add the remaining names to second column
610 //you want part of this row
611 if (validSecond.size() != 0) {
613 wroteSomething = true;
615 out << validSecond[0] << '\t';
617 //you know you have at least one valid second since first column is valid
618 for (int i = 0; i < validSecond.size()-1; i++) { out << validSecond[i] << ','; }
619 out << validSecond[validSecond.size()-1] << endl;
628 if (wroteSomething == false) { m->mothurOut("Your name file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
629 outputNames.push_back(outputFileName); outputTypes["name"].push_back(outputFileName);
633 catch(exception& e) {
634 m->errorOut(e, "RemoveLineageCommand", "readName");
638 //**********************************************************************************************************************
639 int RemoveLineageCommand::readCount(){
641 string thisOutputDir = outputDir;
642 if (outputDir == "") { thisOutputDir += m->hasPath(countfile); }
643 map<string, string> variables;
644 variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(countfile));
645 variables["[extension]"] = m->getExtension(countfile);
646 string outputFileName = getOutputFileName("count", variables);
650 m->openOutputFile(outputFileName, out);
653 m->openInputFile(countfile, in);
655 bool wroteSomething = false;
657 string headers = m->getline(in); m->gobble(in);
658 out << headers << endl;
660 string name, rest; int thisTotal;
663 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
665 in >> name; m->gobble(in);
666 in >> thisTotal; m->gobble(in);
667 rest = m->getline(in); m->gobble(in);
668 if (m->debug) { m->mothurOut("[DEBUG]: " + name + '\t' + rest + "\n"); }
670 if (names.count(name) == 0) {
671 out << name << '\t' << thisTotal << '\t' << rest << endl;
672 wroteSomething = true;
678 //check for groups that have been eliminated
680 if (ct.testGroups(outputFileName)) {
681 ct.readTable(outputFileName, true, false);
682 ct.printTable(outputFileName);
685 if (wroteSomething == false) { m->mothurOut("Your group file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
686 outputTypes["count"].push_back(outputFileName); outputNames.push_back(outputFileName);
690 catch(exception& e) {
691 m->errorOut(e, "RemoveLineageCommand", "readCount");
695 //**********************************************************************************************************************
696 int RemoveLineageCommand::readConsList(){
700 if (m->control_pressed) { delete list; return 0;}
703 newList.setLabel(list->getLabel());
704 int removedCount = 0;
705 bool wroteSomething = false;
706 string snumBins = toString(list->getNumBins());
708 vector<string> binLabels = list->getLabels();
709 vector<string> newBinLabels;
710 for (int i = 0; i < list->getNumBins(); i++) {
712 if (m->control_pressed) { delete list; return 0;}
714 //create a label for this otu
715 string otuLabel = "Otu";
716 string sbinNumber = toString(i+1);
717 if (sbinNumber.length() < snumBins.length()) {
718 int diff = snumBins.length() - sbinNumber.length();
719 for (int h = 0; h < diff; h++) { otuLabel += "0"; }
721 otuLabel += sbinNumber;
723 if (names.count(m->getSimpleLabel(otuLabel)) == 0) {
724 newList.push_back(list->get(i));
725 newBinLabels.push_back(binLabels[i]);
726 }else { removedCount++; }
729 string thisOutputDir = outputDir;
730 if (outputDir == "") { thisOutputDir += m->hasPath(listfile); }
731 map<string, string> variables;
732 variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
733 variables["[extension]"] = m->getExtension(listfile);
734 variables["[distance]"] = list->getLabel();
735 string outputFileName = getOutputFileName("list", variables);
737 m->openOutputFile(outputFileName, out);
740 //print new listvector
741 if (newList.getNumBins() != 0) {
742 wroteSomething = true;
743 newList.setLabels(newBinLabels);
744 newList.printHeaders(out);
749 if (wroteSomething == false) { m->mothurOut("Your file only contains OTUs from " + taxons + "."); m->mothurOutEndLine(); }
750 outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName);
752 m->mothurOut("Removed " + toString(removedCount) + " OTUs from your list file."); m->mothurOutEndLine();
757 catch(exception& e) {
758 m->errorOut(e, "RemoveLineageCommand", "readConsList");
762 //**********************************************************************************************************************
763 int RemoveLineageCommand::getListVector(){
765 InputData input(listfile, "list");
766 list = input.getListVector();
767 string lastLabel = list->getLabel();
769 if (label == "") { label = lastLabel; return 0; }
771 //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
772 set<string> labels; labels.insert(label);
773 set<string> processedLabels;
774 set<string> userLabels = labels;
776 //as long as you are not at the end of the file or done wih the lines you want
777 while((list != NULL) && (userLabels.size() != 0)) {
778 if (m->control_pressed) { return 0; }
780 if(labels.count(list->getLabel()) == 1){
781 processedLabels.insert(list->getLabel());
782 userLabels.erase(list->getLabel());
786 if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
787 string saveLabel = list->getLabel();
790 list = input.getListVector(lastLabel);
792 processedLabels.insert(list->getLabel());
793 userLabels.erase(list->getLabel());
795 //restore real lastlabel to save below
796 list->setLabel(saveLabel);
800 lastLabel = list->getLabel();
802 //get next line to process
803 //prevent memory leak
805 list = input.getListVector();
809 if (m->control_pressed) { return 0; }
811 //output error messages about any remaining user labels
812 set<string>::iterator it;
813 bool needToRun = false;
814 for (it = userLabels.begin(); it != userLabels.end(); it++) {
815 m->mothurOut("Your file does not include the label " + *it);
816 if (processedLabels.count(lastLabel) != 1) {
817 m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
820 m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
824 //run last label if you need to
825 if (needToRun == true) {
827 list = input.getListVector(lastLabel);
832 catch(exception& e) {
833 m->errorOut(e, "RemoveLineageCommand", "getListVector");
838 //**********************************************************************************************************************
839 int RemoveLineageCommand::readShared(){
844 if (m->control_pressed) { for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } return 0; }
846 vector<string> newLabels;
848 //create new "filtered" lookup
849 vector<SharedRAbundVector*> newLookup;
850 for (int i = 0; i < lookup.size(); i++) {
851 SharedRAbundVector* temp = new SharedRAbundVector();
852 temp->setLabel(lookup[i]->getLabel());
853 temp->setGroup(lookup[i]->getGroup());
854 newLookup.push_back(temp);
857 bool wroteSomething = false;
859 for (int i = 0; i < lookup[0]->getNumBins(); i++) {
861 if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; }
863 //is this otu on the list
864 if (names.count(m->getSimpleLabel(m->currentSharedBinLabels[i])) == 0) {
865 wroteSomething = true;
866 newLabels.push_back(m->currentSharedBinLabels[i]);
867 for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup
868 newLookup[j]->push_back(lookup[j]->getAbundance(i), lookup[j]->getGroup());
870 }else { numRemoved++; }
873 string thisOutputDir = outputDir;
874 if (outputDir == "") { thisOutputDir += m->hasPath(sharedfile); }
875 map<string, string> variables;
876 variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile));
877 variables["[extension]"] = m->getExtension(sharedfile);
878 variables["[distance]"] = lookup[0]->getLabel();
879 string outputFileName = getOutputFileName("shared", variables);
881 m->openOutputFile(outputFileName, out);
882 outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName);
884 for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; }
886 m->currentSharedBinLabels = newLabels;
888 newLookup[0]->printHeaders(out);
890 for (int i = 0; i < newLookup.size(); i++) {
891 out << newLookup[i]->getLabel() << '\t' << newLookup[i]->getGroup() << '\t';
892 newLookup[i]->print(out);
896 for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; }
898 if (wroteSomething == false) { m->mothurOut("Your file only contains OTUs from " + taxons + "."); m->mothurOutEndLine(); }
900 m->mothurOut("Removed " + toString(numRemoved) + " OTUs from your shared file."); m->mothurOutEndLine();
904 catch(exception& e) {
905 m->errorOut(e, "RemoveLineageCommand", "readShared");
909 //**********************************************************************************************************************
910 int RemoveLineageCommand::getShared(){
912 InputData input(sharedfile, "sharedfile");
913 lookup = input.getSharedRAbundVectors();
914 string lastLabel = lookup[0]->getLabel();
916 if (label == "") { label = lastLabel; return 0; }
918 //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
919 set<string> labels; labels.insert(label);
920 set<string> processedLabels;
921 set<string> userLabels = labels;
923 //as long as you are not at the end of the file or done wih the lines you want
924 while((lookup[0] != NULL) && (userLabels.size() != 0)) {
925 if (m->control_pressed) { return 0; }
927 if(labels.count(lookup[0]->getLabel()) == 1){
928 processedLabels.insert(lookup[0]->getLabel());
929 userLabels.erase(lookup[0]->getLabel());
933 if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
934 string saveLabel = lookup[0]->getLabel();
936 for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
937 lookup = input.getSharedRAbundVectors(lastLabel);
939 processedLabels.insert(lookup[0]->getLabel());
940 userLabels.erase(lookup[0]->getLabel());
942 //restore real lastlabel to save below
943 lookup[0]->setLabel(saveLabel);
947 lastLabel = lookup[0]->getLabel();
949 //get next line to process
950 //prevent memory leak
951 for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
952 lookup = input.getSharedRAbundVectors();
956 if (m->control_pressed) { return 0; }
958 //output error messages about any remaining user labels
959 set<string>::iterator it;
960 bool needToRun = false;
961 for (it = userLabels.begin(); it != userLabels.end(); it++) {
962 m->mothurOut("Your file does not include the label " + *it);
963 if (processedLabels.count(lastLabel) != 1) {
964 m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
967 m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
971 //run last label if you need to
972 if (needToRun == true) {
973 for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }
974 lookup = input.getSharedRAbundVectors(lastLabel);
979 catch(exception& e) {
980 m->errorOut(e, "RemoveLineageCommand", "getShared");
986 //**********************************************************************************************************************
987 int RemoveLineageCommand::readGroup(){
989 string thisOutputDir = outputDir;
990 if (outputDir == "") { thisOutputDir += m->hasPath(groupfile); }
991 map<string, string> variables;
992 variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
993 variables["[extension]"] = m->getExtension(groupfile);
994 string outputFileName = getOutputFileName("group", variables);
997 m->openOutputFile(outputFileName, out);
1000 m->openInputFile(groupfile, in);
1003 bool wroteSomething = false;
1006 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
1008 in >> name; //read from first column
1009 in >> group; //read from second column
1011 //if this name is in the accnos file
1012 if (names.count(name) == 0) {
1013 wroteSomething = true;
1014 out << name << '\t' << group << endl;
1022 if (wroteSomething == false) { m->mothurOut("Your group file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
1023 outputNames.push_back(outputFileName); outputTypes["group"].push_back(outputFileName);
1027 catch(exception& e) {
1028 m->errorOut(e, "RemoveLineageCommand", "readGroup");
1032 //**********************************************************************************************************************
1033 int RemoveLineageCommand::readTax(){
1035 string thisOutputDir = outputDir;
1036 if (outputDir == "") { thisOutputDir += m->hasPath(taxfile); }
1037 map<string, string> variables;
1038 variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(taxfile));
1039 variables["[extension]"] = m->getExtension(taxfile);
1040 string outputFileName = getOutputFileName("taxonomy", variables);
1042 m->openOutputFile(outputFileName, out);
1045 m->openInputFile(taxfile, in);
1048 bool wroteSomething = false;
1050 vector<bool> taxonsHasConfidence; taxonsHasConfidence.resize(listOfTaxons.size(), false);
1051 vector< vector< map<string, float> > > searchTaxons; searchTaxons.resize(listOfTaxons.size());
1052 vector<string> noConfidenceTaxons; noConfidenceTaxons.resize(listOfTaxons.size(), "");
1054 for (int i = 0; i < listOfTaxons.size(); i++) {
1055 noConfidenceTaxons[i] = listOfTaxons[i];
1056 int hasConPos = listOfTaxons[i].find_first_of('(');
1057 if (hasConPos != string::npos) {
1058 taxonsHasConfidence[i] = true;
1059 searchTaxons[i] = getTaxons(listOfTaxons[i]);
1060 noConfidenceTaxons[i] = listOfTaxons[i];
1061 m->removeConfidences(noConfidenceTaxons[i]);
1068 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
1070 in >> name; //read from first column
1071 in >> tax; //read from second column
1073 bool remove = false;
1075 string noQuotesTax = m->removeQuotes(tax);
1077 for (int j = 0; j < listOfTaxons.size(); j++) {
1078 string newtax = noQuotesTax;
1080 //if the users file contains confidence scores we want to ignore them when searching for the taxons, unless the taxon has them
1081 if (!taxonsHasConfidence[j]) {
1083 int hasConfidences = noQuotesTax.find_first_of('(');
1084 if (hasConfidences != string::npos) {
1085 newtax = noQuotesTax;
1086 m->removeConfidences(newtax);
1089 int pos = newtax.find(noConfidenceTaxons[j]);
1091 if (pos == string::npos) {
1092 //wroteSomething = true;
1093 //out << name << '\t' << tax << endl;
1094 }else{ //this sequence contains the taxon the user wants to remove
1099 }else{//if taxons has them and you don't them remove taxons
1100 int hasConfidences = noQuotesTax.find_first_of('(');
1101 if (hasConfidences == string::npos) {
1103 int pos = newtax.find(noConfidenceTaxons[j]);
1105 if (pos == string::npos) {
1106 //wroteSomething = true;
1107 //out << name << '\t' << tax << endl;
1108 }else{ //this sequence contains the taxon the user wants to remove
1112 }else { //both have confidences so we want to make sure the users confidences are greater then or equal to the taxons
1113 //first remove confidences from both and see if the taxonomy exists
1115 string noNewTax = noQuotesTax;
1116 int hasConfidences = noQuotesTax.find_first_of('(');
1117 if (hasConfidences != string::npos) {
1118 noNewTax = noQuotesTax;
1119 m->removeConfidences(noNewTax);
1122 int pos = noNewTax.find(noConfidenceTaxons[j]);
1124 if (pos != string::npos) { //if yes, then are the confidences okay
1126 vector< map<string, float> > usersTaxon = getTaxons(newtax);
1128 //the usersTaxon is most likely longer than the searchTaxons, and searchTaxon[0] may relate to userTaxon[4]
1129 //we want to "line them up", so we will find the the index where the searchstring starts
1131 for (int i = 0; i < usersTaxon.size(); i++) {
1133 if (usersTaxon[i].begin()->first == searchTaxons[j][0].begin()->first) {
1136 bool goodspot = true;
1137 //is this really the start, or are we dealing with a taxon of the same name?
1138 while ((spot < searchTaxons[j].size()) && ((i+spot) < usersTaxon.size())) {
1139 if (usersTaxon[i+spot].begin()->first != searchTaxons[j][spot].begin()->first) { goodspot = false; break; }
1143 if (goodspot) { break; }
1147 for (int i = 0; i < searchTaxons[j].size(); i++) {
1149 if ((i+index) < usersTaxon.size()) { //just in case, should never be false
1150 if (usersTaxon[i+index].begin()->second < searchTaxons[j][i].begin()->second) { //is the users cutoff less than the search taxons
1160 //passed the test so remove you
1165 //wroteSomething = true;
1166 //out << name << '\t' << tax << endl;
1169 //wroteSomething = true;
1170 //out << name << '\t' << tax << endl;
1177 if (!remove) { wroteSomething = true; out << name << '\t' << tax << endl; }
1183 if (!wroteSomething) { m->mothurOut("Your taxonomy file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
1184 outputNames.push_back(outputFileName); outputTypes["taxonomy"].push_back(outputFileName);
1189 catch(exception& e) {
1190 m->errorOut(e, "RemoveLineageCommand", "readTax");
1194 //**********************************************************************************************************************
1195 int RemoveLineageCommand::readConsTax(){
1197 string thisOutputDir = outputDir;
1198 if (outputDir == "") { thisOutputDir += m->hasPath(constaxonomy); }
1199 map<string, string> variables;
1200 variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(constaxonomy));
1201 variables["[extension]"] = m->getExtension(constaxonomy);
1202 string outputFileName = getOutputFileName("constaxonomy", variables);
1204 m->openOutputFile(outputFileName, out);
1207 m->openInputFile(constaxonomy, in);
1208 string otuLabel, tax;
1210 bool wroteSomething = false;
1213 string headers = m->getline(in);
1214 out << headers << endl;
1216 //bool wroteSomething = false;
1217 vector<bool> taxonsHasConfidence; taxonsHasConfidence.resize(listOfTaxons.size(), false);
1218 vector< vector< map<string, float> > > searchTaxons; searchTaxons.resize(listOfTaxons.size());
1219 vector<string> noConfidenceTaxons; noConfidenceTaxons.resize(listOfTaxons.size(), "");
1221 for (int i = 0; i < listOfTaxons.size(); i++) {
1222 noConfidenceTaxons[i] = listOfTaxons[i];
1223 int hasConPos = listOfTaxons[i].find_first_of('(');
1224 if (hasConPos != string::npos) {
1225 taxonsHasConfidence[i] = true;
1226 searchTaxons[i] = getTaxons(listOfTaxons[i]);
1227 noConfidenceTaxons[i] = listOfTaxons[i];
1228 m->removeConfidences(noConfidenceTaxons[i]);
1235 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
1237 in >> otuLabel; m->gobble(in);
1238 in >> numReps; m->gobble(in);
1239 in >> tax; m->gobble(in);
1241 bool remove = false;
1243 string noQuotesTax = m->removeQuotes(tax);
1245 for (int j = 0; j < listOfTaxons.size(); j++) {
1246 string newtax = noQuotesTax;
1248 //if the users file contains confidence scores we want to ignore them when searching for the taxons, unless the taxon has them
1249 if (!taxonsHasConfidence[j]) {
1251 int hasConfidences = noQuotesTax.find_first_of('(');
1252 if (hasConfidences != string::npos) {
1253 newtax = noQuotesTax;
1254 m->removeConfidences(newtax);
1257 int pos = newtax.find(noConfidenceTaxons[j]);
1259 if (pos == string::npos) {
1260 //wroteSomething = true;
1261 //out << name << '\t' << tax << endl;
1262 }else{ //this sequence contains the taxon the user wants to remove
1263 names.insert(m->getSimpleLabel(otuLabel));
1267 }else{//if taxons has them and you don't them remove taxons
1268 int hasConfidences = noQuotesTax.find_first_of('(');
1269 if (hasConfidences == string::npos) {
1271 int pos = newtax.find(noConfidenceTaxons[j]);
1273 if (pos == string::npos) {
1274 //wroteSomething = true;
1275 //out << name << '\t' << tax << endl;
1276 }else{ //this sequence contains the taxon the user wants to remove
1277 names.insert(m->getSimpleLabel(otuLabel));
1280 }else { //both have confidences so we want to make sure the users confidences are greater then or equal to the taxons
1281 //first remove confidences from both and see if the taxonomy exists
1283 string noNewTax = noQuotesTax;
1284 int hasConfidences = noQuotesTax.find_first_of('(');
1285 if (hasConfidences != string::npos) {
1286 noNewTax = noQuotesTax;
1287 m->removeConfidences(noNewTax);
1290 int pos = noNewTax.find(noConfidenceTaxons[j]);
1292 if (pos != string::npos) { //if yes, then are the confidences okay
1294 vector< map<string, float> > usersTaxon = getTaxons(newtax);
1296 //the usersTaxon is most likely longer than the searchTaxons, and searchTaxon[0] may relate to userTaxon[4]
1297 //we want to "line them up", so we will find the the index where the searchstring starts
1299 for (int i = 0; i < usersTaxon.size(); i++) {
1301 if (usersTaxon[i].begin()->first == searchTaxons[j][0].begin()->first) {
1304 bool goodspot = true;
1305 //is this really the start, or are we dealing with a taxon of the same name?
1306 while ((spot < searchTaxons[j].size()) && ((i+spot) < usersTaxon.size())) {
1307 if (usersTaxon[i+spot].begin()->first != searchTaxons[j][spot].begin()->first) { goodspot = false; break; }
1311 if (goodspot) { break; }
1315 for (int i = 0; i < searchTaxons[j].size(); i++) {
1317 if ((i+index) < usersTaxon.size()) { //just in case, should never be false
1318 if (usersTaxon[i+index].begin()->second < searchTaxons[j][i].begin()->second) { //is the users cutoff less than the search taxons
1328 //passed the test so remove you
1330 names.insert(m->getSimpleLabel(otuLabel));
1333 //wroteSomething = true;
1334 //out << name << '\t' << tax << endl;
1337 //wroteSomething = true;
1338 //out << name << '\t' << tax << endl;
1345 if (!remove) { wroteSomething = true; out << otuLabel << '\t' << numReps << '\t' << tax << endl; }
1351 if (names.size() == 0) { m->mothurOut("Your constaxonomy file contains OTUs only from " + taxons + "."); m->mothurOutEndLine(); }
1352 outputNames.push_back(outputFileName); outputTypes["constaxonomy"].push_back(outputFileName);
1357 catch(exception& e) {
1358 m->errorOut(e, "RemoveLineageCommand", "readConsTax");
1362 /**************************************************************************************************/
1363 vector< map<string, float> > RemoveLineageCommand::getTaxons(string tax) {
1366 vector< map<string, float> > t;
1368 int taxLength = tax.length();
1369 for(int i=0;i<taxLength;i++){
1372 int openParen = taxon.find_last_of('(');
1373 int closeParen = taxon.find_last_of(')');
1375 string newtaxon, confidence;
1376 if ((openParen != string::npos) && (closeParen != string::npos)) {
1377 string confidenceScore = taxon.substr(openParen+1, (closeParen-(openParen+1)));
1378 if (m->isNumeric1(confidenceScore)) { //its a confidence
1379 newtaxon = taxon.substr(0, openParen); //rip off confidence
1380 confidence = taxon.substr((openParen+1), (closeParen-openParen-1));
1381 }else { //its part of the taxon
1390 convert(confidence, con);
1392 map<string, float> temp;
1393 temp[newtaxon] = con;
1404 catch(exception& e) {
1405 m->errorOut(e, "RemoveLineageCommand", "getTaxons");
1409 //**********************************************************************************************************************
1410 //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
1411 int RemoveLineageCommand::readAlign(){
1413 string thisOutputDir = outputDir;
1414 if (outputDir == "") { thisOutputDir += m->hasPath(alignfile); }
1415 map<string, string> variables;
1416 variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(alignfile));
1417 variables["[extension]"] = m->getExtension(alignfile);
1418 string outputFileName = getOutputFileName("alignreport", variables);
1421 m->openOutputFile(outputFileName, out);
1424 m->openInputFile(alignfile, in);
1427 bool wroteSomething = false;
1429 //read column headers
1430 for (int i = 0; i < 16; i++) {
1431 if (!in.eof()) { in >> junk; out << junk << '\t'; }
1437 if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
1439 in >> name; //read from first column
1441 //if this name is in the accnos file
1442 if (names.count(name) == 0) {
1443 wroteSomething = true;
1445 out << name << '\t';
1448 for (int i = 0; i < 15; i++) {
1449 if (!in.eof()) { in >> junk; out << junk << '\t'; }
1454 }else {//still read just don't do anything with it
1457 for (int i = 0; i < 15; i++) {
1458 if (!in.eof()) { in >> junk; }
1468 if (wroteSomething == false) { m->mothurOut("Your align file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
1469 outputNames.push_back(outputFileName); outputTypes["alignreport"].push_back(outputFileName);
1474 catch(exception& e) {
1475 m->errorOut(e, "RemoveLineageCommand", "readAlign");
1479 //**********************************************************************************************************************