jweinst1
3/12/2020 - 3:17 AM

A data structure able of storing sequences of DNA as a trie.

A data structure able of storing sequences of DNA as a trie.

class DNATrie {
public:
   DNATrie(): _count(0){}
   ~DNATrie(){}
   
   const DNANode& getRoot() const
   {
       return _root;
   }
   
   size_t getCount() const
   {
       return _count;
   }
   
   DNATrie& operator<<(const char* input)
   {
       DNAChunk chk(input);
       _root.insert(chk.dna, chk.dsize);
       ++_count;
       return *this;
   }
   
   DNATrie& operator<<(const DNAChunk& input)
   {
       _root.insert(input.dna, input.dsize);
       ++_count;
       return *this;
   }
   
   long operator[](const char* input)
   {
       DNAChunk chk(input);
       return _root.find(chk.dna, chk.dsize);
   }
   
   
private:
   size_t _count;
   DNANode _root;
};