]> git.donarmstrong.com Git - mothur.git/blob - fastamap.h
fixed memory leak in parsimony calculator and added progress bars to parsimony and...
[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 "mothur.h"
16 #include "utilities.hpp"
17
18
19 /* This class represents the fasta file.  It reads a fasta file a populates the internal data structure "data".
20 Data is a map where the key is the sequence and the value is a struct containing the sequences groupname, 
21 a list of the sequences names who have the same sequence and a number of how many sequence names there are. */
22
23
24 class FastaMap  {
25
26 public:
27         FastaMap() {};
28         ~FastaMap() {};
29         
30         string getGroupName(string);  //pass a sequence name get its group
31         int getGroupNumber(string);  //pass a sequence name get number of sequence in its group
32         string getNames(string);        //pass a sequence get the string of names in the group separated by ','s.
33         void push_back(string, string); //sequencename, sequence
34         int sizeUnique();                                       //returns number of unique sequences
35         void printNamesFile(ostream&);          //produces a 2 column file with the groupname in the first column and the names in the second column - a names file.
36         void printCondensedFasta(ostream&);             //produces a fasta file.
37         void readFastaFile(ifstream&);
38         string getSequence(string);             //pass it a name of a sequence, it returns the sequence.
39
40 private:
41         struct group {
42                 string groupname;                                       //the group name for identical sequences, will be set to the first sequence found.
43                 int groupnumber;                                        //the number of sequence names with the same sequence.
44                 string names;                                           //the names of the sequence separated by ','.
45         };
46
47         map<string, group>  data;  //sequence, groupinfo        - condensed representation of file
48         map<string, string>  seqmap;  //name, sequence  -  uncondensed representation of file
49         map<string, group>::iterator it;
50         map<string, string>::iterator it2;
51 };
52
53 #endif