]> git.donarmstrong.com Git - mothur.git/blob - fullmatrix.h
libshuff and updated help to include libshuff and modifications to read.dist.
[mothur.git] / fullmatrix.h
1 #ifndef FULLMATRIX_H
2 #define FULLMATRIX_H
3 /*
4  *  fullmatrix.h
5  *  Mothur
6  *
7  *  Created by Sarah Westcott on 3/6/09.
8  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
9  *
10  */
11
12 #include "mothur.h"
13 #include "groupmap.h"
14 #include "globaldata.hpp"
15 #include "progress.hpp"
16
17 using namespace std;
18
19 struct Names {
20         string          groupname;
21         string          seqName;
22 };
23
24 struct Swap {
25         int             a;
26         int             b;
27 };
28
29
30 class FullMatrix {
31         
32         public:
33                 FullMatrix(){};
34                 FullMatrix(ifstream&);
35                 ~FullMatrix(){};
36         
37                 int getNumSeqs();
38                 void printMatrix(ostream&);
39                 void setBounds();  //requires globaldata->Groups to be filled
40                 vector<float> getMins(int); //returns vector of mins for "box" requested ie. groups A, B, 0 = AA, 1 = AB, 2 = BA, 3 = BB;
41                 void getDist(vector<float>&);  //fills a vector with the valid distances for the integral form.
42                 void shuffle(string, string);  //shuffles the sequences in the groups passed in.
43                 void restore();  //unshuffles the matrix.
44         
45         private:
46                 void sortGroups(int, int);  //this function sorts the sequences within the matrix.
47                 void getBounds(int&, string);
48                 void readSquareMatrix(ifstream&);  
49                 void readLTMatrix(ifstream&);
50                 void printMinsForRows(ostream&);
51                 
52                 map<int, Names> index; // row in vector, sequence group.  need to know this so when we sort it can be updated.
53                 map<int, Swap> restoreIndex; //a map of the swaps made so you can undo them in restore.
54                 map<int, Names>::iterator it;
55                 map<int, Swap>::reverse_iterator it2;
56                         
57                 vector< vector<float> > matrix;  //a 2D distance matrix of all the sequences and their distances to eachother.
58                 vector<float> minsForRows;  //vector< minimum distance for that subrow> - one for each comparison.
59                 vector<int> bounds;  //bounds[1] = starting row in matrix from group B, bounds[2] = starting row in matrix from group C, bounds[3] = no need to find upper bound of C because its numSeqs.
60                                                                 
61                 GroupMap* groupmap;  //maps sequences to groups they belong to.
62                 GlobalData* globaldata;
63                 int numSeqs, numGroups, numUserGroups;
64                 bool square;
65
66 };
67
68 #endif