]> git.donarmstrong.com Git - mothur.git/blob - kmerdb.hpp
fixed bug with shhh.flow from file path name in write functions, added "smart" featur...
[mothur.git] / kmerdb.hpp
1 #ifndef KMERDB_HPP
2 #define KMERDB_HPP
3
4 /*
5  *  kmerdb.h
6  *  
7  *
8  *  Created by Pat Schloss on 12/16/08.
9  *  Copyright 2008 Patrick D. Schloss. All rights reserved.
10  *
11  *      This class is a child class of the Database class, which stores the template sequences as a kmer table and provides
12  *      a method of searching the kmer table for the sequence with the most kmers in common with a query sequence.
13  *      kmerLocations is the primary storage variable that is a two-dimensional vector where each row represents the
14  *      different number of kmers and each column contains the index to sequences that use that kmer.
15  *
16  *      Construction of an object of this type will first look for an appropriately named database file and if it is found
17  *      then will read in the database file (readKmerDB), otherwise it will generate one and store the data in memory
18  *      (generateKmerDB)
19
20  */
21
22 #include "mothur.h"
23 #include "database.hpp"
24
25 class KmerDB : public Database {
26         
27 public:
28         KmerDB(string, int);
29         KmerDB(const KmerDB& kdb) : kmerSize(kdb.kmerSize), maxKmer(kdb.maxKmer), count(kdb.count), kmerDBName(kdb.kmerDBName), kmerLocations(kdb.kmerLocations), Database(kdb) {}
30         KmerDB();
31         ~KmerDB();
32         
33         void generateDB();
34         void addSequence(Sequence);
35         vector<int> findClosestSequences(Sequence*, int);
36         void readKmerDB(ifstream&);
37         int getCount(int);  //returns number of sequences with that kmer number
38         vector<int> getSequencesWithKmer(int);  //returns vector of sequences that contain kmer passed in
39         int getReversed(int);  //returns reverse compliment kmerNumber 
40         int getMaxKmer() { return maxKmer; }
41         
42 private:
43         
44         int kmerSize;
45         int maxKmer, count;
46         string kmerDBName;
47         vector<vector<int> > kmerLocations;
48 };
49
50 #endif