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