00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __MatchHashEntry_h__
00010 #define __MatchHashEntry_h__
00011
00012 #ifdef HAVE_CONFIG_H
00013 #include "config.h"
00014 #endif
00015
00016 #include "libGenome/gnClone.h"
00017 #include <iostream>
00018 #include <set>
00019 #include "libMems/Match.h"
00020
00021 namespace mems {
00022
00030 class MatchHashEntry : public Match
00031 {
00032 public:
00033 enum MemType
00034 {
00035 seed,
00036 extended
00037 };
00038
00039 public:
00040 MatchHashEntry();
00048 MatchHashEntry( const uint seq_count, const gnSeqI mersize, const MemType m_type = seed );
00049 MatchHashEntry* Clone() const;
00050 MatchHashEntry* Copy() const;
00051 virtual void Free();
00052 MatchHashEntry( const MatchHashEntry& mhe ){ *this = mhe; }
00053 MatchHashEntry& operator=(const MatchHashEntry& mhe);
00054
00056 boolean operator==(const MatchHashEntry& mhe) const;
00057
00058
00060 boolean Extended() const{return m_extended;}
00062 void SetExtended(boolean extended){m_extended = extended;}
00064 uint MerSize() const{return m_mersize;}
00065
00071 virtual void CalculateOffset();
00072
00074 int64 Offset() const{return m_offset;};
00075
00077 void SetOffset(int64 offset){m_offset = offset;};
00078
00079 static boolean offset_lessthan(const MatchHashEntry& a, const MatchHashEntry& b);
00080 static boolean start_lessthan_ptr(const MatchHashEntry* a, const MatchHashEntry* b);
00081 static bool start_lessthan(const MatchHashEntry& a, const MatchHashEntry& b);
00082 static boolean strict_start_lessthan_ptr(const MatchHashEntry* a, const MatchHashEntry* b);
00085 static int64 end_to_start_compare(const MatchHashEntry& a, const MatchHashEntry& b);
00086 static int64 start_compare(const MatchHashEntry& a, const MatchHashEntry& b);
00087
00096 boolean Contains(const MatchHashEntry& mhe) const;
00097
00098 private:
00099
00100 boolean m_extended;
00101 gnSeqI m_mersize;
00102 int64 m_offset;
00103 };
00104
00105 inline
00106 MatchHashEntry* MatchHashEntry::Copy() const
00107 {
00108 return m_allocateAndCopy(*this);
00109 }
00110 inline
00111 void MatchHashEntry::Free()
00112 {
00113 m_free(this);
00114 }
00115
00116 inline
00117 bool MatchHashEntry::start_lessthan(const MatchHashEntry& a, const MatchHashEntry& b){
00118 return start_lessthan_ptr(&a, &b);
00119 }
00120
00121 class MheCompare {
00122 public:
00123 bool operator()(const MatchHashEntry* a, const MatchHashEntry* b) const{
00124 if( a->FirstStart() > b->FirstStart() ){
00125 return true;
00126 }else if( a->FirstStart() == b->FirstStart() ){
00127
00128 for( size_t i = a->FirstStart(); i < a->SeqCount(); i++ )
00129 {
00130 if( a->LeftEnd(i) == NO_MATCH && b->LeftEnd(i) != NO_MATCH )
00131 return true;
00132 else if( a->LeftEnd(i) != NO_MATCH && b->LeftEnd(i) == NO_MATCH )
00133 return false;
00134 }
00135
00136 if(a->Contains(*b) || b->Contains(*a)){
00137 return false;
00138 }else
00139 return MatchHashEntry::strict_start_lessthan_ptr(a, b);
00140 }
00141 return false;
00142 }
00143 };
00144
00145 }
00146
00147 #endif // __MatchHashEntry_h__