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