]> git.donarmstrong.com Git - mothur.git/blob - source/sequenceparser.h
23fcb9ecc983e1cf59ef1fde1f976da80773a152
[mothur.git] / source / sequenceparser.h
1 #ifndef SEQUENCEPARSER_H
2 #define SEQUENCEPARSER_H
3
4 /*
5  *  sequenceParser.h
6  *  Mothur
7  *
8  *  Created by westcott on 9/9/11.
9  *  Copyright 2011 Schloss Lab. All rights reserved.
10  *
11  */
12
13
14 #include "mothur.h"
15 #include "mothurout.h"
16 #include "sequence.hpp"
17 #include "groupmap.h"
18
19 /* This class reads a fasta and group file with a namesfile as optional and parses the data by group. 
20  
21         Note: The sum of all the groups unique sequences will be larger than the original number of unique sequences. 
22         This is because when we parse the name file we make a unique for each group instead of 1 unique for all
23         groups. 
24  
25  */
26
27 class SequenceParser {
28         
29         public:
30         
31                 SequenceParser(string, string);                 //group, fasta - file mismatches will set m->control_pressed = true
32                 SequenceParser(string, string, string); //group, fasta, name  - file mismatches will set m->control_pressed = true
33                 ~SequenceParser();
34                 
35                 //general operations
36                 int getNumGroups();
37                 vector<string> getNamesOfGroups();      
38                 bool isValidGroup(string);  //return true if string is a valid group
39                 string getGroup(string);        //returns group of a specific sequence
40                 
41                 int getNumSeqs(string);         //returns the number of unique sequences in a specific group
42                 vector<Sequence> getSeqs(string); //returns unique sequences in a specific group
43                 map<string, string> getNameMap(string); //returns seqName -> namesOfRedundantSeqs separated by commas for a specific group - the name file format, but each line is parsed by group.
44                 
45                 int getSeqs(string, string, bool); //prints unique sequences in a specific group to a file - group, filename, uchimeFormat=false
46                 int getNameMap(string, string); //print seqName -> namesOfRedundantSeqs separated by commas for a specific group - group, filename
47                 
48                 map<string, string> getAllSeqsMap(){ return allSeqsMap; }  //returns map where the key=sequenceName and the value=representativeSequence - helps us remove duplicates after group by group processing
49         private:
50         
51                 GroupMap* groupMap;
52                 MothurOut* m;
53         
54                 int numSeqs;
55                 map<string, string> allSeqsMap;
56                 map<string, vector<Sequence> > seqs; //a vector for each group
57                 map<string, map<string, string> > nameMapPerGroup; //nameMap for each group
58 };
59
60 #endif
61