]> git.donarmstrong.com Git - mothur.git/blob - removelineagecommand.cpp
added indicator command
[mothur.git] / removelineagecommand.cpp
1 /*
2  *  removelineagecommand.cpp
3  *  Mothur
4  *
5  *  Created by westcott on 9/24/10.
6  *  Copyright 2010 Schloss Lab. All rights reserved.
7  *
8  */
9
10 #include "removelineagecommand.h"
11 #include "sequence.hpp"
12 #include "listvector.hpp"
13
14 //**********************************************************************************************************************
15 vector<string> RemoveLineageCommand::getValidParameters(){      
16         try {
17                 string Array[] =  {"fasta","name", "group", "alignreport", "taxon", "dups", "list","taxonomy","outputdir","inputdir"};
18                 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
19                 return myArray;
20         }
21         catch(exception& e) {
22                 m->errorOut(e, "RemoveLineageCommand", "getValidParameters");
23                 exit(1);
24         }
25 }
26 //**********************************************************************************************************************
27 RemoveLineageCommand::RemoveLineageCommand(){   
28         try {
29                 abort = true;
30                 //initialize outputTypes
31                 vector<string> tempOutNames;
32                 outputTypes["fasta"] = tempOutNames;
33                 outputTypes["taxonomy"] = tempOutNames;
34                 outputTypes["name"] = tempOutNames;
35                 outputTypes["group"] = tempOutNames;
36                 outputTypes["alignreport"] = tempOutNames;
37                 outputTypes["list"] = tempOutNames;
38         }
39         catch(exception& e) {
40                 m->errorOut(e, "RemoveLineageCommand", "RemoveLineageCommand");
41                 exit(1);
42         }
43 }
44 //**********************************************************************************************************************
45 vector<string> RemoveLineageCommand::getRequiredParameters(){   
46         try {
47                 string Array[] =  {"taxonomy"};
48                 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
49                 return myArray;
50         }
51         catch(exception& e) {
52                 m->errorOut(e, "RemoveLineageCommand", "getRequiredParameters");
53                 exit(1);
54         }
55 }
56 //**********************************************************************************************************************
57 vector<string> RemoveLineageCommand::getRequiredFiles(){        
58         try {
59                 vector<string> myArray;
60                 return myArray;
61         }
62         catch(exception& e) {
63                 m->errorOut(e, "RemoveLineageCommand", "getRequiredFiles");
64                 exit(1);
65         }
66 }
67 //**********************************************************************************************************************
68 RemoveLineageCommand::RemoveLineageCommand(string option)  {
69         try {
70                 abort = false;
71                                 
72                 //allow user to run help
73                 if(option == "help") { help(); abort = true; }
74                 
75                 else {
76                         //valid paramters for this command
77                         string Array[] =  {"fasta","name", "group", "alignreport", "taxon", "dups", "list","taxonomy","outputdir","inputdir"};
78                         vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
79                         
80                         OptionParser parser(option);
81                         map<string,string> parameters = parser.getParameters();
82                         
83                         ValidParameters validParameter;
84                         map<string,string>::iterator it;
85                         
86                         //check to make sure all parameters are valid for command
87                         for (it = parameters.begin(); it != parameters.end(); it++) { 
88                                 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
89                         }
90                         
91                         //initialize outputTypes
92                         vector<string> tempOutNames;
93                         outputTypes["fasta"] = tempOutNames;
94                         outputTypes["taxonomy"] = tempOutNames;
95                         outputTypes["name"] = tempOutNames;
96                         outputTypes["group"] = tempOutNames;
97                         outputTypes["alignreport"] = tempOutNames;
98                         outputTypes["list"] = tempOutNames;
99                         
100                         //if the user changes the output directory command factory will send this info to us in the output parameter 
101                         outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
102                         
103                         //if the user changes the input directory command factory will send this info to us in the output parameter 
104                         string inputDir = validParameter.validFile(parameters, "inputdir", false);              
105                         if (inputDir == "not found"){   inputDir = "";          }
106                         else {
107                                 string path;
108                                 it = parameters.find("alignreport");
109                                 //user has given a template file
110                                 if(it != parameters.end()){ 
111                                         path = m->hasPath(it->second);
112                                         //if the user has not given a path then, add inputdir. else leave path alone.
113                                         if (path == "") {       parameters["alignreport"] = inputDir + it->second;              }
114                                 }
115                                 
116                                 it = parameters.find("fasta");
117                                 //user has given a template file
118                                 if(it != parameters.end()){ 
119                                         path = m->hasPath(it->second);
120                                         //if the user has not given a path then, add inputdir. else leave path alone.
121                                         if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
122                                 }
123                                 
124                                 it = parameters.find("list");
125                                 //user has given a template file
126                                 if(it != parameters.end()){ 
127                                         path = m->hasPath(it->second);
128                                         //if the user has not given a path then, add inputdir. else leave path alone.
129                                         if (path == "") {       parameters["list"] = inputDir + it->second;             }
130                                 }
131                                 
132                                 it = parameters.find("name");
133                                 //user has given a template file
134                                 if(it != parameters.end()){ 
135                                         path = m->hasPath(it->second);
136                                         //if the user has not given a path then, add inputdir. else leave path alone.
137                                         if (path == "") {       parameters["name"] = inputDir + it->second;             }
138                                 }
139                                 
140                                 it = parameters.find("group");
141                                 //user has given a template file
142                                 if(it != parameters.end()){ 
143                                         path = m->hasPath(it->second);
144                                         //if the user has not given a path then, add inputdir. else leave path alone.
145                                         if (path == "") {       parameters["group"] = inputDir + it->second;            }
146                                 }
147                                 
148                                 it = parameters.find("taxonomy");
149                                 //user has given a template file
150                                 if(it != parameters.end()){ 
151                                         path = m->hasPath(it->second);
152                                         //if the user has not given a path then, add inputdir. else leave path alone.
153                                         if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
154                                 }
155                         }
156
157                         
158                         //check for required parameters                 
159                         fastafile = validParameter.validFile(parameters, "fasta", true);
160                         if (fastafile == "not open") { abort = true; }
161                         else if (fastafile == "not found") {  fastafile = "";  }        
162                         
163                         namefile = validParameter.validFile(parameters, "name", true);
164                         if (namefile == "not open") { abort = true; }
165                         else if (namefile == "not found") {  namefile = "";  }  
166                         
167                         groupfile = validParameter.validFile(parameters, "group", true);
168                         if (groupfile == "not open") { abort = true; }
169                         else if (groupfile == "not found") {  groupfile = "";  }        
170                         
171                         alignfile = validParameter.validFile(parameters, "alignreport", true);
172                         if (alignfile == "not open") { abort = true; }
173                         else if (alignfile == "not found") {  alignfile = "";  }
174                         
175                         listfile = validParameter.validFile(parameters, "list", true);
176                         if (listfile == "not open") { abort = true; }
177                         else if (listfile == "not found") {  listfile = "";  }
178                         
179                         taxfile = validParameter.validFile(parameters, "taxonomy", true);
180                         if (taxfile == "not open") { abort = true; }
181                         else if (taxfile == "not found") {  taxfile = ""; m->mothurOut("The taxonomy parameter is required for the get.lineage command."); m->mothurOutEndLine();  abort = true; }
182                         
183                         string usedDups = "true";
184                         string temp = validParameter.validFile(parameters, "dups", false);      
185                         if (temp == "not found") { 
186                                 if (namefile != "") {  temp = "true";                                   }
187                                 else                            {  temp = "false"; usedDups = "";       }
188                         }
189                         dups = m->isTrue(temp);
190                         
191                         taxons = validParameter.validFile(parameters, "taxon", false);  
192                         if (taxons == "not found") { taxons = "";  m->mothurOut("No taxons given, please correct."); m->mothurOutEndLine();  abort = true;  }
193                         else { 
194                                 //rip off quotes
195                                 if (taxons[0] == '\'') {  taxons = taxons.substr(1); }
196                                 if (taxons[(taxons.length()-1)] == '\'') {  taxons = taxons.substr(0, (taxons.length()-1)); }
197                         }
198                         
199                         
200                         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; }
201                 
202                         if ((usedDups != "") && (namefile == "")) {  m->mothurOut("You may only use dups with the name option."); m->mothurOutEndLine();  abort = true; }                       
203
204                 }
205
206         }
207         catch(exception& e) {
208                 m->errorOut(e, "RemoveLineageCommand", "RemoveLineageCommand");
209                 exit(1);
210         }
211 }
212 //**********************************************************************************************************************
213
214 void RemoveLineageCommand::help(){
215         try {
216                 m->mothurOut("The remove.lineage command reads a taxonomy file and any of the following file types: fasta, name, group, list or alignreport file.\n");
217                 m->mothurOut("It outputs a file containing only the sequences from the taxonomy file that are not from the taxon you requested to be removed.\n");
218                 m->mothurOut("The remove.lineage command parameters are taxon, fasta, name, group, list, taxonomy, alignreport and dups.  You must provide taxonomy and taxon.\n");
219                 m->mothurOut("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");
220                 m->mothurOut("The taxon parameter allows you to select the taxons you would like to remove.\n");
221                 m->mothurOut("The remove.lineage command should be in the following format: remove.lineage(taxonomy=yourTaxonomyFile, taxon=yourTaxons).\n");
222                 m->mothurOut("Example remove.lineage(taxonomy=amazon.silva.taxonomy, taxon=Bacteria;Firmicutes;Bacilli;Lactobacillales;).\n");
223                 m->mothurOut("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");
224                 m->mothurOut("Example remove.lineage(taxonomy=amazon.silva.taxonomy, taxon='Bacteria;Firmicutes;Bacilli;Lactobacillales;').\n");
225                 m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
226         }
227         catch(exception& e) {
228                 m->errorOut(e, "RemoveLineageCommand", "help");
229                 exit(1);
230         }
231 }
232
233 //**********************************************************************************************************************
234
235 int RemoveLineageCommand::execute(){
236         try {
237                 
238                 if (abort == true) { return 0; }
239                 
240                 if (m->control_pressed) { return 0; }
241                 
242                 //read through the correct file and output lines you want to keep
243                 if (taxfile != "")                      {               readTax();              }  //fills the set of names to remove
244                 if (namefile != "")                     {               readName();             }
245                 if (fastafile != "")            {               readFasta();    }
246                 if (groupfile != "")            {               readGroup();    }
247                 if (alignfile != "")            {               readAlign();    }
248                 if (listfile != "")                     {               readList();             }
249                 
250                 
251                 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } return 0; }
252                 
253                 if (outputNames.size() != 0) {
254                         m->mothurOutEndLine();
255                         m->mothurOut("Output File Names: "); m->mothurOutEndLine();
256                         for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
257                         m->mothurOutEndLine();
258                 }
259                 
260                 return 0;               
261         }
262
263         catch(exception& e) {
264                 m->errorOut(e, "RemoveLineageCommand", "execute");
265                 exit(1);
266         }
267 }
268
269 //**********************************************************************************************************************
270 int RemoveLineageCommand::readFasta(){
271         try {
272                 string thisOutputDir = outputDir;
273                 if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
274                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
275                 
276                 ofstream out;
277                 m->openOutputFile(outputFileName, out);
278                 
279                 ifstream in;
280                 m->openInputFile(fastafile, in);
281                 string name;
282                 
283                 bool wroteSomething = false;
284                 
285                 while(!in.eof()){
286                         if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
287                         
288                         Sequence currSeq(in);
289                         name = currSeq.getName();
290                         
291                         if (name != "") {
292                                 //if this name is in the accnos file
293                                 if (names.count(name) == 0) {
294                                         wroteSomething = true;
295                                         
296                                         currSeq.printSequence(out);
297                                 }
298                         }
299                         m->gobble(in);
300                 }
301                 in.close();     
302                 out.close();
303                 
304                 if (wroteSomething == false) {  m->mothurOut("Your fasta file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
305                 outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName); 
306                 
307                 return 0;
308                 
309         }
310         catch(exception& e) {
311                 m->errorOut(e, "RemoveLineageCommand", "readFasta");
312                 exit(1);
313         }
314 }
315 //**********************************************************************************************************************
316 int RemoveLineageCommand::readList(){
317         try {
318                 string thisOutputDir = outputDir;
319                 if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
320                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
321                 
322                 ofstream out;
323                 m->openOutputFile(outputFileName, out);
324                 
325                 ifstream in;
326                 m->openInputFile(listfile, in);
327                 
328                 bool wroteSomething = false;
329                 
330                 while(!in.eof()){
331                         //read in list vector
332                         ListVector list(in);
333                         
334                         //make a new list vector
335                         ListVector newList;
336                         newList.setLabel(list.getLabel());
337                         
338                         //for each bin
339                         for (int i = 0; i < list.getNumBins(); i++) {
340                                 if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
341                         
342                                 //parse out names that are in accnos file
343                                 string binnames = list.get(i);
344                                 
345                                 string newNames = "";
346                                 while (binnames.find_first_of(',') != -1) { 
347                                         string name = binnames.substr(0,binnames.find_first_of(','));
348                                         binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
349                                         
350                                         //if that name is in the .accnos file, add it
351                                         if (names.count(name) == 0) {  newNames += name + ",";  }
352                                 }
353                         
354                                 //get last name
355                                 if (names.count(binnames) == 0) {  newNames += binnames + ",";  }
356
357                                 //if there are names in this bin add to new list
358                                 if (newNames != "") {  
359                                         newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
360                                         newList.push_back(newNames);    
361                                 }
362                         }
363                                 
364                         //print new listvector
365                         if (newList.getNumBins() != 0) {
366                                 wroteSomething = true;
367                                 newList.print(out);
368                         }
369                         
370                         m->gobble(in);
371                 }
372                 in.close();     
373                 out.close();
374                 
375                 if (wroteSomething == false) {  m->mothurOut("Your list file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
376                 outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName); 
377                                 
378                 return 0;
379
380         }
381         catch(exception& e) {
382                 m->errorOut(e, "RemoveLineageCommand", "readList");
383                 exit(1);
384         }
385 }
386 //**********************************************************************************************************************
387 int RemoveLineageCommand::readName(){
388         try {
389                 string thisOutputDir = outputDir;
390                 if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
391                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
392
393                 ofstream out;
394                 m->openOutputFile(outputFileName, out);
395
396                 ifstream in;
397                 m->openInputFile(namefile, in);
398                 string name, firstCol, secondCol;
399                 
400                 bool wroteSomething = false;
401                 
402                 while(!in.eof()){
403                         if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
404
405                         in >> firstCol;                         
406                         in >> secondCol;                        
407
408                         vector<string> parsedNames;
409                         //parse second column saving each name
410                         while (secondCol.find_first_of(',') != -1) { 
411                                 name = secondCol.substr(0,secondCol.find_first_of(','));
412                                 secondCol = secondCol.substr(secondCol.find_first_of(',')+1, secondCol.length());
413                                 parsedNames.push_back(name);
414                         }
415                         
416                         //get name after last ,
417                         parsedNames.push_back(secondCol);
418
419                         vector<string> validSecond;  validSecond.clear();
420                         for (int i = 0; i < parsedNames.size(); i++) {
421                                 if (names.count(parsedNames[i]) == 0) {
422                                         validSecond.push_back(parsedNames[i]);
423                                 }
424                         }
425                         
426                         if ((dups) && (validSecond.size() != parsedNames.size())) {  //if dups is true and we want to get rid of anyone, get rid of everyone
427                                 for (int i = 0; i < parsedNames.size(); i++) {  names.insert(parsedNames[i]);  }
428                         }else {
429                                         //if the name in the first column is in the set then print it and any other names in second column also in set
430                                 if (names.count(firstCol) == 0) {
431                                         
432                                         wroteSomething = true;
433                                         
434                                         out << firstCol << '\t';
435                                         
436                                         //you know you have at least one valid second since first column is valid
437                                         for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
438                                         out << validSecond[validSecond.size()-1] << endl;
439                                         
440                                         //make first name in set you come to first column and then add the remaining names to second column
441                                 }else {
442                                         
443                                         //you want part of this row
444                                         if (validSecond.size() != 0) {
445                                                 
446                                                 wroteSomething = true;
447                                                 
448                                                 out << validSecond[0] << '\t';
449                                                 
450                                                 //you know you have at least one valid second since first column is valid
451                                                 for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
452                                                 out << validSecond[validSecond.size()-1] << endl;
453                                         }
454                                 }
455                         }
456                         m->gobble(in);
457                 }
458                 in.close();
459                 out.close();
460
461                 if (wroteSomething == false) {  m->mothurOut("Your name file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
462                 outputNames.push_back(outputFileName); outputTypes["name"].push_back(outputFileName);
463                                 
464                 return 0;
465         }
466         catch(exception& e) {
467                 m->errorOut(e, "RemoveLineageCommand", "readName");
468                 exit(1);
469         }
470 }
471
472 //**********************************************************************************************************************
473 int RemoveLineageCommand::readGroup(){
474         try {
475                 string thisOutputDir = outputDir;
476                 if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
477                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
478                 
479                 ofstream out;
480                 m->openOutputFile(outputFileName, out);
481
482                 ifstream in;
483                 m->openInputFile(groupfile, in);
484                 string name, group;
485                 
486                 bool wroteSomething = false;
487                 
488                 while(!in.eof()){
489                         if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
490                         
491                         in >> name;                             //read from first column
492                         in >> group;                    //read from second column
493                         
494                         //if this name is in the accnos file
495                         if (names.count(name) == 0) {
496                                 wroteSomething = true;
497                                 out << name << '\t' << group << endl;
498                         }
499                                         
500                         m->gobble(in);
501                 }
502                 in.close();
503                 out.close();
504                 
505                 if (wroteSomething == false) {  m->mothurOut("Your group file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
506                 outputNames.push_back(outputFileName); outputTypes["group"].push_back(outputFileName);
507                 
508                 return 0;
509         }
510         catch(exception& e) {
511                 m->errorOut(e, "RemoveLineageCommand", "readGroup");
512                 exit(1);
513         }
514 }
515 //**********************************************************************************************************************
516 int RemoveLineageCommand::readTax(){
517         try {
518                 string thisOutputDir = outputDir;
519                 if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
520                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
521                 ofstream out;
522                 m->openOutputFile(outputFileName, out);
523                 
524                 ifstream in;
525                 m->openInputFile(taxfile, in);
526                 string name, tax;
527                 
528                 bool wroteSomething = false;
529                 
530                 while(!in.eof()){
531
532                         if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str());  return 0; }
533
534                         in >> name;                             //read from first column
535                         in >> tax;                      //read from second column
536                         
537                         string newtax = tax;
538                         
539                         //if the users file contains confidence scores we want to ignore them when searching for the taxons
540                         int hasConfidences = tax.find_first_of('(');
541                         if (hasConfidences != string::npos) { 
542                                 newtax = removeConfidences(tax);
543                         }
544                         
545                         int pos = newtax.find(taxons);
546                         
547                         if (pos == string::npos) { 
548                                 wroteSomething = true;
549                                 out << name << '\t' << tax << endl;
550                         }else{ //this sequence contains the taxon the user wants to remove
551                                 names.insert(name);
552                         }
553                         
554                         m->gobble(in);
555                 }
556                 in.close();
557                 out.close();
558                 
559                 if (!wroteSomething) { m->mothurOut("Your taxonomy file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
560                 outputNames.push_back(outputFileName); outputTypes["taxonomy"].push_back(outputFileName);
561                         
562                 return 0;
563
564         }
565         catch(exception& e) {
566                 m->errorOut(e, "RemoveLineageCommand", "readTax");
567                 exit(1);
568         }
569 }
570 /**************************************************************************************************/
571 string RemoveLineageCommand::removeConfidences(string tax) {
572         try {
573                 
574                 string taxon = "";
575                 int taxLength = tax.length();
576                 for(int i=0;i<taxLength;i++){
577                         if(tax[i] == ';'){
578                                 taxon = taxon.substr(0, taxon.find_first_of('(')); //rip off confidence
579                                 taxon += ";";
580                         }
581                         else{
582                                 taxon += tax[i];
583                         }
584                 }
585                                 
586                 return taxon;
587         }
588         catch(exception& e) {
589                 m->errorOut(e, "RemoveLineageCommand", "removeConfidences");
590                 exit(1);
591         }
592 }
593 //**********************************************************************************************************************
594 //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
595 int RemoveLineageCommand::readAlign(){
596         try {
597                 string thisOutputDir = outputDir;
598                 if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
599                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
600                 
601                 ofstream out;
602                 m->openOutputFile(outputFileName, out);
603
604                 ifstream in;
605                 m->openInputFile(alignfile, in);
606                 string name, junk;
607                 
608                 bool wroteSomething = false;
609                 
610                 //read column headers
611                 for (int i = 0; i < 16; i++) {  
612                         if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
613                         else                    {       break;                  }
614                 }
615                 out << endl;
616                 
617                 while(!in.eof()){
618                         if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
619                         
620                         in >> name;                             //read from first column
621                         
622                         //if this name is in the accnos file
623                         if (names.count(name) == 0) {
624                                 wroteSomething = true;
625                                 
626                                 out << name << '\t';
627                                 
628                                 //read rest
629                                 for (int i = 0; i < 15; i++) {  
630                                         if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
631                                         else                    {       break;                  }
632                                 }
633                                 out << endl;
634                                 
635                         }else {//still read just don't do anything with it
636                                 
637                                 //read rest
638                                 for (int i = 0; i < 15; i++) {  
639                                         if (!in.eof())  {       in >> junk;             }
640                                         else                    {       break;                  }
641                                 }
642                         }
643                         
644                         m->gobble(in);
645                 }
646                 in.close();
647                 out.close();
648                 
649                 if (wroteSomething == false) {  m->mothurOut("Your align file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
650                 outputNames.push_back(outputFileName); outputTypes["alignreport"].push_back(outputFileName);
651                 
652                 return 0;
653                 
654         }
655         catch(exception& e) {
656                 m->errorOut(e, "RemoveLineageCommand", "readAlign");
657                 exit(1);
658         }
659 }
660 //**********************************************************************************************************************
661