]> git.donarmstrong.com Git - mothur.git/blob - readotucommand.cpp
changed all shared commands so that they read the shared file generated by the read...
[mothur.git] / readotucommand.cpp
1 /*
2  *  readotu.cpp
3  *  Mothur
4  *
5  *  Created by Sarah Westcott on 1/20/09.
6  *  Copyright 2009 Schloss Lab UMASS AMherst. All rights reserved.
7  *
8  */
9
10 #include "readotucommand.h"
11
12 //**********************************************************************************************************************
13 ReadOtuCommand::ReadOtuCommand(){
14         try {
15                 globaldata = GlobalData::getInstance();
16                 filename = globaldata->inputFileName;
17                 read = new ReadOTUFile(filename);
18                 if (globaldata->getFormat() == "shared") {
19                         //read in group map info.
20                         groupMap = new GroupMap(globaldata->getGroupFile());
21                 }
22         }
23         catch(exception& e) {
24                 cout << "Standard Error: " << e.what() << " has occurred in the ReadOtuCommand class Function ReadOtuCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
25                 exit(1);
26         }
27         catch(...) {
28                 cout << "An unknown error has occurred in the ReadOtuCommand class function ReadOtuCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
29                 exit(1);
30         }
31 }
32
33 //**********************************************************************************************************************
34
35 ReadOtuCommand::~ReadOtuCommand(){
36         delete read;
37 }
38
39 //**********************************************************************************************************************
40
41 int ReadOtuCommand::execute(){
42         try {
43                 read->read(&*globaldata); 
44                 if (globaldata->getFormat() == "shared") {
45                         groupMap->readMap();
46                         
47                         //if (globaldata->gGroupmap != NULL) { delete globaldata->gGroupmap;  }
48                         globaldata->gGroupmap = groupMap;               
49                         shared = new SharedCommand();
50                         shared->execute();
51
52                         parselist = new ParseListCommand();
53                         parselist->execute();
54                         
55                         //change format to shared  to speed up commands
56                         globaldata->setFormat("sharedfile");
57                         globaldata->setListFile("");
58                         globaldata->setGroupFile("");
59                         globaldata->setSharedFile(getRootName(filename) + "shared");
60                 }
61                 return 0;
62         }
63         catch(exception& e) {
64                 cout << "Standard Error: " << e.what() << " has occurred in the ReadOtuCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
65                 exit(1);
66         }
67         catch(...) {
68                 cout << "An unknown error has occurred in the ReadOtuCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
69                 exit(1);
70         }
71 }
72 //**********************************************************************************************************************