]> git.donarmstrong.com Git - mothur.git/blob - getlineagecommand.cpp
testing 1.14.0
[mothur.git] / getlineagecommand.cpp
1 /*
2  *  getlineagecommand.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 "getlineagecommand.h"
11 #include "sequence.hpp"
12 #include "listvector.hpp"
13
14
15 //**********************************************************************************************************************
16 vector<string> GetLineageCommand::getValidParameters(){ 
17         try {
18                 string Array[] =  {"fasta","name", "group", "alignreport", "taxon", "dups", "list","taxonomy","outputdir","inputdir"};
19                 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
20                 return myArray;
21         }
22         catch(exception& e) {
23                 m->errorOut(e, "GetLineageCommand", "getValidParameters");
24                 exit(1);
25         }
26 }
27 //**********************************************************************************************************************
28 GetLineageCommand::GetLineageCommand(){ 
29         try {
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, "GetLineageCommand", "GetLineageCommand");
41                 exit(1);
42         }
43 }
44 //**********************************************************************************************************************
45 vector<string> GetLineageCommand::getRequiredParameters(){      
46         try {
47                 string Array[] =  {"taxonomy","taxon"};
48                 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
49                 return myArray;
50         }
51         catch(exception& e) {
52                 m->errorOut(e, "GetLineageCommand", "getRequiredParameters");
53                 exit(1);
54         }
55 }
56 //**********************************************************************************************************************
57 vector<string> GetLineageCommand::getRequiredFiles(){   
58         try {
59                 vector<string> myArray;
60                 return myArray;
61         }
62         catch(exception& e) {
63                 m->errorOut(e, "GetLineageCommand", "getRequiredFiles");
64                 exit(1);
65         }
66 }
67 //**********************************************************************************************************************
68 GetLineageCommand::GetLineageCommand(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, "GetLineageCommand", "GetLineageCommand");
205                 exit(1);
206         }
207 }
208 //**********************************************************************************************************************
209
210 void GetLineageCommand::help(){
211         try {
212                 m->mothurOut("The get.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 from the taxon requested.\n");
214                 m->mothurOut("The get.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 get.\n");
217                 m->mothurOut("The get.lineage command should be in the following format: get.lineage(taxonomy=yourTaxonomyFile, taxon=yourTaxons).\n");
218                 m->mothurOut("Example get.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 get.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, "GetLineageCommand", "help");
225                 exit(1);
226         }
227 }
228
229 //**********************************************************************************************************************
230
231 int GetLineageCommand::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 get
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) { outputTypes.clear(); 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, "GetLineageCommand", "execute");
261                 exit(1);
262         }
263 }
264
265 //**********************************************************************************************************************
266 int GetLineageCommand::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                 ofstream out;
272                 m->openOutputFile(outputFileName, out);
273                 
274                 
275                 ifstream in;
276                 m->openInputFile(fastafile, in);
277                 string name;
278                 
279                 bool wroteSomething = false;
280                 
281                 while(!in.eof()){
282                 
283                         if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str());  return 0; }
284                         
285                         Sequence currSeq(in);
286                         name = currSeq.getName();
287                         
288                         if (name != "") {
289                                 //if this name is in the accnos file
290                                 if (names.count(name) != 0) {
291                                         wroteSomething = true;
292                                         
293                                         currSeq.printSequence(out);
294                                 }
295                         }
296                         m->gobble(in);
297                 }
298                 in.close();     
299                 out.close();
300                 
301                 if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
302                 outputNames.push_back(outputFileName);  outputTypes["fasta"].push_back(outputFileName);
303                 
304                 return 0;
305
306         }
307         catch(exception& e) {
308                 m->errorOut(e, "GetLineageCommand", "readFasta");
309                 exit(1);
310         }
311 }
312 //**********************************************************************************************************************
313 int GetLineageCommand::readList(){
314         try {
315                 string thisOutputDir = outputDir;
316                 if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
317                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
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                         
328                         if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str());  return 0; }
329
330                         //read in list vector
331                         ListVector list(in);
332                         
333                         //make a new list vector
334                         ListVector newList;
335                         newList.setLabel(list.getLabel());
336                         
337                         //for each bin
338                         for (int i = 0; i < list.getNumBins(); i++) {
339                         
340                                 //parse out names that are in accnos file
341                                 string binnames = list.get(i);
342                                 
343                                 string newNames = "";
344                                 while (binnames.find_first_of(',') != -1) { 
345                                         string name = binnames.substr(0,binnames.find_first_of(','));
346                                         binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
347                                         
348                                         //if that name is in the .accnos file, add it
349                                         if (names.count(name) != 0) {  newNames += name + ",";  }
350                                 }
351                         
352                                 //get last name
353                                 if (names.count(binnames) != 0) {  newNames += binnames + ",";  }
354
355                                 //if there are names in this bin add to new list
356                                 if (newNames != "") { 
357                                         newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
358                                         newList.push_back(newNames);    
359                                 }
360                         }
361                                 
362                         //print new listvector
363                         if (newList.getNumBins() != 0) {
364                                 wroteSomething = true;
365                                 newList.print(out);
366                         }
367                         
368                         m->gobble(in);
369                 }
370                 in.close();     
371                 out.close();
372                 
373                 if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
374                 outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName);
375                 
376                 return 0;
377
378         }
379         catch(exception& e) {
380                 m->errorOut(e, "GetLineageCommand", "readList");
381                 exit(1);
382         }
383 }
384 //**********************************************************************************************************************
385 int GetLineageCommand::readName(){
386         try {
387                 string thisOutputDir = outputDir;
388                 if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
389                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" +  m->getExtension(namefile);
390                 ofstream out;
391                 m->openOutputFile(outputFileName, out);
392                 
393
394                 ifstream in;
395                 m->openInputFile(namefile, in);
396                 string name, firstCol, secondCol;
397                 
398                 bool wroteSomething = false;
399                 
400                 
401                 while(!in.eof()){
402                 
403                         if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str());  return 0; }
404
405                         in >> firstCol;                         
406                         in >> secondCol;
407                         
408                         string hold = "";
409                         if (dups) { hold = secondCol; }
410                         
411                         vector<string> parsedNames;
412                         //parse second column saving each name
413                         while (secondCol.find_first_of(',') != -1) { 
414                                 name = secondCol.substr(0,secondCol.find_first_of(','));
415                                 secondCol = secondCol.substr(secondCol.find_first_of(',')+1, secondCol.length());
416                                 parsedNames.push_back(name);
417                         }
418                         
419                         //get name after last ,
420                         parsedNames.push_back(secondCol);
421                         
422                         vector<string> validSecond;
423                         for (int i = 0; i < parsedNames.size(); i++) {
424                                 if (names.count(parsedNames[i]) != 0) {
425                                         validSecond.push_back(parsedNames[i]);
426                                 }
427                         }
428
429                         if ((dups) && (validSecond.size() != 0)) { //dups = true and we want to add someone, then add everyone
430                                 for (int i = 0; i < parsedNames.size(); i++) {  names.insert(parsedNames[i]);  }
431                                 out << firstCol << '\t' << hold << endl;
432                                 wroteSomething = true;
433                         }else {
434                                 //if the name in the first column is in the set then print it and any other names in second column also in set
435                                 if (names.count(firstCol) != 0) {
436                                 
437                                         wroteSomething = true;
438                                         
439                                         out << firstCol << '\t';
440                                         
441                                         //you know you have at least one valid second since first column is valid
442                                         for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
443                                         out << validSecond[validSecond.size()-1] << endl;
444                                         
445                                 
446                                 //make first name in set you come to first column and then add the remaining names to second column
447                                 }else {
448                                         //you want part of this row
449                                         if (validSecond.size() != 0) {
450                                         
451                                                 wroteSomething = true;
452                                                 
453                                                 out << validSecond[0] << '\t';
454                                         
455                                                 //you know you have at least one valid second since first column is valid
456                                                 for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
457                                                 out << validSecond[validSecond.size()-1] << endl;
458                                         }
459                                 }
460                         }
461                         m->gobble(in);
462                 }
463                 in.close();
464                 out.close();
465                 
466                 if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
467                 outputNames.push_back(outputFileName);  outputTypes["name"].push_back(outputFileName);
468                 
469                 return 0;
470                 
471         }
472         catch(exception& e) {
473                 m->errorOut(e, "GetLineageCommand", "readName");
474                 exit(1);
475         }
476 }
477
478 //**********************************************************************************************************************
479 int GetLineageCommand::readGroup(){
480         try {
481                 string thisOutputDir = outputDir;
482                 if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
483                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
484                 ofstream out;
485                 m->openOutputFile(outputFileName, out);
486                 
487
488                 ifstream in;
489                 m->openInputFile(groupfile, in);
490                 string name, group;
491                 
492                 bool wroteSomething = false;
493                 
494                 while(!in.eof()){
495
496                         if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str());  return 0; }
497
498
499                         in >> name;                             //read from first column
500                         in >> group;                    //read from second column
501                         
502                         //if this name is in the accnos file
503                         if (names.count(name) != 0) {
504                                 wroteSomething = true;
505                                 
506                                 out << name << '\t' << group << endl;
507                         }
508                                         
509                         m->gobble(in);
510                 }
511                 in.close();
512                 out.close();
513                 
514                 if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
515                 outputNames.push_back(outputFileName);  outputTypes["group"].push_back(outputFileName);
516                 
517                 return 0;
518
519         }
520         catch(exception& e) {
521                 m->errorOut(e, "GetLineageCommand", "readGroup");
522                 exit(1);
523         }
524 }
525 //**********************************************************************************************************************
526 int GetLineageCommand::readTax(){
527         try {
528                 string thisOutputDir = outputDir;
529                 if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
530                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
531                 ofstream out;
532                 m->openOutputFile(outputFileName, out);
533                 
534                 ifstream in;
535                 m->openInputFile(taxfile, in);
536                 string name, tax;
537                 
538                 bool wroteSomething = false;
539                 
540                 while(!in.eof()){
541
542                         if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str());  return 0; }
543
544                         in >> name;                             //read from first column
545                         in >> tax;                      //read from second column
546                         
547                         string newtax = tax;
548                         
549                         //if the users file contains confidence scores we want to ignore them when searching for the taxons
550                         int hasConfidences = tax.find_first_of('(');
551                         if (hasConfidences != string::npos) { 
552                                 newtax = removeConfidences(tax);
553                         }
554                         
555                         int pos = newtax.find(taxons);
556                         
557                         if (pos != string::npos) { //this sequence contains the taxon the user wants
558                                 names.insert(name);
559                                 out << name << '\t' << tax << endl;
560                         }
561                         
562                         m->gobble(in);
563                 }
564                 in.close();
565                 out.close();
566                 
567                 if (names.size() == 0) { m->mothurOut("Your taxonomy file does not contain any sequences from " + taxons + "."); m->mothurOutEndLine();  }
568                 outputNames.push_back(outputFileName); outputTypes["taxonomy"].push_back(outputFileName);
569                         
570                 return 0;
571
572         }
573         catch(exception& e) {
574                 m->errorOut(e, "GetLineageCommand", "readTax");
575                 exit(1);
576         }
577 }
578 /**************************************************************************************************/
579 string GetLineageCommand::removeConfidences(string tax) {
580         try {
581                 
582                 string taxon = "";
583                 int taxLength = tax.length();
584                 for(int i=0;i<taxLength;i++){
585                         if(tax[i] == ';'){
586                                 taxon = taxon.substr(0, taxon.find_first_of('(')); //rip off confidence
587                                 taxon += ";";
588                         }
589                         else{
590                                 taxon += tax[i];
591                         }
592                 }
593                                 
594                 return taxon;
595         }
596         catch(exception& e) {
597                 m->errorOut(e, "GetLineageCommand", "removeConfidences");
598                 exit(1);
599         }
600 }
601 //**********************************************************************************************************************
602 //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
603 int GetLineageCommand::readAlign(){
604         try {
605                 string thisOutputDir = outputDir;
606                 if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
607                 string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
608                 ofstream out;
609                 m->openOutputFile(outputFileName, out);
610                 
611
612                 ifstream in;
613                 m->openInputFile(alignfile, in);
614                 string name, junk;
615                 
616                 bool wroteSomething = false;
617                 
618                 //read column headers
619                 for (int i = 0; i < 16; i++) {  
620                         if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
621                         else                    {       break;                  }
622                 }
623                 out << endl;
624                 
625                 while(!in.eof()){
626                 
627                         if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str());  return 0; }
628
629
630                         in >> name;                             //read from first column
631                         
632                         //if this name is in the accnos file
633                         if (names.count(name) != 0) {
634                                 wroteSomething = true;
635                                 
636                                 out << name << '\t';
637                                 
638                                 //read rest
639                                 for (int i = 0; i < 15; i++) {  
640                                         if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
641                                         else                    {       break;                  }
642                                 }
643                                 out << endl;
644                                 
645                         }else {//still read just don't do anything with it
646                                 //read rest
647                                 for (int i = 0; i < 15; i++) {  
648                                         if (!in.eof())  {       in >> junk;             }
649                                         else                    {       break;                  }
650                                 }
651                         }
652                         
653                         m->gobble(in);
654                 }
655                 in.close();
656                 out.close();
657                 
658                 if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
659                 outputNames.push_back(outputFileName); outputTypes["alignreport"].push_back(outputFileName);
660                 
661                 return 0;
662                 
663         }
664         catch(exception& e) {
665                 m->errorOut(e, "GetLineageCommand", "readAlign");
666                 exit(1);
667         }
668 }
669 //**********************************************************************************************************************
670
671
672
673