]> git.donarmstrong.com Git - mothur.git/blob - readdistcommand.cpp
When Pat tried to compile mothur in Ubuntu linux, there were a number of minor proble...
[mothur.git] / readdistcommand.cpp
1 /*
2  *  readdistcommand.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 "readdistcommand.h"
11
12 ReadDistCommand::ReadDistCommand(){
13         try {
14                 globaldata = GlobalData::getInstance();
15                 
16                 filename = globaldata->inputFileName;
17                 format = globaldata->getFormat();       
18                 
19                 if (format == "column") { read = new ReadColumnMatrix(filename); }      
20                 else if (format == "phylip") { read = new ReadPhylipMatrix(filename); } 
21                         
22                 if(globaldata->getPrecision() != ""){
23                         convert(globaldata->getPrecision(), precision); 
24                 }
25                 
26                 if(globaldata->getCutOff() != ""){
27                         convert(globaldata->getCutOff(), cutoff);       
28                         cutoff += (5 / (precision * 10.0));
29                 }
30                 read->setCutoff(cutoff);
31         
32                 if(globaldata->getNameFile() != ""){    
33                         nameMap = new NameAssignment(globaldata->getNameFile());
34                         nameMap->readMap(1,2);
35                 }
36                 else{
37                         nameMap = NULL;
38                 }
39                         
40         }
41         catch(exception& e) {
42                 cout << "Standard Error: " << e.what() << " has occurred in the ReadDistCommand class Function ReadDistCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
43                 exit(1);
44         }
45         catch(...) {
46                 cout << "An unknown error has occurred in the ReadDistCommand class function ReadDistCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
47                 exit(1);
48         }
49 }
50
51 //**********************************************************************************************************************
52 ReadDistCommand::~ReadDistCommand(){
53         delete read;
54         delete nameMap;
55 }
56
57 //**********************************************************************************************************************
58 int ReadDistCommand::execute(){
59         try {
60                 read->read(nameMap);
61                 globaldata->setListVector(read->getListVector());
62                 globaldata->setSparseMatrix(read->getMatrix());
63                 return 0;
64         }
65         catch(exception& e) {
66                 cout << "Standard Error: " << e.what() << " has occurred in the ReadDistCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
67                 exit(1);
68         }
69         catch(...) {
70                 cout << "An unknown error has occurred in the ReadDistCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
71                 exit(1);
72         }
73 }