]> git.donarmstrong.com Git - mothur.git/blob - deconvolutecommand.cpp
fixed some bugs
[mothur.git] / deconvolutecommand.cpp
1 /*
2  *  deconvolute.cpp
3  *  Mothur
4  *
5  *  Created by Sarah Westcott on 1/21/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "deconvolutecommand.h"
11
12 /**************************************************************************************/
13 int DeconvoluteCommand::execute() {     
14         try {
15                 globaldata = GlobalData::getInstance();
16         
17                 //prepare filenames and open files
18                 filename = globaldata->getFastaFile();
19                 outputFileName = (getRootName(filename) + "names");
20                 outFastafile = (getRootName(filename) + "unique.fasta");
21                 
22                 openInputFile(filename, in);
23                 openOutputFile(outputFileName, out);
24                 openOutputFile(outFastafile, outFasta);
25         
26                 //constructor reads in file and store internally
27                 fastamap = new FastaMap();
28         
29                 //two columns separated by tabs sequence name and then sequence
30                 fastamap->readFastaFile(in);
31                 
32                 //print out new names file 
33                 //file contains 2 columns separated by tabs.  the first column is the groupname(name of first sequence found.
34                 //the second column is the list of names of identical sequences separated by ','.
35                 fastamap->printNamesFile(out);
36                 fastamap->printCondensedFasta(outFasta);
37                 
38                 out.close();
39                 outFasta.close();
40         
41                 return 0;
42         }
43         catch(exception& e) {
44                 cout << "Standard Error: " << e.what() << " has occurred in the DeconvoluteCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
45                 exit(1);
46         }
47         catch(...) {
48                 cout << "An unknown error has occurred in the DeconvoluteCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
49                 exit(1);
50         }
51 }
52 /**************************************************************************************/