]> git.donarmstrong.com Git - mothur.git/blob - removelineagecommand.cpp
fixes while testing
[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);      if (temp == "not found") { temp = "false"; usedDups = ""; }
185                         dups = m->isTrue(temp);
186                         
187                         taxons = validParameter.validFile(parameters, "taxon", false);  
188                         if (taxons == "not found") { taxons = "";  m->mothurOut("No taxons given, please correct."); m->mothurOutEndLine();  abort = true;  }
189                         else { 
190                                 //rip off quotes
191                                 if (taxons[0] == '\'') {  taxons = taxons.substr(1); }
192                                 if (taxons[(taxons.length()-1)] == '\'') {  taxons = taxons.substr(0, (taxons.length()-1)); }
193                         }
194                         
195                         
196                         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; }
197                 
198                         if ((usedDups != "") && (namefile == "")) {  m->mothurOut("You may only use dups with the name option."); m->mothurOutEndLine();  abort = true; }                       
199
200                 }
201
202         }
203         catch(exception& e) {
204                 m->errorOut(e, "RemoveLineageCommand", "RemoveLineageCommand");
205                 exit(1);
206         }
207 }
208 //**********************************************************************************************************************
209
210 void RemoveLineageCommand::help(){
211         try {
212                 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");
213                 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");
214                 m->mothurOut("The remove.lineage command parameters are taxon, fasta, name, group, list, taxonomy, alignreport and dups.  You must provide taxonomy and taxon.\n");
215                 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");
216                 m->mothurOut("The taxon parameter allows you to select the taxons you would like to remove.\n");
217                 m->mothurOut("The remove.lineage command should be in the following format: remove.lineage(taxonomy=yourTaxonomyFile, taxon=yourTaxons).\n");
218                 m->mothurOut("Example remove.lineage(taxonomy=amazon.silva.taxonomy, taxon=Bacteria;Firmicutes;Bacilli;Lactobacillales;).\n");
219                 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");
220                 m->mothurOut("Example remove.lineage(taxonomy=amazon.silva.taxonomy, taxon='Bacteria;Firmicutes;Bacilli;Lactobacillales;').\n");
221                 m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
222         }
223         catch(exception& e) {
224                 m->errorOut(e, "RemoveLineageCommand", "help");
225                 exit(1);
226         }
227 }
228
229 //**********************************************************************************************************************
230
231 int RemoveLineageCommand::execute(){
232         try {
233                 
234                 if (abort == true) { return 0; }
235                 
236                 if (m->control_pressed) { return 0; }
237                 
238                 //read through the correct file and output lines you want to keep
239                 if (taxfile != "")                      {               readTax();              }  //fills the set of names to remove
240                 if (namefile != "")                     {               readName();             }
241                 if (fastafile != "")            {               readFasta();    }
242                 if (groupfile != "")            {               readGroup();    }
243                 if (alignfile != "")            {               readAlign();    }
244                 if (listfile != "")                     {               readList();             }
245                 
246                 
247                 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } return 0; }
248                 
249                 if (outputNames.size() != 0) {
250                         m->mothurOutEndLine();
251                         m->mothurOut("Output File Names: "); m->mothurOutEndLine();
252                         for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
253                         m->mothurOutEndLine();
254                 }
255                 
256                 return 0;               
257         }
258
259         catch(exception& e) {
260                 m->errorOut(e, "RemoveLineageCommand", "execute");
261                 exit(1);
262         }
263 }
264
265 //**********************************************************************************************************************
266 int RemoveLineageCommand::readFasta(){
267         try {
268                 string thisOutputDir = outputDir;
269                 if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
270                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
271                 
272                 ofstream out;
273                 m->openOutputFile(outputFileName, out);
274                 
275                 ifstream in;
276                 m->openInputFile(fastafile, in);
277                 string name;
278                 
279                 bool wroteSomething = false;
280                 
281                 while(!in.eof()){
282                         if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
283                         
284                         Sequence currSeq(in);
285                         name = currSeq.getName();
286                         
287                         if (name != "") {
288                                 //if this name is in the accnos file
289                                 if (names.count(name) == 0) {
290                                         wroteSomething = true;
291                                         
292                                         currSeq.printSequence(out);
293                                 }
294                         }
295                         m->gobble(in);
296                 }
297                 in.close();     
298                 out.close();
299                 
300                 if (wroteSomething == false) {  m->mothurOut("Your fasta file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
301                 outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName); 
302                 
303                 return 0;
304                 
305         }
306         catch(exception& e) {
307                 m->errorOut(e, "RemoveLineageCommand", "readFasta");
308                 exit(1);
309         }
310 }
311 //**********************************************************************************************************************
312 int RemoveLineageCommand::readList(){
313         try {
314                 string thisOutputDir = outputDir;
315                 if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
316                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
317                 
318                 ofstream out;
319                 m->openOutputFile(outputFileName, out);
320                 
321                 ifstream in;
322                 m->openInputFile(listfile, in);
323                 
324                 bool wroteSomething = false;
325                 
326                 while(!in.eof()){
327                         //read in list vector
328                         ListVector list(in);
329                         
330                         //make a new list vector
331                         ListVector newList;
332                         newList.setLabel(list.getLabel());
333                         
334                         //for each bin
335                         for (int i = 0; i < list.getNumBins(); i++) {
336                                 if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
337                         
338                                 //parse out names that are in accnos file
339                                 string binnames = list.get(i);
340                                 
341                                 string newNames = "";
342                                 while (binnames.find_first_of(',') != -1) { 
343                                         string name = binnames.substr(0,binnames.find_first_of(','));
344                                         binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
345                                         
346                                         //if that name is in the .accnos file, add it
347                                         if (names.count(name) == 0) {  newNames += name + ",";  }
348                                 }
349                         
350                                 //get last name
351                                 if (names.count(binnames) == 0) {  newNames += binnames + ",";  }
352
353                                 //if there are names in this bin add to new list
354                                 if (newNames != "") {  
355                                         newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
356                                         newList.push_back(newNames);    
357                                 }
358                         }
359                                 
360                         //print new listvector
361                         if (newList.getNumBins() != 0) {
362                                 wroteSomething = true;
363                                 newList.print(out);
364                         }
365                         
366                         m->gobble(in);
367                 }
368                 in.close();     
369                 out.close();
370                 
371                 if (wroteSomething == false) {  m->mothurOut("Your list file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
372                 outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName); 
373                                 
374                 return 0;
375
376         }
377         catch(exception& e) {
378                 m->errorOut(e, "RemoveLineageCommand", "readList");
379                 exit(1);
380         }
381 }
382 //**********************************************************************************************************************
383 int RemoveLineageCommand::readName(){
384         try {
385                 string thisOutputDir = outputDir;
386                 if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
387                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
388
389                 ofstream out;
390                 m->openOutputFile(outputFileName, out);
391
392                 ifstream in;
393                 m->openInputFile(namefile, in);
394                 string name, firstCol, secondCol;
395                 
396                 bool wroteSomething = false;
397                 
398                 while(!in.eof()){
399                         if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
400
401                         in >> firstCol;                         
402                         in >> secondCol;                        
403
404                         vector<string> parsedNames;
405                         //parse second column saving each name
406                         while (secondCol.find_first_of(',') != -1) { 
407                                 name = secondCol.substr(0,secondCol.find_first_of(','));
408                                 secondCol = secondCol.substr(secondCol.find_first_of(',')+1, secondCol.length());
409                                 parsedNames.push_back(name);
410                         }
411                         
412                         //get name after last ,
413                         parsedNames.push_back(secondCol);
414
415                         vector<string> validSecond;  validSecond.clear();
416                         for (int i = 0; i < parsedNames.size(); i++) {
417                                 if (names.count(parsedNames[i]) == 0) {
418                                         validSecond.push_back(parsedNames[i]);
419                                 }
420                         }
421                         
422                         if ((dups) && (validSecond.size() != parsedNames.size())) {  //if dups is true and we want to get rid of anyone, get rid of everyone
423                                 for (int i = 0; i < parsedNames.size(); i++) {  names.insert(parsedNames[i]);  }
424                         }else {
425                                         //if the name in the first column is in the set then print it and any other names in second column also in set
426                                 if (names.count(firstCol) == 0) {
427                                         
428                                         wroteSomething = true;
429                                         
430                                         out << firstCol << '\t';
431                                         
432                                         //you know you have at least one valid second since first column is valid
433                                         for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
434                                         out << validSecond[validSecond.size()-1] << endl;
435                                         
436                                         //make first name in set you come to first column and then add the remaining names to second column
437                                 }else {
438                                         
439                                         //you want part of this row
440                                         if (validSecond.size() != 0) {
441                                                 
442                                                 wroteSomething = true;
443                                                 
444                                                 out << validSecond[0] << '\t';
445                                                 
446                                                 //you know you have at least one valid second since first column is valid
447                                                 for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
448                                                 out << validSecond[validSecond.size()-1] << endl;
449                                         }
450                                 }
451                         }
452                         m->gobble(in);
453                 }
454                 in.close();
455                 out.close();
456
457                 if (wroteSomething == false) {  m->mothurOut("Your name file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
458                 outputNames.push_back(outputFileName); outputTypes["name"].push_back(outputFileName);
459                                 
460                 return 0;
461         }
462         catch(exception& e) {
463                 m->errorOut(e, "RemoveLineageCommand", "readName");
464                 exit(1);
465         }
466 }
467
468 //**********************************************************************************************************************
469 int RemoveLineageCommand::readGroup(){
470         try {
471                 string thisOutputDir = outputDir;
472                 if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
473                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
474                 
475                 ofstream out;
476                 m->openOutputFile(outputFileName, out);
477
478                 ifstream in;
479                 m->openInputFile(groupfile, in);
480                 string name, group;
481                 
482                 bool wroteSomething = false;
483                 
484                 while(!in.eof()){
485                         if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
486                         
487                         in >> name;                             //read from first column
488                         in >> group;                    //read from second column
489                         
490                         //if this name is in the accnos file
491                         if (names.count(name) == 0) {
492                                 wroteSomething = true;
493                                 out << name << '\t' << group << endl;
494                         }
495                                         
496                         m->gobble(in);
497                 }
498                 in.close();
499                 out.close();
500                 
501                 if (wroteSomething == false) {  m->mothurOut("Your group file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
502                 outputNames.push_back(outputFileName); outputTypes["group"].push_back(outputFileName);
503                 
504                 return 0;
505         }
506         catch(exception& e) {
507                 m->errorOut(e, "RemoveLineageCommand", "readGroup");
508                 exit(1);
509         }
510 }
511 //**********************************************************************************************************************
512 int RemoveLineageCommand::readTax(){
513         try {
514                 string thisOutputDir = outputDir;
515                 if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
516                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
517                 ofstream out;
518                 m->openOutputFile(outputFileName, out);
519                 
520                 ifstream in;
521                 m->openInputFile(taxfile, in);
522                 string name, tax;
523                 
524                 bool wroteSomething = false;
525                 
526                 while(!in.eof()){
527
528                         if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str());  return 0; }
529
530                         in >> name;                             //read from first column
531                         in >> tax;                      //read from second column
532                         
533                         string newtax = tax;
534                         
535                         //if the users file contains confidence scores we want to ignore them when searching for the taxons
536                         int hasConfidences = tax.find_first_of('(');
537                         if (hasConfidences != string::npos) { 
538                                 newtax = removeConfidences(tax);
539                         }
540                         
541                         int pos = newtax.find(taxons);
542                         
543                         if (pos == string::npos) { 
544                                 wroteSomething = true;
545                                 out << name << '\t' << tax << endl;
546                         }else{ //this sequence contains the taxon the user wants to remove
547                                 names.insert(name);
548                         }
549                         
550                         m->gobble(in);
551                 }
552                 in.close();
553                 out.close();
554                 
555                 if (!wroteSomething) { m->mothurOut("Your taxonomy file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
556                 outputNames.push_back(outputFileName); outputTypes["taxonomy"].push_back(outputFileName);
557                         
558                 return 0;
559
560         }
561         catch(exception& e) {
562                 m->errorOut(e, "RemoveLineageCommand", "readTax");
563                 exit(1);
564         }
565 }
566 /**************************************************************************************************/
567 string RemoveLineageCommand::removeConfidences(string tax) {
568         try {
569                 
570                 string taxon = "";
571                 int taxLength = tax.length();
572                 for(int i=0;i<taxLength;i++){
573                         if(tax[i] == ';'){
574                                 taxon = taxon.substr(0, taxon.find_first_of('(')); //rip off confidence
575                                 taxon += ";";
576                         }
577                         else{
578                                 taxon += tax[i];
579                         }
580                 }
581                                 
582                 return taxon;
583         }
584         catch(exception& e) {
585                 m->errorOut(e, "RemoveLineageCommand", "removeConfidences");
586                 exit(1);
587         }
588 }
589 //**********************************************************************************************************************
590 //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
591 int RemoveLineageCommand::readAlign(){
592         try {
593                 string thisOutputDir = outputDir;
594                 if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
595                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
596                 
597                 ofstream out;
598                 m->openOutputFile(outputFileName, out);
599
600                 ifstream in;
601                 m->openInputFile(alignfile, in);
602                 string name, junk;
603                 
604                 bool wroteSomething = false;
605                 
606                 //read column headers
607                 for (int i = 0; i < 16; i++) {  
608                         if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
609                         else                    {       break;                  }
610                 }
611                 out << endl;
612                 
613                 while(!in.eof()){
614                         if (m->control_pressed) { in.close();  out.close();  remove(outputFileName.c_str());  return 0; }
615                         
616                         in >> name;                             //read from first column
617                         
618                         //if this name is in the accnos file
619                         if (names.count(name) == 0) {
620                                 wroteSomething = true;
621                                 
622                                 out << name << '\t';
623                                 
624                                 //read rest
625                                 for (int i = 0; i < 15; i++) {  
626                                         if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
627                                         else                    {       break;                  }
628                                 }
629                                 out << endl;
630                                 
631                         }else {//still read just don't do anything with it
632                                 
633                                 //read rest
634                                 for (int i = 0; i < 15; i++) {  
635                                         if (!in.eof())  {       in >> junk;             }
636                                         else                    {       break;                  }
637                                 }
638                         }
639                         
640                         m->gobble(in);
641                 }
642                 in.close();
643                 out.close();
644                 
645                 if (wroteSomething == false) {  m->mothurOut("Your align file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
646                 outputNames.push_back(outputFileName); outputTypes["alignreport"].push_back(outputFileName);
647                 
648                 return 0;
649                 
650         }
651         catch(exception& e) {
652                 m->errorOut(e, "RemoveLineageCommand", "readAlign");
653                 exit(1);
654         }
655 }
656 //**********************************************************************************************************************
657