]> git.donarmstrong.com Git - mothur.git/blob - readdistcommand.cpp
fixed valid parameters to include shared parameter for read.shared command.
[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                 else if (format == "matrix") { 
22                                 groupMap = new GroupMap(globaldata->getGroupFile());
23                                 groupMap->readMap();
24                                 globaldata->gGroupmap = groupMap;
25                 }
26                 
27                 if (format != "matrix" ) {
28                         if(globaldata->getPrecision() != ""){
29                                 convert(globaldata->getPrecision(), precision); 
30                         }
31                 
32                         if(globaldata->getCutOff() != ""){
33                                 convert(globaldata->getCutOff(), cutoff);       
34                                 cutoff += (5 / (precision * 10.0));
35                         }
36                         read->setCutoff(cutoff);
37         
38                         if(globaldata->getNameFile() != ""){    
39                                 nameMap = new NameAssignment(globaldata->getNameFile());
40                                 nameMap->readMap(1,2);
41                         }
42                         else{
43                                 nameMap = NULL;
44                         }
45                 }
46                         
47         }
48         catch(exception& e) {
49                 cout << "Standard Error: " << e.what() << " has occurred in the ReadDistCommand class Function ReadDistCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
50                 exit(1);
51         }
52         catch(...) {
53                 cout << "An unknown error has occurred in the ReadDistCommand class function ReadDistCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
54                 exit(1);
55         }
56 }
57
58 //**********************************************************************************************************************
59 ReadDistCommand::~ReadDistCommand(){
60         delete read;
61         delete nameMap;
62 }
63
64 //**********************************************************************************************************************
65 int ReadDistCommand::execute(){
66         try {
67                 
68                 if (format == "matrix") {
69                         ifstream in;
70                         openInputFile(filename, in);
71                         matrix = new FullMatrix(in); //reads the matrix file
72                         globaldata->gMatrix = matrix; //save matrix for coverage commands
73                 }else {
74                         read->read(nameMap);
75                         globaldata->setListVector(read->getListVector());
76                         globaldata->setSparseMatrix(read->getMatrix());
77                 }
78                 return 0;
79         }
80         catch(exception& e) {
81                 cout << "Standard Error: " << e.what() << " has occurred in the ReadDistCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
82                 exit(1);
83         }
84         catch(...) {
85                 cout << "An unknown error has occurred in the ReadDistCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
86                 exit(1);
87         }
88 }