]> git.donarmstrong.com Git - mothur.git/blob - counttable.h
sffinfo bug with flow grams right index when clipQualRight=0
[mothur.git] / counttable.h
1 #ifndef Mothur_counttable_h
2 #define Mothur_counttable_h
3
4
5 //
6 //  counttable.h
7 //  Mothur
8 //
9 //  Created by Sarah Westcott on 6/26/12.
10 //  Copyright (c) 2012 Schloss Lab. All rights reserved.
11 //
12
13 //This class is designed to read a count table file and store its data.
14 //count table files look like:
15
16 /*
17  Representative_Sequence        total   F003D000        F003D002        F003D004        F003D006        F003D008        F003D142        F003D144        F003D146        F003D148        F003D150        MOCK.GQY1XT001  
18  GQY1XT001C296C 6051    409     985     923     937     342     707     458     439     387     464     0       
19  GQY1XT001A3TJI 4801    396     170     413     442     306     769     581     576     497     651     0       
20  GQY1XT001CS2B8 3018    263     226     328     460     361     336     248     290     187     319     0       
21  GQY1XT001CD9IB 2736    239     177     256     405     306     286     263     248     164     392     0       
22  
23  or if no group info was used to create it
24  
25  Representative_Sequence        total   
26  GQY1XT001C296C 6051
27  GQY1XT001A3TJI 4801
28  GQY1XT001CS2B8 3018
29  GQY1XT001CD9IB 2736
30  GQY1XT001ARCB1 2183
31  GQY1XT001CNF2P 2796
32  GQY1XT001CJMDA 1667
33  GQY1XT001CBVJB 3758
34  
35  
36  */
37
38
39 #include "mothurout.h"
40 #include "listvector.hpp"
41 #include "groupmap.h"
42
43 class CountTable {
44     
45     public:
46     
47         CountTable() { m = MothurOut::getInstance(); hasGroups = false; total = 0; uniques = 0; }
48         ~CountTable() {}
49     
50         //reads and creates smart enough to eliminate groups with zero counts 
51         int createTable(set<string>&, map<string, string>&, set<string>&); //seqNames, seqName->group, groupNames 
52         int createTable(string, string, bool); //namefile, groupfile, createGroup
53         int readTable(string); 
54     
55         int printTable(string);
56         int printHeaders(ofstream&);
57         int printSeq(ofstream&, string);
58         bool testGroups(string file); //used to check if file has group data without reading it.
59         int copy(CountTable*);
60     
61         bool hasGroupInfo() { return hasGroups; }
62         int getNumGroups() { return groups.size(); }
63         vector<string> getNamesOfGroups() {  return groups;   }  //returns group names, if no group info vector is blank.
64         int addGroup(string);
65         int removeGroup(string);
66         
67         int renameSeq(string, string); //used to change name of sequence for use with trees
68         int setAbund(string, string, int); //set abundance number of seqs for that group for that seq
69         int push_back(string); //add a sequence 
70         int push_back(string, int); //add a sequence 
71         int push_back(string, vector<int>); //add a sequence with group info
72         int remove(string); //remove seq
73         int get(string); //returns unique sequence index for reading distance matrices like NameAssignment
74         int size() { return indexNameMap.size(); }
75     
76         vector<string> getGroups(string); //returns vector of groups represented by this sequences
77         vector<int> getGroupCounts(string);  //returns group counts for a seq passed in, if no group info is in file vector is blank. Order is the same as the groups returned by getGroups function.
78         int getGroupCount(string, string); //returns number of seqs for that group for that seq
79         int getGroupCount(string); // returns total seqs for that group
80         int getNumSeqs(string); //returns total seqs for that seq, 0 if not found 
81         int getNumSeqs() { return total; } //return total number of seqs
82         int getNumUniqueSeqs() { return uniques; } //return number of unique/representative seqs
83         int getGroupIndex(string); //returns index in getGroupCounts vector of specific group
84     
85         vector<string> getNamesOfSeqs();
86         vector<string> getNamesOfSeqs(string);
87         int mergeCounts(string, string); //combines counts for 2 seqs, saving under the first name passed in.
88         ListVector getListVector();
89         map<string, int> getNameMap();
90     
91     private:
92         string filename;
93         MothurOut* m;
94         bool hasGroups;
95         int total, uniques;
96         vector<string> groups;
97         vector< vector<int> > counts;
98         vector<int> totals;
99         vector<int> totalGroups;
100         map<string, int> indexNameMap;
101         map<string, int> indexGroupMap;
102     
103 };
104
105 #endif