]> git.donarmstrong.com Git - mothur.git/blob - filterseqscommand.cpp
*** empty log message ***
[mothur.git] / filterseqscommand.cpp
1 /*
2  *  filterseqscommand.cpp
3  *  Mothur
4  *
5  *  Created by Thomas Ryabin on 5/4/09.
6  *  Copyright 2009 __MyCompanyName__. All rights reserved.
7  *
8  */
9
10 #include "filterseqscommand.h"
11 #include <iostream>
12 #include <fstream>
13
14 /**************************************************************************************/
15 void FilterSeqsCommand::doTrump() {
16         //trump = globaldata->getTrump();
17 //      
18 //      for(int i = 0; i < db->size(); i++) {
19 //              Sequence cur = db->get(i);
20 //              string curAligned = cur.getAligned();
21 //              
22 //              for(int j = 0; j < curAligned.length-1; j++) {
23 //                      string curChar = curAligned.substr(j, j+1);
24 //                      
25 //                      if(curChar.compare(trump) == 0) 
26 //                              columnsToRemove[j] = true;
27 //              }
28 //      }
29 }
30
31 /**************************************************************************************/
32 void FilterSeqsCommand::doSoft() {
33         //soft = atoi(globaldata->getSoft().c_str());
34 //      vector<vector<int> > columnSymbolSums;
35 //      vector<vector<string> > columnSymbols;
36 //      for(int i = 0; i < db->get(0).getLength(); i++) {
37 //              vector<string> symbols;
38 //              vector<int> sums;
39 //              columnSymbols[i] = symbols;
40 //              columnSymbolSums[i] = sums;
41 //      }
42 //      
43 //      for(int i = 0; i < db->size(); i++) {
44 //              Sequence cur = db->get(i);
45 //              string curAligned = cur.getAligned();
46 //              
47 //              for(int j = 0; j < curAligned.length-1; j++) {
48 //                      string curChar = curAligned.substr(j, j+1);
49 //                      vector<string> curColumnSymbols = columnSymbols[j];
50 //                      
51 //                      bool newSymbol = true;
52 //                      
53 //                      for(int k = 0; j < curColumnSymbols.size(); j++) 
54 //                              if(curChar.compare(curColumnSymbols[k]) == 0) {
55 //                                      newSymbol = false;
56 //                                      columnSymbolSums[j][k]++;
57 //                              }
58 //                      
59 //                      if(newSymbol) {
60 //                              columnSymbols.push_back(curChar);
61 //                              columnSymbolSums[j].push_back(1);
62 //                      }
63 //              }
64 //      }
65 //      
66 //      for(int i = 0; i < columnSymbolSums.size(); i++) {
67 //              int totalSum = 0;
68 //              int max = 0;
69 //              vector<int> curColumn = columnSymbolSums[i];
70 //              
71 //              for(int j = 0; j < curColumn.size(); j++) {
72 //                      int curSum = curColumn[j];
73 //                      if(curSum > max)
74 //                              max = curSum;
75 //                      totalSum += curSum;
76 //              }
77 //              
78 //              if((double)max/(double)totalSum * 100 < soft)
79 //                      columnsToRemove[i] = true;
80 //      }
81 }
82 void FilterSeqsCommand::doFilter() {}
83 /**************************************************************************************/
84 int FilterSeqsCommand::execute() {      
85         try {
86                 globaldata = GlobalData::getInstance();
87                 filename = globaldata->inputFileName;
88                 
89                 if(globaldata->getFastaFile().compare("") != 0) {
90                         readFasta = new ReadFasta(filename);
91                         readFasta->read();
92                         db = readFasta->getDB();
93                 }
94                 
95                 else if(globaldata->getNexusFile().compare("") != 0) {
96                         readNexus = new ReadNexus(filename);
97                         readNexus->read();
98                         db = readNexus->getDB();
99                 }
100                 
101                 else if(globaldata->getClustalFile().compare("") != 0) {
102                         readClustal = new ReadClustal(filename);
103                         readClustal->read();
104                         db = readClustal->getDB();
105                 }
106
107                 else if(globaldata->getPhylipFile().compare("") != 0) {
108                         readPhylip = new ReadPhylip(filename);
109                         readPhylip->read();
110                         db = readPhylip->getDB();
111                 }
112         
113                 for(int i = 0; i < db->get(0).getLength(); i++) 
114                         columnsToRemove[i] = false;
115                         
116                 // Trump
117                 if(globaldata->getTrump().compare("") != 0) {
118                 
119                         
120                 }
121                 
122                 // Soft
123                 if(globaldata->getSoft().compare("") != 0) {}
124
125                 
126                         
127                 
128                 // Filter
129                 //if(globaldata->getFilter().compare("") != 0) {
130 //
131 //                      filter = globaldata->getFilter();
132 //                      ifstream filehandle;
133 //                      openInputFile(filter, filehandle);
134 //                      
135 //                      char c;
136 //                      int count = 0;
137 //                      while(!filehandle.eof()) {
138 //                              c = filehandle.get();
139 //                              if(c == '0') 
140 //                                      columnsToRemove[count] = true;
141 //                              count++;
142 //                      }
143 //              }
144                 
145                 
146                 
147                         
148                         
149                 return 0;
150         }
151         catch(exception& e) {
152                 cout << "Standard Error: " << e.what() << " has occurred in the DeconvoluteCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
153                 exit(1);
154         }
155         catch(...) {
156                 cout << "An unknown error has occurred in the DeconvoluteCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
157                 exit(1);
158         }
159 }
160 /**************************************************************************************/