]> git.donarmstrong.com Git - mothur.git/blob - fastamap.h
finishing the container classes, combining read.otu and read.list commands. some...
[mothur.git] / fastamap.h
1 #ifndef FASTAMAP_H
2 #define FASTAMAP_H
3
4 /*
5  *  fastamap.h
6  *  mothur
7  *
8  *  Created by Sarah Westcott on 1/16/09.
9  *  Copyright 2009 Schloss Lab UMASS AMherst. All rights reserved.
10  *
11  */
12  
13 using namespace std;
14  
15 #include <iostream>
16 #include <fstream>
17 #include <string>
18 #include <map>
19 #include "utilities.hpp"
20
21
22 /* This class represents the fasta file.  It reads a fasta file a populates the internal data structure "data".
23 Data is a map where the key is the sequence and the value is a struct containing the sequences groupname, 
24 a list of the sequences names who have the same sequence and a number of how many sequence names there are. */
25
26
27 class FastaMap  {
28
29 public:
30         FastaMap() {};
31         ~FastaMap() {};
32         
33         string getGroupName(string);  //pass a sequence name get its group
34         int getGroupNumber(string);  //pass a sequence name get number of sequence in its group
35         string getNames(string);        //pass a sequence get the string of names in the group separated by ','s.
36         void push_back(string, string); //sequencename, groupname
37         void set(string, string, string); //sequencename, groupname, groupnumber, names.
38         void clear();
39         int size();                                     //returns number of unique sequences
40         void print(ostream&);           //produces a 2 column file with the groupname in the first column and the names in the second column.
41         void readFastaFile(ifstream&);
42
43 private:
44         struct group {
45                 string groupname;                                       //the group name for identical sequences, will be set to the first sequence found.
46                 int groupnumber;                                        //the number of sequence names with the same sequence.
47                 string names;                                           //the names of the sequence separated by ','.
48         };
49
50         map<string, group>  data;  //sequence, groupinfo
51         map<string, group>::iterator it;
52 };
53
54 #endif