]> git.donarmstrong.com Git - mothur.git/blob - formatmatrix.h
Revert to previous commit
[mothur.git] / formatmatrix.h
1 #ifndef FORMATMATRIX_H
2 #define FORMATMATRIX_H
3
4 /*
5  *  formatmatrix.h
6  *  Mothur
7  *
8  *  Created by westcott on 1/13/10.
9  *  Copyright 2010 Schloss Lab. All rights reserved.
10  *
11  */
12
13 #include "mothur.h"
14 #include "listvector.hpp"
15 #include "nameassignment.hpp"
16
17
18 //**********************************************************************************************************************
19 //  This class takes a distance matrix file and converts it to a file where each row contains all distances below the cutoff
20 //  for a given sequence.
21
22 //  Example:
23         /*      5
24                 A  
25                 B  0.01 
26                 C  0.015 0.03 
27                 D  0.03 0.02 0.02  
28                 E  0.04 0.05 0.03 0.02   
29                 
30                 becomes 
31                 
32                 0       4       1       0.01    2       0.015   3       0.03    4       0.04    
33                 1       4       0       0.01    2       0.03    3       0.02    4       0.05    
34                 2       4       0       0.015   1       0.03    3       0.02    4       0.03    
35                 3       4       0       0.03    1       0.02    2       0.02    4       0.02    
36                 4       4       0       0.04    1       0.05    2       0.03    3       0.02
37                 
38                 column 1 - sequence name converted to row number
39                 column 2 - numDists under cutoff
40                 rest of line - sequence row -> distance, sequence row -> distance
41                 
42                 if you had a cutoff of 0.03 then the file would look like,
43                 
44                 0       3       1       0.01    2       0.015   3       0.03    
45                 1       3       0       0.01    2       0.03    3       0.02    
46                 2       4       0       0.015   1       0.03    3       0.02    4       0.03    
47                 3       4       0       0.03    1       0.02    2       0.02    4       0.02    
48                 4       2       2       0.03    3       0.02    
49                 
50                 This class also creates a vector of ints, rowPos.
51                 
52                 rowPos[0] = position in the file of distances related to sequence 0.
53                 If a sequence is excluded by the cutoff, it's rowPos = -1.
54 */
55 //**********************************************************************************************************************
56
57 class FormatMatrix {
58
59 public:
60         FormatMatrix(){ m = MothurOut::getInstance(); }
61         virtual ~FormatMatrix() {}
62         
63         virtual int read(NameAssignment*){ return 1; }
64         
65         void setCutoff(float c)                 {       cutoff = c;                     }
66         ListVector* getListVector()             {       return list;            }
67         string getFormattedFileName()   {       return distFile;        }
68         vector<int> getRowPositions()   {       return rowPos;          }
69         
70 protected:
71         ListVector* list;
72         float cutoff;
73         string distFile;
74         vector<int> rowPos;
75         MothurOut* m;
76 };
77
78 //**********************************************************************************************************************
79
80 #endif
81