]> git.donarmstrong.com Git - mothur.git/blob - designmap.h
changed random forest output filename
[mothur.git] / designmap.h
1 //
2 //  designmap.h
3 //  Mothur
4 //
5 //  Created by SarahsWork on 6/17/13.
6 //  Copyright (c) 2013 Schloss Lab. All rights reserved.
7 //
8
9 #ifndef __Mothur__designmap__
10 #define __Mothur__designmap__
11
12 #include "mothurout.h"
13
14 /* This class is a representation of the design file.  
15  
16  group    treatment    sex        age
17  F000142    Early       female    young
18  F000132    Late        male        old
19  F000138    Mid         male        old
20  
21  
22  */
23
24 class DesignMap {
25 public:
26         DesignMap() { m = MothurOut::getInstance(); defaultClass = "not found"; }
27         DesignMap(string); 
28         ~DesignMap() {}
29     
30     int read(string);
31     string get(string, string); //groupName, category returns value. example F000132, sex -> male
32     string get(string); //groupName, returns first categories value. example F000132, -> late
33     vector<string> getValues(string); //categoryName, returns values. example treatment, -> early,late,mid
34         int set(string, map<string, string>); //groupName, map<category, value>
35     int push_back(string, vector<string>); //groupName, vector<value> - assumes you put values in order of getNamesOfCategories
36         vector<string> getNamesOfCategories() {
37                 sort(namesOfCategories.begin(), namesOfCategories.end());
38         return namesOfCategories;
39         }
40     int getNumCategories() { return namesOfCategories.size(); }
41         int getNum()  {  return designMap.size();  }
42     int getNumUnique(map<string, vector<string> >); //get number of groups belonging to a category or set of categories, with value or a set of values. Must have all categories and values. Example:
43     //  map<treatment - > early, late>, <sex -> male> would return 1. Only one group is male and from early or late.
44     int getNumShared(map<string, vector<string> >); //get number of groups belonging to a category or set of categories, with value or a set of values. Must have at least one categories and values. Example:
45     //  map<treatment - > early, late>, <sex -> male> would return 3. All three group have are either male or from early or late.
46
47     vector<string> getNames();
48     vector<string> getNames(string, string); //get names group from category and value.
49         vector<string> getNamesUnique(map<string, vector<string> >); //get names of groups belonging to a category or set of categories, with value or a set of values. Must have all categories and values. Example:
50     //  map<treatment - > early, late>, <sex -> male> would return F000132. F000132 is the only group which is male and from early or late.
51     vector<string> getNamesShared(map<string, vector<string> >); //get names of groups belonging to a category or set of categories, with value or a set of values. Must have at least one categories and values. Example:
52     //  map<treatment - > early, late>, <sex -> male> would return F000132, F000142, F000138. All three group have are either male or from early or late.
53
54     int print(ofstream&);
55     int print(ofstream&, vector<string>); //print certain categories
56     
57     string getDefaultClass() { return defaultClass; }
58     
59 private:
60     string defaultClass;
61         vector<string> namesOfCategories;
62         MothurOut* m;
63         vector< vector<string> > designMap;
64     vector< map<string, int> > totalCategories;  //for each category, total groups assigned to it.   vector[0] early -> 1, vector[1] male -> 2
65     map<string, int> indexNameMap;
66     map<string, int> indexCategoryMap;
67 };
68
69
70 #endif /* defined(__Mothur__designmap__) */